fix: expose server identity and refine KAAK client

This commit is contained in:
illusia committed 2026-10-11 17:14:56 +08:00
1 parent e8164abafe
commit 17fb27b89a
28 files changed
+1504 -334

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ Chat visibility is kept separately for each active TeamSpeak channel, so collaps
While the WebSpeak performance card is sampling, its refresh icon spins to show the busy state; the animation is disabled when reduced motion is requested.
KAAK is a schema v3 open-skin package with full connection and voice-workspace surfaces. Its desktop voice page follows KOOK's proportions: an 80px server rail, a 290px channel pane, a 40px top bar, a central participant stage, right-side chat attached to the current voice channel, and a lower-left voice dock. The server rail uses KOOK's rounded-square silhouette and left-edge active marker, with distinct colored monogram tiles as placeholders. WebSpeak currently exposes the saved server label but no server icon image, so these tiles do not copy KOOK's artwork or expose a connection address. The host provides a stable color-tone number derived only from the privacy-safe label, so a tile keeps its color when the saved list order changes. The KOOK voice room is the point-to-point visual reference: composition, member presentation, styling, and motion should be compared directly, rather than treating matching component types or approximate placement as sufficient. The left tree contains the TeamSpeak voice channels only; KOOK's separate text-channel group is outside this pass because TeamSpeak has no equivalent channel type. The current voice channel's text chat remains on the right. Closing it hides the entire panel, expands the participant stage, and leaves a reopen button in the stage heading; this happens without leaving the voice room. Its header uses the `#` channel mark and an unobtrusive close control; the composer sits at the bottom edge. Messages use author monograms, a separate identity/time line, and readable message text. The central stage uses WebSpeak's reusable member-card widget so available TeamSpeak profile avatars appear inside KAAK's participant tiles; the tiles use a wide 1.82:1 layout with a responsive grid to match KOOK's participant presentation. Member names stay hidden at rest while chat is open and fade upward into the lower-left label on hover; they remain visible while chat is collapsed. KAAK's CSS adds hover depth and a smoothly transitioning speaking ring driven by live voice state. Paid screen sharing is outside this skin; its member cards and performance panel omit share actions and share-state details. The dock retains WebSpeak's trusted connection-quality, audio, and disconnect controls. Input/output volume buttons open hover or keyboard-focus panels with live numeric levels; sliders use a skin-colored progress track, a distinct thumb, and visible focus feedback. Audio input and output devices use a reusable keyboard-accessible picker with a scrollable option list, selected/highlighted states, and an animated chevron; KAAK styles the trigger and open list. The connection surface, voice workspace, and audio settings share KOOK's PingFang SC-first font stack; audio settings use 16px/600 section headings and observed 14px/400 field labels. Audio sliders use a 16px thumb with hover/focus feedback. The performance card opens with a short entrance motion and readable network/audio metrics. No real device, volume, or microphone state is changed during visual checks. The roster shows connected TeamSpeak clients only; it does not invent an offline list. Channel selection is single-click; joining is double-click. The narrow layout keeps the host's mobile controls available while retaining readable member tiles.
KAAK is a schema v3 open-skin package with full connection and voice-workspace surfaces. Its desktop voice page follows KOOK's proportions: an 86px server rail with 58px icons and 18px vertical spacing, a 290px channel pane, a 40px top bar, a central participant stage, right-side chat attached to the current voice channel, and a lower-left voice dock. The server rail uses KOOK's rounded-square silhouette, a 2px green active outline and left-edge marker, with neutral fallback tiles and the muted purple active tile from the reference. The identity tile stays pinned at the bottom with a 54px circular monogram and connection-aware online dot; the server list scrolls when the window is short. The host provides a stable color-tone value derived only from the privacy-safe label, but the rail keeps the KOOK neutral tile treatment rather than exposing those tones. The KOOK voice room is the point-to-point visual reference: composition, member presentation, styling, and motion should be compared directly, rather than treating matching component types or approximate placement as sufficient. The left tree contains the TeamSpeak voice channels only; KOOK's separate text-channel group is outside this pass because TeamSpeak has no equivalent channel type. The current voice channel's text chat remains on the right. Closing it hides the entire panel, expands the participant stage, and leaves a reopen button in the stage heading; this happens without leaving the voice room. Its header uses the `#` channel mark and an unobtrusive close control; the composer sits at the bottom edge. Messages use author monograms, a separate identity/time line, and readable message text. The central stage uses WebSpeak's reusable member-card widget so available TeamSpeak profile avatars appear inside KAAK's participant tiles; the tiles use a wide 1.82:1 layout with a responsive grid to match KOOK's participant presentation. Member names stay hidden at rest while chat is open and fade upward into the lower-left label on hover; they remain visible while chat is collapsed. KAAK's CSS adds hover depth and a smoothly transitioning speaking ring driven by live voice state. Paid screen sharing is outside this skin; its member cards and performance panel omit share actions and share-state details. The dock retains WebSpeak's trusted connection-quality, audio, and disconnect controls. Input/output volume buttons open hover or keyboard-focus panels with live numeric levels; sliders use a skin-colored progress track, a distinct thumb, and visible focus feedback. Audio input and output devices use a reusable keyboard-accessible picker with a scrollable option list, selected/highlighted states, and an animated chevron; KAAK styles the trigger and open list. The connection surface, voice workspace, and audio settings share KOOK's PingFang SC-first font stack; audio settings use 16px/600 section headings and observed 14px/400 field labels. Audio sliders use a 16px thumb with hover/focus feedback. The performance card opens with a short entrance motion and readable network/audio metrics. No real device, volume, or microphone state is changed during visual checks. The roster shows connected TeamSpeak clients only; it does not invent an offline list. Channel selection is single-click; joining is double-click. The narrow layout keeps the host's mobile controls available while retaining readable member tiles.
The single TeamSpeak voice-channel group in the left tree collapses and expands with a short two-way height and fade transition like KOOK's voice group; the separate KOOK text-channel group remains outside this pass. A first click selects a channel and reveals a brief “双击加入” hint; the hint disappears on the active room. The current voice-room heading keeps the channel name and live member count visible above the participant stage while the attached chat is expanded, matching KOOK's room view. Member cards expose WebSpeak's trusted member-actions menu from a small hover or keyboard-focus control; touch layouts keep the control visible. That menu provides the existing individual-volume slider and member actions without adding skin-side audio logic.
Binary file not shown.
+34 -1
View File
@@ -269,7 +269,28 @@
},
"children": [
{
"text": "{{server.monogram}}"
"tag": "img",
"part": "server-icon",
"when": {
"path": "server.icon"
},
"attributes": {
"src": "{{server.icon}}",
"alt": ""
}
},
{
"tag": "span",
"part": "server-monogram-initial",
"when": {
"path": "server.icon",
"equals": ""
},
"children": [
{
"text": "{{server.monogram}}"
}
]
}
]
},
@@ -1073,6 +1094,18 @@
"children": [
{
"text": "TS"
},
{
"tag": "span",
"part": "identity-online",
"when": {
"path": "session.status.connected",
"equals": true
},
"attributes": {
"role": "img",
"aria-label": "在线"
}
}
]
},
+1 -1
View File
@@ -3,7 +3,7 @@
"packageType": "open-skin",
"id": "community.kaak-voice",
"name": "KAAK",
"version": "3.1.62",
"version": "3.1.64",
"author": "WebSpeak Project",
"license": "AGPL-3.0-only",
"description": "A KOOK-inspired voice workspace with collapsible voice groups, channel chat, TeamSpeak profile cards, accessible member controls, and WebSpeak screen sharing.",
+109 -87
View File
@@ -122,7 +122,7 @@
--skin-kaak-border: #3a3b40;
position: relative;
display: grid;
grid-template-columns: 80px 290px minmax(280px, 1fr) minmax(340px, min(38vw, 520px));
grid-template-columns: 86px 290px minmax(280px, 1fr) minmax(340px, min(38vw, 520px));
grid-template-rows: 40px minmax(0, 1fr);
width: 100%;
height: 100dvh;
@@ -135,7 +135,7 @@
}
[data-ws-plugin-part="kaak-workspace"]:has([data-ws-plugin-part="kaak-workspace.chat-panel-toggle"][aria-expanded="false"]) {
grid-template-columns: 80px 290px minmax(280px, 1fr) 0;
grid-template-columns: 86px 290px minmax(280px, 1fr) 0;
}
[data-ws-plugin-part="kaak-workspace"] .language-switcher .language-trigger,
@@ -208,94 +208,111 @@
[data-ws-plugin-part="kaak-workspace.server-rail"] {
grid-column: 1;
grid-row: 2;
--skin-kaak-rail-bg: #191a1d;
--skin-kaak-rail-item-bg: #2b2d32;
--skin-kaak-rail-accent: #75c900;
--skin-kaak-rail-text: #e7e9ed;
display: flex;
flex-direction: column;
align-items: center;
gap: 14px;
gap: 18px;
box-sizing: border-box;
height: 100%;
min-height: 0;
overflow-y: auto;
padding: 12px 15px 96px;
background: var(--skin-kaak-rail);
border-right: 1px solid #ffffff08;
padding: 14px 0 96px;
background: var(--skin-kaak-rail-bg);
scrollbar-width: none;
}
[data-ws-plugin-part="kaak-workspace.server-rail"]::-webkit-scrollbar {
display: none;
}
[data-ws-plugin-part="kaak-workspace.quick-server-item"] {
box-sizing: border-box;
width: 58px;
height: 58px;
flex: 0 0 58px;
}
[data-ws-plugin-part="kaak-workspace.quick-server"] {
position: relative;
display: grid;
place-items: center;
width: 50px;
min-height: 50px;
padding: 1px;
border: 0;
border-radius: 14px;
color: var(--skin-kaak-muted);
background: transparent;
box-sizing: border-box;
width: 58px;
height: 58px;
min-height: 58px;
padding: 0;
border: 2px solid transparent;
border-radius: 18px;
color: var(--skin-kaak-rail-text);
background: var(--skin-kaak-rail-item-bg);
cursor: pointer;
transition: background-color .18s ease;
transition: background .15s ease, border-color .15s ease, border-radius .15s ease;
}
[data-ws-plugin-part="kaak-workspace.quick-server"]:hover,
[data-ws-plugin-part="kaak-workspace.quick-server"]:focus-visible {
color: var(--skin-kaak-text);
background: var(--skin-kaak-raised);
background: #383a40;
}
[data-ws-plugin-part="kaak-workspace.quick-server"]:focus-visible {
outline: 2px solid #f0f1f3;
outline-offset: 3px;
}
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"] {
color: var(--skin-kaak-text);
border-color: var(--skin-kaak-rail-accent);
color: var(--skin-kaak-rail-text);
background: var(--skin-kaak-rail-item-bg);
}
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"]::before {
position: absolute;
left: -15px;
top: 50%;
width: 3px;
height: 22px;
border-radius: 0 3px 3px 0;
background: var(--skin-kaak-accent);
left: -16px;
top: 10px;
width: 4px;
height: 34px;
border-radius: 0 4px 4px 0;
background: var(--skin-kaak-rail-accent);
content: "";
transform: translateY(-50%);
transform-origin: center;
animation: kaak-server-active-arrive .2s cubic-bezier(.2, .75, .25, 1) both;
}
@keyframes kaak-server-active-arrive {
from { opacity: 0; transform: translateY(-50%) scaleY(.55); }
to { opacity: 1; transform: translateY(-50%) scaleY(1); }
}
[data-ws-plugin-part="kaak-workspace.server-monogram"] {
position: relative;
display: grid;
place-items: center;
width: 48px;
height: 48px;
box-sizing: border-box;
width: 100%;
height: 100%;
overflow: hidden;
border: 1px solid #ffffff12;
border-radius: 12px;
color: var(--skin-kaak-text);
background: linear-gradient(145deg, #383a40, #222429);
font-size: 15px;
font-weight: 800;
border-radius: 16px;
color: var(--skin-kaak-rail-text);
background: var(--skin-kaak-rail-item-bg);
font-size: 23px;
font-weight: 600;
text-align: center;
transition: border-radius .18s ease, transform .18s ease, border-color .18s ease, filter .18s ease;
transition: background-color .15s ease;
}
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="0"] { background: linear-gradient(145deg, #b54645, #59304a); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="1"] { background: linear-gradient(145deg, #7756b7, #352d5e); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="2"] { background: linear-gradient(145deg, #268f83, #20524f); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="3"] { background: linear-gradient(145deg, #477fbc, #294763); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="4"] { background: linear-gradient(145deg, #bd5b76, #63374d); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="5"] { background: linear-gradient(145deg, #b97837, #64442f); }
[data-ws-plugin-part="kaak-workspace.server-monogram"][data-tone="6"] { background: linear-gradient(145deg, #638a49, #3a513d); }
[data-ws-plugin-part="kaak-workspace.server-icon"] {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border-radius: inherit;
object-fit: cover;
}
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"] [data-ws-plugin-part="kaak-workspace.server-monogram"] {
border-color: var(--skin-kaak-accent);
border-radius: 12px;
background: var(--skin-kaak-rail-item-bg);
}
[data-ws-plugin-part="kaak-workspace.quick-server"]:hover [data-ws-plugin-part="kaak-workspace.server-monogram"] {
border-radius: 11px;
transform: scale(1.04);
filter: saturate(1.12) brightness(1.08);
[data-ws-plugin-part="kaak-workspace.quick-server"]:not([aria-current="true"]):hover [data-ws-plugin-part="kaak-workspace.server-monogram"],
[data-ws-plugin-part="kaak-workspace.quick-server"]:not([aria-current="true"]):focus-visible [data-ws-plugin-part="kaak-workspace.server-monogram"] {
background: #383a40;
}
[data-ws-plugin-part="kaak-workspace.server-kind"] {
@@ -313,28 +330,40 @@
display: grid;
justify-items: center;
gap: 4px;
width: 80px;
box-sizing: border-box;
width: 86px;
margin: 0;
padding: 10px 2px max(12px, env(safe-area-inset-bottom));
border-top: 1px solid var(--skin-kaak-border);
background: var(--skin-kaak-rail);
padding: 0 0 max(12px, env(safe-area-inset-bottom));
background: #191a1d;
}
[data-ws-plugin-part="kaak-workspace.identity-monogram"] {
position: relative;
display: grid;
place-items: center;
width: 38px;
height: 38px;
border: 1px solid #ffffff18;
width: 54px;
height: 54px;
border: 0;
border-radius: 50%;
color: var(--skin-kaak-text);
background: linear-gradient(145deg, #4a4c53, #292a30);
font-size: 10px;
font-weight: 850;
color: #fff;
background: #176a9e;
font-size: 17px;
font-weight: 700;
}
[data-ws-plugin-part="kaak-workspace.identity-online"] {
position: absolute;
right: -2px;
bottom: -2px;
width: 17px;
height: 17px;
border: 3px solid #191a1d;
border-radius: 50%;
background: #75c900;
}
[data-ws-plugin-part="kaak-workspace.identity-name"] {
display: block;
display: none;
max-width: 100%;
overflow: hidden;
color: var(--skin-kaak-muted);
@@ -1231,26 +1260,20 @@
@media (max-width: 1200px) {
[data-ws-plugin-part="kaak-workspace"] {
grid-template-columns: 56px 204px minmax(340px, 1fr) minmax(280px, 32vw);
grid-template-columns: 86px 204px minmax(340px, 1fr) minmax(280px, 32vw);
}
[data-ws-plugin-part="kaak-workspace"]:has([data-ws-plugin-part="kaak-workspace.chat-panel-toggle"][aria-expanded="false"]) {
grid-template-columns: 56px 204px minmax(340px, 1fr) 0;
grid-template-columns: 86px 204px minmax(340px, 1fr) 0;
}
[data-ws-plugin-part="kaak-workspace.identity-entry"] { width: 56px; }
[data-ws-plugin-part="kaak-workspace.server-rail"] { padding-inline: 3px; }
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"]::before { left: -3px; }
}
@media (max-width: 960px) {
[data-ws-plugin-part="kaak-workspace"] {
grid-template-columns: 52px 184px minmax(260px, 1fr) minmax(260px, 29vw);
grid-template-columns: 86px 184px minmax(260px, 1fr) minmax(260px, 29vw);
}
[data-ws-plugin-part="kaak-workspace"]:has([data-ws-plugin-part="kaak-workspace.chat-panel-toggle"][aria-expanded="false"]) {
grid-template-columns: 52px 184px minmax(260px, 1fr) 0;
grid-template-columns: 86px 184px minmax(260px, 1fr) 0;
}
[data-ws-plugin-part="kaak-workspace.identity-entry"] { width: 52px; }
[data-ws-plugin-part="kaak-workspace.server-rail"] { padding-inline: 1px; }
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"]::before { left: -1px; }
[data-ws-plugin-part="kaak-workspace.member-cards"] .voice-avatar-wrap::before,
[data-ws-plugin-part="kaak-workspace.member-cards"] .voice-avatar-wrap::after { width: 92px; height: 92px; }
[data-ws-plugin-part="kaak-workspace.member-cards"] .voice-avatar { width: 76px; height: 76px; font-size: 28px; }
@@ -1258,7 +1281,7 @@
@media (max-width: 820px) {
[data-ws-plugin-part="kaak-workspace"] {
grid-template-columns: 56px minmax(0, 1fr);
grid-template-columns: 86px minmax(0, 1fr);
grid-template-rows: 50px 126px minmax(176px, 24dvh) minmax(180px, 1fr) 122px;
height: 100dvh;
min-height: 540px;
@@ -1268,12 +1291,7 @@
[data-ws-plugin-part="kaak-workspace.brand-mark"] { flex-basis: 28px; width: 28px; height: 28px; }
[data-ws-plugin-part="kaak-workspace.brand-name"] { font-size: 10px; }
[data-ws-plugin-part="kaak-workspace.server-title"] { font-size: 10px; }
[data-ws-plugin-part="kaak-workspace.server-rail"] { grid-column: 1; grid-row: 2 / 6; padding: 8px 3px 96px; gap: 8px; }
[data-ws-plugin-part="kaak-workspace.quick-server"] { width: 48px; min-height: 48px; }
[data-ws-plugin-part="kaak-workspace.server-monogram"] { width: 42px; height: 42px; }
[data-ws-plugin-part="kaak-workspace.quick-server"][aria-current="true"]::before { left: -4px; }
[data-ws-plugin-part="kaak-workspace.identity-monogram"] { width: 34px; height: 34px; }
[data-ws-plugin-part="kaak-workspace.identity-entry"] { width: 56px; }
[data-ws-plugin-part="kaak-workspace.server-rail"] { grid-column: 1; grid-row: 2 / 6; padding: 8px 13px 96px; gap: 18px; }
[data-ws-plugin-part="kaak-workspace.channel-panel"] {
grid-column: 2;
@@ -1319,7 +1337,7 @@
[data-ws-plugin-part="kaak-workspace.voice-group-name"] { display: none; }
[data-ws-plugin-part="kaak-workspace.voice-group-chevron"] { width: auto; font-size: 20px; }
[data-ws-plugin-part="kaak-workspace"]:has([data-ws-plugin-part="kaak-workspace.chat-panel-toggle"][aria-expanded="false"]) {
grid-template-columns: 56px minmax(0, 1fr);
grid-template-columns: 86px minmax(0, 1fr);
grid-template-rows: 50px 126px minmax(176px, 24dvh) 0 122px;
}
[data-ws-plugin-part="kaak-workspace.voice-channel-list"] { flex: 0 0 auto; }
@@ -1396,10 +1414,7 @@
}
@media (max-width: 460px) {
[data-ws-plugin-part="kaak-workspace"] { grid-template-columns: 50px minmax(0, 1fr); }
[data-ws-plugin-part="kaak-workspace.server-rail"] { padding-inline: 1px; }
[data-ws-plugin-part="kaak-workspace.quick-server"] { width: 44px; }
[data-ws-plugin-part="kaak-workspace.identity-entry"] { width: 50px; }
[data-ws-plugin-part="kaak-workspace"] { grid-template-columns: 86px minmax(0, 1fr); }
[data-ws-plugin-part="kaak-workspace.identity-name"] { max-width: 43px; }
[data-ws-plugin-part="kaak-workspace.topbar"] { padding-inline: 5px; }
[data-ws-plugin-part="kaak-workspace.brand-name"] { display: none; }
@@ -1410,6 +1425,13 @@
[data-ws-plugin-part="kaak-workspace.voice-dock"] { grid-column: 2; }
}
@media (max-height: 620px) {
[data-ws-plugin-part="kaak-workspace"] { min-height: 0; }
[data-ws-plugin-part="kaak-workspace.server-rail"] { padding-top: 8px; padding-bottom: 76px; }
[data-ws-plugin-part="kaak-workspace.identity-entry"] { gap: 2px; padding-top: 7px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
[data-ws-plugin-part="kaak-workspace.identity-name"] { display: none; }
}
@media (max-width: 820px) and (max-height: 620px) {
[data-ws-plugin-part="kaak-workspace"] {
grid-template-rows: 46px 104px minmax(138px, 25dvh) minmax(136px, 1fr) 122px;
+2 -2
View File
@@ -65,8 +65,8 @@
}
},
"node_modules/@echosixhiya/teamspeak-client": {
"version": "0.2.4",
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#56d426d24852c39439f7bfe1d5850b574a1b0811",
"version": "0.2.5",
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#2ce968e07a4384cdc873cc368b5b9d25de0b3c52",
"license": "MIT",
"dependencies": {
"@noble/curves": "^2.0.1"
+1 -1
View File
@@ -29,7 +29,7 @@
},
"dependencies": {
"@discordjs/opus": "^0.10.0",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#56d426d24852c39439f7bfe1d5850b574a1b0811",
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#2ce968e07a4384cdc873cc368b5b9d25de0b3c52",
"express": "^5.2.1",
"pino": "^10.3.1",
"postcss": "^8.5.29",
+27 -2
View File
@@ -17,6 +17,8 @@ const transfer = { size: 6n };
class SdkStub extends EventEmitter {
inputCommands: string[] = [];
fileTransfers: Array<{ channelId: bigint; path: string; password: string }> = [];
serverInfo: { name: string; iconId: number | null } | null = { name: "兄弟们的teamspeak", iconId: 123456 };
inputUpdate = async (_command: string): Promise<void> => {};
async execCommand(command: string) { this.inputCommands.push(command); await this.inputUpdate(command); }
initialized = 0;
@@ -24,8 +26,12 @@ class SdkStub extends EventEmitter {
metadata = async () => rows;
transfer = async () => transfer;
download = async (destination: Writable) => { destination.write(Buffer.from("GIF89a")); };
execCommandWithResponse() { return this.metadata(); }
async fileTransferInitDownload() { this.initialized++; return this.transfer(); }
execCommandWithResponse(command = "") { this.inputCommands.push(command); return this.metadata(); }
async fileTransferInitDownload(channelId: bigint, path: string, password: string) {
this.initialized++;
this.fileTransfers.push({ channelId, path, password });
return this.transfer();
}
async downloadFileData(_host: string, _transfer: unknown, destination: Writable) { this.downloaded++; await this.download(destination); }
}
@@ -53,6 +59,25 @@ test("stream commands wait for server acknowledgement and propagate refusals", a
await assert.rejects(f.client.sendProtocolCommand("removeclientfromstream id=test"), /missing required parameter/);
});
test("server info uses the name and icon id captured by the SDK handshake", async () => {
const f = fixture();
assert.deepEqual(await f.client.getServerInfo(), { name: "兄弟们的teamspeak", iconId: 123456 });
assert.deepEqual(f.sdk.inputCommands, [], "server identity does not issue a ServerQuery-only command over the client session");
f.sdk.serverInfo = { name: "No icon", iconId: null };
assert.deepEqual(await f.client.getServerInfo(), { name: "No icon", iconId: null });
});
test("server icons use the TeamSpeak file transfer path and enforce the download limit", async () => {
const f = fixture();
assert.equal((await f.client.getServerIcon(123456))?.toString(), "GIF89a");
assert.deepEqual(f.sdk.fileTransfers, [{ channelId: 0n, path: "/icon_123456", password: "" }]);
assert.equal(f.sdk.downloaded, 1);
f.sdk.transfer = async () => ({ size: 128n * 1024n + 1n });
assert.equal(await f.client.getServerIcon(123456), null);
assert.equal(f.sdk.downloaded, 1);
});
test("stream cleanup flood retries back off and stop after two retries", async t => {
const f = fixture();
t.mock.timers.enable({ apis: ["setTimeout"] });
+43
View File
@@ -44,10 +44,16 @@ export interface TSClientAvatar {
data: Buffer;
}
export interface TSClientServerInfo {
name: string;
iconId: number | null;
}
// Keep enough room for avatars produced by the native client. The previous
// 120 KiB limit rejected the 134 KiB PNG used by the Shanghai test account,
// so every avatar silently fell back to its initial letter.
const MAX_CLIENT_AVATAR_BYTES = 256 * 1024;
const MAX_SERVER_ICON_BYTES = 128 * 1024;
export type TSDirectoryChannel = DirectorySnapshot["channels"][number] & Partial<ChannelCapacity>;
export type TSDirectorySnapshot = Omit<DirectorySnapshot, "channels"> & { channels: TSDirectoryChannel[] };
@@ -274,6 +280,43 @@ export class TSClient extends EventEmitter {
return { cacheKey, data };
}
/** Read the public virtual-server name and icon marker from the active session. */
async getServerInfo(): Promise<TSClientServerInfo> {
const client = this.client;
if (!client || !this.connected) throw new Error("TeamSpeak session is not ready");
const generation = this.connectionGeneration;
if (this.client !== client || !this.connected || this.connectionGeneration !== generation) {
throw new Error("TeamSpeak session changed while reading server information");
}
return client.serverInfo ?? { name: "", iconId: null };
}
/** Download the public virtual-server icon using TeamSpeak's normal file-transfer port. */
async getServerIcon(iconId: number): Promise<Buffer | null> {
const client = this.client;
if (!client || !this.connected) throw new Error("TeamSpeak session is not ready");
if (!Number.isSafeInteger(iconId) || iconId === 0) return null;
const generation = this.connectionGeneration;
const isCurrent = () => this.client === client && this.connected && this.connectionGeneration === generation;
const transfer = await client.fileTransferInitDownload(0n, `/icon_${iconId}`, "");
if (!isCurrent()) return null;
const size = Number(transfer.size);
if (!Number.isSafeInteger(size) || size <= 0 || size > MAX_SERVER_ICON_BYTES) return null;
const chunks: Buffer[] = [];
const destination = new Writable({
write(chunk: Buffer | string, _encoding, callback) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
callback();
},
});
await client.downloadFileData(this.options.target.host, transfer, destination);
if (!isCurrent()) return null;
const data = Buffer.concat(chunks);
if (data.length === 0 || data.length > MAX_SERVER_ICON_BYTES) return null;
return data;
}
private attachClientListeners(client: TS3FullClient): void {
client.on("voiceData", (data: VoiceData) => {
if (this.client !== client) return;
+30 -2
View File
@@ -20,11 +20,16 @@ class TeamSpeakStub extends EventEmitter {
sent: Buffer[] = [];
directory: TSDirectorySnapshot = { channels: [], clients: [] };
avatarRequest: (id: number, uid: string) => Promise<TSClientAvatar | null> = async () => null;
async connect() { this.disconnected = false; this.emit("directorySnapshot", this.directory); }
emitDirectorySnapshotOnConnect = true;
connectCalls = 0;
serverInfoCalls = 0;
async connect() { this.connectCalls++; this.disconnected = false; if (this.emitDirectorySnapshotOnConnect) this.emit("directorySnapshot", this.directory); }
async disconnect() { this.disconnected = true; }
getClientId() { return 1; }
getChannelId() { return 1n; }
isConnected() { return !this.disconnected; }
async getServerInfo() { this.serverInfoCalls++; return { name: "兄弟们的teamspeak", iconId: null }; }
async getServerIcon() { return null; }
async sendProtocolCommand() {}
async setAccompanimentActive() {}
sendVoice(data: Buffer) { this.sent.push(data); this.emit("sent", data); }
@@ -36,6 +41,7 @@ async function fixture(t: TestContext, overrides: {
createTeamSpeakClient?: () => TSClient;
createEncoder?: () => Pick<OpusEncoder, "encode" | "dispose">;
configureSdk?: (sdk: TeamSpeakStub) => void;
waitForFirstMessage?: boolean;
} = {}) {
const sdk = new TeamSpeakStub();
overrides.configureSdk?.(sdk);
@@ -65,7 +71,7 @@ async function fixture(t: TestContext, overrides: {
await bridge.shutdown();
await new Promise<void>(resolve => server.close(() => resolve()));
});
await first;
if (overrides.waitForFirstMessage !== false) await first;
const entries = (bridge as unknown as { entries: Map<string, {
id: string; ws: WebSocket; audio: AudioFlowStats; webrtc: WebRtcAudioSession | null;
isAlive: boolean; avatarCache: Map<string, string | null>;
@@ -82,6 +88,28 @@ test("a TeamSpeak constructor failure releases the admitted gateway slot", { tim
assert.equal(f.bridge.getActiveCount(), 0);
});
test("server identity lookup waits until the directory sync publishes the connected state", { timeout: 5_000 }, async t => {
const f = await fixture(t, { waitForFirstMessage: false, configureSdk(sdk) { sdk.emitDirectorySnapshotOnConnect = false; } });
while (!f.sdk.connectCalls) await nextTurn();
await nextTurn();
assert.equal(f.sdk.serverInfoCalls, 0);
const serverInfo = new Promise<Record<string, unknown>>(resolve => {
f.socket.on("message", (data, binary) => {
if (binary) return;
const message = JSON.parse(data.toString()) as Record<string, unknown>;
if (message.type === "serverInfo") resolve(message);
});
});
f.sdk.emit("directorySnapshot", f.sdk.directory);
assert.deepEqual(await serverInfo, { type: "serverInfo", name: "兄弟们的teamspeak", icon: null });
const publishedTypes = f.messages.filter(message => !message.binary).map(message => (JSON.parse(message.data.toString()) as { type: string }).type);
assert.ok(publishedTypes.indexOf("connected") >= 0);
assert.ok(publishedTypes.indexOf("serverInfo") > publishedTypes.indexOf("connected"));
assert.equal(f.sdk.serverInfoCalls, 1);
assert.ok(f.bridge.getActiveCount() > 0);
});
test("a codec disposal failure cannot abandon TeamSpeak or the browser socket", { timeout: 5_000 }, async t => {
const encoder = new OpusEncoder(48000, 1);
t.mock.method(encoder, "dispose", () => { throw new Error("Codec already disposed"); });
+22
View File
@@ -26,6 +26,7 @@ import { WebRtcAudioSession, type WebRtcAudioOptions, type WebRtcAudioSessionOpt
import type { AccelerationRelayOptions, ConfiguredAccelerationRelay } from "./acceleration-relay.js";
import { normalizeScreenShareIceServers, parseScreenShareMessage, type ScreenShareIceServer } from "./screen-share.js";
import { OpusEncoder } from "./opus-codec.js";
import { avatarDataUrl } from "./directory-view.js";
const HEARTBEAT_INTERVAL_MS = 30_000;
function publicFailureDetail(error: ReturnType<typeof normalizeTeamSpeakError>): string | undefined {
@@ -242,6 +243,7 @@ export class VoiceBridge {
}
let initialStateSent = false;
let serverInfoGeneration = 0;
let hasConnectedOnce = false;
let reconnectStartedAt = 0;
let reconnectAttempt = 0;
@@ -290,6 +292,7 @@ export class VoiceBridge {
sendJson({ type: "channelList", channels: entry!.channelTree });
if (wasReconnecting) sendJson({ type: "reconnected" });
events.scheduleAvatars();
void publishServerInfo();
};
const resetDirectoryForReconnect = () => {
@@ -299,6 +302,25 @@ export class VoiceBridge {
initialStateSent = false;
};
const publishServerInfo = async (): Promise<void> => {
const generation = ++serverInfoGeneration;
const isCurrent = () => generation === serverInfoGeneration
&& this.entries.get(entryId) === entry && session.state === "connected";
try {
const info = await tsClient.getServerInfo();
if (!isCurrent()) return;
const name = info.name.trim().slice(0, 256);
sendJson({ type: "serverInfo", name, icon: null });
if (!info.iconId) return;
const icon = await tsClient.getServerIcon(info.iconId);
if (!icon || !isCurrent()) return;
const dataUrl = avatarDataUrl(icon);
if (dataUrl) sendJson({ type: "serverInfo", name, icon: dataUrl });
} catch (error: unknown) {
if (isCurrent()) this.logger.debug({ entryId, err: error instanceof Error ? error.message : String(error) }, "TeamSpeak server icon unavailable");
}
};
const failReconnect = (normalized: ReturnType<typeof normalizeTeamSpeakError>) => {
if (entry!.reconnectTimer) {
clearTimeout(entry!.reconnectTimer);
+2
View File
@@ -9,6 +9,7 @@ const stream = {
const event = { id: "event-1", kind: "joined", message: "Member joined", timestamp: 1_000 };
const samples: Record<ServerMessage["type"], ServerMessage> = {
connected: { type: "connected", tsClientId: 1, members: [{ id: 1, nickname: "Owner" }], serverEventLog: [event] },
serverInfo: { type: "serverInfo", name: "兄弟们的teamspeak", icon: "data:image/png;base64,iVBORw0KGgo=" },
memberEnter: { type: "memberEnter", id: 2, nickname: "Visitor", uid: "uid-2", isSelf: false },
memberLeave: { type: "memberLeave", id: 2 },
memberAvatar: { type: "memberAvatar", id: 2, avatar: "data:image/png;base64,test" },
@@ -60,6 +61,7 @@ test("malformed nested directory and event data is rejected before client state
{ type: "connected", tsClientId: 1, members: [null] },
{ type: "connected", tsClientId: 1, members: [{ id: "1", nickname: "bad id" }] },
{ type: "connected", tsClientId: 1, serverEventLog: [{ id: "incomplete" }] },
{ type: "serverInfo", name: "TeamSpeak", icon: "https://example.com/icon.png" },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", members: [{}] }] },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10 }] },
{ type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 65536, maxClientsLimited: true }] },
+4
View File
@@ -13,6 +13,7 @@ type ChatFields = { invokerId?: number; invokerName?: string; message: string; t
/** Public JSON messages. Internal sockets, SDK clients and media objects stay out. */
export type ServerMessage =
| Message<"connected", { tsClientId: number; members?: ChannelMember[]; serverEventLog?: ServerEvent[]; identity?: string; webrtcAvailable?: boolean; webRtcStunServer?: string; whisperTargetIds?: number[]; whisperActive?: boolean; screenShareIceServers?: ScreenShareIceServer[]; accelerated?: boolean }>
| Message<"serverInfo", { name: string; icon?: string | null }>
| Message<"memberEnter", ChannelMember>
| Message<"memberLeave", { id: number }>
| Message<"memberAvatar", { id: number; uid?: string; avatar?: string }>
@@ -115,6 +116,9 @@ const valid: Record<ServerMessage["type"], (message: RecordValue) => boolean> =
connected: m => clientId(m.tsClientId) && optional(m.members, v => arrayOf(v, member)) && optional(m.serverEventLog, v => arrayOf(v, event))
&& optional(m.identity, v => text(v) && v.length <= 8192) && optional(m.webrtcAvailable, boolean) && optional(m.webRtcStunServer, v => normalizeVoiceStunServer(v) !== null)
&& optional(m.whisperTargetIds, v => arrayOf(v, clientId)) && optional(m.whisperActive, boolean) && optional(m.accelerated, boolean),
serverInfo: m => text(m.name) && m.name.length <= 256
&& optional(m.icon, v => v === null || (text(v) && v.length <= 180_000
&& /^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(v))),
memberEnter: member,
memberLeave: m => clientId(m.id),
memberAvatar: m => clientId(m.id) && optional(m.uid, text) && optional(m.avatar, text),
+19
View File
@@ -119,6 +119,25 @@ test("custom surfaces can safely render and switch unified favorite and recent s
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_PERMISSION_MISSING");
});
test("server list skins may display only the host-provided TeamSpeak icon image", () => {
const document = validDocument();
document.schemaVersion = 3;
document.components[0].actions = {};
document.components[0].permissions = ["servers.quickList.read"];
document.components[0].root = {
tag: "nav",
repeat: { path: "servers.quickList", as: "server" },
children: [{ tag: "img", attributes: { src: "{{server.icon}}", alt: "" } }],
};
assert.equal(parseSkinPluginDocument(document).components[0].root.children?.[0].attributes?.src, "{{server.icon}}");
document.components[0].root.children![0].attributes!.src = "https://example.com/icon.png";
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_ATTRIBUTE_INVALID");
document.components[0].root.children![0].attributes!.src = "{{server.icon}}";
document.components[0].root.children![0].tag = "span";
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_ATTRIBUTE_INVALID");
});
test("host widget references stay allowlisted and cannot be used on the demo page", () => {
const unknownWidget = validDocument();
unknownWidget.schemaVersion = 2;
+4 -3
View File
@@ -22,7 +22,7 @@ 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.read": Object.freeze({ policyVersion: 1, description: "Read favorite and recent server labels, public server icons, 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." }),
"audio.status.read": Object.freeze({ policyVersion: 1, description: "Read the user's own microphone and speaker mute states." }),
@@ -168,7 +168,7 @@ const VOID_ELEMENTS = new Set(["br", "circle", "hr", "img", "input", "line", "pa
const ATTRIBUTES = new Set([
"alt", "aria-current", "aria-expanded", "aria-hidden", "aria-label", "aria-pressed", "aria-selected", "autocomplete", "checked", "class", "colspan", "disabled", "draggable", "fill", "height", "inputmode", "max", "maxlength", "min",
"minlength", "multiple", "name", "open", "placeholder", "required", "role", "rows", "rowspan", "step", "stroke", "stroke-linecap", "stroke-linejoin",
"stroke-width", "tabindex", "title", "type", "value", "viewbox", "width", "x", "x1", "x2", "y", "y1", "y2",
"src", "stroke-width", "tabindex", "title", "type", "value", "viewbox", "width", "x", "x1", "x2", "y", "y1", "y2",
]);
const EVENTS = new Set<string>([
"click", "dblclick", "change", "input", "submit", "keydown", "keyup", "contextmenu", "focus", "blur", "pointerdown", "pointerup",
@@ -240,7 +240,7 @@ const COLLECTION_FIELDS: Record<string, ReadonlySet<string>> = {
"session.channels": new Set(["id", "name", "parentId", "depth", "memberCount", "memberCountLabel", "maxClients", "maxClientsLimited", "current"]),
"session.members": new Set(["id", "name", "avatarInitial", "channelId", "status", "speaking", "self"]),
"favorites.items": new Set(["id", "label", "current", "kind"]),
"servers.quickList": new Set(["id", "label", "monogram", "tone", "current", "kind", "favorite"]),
"servers.quickList": new Set(["id", "label", "monogram", "icon", "tone", "current", "kind", "favorite"]),
"chat.messages": new Set(["id", "author", "text", "time", "kind", "channelId"]),
"screenShare.streams": new Set(["streamId", "source", "ownerClientId", "ownerNickname", "name", "audio", "viewerCount"]),
};
@@ -481,6 +481,7 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
const isAriaOrData = inputSchemaVersion >= 3 && /^(?:aria|data)-[a-z][a-z0-9-]{0,47}$/.test(lowerKey);
if ((!ATTRIBUTES.has(lowerKey) && !isAriaOrData) || lowerKey.startsWith("on") || key !== lowerKey) fail("SKIN_PLUGIN_ATTRIBUTE_INVALID", "The component uses an unsupported or executable attribute.");
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") fail("SKIN_PLUGIN_ATTRIBUTE_INVALID", "Component attributes must be scalar values.");
if (lowerKey === "src" && (node.tag !== "img" || value !== "{{server.icon}}")) fail("SKIN_PLUGIN_ATTRIBUTE_INVALID", "Image sources may only bind to a TeamSpeak server icon.");
if (typeof value === "string" && ["fill", "stroke"].includes(lowerKey) && /\burl\s*\(|javascript\s*:/i.test(value)) fail("SKIN_PLUGIN_ATTRIBUTE_INVALID", "SVG paint attributes cannot load external or executable resources.");
if (typeof value === "string") {
for (const permission of bindingPermissions(value, aliases, stateKeys)) {
Binary file not shown.
+11
View File
@@ -43,6 +43,11 @@ export interface VoiceState {
channelSwitchedChannelId: string;
}
export interface VoiceServerInfo {
name: string;
icon?: string | null;
}
export interface AudioInputDevice {
deviceId: string;
label: string;
@@ -190,6 +195,7 @@ class CancelledMediaOperation extends Error {
export function useVoiceWebSocket() {
const ws = shallowRef<WebSocket | null>(null);
const serverInfo = shallowRef<VoiceServerInfo | null>(null);
const state = reactive<VoiceState>({ connected: false, connecting: false, reconnecting: false, reconnectAttempt: 0, reconnectFailed: false, tsClientId: 0, error: "", errorCode: "", microphoneError: "", microphoneErrorCode: "", audioNotice: "", audioNoticeCode: "", channelSwitchedChannelId: "" });
const sessionState = createVoiceSessionState({
selfId: () => state.tsClientId,
@@ -993,6 +999,7 @@ export function useVoiceWebSocket() {
}
function disconnect(preserveConnection = false): void {
serverInfo.value = null;
const keepRememberedIdentity = lastConnection?.rememberIdentity === true;
if (!preserveConnection) lastConnection = null;
voiceConnection.stop(() => releaseSessionResources(!preserveConnection));
@@ -1036,6 +1043,9 @@ export function useVoiceWebSocket() {
const msg = parseServerMessage(raw);
if (!msg || screenShare.handleMessage(msg) || sessionState.receive(msg)) return;
switch (msg.type) {
case "serverInfo":
serverInfo.value = { name: msg.name, icon: msg.icon ?? null };
break;
case "connected":
const wasReconnecting = state.reconnecting;
state.connected = true;
@@ -1401,6 +1411,7 @@ export function useVoiceWebSocket() {
...screenShare.api,
ws,
state,
serverInfo,
sessionEpoch: sessionState.epoch,
memberConversationKey: sessionState.memberConversationKey,
members,
@@ -49,12 +49,15 @@ export function useWebClientServerHistory({
function recordCurrentServer(): void {
const address = currentTarget.value;
if (!address) return;
const savedServer = quickServers.value.find((server) => server.id === serverKey(address));
const recent: RecentServer = {
id: serverKey(address),
address,
...(nickname.value.trim() ? { nickname: nickname.value.trim() } : {}),
...(rememberIdentity.value && identityMaterial.value ? { identityId: "current" } : {}),
lastConnectedAt: Date.now(),
...(savedServer?.serverName ? { serverName: savedServer.serverName } : {}),
...(savedServer?.serverIcon ? { serverIcon: savedServer.serverIcon } : {}),
...(channel.value.trim() ? { lastChannelHint: { name: channel.value.trim() } } : {}),
};
void recordRecentServer(recent).then(() => listRecentServers().then((items) => { recentServers.value = items; }));
@@ -77,12 +80,15 @@ export function useWebClientServerHistory({
const normalizedAddress = address.trim();
if (!normalizedAddress) return;
const id = serverKey(normalizedAddress);
const existing = quickServers.value.find((server) => server.id === id);
const favorite: FavoriteServer = {
id,
label: label.trim() || normalizedAddress,
address: normalizedAddress,
...(savedNickname ? { nickname: savedNickname } : {}),
...(rememberIdentity.value && identityMaterial.value ? { identityId: "current" } : {}),
...(existing?.serverName ? { serverName: existing.serverName } : {}),
...(existing?.serverIcon ? { serverIcon: existing.serverIcon } : {}),
...(channelHint ? { lastChannelHint: { name: channelHint } } : {}),
};
await saveFavorite(favorite);
@@ -124,6 +130,37 @@ export function useWebClientServerHistory({
showToast(t("savedFavoriteToast"));
}
async function updateCurrentServerIdentity(serverName: string, serverIcon: string | null): Promise<void> {
const address = currentTarget.value;
const name = serverName.trim().slice(0, 256);
if (!address || !name) return;
const id = serverKey(address);
const existingRecent = recentServers.value.find((server) => server.id === id);
const recent: RecentServer = {
...(existingRecent ?? {}),
id,
address,
lastConnectedAt: existingRecent?.lastConnectedAt ?? Date.now(),
serverName: name,
...(nickname.value.trim() ? { nickname: nickname.value.trim() } : {}),
...(channel.value.trim() ? { lastChannelHint: { name: channel.value.trim() } } : {}),
};
if (serverIcon) recent.serverIcon = serverIcon;
else delete recent.serverIcon;
recentServers.value = [recent, ...recentServers.value.filter((server) => server.id !== id)]
.sort((left, right) => right.lastConnectedAt - left.lastConnectedAt).slice(0, 10);
await recordRecentServer(recent);
const favorite = favoriteServers.value.find((server) => server.id === id);
if (favorite) {
const updated: FavoriteServer = { ...favorite, serverName: name };
if (serverIcon) updated.serverIcon = serverIcon;
else delete updated.serverIcon;
favoriteServers.value = favoriteServers.value.map((server) => server.id === id ? updated : server);
await saveFavorite(updated);
}
}
function clearServerHistory(): void {
favoriteServers.value = [];
recentServers.value = [];
@@ -136,6 +173,7 @@ export function useWebClientServerHistory({
isFavorite,
loadSavedServers,
recordCurrentServer,
updateCurrentServerIdentity,
selectLocalServer,
saveFavoriteServer,
removeFavoriteServer,
+4
View File
@@ -31,6 +31,8 @@ export interface FavoriteServer {
nickname?: string;
identityId?: string;
lastChannelHint?: { id?: string; name?: string };
serverName?: string;
serverIcon?: string;
}
export interface RecentServer {
@@ -40,6 +42,8 @@ export interface RecentServer {
identityId?: string;
lastConnectedAt: number;
lastChannelHint?: { id?: string; name?: string };
serverName?: string;
serverIcon?: string;
}
export interface LocalPreferences {
+32
View File
@@ -46,3 +46,35 @@ test("quick server addresses are trimmed, normalized, and empty targets are skip
assert.equal(quickServers[0].id, "voice.example:9987");
assert.equal(quickServers[0].address, "Voice.Example:9987");
});
test("server-provided name and image replace address placeholders while custom favorite names stay intact", () => {
const icon = "data:image/png;base64,iVBORw0KGgo=";
const quickServers = mergeQuickServers(
[
{ id: "shanghai", label: "shanghai.example:9987", address: "shanghai.example:9987" },
{ id: "custom", label: "My room", address: "custom.example:9987" },
],
[
{ id: "recent-shanghai", address: "shanghai.example:9987", serverName: "兄弟们的teamspeak", serverIcon: icon, lastConnectedAt: 2 },
{ id: "recent-custom", address: "custom.example:9987", serverName: "Original TeamSpeak name", lastConnectedAt: 1 },
],
);
const shanghai = quickServers.find((server) => server.address === "shanghai.example:9987");
const custom = quickServers.find((server) => server.address === "custom.example:9987");
assert.equal(shanghai?.label, "兄弟们的teamspeak");
assert.equal(shanghai?.serverIcon, icon);
assert.equal(custom?.label, "My room");
assert.equal(custom?.serverName, "Original TeamSpeak name");
});
test("unsafe or non-image server icon URLs are ignored", () => {
const quickServers = mergeQuickServers([], [{
id: "recent",
address: "voice.example:9987",
serverName: "Voice",
serverIcon: "https://tracking.example/image.png",
lastConnectedAt: 1,
}]);
assert.equal(quickServers[0].serverIcon, undefined);
});
+27 -2
View File
@@ -1,4 +1,5 @@
import type { FavoriteServer, RecentServer } from "./local-persistence.js";
import { splitTeamSpeakTarget } from "./teamspeak-target.js";
export interface QuickServer {
id: string;
@@ -9,6 +10,20 @@ export interface QuickServer {
lastChannelHint?: { id?: string; name?: string };
isFavorite: boolean;
lastConnectedAt?: number;
serverName?: string;
serverIcon?: string;
}
export function isSafeQuickServerIcon(value: unknown): value is string {
return typeof value === "string" && value.length <= 180_000
&& /^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(value);
}
export function isQuickServerAddressLabel(label: string, address: string): boolean {
const normalizedLabel = label.trim().toLocaleLowerCase();
const candidates = new Set([address.trim()]);
try { candidates.add(splitTeamSpeakTarget(address).address.trim()); } catch { /* Persisted targets are validated on write. */ }
return [...candidates].some((candidate) => candidate.length >= 3 && normalizedLabel.includes(candidate.toLocaleLowerCase()));
}
/**
@@ -33,11 +48,19 @@ export function mergeQuickServers(
if (!key || seen.has(key)) continue;
seen.add(key);
const recent = recentByAddress.get(key);
const serverName = recent?.serverName?.trim() || favorite.serverName?.trim() || "";
const serverIcon = isSafeQuickServerIcon(recent?.serverIcon) ? recent.serverIcon
: isSafeQuickServerIcon(favorite.serverIcon) ? favorite.serverIcon : "";
const savedLabel = favorite.label.trim();
result.push({
id: key,
address: favorite.address.trim(),
label: favorite.label.trim() || favorite.address.trim(),
label: serverName && (!savedLabel || isQuickServerAddressLabel(savedLabel, favorite.address))
? serverName
: savedLabel || favorite.address.trim(),
isFavorite: true,
...(serverName ? { serverName } : {}),
...(serverIcon ? { serverIcon } : {}),
...(recent?.nickname || favorite.nickname ? { nickname: recent?.nickname || favorite.nickname } : {}),
...(recent?.identityId || favorite.identityId ? { identityId: recent?.identityId || favorite.identityId } : {}),
...(recent?.lastChannelHint || favorite.lastChannelHint ? { lastChannelHint: recent?.lastChannelHint ?? favorite.lastChannelHint } : {}),
@@ -52,8 +75,10 @@ export function mergeQuickServers(
result.push({
id: key,
address: recent.address.trim(),
label: recent.address.trim(),
label: recent.serverName?.trim() || recent.address.trim(),
isFavorite: false,
...(recent.serverName?.trim() ? { serverName: recent.serverName.trim() } : {}),
...(isSafeQuickServerIcon(recent.serverIcon) ? { serverIcon: recent.serverIcon } : {}),
...(recent.nickname ? { nickname: recent.nickname } : {}),
...(recent.identityId ? { identityId: recent.identityId } : {}),
...(recent.lastChannelHint ? { lastChannelHint: recent.lastChannelHint } : {}),
+1 -1
View File
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.62",
version: "3.1.64",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired voice-room workspace with collapsible voice groups, channel chat, TeamSpeak profile cards, accessible host-owned member controls, and WebSpeak screen sharing.",
+24 -6
View File
@@ -464,7 +464,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.62");
assert.equal(skin.version, "3.1.64");
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
assert.equal(skin.schemaVersion, 3);
const home = skin.pluginData?.components.find((component) => component.page === "home");
@@ -517,8 +517,11 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(chatExpand?.attributes?.["aria-expanded"], "{{state.chatopen}}");
assert.deepEqual(findPart(voice?.root, "chat")?.when, { path: "state.chatopen", equals: true });
assert.equal(voice?.root.attributes?.["data-chat-open"], "{{state.chatopen}}");
assert.equal(findPart(voice?.root, "server-monogram")?.children?.[0]?.text, "{{server.monogram}}");
assert.equal(findPart(voice?.root, "server-icon")?.attributes?.src, "{{server.icon}}");
assert.equal(findPart(voice?.root, "server-monogram-initial")?.children?.[0]?.text, "{{server.monogram}}");
assert.equal(findPart(voice?.root, "server-monogram")?.attributes?.["data-tone"], "{{server.tone}}");
assert.deepEqual(findPart(voice?.root, "identity-online")?.when, { path: "session.status.connected", equals: true });
assert.equal(findPart(voice?.root, "identity-online")?.attributes?.role, "img");
const voiceStageHeadingItem = findPart(voice?.root, "voice-stage-heading-item");
assert.equal(voiceStageHeadingItem?.repeat?.path, "session.channels");
const voiceStageHeading = findPart(voiceStageHeadingItem, "voice-stage-heading");
@@ -617,14 +620,29 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /kaak-workspace\.voice-channel-group-toggle/);
assert.match(skin.css, /voice-channel-list[\s\S]*?grid-template-rows: 1fr;[\s\S]*?transition: grid-template-rows \.18s ease/);
assert.match(skin.css, /data-voice-group-open="false"[\s\S]*?voice-channel-list[\s\S]*?grid-template-rows: 0fr;[\s\S]*?visibility: hidden;[\s\S]*?visibility 0s linear \.18s/);
assert.match(skin.css, /kaak-workspace\.server-monogram"\]\[data-tone="0"\]/);
assert.match(skin.css, /voice-stage-heading[\s\S]*?flex: 0 0 46px;/);
assert.doesNotMatch(skin.css, /aria-expanded="true"\]\s*[^\n]*voice-stage-heading[^\n]*display: none;/);
assert.match(skin.css, /kaak-workspace"\]:has\(\[data-ws-plugin-part="kaak-workspace\.chat-panel-toggle"\]\[aria-expanded="false"\]\)[\s\S]*?grid-template-columns: 80px 290px minmax\(280px, 1fr\) 0;/);
assert.match(skin.css, /grid-template-columns: 80px 290px/);
assert.match(skin.css, /kaak-workspace"\]:has\(\[data-ws-plugin-part="kaak-workspace\.chat-panel-toggle"\]\[aria-expanded="false"\]\)[\s\S]*?grid-template-columns: 86px 290px minmax\(280px, 1fr\) 0;/);
assert.match(skin.css, /grid-template-columns: 86px 290px/);
assert.match(skin.css, /minmax\(340px, min\(38vw, 520px\)\)/);
assert.match(skin.css, /grid-template-rows: 40px/);
assert.match(skin.css, /kaak-workspace\.server-monogram[\s\S]*?width: 48px;[\s\S]*?height: 48px;/);
assert.match(skin.css, /kaak-workspace\.server-rail"\]\s*\{[\s\S]*?--skin-kaak-rail-bg: #191a1d;[\s\S]*?--skin-kaak-rail-item-bg: #2b2d32;[\s\S]*?--skin-kaak-rail-accent: #75c900;[\s\S]*?gap: 18px;[\s\S]*?padding: 14px 0 96px;[\s\S]*?background: var\(--skin-kaak-rail-bg\);/);
assert.match(skin.css, /kaak-workspace\.quick-server-item"\]\s*\{[\s\S]*?width: 58px;[\s\S]*?height: 58px;/);
assert.match(skin.css, /kaak-workspace\.quick-server"\]\s*\{[\s\S]*?width: 58px;[\s\S]*?height: 58px;[\s\S]*?border: 2px solid transparent;[\s\S]*?border-radius: 18px;/);
assert.match(skin.css, /quick-server\"\]\:hover[\s\S]*?background: #383a40;/);
assert.match(skin.css, /quick-server\"\]\:not\(\[aria-current=\"true\"\]\):hover[\s\S]*?server-monogram[\s\S]*?background: #383a40;/);
assert.match(skin.css, /quick-server\"\]\[aria-current=\"true\"\] \{[\s\S]*?border-color: var\(--skin-kaak-rail-accent\);[\s\S]*?background: var\(--skin-kaak-rail-item-bg\);/);
assert.match(skin.css, /quick-server\"\]\[aria-current=\"true\"\][\s\S]*?server-monogram[\s\S]*?background: var\(--skin-kaak-rail-item-bg\);/);
assert.match(skin.css, /quick-server\"\]\[aria-current=\"true\"\]::before[\s\S]*?left: -16px;[\s\S]*?top: 10px;[\s\S]*?width: 4px;[\s\S]*?height: 34px;/);
assert.match(skin.css, /kaak-workspace\.identity-entry\"\]\s*\{[\s\S]*?width: 86px;[\s\S]*?background: #191a1d;/);
assert.match(skin.css, /kaak-workspace\.server-monogram[\s\S]*?width: 100%;[\s\S]*?height: 100%;[\s\S]*?border-radius: 16px;[\s\S]*?font-size: 23px;[\s\S]*?font-weight: 600;/);
assert.match(skin.css, /kaak-workspace\.server-icon[\s\S]*?width: 100%;[\s\S]*?height: 100%;[\s\S]*?border-radius: inherit;[\s\S]*?object-fit: cover;/);
assert.doesNotMatch(skin.css, /server-monogram\"\]\[data-tone=/);
assert.match(skin.css, /kaak-workspace\.identity-monogram\"\]\s*\{[\s\S]*?width: 54px;[\s\S]*?height: 54px;[\s\S]*?border-radius: 50%;[\s\S]*?background: #176a9e;[\s\S]*?font-size: 17px;/);
assert.match(skin.css, /kaak-workspace\.identity-online\"\]\s*\{[\s\S]*?right: -2px;[\s\S]*?bottom: -2px;[\s\S]*?width: 17px;[\s\S]*?height: 17px;[\s\S]*?border: 3px solid #191a1d;[\s\S]*?background: #75c900;/);
assert.match(skin.css, /kaak-workspace\.identity-name\"\]\s*\{\s*display: none;/);
assert.match(skin.css, /@media \(max-width: 820px\)[\s\S]*?grid-template-columns: 86px minmax\(0, 1fr\);[\s\S]*?grid-template-columns: 86px minmax\(0, 1fr\);/);
assert.match(skin.css, /@media \(max-height: 620px\)[\s\S]*?server-rail[\s\S]*?padding-bottom: 76px;/);
assert.match(skin.css, /voice-grid[\s\S]*?grid-template-columns: repeat\(auto-fit/);
assert.match(skin.css, /voice-card[\s\S]*?aspect-ratio: 1\.82;/);
assert.match(skin.css, /\.voice-card\s*\{[\s\S]*?transition: border-color \.18s ease, background-color \.18s ease, box-shadow \.18s ease;/);
+8 -3
View File
@@ -1,10 +1,11 @@
import type { QuickServer } from "./quick-servers.js";
import { isSafeQuickServerIcon, type QuickServer } from "./quick-servers.js";
import { splitTeamSpeakTarget } from "./teamspeak-target.js";
export interface SkinPluginQuickServer {
id: string;
label: string;
monogram: string;
icon: string;
tone: number;
current: boolean;
kind: "favorite" | "recent";
@@ -47,13 +48,17 @@ export function createSkinPluginQuickServerProjection(createId: () => string = r
}
targetByOpaqueId.set(opaqueId, server);
const label = server.label.trim();
const serverName = server.serverName?.trim() ?? "";
const safeLabel = !label || containsConnectionTarget(label, server.address)
? `${server.isFavorite ? "Favorite" : "Recent"} ${index + 1}`
? serverName && !containsConnectionTarget(serverName, server.address)
? serverName
: `${server.isFavorite ? "Favorite" : "Recent"} ${index + 1}`
: label;
return {
id: opaqueId,
label: safeLabel,
monogram: Array.from(safeLabel)[0] ?? "?",
monogram: Array.from(serverName || safeLabel)[0] ?? "?",
icon: isSafeQuickServerIcon(server.serverIcon) ? server.serverIcon : "",
tone: safeLabelTone(safeLabel),
current: isCurrent(server),
kind: server.isFavorite ? "favorite" : "recent",
@@ -83,3 +83,21 @@ test("skin quick-server data redacts connection targets and resolves only host-g
assert.equal(projection.resolve("opaque-1")?.address, "192.0.2.10:9987");
assert.equal(projection.resolve("192.0.2.10:9987"), undefined);
});
test("skin quick-server projection uses the TeamSpeak name and public icon while keeping its target private", () => {
const icon = "data:image/png;base64,iVBORw0KGgo=";
const projection = createSkinPluginQuickServerProjection(() => "opaque-server");
const [server] = projection.project([{
id: "shanghai.example:9987",
address: "shanghai.example:9987",
label: "shanghai.example:9987",
serverName: "兄弟们的teamspeak",
serverIcon: icon,
isFavorite: false,
}], () => true);
assert.equal(server.label, "兄弟们的teamspeak");
assert.equal(server.monogram, "兄");
assert.equal(server.icon, icon);
assert.equal(JSON.stringify(server).includes("shanghai.example"), false);
});
+6
View File
@@ -7900,6 +7900,12 @@
text-transform: uppercase;
}
.favorite-server-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.favorite-server-tooltip {
position: absolute;
z-index: 45;
+28 -7
View File
@@ -347,7 +347,7 @@
<div class="ws-skin-mount-slot" data-ws-skin-mount="voice.server-rail.before"></div>
<div class="favorite-server-rail-list" data-ws-part="voice.favorite-servers.rail.list">
<div
v-for="server in quickServers"
v-for="server in quickServersForDisplay"
:key="server.id"
class="favorite-server-rail-item"
data-ws-part="voice.favorite-servers.rail.item"
@@ -365,7 +365,7 @@
:disabled="voiceState.connecting"
@click.stop="connectQuickServer(server)"
>
<span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)">{{ avatarInitial(server.label) }}</span>
<span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)"><img v-if="server.serverIcon" :src="server.serverIcon" alt="" aria-hidden="true" /><template v-else>{{ avatarInitial(server.serverName || server.label) }}</template></span>
<span class="favorite-server-tooltip" data-ws-part="voice.favorite-servers.tooltip"><strong>{{ server.label }}</strong><small>{{ server.address }}</small></span>
</button>
<button
@@ -400,7 +400,7 @@
:aria-label="t('quickServers')"
>
<div
v-for="server in quickServers"
v-for="server in quickServersForDisplay"
:key="server.id"
class="favorite-server-strip-item"
data-ws-part="voice.favorite-servers.strip.item"
@@ -415,7 +415,7 @@
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
@click="connectQuickServer(server)"
><span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)">{{ avatarInitial(server.label) }}</span><span>{{ server.label }}</span></button
><span class="favorite-server-avatar" data-ws-part="voice.favorite-servers.avatar" :style="avatarStyle(server.label)"><img v-if="server.serverIcon" :src="server.serverIcon" alt="" aria-hidden="true" /><template v-else>{{ avatarInitial(server.serverName || server.label) }}</template></span><span>{{ server.label }}</span></button
><button
type="button"
:class="['favorite-server-strip-toggle', { active: server.isFavorite }]"
@@ -1011,7 +1011,7 @@ import { useWebClientPublicConfig } from "../composables/useWebClientPublicConfi
import { useWebClientServerHistory } from "../composables/useWebClientServerHistory.js";
import { getInitialLanguage, type Language } from "../i18n/web-client.js";
import { clearLocalData as clearStoredLocalData, isLocalPersistenceAvailable, loadLocalPreferences, loadStoredIdentity, removeStoredIdentity, saveLocalPreferences, saveStoredIdentity, type FavoriteServer } from "../services/local-persistence.js";
import type { QuickServer } from "../services/quick-servers.js";
import { isQuickServerAddressLabel, type QuickServer } from "../services/quick-servers.js";
import type { InstalledSkin, SkinHomeCopy } from "../services/skin-pack.js";
import { isPublicSkinEnabled } from "../services/skin-catalog.js";
import { BUILTIN_DARK_SKIN, BUILTIN_LIGHT_SKIN } from "../services/skin-runtime.js";
@@ -1025,6 +1025,7 @@ import { combineTeamSpeakTarget, DEFAULT_TEAM_SPEAK_PORT, isValidTeamSpeakPort,
const {
state: voiceState,
serverInfo: voiceServerInfo,
sessionEpoch,
memberConversationKey,
members,
@@ -1180,6 +1181,7 @@ const {
isFavorite,
loadSavedServers,
recordCurrentServer,
updateCurrentServerIdentity,
selectLocalServer,
saveFavoriteServer,
toggleFavorite,
@@ -1444,6 +1446,20 @@ function isQuickServerTarget(server: QuickServer): boolean {
return server.id === currentServerTarget().toLocaleLowerCase();
}
const quickServersForDisplay = computed(() => quickServers.value.map((server) => {
const liveInfo = isQuickServerTarget(server) ? voiceServerInfo.value : null;
const serverName = liveInfo?.name.trim() || server.serverName;
const label = serverName && (!server.label.trim() || isQuickServerAddressLabel(server.label, server.address))
? serverName
: server.label;
return {
...server,
label,
...(serverName ? { serverName } : {}),
serverIcon: liveInfo ? (liveInfo.icon || undefined) : server.serverIcon,
};
}));
function connectQuickServer(server: QuickServer): void {
if (accessMode.value !== "open" || voiceState.connecting || (voiceState.connected && isQuickServerTarget(server))) return;
const target = splitTeamSpeakTarget(server.address);
@@ -1527,7 +1543,7 @@ async function submitFavoriteServerDraft(draft: FavoriteServerDraft): Promise<vo
const visiblePokes = computed(() => pokeNotifications.slice(-3));
const skinPluginQuickServers = createSkinPluginQuickServerProjection();
const skinPluginQuickList = computed(() => skinPluginQuickServers.project(quickServers.value, isQuickServerTarget));
const skinPluginQuickList = computed(() => skinPluginQuickServers.project(quickServersForDisplay.value, isQuickServerTarget));
const skinPluginFavorites = computed(() => skinPluginQuickList.value
.filter((server) => server.favorite)
.map(({ favorite: _favorite, ...server }) => server));
@@ -1697,7 +1713,7 @@ const skinPluginWidgets = {
accessMode: accessMode.value,
openTargetPrefillBlocked: openTargetPrefillBlocked.value,
accelerationRelays: accelerationRelays.value,
quickServers: quickServers.value,
quickServers: quickServersForDisplay.value,
isFavorite: isFavorite.value,
identityExportBusy: identityExportBusy.value,
hasIdentity: Boolean(identityMaterial.value),
@@ -1888,6 +1904,11 @@ watch(() => voiceState.connected, (connected) => {
playNotification("connected");
recordCurrentServer();
});
watch(voiceServerInfo, (server) => {
if (server && voiceState.connected && server.name.trim()) {
void updateCurrentServerIdentity(server.name, server.icon ?? null);
}
});
watch(() => voiceState.errorCode, (code) => {
if (!favoriteSwitchPending.value || !code || code === "SERVER_PASSWORD_REQUIRED" || code === "INVALID_SERVER_PASSWORD") return;
failFavoriteConnection(localizedMessage(voiceState.error) || t("quickConnectFailed"));
File diff suppressed because it is too large. Load diff