Files
Netcatty/electron/plugins/hostBootstrap.cjs
T
陈大猫 f4a087e890 feat(plugins): add host-rendered IDE primitives, STARTTLS/SSH bindings, file/secret APIs, and pooled image rasterizer (#4437)
- Add host-rendered native IDE primitives (PluginCodeEditor/Monaco, PluginDataGrid/@tanstack/react-virtual, PluginSplitPane, PluginErCanvas) with Shadow DOM slot projection (zero iframes, zero plugin JS in renderer)
- Expand Remote DOM budgets, expose full 22 Netcatty semantic CSS tokens, add dblclick/contextmenu/scroll/selection events, cursor-anchored PluginPopover, database theme icon, and full-bleed chrome flag
- Add dynamic user-approved TCP/TLS byte streams (incl. localhost opt-in blocking internal control ports), in-band STARTTLS upgrade with cert fingerprint confirmation, durable revocable Vault SSH host bindings, plugin-owned encrypted secrets, native ui.openFile/saveFile streaming handles, 4 MiB clipboard, and prefix-filtered storage.keys
- Optimize plugin view image pipeline with pooled sandboxed rasterizer window (auto-destroyed on idle/error/dispose), LRU version+hash cache in PluginViewResources, transient failure eviction in HostDrawnViewHost, renderer-side session deduplication, and RemoteImageElement cache + retry
- Temporarily enable plugin host by default in hostBootstrap.cjs (marked TODO(revert), opt-out via NETCATTY_PLUGIN_DEV=0)
2026-11-26 17:52:27 +08:00

34 lines
1.1 KiB
JavaScript

"use strict";
function startPluginHost(options) {
// TODO(revert): temporarily enabled by default for database plugin development
if (options.env?.NETCATTY_PLUGIN_DEV === "0") return null;
const reportFailure = (message, error) => {
try { options.logger?.error?.(message, error); } catch {}
};
let service;
try {
service = options.createService();
const initialization = Promise.resolve(service.manager.initialize());
options.registerShutdown(() => service.manager.shutdown());
void initialization.catch(async (error) => {
reportFailure("[Plugins] Failed to initialize plugin host:", error);
try {
await service.manager.shutdown();
} catch (shutdownError) {
reportFailure("[Plugins] Failed to close unavailable plugin host:", shutdownError);
}
});
return service;
} catch (error) {
reportFailure("[Plugins] Failed to create plugin host:", error);
if (typeof service?.manager?.shutdown === "function") {
try { void Promise.resolve(service.manager.shutdown()).catch(() => {}); } catch {}
}
return null;
}
}
module.exports = { startPluginHost };