Files
Netcatty/electron/plugins/runtime/utilityRuntime.mjs
T
ryan-wong-coder 7a47187e37 feat(plugins): add isolated plugin host runtime (#2303)
* feat(plugins): add isolated plugin host runtime

* test(plugins): build runtime dependencies before tests

* fix(plugins): harden runtime lifecycle and recovery

* fix(plugins): harden runtime extension boundaries

* fix(plugins): enforce runtime integrity boundaries

* fix(plugins): await utility process exit

* fix(plugins): harden utility process containment

* fix(plugins): close runtime recovery gaps

* fix(plugins): harden runtime lifecycle boundaries
2026-07-19 08:22:17 +08:00

25 lines
868 B
JavaScript

import { register } from "node:module";
import process from "node:process";
function messageData(value) {
return value && typeof value === "object" && "data" in value ? value.data : value;
}
const bootstrap = await new Promise((resolve) => {
process.parentPort.once("message", (event) => resolve(messageData(event)));
});
if (bootstrap?.type !== "netcatty-plugin:bootstrap") {
throw new Error("Missing plugin utility runtime bootstrap");
}
register(new URL("./pluginModuleLoader.mjs", import.meta.url), {
parentURL: import.meta.url,
data: { mappings: bootstrap.config.moduleMappings },
});
const { startPluginRuntime } = await import("./runtimePeer.mjs");
await startPluginRuntime({
port: process.parentPort,
config: bootstrap.config,
loadPlugin: (entryUrl) => import(entryUrl),
});
process.parentPort.postMessage({ type: "netcatty-plugin:ready" });