feat(skins): add persistent voice workspace API and align KAAK

This commit is contained in:
illusia committed 2026-10-24 13:30:50 +08:00
1 parent 0af3236c30
commit 452e6f09ca
24 files changed
+451 -21

No files matched your search

+2
View File
@@ -154,6 +154,8 @@ export interface LocalPreferences {
outputVolume?: number;
notificationVolume?: number;
lastNickname?: string;
/** Successful voice connection history, independent of the selected skin. */
hasConnected?: boolean;
inputDeviceId?: string;
volumesByUid?: Record<string, number>;
}
+2 -2
View File
@@ -46,11 +46,11 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.122",
version: "3.1.125",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired WebSpeak skin with a split-screen connection home, searchable server header, TeamSpeak banner, nested channel members, unified chat with local history, and a compact audio dock.",
minAppVersion: "0.2.7",
minAppVersion: "0.2.8",
installedAt: 0,
builtIn: true,
},
+5 -1
View File
@@ -486,7 +486,9 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.122");
assert.equal(skin.version, "3.1.125");
assert.deepEqual(skin.workspace, { apiVersion: 1, mode: "persistent" });
assert.equal(skin.minAppVersion, "0.2.8");
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
assert.equal(skin.schemaVersion, 3);
const baseMessages = skin.contentData?.locales["zh-CN"]?.messages ?? {};
@@ -499,6 +501,8 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
}
const home = skin.pluginData?.components.find((component) => component.page === "home");
const voice = skin.pluginData?.components.find((component) => component.page === "voice");
assert.ok(voice?.permissions.includes("voice.connect"));
assert.match(JSON.stringify(voice?.root), /"widget":"voice.connection-status"/);
assert.deepEqual(skin.pluginData?.components.map((component) => [component.id, component.mode]), [
["kaak-home", "surface"],
["kaak-workspace", "surface"],
+7 -1
View File
@@ -1,3 +1,4 @@
import { parseSkinWorkspacePolicy, type SkinWorkspacePolicy } from "../../../src/shared/skin-workspace.js";
import { unzipSync } from "fflate";
import { compileSkinCss as compileSharedSkinCss, rewriteSkinCssAssets, SkinCssValidationError } from "../../../src/shared/skin-css.js";
@@ -38,6 +39,7 @@ export interface SkinManifest {
content?: string;
components?: string;
plugins?: string;
workspace?: SkinWorkspacePolicy;
minAppVersion: string;
preview?: string;
}
@@ -405,7 +407,7 @@ function parseManifest(bytes: Uint8Array): SkinManifest {
if (schemaVersion !== 1 && schemaVersion !== 2 && schemaVersion !== 3 && schemaVersion !== 4) throw new SkinPackError("This skin package version is not supported.", "SKIN_SCHEMA_VERSION");
if (schemaVersion >= 2) {
const fields = new Set(["schemaVersion", "packageType", "id", "name", "version", "author", "license", "description", "entry", "layout", "permissions", "content", "minAppVersion", "preview"]);
if (schemaVersion >= 3) { fields.delete("permissions"); fields.add("components"); }
if (schemaVersion >= 3) { fields.delete("permissions"); fields.add("components"); fields.add("workspace"); }
if (schemaVersion === 4) fields.add("plugins");
const unknown = Object.keys(raw).find((key) => !fields.has(key));
if (unknown) throw new SkinPackError(`Version 2 skin manifest contains an unsupported field: ${unknown}.`, "SKIN_MANIFEST_INVALID");
@@ -428,6 +430,9 @@ function parseManifest(bytes: Uint8Array): SkinManifest {
if (schemaVersion === 1 && (raw.layout !== undefined || raw.packageType !== undefined || raw.permissions !== undefined || raw.components !== undefined || raw.plugins !== undefined)) {
throw new SkinPackError("Version 1 skin packages cannot declare layout or plugin fields.", "SKIN_SCHEMA_VERSION");
}
let workspace: SkinWorkspacePolicy | undefined;
try { workspace = parseSkinWorkspacePolicy(raw.workspace, schemaVersion); }
catch (error) { throw new SkinPackError(error instanceof Error ? error.message : "Invalid workspace policy.", "SKIN_MANIFEST_INVALID"); }
const id = stringField("id", 80)!;
if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/.test(id) || id.startsWith("builtin.")) throw new SkinPackError("Skin IDs must be unique lowercase IDs and cannot use the reserved builtin. prefix.", "SKIN_ID_INVALID");
const entry = stringField("entry", 120)!;
@@ -461,6 +466,7 @@ function parseManifest(bytes: Uint8Array): SkinManifest {
components,
plugins,
minAppVersion,
...(workspace ? { workspace } : {}),
preview,
};
}