feat(skin): add approved full-page surface composition

This commit is contained in:
illusia committed 2026-10-10 15:53:48 +08:00
1 parent eabc78f36a
commit d505815f28
19 files changed
+1261 -99

No files matched your search

@@ -1,11 +1,11 @@
---
name: webspeak-skin-development
description: Create, refine, package, and verify WebSpeak v1 visual, v2 layout, and v3 open skins while preserving host-owned behavior and access boundaries.
description: Create, refine, package, and verify WebSpeak v1 visual, v2 layout, and v3 open skins, including declarative full-page surfaces that compose host-owned voice controls.
---
# WebSpeak skin development
Use this skill when editing or authoring a WebSpeak `.wskin` package, a built-in skin, or skin-facing UI hooks. v1/v2 packages are visual/layout data; v3 may rearrange public UI and add bounded declarative components. WebSpeak owns host behavior and the administrator console is outside the skin scope.
Use this skill when editing or authoring a WebSpeak `.wskin` package, a built-in skin, or skin-facing UI hooks. v1/v2 packages are visual/layout data; v3 may rearrange public UI, add bounded declarative components, or replace the visible home/voice page with a validated surface. WebSpeak owns host behavior and the administrator console is outside the skin scope.
## Before editing
@@ -17,17 +17,24 @@ Use this skill when editing or authoring a WebSpeak `.wskin` package, a built-in
- Keep WebSpeak's translations and semantic content as the baseline. Add `content.json` only when a text override is an explicit part of the request; never use it to implement visual artwork.
- Follow the schema-specific CSS rules: v1/v2 reject layout changes; v3 allows layout, placement, size, typography, and visibility changes within the skin root. Keep CSS package-local, scoped to public hooks, and free of external resources or executable values.
- v3 can obscure normal page controls. Preserve usable microphone, disconnect, device-settings, screen-share and recovery paths at desktop and mobile sizes. Skin CSS cannot reach host permission and recovery chrome rendered outside the skin root. Keep `/admin/**` unskinned.
- v3 component trees are declarative JSON rendered by the host. Never add script, Wasm, HTML strings, direct network/storage, or private host objects. Request only the component-level permissions needed; keep labels and favorite identifiers opaque and never bind server addresses or credentials.
- v3 can replace or obscure normal page controls. A surface must request `ui.surface.replace` and stays disabled until the user approves it. Arrange host widgets for the functions it needs; available IDs are registered in `src/shared/skin-plugin.ts`. Each stateful host widget may appear once per page. Preserve usable microphone, disconnect, device-settings, screen-share and recovery paths at desktop and mobile sizes. Verify both the return-to-built-in-UI and restore-built-in-skin buttons. The host recovery and permission UI render outside the skin root. Keep `/admin/**` unskinned.
- components.json schema v1 is legacy; schema v2 adds `mode: "surface"` and allowlisted host-widget nodes. Component trees are declarative JSON rendered by the host. Never add script, Wasm, HTML strings, direct network/storage, or private host objects. Request only the component-level permissions needed; surfaces require `ui.surface.replace`. Keep server-list labels and opaque identifiers separate from addresses and credentials. Use `servers.quickList` plus `quickServers.switch` when a custom UI should show favorites and recent servers together. Host widgets execute in WebSpeak and do not grant author code access to their private state.
- Use the host's reserved artwork hooks for layered character art and the headphone scene. Prefer transparent assets and `background-size: contain` where the reference requires the full character or chibi to remain visible; arrange the artwork around the fixed hook rather than changing its geometry.
- Build visual depth with separate background, surface, and foreground artwork already exposed by the hooks. Avoid duplicate static decorations when an animated replacement exists. For motion, keep waveforms/sonar smooth and restrained, honor reduced-motion preferences, and retain readable focus, error, mute, and speaking states.
- Keep skin-specific CSS variables under `--skin-*`. Use only package-local assets and confirm their redistribution rights.
## Verify and package
1. Compare the implementation with its visual reference at desktop and narrow widths. Check the homepage, voice workspace, empty chat, member list, screen-share player, selectors, and `/demo`; verify no crop, overflow, text collision, or control overlap.
1. Compare the implementation with its accessible visual reference at desktop and narrow widths. Check the homepage, voice workspace, empty chat, member list, screen-share player, selectors, and `/demo`; verify no crop, overflow, text collision, or control overlap. Do not claim visual verification when the reference page could not be read.
2. Check all five interface languages, day/night modes, keyboard focus, and reduced-motion behavior. Confirm the admin console is unchanged.
3. Run the relevant skin-package tests and application build after a related batch of changes. Fix validation failures rather than weakening the v1/v2 boundaries or v3 permission checks.
3. Run the relevant skin-package tests and application build after a related batch of changes. Fix validation failures rather than weakening v1/v2 boundaries, v3 permission checks, surface limits, or the host-widget allowlist.
4. Package the contents of the skin directory so `manifest.json` is at the archive root, then import it through `/admin/skins` and retest the installed `.wskin` in a visitor session.
The shipped default day, default night, and ILLUSIA skins are protected built-ins. Do not change their IDs or introduce upload/update flows that can disable, replace, or remove them. A permission request is not a grant; verify the deny and revoke paths. Do not claim a skin was visually verified against an external reference unless that page was actually accessible.
## Integration findings
- A full-page surface is a separate user-approved capability (`ui.surface.replace`); package installation alone must leave the built-in page visible.
- The “restore built-in skin” control must use an unconditional selection function, not the skin-load-error-only recovery handler.
- Custom quick-server layouts should use the unified favorites/recent collection and opaque host tokens. Labels that match the underlying address are redacted before projection; never expose target addresses or credentials to skin data bindings.
- Record external-reference access failures and leave visual checks incomplete; do not replace the authorized page with search snippets or unrelated screenshots.
+33 -15
View File
@@ -1,6 +1,6 @@
# 更开放的皮肤系统路线图
当前路线把皮肤能力限定在 WebSpeak 的公开连接首页、语音工作区和演示页。目标是让基础组件能自由安排、设定样式与显隐,并允许作者用声明式组件补充界面。管理员面板、管理 API 和语音服务运营页面都不纳入皮肤范围。
皮肤只作用于 WebSpeak 的公开连接首页、语音工作区和公开演示页。目标是让作者可以安排、隐藏、重设基础组件,也可以用安全声明式界面替换首页或语音工作区的完整可见内容。TeamSpeak 连接、聊天、频道和音频行为仍由宿主控件执行;管理员面板、管理 API 以及语音服务运营页面不在范围内。
零新增预算是持续约束:不因皮肤系统引入付费托管、CDN、域名或存储。商城与管理员面板重做由后续阶段共同规划;优先复用公开 GitHub 仓库、版本化 Release 附件和现有免费能力,不能把隐私配置发布到公共目录。
@@ -20,22 +20,40 @@ schema v2 支持公开组件布局、桌面/平板/手机配置、本地覆盖
### R3:开放皮肤与受控组件
schema v3 的客户端和服务端包校验、CSS 布局能力、声明式组件渲染、按组件权限审批与撤销、公开数据代理及有限宿主动作已接入。自定义组件使用受限 JSON 节点,不运行作者 JavaScript 或 WebAssembly。只有经用户启用的组件才可读取明确列出的公开会话数据或提出宿主动作;宿主对每次动作重新校验。
皮肤包 schema v3 的客户端和服务端包校验、CSS 布局能力、声明式组件渲染、按组件权限审批与撤销、公开数据代理及有限宿主动作已接入。旧的 components.json schema v1 使用受限 JSON 节点,不运行作者 JavaScript 或 WebAssembly。宿主对每次动作重新校验。
当前白名单包括连接摘要、公开频道、可见成员、当前公开频道消息和脱敏收藏名称。宿主动作覆盖公开频道加入、已有收藏切换、当前频道聊天发送和组件本地状态更新。收藏服务器地址、密码、身份密钥、私聊、原始音频、屏幕流、管理 API、任意网络和浏览器存储均不提供。
当前白名单包括连接摘要、公开频道、可见成员、当前公开频道消息和脱敏收藏名称。宿主动作覆盖公开频道加入、已有收藏切换、当前频道聊天发送和组件本地状态更新。收藏服务器地址、密码、身份密钥、私聊数据、原始音频、屏幕流、管理 API、任意网络和浏览器存储不会交给组件代码。
CSS v3 可以完全改变公开页面布局、尺寸、排版和显隐,所以皮肤可能遮挡普通界面。宿主权限和恢复控件不受其 CSS 控制;实际皮肤仍要检查触屏、键盘、移动端及语音操作可达性。CSS 隔离不是恶意代码沙箱。
### R4:整页皮肤界面和宿主控件组合(进行中)
## 下一步
- components.json schema v2 增加 `mode: "surface"`,允许替换首页或语音工作区的完整可见页面;旧 schema v1 继续兼容。
- surface 用受限节点、受控 CSS、公开数据绑定及白名单动作构建布局,不运行作者代码。
- 整页替换要求用户单独批准 `ui.surface.replace`;页面权限确认、撤销入口和恢复控件由宿主绘制。
- 固定宿主控件 ID 可供皮肤编排,包括连接表单、皮肤/语言选择器、频道成员面板、语音成员卡、聊天、音频控制、屏幕共享、悄悄话、性能面板和退出控件。控件只在 WebSpeak 内执行,作者代码无法读取其私有状态;每个有状态控件每页仅可挂载一次。
- 为完整定制常用服务器栏提供脱敏的收藏/历史列表与宿主切换动作;地址、密码和身份材料仍留在 WebSpeak 内。
- 页面权限确认、撤销入口和“返回标准界面”控件在皮肤 CSS 作用域之外。页面替换被拒绝或退出时,原生首页/语音工作区重新显示。
- 补充导入、旧包兼容、页面替换、权限拒绝/撤销、宿主控件及皮肤切换回归。
- 已提供可导入的完整首页/语音工作区 surface 样例,覆盖服务器切换、频道、成员、聊天、音频、悄悄话和屏幕共享;该样例验证格式与宿主控件组合,不代表已经实测 KOOK 视觉。
- KOOK 参考皮肤只实现语音客户端体验;不复制运营、广告、陪玩、活动和商城页面。只有能实际查看的公开/授权界面才作为视觉依据。
### R4:作者体验与兼容性
#### R4 问题记录
- 完成 Illusia 和 KAAK 示例的 v3 迁移,提供真实可导入的 .wskin 包和清楚的权限清单。
- 为组件数据绑定、重复列表、动作校验、用户拒绝与撤销补足自动化回归。
- 改善权限说明和皮肤开发文档;注明视觉预览限制、CSS 可隐藏普通 UI 的风险及恢复方式。
- 汇总公开语音界面的预览问题并修复;不扩展到无关业务代码。
- 初版 surface 可以在没有任何数据/API 权限时直接替换页面,安装皮肤即可能显示仿制界面。现要求 surface 额外申请 `ui.surface.replace`,用户批准前继续显示 WebSpeak 原页面,并覆盖拒绝与撤销路径。
- surface 的“恢复内置皮肤”按钮误接到仅用于皮肤加载错误的回退函数,正常皮肤下点击无效。已改为明确切换到当前主题对应的内置皮肤,并增加授权/撤销回归。
- 初版自定义服务器栏只有收藏数据,缺少最近连接项。新增 `servers.quickList` 和宿主切换动作,使用不透明令牌,不下放目标地址或凭据。
- 收藏名/最近连接显示名有时会直接等于服务器地址;投影数据前增加地址匹配与泛化标签,避免通过“显示名”字段间接暴露连接目标。
- KOOK 页面标签能在标签清单中看到,但 IAB `getTab` 超时,Edge 扩展桥接返回 `nodeRepl.fetch request failed`;因此本轮未进入授权频道,未取得真实房间截图。视觉复刻与房间交互验收保持未完成,不以第三方截图替代授权页面证据。
### R5:皮肤商城与管理员面板重做时交付
## 下一阶段
### R5:作者体验与兼容性
- 已提供可导入的完整 surface 示例,记录权限清单和桌面/移动布局:[`open-voice-surface.wskin`](./examples/OPEN-VOICE-SURFACE.md)。
- 对首页连接、收藏快速切换、频道切换、成员区、聊天、音频和屏幕共享进行端到端验收。
- 检查产品支持语言、键盘焦点、触屏、拒绝授权、撤销和恢复路径。
- 更新皮肤开发技能、公开控件索引和各语言用户文档。
### R6:皮肤商城与管理员面板重做时交付
- 商城目录、发现、安装、更新、回退、下架与撤销同管理员面板改造一起设计;后台本身保持不可皮肤化。
- 首选人工审查的静态清单和 Release 附件,列出来源、版本、许可证、包校验值和组件权限。
@@ -45,8 +63,8 @@ CSS v3 可以完全改变公开页面布局、尺寸、排版和显隐,所以
## 迁移和验收
- v1、v2 包继续按原有规则校验;只有明确声明 open-skin 的 v3 包才有 v3 CSS 与组件能力。
- 未知版本、字段、权限、节点、数据路径、动作和素材类型都拒绝导入。
- v1、v2 皮肤包继续按原有规则校验;皮肤包 schema v3 才有开放 CSS 和组件能力。
- components.json schema v1 继续导入;只有 schema v2 可以声明 surface 和宿主控件。
- 未知版本、字段、权限、节点、数据路径、动作、控件和素材类型都拒绝导入。
- 每次将相关修改合并成一批统一运行验证,避免每个小节点重复跑全套构建。
- 验收桌面与移动视口、产品支持语言、键盘与触屏、焦点状态、语音/静音/退出和皮肤恢复路径。
- 管理端、运营页面、Android 计划及语音业务逻辑不因开放皮肤系统而扩展。
- 管理端、运营页面和语音服务内部行为不因开放皮肤系统而扩展。
+15 -7
View File
@@ -1,6 +1,6 @@
# 更开放的皮肤系统规格
状态:schema v3 声明式开放皮肤已接入公开客户端、浏览器导入和服务端包校验。当前实现的是受限组件树与宿主能力桥,不执行皮肤作者提供的 JavaScript 或 WebAssembly。阶段记录见[路线图](./OPEN_SKIN_SYSTEM_ROADMAP.zh-CN.md),创作者操作见[皮肤开发规范](./SKIN_DEVELOPMENT.md)。
状态:皮肤包 schema v3 已接入公开客户端、浏览器导入和服务端包校验;components.json schema v2 正在提供整页替换和宿主控件插槽,旧组件 schema v1 继续兼容。页面内容由受限声明式树和皮肤 CSS 定义,交互通过白名单动作及 WebSpeak 原生控件完成;不执行皮肤作者的 JavaScript 或 WebAssembly。阶段记录见[路线图](./OPEN_SKIN_SYSTEM_ROADMAP.zh-CN.md),创作者操作见[皮肤开发规范](./SKIN_DEVELOPMENT.md)。
## 1. 目标与范围
@@ -12,13 +12,17 @@
皮肤格式按版本区分:v1 保持视觉皮肤兼容;v2 提供有界布局 JSON;v3 使用 open-skin 清单、受控 CSS 和可选的 components.json。v1/v2 的 CSS 继续拒绝布局类声明,既有用户包不会因升级而获得新权限。v3 才允许 CSS 控制公开页面中的布局、位置、尺寸、顺序、文字排版和显隐。
v3 自定义组件不是脚本插件。宿主解析 JSON 中的元素白名单、受限属性、数据绑定、重复列表、条件和事件声明,再由 Vue 创建安全节点。包不能提交 HTML 字符串、事件处理代码、JavaScript、WebAssembly、远程脚本、任意 URL、表单导航、浏览器存储访问或网络调用。未知字段、元素、动作、数据路径和权限一律拒绝。
v3 自定义组件不是脚本插件。components.json schema v1 是既有组件格式;schema v2 增加 `mode: "surface"` 与宿主控件节点。surface 可以替换首页或语音工作区的整页可见内容;作者可把安全节点、公开数据列表和宿主控件组合成自己的应用布局。宿主解析元素白名单、受限属性、数据绑定、重复列表、条件和事件声明,再由 Vue 创建节点。管理员面板和演示页不能被 surface 替换。
宿主控件通过固定 ID 嵌入,始终由 WebSpeak 代码运行。当前注册表包括 `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.whisper-controls`、`voice.performance-panel`、`voice.connection-controls` 和 `voice.disconnect-control`。每个控件在同一页面最多出现一次;未知 ID 或重复的有状态控件会拒绝导入。频道、收藏等自定义列表仍可用现有公开数据绑定和受限动作构建。
包不能提交 HTML 字符串、事件处理代码、JavaScript、WebAssembly、远程脚本、任意 URL、表单导航、浏览器存储访问或网络调用。未知字段、元素、动作、数据路径、控件和权限一律拒绝。
每个组件只能声明 home、voice 或 demo 页面中的一个页面、一个有界的树和精确权限清单。components.json 全文不超过 256 KiB;最多 32 个组件;每组件最多 256 个节点、16 层深度、100 个重复行、32 个本地状态值和 24 个宿主动作。图片仅可通过包内 image 资源引用。
## 3. 可读数据和权限
组件权限按组件单独请求,用户在宿主确认界面查看用途后才启用。授权按皮肤 ID、版本、页面、组件和权限策略版本保存;换版本或策略含义变化会重新询问。皮肤设置中的独立入口可查看和撤销授权;拒绝或撤销后对应组件不渲染、不触发动作。
组件权限按组件单独请求,用户在宿主确认界面查看用途后才启用。整页 surface 必须申请 `ui.surface.replace`,所以页面替换不会因皮肤包已安装而静默启用。授权按皮肤 ID、版本、页面、组件和权限策略版本保存;换版本或策略含义变化会重新询问。皮肤设置中的独立入口可查看和撤销授权;拒绝或撤销后对应组件不渲染、不触发动作。
当前公开只读能力如下:
@@ -27,23 +31,27 @@ v3 自定义组件不是脚本插件。宿主解析 JSON 中的元素白名单
- session.members.read:可见成员名称、所在频道、在线状态、说话状态及本人标志。
- chat.channel.read:当前公开文字频道中可见的消息。
- favorites.read:收藏项名称、类型、是否当前项和随机不透明本地令牌;不提供地址或凭据。
- servers.quickList.read:统一后的收藏和最近连接名称、当前项、分类与随机不透明本地令牌;不提供地址或凭据。
当前宿主动作如下:
- voice.joinChannel 需要 session.channel.join,只能请求加入当前页面公开可见的 TeamSpeak 频道,仍经过宿主和原有密码、权限流程。
- favorites.switch 需要 favorites.switch,只能让宿主按不透明令牌选择本机已有收藏并走原连接流程。
- quickServers.switch 需要 servers.quickList.switch,只能让宿主按不透明令牌选择本机已有收藏或最近连接并走原连接流程。
- chat.sendMessage 需要 chat.channel.send,只能发送到当前公开文字频道;不包括私聊。
- ui.setState 只修改该组件短暂的本地标量状态,不需要会话权限。
宿主控件节点只是把 WebSpeak 的原生界面放进皮肤布局,不向皮肤提供控件内部的数据对象。控件仍使用原来的连接、权限和用户事件检查;例如嵌入 `voice.chat-panel` 可以让用户继续使用原生聊天界面,但不会授予组件读取私聊内容的能力。
动作仅能绑定到真实可信用户事件。输入和 change 事件不能调用宿主动作;键盘动作仅响应 Enter 或 Space。宿主再次检查当前频道、令牌及动作参数。皮肤不能控制麦克风、音频设备、屏幕采集、身份密钥或 TeamSpeak 管理命令。
数据授权不是数据上传授权:组件没有任意联网或持久化 API,权限决定保存在本机。渲染进程不会把服务器地址、密码、身份私钥、访问令牌、Cookie、私聊、原始音频或屏幕流交给皮肤。
## 4. CSS 与基础组件
全部 CSS 被重写到当前公开皮肤根节点。选择器必须锚定 :root、data-ws-page、data-ws-part 或 v3 的 data-ws-plugin-part;v3 可在这些锚点之外使用皮肤自己的 class 和 ID。禁止全局逃逸、@import、脚本化 CSS 值和外部资源;图片和字体必须打包。不同 skin CSS 变量使用 --skin- 前缀。
全部 CSS 被重写到当前公开皮肤根节点。选择器必须锚定 :root、data-ws-page、data-ws-part 或 v3 的 data-ws-plugin-part;v3 可在这些锚点之外使用皮肤自己的 class 和 ID。禁止全局逃逸、@import、脚本化 CSS 值和外部资源;图片和字体必须打包。不同 skin CSS 变量使用 --skin- 前缀。surface 会替换首页或语音工作区的正常页面节点;页面权限提示、皮肤组件权限入口和“返回标准界面”控件由宿主放在皮肤根之外,不能被皮肤 CSS 隐藏。
v3 CSS 可排列和重设公开 UI,因此可能遮挡麦克风、退出、共享或恢复入口。导入器会对隐藏界面发出提示,但这不是安全边界,也不能证明皮肤布局可用。可信的皮肤选择、恢复入口、组件权限确认和撤销控件在皮肤根节点之外;作者必须在桌面和移动布局中保留必要语音操作的可达路径。用户始终可切回内置皮肤。
v3 CSS 和 surface 可排列、替换或遮挡公开 UI,因此可能改变麦克风、退出、共享等控件的可见位置。宿主提供的“返回标准界面”和“恢复内置皮肤”控件以及组件权限确认和撤销入口在皮肤根节点之外;用户可立即退回 WebSpeak 页面,再用原生皮肤选择器切换皮肤。作者仍应在桌面和移动布局中保留语音操作的可达路径。
皮肤与 /admin/** 完全分离。不得将后台页面标记为公开皮肤页面,也不得通过资源、选择器或组件数据间接读取管理员内容。
@@ -59,7 +67,7 @@ v3 CSS 可排列和重设公开 UI,因此可能遮挡麦克风、退出、共
## 7. 后续安全工作
- 扩展数据字段或宿主动作时,增加精确 schema、权限和宿主侧运行时验证,不暴露内部 SDK 对象。
- 扩展数据字段或宿主动作时,增加精确 schema、权限和宿主侧运行时验证,不暴露内部 SDK 对象。新增宿主控件也必须登记固定 ID、明确页面和确认只在宿主内处理其私有状态。
- 对恶意输入、路径别名、拒绝授权、撤销、更新和皮肤切换增加测试;高敏能力必须单独设计。
- 不把当前 v3 声明式包描述为可执行代码沙箱。若未来考虑代码扩展,应另行开展威胁建模、浏览器隔离评估与独立安全审查。
- 不把当前声明式包描述为可执行代码沙箱。现有 JavaScript Worker 与 Wasm 原型均未启用;浏览器 Worker 没有硬内存配额,原型也没有完整的页面渲染、控件与动作审查流程。若未来考虑作者代码,应另行开展威胁建模、资源耗尽测试、浏览器隔离评估与独立安全审查。
- 商城发布、签名、下架、更新和撤销设计与管理员面板重做一起验收,且保持零新增服务费用为默认约束。
+43 -6
View File
@@ -1,6 +1,6 @@
# WebSpeak 皮肤开发规范
本文说明仍受支持的 v1 视觉皮肤、v2 声明式布局皮肤和 v3 开放皮肤。v1/v2 保持固定 CSS 几何边界;v3 可重排公开 UI 并携带受限声明式组件,但不执行作者代码。路线和安全边界见[路线图](./OPEN_SKIN_SYSTEM_ROADMAP.zh-CN.md)与[规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)。
本文说明仍受支持的 v1 视觉皮肤、v2 声明式布局皮肤和 v3 开放皮肤。v1/v2 保持固定 CSS 几何边界;v3 可重排公开 UI、添加受限组件,或用 components.json schema v2 替换首页/语音工作区的整页可见界面。界面由宿主安全渲染,仍不执行作者代码。路线和安全边界见[路线图](./OPEN_SKIN_SYSTEM_ROADMAP.zh-CN.md)与[规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)。
`.wskin` 包可为公开页面定制艺术表现。v1 提供 CSS 与美术资源;v2 另外携带受校验的布局 JSON;v3 可自由安排公开组件,并用 components.json 声明由宿主渲染的安全组件。所有版本均由 WebSpeak 保留基础组件的业务逻辑和 TeamSpeak 行为。
@@ -25,7 +25,7 @@ content.json # 可选:首页内容与多语言界面文案
assets/preview.jpg # 可选:管理后台显示的预览图,也可在 CSS 中使用
assets/background.webp # 可选:页面艺术素材
assets/brand.woff2 # 可选:自带字体
components.json # v3 可选:声明式扩展组件
components.json # v3 可选:声明式组件或完整页面 surface
```
所有资源路径使用 `/`,区分大小写,并相对于包根目录。CSS 的 `url()` 使用同样的包根相对路径,例如 `url("assets/background.webp")`。不得使用机器本地路径、站点绝对路径或远程 URL。
@@ -104,17 +104,46 @@ v2 为 v1 增加一个必需布局文件。清单和布局 JSON 会在导入端
v1 和 v2 都只支持公开页面。`/admin/**` 不加载布局、用户覆盖和皮肤组件编辑器。布局包没有数据/API 权限;后续插件必须另行设计独立沙箱与授权协议,不能通过增加 v2 清单字段取得能力。
### schemaVersion 3:开放皮肤和声明式组件
### schemaVersion 3:开放皮肤和完整声明式页面
v3 清单的 packageType 固定为 open-skin,entry 指向 CSS,components 指向 components.json;不含 v2 的 layout 或 permissions 字段。组件文件可以省略。仅 v3 开放公开页面的 CSS 排版能力,v1/v2 仍按旧 CSS 规则校验。客户端导入和服务端登记使用同一共享组件 schema 与权限白名单。
components.json 顶层为 schemaVersion 1 和 components 数组。每个组件需声明 id、name、page、accessibleName、permissions、actions 和 root,可选 state。page 只接受 home、voice、demo。root 使用白名单 HTML/SVG 元素。节点可包含 text、part、className、受限 attributes、包内图片 asset、bindValue、本地 repeat/when、events 和 children。文本与属性支持简单的双大括号数据路径;不支持表达式、HTML 字符串或脚本。
components.json 顶层接受 schemaVersion 1 或 2 和 components 数组。schema v1 维持原有兼容;schema v2 的组件可声明 `mode: "widget"`(默认)或 `mode: "surface"`。每个组件需声明 id、name、page、accessibleName、permissions、actions 和 root,可选 state。page 接受 home、voice、demo;surface 仅可用于 home 和 voice,并且必须请求 `ui.surface.replace`。用户批准前不会显示 surface,撤销后宿主立即恢复普通页面。
示例包见 [KAAK voice 示例](./examples/KAAK-VOICE.md),其 components.json 展示了公开频道列表和双击加入频道。当前数据权限和宿主动作以[开放皮肤规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)中的清单为准。组件按本地用户授权后才渲染;权限对每个皮肤版本、页面和组件分别保存,可在宿主浮动的权限入口撤销。用户拒绝时组件保持关闭。
普通节点使用白名单 HTML/SVG 元素。节点可包含 text、part、className、受限 attributes、包内图片 asset、bindValue、本地 repeat/when、events 和 children。文本与属性支持简单的双大括号数据路径;不支持表达式、HTML 字符串或脚本。schema v2 另允许固定宿主控件节点,例如:
```json
{
"schemaVersion": 2,
"components": [{
"id": "example-voice-surface",
"name": "Example voice surface",
"page": "voice",
"mode": "surface",
"accessibleName": "Example voice workspace",
"permissions": ["ui.surface.replace"],
"actions": {},
"root": {
"tag": "main",
"children": [
{ "widget": "voice.channel-panel" },
{ "widget": "voice.member-cards" },
{ "widget": "voice.chat-panel" },
{ "widget": "voice.audio-controls" },
{ "widget": "voice.disconnect-control" }
]
}
}]
}
```
当前宿主控件 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.whisper-controls`、`voice.performance-panel`、`voice.connection-controls`、`voice.disconnect-control`。未知控件和同页重复控件会被拒绝;每个控件的状态和业务动作仍由 WebSpeak 内部处理。只显示收藏时可用 `favorites.items` 和 `favorites.switch`;若要将收藏与最近连接放在同一自定义栏,可用 `servers.quickList` 数据与 `quickServers.switch` 动作。服务器目标始终使用本机生成的不透明令牌,不把地址、密码或身份材料交给组件。频道行也可把 `voice.joinChannel` 绑定到双击事件,切房继续走 TeamSpeak 原有权限和密码流程。
示例包见 [KAAK voice 示例](./examples/KAAK-VOICE.md),其 components.json 展示了公开频道列表和双击加入频道;[Open Voice Surface](./examples/OPEN-VOICE-SURFACE.md) 展示了完整首页和语音工作区 surface。后者是格式验证脚手架,不声称已经逐像素复刻 KOOK。当前数据权限和宿主动作以[开放皮肤规格](./OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)中的清单为准。组件按本地用户授权后才渲染;权限对每个皮肤版本、页面和组件分别保存,可在宿主权限入口撤销。页面替换时,宿主会额外显示“返回标准界面”和“恢复内置皮肤”入口;拒绝授权或离开 surface 后,普通页面可立即恢复。
组件树有硬上限:components.json 256 KiB,最多 32 个组件,每组件最多 256 个模板节点、16 层深度、100 条重复记录、32 个本地标量状态和 24 个动作。图片资源只能从包内引用,CSS 不能读取外部 URL、脚本或浏览器存储。宿主动作需显式权限,并只能绑定可信的用户事件;输入或 change 事件不能连接、切房或发消息。
注意:v3 CSS 可以隐藏或遮挡语音控件。权限和恢复提示由宿主在皮肤根之外绘制,但其他界面控件仍受皮肤排版影响。测试时务必确保麦克风、设置、退出语音、屏幕共享操作和移动端导航仍有可达路径。组件演示页 /demo 使用合成数据,加入频道和聊天动作只更新演示状态。
注意:v3 CSS 和 surface 可以隐藏或遮挡普通语音控件。权限和返回标准界面提示由宿主在皮肤根之外绘制;其他界面控件仍受皮肤排版影响。测试时务必确保麦克风、设置、退出语音、屏幕共享操作和移动端导航仍有可达路径。组件演示页 /demo 使用合成数据,加入频道和聊天动作只更新演示状态;它不支持宿主控件或整页替换。
## 首页内容和文案
@@ -312,3 +341,11 @@ CSS 被限定在 `.ws-skin-root` 内,管理员页面不会继承皮肤。删
6. 检查至少一个窄屏尺寸和桌面尺寸,并检查焦点可见、对比度、动效偏好;确认没有第三方素材授权问题。
当前自动化回归涵盖 ZIP/清单验证、资源路径、CSS 隔离与拒绝规则、文案结构和服务端皮肤目录读写。视觉排版、内容遮挡和浏览器间表现仍须人工预览。
## 本轮实现问题记录
- 整页替换必须是用户明确批准的能力;仅安装皮肤不能隐藏普通首页或语音页。schema v2 surface 应声明 `ui.surface.replace`,并验证拒绝授权和撤销后普通界面会恢复。
- surface 上的“恢复内置皮肤”操作必须调用无条件的内置皮肤切换路径;用于“皮肤加载失败”提示的回退函数会在正常情况下直接返回。
- 自定义服务器栏需要用 `servers.quickList` 同时显示收藏与最近连接;只能把标签、类型、当前标记和随机令牌交给组件,切换时再由宿主解析本地目标。
- 最近连接和默认收藏名可能直接是服务器地址;组件上下文会在投影阶段将这种标签改为通用名称,不能改为暴露原始地址。
- 外部 KOOK 页面目前无法通过当前 IAB/Edge 桥接读取;本轮没有采集房间视觉或操作状态。皮肤指南要求将该项保留为未验收,不能根据搜索摘要宣称完成视觉克隆。
+10
View File
@@ -0,0 +1,10 @@
# Open Voice Surface scaffold
This importable schema v2 surface package exercises complete public home and voice pages using only declarative nodes and WebSpeak-owned controls. It includes server switching, channel navigation, visible members, chat, audio, whisper, screen sharing, connection controls, and the built-in language and skin selectors. It contains no discovery, events, shop, companion, advertising, or administration pages.
This is an implementation scaffold for testing the open-skin format, not a visual claim about KOOK. The current KOOK browser bridge does not expose the logged-in page, so its room-specific visual details remain unverified. Once the reference page can be read, the scaffold can be styled from the two authorized rooms without adding unrelated service pages.
- Source: [open-voice-surface](./open-voice-surface/)
- Importable package: [open-voice-surface.wskin](./open-voice-surface.wskin)
- Shared component and permission rules: [skin development guide](../SKIN_DEVELOPMENT.md)
- Architecture and safety boundaries: [open skin spec](../OPEN_SKIN_SYSTEM_SPEC.zh-CN.md)
Binary file not shown.
@@ -0,0 +1,205 @@
{
"schemaVersion": 2,
"components": [
{
"id": "open-voice-home",
"name": "Open voice connection page",
"page": "home",
"mode": "surface",
"accessibleName": "WebSpeak connection page",
"permissions": ["ui.surface.replace"],
"actions": {},
"root": {
"tag": "main",
"part": "home",
"children": [
{
"tag": "header",
"part": "home-header",
"children": [
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
{ "tag": "span", "part": "brand-name", "children": [{ "text": "VOICE SPACE" }] },
{ "widget": "app.language-switcher", "part": "language" },
{ "widget": "app.skin-switcher", "part": "skin" }
]
},
{
"tag": "section",
"part": "connection-card",
"children": [
{ "tag": "p", "part": "eyebrow", "children": [{ "text": "TEAM SPEAK · VOICE CLIENT" }] },
{ "tag": "h1", "part": "title", "children": [{ "text": "Connect with your people" }] },
{ "tag": "p", "part": "description", "children": [{ "text": "Join a voice server and continue where your community meets." }] },
{ "widget": "home.connection-form", "part": "connection-form" }
]
},
{
"tag": "footer",
"part": "home-footer",
"children": [{ "text": "Your connection and identity remain managed by WebSpeak." }]
}
]
}
},
{
"id": "open-voice-workspace",
"name": "Open voice workspace",
"page": "voice",
"mode": "surface",
"accessibleName": "WebSpeak voice workspace",
"permissions": [
"ui.surface.replace",
"session.status.read",
"servers.quickList.read",
"servers.quickList.switch",
"session.channels.read",
"session.members.read",
"session.channel.join"
],
"actions": {
"switch-server": {
"type": "quickServers.switch",
"args": { "quickServerId": "{{server.id}}" }
},
"join-channel": {
"type": "voice.joinChannel",
"args": { "channelId": "{{channel.id}}" }
}
},
"root": {
"tag": "main",
"part": "workspace",
"children": [
{
"tag": "header",
"part": "workspace-header",
"children": [
{ "tag": "span", "part": "brand-mark", "children": [{ "text": "W" }] },
{ "tag": "strong", "part": "server-title", "children": [{ "text": "{{session.status.channelName}}" }] },
{ "widget": "app.language-switcher", "part": "language" },
{ "widget": "app.skin-switcher", "part": "skin" }
]
},
{
"tag": "nav",
"part": "quick-rail",
"attributes": { "aria-label": "Favorite and recent servers" },
"children": [
{
"tag": "div",
"part": "quick-server-item",
"repeat": { "path": "servers.quickList", "as": "server" },
"children": [
{
"tag": "button",
"part": "quick-server",
"attributes": {
"type": "button",
"aria-current": "{{server.current}}",
"aria-label": "Switch to {{server.label}}"
},
"events": { "click": "switch-server" },
"children": [
{ "tag": "span", "part": "server-monogram", "children": [{ "text": "{{server.label}}" }] },
{
"tag": "small",
"part": "server-kind",
"when": { "path": "server.favorite", "equals": true },
"children": [{ "text": "Favorite" }]
},
{
"tag": "small",
"part": "server-kind",
"when": { "path": "server.kind", "equals": "recent" },
"children": [{ "text": "Recent" }]
}
]
}
]
}
]
},
{
"tag": "nav",
"part": "channels",
"attributes": { "aria-label": "Voice channels" },
"children": [
{ "tag": "h2", "part": "section-title", "children": [{ "text": "VOICE CHANNELS" }] },
{
"tag": "div",
"part": "channel-item",
"repeat": { "path": "session.channels", "as": "channel" },
"children": [
{
"tag": "button",
"part": "channel-row",
"attributes": {
"type": "button",
"aria-current": "{{channel.current}}",
"aria-label": "Join {{channel.name}}"
},
"events": { "dblclick": "join-channel", "keydown": "join-channel" },
"children": [
{ "tag": "span", "part": "channel-glyph", "children": [{ "text": "◖" }] },
{ "tag": "span", "part": "channel-name", "children": [{ "text": "{{channel.name}}" }] },
{ "tag": "small", "part": "channel-count", "children": [{ "text": "{{channel.memberCount}}" }] }
]
}
]
}
]
},
{
"tag": "section",
"part": "conversation",
"children": [
{
"tag": "header",
"part": "conversation-heading",
"children": [
{ "tag": "h1", "part": "channel-title", "children": [{ "text": "{{session.status.channelName}}" }] },
{ "tag": "span", "part": "connection-state", "children": [{ "text": "Connected" }] }
]
},
{ "widget": "voice.chat-panel", "part": "chat" },
{ "widget": "voice.screen-share-player", "part": "screen-share" }
]
},
{
"tag": "aside",
"part": "members-and-controls",
"children": [
{ "tag": "h2", "part": "section-title", "children": [{ "text": "IN THIS CHANNEL" }] },
{
"tag": "ul",
"part": "member-list",
"children": [
{
"tag": "li",
"part": "member-row",
"repeat": { "path": "session.members", "as": "member" },
"children": [
{ "tag": "span", "part": "member-avatar", "children": [{ "text": "{{member.name}}" }] },
{ "tag": "span", "part": "member-name", "children": [{ "text": "{{member.name}}" }] },
{
"tag": "small",
"part": "speaking-indicator",
"when": { "path": "member.speaking", "equals": true },
"attributes": { "aria-label": "Speaking" },
"children": [{ "text": "Speaking" }]
}
]
}
]
},
{ "widget": "voice.whisper-controls", "part": "whisper" },
{ "widget": "voice.audio-controls", "part": "audio" },
{ "widget": "voice.connection-controls", "part": "connection" },
{ "widget": "voice.disconnect-control", "part": "disconnect" }
]
}
]
}
}
]
}
@@ -0,0 +1,13 @@
{
"schemaVersion": 3,
"packageType": "open-skin",
"id": "community.open-voice-surface",
"name": "Open Voice Surface",
"version": "1.0.0",
"author": "WebSpeak Project",
"license": "AGPL-3.0-only",
"description": "A complete, script-free public voice client surface scaffold.",
"entry": "skin.css",
"components": "components.json",
"minAppVersion": "0.2.7-preview"
}
+294
View File
@@ -0,0 +1,294 @@
:root {
color-scheme: dark;
--skin-voice-bg: #111318;
--skin-voice-panel: #191c24;
--skin-voice-raised: #222631;
--skin-voice-text: #f0f1f5;
--skin-voice-muted: #969baa;
--skin-voice-accent: #8e7bff;
--skin-voice-live: #62d5a7;
}
[data-ws-plugin-part="open-voice-home"] {
min-height: 100vh;
display: grid;
grid-template-rows: auto 1fr auto;
justify-items: center;
gap: 32px;
padding: clamp(18px, 5vw, 56px);
color: var(--skin-voice-text);
background: radial-gradient(ellipse at 50% 42%, #25253c 0, var(--skin-voice-bg) 66%);
}
[data-ws-plugin-part="open-voice-home.home-header"] {
display: flex;
align-items: center;
gap: 12px;
width: min(100%, 1080px);
}
[data-ws-plugin-part="open-voice-home.brand-mark"],
[data-ws-plugin-part="open-voice-workspace.brand-mark"] {
display: grid;
place-items: center;
width: 38px;
height: 38px;
border-radius: 14px;
color: white;
background: var(--skin-voice-accent);
font-weight: 800;
}
[data-ws-plugin-part="open-voice-home.brand-name"] {
margin-right: auto;
font-size: 13px;
font-weight: 800;
letter-spacing: .14em;
}
[data-ws-plugin-part="open-voice-home.connection-card"] {
align-self: center;
width: min(100%, 520px);
padding: clamp(22px, 5vw, 42px);
border: 1px solid #ffffff17;
border-radius: 24px;
background: color-mix(in srgb, var(--skin-voice-panel) 94%, transparent);
box-shadow: 0 28px 90px #0008;
}
[data-ws-plugin-part="open-voice-home.eyebrow"],
[data-ws-plugin-part="open-voice-workspace.section-title"] {
color: var(--skin-voice-muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .14em;
}
[data-ws-plugin-part="open-voice-home.title"] {
margin: 10px 0;
font-size: clamp(27px, 5vw, 40px);
letter-spacing: -.04em;
}
[data-ws-plugin-part="open-voice-home.description"],
[data-ws-plugin-part="open-voice-home.home-footer"] {
color: var(--skin-voice-muted);
line-height: 1.6;
}
[data-ws-plugin-part="open-voice-workspace"] {
display: grid;
grid-template-columns: 72px 228px minmax(320px, 1fr) 252px;
grid-template-rows: 62px minmax(0, 1fr);
width: 100%;
min-height: 100vh;
color: var(--skin-voice-text);
background: var(--skin-voice-bg);
}
[data-ws-plugin-part="open-voice-workspace.workspace-header"] {
grid-column: 1 / -1;
display: flex;
align-items: center;
gap: 14px;
padding: 0 18px;
border-bottom: 1px solid #ffffff12;
background: #171920;
}
[data-ws-plugin-part="open-voice-workspace.server-title"] { margin-right: auto; }
[data-ws-plugin-part="open-voice-workspace.quick-rail"] {
grid-column: 1;
grid-row: 2;
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
overflow-y: auto;
padding: 14px 8px;
background: #171920;
}
[data-ws-plugin-part="open-voice-workspace.quick-server"] {
display: grid;
justify-items: center;
gap: 4px;
width: 52px;
min-height: 58px;
padding: 5px;
border: 0;
border-radius: 16px;
color: var(--skin-voice-muted);
background: transparent;
cursor: pointer;
}
[data-ws-plugin-part="open-voice-workspace.quick-server"][aria-current="true"] {
color: white;
background: var(--skin-voice-accent);
}
[data-ws-plugin-part="open-voice-workspace.server-monogram"] {
display: grid;
place-items: center;
width: 36px;
height: 36px;
overflow: hidden;
border-radius: 12px;
background: #ffffff18;
font-size: 11px;
font-weight: 800;
}
[data-ws-plugin-part="open-voice-workspace.server-kind"] { font-size: 8px; }
[data-ws-plugin-part="open-voice-workspace.channels"],
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] {
min-height: 0;
overflow: auto;
padding: 18px 12px;
background: var(--skin-voice-panel);
}
[data-ws-plugin-part="open-voice-workspace.channels"] { grid-column: 2; grid-row: 2; }
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] { grid-column: 4; grid-row: 2; }
[data-ws-plugin-part="open-voice-workspace.channel-row"] {
display: flex;
align-items: center;
gap: 9px;
width: 100%;
margin-top: 4px;
padding: 9px 10px;
border: 0;
border-radius: 8px;
color: var(--skin-voice-muted);
background: transparent;
text-align: left;
cursor: pointer;
}
[data-ws-plugin-part="open-voice-workspace.channel-row"][aria-current="true"] {
color: var(--skin-voice-text);
background: var(--skin-voice-raised);
}
[data-ws-plugin-part="open-voice-workspace.channel-name"] { flex: 1; }
[data-ws-plugin-part="open-voice-workspace.channel-count"] { font-size: 11px; }
[data-ws-plugin-part="open-voice-workspace.conversation"] {
grid-column: 3;
grid-row: 2;
display: grid;
grid-template-rows: auto minmax(0, 1fr) auto;
min-width: 0;
min-height: 0;
padding: 18px;
gap: 12px;
}
[data-ws-plugin-part="open-voice-workspace.conversation-heading"] {
display: flex;
align-items: center;
gap: 12px;
min-height: 46px;
border-bottom: 1px solid #ffffff12;
}
[data-ws-plugin-part="open-voice-workspace.channel-title"] { margin-right: auto; }
[data-ws-plugin-part="open-voice-workspace.connection-state"] { color: var(--skin-voice-live); font-size: 12px; }
[data-ws-plugin-part="open-voice-workspace.member-list"] {
display: grid;
gap: 8px;
margin: 12px 0 20px;
padding: 0;
list-style: none;
}
[data-ws-plugin-part="open-voice-workspace.member-row"] {
display: grid;
grid-template-columns: 34px minmax(0, 1fr);
align-items: center;
column-gap: 10px;
color: var(--skin-voice-text);
font-size: 12px;
}
[data-ws-plugin-part="open-voice-workspace.member-avatar"] {
grid-row: span 2;
display: grid;
place-items: center;
width: 34px;
height: 34px;
overflow: hidden;
border-radius: 50%;
color: white;
background: var(--skin-voice-raised);
font-weight: 700;
}
[data-ws-plugin-part="open-voice-workspace.speaking-indicator"] { color: var(--skin-voice-live); font-size: 10px; }
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.chat"],
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.audio-controls"],
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.connection-controls"],
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.disconnect-control"],
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.whisper-controls"],
[data-ws-plugin-part="open-voice-workspace"] [data-ws-part="voice.screen-player"] {
border-radius: 12px;
color: var(--skin-voice-text);
background-color: var(--skin-voice-panel);
}
[data-ws-plugin-part="open-voice-workspace"] button:focus-visible {
outline: 2px solid var(--skin-voice-accent);
outline-offset: 2px;
}
@media (max-width: 800px) {
[data-ws-plugin-part="open-voice-workspace"] {
grid-template-columns: 58px minmax(0, 1fr);
grid-template-rows: 56px minmax(320px, 1fr) auto;
min-height: 100dvh;
}
[data-ws-plugin-part="open-voice-workspace.workspace-header"] { padding: 0 10px; }
[data-ws-plugin-part="open-voice-workspace.quick-rail"] { grid-column: 1; grid-row: 2; }
[data-ws-plugin-part="open-voice-workspace.channels"] {
grid-column: 1 / -1;
grid-row: 3;
display: flex;
gap: 6px;
overflow-x: auto;
overflow-y: hidden;
padding: 8px;
}
[data-ws-plugin-part="open-voice-workspace.section-title"] { display: none; }
[data-ws-plugin-part="open-voice-workspace.channel-row"] { width: max-content; min-width: 130px; margin: 0; }
[data-ws-plugin-part="open-voice-workspace.conversation"] {
grid-column: 2;
grid-row: 2;
padding: 10px;
}
[data-ws-plugin-part="open-voice-workspace.members-and-controls"] {
grid-column: 1 / -1;
grid-row: 4;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
padding: 8px;
}
[data-ws-plugin-part="open-voice-workspace.member-list"] { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
[data-ws-plugin-part="open-voice-workspace"] *,
[data-ws-plugin-part="open-voice-home"] * {
scroll-behavior: auto;
animation-duration: .01ms;
animation-iteration-count: 1;
transition-duration: .01ms;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
"scripts": {
"dev": "tsx src/index.ts",
"build": "tsc",
"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/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/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-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/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-wasm-interpreter.test.ts",
"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/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/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-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/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-wasm-interpreter.test.ts",
"verify": "npm test && npm run build && npm run web:build",
"start": "node dist/index.js",
"web:dev": "cd web && npx vite --host",
+87
View File
@@ -41,10 +41,97 @@ function errorCode(run: () => unknown, expected: string): void {
test("skin plugin accepts a bounded channel list with a double-click host action", () => {
const parsed = parseSkinPluginDocument(validDocument());
assert.equal(parsed.schemaVersion, 2, "legacy documents normalize to the current component schema");
assert.equal(parsed.components[0].mode, "widget");
assert.equal(parsed.components[0].root.repeat?.path, "session.channels");
assert.equal(parsed.components[0].root.children?.[0].events?.dblclick, "join");
});
test("component schema v2 can replace a public page and compose trusted host widgets", () => {
const document = validDocument();
document.schemaVersion = 2;
document.components[0].mode = "surface";
document.components[0].permissions = ["ui.surface.replace"];
document.components[0].actions = {};
document.components[0].root = {
tag: "main",
className: "custom-voice-shell",
children: [
{ widget: "voice.channel-panel", part: "channels" },
{ widget: "voice.chat-panel" },
],
};
const parsed = parseSkinPluginDocument(document);
assert.equal(parsed.components[0].mode, "surface");
assert.deepEqual(parsed.components[0].root.children?.map((node) => node.widget), ["voice.channel-panel", "voice.chat-panel"]);
assert.throws(() => parseSkinPluginDocument({ ...document, schemaVersion: 1 }), { code: "SKIN_PLUGIN_SCHEMA_UNSUPPORTED" });
});
test("page surfaces and stateful host widgets cannot be duplicated", () => {
const document = validDocument();
document.schemaVersion = 2;
document.components[0].mode = "surface";
document.components[0].permissions.push("ui.surface.replace");
document.components[0].root = { tag: "main", children: [{ widget: "voice.chat-panel" }] };
document.components.push({
...document.components[0],
id: "second-surface",
mode: "widget",
root: { tag: "section", children: [{ widget: "voice.chat-panel" }] },
});
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_WIDGET_DUPLICATE");
document.components[1].mode = "surface";
document.components[1].root.children = [{ widget: "voice.member-cards" }];
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_SURFACE_DUPLICATE");
});
test("replacing a built-in public page requires an explicit user approval capability", () => {
const document = validDocument();
document.schemaVersion = 2;
document.components[0].mode = "surface";
document.components[0].permissions = [];
document.components[0].actions = {};
document.components[0].root = { tag: "main", children: [{ tag: "h1", children: [{ text: "Custom client" }] }] };
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_PERMISSION_MISSING");
document.components[0].permissions = ["ui.surface.replace"];
assert.deepEqual(parseSkinPluginDocument(document).components[0].permissions, ["ui.surface.replace"]);
});
test("custom surfaces can safely render and switch unified favorite and recent server entries", () => {
const document = validDocument();
document.components[0].permissions = ["servers.quickList.read", "servers.quickList.switch"];
document.components[0].actions = {
switch: { type: "quickServers.switch", args: { quickServerId: "{{server.id}}" } },
};
document.components[0].root = {
tag: "nav",
repeat: { path: "servers.quickList", as: "server" },
children: [{ tag: "button", events: { dblclick: "switch" }, children: [{ text: "{{server.label}}" }] }],
};
const parsed = parseSkinPluginDocument(document).components[0];
assert.equal(parsed.root.repeat?.path, "servers.quickList");
assert.equal(parsed.actions.switch.type, "quickServers.switch");
document.components[0].permissions = ["servers.quickList.read"];
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_PERMISSION_MISSING");
});
test("host widget references stay allowlisted and cannot be used on the demo page", () => {
const unknownWidget = validDocument();
unknownWidget.schemaVersion = 2;
unknownWidget.components[0].root = { tag: "main", children: [{ widget: "filesystem.read" as never }] };
errorCode(() => parseSkinPluginDocument(unknownWidget), "SKIN_PLUGIN_WIDGET_INVALID");
const demoWidget = validDocument();
demoWidget.schemaVersion = 2;
demoWidget.components[0].page = "demo";
demoWidget.components[0].root = { tag: "main", children: [{ widget: "voice.chat-panel" }] };
errorCode(() => parseSkinPluginDocument(demoWidget), "SKIN_PLUGIN_WIDGET_INVALID");
});
test("KAAK v3 example uses only validated public session data and an explicit join action", async () => {
const source = await readFile(new URL("../../docs/examples/kaak-voice/components.json", import.meta.url), "utf8");
const parsed = parseSkinPluginJson(source);
+78 -12
View File
@@ -2,7 +2,8 @@
* Extension authors provide a bounded component tree and action declarations,
* never executable HTML, JavaScript, or browser APIs.
*/
export const SKIN_PLUGIN_SCHEMA_VERSION = 1 as const;
export const SKIN_PLUGIN_SCHEMA_VERSION = 2 as const;
export const SKIN_PLUGIN_SUPPORTED_SCHEMA_VERSIONS = Object.freeze([1, 2] as const);
export const SKIN_PLUGIN_DOCUMENT_LIMIT_BYTES = 256 * 1024;
export const SKIN_PLUGIN_COMPONENT_LIMIT = 32;
export const SKIN_PLUGIN_NODE_LIMIT = 256;
@@ -10,6 +11,7 @@ export const SKIN_PLUGIN_TREE_DEPTH_LIMIT = 16;
export const SKIN_PLUGIN_REPEAT_LIMIT = 100;
export const SKIN_PLUGIN_PERMISSIONS = Object.freeze({
"ui.surface.replace": Object.freeze({ policyVersion: 1, description: "Replace the built-in public page with a custom skin surface; the host recovery controls remain available." }),
"session.status.read": Object.freeze({ policyVersion: 1, description: "Read the current connection and channel summary." }),
"session.channels.read": Object.freeze({ policyVersion: 1, description: "Read the public TeamSpeak channel tree; the demo page uses synthetic sample data." }),
"session.members.read": Object.freeze({ policyVersion: 1, description: "Read visible member names and speaking states; the demo page uses synthetic sample data." }),
@@ -17,13 +19,31 @@ export const SKIN_PLUGIN_PERMISSIONS = Object.freeze({
"chat.channel.send": Object.freeze({ policyVersion: 1, description: "Send to the current public text channel; the demo page only simulates this action." }),
"favorites.read": Object.freeze({ policyVersion: 1, description: "Read favorite labels and opaque local identifiers, without server addresses or credentials." }),
"favorites.switch": Object.freeze({ policyVersion: 1, description: "Select a saved TeamSpeak server using the host's connection flow." }),
"servers.quickList.read": Object.freeze({ policyVersion: 1, description: "Read favorite and recent server labels and opaque local identifiers, without server addresses or credentials." }),
"servers.quickList.switch": Object.freeze({ policyVersion: 1, description: "Switch to a user-selected favorite or recent server through the host connection flow." }),
"session.channel.join": Object.freeze({ policyVersion: 1, description: "Request joining a visible TeamSpeak channel through the host; the demo page only changes simulated state." }),
} as const);
export type SkinPluginPermission = keyof typeof SKIN_PLUGIN_PERMISSIONS;
export type SkinPluginPage = "home" | "voice" | "demo";
export type SkinPluginComponentMode = "widget" | "surface";
export const SKIN_PLUGIN_HOST_WIDGETS = Object.freeze([
"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.whisper-controls",
"voice.performance-panel",
"voice.connection-controls",
"voice.disconnect-control",
] as const);
export type SkinPluginHostWidget = typeof SKIN_PLUGIN_HOST_WIDGETS[number];
export type SkinPluginEvent = "click" | "dblclick" | "change" | "input" | "submit" | "keydown";
export type SkinPluginAction = "ui.setState" | "voice.joinChannel" | "favorites.switch" | "chat.sendMessage";
export type SkinPluginAction = "ui.setState" | "voice.joinChannel" | "favorites.switch" | "quickServers.switch" | "chat.sendMessage";
export interface SkinPluginActionDefinition {
type: SkinPluginAction;
@@ -31,6 +51,7 @@ export interface SkinPluginActionDefinition {
}
export interface SkinPluginNode {
widget?: SkinPluginHostWidget;
tag?: string;
text?: string;
part?: string;
@@ -48,6 +69,7 @@ export interface SkinPluginComponent {
id: string;
name: string;
page: SkinPluginPage;
mode?: SkinPluginComponentMode;
accessibleName: string;
permissions: SkinPluginPermission[];
state?: Record<string, string | number | boolean>;
@@ -56,7 +78,7 @@ export interface SkinPluginComponent {
}
export interface SkinPluginDocument {
schemaVersion: typeof SKIN_PLUGIN_SCHEMA_VERSION;
schemaVersion: 1 | typeof SKIN_PLUGIN_SCHEMA_VERSION;
components: SkinPluginComponent[];
}
@@ -84,30 +106,35 @@ const ATTRIBUTES = new Set([
"tabindex", "title", "type", "value", "viewbox", "width", "x", "x1", "x2", "y", "y1", "y2",
]);
const EVENTS = new Set<string>(["click", "dblclick", "change", "input", "submit", "keydown"]);
const ACTIONS = new Set<string>(["ui.setState", "voice.joinChannel", "favorites.switch", "chat.sendMessage"]);
const ACTIONS = new Set<string>(["ui.setState", "voice.joinChannel", "favorites.switch", "quickServers.switch", "chat.sendMessage"]);
const PERMISSIONS = new Set<string>(Object.keys(SKIN_PLUGIN_PERMISSIONS));
const HOST_WIDGETS = new Set<string>(SKIN_PLUGIN_HOST_WIDGETS);
const ACTION_ARGS: Record<SkinPluginAction, ReadonlySet<string>> = {
"ui.setState": new Set(["key", "value"]),
"voice.joinChannel": new Set(["channelId"]),
"favorites.switch": new Set(["favoriteId"]),
"quickServers.switch": new Set(["quickServerId"]),
"chat.sendMessage": new Set(["text"]),
};
const ACTION_PERMISSION: Record<SkinPluginAction, SkinPluginPermission | null> = {
"ui.setState": null,
"voice.joinChannel": "session.channel.join",
"favorites.switch": "favorites.switch",
"quickServers.switch": "servers.quickList.switch",
"chat.sendMessage": "chat.channel.send",
};
const COLLECTION_PERMISSION: Record<string, SkinPluginPermission> = {
"session.channels": "session.channels.read",
"session.members": "session.members.read",
"favorites.items": "favorites.read",
"servers.quickList": "servers.quickList.read",
"chat.messages": "chat.channel.read",
};
const COLLECTION_FIELDS: Record<string, ReadonlySet<string>> = {
"session.channels": new Set(["id", "name", "parentId", "depth", "memberCount", "current"]),
"session.members": new Set(["id", "name", "channelId", "status", "speaking", "self"]),
"favorites.items": new Set(["id", "label", "current", "kind"]),
"servers.quickList": new Set(["id", "label", "current", "kind", "favorite"]),
"chat.messages": new Set(["id", "author", "text", "time", "kind", "channelId"]),
};
const SESSION_STATUS_FIELDS = new Set(["connected", "connecting", "serverLabel", "channelId", "channelName", "userName"]);
@@ -161,28 +188,36 @@ function bindingPermissions(value: string, aliases: ReadonlyMap<string, string>,
export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
if (!isRecord(input)) fail("SKIN_PLUGIN_DOCUMENT_INVALID", "components.json must contain an object.");
onlyKeys(input, new Set(["schemaVersion", "components"]), "components.json");
if (input.schemaVersion !== SKIN_PLUGIN_SCHEMA_VERSION || !Array.isArray(input.components)
if (!SKIN_PLUGIN_SUPPORTED_SCHEMA_VERSIONS.includes(input.schemaVersion as 1 | 2) || !Array.isArray(input.components)
|| !input.components.length || input.components.length > SKIN_PLUGIN_COMPONENT_LIMIT) {
fail("SKIN_PLUGIN_DOCUMENT_INVALID", "components.json uses an unsupported schema or component count.");
}
const ids = new Set<string>();
const inputSchemaVersion = input.schemaVersion as 1 | 2;
const components = input.components.map((rawComponent, componentIndex): SkinPluginComponent => {
if (!isRecord(rawComponent)) fail("SKIN_PLUGIN_COMPONENT_INVALID", `Component ${componentIndex} must be an object.`);
onlyKeys(rawComponent, new Set(["id", "name", "page", "accessibleName", "permissions", "actions", "state", "root"]), "Skin plugin component");
onlyKeys(rawComponent, new Set(["id", "name", "page", "mode", "accessibleName", "permissions", "actions", "state", "root"]), "Skin plugin component");
if (inputSchemaVersion === 1 && rawComponent.mode !== undefined) fail("SKIN_PLUGIN_SCHEMA_UNSUPPORTED", "Page surfaces require components schema version 2.");
const id = identifier(rawComponent.id, "component.id");
if (ids.has(id)) fail("SKIN_PLUGIN_COMPONENT_DUPLICATE", "Component IDs must be unique within the skin.");
ids.add(id);
if (!(rawComponent.page === "home" || rawComponent.page === "voice" || rawComponent.page === "demo")) fail("SKIN_PLUGIN_COMPONENT_INVALID", "A plugin component must target a public page.");
const page = rawComponent.page as SkinPluginPage;
const mode = rawComponent.mode === undefined ? "widget" : rawComponent.mode;
if (mode !== "widget" && mode !== "surface") fail("SKIN_PLUGIN_COMPONENT_INVALID", "A component mode must be widget or surface.");
if (mode === "surface" && page === "demo") fail("SKIN_PLUGIN_COMPONENT_INVALID", "Page surfaces are supported only for the home and voice client pages.");
const name = boundedText(rawComponent.name, "component.name", 80);
const accessibleName = boundedText(rawComponent.accessibleName, "component.accessibleName", 120);
if (!Array.isArray(rawComponent.permissions) || rawComponent.permissions.length > 8) fail("SKIN_PLUGIN_PERMISSION_INVALID", "Each component may request at most eight explicit permissions.");
if (!Array.isArray(rawComponent.permissions) || rawComponent.permissions.length > 11) fail("SKIN_PLUGIN_PERMISSION_INVALID", "Each component may request at most eleven explicit permissions.");
const permissions: SkinPluginPermission[] = [];
for (const permission of rawComponent.permissions) {
if (typeof permission !== "string" || !PERMISSIONS.has(permission)) fail("SKIN_PLUGIN_PERMISSION_UNKNOWN", "The component requests an unsupported permission.");
if (permissions.includes(permission as SkinPluginPermission)) fail("SKIN_PLUGIN_PERMISSION_DUPLICATE", "A component permission is duplicated.");
permissions.push(permission as SkinPluginPermission);
}
if (mode === "surface" && !permissions.includes("ui.surface.replace")) {
fail("SKIN_PLUGIN_PERMISSION_MISSING", "A page surface requires ui.surface.replace so users can approve page replacement explicitly.");
}
const state: Record<string, string | number | boolean> = Object.create(null) as Record<string, string | number | boolean>;
if (rawComponent.state !== undefined) {
if (!isRecord(rawComponent.state) || Object.keys(rawComponent.state).length > 32) fail("SKIN_PLUGIN_STATE_INVALID", "A component may declare up to 32 local state values.");
@@ -221,6 +256,7 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
}
if (rawAction.type === "voice.joinChannel" && typeof args.channelId !== "string") fail("SKIN_PLUGIN_ACTION_INVALID", "voice.joinChannel requires a channelId binding.");
if (rawAction.type === "favorites.switch" && typeof args.favoriteId !== "string") fail("SKIN_PLUGIN_ACTION_INVALID", "favorites.switch requires a favoriteId binding.");
if (rawAction.type === "quickServers.switch" && typeof args.quickServerId !== "string") fail("SKIN_PLUGIN_ACTION_INVALID", "quickServers.switch requires a quickServerId binding.");
if (rawAction.type === "chat.sendMessage" && typeof args.text !== "string") fail("SKIN_PLUGIN_ACTION_INVALID", "chat.sendMessage requires a text binding.");
actions[actionId] = { type: rawAction.type as SkinPluginAction, args };
}
@@ -229,9 +265,18 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
componentNodes += 1;
if (componentNodes > SKIN_PLUGIN_NODE_LIMIT) fail("SKIN_PLUGIN_COMPLEXITY_LIMIT", "A component contains too many template nodes.");
if (depth > SKIN_PLUGIN_TREE_DEPTH_LIMIT || !isRecord(rawNode)) fail("SKIN_PLUGIN_TREE_INVALID", "A component tree is too deep or contains an invalid node.");
onlyKeys(rawNode, new Set(["tag", "text", "part", "className", "attributes", "asset", "bindValue", "repeat", "when", "events", "children"]), "Component node");
if ((rawNode.tag === undefined) === (rawNode.text === undefined)) fail("SKIN_PLUGIN_TREE_INVALID", "Each component node must define either a tag or text, but not both.");
onlyKeys(rawNode, new Set(["widget", "tag", "text", "part", "className", "attributes", "asset", "bindValue", "repeat", "when", "events", "children"]), "Component node");
if (inputSchemaVersion === 1 && rawNode.widget !== undefined) fail("SKIN_PLUGIN_SCHEMA_UNSUPPORTED", "Host widgets require components schema version 2.");
const nodeKinds = Number(rawNode.widget !== undefined) + Number(rawNode.tag !== undefined) + Number(rawNode.text !== undefined);
if (nodeKinds !== 1) fail("SKIN_PLUGIN_TREE_INVALID", "Each component node must define exactly one of widget, tag, or text.");
const node: SkinPluginNode = {};
if (rawNode.widget !== undefined) {
if (typeof rawNode.widget !== "string" || !HOST_WIDGETS.has(rawNode.widget)) fail("SKIN_PLUGIN_WIDGET_INVALID", "The component requests an unsupported host widget.");
if (page === "demo") fail("SKIN_PLUGIN_WIDGET_INVALID", "Host widgets are available only on the home and voice client pages.");
const widgetOnlyKeys = new Set(["widget", "part", "className", "when"]);
onlyKeys(rawNode, widgetOnlyKeys, "Host widget node");
node.widget = rawNode.widget as SkinPluginHostWidget;
}
if (rawNode.tag !== undefined) {
if (typeof rawNode.tag !== "string" || !ELEMENTS.has(rawNode.tag)) fail("SKIN_PLUGIN_ELEMENT_INVALID", "The component uses an unsupported HTML element.");
node.tag = rawNode.tag;
@@ -281,7 +326,7 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
if (!isRecord(rawNode.repeat)) fail("SKIN_PLUGIN_REPEAT_INVALID", "A repeat declaration must be an object.");
onlyKeys(rawNode.repeat, new Set(["path", "as"]), "Repeat declaration");
const path = boundedText(rawNode.repeat.path, "repeat.path", 120);
if (!(path === "session.channels" || path === "session.members" || path === "favorites.items" || path === "chat.messages")) fail("SKIN_PLUGIN_REPEAT_INVALID", "A component may repeat only a registered public collection.");
if (!(path === "session.channels" || path === "session.members" || path === "favorites.items" || path === "servers.quickList" || path === "chat.messages")) fail("SKIN_PLUGIN_REPEAT_INVALID", "A component may repeat only a registered public collection.");
const permission = COLLECTION_PERMISSION[path];
if (!permissions.includes(permission)) fail("SKIN_PLUGIN_PERMISSION_MISSING", `Repeating ${path} requires ${permission}.`);
const alias = identifier(rawNode.repeat.as, "repeat.as");
@@ -326,9 +371,30 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
return node;
};
const root = walk(rawComponent.root, 1);
if (!root.tag) fail("SKIN_PLUGIN_TREE_INVALID", "A plugin component root must be an element.");
return { id, name, page, accessibleName, permissions, actions, ...(Object.keys(state).length ? { state } : {}), root };
if (!root.tag && !root.widget) fail("SKIN_PLUGIN_TREE_INVALID", "A plugin component root must be an element or a host widget.");
if (mode === "surface" && (!root.tag || root.repeat || root.when || !root.children?.length)) {
fail("SKIN_PLUGIN_TREE_INVALID", "A page surface root must be a visible container with at least one child.");
}
return { id, name, page, mode, accessibleName, permissions, actions, ...(Object.keys(state).length ? { state } : {}), root };
});
const surfaces = new Set<SkinPluginPage>();
const widgetsByPage = new Map<SkinPluginPage, Set<SkinPluginHostWidget>>();
for (const component of components) {
if (component.mode === "surface") {
if (surfaces.has(component.page)) fail("SKIN_PLUGIN_SURFACE_DUPLICATE", "A skin may define only one page surface per public page.");
surfaces.add(component.page);
}
const pageWidgets = widgetsByPage.get(component.page) ?? new Set<SkinPluginHostWidget>();
const visit = (node: SkinPluginNode) => {
if (node.widget) {
if (pageWidgets.has(node.widget)) fail("SKIN_PLUGIN_WIDGET_DUPLICATE", "A skin may mount each stateful host widget only once per page.");
pageWidgets.add(node.widget);
}
node.children?.forEach(visit);
};
visit(component.root);
widgetsByPage.set(component.page, pageWidgets);
}
return { schemaVersion: SKIN_PLUGIN_SCHEMA_VERSION, components };
}
+56 -8
View File
@@ -5,6 +5,7 @@ import {
type SkinPluginActionDefinition,
type SkinPluginComponent,
type SkinPluginDocument,
type SkinPluginHostWidget,
type SkinPluginNode,
} from "../../../src/shared/skin-plugin.js";
import { approveSkinPluginComponents, getMissingSkinPluginApprovals, isSkinPluginComponentApproved, revokeSkinPluginApprovals } from "../services/skin-plugin-approval.js";
@@ -12,6 +13,7 @@ import { approveSkinPluginComponents, getMissingSkinPluginApprovals, isSkinPlugi
type Scalar = string | number | boolean;
type SafeContext = Record<string, unknown>;
type HostAction = (args: Record<string, Scalar>, component: SkinPluginComponent) => void | Promise<void>;
type HostWidget = () => VNodeChild;
const eventProps: Record<string, string> = {
click: "onClick", dblclick: "onDblclick", change: "onChange", input: "onInput", submit: "onSubmit", keydown: "onKeydown",
@@ -27,16 +29,22 @@ export default defineComponent({
data: { type: Object as PropType<SafeContext>, required: true },
assets: { type: Object as PropType<Record<string, Blob>>, required: true },
actions: { type: Object as PropType<Record<string, HostAction>>, required: true },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, HostWidget>>>, default: () => ({}) },
},
setup(props) {
emits: {
"surface-change": (_active: boolean) => typeof _active === "boolean",
"restore-skin": () => true,
},
setup(props, { emit }) {
const denied = ref(false);
const surfaceSuppressed = ref(false);
const manageOpen = ref(false);
const refresh = ref(0);
const stateByComponent = reactive<Record<string, Record<string, Scalar>>>({});
const objectUrls = new Map<string, string>();
const validatedDocument = computed(() => {
try { return parseSkinPluginDocument(props.document); }
catch { return { schemaVersion: 1 as const, components: [] }; }
catch { return { schemaVersion: 2 as const, components: [] }; }
});
const matchingComponents = computed(() => validatedDocument.value.components.filter((component) => component.page === props.page));
const pendingApproval = computed(() => {
@@ -50,8 +58,17 @@ export default defineComponent({
refresh.value;
return matchingComponents.value.filter((component) => isSkinPluginComponentApproved(props.skinId, props.skinVersion, component));
});
const surfaceCandidate = computed(() => activeComponents.value.find((component) => component.mode === "surface") ?? null);
const activeSurface = computed(() => surfaceSuppressed.value ? null : surfaceCandidate.value);
const renderedComponents = computed(() => activeComponents.value.filter((component) =>
component.mode !== "surface" || component !== surfaceCandidate.value || !surfaceSuppressed.value));
watch(() => [props.skinId, props.skinVersion, props.document, props.page], () => { denied.value = false; refresh.value += 1; }, { immediate: true });
watch(() => [props.skinId, props.skinVersion, props.document, props.page], () => {
denied.value = false;
surfaceSuppressed.value = false;
refresh.value += 1;
}, { immediate: true });
watch(activeSurface, (surface) => emit("surface-change", Boolean(surface)), { immediate: true, flush: "sync" });
function localState(component: SkinPluginComponent): Record<string, Scalar> {
const key = `${props.skinId}/${component.id}`;
@@ -114,6 +131,20 @@ export default defineComponent({
}
function renderNode(component: SkinPluginComponent, node: SkinPluginNode, context: SafeContext, state: Record<string, Scalar>, skipRepeat = false): VNodeChild {
if (node.widget) {
if (node.when) {
const value = resolvePath(node.when.path, context, state);
if (node.when.equals !== undefined ? value !== node.when.equals : !value) return null;
}
const widget = props.widgets[node.widget];
if (!widget) return null;
return h("div", {
class: ["ws-plugin-host-widget", node.className],
"data-ws-plugin-widget": node.widget,
"data-ws-plugin-part": node.part ? `${component.id}.${node.part}` : component.id,
"aria-label": component.accessibleName,
}, [widget()]);
}
if (!node.tag) return interpolate(node.text ?? "", context, state);
if (!skipRepeat && node.repeat) {
const values = resolvePath(node.repeat.path, context, state);
@@ -194,12 +225,13 @@ export default defineComponent({
onUnmounted(() => { objectUrls.forEach((url) => URL.revokeObjectURL(url)); objectUrls.clear(); });
return () => {
const nodes: VNodeChild[] = activeComponents.value.map((component) => h("div", {
const nodes: VNodeChild[] = renderedComponents.value.map((component) => h("div", {
key: `${props.skinId}:${component.id}`,
class: "ws-plugin-component",
class: ["ws-plugin-component", component.mode === "surface" && "ws-plugin-surface"],
"data-ws-plugin-component": component.id,
"data-ws-plugin-name": component.name,
"data-ws-plugin-part": component.id,
...(component.mode === "surface" ? { "data-ws-plugin-surface": component.page } : {}),
"aria-label": component.accessibleName,
}, [renderNode(component, component.root, props.data, localState(component))]));
const hasPermissions = matchingComponents.value.some((component) => component.permissions.length > 0);
@@ -210,7 +242,23 @@ export default defineComponent({
"aria-label": "管理皮肤组件权限 / Manage skin component access",
onClick: openAccessManager,
}, "权限 / Access")]) : null;
if (!showConsent) return h(Fragment, null, [...nodes, ...(accessToggle ? [accessToggle] : [])]);
const surfaceRecovery = activeSurface.value ? h(Teleport, { to: "body" }, [h("button", {
type: "button",
class: "ws-plugin-surface-recovery",
"aria-label": "返回 WebSpeak 标准界面 / Return to the built-in interface",
onClick: () => { surfaceSuppressed.value = true; },
}, "标准界面 / Built-in UI")]) : null;
const skinRecovery = activeSurface.value ? h(Teleport, { to: "body" }, [h("button", {
type: "button",
class: "ws-plugin-surface-reset",
"aria-label": "恢复内置皮肤 / Restore the built-in skin",
onClick: () => emit("restore-skin"),
}, "恢复内置皮肤 / Reset skin")]) : null;
const recoveryControls = [
...(surfaceRecovery ? [surfaceRecovery] : []),
...(skinRecovery ? [skinRecovery] : []),
];
if (!showConsent) return h(Fragment, null, [...nodes, ...(accessToggle ? [accessToggle] : []), ...recoveryControls]);
const requested = accessComponents.value;
const hasMissing = pendingApproval.value.length > 0;
@@ -222,7 +270,7 @@ export default defineComponent({
h("strong", null, component.name),
h("ul", null, component.permissions.map((permission) => h("li", { key: permission }, permissionLabel(permission)))),
])),
h("p", { class: "ws-plugin-consent-note" }, "组件不能运行脚本、访问浏览器存储、读取连接地址/密码或控制麦克风。/ Components cannot run code, access storage or credentials, or control the microphone."),
h("p", { class: "ws-plugin-consent-note" }, "页面可以替换公开客户端外观;内置控件仍由 WebSpeak 处理。皮肤不能运行脚本、访问网络或存储,也不能读取连接地址、密码和身份材料。/ A surface can replace the public client UI while built-in controls remain host-owned. Skins cannot run code, access network or storage, or read connection targets, passwords, or identity material."),
h("div", { class: "ws-plugin-consent-actions" }, [
...(hasMissing ? [h("button", { type: "button", class: "secondary", onClick: closeOrDisable }, "暂不启用 / Keep disabled")]
: [h("button", { type: "button", class: "secondary", onClick: revokeAll }, "撤销全部授权 / Revoke all access")]),
@@ -230,7 +278,7 @@ export default defineComponent({
]),
]),
])]);
return h(Fragment, null, [...nodes, ...(accessToggle ? [accessToggle] : []), consent]);
return h(Fragment, null, [...nodes, ...(accessToggle ? [accessToggle] : []), ...recoveryControls, consent]);
};
},
});
+4 -1
View File
@@ -115,6 +115,9 @@ export function usePublicSkin(options: PublicSkinOptions = {}) {
if (!skinLoadError.value) return;
await select(fallbackId());
}
async function switchToBuiltIn(): Promise<void> {
await select(fallbackId());
}
return { activeSkin, activeSkinId, skinReady, skinLoadError, installedSkins, catalogSkins, initialize, select, cancel, reset, switchToBuiltInAfterLoadError };
return { activeSkin, activeSkinId, skinReady, skinLoadError, installedSkins, catalogSkins, initialize, select, cancel, reset, switchToBuiltIn, switchToBuiltInAfterLoadError };
}
+49
View File
@@ -331,6 +331,37 @@ test("schema version 3 supports arbitrary public layouts and validated declarati
await assert.rejects(importSkinPack(makeSkinV3(missingAsset, "[data-ws-part=app] { color: red; }")), (error: unknown) => error instanceof SkinPackError && error.code === "SKIN_PLUGIN_ASSET_INVALID");
});
test("schema version 3 accepts a schema v2 full-page surface with host widgets", async () => {
const components = {
schemaVersion: 2,
components: [{
id: "custom-voice-surface",
name: "Custom voice surface",
page: "voice",
mode: "surface",
accessibleName: "Custom voice workspace",
permissions: ["ui.surface.replace"],
actions: {},
root: {
tag: "main",
className: "custom-workspace",
children: [
{ widget: "voice.channel-panel" },
{ widget: "voice.member-cards" },
{ widget: "voice.chat-panel" },
{ widget: "voice.audio-controls" },
],
},
}],
};
const skin = await importSkinPack(makeSkinV3(components, '[data-ws-part="app"] { --skin-surface: #123456; }'));
assert.equal(skin.pluginData?.schemaVersion, 2);
assert.equal(skin.pluginData?.components[0].mode, "surface");
assert.deepEqual(skin.pluginData?.components[0].root.children?.map((node) => node.widget), [
"voice.channel-panel", "voice.member-cards", "voice.chat-panel", "voice.audio-controls",
]);
});
test("the distributable KAAK v3 package validates end to end", async () => {
const archive = await readFile(new URL("../../../docs/examples/kaak-voice.wskin", import.meta.url));
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
@@ -341,6 +372,24 @@ test("the distributable KAAK v3 package validates end to end", async () => {
assert.ok(skin.css.includes('data-ws-plugin-part="kaak-room-sidebar.channel-row"'));
});
test("the full voice surface example packages home, voice, and host-owned controls", async () => {
const archive = await readFile(new URL("../../../docs/examples/open-voice-surface.wskin", import.meta.url));
const file = new File([archive], "open-voice-surface.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.open-voice-surface");
assert.equal(skin.pluginData?.schemaVersion, 2);
assert.deepEqual(skin.pluginData?.components.map((component) => [component.page, component.mode]), [
["home", "surface"], ["voice", "surface"],
]);
const voiceSurface = skin.pluginData?.components.find((component) => component.page === "voice");
assert.ok(voiceSurface?.permissions.includes("ui.surface.replace"));
assert.ok(voiceSurface?.permissions.includes("servers.quickList.read"));
assert.ok(voiceSurface?.permissions.includes("servers.quickList.switch"));
assert.ok(voiceSurface?.permissions.includes("session.channels.read"));
assert.ok(voiceSurface?.permissions.includes("session.members.read"));
assert.ok(skin.css.includes("@media (max-width: 800px)"));
});
function makeSkinV2(layout: unknown, manifestChanges: Record<string, unknown> = {}): File {
const packageFiles: Record<string, Uint8Array> = {
"manifest.json": strToU8(JSON.stringify({
+58
View File
@@ -0,0 +1,58 @@
import type { QuickServer } from "./quick-servers.js";
import { splitTeamSpeakTarget } from "./teamspeak-target.js";
export interface SkinPluginQuickServer {
id: string;
label: string;
current: boolean;
kind: "favorite" | "recent";
favorite: boolean;
}
function randomOpaqueId(): string {
return globalThis.crypto?.randomUUID?.() ?? `quick-server-${Math.random().toString(36).slice(2)}`;
}
function containsConnectionTarget(label: string, address: string): boolean {
const candidates = new Set([address.trim()]);
try { candidates.add(splitTeamSpeakTarget(address).address.trim()); } catch { /* Persisted targets are validated on write. */ }
const normalizedLabel = label.toLocaleLowerCase();
return [...candidates].some((candidate) => candidate.length >= 3 && normalizedLabel.includes(candidate.toLocaleLowerCase()));
}
/** Projects local favorite/recent entries without exposing their connection targets. */
export function createSkinPluginQuickServerProjection(createId: () => string = randomOpaqueId) {
const opaqueIdByServerId = new Map<string, string>();
const targetByOpaqueId = new Map<string, QuickServer>();
return {
project(servers: readonly QuickServer[], isCurrent: (server: QuickServer) => boolean): SkinPluginQuickServer[] {
const activeServerIds = new Set(servers.map((server) => server.id));
for (const id of opaqueIdByServerId.keys()) if (!activeServerIds.has(id)) opaqueIdByServerId.delete(id);
targetByOpaqueId.clear();
return servers.map((server, index) => {
let opaqueId = opaqueIdByServerId.get(server.id);
if (!opaqueId) {
opaqueId = createId();
opaqueIdByServerId.set(server.id, opaqueId);
}
targetByOpaqueId.set(opaqueId, server);
const label = server.label.trim();
const safeLabel = !label || containsConnectionTarget(label, server.address)
? `${server.isFavorite ? "Favorite" : "Recent"} ${index + 1}`
: label;
return {
id: opaqueId,
label: safeLabel,
current: isCurrent(server),
kind: server.isFavorite ? "favorite" : "recent",
favorite: server.isFavorite,
};
});
},
resolve(opaqueId: string): QuickServer | undefined {
return targetByOpaqueId.get(opaqueId);
},
};
}
@@ -0,0 +1,74 @@
import assert from "node:assert/strict";
import test from "node:test";
import { parseSkinPluginDocument, type SkinPluginDocument } from "../../../src/shared/skin-plugin.js";
import {
approveSkinPluginComponents,
getMissingSkinPluginApprovals,
isSkinPluginComponentApproved,
revokeSkinPluginApprovals,
} from "./skin-plugin-approval.js";
import { createSkinPluginQuickServerProjection } from "./skin-plugin-context.js";
function surfaceDocument(): SkinPluginDocument {
return {
schemaVersion: 2,
components: [{
id: "custom-surface",
name: "Custom surface",
page: "voice",
mode: "surface",
accessibleName: "Custom voice page",
permissions: ["ui.surface.replace"],
actions: {},
root: { tag: "main", children: [{ tag: "h1", children: [{ text: "Custom client" }] }] },
}],
};
}
test("page replacement stays disabled until local approval and returns to the host after revocation", () => {
const storage = new Map<string, string>();
const previousStorage = Object.getOwnPropertyDescriptor(globalThis, "localStorage");
Object.defineProperty(globalThis, "localStorage", {
configurable: true,
value: {
getItem: (key: string) => storage.get(key) ?? null,
setItem: (key: string, value: string) => { storage.set(key, value); },
},
});
try {
const document = parseSkinPluginDocument(surfaceDocument());
const component = document.components[0];
assert.deepEqual(getMissingSkinPluginApprovals("test.skin", "1.0.0", document), [component]);
assert.equal(isSkinPluginComponentApproved("test.skin", "1.0.0", component), false);
approveSkinPluginComponents("test.skin", "1.0.0", [component]);
assert.deepEqual(getMissingSkinPluginApprovals("test.skin", "1.0.0", document), []);
assert.equal(isSkinPluginComponentApproved("test.skin", "1.0.0", component), true);
revokeSkinPluginApprovals("test.skin");
assert.equal(isSkinPluginComponentApproved("test.skin", "1.0.0", component), false);
} finally {
if (previousStorage) Object.defineProperty(globalThis, "localStorage", previousStorage);
else Reflect.deleteProperty(globalThis, "localStorage");
}
});
test("skin quick-server data redacts connection targets and resolves only host-generated opaque IDs", () => {
const servers = [
{ id: "192.0.2.10:9987", address: "192.0.2.10:9987", label: "192.0.2.10:9987", isFavorite: true },
{ id: "voice.example:9987", address: "voice.example:9987", label: "Friends (voice.example:9987)", isFavorite: false },
{ id: "voice2.example:9987", address: "voice2.example:9987", label: "Friends", isFavorite: true },
];
let sequence = 0;
const projection = createSkinPluginQuickServerProjection(() => `opaque-${++sequence}`);
const rows = projection.project(servers, (server) => server.id === "voice2.example:9987");
assert.deepEqual(rows.map(({ label, kind, favorite, current }) => [label, kind, favorite, current]), [
["Favorite 1", "favorite", true, false],
["Recent 2", "recent", false, false],
["Friends", "favorite", true, true],
]);
assert.equal(JSON.stringify(rows).includes("192.0.2.10"), false);
assert.equal(JSON.stringify(rows).includes("voice.example"), false);
assert.equal(projection.resolve("opaque-1")?.address, "192.0.2.10:9987");
assert.equal(projection.resolve("192.0.2.10:9987"), undefined);
});
+32 -1
View File
@@ -15,7 +15,7 @@
position: fixed;
right: 12px;
bottom: 12px;
z-index: 2147483000;
z-index: 2147483647;
min-height: 34px;
padding: 0 12px;
border: 1px solid #8197ac;
@@ -28,6 +28,37 @@
}
.ws-plugin-access-toggle:focus-visible { outline: 3px solid #fbbf24; outline-offset: 3px; }
.ws-plugin-surface {
display: block;
width: 100%;
min-height: var(--ws-viewport-height, 100vh);
}
.ws-plugin-host-widget {
min-width: 0;
min-height: 0;
}
.ws-plugin-surface-recovery,
.ws-plugin-surface-reset {
position: fixed;
left: 12px;
z-index: 2147483647;
min-height: 34px;
padding: 0 12px;
border: 1px solid #8197ac;
border-radius: 999px;
color: #f7fbff;
background: #182331ef;
box-shadow: 0 4px 18px #0006;
font: 12px/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
cursor: pointer;
}
.ws-plugin-surface-recovery { bottom: 12px; }
.ws-plugin-surface-reset { bottom: 54px; }
.ws-plugin-surface-recovery:focus-visible,
.ws-plugin-surface-reset:focus-visible { outline: 3px solid #fbbf24; outline-offset: 3px; }
.ws-plugin-consent {
width: min(640px, 100%);
max-height: min(86vh, 800px);
+196 -42
View File
@@ -20,10 +20,13 @@
:data="skinPluginContext"
:assets="activeSkin.assets"
:actions="skinPluginActions"
:widgets="skinPluginWidgets"
@surface-change="skinPluginSurfaceActive = $event"
@restore-skin="switchToBuiltIn"
/>
<!-- Connection / welcome screen -->
<section
v-if="!showVoiceShell"
v-if="!showVoiceShell && !skinPluginSurfaceActive"
class="join-page"
data-ws-part="home"
>
@@ -236,18 +239,6 @@
</div>
</main>
<IdentityImportDialog
v-if="identityImportOpen"
v-model="identityImportText"
:busy="identityImportBusy"
:reading="identityFileReading"
:error="identityImportError"
:t="t"
@close="closeIdentityImport"
@submit="importIdentity"
@file="readIdentityFile"
/>
<footer
class="join-footer"
data-ws-part="home.footer"
@@ -310,7 +301,7 @@
<!-- Connected application shell -->
<div
v-else
v-else-if="showVoiceShell && !skinPluginSurfaceActive"
:class="['app-shell', `mobile-view-${mobileSection}`]"
:data-performance-open="performancePanelOpen ? 'true' : 'false'"
:data-favorite-rail="accessMode === 'open' ? 'true' : 'false'"
@@ -540,13 +531,6 @@
<button v-if="favoriteSwitchFailed" type="button" @click="leaveVoiceWorkspace">{{ t('back') }}</button>
</div>
<ScreenShareSettingsDialog
v-if="screenShareSettingsOpen"
:model="screenShareControls"
:t="t"
@close="screenShareSettingsOpen = false"
/>
<div
v-if="voiceState.reconnecting || voiceState.reconnectFailed"
:class="['reconnect-banner', { failed: voiceState.reconnectFailed }]"
@@ -853,6 +837,25 @@
</nav>
</div>
<IdentityImportDialog
v-if="identityImportOpen"
v-model="identityImportText"
:busy="identityImportBusy"
:reading="identityFileReading"
:error="identityImportError"
:t="t"
@close="closeIdentityImport"
@submit="importIdentity"
@file="readIdentityFile"
/>
<ScreenShareSettingsDialog
v-if="screenShareSettingsOpen"
:model="screenShareControls"
:t="t"
@close="screenShareSettingsOpen = false"
/>
<MemberActionsMenu
:model="memberControls"
:is-mobile-viewport="isMobileViewport"
@@ -924,7 +927,7 @@
<script setup lang="ts">
import { observeMobileViewport } from "../services/mobile-viewport.js";
import { computed, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
import { computed, h, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
import Icon from "../components/Icon.vue";
import SkinPluginOutlet from "../components/SkinPluginOutlet.js";
import SkinLoadRecoveryNotice from "../components/SkinLoadRecoveryNotice.vue";
@@ -968,6 +971,7 @@ import { BUILTIN_DARK_SKIN, BUILTIN_LIGHT_SKIN } from "../services/skin-runtime.
import { applyTheme, getStoredTheme, type ThemeMode } from "../services/theme.js";
import { createScreenWakeLockController, getScreenWakeLockApi, type ScreenWakeLockController, type ScreenWakeLockSnapshot } from "../services/screen-wake-lock.js";
import { createMobileAwayController, type MobileAwayController } from "../services/mobile-away.js";
import { createSkinPluginQuickServerProjection } from "../services/skin-plugin-context.js";
import { combineTeamSpeakTarget, DEFAULT_TEAM_SPEAK_PORT, isValidTeamSpeakPort, splitTeamSpeakTarget } from "../services/teamspeak-target.js";
const {
@@ -1092,6 +1096,8 @@ let toastTimer: ReturnType<typeof setTimeout> | undefined;
const language = ref<Language>(getInitialLanguage());
const activeSkin = shallowRef<InstalledSkin | null>(null);
const skinPluginSurfaceActive = ref(false);
watch(activeSkin, () => { skinPluginSurfaceActive.value = false; }, { flush: "sync" });
const skinMessageOverrides = computed(() => resolveSkinMessages(activeSkin.value, language.value));
const { t: translate, localizedMessage, localizedAudioNotice, visibleErrorCode } = useWebClientI18n(language);
function t(key: string, variables: Record<string, string | number> = {}) {
@@ -1136,7 +1142,7 @@ const themeMode = ref<ThemeMode>(getStoredTheme());
applyTheme(themeMode.value);
const publicSkin = usePublicSkin({ activeSkin, themeMode, appVersion: () => appVersion.value });
const { activeSkinId, skinReady, skinLoadError, installedSkins, catalogSkins,
select: onSkinChange, initialize: initializeSkin, switchToBuiltInAfterLoadError } = publicSkin;
select: onSkinChange, initialize: initializeSkin, switchToBuiltIn, switchToBuiltInAfterLoadError } = publicSkin;
const skinOptions = computed<SkinOption[]>(() => [
...catalogSkins.value.map((skin) => ({
value: skin.id,
@@ -1457,23 +1463,11 @@ async function submitFavoriteServerDraft(draft: FavoriteServerDraft): Promise<vo
const visiblePokes = computed(() => pokeNotifications.slice(-3));
const opaqueFavoriteTokenById = new Map<string, string>();
const skinPluginFavoriteTargets = new Map<string, QuickServer>();
const skinPluginFavorites = computed(() => {
const targets = quickServers.value.filter((server) => server.isFavorite);
const activeIds = new Set(targets.map((server) => server.id));
for (const id of opaqueFavoriteTokenById.keys()) if (!activeIds.has(id)) opaqueFavoriteTokenById.delete(id);
skinPluginFavoriteTargets.clear();
return targets.map((server) => {
let token = opaqueFavoriteTokenById.get(server.id);
if (!token) {
token = globalThis.crypto?.randomUUID?.() ?? `favorite-${Math.random().toString(36).slice(2)}`;
opaqueFavoriteTokenById.set(server.id, token);
}
skinPluginFavoriteTargets.set(token, server);
return { id: token, label: server.label, current: isQuickServerTarget(server), kind: "favorite" };
});
});
const skinPluginQuickServers = createSkinPluginQuickServerProjection();
const skinPluginQuickList = computed(() => skinPluginQuickServers.project(quickServers.value, isQuickServerTarget));
const skinPluginFavorites = computed(() => skinPluginQuickList.value
.filter((server) => server.favorite)
.map(({ favorite: _favorite, ...server }) => server));
const skinPluginContext = computed(() => ({
session: {
@@ -1502,6 +1496,7 @@ const skinPluginContext = computed(() => ({
}))),
},
favorites: { items: skinPluginFavorites.value },
servers: { quickList: skinPluginQuickList.value },
chat: {
messages: chat.visibleMessages.value.filter((message) => message.scope === "channel").map((message) => ({
id: message.id,
@@ -1522,8 +1517,13 @@ const skinPluginActions = {
},
"favorites.switch": (args: Record<string, string | number | boolean>) => {
if (accessMode.value !== "open" || typeof args.favoriteId !== "string") return;
const target = skinPluginFavoriteTargets.get(args.favoriteId);
if (target?.isFavorite) connectQuickServer(target);
const target = skinPluginQuickServers.resolve(args.favoriteId);
if (target?.isFavorite && quickServers.value.some((server) => server.id === target.id && server.isFavorite)) connectQuickServer(target);
},
"quickServers.switch": (args: Record<string, string | number | boolean>) => {
if (accessMode.value !== "open" || typeof args.quickServerId !== "string") return;
const target = skinPluginQuickServers.resolve(args.quickServerId);
if (target && quickServers.value.some((server) => server.id === target.id)) connectQuickServer(target);
},
"chat.sendMessage": (args: Record<string, string | number | boolean>) => {
if (!voiceState.connected || typeof args.text !== "string" || !currentChannel.value?.id) return;
@@ -1533,6 +1533,160 @@ const skinPluginActions = {
},
};
const skinPluginWidgets = {
"home.connection-form": () => h(JoinForm, {
autofocusNickname: !isMobileViewport.value,
serverHost: serverHost.value,
"onUpdate:serverHost": (value: string) => { serverHost.value = value; },
serverPort: serverPort.value,
"onUpdate:serverPort": (value: string) => { serverPort.value = value; },
serverPassword: serverPassword.value,
"onUpdate:serverPassword": (value: string) => { serverPassword.value = value; },
nickname: nickname.value,
"onUpdate:nickname": (value: string) => { nickname.value = value; },
channel: channel.value,
"onUpdate:channel": (value: string) => { channel.value = value; },
rememberIdentity: rememberIdentity.value,
"onUpdate:rememberIdentity": (value: boolean) => { rememberIdentity.value = value; },
accelerationRelayId: accelerationRelayId.value,
"onUpdate:accelerationRelayId": (value: string) => { accelerationRelayId.value = value; },
accessMode: accessMode.value,
openTargetPrefillBlocked: openTargetPrefillBlocked.value,
accelerationRelays: accelerationRelays.value,
quickServers: quickServers.value,
isFavorite: isFavorite.value,
identityExportBusy: identityExportBusy.value,
hasIdentity: Boolean(identityMaterial.value),
connecting: voiceState.connecting,
joinDisabled: !canJoin.value || serverConfigLoading.value || !identityReady.value || voiceState.connecting,
t,
onConnect: doConnect,
onDisconnect: doDisconnect,
onSelectServer: selectLocalServer,
onToggleFavorite: toggleFavorite,
onToggleQuickFavorite: toggleQuickFavorite,
onImportIdentity: openIdentityImport,
onExportIdentity: exportIdentity,
}),
"app.skin-switcher": () => h(SkinSwitcher, {
modelValue: activeSkinId.value,
"onUpdate:modelValue": (value: string) => { activeSkinId.value = value; },
class: "skin-switcher",
menuLabel: t("skinSelector"),
options: skinOptions.value,
onChange: onSkinChange,
}),
"app.language-switcher": () => h(LanguageSwitcher, {
modelValue: language.value,
"onUpdate:modelValue": (value: Language) => { language.value = value; },
menuLabel: t("languageMenu"),
onChange: persistLanguage,
}),
"voice.channel-panel": () => h(ChannelMemberPanel, {
query: memberQuery.value,
"onUpdate:query": (value: string) => { memberQuery.value = value; },
model: memberControls,
filteredMemberChannels: filteredMemberChannels.value,
currentChannelId: currentChannel.value?.id,
mobileVisible: true,
isMobileViewport: isMobileViewport.value,
volumes,
avatarStyle,
avatarInitial,
rangeStyle,
t,
onSelectChannel: selectChannel,
onVolumeInput: onVolInput,
}),
"voice.member-cards": () => h(VoiceMemberCards, {
currentMembers: currentMembers.value,
isMobileViewport: isMobileViewport.value,
sharing: memberSharingState,
controls: screenShareControls,
isSpeaking,
avatarStyle,
avatarInitial,
t,
onMemberActions: openMemberActions,
onStopShare: stopScreenShare,
}),
"voice.chat-panel": () => h(ChatPanel, {
model: chat,
t,
currentChannelName: currentChannelName.value,
mobileHidden: false,
serverEvents,
avatarStyle,
avatarInitial,
messageAvatar,
formatTime,
}),
"voice.audio-controls": () => isMobileViewport.value
? h("div", { class: "mobile-voice-controls", role: "toolbar", "aria-label": t("desktopAudioControls") }, [
h("button", {
type: "button",
class: ["mobile-voice-toggle", microphoneMuted.value && "muted"],
"aria-label": t("microphone"),
"aria-pressed": !microphoneMuted.value,
onClick: toggleMicrophone,
}, [h(Icon, { name: microphoneMuted.value ? "mic-off" : "mic", size: 20 }), h("span", null, t("microphone"))]),
h("button", {
type: "button",
class: ["mobile-voice-toggle", outputMuted.value && "muted"],
"aria-label": t("speaker"),
"aria-pressed": !outputMuted.value,
onClick: toggleOutputMute,
}, [h(Icon, { name: outputMuted.value ? "volume-off" : "volume", size: 20 }), h("span", null, t("speaker"))]),
])
: h(AudioDock, {
model: audioDockState,
controls: audioControls,
t,
rangeStyle,
onSettings: () => { settingsOpen.value = true; },
onOutputMute: toggleOutputMute,
}),
"voice.screen-share-player": () => screenShareViewing.value ? h(ScreenSharePlayer, {
model: screenShareControls,
screenShareRemoteStream: screenShareRemoteStream.value,
screenShareRemoteVolume: screenShareRemoteVolume.value,
screenShareError: screenShareError.value,
leaveScreenShare,
avatarInitial,
t,
}) : null,
"voice.whisper-controls": () => whisperTargetIds.size ? h(WhisperControls, {
targets: whisperTargets.value,
active: whisperActive.value,
enabled: !isMobileViewport.value || mobileSection.value === "voice",
controls: audioControls,
t,
onClear: clearWhisperTargets,
}) : null,
"voice.performance-panel": () => h(VoicePerformancePanel, {
model: performance,
screenShareWebRtcStats,
t,
}),
"voice.connection-controls": () => h("div", { class: "ws-plugin-connection-controls", role: "toolbar", "aria-label": t("desktopAudioControls") }, [
h("button", { type: "button", "aria-label": t("copyInvite"), title: t("copyInvite"), onClick: doShare }, [h(Icon, { name: "share", size: 18 })]),
...(accessMode.value === "open" ? [h("button", {
type: "button",
"aria-label": t(isFavorite.value ? "removeFavorite" : "saveFavorite"),
"aria-pressed": isFavorite.value,
title: t(isFavorite.value ? "removeFavorite" : "saveFavorite"),
onClick: toggleFavorite,
}, [h(Icon, { name: "star", size: 18 })])] : []),
h("button", { type: "button", "aria-label": t("exit"), title: t("exit"), onClick: leaveVoiceWorkspace }, [h(Icon, { name: "door", size: 18 }), h("span", null, t("exit"))]),
]),
"voice.disconnect-control": () => h("button", {
type: "button",
class: "ws-plugin-disconnect-control",
"aria-label": t("exit"),
onClick: leaveVoiceWorkspace,
}, [h(Icon, { name: "door", size: 18 }), h("span", null, t("exit"))]),
};
watch(() => pokeNotifications.length, (length, previousLength) => {
const latest = pokeNotifications[length - 1];
if (!latest || length <= previousLength) return;