feat: rebuild plugin UI with host rendering and standard settings (#4053)

* feat: rebuild plugin pages with host rendering and native settings

* fix(plugins): contain host-view errors, isolate editing, and migrate fixtures

* fix(plugins): migrate remaining permission fixture hosts
This commit is contained in:
陈大猫 authored and GitHub committed 2026-10-28 23:08:31 -07:00
1 parent 7cd57adcea
commit d5a03606b7
227 files changed
+8298 -4172

No files matched your search

-46
View File
@@ -139,49 +139,3 @@ test("browser runtime import maps accept reviewed host modules without protocol
});
assert.equal(await moduleResponse.text(), "export const ui = true;\n");
});
test("custom views load packaged resources only with a network-denying document policy", async (context) => {
const roots = createRoots(context);
fs.writeFileSync(path.join(roots.packageRoot, "view.html"), "<!doctype html><script src=\"view.js\"></script>\n");
fs.writeFileSync(path.join(roots.packageRoot, "view.js"), "globalThis.ready = true;\n");
fs.writeFileSync(path.join(roots.packageRoot, "view.svg"), "<svg xmlns=\"http://www.w3.org/2000/svg\"></svg>\n");
let handler;
const protocol = new PluginProtocol(roots);
protocol.registerSession({
protocol: {
handle(_scheme, callback) { handler = callback; },
unhandle() {},
},
});
const registration = protocol.registerView({
pluginId: "com.example.view",
packageRoot: roots.packageRoot,
entry: "view.html",
});
const page = await handler({ method: "GET", url: registration.url });
assert.equal(page.status, 200);
assert.match(page.headers.get("content-security-policy"), /connect-src 'none'/u);
assert.match(page.headers.get("content-security-policy"), /frame-src 'none'/u);
assert.match(page.headers.get("permissions-policy"), /clipboard-write=\(\)/u);
const svgRegistration = protocol.registerView({
pluginId: "com.example.svg-view",
packageRoot: roots.packageRoot,
entry: "view.svg",
});
const svgPage = await handler({ method: "GET", url: svgRegistration.url });
assert.equal(svgPage.headers.get("content-type"), "image/svg+xml");
assert.match(svgPage.headers.get("content-security-policy"), /worker-src 'none'/u);
assert.match(svgPage.headers.get("permissions-policy"), /camera=\(\)/u);
assert.equal((await handler({
method: "GET",
url: `netcatty-plugin://${registration.token}/package/view.js`,
})).status, 200);
assert.equal((await handler({
method: "GET",
url: `netcatty-plugin://${registration.token}/__host/runtime/browserRuntime.mjs`,
})).status, 404);
assert.equal((await handler({
method: "GET",
url: `netcatty-plugin://${registration.token}/index.html`,
})).status, 404);
});