feat(skin): support approved Wasm plugin prototype

This commit is contained in:
illusia committed 2026-10-10 15:53:50 +08:00
1 parent 26b74c5be4
commit 7993b38eee
13 files changed
+321 -24

No files matched your search

+26
View File
@@ -229,6 +229,32 @@ test("server validates v4 plugin manifests and package files without executing a
assert.equal(saved.id, "sample-skin");
assert.deepEqual(await registry.readArchive("sample-skin"), archive);
const wasmPlugins = {
schemaVersion: 1,
plugins: [{
id: "bounded-widget",
name: "Bounded widget",
version: "1.0.0",
apiVersion: 1,
runtime: "wasm",
page: "voice",
mode: "widget",
entry: "plugins/bounded-widget/index.wasm",
assets: [],
permissions: [],
}],
};
const wasmManifest = { ...manifestV4, id: "wasm-skin" };
const wasmArchive = createZip([
["manifest.json", Buffer.from(JSON.stringify(wasmManifest))],
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
["plugins.json", Buffer.from(JSON.stringify(wasmPlugins))],
["plugins/bounded-widget/index.wasm", Buffer.from([0, 97, 115, 109, 1, 0, 0, 0])],
]);
const wasmSaved = await registry.save(wasmArchive, "wasm-skin");
assert.equal(wasmSaved.id, "wasm-skin");
assert.deepEqual(await registry.readArchive("wasm-skin"), wasmArchive);
const missingEntry = createZip([
["manifest.json", Buffer.from(JSON.stringify(manifestV4))],
["skin.css", Buffer.from("[data-ws-part=app] { color: teal; }")],
+2
View File
@@ -257,6 +257,8 @@ function validateSkinArchive(bytes: Buffer, expectedId?: string): { manifest: Pa
if (lowerPath.endsWith(".js")) {
if (data.byteLength > SKIN_RUNTIME_PLUGIN_SOURCE_LIMIT_BYTES) throw new SkinRegistryError("Plugin entry files must be smaller than 256 KiB.", "SKIN_RUNTIME_PLUGIN_SOURCE_SIZE");
decodeUtf8(data, "Plugin entry files must contain valid UTF-8.");
} else if (lowerPath.endsWith(".wasm")) {
if (data.byteLength > SKIN_RUNTIME_PLUGIN_SOURCE_LIMIT_BYTES) throw new SkinRegistryError("Wasm plugin entry files must be smaller than 256 KiB.", "SKIN_RUNTIME_PLUGIN_SOURCE_SIZE");
} else if (lowerPath.endsWith(".css")) {
if (data.byteLength > SKIN_RUNTIME_PLUGIN_STYLE_LIMIT_BYTES) throw new SkinRegistryError("Plugin style files must be smaller than 512 KiB.", "SKIN_RUNTIME_PLUGIN_STYLE_SIZE");
decodeUtf8(data, "Plugin style files must contain valid UTF-8.");