mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat(skins): add complete KAAK voice workspace skin
This commit is contained in:
1 parent
f2e5695bb6
commit
54805f8928
13 files changed
+1809
-1191
No files matched your search
@@ -4,7 +4,7 @@
|
||||
|
||||
KOOK 语音界面参考仅覆盖用户授权的语音频道,语音区结构记录在[参考文档](./KOOK_VOICE_REFERENCE.zh-CN.md);发现、陪玩、活动、广告、商城和管理后台不属于复刻范围。
|
||||
|
||||
可导入的 KOOK 风格完整语音工作区测试包见[Harbor Voice Workspace](./examples/harbor-voice/README.zh-CN.md);它只复用 WebSpeak 的可信宿主控件和公开会话数据,不包含站点素材、运营页或后台。
|
||||
完整的 KOOK 语音端体验测试皮肤见 [KAAK](./examples/KAAK-VOICE.md):它复用 WebSpeak 可信宿主控件和公开 TeamSpeak 会话数据,不包含站点素材、运营页面或后台。Harbor Voice 保留为通用 surface 格式验证样例。
|
||||
|
||||
v3 保留安全的标准元素和属性白名单;组件可通过完整页面 surface 自己构建界面,不需要把聊天、音频或成员 UI 锁在固定宿主面板里。条件可比较权限化公开数据、重复项和皮肤本地状态,也可判断已登记公开集合是否为空。表单输入先留在宿主渲染的本地状态;宿主动作不能在逐字输入时触发,可在已提交的 `change`、表单提交或显式点击上触发。作者自定义代码逻辑由 v4 有界 Wasm 路径提供。生产构建中的 v4 Wasm 运行时已接入本地摘要授权、页面生命周期、动态 HTML/SVG 节点渲染、插件 CSS、权限化只读数据投影、宿主动作桥、语义挂载槽位和全局 worker 资源治理;目前支持 `session.status.read`、频道/成员/聊天、收藏/最近列表和音频/共享状态读取权限,以及 `ui.surface.replace`、`ui.input.read`。每份公开数据投影最多 48 KiB,只传清单准许的字段;Wasm 可生成自定义节点树、有限本地状态并响应命名 UI 事件。宿主动作只接受可信 UI 事件触发的同一轮输出中的单个请求,并重新检查插件权限、参数和当前会话;`dblclick` 可绑定到加入频道等已授权宿主动作。JavaScript 仍只校验和缓存,不执行。每个 v4 插件有独立布局根,用户可调整插件整体、组件根和 DOM 节点的位置、尺寸、显隐、安全外观及 Flex/Grid 同级显示顺序;`plugins.json` 可将 widget 放到公开页面的注册槽位,也可通过 surface 重做整页。这个边界能承载完整自定义客户端界面,但不等于已完成插件商城和作者管理平台;跨浏览器测试与独立安全审查尚未完成。
|
||||
|
||||
@@ -150,7 +150,7 @@ components.json 顶层接受 schemaVersion 1、2 或 3 和 components 数组。s
|
||||
|
||||
当前可选宿主控件 ID:`home.connection-form`、`app.skin-switcher`、`app.language-switcher`、`voice.channel-panel`、`voice.member-cards`、`voice.chat-panel`、`voice.audio-controls`、`voice.screen-share-player`、`voice.screen-share-start`、`voice.whisper-controls`、`voice.performance-panel`、`voice.connection-controls`、`voice.disconnect-control`。未知控件和同页重复控件会被拒绝;每个控件的状态和业务动作仍由 WebSpeak 内部处理。schema v3 会检查受保护控件所需权限:音频控件需 `audio.status.read`、`audio.microphone.control` 和 `audio.output.control`;聊天需 `chat.channel.read` 与 `chat.channel.send`;成员卡片需 `session.members.read` 及屏幕共享读取/控制权限;屏幕共享播放器需 `voice.screenShare.read` 与 `voice.screenShare.control`;悄悄话控件需对应状态读取和控制权限;断开/连接控件需 `voice.disconnect`。既有 v2 包维持旧校验行为,`voice.screen-share-start` 仍像此前一样要求 `voice.screenShare.control`。该控件仅能放在语音页;宿主按钮在可信点击处理器内直接启动屏幕采集,避免异步 Wasm 回调丢失浏览器瞬时用户激活。自定义 UI 可以完全用普通声明式节点搭建,不需要采用这些控件。只显示收藏时可用 `favorites.items` 和 `favorites.switch`;若要将收藏与最近连接放在同一自定义栏,可用 `servers.quickList` 数据与 `quickServers.switch` 动作。服务器目标始终使用本机生成的不透明令牌,不把地址、密码或身份材料交给组件。频道行也可把 `voice.joinChannel` 绑定到双击事件,切房继续走 TeamSpeak 原有权限和密码流程。v3 还提供经独立权限保护的麦克风/扬声器、输出音量、离开状态、悄悄话、断开连接和屏幕共享动作;它们只调用 WebSpeak 已有操作,屏幕采集仍由浏览器或操作系统询问用户。
|
||||
|
||||
示例包见 [KAAK voice 示例](./examples/KAAK-VOICE.md),其 components.json 展示了公开频道列表和在线成员侧栏;[Open Voice Surface](./examples/OPEN-VOICE-SURFACE.md) 展示了完整首页和语音工作区 surface,是格式验证脚手架。KAAK 的语音视觉参考来自用户授权进入的前两个语音房间;只记录布局,不保留服务器/房间标识、成员名或聊天内容。当前数据权限和宿主动作以[开放皮肤规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)中的清单为准。组件按本地用户授权后才渲染;权限对每个皮肤版本、页面和组件分别保存,可在宿主权限入口撤销。页面替换时,宿主会额外显示“返回标准界面”和“恢复内置皮肤”入口;拒绝授权或离开 surface 后,普通页面可立即恢复。
|
||||
示例包见 [KAAK voice 示例](./examples/KAAK-VOICE.md),其 components.json 使用完整首页与语音工作区 surface,展示收藏服务器、频道树、在线成员、聊天和可信语音控制的组合;[Open Voice Surface](./examples/OPEN-VOICE-SURFACE.md) 保留为通用格式验证脚手架。KAAK 的语音视觉参考来自用户授权进入的前两个语音房间;只记录布局,不保留服务器/房间标识、成员名或聊天内容。当前数据权限和宿主动作以[开放皮肤规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)中的清单为准。组件按本地用户授权后才渲染;权限对每个皮肤版本、页面和组件分别保存,可在宿主权限入口撤销。页面替换时,宿主会额外显示“返回标准界面”和“恢复内置皮肤”入口;拒绝授权或离开 surface 后,普通页面可立即恢复。
|
||||
|
||||
组件树有硬上限:components.json 256 KiB。schema v1/v2 上限为 32 个组件、每组件 256 个模板节点、16 层深度和 100 条重复记录;schema v3 上限为 128 个组件、每组件 2048 个模板节点、32 层深度和 250 个重复行,并允许 64 个本地标量状态与 64 个动作。Wasm 动态 UI 输出的 schema v4/v5/v6 有 256 KiB 总输出上限、最多 64 个组件、每个节点最多 64 个属性和 256 个子节点,并沿用每组件节点/深度限制;渲染器接受标准 HTML/SVG 元素及普通属性,而不是由元素/属性展示白名单限制。脚本、嵌入式浏览器、网络/导航属性、事件属性和行内 style 仍拒绝;样式通过经过隔离校验的插件 CSS 提供。包内图片通过专用资源字段引用,自定义元素映射为惰性 `div`。宿主只通过 `isTrusted` 用户事件发出剥离 DOM/Event 对象后的 `extension-event`,Wasm 侧只能经 `env.ui_input_read` 一次读取最多 64 KiB 的 JSON,包含插件本地状态、安全事件和宿主按插件读取权限投影的数据。每份数据投影最多 48 KiB,只含公开字段;地址、凭据、SDK 对象和未声明字段不会进入 guest。输入字段限长;生成界面中的 password/file/hidden 类型输入会拒绝。UI 循环已经接入 WebClient 授权生命周期,可把可信事件或最新数据快照作为下一次独立 Wasm 调用输入,最多串行排队 8 项并验证回调/状态归属;动作桥复核清单权限和会话状态。单个页面实例最多并发运行 2 个 Wasm worker,并限制最多排队 64 项。
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# KAAK voice skin
|
||||
|
||||
KAAK is a schema v3 open-skin package for WebSpeak's public connection page and voice workspace. It keeps TeamSpeak connection, channel, member, chat, favorite-server, audio, and screen-sharing behavior in the host. The desktop voice layout places the favorite-server rail, a declarative channel list with members nested under each channel, the active chat workspace, a member column, and the audio dock in separate regions. Narrow screens return to WebSpeak's responsive channel and member controls.
|
||||
KAAK is a schema v3 open-skin package with full connection and voice-workspace surfaces. Its voice page uses a narrow server rail, grouped TeamSpeak channels with inline voice participants, a central text chat, an online-member column, and a lower-left voice dock. Channel selection is single-click; joining is double-click. The narrow layout keeps the host's mobile controls available.
|
||||
|
||||
The design target is the voice-client portion of KOOK, as requested by the project owner. This skin does not include discovery, companion/party, event, store, advertising, administrator, or other service-operator pages. It does not add a KOOK account flow, direct messages, server administration, or channels absent from the connected TeamSpeak server.
|
||||
The design target is the voice-client portion of KOOK, as requested by the project owner. It does not include discovery, companion/party, event, store, advertising, administrator, or other service-operator pages. It does not add a KOOK account flow, direct messages, server administration, or channels absent from the connected TeamSpeak server.
|
||||
|
||||
## Reference access note
|
||||
|
||||
@@ -10,9 +10,9 @@ The owner authorized inspection of the first two voice rooms in the KOOK server.
|
||||
|
||||
## Components and permissions
|
||||
|
||||
The channel list and member column are defined as separate components in [components.json](./kaak-voice/components.json). The channel component reads the visible TeamSpeak channel tree and, with a separate `session.members.read` grant, renders visible member names and speaking state beneath each channel. Double-clicking a channel asks the host to join it; the host rechecks visibility and applies the existing TeamSpeak password and permission flow. This behavior belongs only to this KAAK component and does not alter the TeamSpeak protocol or other skins. Permission approval is local to this skin version and can be revoked from the host access control.
|
||||
The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen sharing. The host renders trusted connection, language, skin, audio, and screen-share controls. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control.
|
||||
|
||||
The favorite-server rail and main audio/chat controls remain WebSpeak components. The plugin does not receive server addresses, passwords, identity keys, microphone controls, raw audio, private messages, or arbitrary network/storage APIs. The /demo page uses synthetic data and does not connect to TeamSpeak.
|
||||
The skin does not receive server addresses, passwords, identity keys, raw audio, private messages, or arbitrary network/storage APIs. Its markup is data-only; it contains no executable JavaScript or Wasm. The `/demo` page uses synthetic data and does not connect to TeamSpeak.
|
||||
|
||||
## Files
|
||||
|
||||
@@ -21,4 +21,4 @@ The favorite-server rail and main audio/chat controls remain WebSpeak components
|
||||
- Distributable archive: [kaak-voice.wskin](./kaak-voice.wskin)
|
||||
- Shared format and safety rules: [SKIN_DEVELOPMENT.md](../SKIN_DEVELOPMENT.md)
|
||||
|
||||
The package is a ZIP archive with manifest.json at its root. Rebuild the archive from the contents of kaak-voice after any source change, then import the .wskin in a visitor browser and verify the consent, approval, denial, revoke, desktop, and narrow-screen paths.
|
||||
KAAK is included in the public skin selector and its `.wskin` archive is also available as a standalone package. After changing the source, run `npm run skin:kaak:build` to rebuild both copies, then run the package tests and verify the connection page, approval, denial, revoke, desktop, and narrow-screen paths in the local browser. The connected voice surface can be verified when a TeamSpeak session is available.
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -3,10 +3,10 @@
|
||||
"packageType": "open-skin",
|
||||
"id": "community.kaak-voice",
|
||||
"name": "KAAK",
|
||||
"version": "2.0.0",
|
||||
"version": "3.0.0",
|
||||
"author": "WebSpeak Project",
|
||||
"license": "AGPL-3.0-only",
|
||||
"description": "An open, channel-forward voice skin with safe declarative channel navigation.",
|
||||
"description": "A complete dark voice-client workspace inspired by modern voice apps, built with WebSpeak host controls and public TeamSpeak data.",
|
||||
"entry": "skin.css",
|
||||
"components": "components.json",
|
||||
"content": "content.json",
|
||||
|
||||
+854
-1049
File diff suppressed because it is too large.
Load diff
@@ -14,6 +14,7 @@
|
||||
"test": "node --import tsx --test src/admin/skin-registry.test.ts web/test/admin-api.integration.test.ts web/test/admin-view.test.mjs web/src/services/admin-api.test.ts src/security/open-target-policy.test.ts src/server/visitor-count.test.ts src/server/voice-protocol.test.ts src/server/teamspeak-resolver.test.ts src/server/ts-client.test.ts src/server/join-ticket.test.ts src/server/identity-lease.test.ts src/server/session-manager.test.ts src/server/directory-sync.test.ts src/server/session-events.test.ts src/server/reconnect-policy.test.ts src/server/voice-commands.test.ts src/server/voice-bridge.test.ts src/server/session-audio.test.ts src/server/voice-bridge.integration.test.ts src/server/webrtc-audio.test.ts src/server/webrtc-config.test.ts src/server/audio-stats.test.ts src/server/directory-view.test.ts src/server/member-avatars.test.ts src/server/screen-share-coordinator.test.ts src/shared/client-commands.test.ts src/shared/skin-layout.test.ts src/shared/skin-plugin.test.ts src/shared/skin-runtime-plugin-context.test.ts src/shared/skin-runtime-plugins.test.ts src/shared/skin-runtime-plugin-approval.test.ts src/shared/server-messages.test.ts src/shared/webrtc.test.ts scripts/docker-healthcheck.test.mjs web/test/voice-session.test.mjs web/test/audio-controls.test.mjs web/test/connection-dialogs.test.mjs web/test/voice-performance.test.mjs web/test/screen-share.test.ts web/test/screen-share-ui.test.mjs web/test/android-gateway.test.ts web/src/services/skin-catalog.test.ts web/src/services/skin-plugin-runtime.test.ts web/src/services/skin-plugin-authoring.test.ts web/src/services/host-editor-top-layer.test.ts web/src/services/skin-extension-ui.test.ts web/src/services/member-menu-placement.test.ts web/src/services/mobile-viewport.test.ts web/src/services/mobile-away.test.ts web/src/services/screen-wake-lock.test.ts web/src/services/microphone-start.test.ts web/src/services/skin-pack.test.ts web/src/services/skin-runtime-plugin-approval.test.ts web/src/services/skin-layout-storage.test.ts web/src/services/skin-layout-geometry.test.ts web/src/services/skin-layout-focus.test.ts web/test/skin-layout-runtime.test.mjs web/test/skin-plugin-editor.test.mjs web/src/services/identity-import.test.ts web/test/identity-dialog.test.mjs web/test/skin-lifecycle.test.mjs web/src/services/local-persistence.test.ts web/src/services/quick-servers.test.ts src/server/teamspeak-alias.test.ts src/server/teamspeak-alias-integration.test.ts web/src/services/teamspeak-target.test.ts web/src/services/skin-extension-sandbox.test.ts web/src/services/skin-extension-wasm-policy.test.ts web/src/services/skin-extension-wasm-sandbox.test.ts web/src/services/skin-runtime-plugin-wasm.test.ts web/src/services/skin-extension-wasm-ui-loop.test.ts web/src/services/skin-wasm-interpreter.test.ts",
|
||||
"verify": "npm test && npm run build && npm run web:build",
|
||||
"skin:harbor:build": "node web/scripts/build-harbor-voice-skin.mjs",
|
||||
"skin:kaak:build": "node web/scripts/build-kaak-voice-skin.mjs",
|
||||
"start": "node dist/index.js",
|
||||
"web:dev": "cd web && npx vite --host",
|
||||
"web:build": "npm --prefix web run build",
|
||||
|
||||
@@ -163,22 +163,38 @@ test("schema v3 host audio controls require read and control permissions while v
|
||||
assert.equal(parseSkinPluginDocument(legacyDocument).components[0].root.children?.[0].widget, "voice.audio-controls");
|
||||
});
|
||||
|
||||
test("KAAK v3 example splits validated channel and member data by component", async () => {
|
||||
test("KAAK v3 example declares the connection home and complete voice workspace", async () => {
|
||||
const source = await readFile(new URL("../../docs/examples/kaak-voice/components.json", import.meta.url), "utf8");
|
||||
const parsed = parseSkinPluginJson(source);
|
||||
const channelSidebar = parsed.components.find((component) => component.id === "kaak-channel-sidebar");
|
||||
const memberSidebar = parsed.components.find((component) => component.id === "kaak-members-sidebar");
|
||||
assert.ok(channelSidebar);
|
||||
assert.ok(memberSidebar);
|
||||
assert.deepEqual(channelSidebar.permissions, ["session.channels.read", "session.members.read", "session.channel.join"]);
|
||||
assert.equal(channelSidebar.actions["join-channel"].type, "voice.joinChannel");
|
||||
assert.equal(channelSidebar.root.children?.[1].children?.[0].children?.[0].events?.dblclick, "join-channel");
|
||||
assert.equal(channelSidebar.root.children?.[1].children?.[0].repeat?.path, "session.channels");
|
||||
const nestedMembers = channelSidebar.root.children?.[1].children?.[0].children?.[1].children?.[0];
|
||||
assert.equal(nestedMembers?.repeat?.path, "channel.members");
|
||||
assert.equal(nestedMembers?.children?.[1].children?.[0].text, "{{member.name}}");
|
||||
assert.deepEqual(memberSidebar.permissions, ["session.members.read"]);
|
||||
assert.equal(memberSidebar.root.children?.[2].children?.[0].repeat?.path, "session.members");
|
||||
const home = parsed.components.find((component) => component.id === "kaak-home");
|
||||
const workspace = parsed.components.find((component) => component.id === "kaak-workspace");
|
||||
assert.ok(home);
|
||||
assert.ok(workspace);
|
||||
assert.equal(home.page, "home");
|
||||
assert.equal(home.mode, "surface");
|
||||
assert.deepEqual(home.permissions, ["ui.surface.replace"]);
|
||||
assert.equal(home.root.children?.[1].children?.[3].widget, "home.connection-form");
|
||||
|
||||
assert.equal(workspace.page, "voice");
|
||||
assert.equal(workspace.mode, "surface");
|
||||
assert.ok(workspace.permissions.includes("session.channels.read"));
|
||||
assert.ok(workspace.permissions.includes("session.members.read"));
|
||||
assert.ok(workspace.permissions.includes("chat.channel.send"));
|
||||
assert.ok(workspace.permissions.includes("audio.microphone.control"));
|
||||
assert.equal(workspace.actions["join-channel"].type, "voice.joinChannel");
|
||||
assert.equal(workspace.actions["send-message"].type, "chat.sendMessage");
|
||||
|
||||
const nodes: SkinPluginNode[] = [];
|
||||
const visit = (node: SkinPluginNode): void => {
|
||||
nodes.push(node);
|
||||
node.children?.forEach(visit);
|
||||
};
|
||||
visit(workspace.root);
|
||||
assert.ok(nodes.some((node) => node.widget === "voice.audio-controls"));
|
||||
assert.ok(nodes.some((node) => node.widget === "voice.screen-share-start"));
|
||||
assert.ok(nodes.some((node) => node.repeat?.path === "session.channels" && node.children?.[0].events?.dblclick === "join-channel"));
|
||||
assert.ok(nodes.some((node) => node.repeat?.path === "session.members"));
|
||||
assert.ok(nodes.some((node) => node.tag === "input" && node.bindValue === "message"));
|
||||
});
|
||||
|
||||
test("skin plugin binds form controls only to declared local state", () => {
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { zipSync } from "fflate";
|
||||
|
||||
const sourceDirectory = new URL("../../docs/examples/kaak-voice/", import.meta.url);
|
||||
const sourceFiles = ["manifest.json", "components.json", "content.json", "skin.css"];
|
||||
const files = Object.fromEntries(await Promise.all(sourceFiles.map(async (name) => [
|
||||
name,
|
||||
await readFile(new URL(name, sourceDirectory)),
|
||||
])));
|
||||
const archive = zipSync(files, { level: 9 });
|
||||
|
||||
await Promise.all([
|
||||
writeFile(fileURLToPath(new URL("../../docs/examples/kaak-voice.wskin", import.meta.url)), archive),
|
||||
writeFile(fileURLToPath(new URL("../public/skins/kaak-voice.wskin", import.meta.url)), archive),
|
||||
]);
|
||||
@@ -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;
|
||||
|
||||
@@ -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 [{
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in new issue
Block a user