feat(skins): add component authoring workflow

This commit is contained in:
illusia committed 2026-10-10 15:53:51 +08:00
1 parent 96c29394f3
commit 0c4cc344ef
25 files changed
+2013 -58

No files matched your search

+28
View File
@@ -229,6 +229,34 @@ 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 layout = {
schemaVersion: 1,
pages: { voice: { desktop: { "skin.voice.runtime_plugin_root_voice-toolbar": { order: 2, visible: true } } } },
};
const archiveWithLayout = createZip([
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV4, layout: "layout.json" }))],
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
["plugins.json", Buffer.from(JSON.stringify(plugins))],
["plugins/voice-toolbar/index.js", Buffer.from("export const render = () => document.createElement('button');")],
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
["layout.json", Buffer.from(JSON.stringify(layout))],
]);
const layoutSaved = await registry.save(archiveWithLayout, "sample-skin");
assert.equal(layoutSaved.id, "sample-skin");
assert.deepEqual(await registry.readArchive("sample-skin"), archiveWithLayout);
const invalidLayoutArchive = createZip([
["manifest.json", Buffer.from(JSON.stringify({ ...manifestV4, layout: "layout.json" }))],
["skin.css", Buffer.from('[data-ws-part="app"] { position: fixed; }')],
["plugins.json", Buffer.from(JSON.stringify(plugins))],
["plugins/voice-toolbar/index.js", Buffer.from("export {}; ")],
["plugins/voice-toolbar/style.css", Buffer.from(".toolbar { color: teal; }")],
["plugins/voice-toolbar/assets/icon.png", Buffer.from([1, 2, 3, 4])],
["layout.json", Buffer.from(JSON.stringify({ schemaVersion: 1, pages: { voice: { desktop: { "voice.not-registered": { order: 2 } } } } }))],
]);
await assert.rejects(registry.save(invalidLayoutArchive, "sample-skin"), (error: unknown) => error instanceof SkinRegistryError && error.code === "SKIN_LAYOUT_INVALID");
const wasmPlugins = {
schemaVersion: 1,
plugins: [{
+1 -1
View File
@@ -463,7 +463,7 @@ function parseManifest(bytes: Buffer): ParsedSkinManifest {
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(version) || !/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(minAppVersion)) throw new SkinRegistryError("Skin and minimum app versions must use semantic version format.", "SKIN_MANIFEST_INVALID");
const entry = read("entry", 120);
const readOptional = (key: string, max: number): string | undefined => value[key] == null ? undefined : read(key, max);
const layout = schemaVersion === 2 ? read("layout", 120) : schemaVersion === 3 && value.layout != null ? read("layout", 120) : undefined;
const layout = schemaVersion === 2 ? read("layout", 120) : schemaVersion >= 3 ? readOptional("layout", 120) : undefined;
const content = readOptional("content", 120);
const components = schemaVersion >= 3 && value.components != null ? read("components", 120) : undefined;
const plugins = schemaVersion === 4 ? read("plugins", 120) : undefined;