mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-26 19:07:17 +00:00
- 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)
115 lines
3.6 KiB
JavaScript
115 lines
3.6 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const test = require("node:test");
|
|
|
|
const { startPluginHost } = require("./hostBootstrap.cjs");
|
|
|
|
test("explicitly disabling NETCATTY_PLUGIN_DEV leaves the plugin host and stored plugin data untouched", () => {
|
|
const effects = [];
|
|
assert.equal(startPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "0" },
|
|
createService() { effects.push("create"); },
|
|
registerShutdown() { effects.push("register"); },
|
|
logger: { error() { effects.push("error"); } },
|
|
}), null);
|
|
assert.deepEqual(effects, []);
|
|
});
|
|
|
|
test("default startup enables the plugin host during database plugin development", async () => {
|
|
let initialized = 0;
|
|
const service = {
|
|
manager: {
|
|
async initialize() { initialized += 1; },
|
|
async shutdown() {},
|
|
},
|
|
};
|
|
assert.equal(startPluginHost({
|
|
env: {},
|
|
createService: () => service,
|
|
registerShutdown() {},
|
|
logger: { error() {} },
|
|
}), service);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(initialized, 1);
|
|
});
|
|
|
|
test("synchronous plugin host construction failure leaves Netcatty available", () => {
|
|
const errors = [];
|
|
let registered = 0;
|
|
const service = startPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService() { throw new Error("corrupt plugin database"); },
|
|
registerShutdown() { registered += 1; },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
});
|
|
assert.equal(service, null);
|
|
assert.equal(registered, 0);
|
|
assert.match(errors[0][1].message, /corrupt plugin database/);
|
|
});
|
|
|
|
test("created plugin host initializes and registers one shutdown owner", async () => {
|
|
let initialized = 0;
|
|
let shutdown = 0;
|
|
let shutdownHandler;
|
|
const service = {
|
|
manager: {
|
|
async initialize() { initialized += 1; },
|
|
async shutdown() { shutdown += 1; },
|
|
},
|
|
};
|
|
assert.equal(startPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => service,
|
|
registerShutdown(handler) { shutdownHandler = handler; },
|
|
logger: { error() {} },
|
|
}), service);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(initialized, 1);
|
|
await shutdownHandler();
|
|
assert.equal(shutdown, 1);
|
|
});
|
|
|
|
test("asynchronous initialization failure closes and leaves the host unavailable", async () => {
|
|
let shutdown = 0;
|
|
let shutdownHandler;
|
|
const errors = [];
|
|
const service = {
|
|
manager: {
|
|
initialize: async () => { throw new Error("recovery failed"); },
|
|
shutdown: async () => { shutdown += 1; },
|
|
},
|
|
};
|
|
assert.equal(startPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => service,
|
|
registerShutdown(handler) { shutdownHandler = handler; },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
}), service);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(shutdown, 1);
|
|
assert.match(errors[0][1].message, /recovery failed/);
|
|
await shutdownHandler();
|
|
assert.equal(shutdown, 2);
|
|
});
|
|
|
|
test("failure while registering shutdown closes the constructed host", async () => {
|
|
let shutdown = 0;
|
|
const errors = [];
|
|
const service = startPluginHost({
|
|
env: { NETCATTY_PLUGIN_DEV: "1" },
|
|
createService: () => ({
|
|
manager: {
|
|
async initialize() {},
|
|
async shutdown() { shutdown += 1; },
|
|
},
|
|
}),
|
|
registerShutdown() { throw new Error("shutdown registry unavailable"); },
|
|
logger: { error(...args) { errors.push(args); } },
|
|
});
|
|
assert.equal(service, null);
|
|
await new Promise((resolve) => setImmediate(resolve));
|
|
assert.equal(shutdown, 1);
|
|
assert.match(errors[0][1].message, /shutdown registry unavailable/);
|
|
});
|