feat: complete runtime and KAAK skin updates

This commit is contained in:
illusia committed 2026-10-12 23:06:55 +08:00
1 parent c994722016
commit 7fd1ea96fe
40 files changed
+3436 -1088

No files matched your search

@@ -0,0 +1,29 @@
import assert from "node:assert/strict";
import test from "node:test";
import { registerIdentityProviderAdapter, requestIdentityProviderLogin } from "./identity-provider.js";
test("identity provider login dispatches stable provider metadata only to a host adapter", async () => {
const requests: unknown[] = [];
const unregister = registerIdentityProviderAdapter("example.account", (request) => requests.push(request));
try {
assert.equal(await requestIdentityProviderLogin({ providerId: "unregistered", providerLabel: "Unregistered" }), false);
assert.equal(await requestIdentityProviderLogin({ providerId: "example.account", providerLabel: "Example" }), true);
assert.deepEqual(requests, [{ providerId: "example.account", providerLabel: "Example" }]);
} finally {
unregister();
}
assert.equal(await requestIdentityProviderLogin({ providerId: "example.account", providerLabel: "Example" }), false);
});
test("identity provider adapters reject invalid or duplicate keys and unregister safely", async () => {
const adapter = () => {};
assert.throws(() => registerIdentityProviderAdapter("MyTS/login", adapter), /Invalid identity provider ID/);
const unregister = registerIdentityProviderAdapter("example", adapter);
assert.throws(() => registerIdentityProviderAdapter("example", adapter), /already registered/);
unregister();
const replacement = () => {};
const unregisterReplacement = registerIdentityProviderAdapter("example", replacement);
unregister();
assert.equal(await requestIdentityProviderLogin({ providerId: "example", providerLabel: "Example" }), true);
unregisterReplacement();
});
+40
View File
@@ -0,0 +1,40 @@
/** Public host contract for future account and identity providers. */
export interface IdentityProviderLoginRequest {
/** Stable, provider-owned key. Never infer the provider from its display label. */
providerId: string;
/** UI label only; adapters should use providerId for all decisions. */
providerLabel: string;
}
export type IdentityProviderLoginAdapter = (request: Readonly<IdentityProviderLoginRequest>) => void | Promise<void>;
const adapters = new Map<string, IdentityProviderLoginAdapter>();
const PROVIDER_ID_PATTERN = /^[a-z0-9][a-z0-9._-]{0,63}$/;
/** Register a host-owned adapter. Skins can request sign-in but cannot register adapters. */
export function registerIdentityProviderAdapter(
providerId: string,
adapter: IdentityProviderLoginAdapter,
): () => void {
if (!PROVIDER_ID_PATTERN.test(providerId)) throw new TypeError("Invalid identity provider ID.");
if (typeof adapter !== "function") throw new TypeError("An identity provider adapter must be a function.");
if (adapters.has(providerId)) throw new Error(`An identity provider adapter is already registered for ${providerId}.`);
adapters.set(providerId, adapter);
return () => {
if (adapters.get(providerId) === adapter) adapters.delete(providerId);
};
}
/** Ask a registered host adapter to handle a user-initiated sign-in request. */
export async function requestIdentityProviderLogin(
request: Readonly<IdentityProviderLoginRequest>,
): Promise<boolean> {
if (!PROVIDER_ID_PATTERN.test(request.providerId)) return false;
const adapter = adapters.get(request.providerId);
if (!adapter) return false;
await adapter(Object.freeze({
providerId: request.providerId,
providerLabel: request.providerLabel,
}));
return true;
}
+8
View File
@@ -0,0 +1,8 @@
import type { ChannelMember } from "../composables/useVoiceWebSocket.js";
/** A client already present in the channel is online unless explicitly away. */
export function memberPresenceKey(member: Pick<ChannelMember, "away" | "isSelf">, speaking: boolean): string {
if (member.away === true) return "away";
if (speaking) return "speaking";
return member.isSelf ? "yourDevice" : "memberOnline";
}
+21 -1
View File
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
import { mergeQuickServers } from "./quick-servers.js";
import { mergeQuickServers, quickServerTargetsEqual } from "./quick-servers.js";
test("quick servers put favorites first and merge matching recent connection details", () => {
const quickServers = mergeQuickServers(
@@ -47,6 +47,26 @@ test("quick server addresses are trimmed, normalized, and empty targets are skip
assert.equal(quickServers[0].address, "Voice.Example:9987");
});
test("a recent default-port alias does not duplicate a favorite, while a different port remains separate", () => {
const quickServers = mergeQuickServers(
[{ id: "favorite", label: "Voice", address: "voice.example" }],
[
{ id: "recent-default", address: "VOICE.EXAMPLE:9987", lastConnectedAt: 3 },
{ id: "recent-custom", address: "voice.example:9988", lastConnectedAt: 2 },
],
);
assert.deepEqual(quickServers.map(({ address, isFavorite }) => [address, isFavorite]), [
["voice.example", true],
["voice.example:9988", false],
]);
});
test("current server matching recognizes omitted default ports after quick-server merging", () => {
assert.equal(quickServerTargetsEqual("voice.example", "VOICE.EXAMPLE:9987"), true);
assert.equal(quickServerTargetsEqual("voice.example:9988", "voice.example:9987"), false);
});
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(
+17 -5
View File
@@ -37,14 +37,14 @@ export function mergeQuickServers(
): QuickServer[] {
const recentByAddress = new Map<string, RecentServer>();
for (const recent of [...recentServers].sort((left, right) => right.lastConnectedAt - left.lastConnectedAt)) {
const key = serverKey(recent.address);
const key = comparableServerKey(recent.address);
if (key && !recentByAddress.has(key)) recentByAddress.set(key, recent);
}
const result: QuickServer[] = [];
const seen = new Set<string>();
for (const favorite of [...favorites].sort((left, right) => left.label.localeCompare(right.label))) {
const key = serverKey(favorite.address);
const key = comparableServerKey(favorite.address);
if (!key || seen.has(key)) continue;
seen.add(key);
const recent = recentByAddress.get(key);
@@ -53,7 +53,7 @@ export function mergeQuickServers(
: isSafeQuickServerIcon(favorite.serverIcon) ? favorite.serverIcon : "";
const savedLabel = favorite.label.trim();
result.push({
id: key,
id: serverKey(favorite.address),
address: favorite.address.trim(),
label: serverName && (!savedLabel || isQuickServerAddressLabel(savedLabel, favorite.address))
? serverName
@@ -69,11 +69,11 @@ export function mergeQuickServers(
}
for (const recent of [...recentServers].sort((left, right) => right.lastConnectedAt - left.lastConnectedAt)) {
const key = serverKey(recent.address);
const key = comparableServerKey(recent.address);
if (!key || seen.has(key)) continue;
seen.add(key);
result.push({
id: key,
id: serverKey(recent.address),
address: recent.address.trim(),
label: recent.serverName?.trim() || recent.address.trim(),
isFavorite: false,
@@ -92,3 +92,15 @@ export function mergeQuickServers(
function serverKey(address: string): string {
return address.trim().toLocaleLowerCase();
}
function comparableServerKey(address: string): string {
const target = splitTeamSpeakTarget(address);
const host = target.address.trim().toLocaleLowerCase();
const port = target.port.trim() || "9987";
return host ? `${host}:${port}` : "";
}
export function quickServerTargetsEqual(left: string, right: string): boolean {
const leftKey = comparableServerKey(left);
return Boolean(leftKey) && leftKey === comparableServerKey(right);
}
+2 -2
View File
@@ -46,10 +46,10 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.86",
version: "3.1.107",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired WebSpeak skin with a split-screen connection home, searchable server header, TeamSpeak banner, nested channel members, attached channel chat, and a compact audio dock.",
description: "A KOOK-inspired WebSpeak skin with a split-screen connection home, searchable server header, TeamSpeak banner, nested channel members, unified chat with local history, and a compact audio dock.",
minAppVersion: "0.2.7-preview",
installedAt: 0,
builtIn: true,
+5 -2
View File
@@ -65,12 +65,13 @@ test("scoped local state keeps each voice channel's chat visibility independent"
accessibleName: "Voice workspace",
permissions: ["session.status.read"],
stateScope: "session.status.channelId",
state: { chatopen: true },
actions: { toggle: { type: "ui.toggleState", args: { key: "chatopen" } } },
state: { chatopen: true, roommenu: true },
actions: { toggle: { type: "ui.toggleState", args: { key: "chatopen", resetKey: "roommenu" } } },
root: { tag: "main", children: [
{ tag: "button", attributes: { type: "button" }, events: { click: "toggle" }, children: [{ text: "Toggle chat" }] },
{ tag: "span", when: { path: "state.chatopen", equals: true }, children: [{ text: "Open" }] },
{ tag: "span", when: { path: "state.chatopen", equals: false }, children: [{ text: "Closed" }] },
{ tag: "span", when: { path: "state.roommenu", equals: true }, children: [{ text: "Menu open" }] },
] },
}],
});
@@ -140,8 +141,10 @@ test("scoped local state keeps each voice channel's chat visibility independent"
app.mount(host);
await nextTick();
assert.match(textContent(host), /Open/);
assert.match(textContent(host), /Menu open/);
await toggle();
assert.match(textContent(host), /Closed/);
assert.doesNotMatch(textContent(host), /Menu open/, "a page toggle can close a related transient menu");
channelId.value = "voice-b";
await nextTick();
+120 -41
View File
@@ -243,15 +243,22 @@ test("the activity artwork layer floats above room content without intercepting
assert.match(css, /@media \(min-width: 741px\)\s*\{\s*\/\* Keep header menus above the independently stacked screen-share stage\. \*\/\s*\.app-shell \.workspace-header\s*\{\s*position: relative;\s*z-index: 40;/);
});
test("channel empty state removes its bubble ornament and keeps the text-channel label", async () => {
test("channel empty state removes its bubble ornament and keeps the text-channel label", async () => {
const [view, chat] = await Promise.all([
readFile(new URL("../components/web-client/ChatPanel.vue", import.meta.url), "utf8"),
readFile(new URL("../composables/useWebClientChat.ts", import.meta.url), "utf8"),
]);
assert.doesNotMatch(view, /data-ws-state="messages-empty"><div class="chat-empty-icon"/);
assert.match(view, /class="section-kicker">\{\{ chatTabLabel \}\}/);
assert.match(chat, /tab\.value === "channel" \? t\("textChannel"\)/);
});
assert.match(chat, /tab\.value === "channel" \? t\("textChannel"\)/);
});
test("mobile chat starts closed and follows viewport changes", async () => {
const chat = await readFile(new URL("../composables/useWebClientChat.ts", import.meta.url), "utf8");
assert.match(chat, /const panelOpen = ref\(!isMobileViewport\.value\)/);
assert.match(chat, /watch\(isMobileViewport,[\s\S]*?panelOpen\.value = !mobile;/);
assert.match(chat, /panelOpen\.value = !isMobileViewport\.value;/);
});
test("homepage motion and room content spacing preserve the ILLUSIA layout", async () => {
const css = await readFile(new URL("../styles/web-client.css", import.meta.url), "utf8");
@@ -479,7 +486,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.86");
assert.equal(skin.version, "3.1.107");
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");
@@ -489,7 +496,14 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
["kaak-workspace", "surface"],
]);
assert.ok(home?.permissions.includes("ui.surface.replace"));
assert.match(skin.css, /@media \(max-width: 850px\)[\s\S]*?\[data-ws-plugin-part="kaak-home\.hero"\]\s*\{\s*display: none;/, "the narrow connection home hides the green hero and screen illustration");
assert.match(skin.css, /@media \(max-width: 850px\)[\s\S]*?\[data-ws-plugin-part="kaak-home\.welcome-title"\]\s*\{\s*display: none;/, "the narrow connection home shows only the login card");
assert.equal(voice?.stateScope, "session.status.channelId");
assert.equal(voice?.state?.channelspage, false);
assert.equal(voice?.actions["toggle-mobile-page"]?.type, "ui.toggleState");
assert.equal(voice?.actions["toggle-mobile-page"]?.args.resetKey, "roommenu");
assert.equal(voice?.root.attributes?.["data-mobile-channels"], "{{state.channelspage}}");
assert.equal(voice?.root.attributes?.["data-session-connected"], "{{session.status.connected}}");
assert.ok(voice?.permissions.includes("ui.surface.replace"));
assert.ok(voice?.permissions.includes("servers.quickList.read"));
assert.ok(voice?.permissions.includes("servers.quickList.switch"));
@@ -514,6 +528,16 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
return undefined;
}
assert.equal(findPart(home?.root, "home-language")?.widget, "app.language-switcher", "the KAAK connection home has a language switcher in its top corner");
assert.equal(findPart(home?.root, "server-announcement")?.widget, "home.server-announcement", "the KAAK connection home displays the localized administrator announcement");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.hero"\]\s*\{[^}]*overflow: visible;/, "the hero does not clip the announcement as it spans the full home width");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.server-announcement"\][^}]*width: calc\(100% - 40px\);[^}]*margin: 20px 20px 0;/, "the announcement card fills its half-width hero with 20px side margins");
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home\.server-announcement"\] \[data-ws-part="home\.server-announcement\.body"\]\s*\{[^}]*color: #273248;/, "the announcement uses the published semantic text part with a readable color");
assert.equal(findPart(home?.root, "home-social-links")?.widget, "home.social-links", "the KAAK connection home exposes icon links beside the language switcher");
assert.equal(findPart(home?.root, "identity-provider")?.widget, "home.identity-provider");
assert.deepEqual(findPart(home?.root, "identity-provider")?.options, { identityProviderId: "myts", identityProviderLabel: "myts" });
assert.doesNotMatch(skin.css, /kaak-home-announcement-text|kaak-home-social-links|kaak-home-status|kaak-myts/);
assert.match(skin.css, /kaak-home\.home-social-links"\]\s*\{[^}]*position: fixed;[^}]*top: 18px;[^}]*right: 74px;/);
assert.match(skin.css, /kaak-home\.home-social-links"\] \[data-ws-part="home\.social-links"\]\s*\{[^}]*display: flex;[^}]*gap: 8px;/);
assert.equal(findPart(voice?.root, "topbar"), undefined, "the KAAK voice surface has no top bar");
assert.equal(findPart(voice?.root, "rail-skin")?.widget, "app.skin-switcher", "skin selection lives in the server rail");
assert.equal(findPart(voice?.root, "rail-language")?.widget, "app.language-switcher", "language selection lives in the server rail");
@@ -521,6 +545,34 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.deepEqual(findPart(voice?.root, "member-cards")?.options, { screenShare: true, memberActions: true });
assert.equal(findPart(voice?.root, "server-summary")?.widget, "voice.server-header");
assert.equal(findPart(voice?.root, "server-banner")?.widget, "voice.server-banner");
assert.deepEqual(findPart(voice?.root, "mobile-room-return")?.when, { path: "session.status.connected", equals: true });
assert.equal(findPart(voice?.root, "mobile-room-return")?.events?.click, "toggle-mobile-page");
assert.equal(findPart(voice?.root, "mobile-room-topbar")?.children?.[0]?.events?.click, "toggle-mobile-page");
assert.equal(findPart(voice?.root, "mobile-room-more-toggle")?.events?.click, "toggle-room-menu");
assert.equal(findPart(voice?.root, "mobile-room-chat-open")?.events?.click, "toggle-chat-panel");
assert.equal(findPart(voice?.root, "mobile-room-sheet"), undefined, "the narrow room page reuses the sample-matched voice console");
const roomControls = findPart(voice?.root, "mobile-room-controls");
assert.equal(roomControls?.attributes?.role, "toolbar");
assert.deepEqual(roomControls?.children?.map((control) => control.part), [
"mobile-room-microphone", "mobile-room-deafen", "mobile-room-speaker", "mobile-room-share", "mobile-room-share-active", "mobile-room-exit",
]);
assert.equal(findPart(roomControls, "mobile-room-microphone")?.events?.click, "toggle-microphone");
assert.equal(findPart(roomControls, "mobile-room-deafen")?.events?.click, "toggle-output-mute");
assert.equal(findPart(roomControls, "mobile-room-speaker")?.events?.click, "open-audio-settings");
assert.equal(findPart(roomControls, "mobile-room-share")?.events?.click, "start-screen-share");
assert.equal(findPart(roomControls, "mobile-room-share-active")?.events?.click, "stop-screen-share");
assert.equal(findPart(roomControls, "mobile-room-exit")?.events?.click, "disconnect");
assert.equal(voice?.actions["open-audio-settings"]?.type, "audio.openSettings");
assert.equal(findPart(voice?.root, "audio-controls"), undefined, "KAAK declares its desktop audio toolbar in the package instead of selecting a host layout");
const desktopRoomControls = findPart(voice?.root, "desktop-room-controls");
assert.equal(desktopRoomControls?.attributes?.role, "toolbar");
assert.equal(findPart(desktopRoomControls, "desktop-room-settings")?.events?.click, "open-audio-settings");
assert.equal(findPart(desktopRoomControls, "desktop-room-noise-suppression")?.events?.click, "toggle-noise-suppression");
assert.equal(findPart(desktopRoomControls, "desktop-room-microphone")?.events?.click, "toggle-microphone");
assert.equal(findPart(desktopRoomControls, "desktop-room-output")?.events?.click, "toggle-output-mute");
assert.equal(findPart(desktopRoomControls, "desktop-room-accompaniment")?.events?.click, "toggle-accompaniment");
assert.equal(voice?.actions["toggle-noise-suppression"]?.type, "audio.toggleNoiseSuppression");
assert.equal(voice?.actions["toggle-accompaniment"]?.type, "audio.toggleAccompaniment");
assert.equal(findPart(voice?.root, "record-placeholder"), undefined, "the KAAK voice dock has no recording control");
assert.equal(findPart(voice?.root, "voice-channel-tree")?.widget, "voice.channel-tree");
assert.deepEqual(findPart(voice?.root, "voice-channel-tree")?.options, { layout: "server-sidebar", memberActions: true, memberDragDrop: true });
@@ -536,13 +588,22 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(voice?.root.attributes?.["data-voice-group-open"], "{{state.voicegroupopen}}");
const chatToggle = findPart(voice?.root, "chat-panel-toggle");
assert.equal(chatToggle?.events?.click, "toggle-chat-panel");
assert.equal(chatToggle?.attributes?.["aria-expanded"], "{{state.chatopen}}");
assert.equal(chatToggle?.attributes?.["aria-expanded"], "{{chat.status.panelOpen}}");
assert.equal(voice?.actions["toggle-chat-panel"]?.type, "chat.togglePanel");
assert.equal(findPart(voice?.root, "conversation")?.attributes?.["data-chat-open"], "{{chat.status.panelOpen}}");
const chatExpand = findPart(voice?.root, "chat-panel-expand");
assert.deepEqual(chatExpand?.when, { path: "state.chatopen", equals: false });
assert.deepEqual(chatExpand?.when, { path: "chat.status.panelOpen", equals: false });
assert.equal(chatExpand?.events?.click, "toggle-chat-panel");
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(chatExpand?.attributes?.["aria-expanded"], "{{chat.status.panelOpen}}");
assert.equal(chatExpand?.children?.[0]?.text, "聊天");
assert.equal(findPart(voice?.root, "chat-panel")?.widget, "voice.chat-panel");
assert.deepEqual(findPart(voice?.root, "chat-panel")?.when, { path: "chat.status.panelOpen", equals: true });
assert.equal(voice?.root.attributes?.["data-chat-open"], "{{chat.status.panelOpen}}");
assert.equal(findPart(voice?.root, "whisper-controls"), undefined, "the KAAK surface does not add a duplicate whisper button");
assert.equal(voice?.actions["whisper-on"], undefined);
assert.equal(voice?.actions["whisper-off"], undefined);
assert.equal(voice?.permissions.includes("voice.whisper.control"), false);
assert.equal(voice?.permissions.includes("voice.whisper.status.read"), false);
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}}");
@@ -552,6 +613,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(voiceStageHeadingItem?.repeat?.path, "session.channels");
const voiceStageHeading = findPart(voiceStageHeadingItem, "voice-stage-heading");
assert.deepEqual(voiceStageHeading?.when, { path: "stagechannel.current", equals: true });
assert.equal(findPart(voiceStageHeading, "mobile-channel-back")?.events?.click, "toggle-mobile-page");
assert.equal(findPart(voiceStageHeading, "voice-stage-glyph")?.children?.[0]?.text, "🔊︎");
assert.equal(findPart(voiceStageHeading, "voice-stage-title")?.children?.[0]?.text, "{{stagechannel.name}}");
assert.equal(findPart(voiceStageHeading, "voice-stage-member-count")?.children?.[0]?.text, "{{stagechannel.memberCountLabel}}");
@@ -566,24 +628,43 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(findPart(voice?.root, "screen-share-player")?.widget, "voice.screen-share-player");
assert.equal(findPart(voice?.root, "performance-panel")?.widget, "voice.performance-panel");
assert.deepEqual(findPart(voice?.root, "performance-panel")?.options, { screenShare: false });
assert.equal(findPart(voice?.root, "chat-input")?.bindValue, "message");
assert.equal(findPart(voice?.root, "chat-input")?.attributes?.placeholder, "给 #{{session.status.channelName}} 发消息");
assert.equal(findPart(voice?.root, "conversation-glyph")?.children?.[0]?.text, "#");
assert.equal(findPart(voice?.root, "chat-input"), undefined, "KAAK uses the host-owned unified chat composer");
assert.ok(skin.css.includes("data-session-connected=\"true\""));
assert.ok(skin.css.includes("[data-ws-plugin-part=\"kaak-workspace.workspace\"][data-session-connected=\"true\"]:not([data-mobile-channels=\"true\"])"));
assert.ok(skin.css.includes("[data-ws-plugin-part=\"kaak-workspace\"][data-ws-plugin-surface=\"voice\"]:has([data-ws-plugin-part=\"kaak-workspace.chat-panel-toggle\"][aria-expanded=\"false\"])"));
assert.match(skin.css, /\.ws-skin-root\[data-ws-skin="community\.kaak-voice"\]\s+\[data-ws-plugin-part="kaak-workspace"\]\[data-ws-plugin-surface="voice"\]\s*\{[\s\S]*?height: 100dvh;/, "the voice surface owns the KAAK grid and viewport sizing");
assert.doesNotMatch(skin.css, /\[data-ws-plugin-part="kaak-workspace"\](?!\[data-ws-plugin-surface="voice"\])/, "KAAK workspace selectors must anchor to the voice surface root, not generic child nodes");
assert.ok(skin.css.includes("mobile-room-return"));
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace.workspace"][data-session-connected="true"][data-mobile-channels="true"] [data-ws-plugin-part="kaak-workspace.mobile-room-menu"]'), "the room menu stays hidden on the channel tree page");
assert.ok(skin.css.includes("grid-template-columns: 86px minmax(0, 1fr)"));
assert.ok(skin.css.includes("inset: 0 0 0 86px"));
assert.match(skin.css, /kaak-workspace"\]\[data-ws-plugin-surface="voice"\]:has\([\s\S]{0,180}kaak-workspace\.voice-stage"\]\s*\{[^}]*grid-column: 1;[^}]*grid-row: 3;/, "the collapsed chat state must not push the connected narrow room into an implicit side column");
assert.match(skin.css, /kaak-workspace\.conversation\"]\[data-chat-open="true"\]\s*\{\s*position: absolute;/);
assert.match(skin.css, /voice-dock-actions"\] \{ grid-template-columns: minmax\(0, 1fr\) 28px 28px 36px; grid-template-rows: 29px 26px; column-gap: 6px; row-gap: 21px; \}/);
assert.match(skin.css, /voice-dock-actions"\]::after \{ top: 40px; \}/);
assert.match(skin.css, /max-width: 740px[\s\S]*?grid-template-rows: auto auto minmax\(0, 1fr\) auto;[\s\S]*?max-width: 500px;/);
assert.match(skin.css, /workspace\"\]\[data-session-connected=\"true\"\]:not\(\[data-mobile-channels=\"true\"\]\)[\s\S]*?server-rail[\s\S]*?display: none;/);
assert.match(skin.css, /voice-dock-actions"\] \{[\s\S]*?grid-template-columns: minmax\(0, 1fr\) 28px 28px 36px;[\s\S]*?grid-template-rows: 29px 26px;/);
assert.match(skin.css, /workspace"\]\[data-session-connected="true"\]:not\(\[data-mobile-channels="true"\]\) \[data-ws-plugin-part="kaak-workspace\.voice-dock"\] \{[\s\S]*?height: max-content;[\s\S]*?grid-template-columns: minmax\(0, 1fr\);[\s\S]*?grid-template-rows: 5px max-content;[\s\S]*?overflow: hidden;/, "the narrow room console stays content-sized in one column and clips controls to its boundary");
assert.match(skin.css, /mobile-room-control-disc[\s\S]*?aspect-ratio: 1;[\s\S]*?border-radius: 50%;/);
assert.match(skin.css, /mobile-room-controls[\s\S]*?width: min\(100%, 62px\);/);
assert.match(skin.css, /mobile-room-control-caption[\s\S]*?font-size: 11px;[\s\S]*?line-height: 1\.2;/);
assert.match(skin.css, /voice-dock-actions"\] \{ display: none; \}/);
assert.match(skin.css, /mobile-room-controls"\] \{[\s\S]*?grid-column: 1 \/ -1;[\s\S]*?grid-template-columns: repeat\(5, minmax\(0, 1fr\)\);[\s\S]*?grid-template-rows: max-content;[\s\S]*?height: max-content;[\s\S]*?gap: 2px;/);
assert.match(skin.css, /\.mobile-room-(microphone|deafen|speaker|share|exit) \{ grid-column: [1-5]; \}/);
assert.equal(findPart(voice?.root, "conversation-title")?.children?.[0]?.text, "{{chat.status.tabLabel}}");
assert.equal(findPart(voice?.root, "connection-state"), undefined);
assert.equal(findPart(voice?.root, "chat-message-avatar")?.children?.[0]?.text, "{{message.author}}");
assert.equal(findPart(voice?.root, "chat-message-body")?.children?.[0]?.part, "chat-message-heading");
assert.equal(findPart(voice?.root, "chat-message-body")?.attributes?.["data-kind"], "{{message.kind}}");
assert.equal(findPart(voice?.root, "chat-message"), undefined, "private, server, and channel messages use the same host panel");
assert.equal(findPart(voice?.root, "screen-share-start")?.widget, "voice.screen-share-start");
assert.equal(findPart(voice?.root, "screen-share-stop")?.events?.click, "stop-screen-share");
assert.equal(findPart(voice?.root, "audio-controls")?.widget, "voice.audio-controls");
assert.deepEqual(findPart(voice?.root, "audio-controls")?.options, { layout: "room-panel" });
assert.equal(findPart(voice?.root, "audio-controls"), undefined);
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace.server-summary"]'));
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace.server-banner"]'));
assert.match(skin.css, /ws-voice-server-banner-image[\s\S]*?aspect-ratio: 1\.95 \/ 1;[\s\S]*?object-fit: cover;/);
assert.match(skin.css, /voice\.server-banner\.body[\s\S]*?white-space: pre-wrap;/);
assert.ok(skin.css.includes(".ws-voice-server-search-toggle"));
assert.ok(skin.css.includes(".ws-voice-server-switcher-menu"));
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace"] .ws-voice-channel-row'));
assert.ok(skin.css.includes('[data-ws-plugin-part="kaak-workspace"][data-ws-plugin-surface="voice"] .ws-voice-channel-row'));
assert.match(skin.css, /ws-voice-channel-node\[data-current="true"\][\s\S]*?box-shadow: inset 2px 0 var\(--skin-kaak-accent\);/);
assert.match(skin.css, /ws-voice-channel-branch\[data-expanded="false"\][\s\S]*?grid-template-rows: 0fr;/);
assert.match(skin.css, /ws-voice-channel-member-avatar[\s\S]*?border-radius: 50%;/);
@@ -606,25 +687,22 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /ws-voice-channel-member:hover\s*\{[^}]*background: #303238;/);
assert.match(skin.css, /ws-voice-channel-row\[data-drag-over="true"\]\s*\{[^}]*box-shadow: inset 0 0 0 1px #72c866;/);
assert.doesNotMatch(skin.css, /kaak-workspace\.record-placeholder|kaak-workspace\.recording-label/);
assert.match(skin.css, /desktop-audio-dock-room-panel \{\s*display: contents;\s*\}/);
assert.match(skin.css, /desktop-audio-dock-copy \{ display: none; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-controls"\] \{ display: contents; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace"\]\[data-ws-plugin-surface="voice"\] \.desktop-audio-dock-copy \{ display: none; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.voice-dock-share"\] \{ grid-column: 1 \/ 4; grid-row: 1;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.voice-dock-share"\] \.skin-runtime-screen-share-start \{[\s\S]*?background: #69c000;/);
assert.match(skin.css, /room-panel-audio-settings[\s\S]*?grid-column: 1;[\s\S]*?grid-row: 2;[\s\S]*?justify-content: flex-start;[\s\S]*?gap: 8px;/);
assert.match(skin.css, /noise-suppression-toggle \{ grid-column: 2; grid-row: 2; align-self: center; \}/);
assert.match(skin.css, /noise-suppression-toggle\.inactive::after[\s\S]*?background: #e34848;/);
assert.match(skin.css, /noise-suppression-toggle\.inactive \{ position: relative; color: #ff4c49; \}/);
assert.match(skin.css, /mobile-noise-suppression\.inactive::after[\s\S]*?background: #e34848;/);
assert.match(skin.css, /voice\.audio-dock\.microphone[\s\S]*?grid-column: 3;[\s\S]*?grid-row: 2;/);
assert.match(skin.css, /voice\.audio-dock\.output[\s\S]*?grid-column: 4;[\s\S]*?grid-row: 2;/);
assert.match(skin.css, /accompaniment-toggle \{[\s\S]*?grid-column: 4;[\s\S]*?grid-row: 1;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-settings"\][\s\S]*?grid-column: 1;[\s\S]*?grid-row: 2;[\s\S]*?justify-content: flex-start;[\s\S]*?gap: 8px;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-noise-suppression"\] \{ grid-column: 2; grid-row: 2; color: #fff; background: #6cbf00; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-noise-suppression"\]\[aria-pressed="false"\],[\s\S]*?background: #e34848;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-microphone"\] \{ grid-column: 3; grid-row: 2; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-output"\] \{ grid-column: 4; grid-row: 2; \}/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-accompaniment"\] \{[\s\S]*?grid-column: 4;[\s\S]*?grid-row: 1;/);
assert.match(skin.css, /voice-dock-heading"\] \[data-ws-plugin-part="kaak-workspace\.disconnect-control"\]::before \{ content: "⏻";/);
assert.match(skin.css, /desktop-audio-dock-room-panel \.noise-suppression-toggle \{[\s\S]*?margin: 0;[\s\S]*?padding: 0;/);
assert.match(skin.css, /desktop-audio-dock-room-panel \.accompaniment-toggle \{[\s\S]*?pointer-events: auto;[\s\S]*?cursor: pointer;/);
assert.match(skin.css, /accompaniment-toggle\[aria-pressed="true"\] \{ background: #477f00;/);
assert.match(skin.css, /mobile-voice-controls \{\s*display: contents;\s*\}/);
assert.match(skin.css, /mobile-noise-suppression \{ grid-column: 2; grid-row: 2; \}/);
assert.match(skin.css, /mobile-microphone-toggle \{ grid-column: 3; grid-row: 2; \}/);
assert.doesNotMatch(skin.css, /desktop-audio-dock-room-panel|room-panel-audio-settings|data-ws-plugin-part="kaak-workspace\.audio-controls"/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.desktop-room-accompaniment"\]\[aria-pressed="true"\] \{ background: #477f00;/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-workspace\.mobile-room-controls"\] \{ display: none; \}/);
assert.match(skin.css, /kaak-workspace\.mobile-room-controls[\s\S]*?\.mobile-room-microphone \{ grid-column: 1; \}/);
assert.match(skin.css, /kaak-workspace\.mobile-room-controls[\s\S]*?\.mobile-room-exit \{ grid-column: 5; \}/);
assert.match(skin.css, /voice\.member\.action-trigger[\s\S]*?width: 44px;/);
assert.match(skin.css, /\.ws-skin-root\[data-ws-skin="community\.kaak-voice"\] \[data-ws-part="voice\.context-menu"\]\s*\{[^}]*background: #303136;/);
assert.match(skin.css, /\[data-ws-part="voice\.context-menu"\] \.menu-volume\s*\{[^}]*border-bottom: 1px solid #48494f;/);
@@ -644,8 +722,8 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /\.microphone-toggle:not\(\.muted\):active,[\s\S]*?background: #60ab00;\s*border-color: #60ab00;/);
assert.doesNotMatch(skin.css, /#58c877/);
assert.match(skin.css, /\[data-ws-plugin-part="kaak-home"\] \{[^}]*font-family: Arial, "Microsoft YaHei", sans-serif;/);
assert.match(skin.css, /\.kaak-myts-login\s*\{[^}]*width: 60px;[^}]*height: 60px;[^}]*background: transparent;[^}]*clip-path: polygon\(0 0, 100% 0, 100% 100%\);/);
assert.match(skin.css, /\.kaak-myts-wordmark\s*\{[^}]*color: #fff;[^}]*transform: rotate\(45deg\);/);
assert.match(skin.css, /\[data-ws-part="home\.identity-provider\.button"\][\s\S]*?clip-path: polygon\(0 0, 100% 0, 100% 100%\);/);
assert.match(skin.css, /\[data-ws-part="home\.identity-provider\.label"\][\s\S]*?color: #fff;[\s\S]*?transform: rotate\(45deg\);/);
assert.match(skin.css, /settings-select-menu[\s\S]*?background: #25262a/);
assert.match(skin.css, /settings-select-option[\s\S]*?min-height: 32px/);
assert.match(skin.css, /settings-header h2 \{\s*color: #f2f3f5;\s*font-size: 32px;\s*font-weight: 600;/);
@@ -740,18 +818,19 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.match(skin.css, /kaak-workspace\.screen-share-player"\] \.screen-share-player-stage \{[^}]*height: min\(42dvh, 400px\);[^}]*min-height: 180px;/);
assert.match(skin.css, /kaak-workspace\.member-cards"\]\s*\{[^}]*flex: 1 1 0%;[^}]*overflow-y: auto;/);
assert.match(skin.css, /kaak-workspace\.conversation[\s\S]*?grid-column: 4;/);
assert.match(skin.css, /conversation[\s\S]*?grid-template-rows: 58px minmax\(0, 1fr\) auto/);
assert.match(skin.css, /chat-send[\s\S]*?::after \{ content: "➤";/);
assert.match(skin.css, /conversation[\s\S]*?grid-template-rows: 50px minmax\(0, 1fr\);/);
assert.match(skin.css, /voice\.chat\.messages[\s\S]*?max-height: none;[\s\S]*?overflow-y: auto;/);
assert.match(skin.css, /voice\.chat\.message-bubble[\s\S]*?background: transparent;[\s\S]*?white-space: pre-wrap;/);
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.voice-card[\s\S]*?aspect-ratio: 1\.82;/);
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.screen-share-live-indicator[\s\S]*?background: #20251e;/);
assert.match(skin.css, /kaak-workspace\.member-cards[\s\S]*?\.screen-share-card-button\.viewing[\s\S]*?background: #8be31e;/);
assert.match(skin.css, /kaak-workspace"\] \[data-ws-part="voice\.screen-player\.stage"\]\s*\{[^}]*background: #000/);
assert.match(skin.css, /kaak-workspace"\] \[data-ws-part="voice\.screen-player\.video"\]\s*\{[^}]*object-fit: contain;[^}]*background: #000/);
assert.match(skin.css, /kaak-workspace"\]\[data-ws-plugin-surface="voice"\] \[data-ws-part="voice\.screen-player\.stage"\]\s*\{[^}]*background: #000/);
assert.match(skin.css, /kaak-workspace"\]\[data-ws-plugin-surface="voice"\] \[data-ws-part="voice\.screen-player\.video"\]\s*\{[^}]*object-fit: contain;[^}]*background: #000/);
assert.match(skin.css, /@keyframes ws-community-kaak-voice-kaak-member-speaking-wave/);
assert.ok(skin.css.includes("animation: ws-community-kaak-voice-kaak-performance-refresh-spin .72s linear infinite;"));
assert.ok(skin.css.includes("performance-refresh:disabled .ui-icon { animation: none; }"));
assert.match(skin.css, /kaak-workspace\.performance-panel"\] \.network-performance \{\s*position: relative;\s*z-index: 8;/);
assert.match(skin.css, /kaak-workspace"\] \.dock-hover-panel \{[\s\S]*?background: #202126;/);
assert.match(skin.css, /kaak-workspace"\]\[data-ws-plugin-surface="voice"\] \.dock-hover-panel \{[\s\S]*?background: #202126;/);
assert.match(skin.css, /kaak-workspace\.identity-entry[\s\S]*?position: absolute;/);
assert.ok(skin.css.includes("@media (max-width: 820px)"));
});
@@ -1,6 +1,10 @@
import assert from "node:assert/strict";
import test from "node:test";
import { computed, ref } from "vue";
import type { ChannelMember } from "../composables/useVoiceWebSocket.js";
import { useWebClientMembers } from "../composables/useWebClientMembers.js";
import { buildVoiceChannelTree, filterVoiceChannelTree } from "./voice-channel-tree.js";
import { memberPresenceKey } from "./member-presence.js";
test("channel search keeps matching nested channels and only their ancestors", () => {
const tree = buildVoiceChannelTree([
@@ -20,3 +24,71 @@ test("channel search keeps matching nested channels and only their ancestors", (
assert.deepEqual(filterVoiceChannelTree(tree, "missing"), []);
assert.deepEqual(filterVoiceChannelTree(tree, " "), tree);
});
test("member volume controls do not begin native drag while member rows remain draggable", () => {
class TestElement {
constructor(private readonly control: boolean) {}
closest(): TestElement | null { return this.control ? this : null; }
setPointerCapture(): void {}
releasePointerCapture(): void {}
}
const previousElement = Object.getOwnPropertyDescriptor(globalThis, "Element");
Object.defineProperty(globalThis, "Element", { configurable: true, value: TestElement });
try {
const member = { id: 12, nickname: "Member", isSelf: false } as ChannelMember;
const channel = { id: "voice", parentID: "0", name: "Voice", depth: 0, members: [member] };
const controller = useWebClientMembers({
channels: ref([channel]),
currentChannel: computed(() => channel),
members: [member],
speakingIds: new Set<number>(),
whisperTargetIds: new Set<number>(),
moveClient: async () => {},
setWhisperTargets: () => {},
sendPoke: () => {},
setAway: () => {},
stopWhisperTalk: () => {},
localizedMessage: (message) => message,
showToast: () => {},
t: (key) => key,
});
const row = new TestElement(false);
let pointerPrevented = false;
controller.onMemberPointerDown(member, {
target: new TestElement(true), currentTarget: row, button: 0, pointerId: 1, clientX: 10, clientY: 10,
preventDefault: () => { pointerPrevented = true; },
} as unknown as PointerEvent);
assert.equal(pointerPrevented, false, "the slider keeps its pointer interaction");
let dragPrevented = false;
controller.onMemberDragStart(member, {
preventDefault: () => { dragPrevented = true; },
dataTransfer: null,
} as unknown as DragEvent);
assert.equal(dragPrevented, true, "a slider drag cannot start the enclosing member drag");
assert.equal(controller.draggedMember.value, null);
controller.onMemberPointerUp({ pointerId: 1 } as PointerEvent);
controller.onMemberPointerDown(member, {
target: row, currentTarget: row, button: 0, pointerId: 2, clientX: 10, clientY: 10,
preventDefault: () => {},
} as unknown as PointerEvent);
dragPrevented = false;
controller.onMemberDragStart(member, {
preventDefault: () => { dragPrevented = true; },
dataTransfer: null,
} as unknown as DragEvent);
assert.equal(dragPrevented, false, "dragging the member row itself remains available");
} finally {
if (previousElement) Object.defineProperty(globalThis, "Element", previousElement);
else Reflect.deleteProperty(globalThis, "Element");
}
});
test("channel members without an away flag are presented as online, never as an unknown state", () => {
assert.equal(memberPresenceKey({ away: undefined, isSelf: false }, false), "memberOnline");
assert.equal(memberPresenceKey({ away: undefined, isSelf: true }, false), "yourDevice");
assert.equal(memberPresenceKey({ away: undefined, isSelf: false }, true), "speaking");
assert.equal(memberPresenceKey({ away: true, isSelf: false }, false), "away");
});