feat(skins): add complete KAAK voice workspace skin

This commit is contained in:
illusia committed 2026-10-10 15:53:51 +08:00
1 parent f2e5695bb6
commit 54805f8928
13 files changed
+1809 -1191

No files matched your search

+6 -3
View File
@@ -7,7 +7,7 @@ import {
listPublicSkins,
} from "./skin-catalog.js";
test("skin catalog always includes the three protected built-ins and exposes only enabled custom skins", async () => {
test("skin catalog always includes protected built-ins and exposes only enabled custom skins", async () => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async () => new Response(JSON.stringify({
defaultSkinId: "sample-skin",
@@ -15,6 +15,7 @@ test("skin catalog always includes the three protected built-ins and exposes onl
{ id: "sample-skin", name: "Sample", version: "1.0.0", author: "Test", license: "MIT", minAppVersion: "0.2.6", installedAt: 1, enabled: true },
{ id: "disabled-skin", name: "Disabled", version: "1.0.0", author: "Test", license: "MIT", minAppVersion: "0.2.6", installedAt: 2, enabled: false },
{ id: "community.illusia-voice", name: "Spoofed", version: "9.9.9", author: "Other", license: "MIT", minAppVersion: "0.0.1", installedAt: 3 },
{ id: "community.kaak-voice", name: "Spoofed KAAK", version: "9.9.9", author: "Other", license: "MIT", minAppVersion: "0.0.1", installedAt: 4 },
],
}), { status: 200, headers: { "content-type": "application/json" } });
@@ -24,13 +25,15 @@ test("skin catalog always includes the three protected built-ins and exposes onl
"builtin.light",
"builtin.dark",
"community.illusia-voice",
"community.kaak-voice",
"sample-skin",
]);
assert.deepEqual(BUILTIN_SKIN_CATALOG.map((skin) => skin.id), skins.slice(0, 3).map((skin) => skin.id));
assert.deepEqual(BUILTIN_SKIN_CATALOG.map((skin) => skin.id), skins.slice(0, 4).map((skin) => skin.id));
assert.equal(getPublicDefaultSkinId(), "sample-skin");
assert.equal(isPublicSkinEnabled("sample-skin"), true);
assert.equal(isPublicSkinEnabled("disabled-skin"), false);
assert.equal(isPublicSkinEnabled("community.illusia-voice"), true);
assert.equal(isPublicSkinEnabled("community.kaak-voice"), true);
} finally {
globalThis.fetch = originalFetch;
}
@@ -45,7 +48,7 @@ test("invalid or disabled instance defaults safely fall back to the protected da
try {
const skins = await listPublicSkins();
assert.equal(skins.length, 3);
assert.equal(skins.length, 4);
assert.equal(getPublicDefaultSkinId(), "builtin.light");
} finally {
globalThis.fetch = originalFetch;
+17 -2
View File
@@ -3,6 +3,7 @@ import { createSkinOperation, type SkinLoadOptions } from "./skin-operation.js";
export type { SkinCatalogEntry } from "../../../src/shared/skin-catalog.js";
export const BUILTIN_ILLUSIA_SKIN_ID = "community.illusia-voice";
export const BUILTIN_KAAK_SKIN_ID = "community.kaak-voice";
export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
@@ -42,9 +43,21 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
builtIn: true,
previewKind: "illusia",
},
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.0.0",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A complete dark voice workspace with server switching, channels, chat, members, and host-owned voice controls.",
minAppVersion: "0.2.7-preview",
installedAt: 0,
builtIn: true,
},
];
const BUILTIN_ILLUSIA_PACKAGE_URL = "/skins/illusia-voice.wskin";
const BUILTIN_KAAK_PACKAGE_URL = "/skins/kaak-voice.wskin";
let publicDirectoryLoaded = false;
let publicEnabledSkinIds = new Set<string>(BUILTIN_SKIN_CATALOG.map((skin) => skin.id));
let publicDefaultSkinId = "builtin.light";
@@ -60,7 +73,9 @@ export function isPublicSkinEnabled(id: string): boolean {
}
export function getBundledSkinPackageUrl(id: string): string | null {
return id === BUILTIN_ILLUSIA_SKIN_ID ? BUILTIN_ILLUSIA_PACKAGE_URL : null;
if (id === BUILTIN_ILLUSIA_SKIN_ID) return BUILTIN_ILLUSIA_PACKAGE_URL;
if (id === BUILTIN_KAAK_SKIN_ID) return BUILTIN_KAAK_PACKAGE_URL;
return null;
}
export async function listPublicSkins(options: SkinLoadOptions = {}): Promise<SkinCatalogEntry[]> {
@@ -76,7 +91,7 @@ export async function listPublicSkins(options: SkinLoadOptions = {}): Promise<Sk
const directorySkins = (payload as { skins: unknown[] }).skins.flatMap((value) => {
if (!value || typeof value !== "object") return [];
const skin = value as Record<string, unknown>;
if (typeof skin.id !== "string" || !/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/.test(skin.id) || skin.id.startsWith("builtin.") || skin.id === BUILTIN_ILLUSIA_SKIN_ID) return [];
if (typeof skin.id !== "string" || !/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/.test(skin.id) || skin.id.startsWith("builtin.") || BUILTIN_SKIN_CATALOG.some((entry) => entry.id === skin.id)) return [];
if ([skin.name, skin.version, skin.author, skin.license, skin.minAppVersion].some((field) => typeof field !== "string")) return [];
const previewUrl = typeof skin.previewUrl === "string" && skin.previewUrl === `/api/skins/${skin.id}/preview` ? skin.previewUrl : undefined;
return [{
+36 -8
View File
@@ -456,19 +456,47 @@ test("a v4 surface cannot compete with a v3 surface on the same public page", as
);
});
test("the distributable KAAK v3 package validates end to end", async () => {
test("the distributable KAAK package provides full home and voice surfaces", async () => {
const archive = await readFile(new URL("../../../docs/examples/kaak-voice.wskin", import.meta.url));
const bundledArchive = await readFile(new URL("../../public/skins/kaak-voice.wskin", import.meta.url));
assert.deepEqual(archive, bundledArchive, "the downloadable example and bundled skin stay in sync");
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.schemaVersion, 3);
assert.deepEqual(skin.pluginData?.components.map((component) => component.id), ["kaak-channel-sidebar", "kaak-members-sidebar"]);
assert.equal(skin.pluginData?.components[0].root.children?.[1].children?.[0].children?.[0].events?.dblclick, "join-channel");
assert.ok(skin.pluginData?.components[0].permissions.includes("session.members.read"));
assert.equal(skin.pluginData?.components[0].root.children?.[1].children?.[0].children?.[1].children?.[0].repeat?.path, "channel.members");
assert.ok(skin.css.includes('data-ws-plugin-part="kaak-channel-sidebar.channel-row"'));
assert.ok(skin.css.includes('data-ws-plugin-part="kaak-channel-sidebar.channel-members"'));
assert.ok(skin.css.includes('data-ws-plugin-part="kaak-members-sidebar.member-row-content"'));
const home = skin.pluginData?.components.find((component) => component.page === "home");
const voice = skin.pluginData?.components.find((component) => component.page === "voice");
assert.deepEqual(skin.pluginData?.components.map((component) => [component.id, component.mode]), [
["kaak-home", "surface"],
["kaak-workspace", "surface"],
]);
assert.ok(home?.permissions.includes("ui.surface.replace"));
assert.ok(voice?.permissions.includes("ui.surface.replace"));
assert.ok(voice?.permissions.includes("servers.quickList.switch"));
assert.ok(voice?.permissions.includes("session.channels.read"));
assert.ok(voice?.permissions.includes("session.members.read"));
assert.ok(voice?.permissions.includes("chat.channel.read"));
assert.ok(voice?.permissions.includes("chat.channel.send"));
assert.ok(voice?.permissions.includes("audio.microphone.control"));
assert.ok(voice?.permissions.includes("audio.output.control"));
assert.ok(voice?.permissions.includes("voice.screenShare.control"));
function findPart(node: SkinPluginNode | undefined, part: string): SkinPluginNode | undefined {
if (!node) return undefined;
if (node.part === part) return node;
for (const child of node.children ?? []) {
const found = findPart(child, part);
if (found) return found;
}
return undefined;
}
const channelRow = findPart(voice?.root, "channel-row");
assert.equal(channelRow?.events?.click, "select-channel");
assert.equal(channelRow?.events?.dblclick, "join-channel");
assert.equal(findPart(voice?.root, "chat-input")?.bindValue, "message");
assert.equal(findPart(voice?.root, "screen-share-start")?.widget, "voice.screen-share-start");
assert.equal(findPart(voice?.root, "audio-controls")?.widget, "voice.audio-controls");
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace.channel-row"]'));
assert.ok(skin.css.includes("@media (max-width: 820px)"));
});
test("v4 skin packages validate Wasm entry ABI and cache it as application/wasm", async () => {