mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
feat(skin): support approved Wasm plugin prototype
This commit is contained in:
1 parent
26b74c5be4
commit
7993b38eee
13 files changed
+321
-24
No files matched your search
@@ -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; }")],
|
||||
|
||||
@@ -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.");
|
||||
|
||||
Reference in new issue
Block a user