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

+17 -10
View File
@@ -214,16 +214,23 @@ export default defineComponent({
const definition = component.actions[actionId];
if (!definition || !isSkinPluginComponentApproved(props.skinId, props.skinVersion, component)) return;
const args = resolveActionArgs(definition, context, state);
if (definition.type === "ui.setState") {
if (typeof args.key === "string" && component.state && Object.hasOwn(component.state, args.key) && "value" in args) state[args.key] = args.value;
return;
}
if (definition.type === "ui.toggleState") {
if (typeof args.key === "string" && component.state && Object.hasOwn(component.state, args.key) && typeof state[args.key] === "boolean") {
state[args.key] = !state[args.key];
}
return;
}
if (definition.type === "ui.setState") {
if (typeof args.key === "string" && component.state && Object.hasOwn(component.state, args.key) && "value" in args) {
state[args.key] = args.value;
refresh.value += 1;
}
return;
}
if (definition.type === "ui.toggleState") {
if (typeof args.key === "string" && component.state && Object.hasOwn(component.state, args.key) && typeof state[args.key] === "boolean") {
state[args.key] = !state[args.key];
if (typeof args.resetKey === "string" && component.state && Object.hasOwn(component.state, args.resetKey) && typeof state[args.resetKey] === "boolean") {
state[args.resetKey] = false;
}
refresh.value += 1;
}
return;
}
const handler = props.actions[definition.type];
if (handler) void Promise.resolve(handler(args, component)).catch(() => undefined);
}
+12 -41
View File
@@ -1,23 +1,10 @@
<template>
<div
:class="[
'desktop-audio-dock',
{ 'desktop-audio-dock-room-panel': layout === 'room-panel' },
]"
class="desktop-audio-dock"
data-ws-part="voice.audio-dock"
role="toolbar"
:aria-label="t('desktopAudioControls')"
>
<button
v-if="layout === 'room-panel'"
type="button"
class="room-panel-audio-settings"
:aria-label="t('voiceSettings')"
:title="t('voiceSettings')"
aria-haspopup="dialog"
@click="emit('settings')"
><Icon name="settings" :size="16" /><span>{{ t("voiceSettings") }}</span></button
>
<div class="desktop-audio-dock-copy"
><strong>{{ t("desktopAudioControls") }}</strong
><span>{{
@@ -25,17 +12,6 @@
}}</span></div
>
<div class="desktop-audio-dock-actions">
<button
v-if="layout === 'room-panel'"
type="button"
class="dock-audio-button noise-suppression-toggle"
:class="{ active: noiseSuppressionEnabled, inactive: !noiseSuppressionEnabled }"
:title="t('noiseSuppression')"
:aria-label="t('noiseSuppression')"
:aria-pressed="noiseSuppressionEnabled"
@click="toggleNoiseSuppression"
><Icon name="noise-suppression" :size="20" /></button
>
<div
class="dock-hover-control"
data-ws-part="voice.audio-dock.microphone"
@@ -73,18 +49,16 @@
:aria-label="t('inputVolume')"
@input="onInputVolume"
/>
<template v-if="layout === 'default'">
<div class="dock-panel-divider"></div>
<label class="dock-switch-row"
><span
><strong>{{ t("noiseSuppression") }}</strong></span
><input
type="checkbox"
:checked="noiseSuppressionEnabled"
:aria-label="t('noiseSuppression')"
@change="onNoiseSuppressionToggle"
/></label>
</template>
<div class="dock-panel-divider"></div>
<label class="dock-switch-row"
><span
><strong>{{ t("noiseSuppression") }}</strong></span
><input
type="checkbox"
:checked="noiseSuppressionEnabled"
:aria-label="t('noiseSuppression')"
@change="onNoiseSuppressionToggle"
/></label>
</div>
</div>
<div
@@ -127,7 +101,6 @@
</div>
</div>
<button
v-if="layout === 'default'"
type="button"
class="dock-audio-button"
:title="t('audioSettings')"
@@ -161,12 +134,10 @@ import type { useWebClientAudioControls } from "../../composables/useWebClientAu
const props = defineProps<{
model: Pick<ReturnType<typeof useVoiceWebSocket>, "microphoneMuted" | "inputVolume" | "outputVolume" | "outputMuted" | "noiseSuppressionEnabled" | "accompanimentActive">;
controls: Pick<ReturnType<typeof useWebClientAudioControls>, "toggleMicrophone" | "toggleNoiseSuppression" | "onInputVolume" | "onOutputVolume" | "onNoiseSuppressionToggle" | "toggleAccompaniment">;
layout?: "default" | "room-panel";
t: (key: string) => string;
rangeStyle: (value: number, max: number) => Record<string, string>;
}>();
const { microphoneMuted, inputVolume, outputVolume, outputMuted, noiseSuppressionEnabled, accompanimentActive } = props.model;
const { toggleMicrophone, toggleNoiseSuppression, onInputVolume, onOutputVolume, onNoiseSuppressionToggle, toggleAccompaniment } = props.controls;
const layout = props.layout ?? "default";
const { toggleMicrophone, onInputVolume, onOutputVolume, onNoiseSuppressionToggle, toggleAccompaniment } = props.controls;
const emit = defineEmits<{ settings: []; outputMute: [] }>();
</script>
@@ -108,15 +108,7 @@
class="member-copy"
data-ws-part="voice.member-row.copy"
><strong>{{ memberDisplayName(member) }}</strong
><span>{{
member.away === true
? t("away")
: isSpeaking(member)
? t("speaking")
: member.away === false
? member.isSelf ? t("yourDevice") : t("memberOnline")
: t("statusUnknown")
}}</span></div
><span>{{ t(memberPresenceKey(member, isSpeaking(member))) }}</span></div
>
<div
class="member-flags"
@@ -130,13 +122,7 @@
name="clock"
:size="13" /></span
><span
v-if="member.inputMuted === undefined"
class="unknown"
:title="t('statusUnknown')"
:aria-label="t('statusUnknown')"
><Icon name="info" :size="13" /></span
><span
v-else-if="member.inputMuted"
v-if="member.inputMuted"
:title="t('inputMuted')"
:aria-label="t('inputMuted')"
><Icon
@@ -202,6 +188,7 @@
<script setup lang="ts">
import type { CSSProperties } from "vue";
import Icon from "../Icon.vue";
import { memberPresenceKey } from "../../services/member-presence.js";
import type { TreeChannel } from "../../composables/useWebClientChannels.js";
import type { useWebClientMembers } from "../../composables/useWebClientMembers.js";
@@ -1,6 +1,8 @@
<template>
<section
:class="['chat-panel', { 'mobile-section-hidden': mobileHidden }]"
:data-ws-chat-tab="chatTab"
:data-ws-chat-panel-open="panelOpen"
data-ws-part="voice.chat"
>
<div
@@ -12,6 +14,7 @@
<button
type="button"
data-ws-part="voice.chat.tab"
data-ws-chat-kind="channel"
:data-ws-state="chatTab === 'channel' ? 'active' : 'idle'"
:class="{ active: chatTab === 'channel' }"
@click="chatTab = 'channel'"
@@ -24,6 +27,7 @@
<button
type="button"
data-ws-part="voice.chat.tab"
data-ws-chat-kind="server"
:data-ws-state="chatTab === 'server' ? 'active' : 'idle'"
:class="{ active: chatTab === 'server' }"
@click="chatTab = 'server'"
@@ -38,6 +42,7 @@
:key="conversation.key"
type="button"
data-ws-part="voice.chat.tab"
data-ws-chat-kind="private"
:data-ws-state="
chatTab === 'private' && privateConversationKey === conversation.key ? 'active' : 'idle'
"
@@ -52,6 +57,7 @@
<button
type="button"
data-ws-part="voice.chat.tab"
data-ws-chat-kind="events"
:data-ws-state="chatTab === 'events' ? 'active' : 'idle'"
:class="{ active: chatTab === 'events' }"
@click="chatTab = 'events'"
@@ -203,6 +209,7 @@ import type { ChatMessage, ServerEvent } from "../../composables/useVoiceWebSock
type ChatPanelModel = Pick<ReturnType<typeof useWebClientChat>,
| "tab" | "privateConversationKey" | "canSend" | "status" | "messageDraft"
| "panelOpen"
| "listElement" | "conversations" | "visibleMessages" | "tabLabel" | "title"
| "placeholder" | "openConversation" | "submitMessage" | "onScroll"
>;
@@ -223,6 +230,7 @@ const props = defineProps<{
// Keep its list ref attached to the rendered scroller, including unmount cleanup.
const {
tab: chatTab,
panelOpen,
privateConversationKey,
canSend: canSendChat,
status: chatStatus,
+28 -2
View File
@@ -51,6 +51,7 @@ export function useWebClientChat({
t,
}: UseWebClientChatOptions) {
const tab = ref<WebClientChatTab>("channel");
const panelOpen = ref(!isMobileViewport.value);
const privateClientId = ref(0);
const privateConversationKey = ref("");
const messageDraft = ref("");
@@ -95,6 +96,19 @@ export function useWebClientChat({
lastMessage: Math.max(existing?.lastMessage ?? 0, message.timestamp),
});
}
// A newly opened private chat has no message from which to derive a tab.
// Keep the selected recipient visible so the first message can be sent and
// the empty state still has a named conversation.
if (tab.value === "private" && privateConversationKey.value && privateClientId.value) {
const selected = recipient.value;
const existing = byConversation.get(privateConversationKey.value);
byConversation.set(privateConversationKey.value, {
id: selected?.id ?? existing?.id ?? privateClientId.value,
key: privateConversationKey.value,
name: selected?.nickname ?? existing?.name ?? t("privateMessage"),
lastMessage: existing?.lastMessage ?? 0,
});
}
return [...byConversation.values()].sort((left, right) => right.lastMessage - left.lastMessage);
});
@@ -102,8 +116,9 @@ export function useWebClientChat({
if (tab.value === "server") return messages.filter((message) => message.scope === "server");
if (tab.value === "private") return messages.filter(message => message.scope === "private" && messageKey(message) === privateConversationKey.value);
if (tab.value !== "channel") return [];
const channelId = currentChannel.value?.id;
return messages.filter((message) => message.scope === "channel" && (!message.targetId || message.targetId === "0" || !channelId || message.targetId === channelId));
const channelId = currentChannel.value?.id || selectedChannelId.value;
return messages.filter((message) => message.scope === "channel"
&& (!message.targetId || message.targetId === "0" || (channelId ? message.targetId === channelId : false)));
});
const tabLabel = computed(() => tab.value === "channel" ? t("textChannel") : tab.value === "server" ? t("serverChat") : tab.value === "private" ? t("privateMessage") : t("eventLog"));
@@ -146,6 +161,7 @@ export function useWebClientChat({
function openConversation(conversation: PrivateConversation): void {
if (disposed) return;
panelOpen.value = true;
privateClientId.value = conversation.id;
privateConversationKey.value = conversation.key;
tab.value = "private";
@@ -155,6 +171,10 @@ export function useWebClientChat({
scrollIfFollowing();
}
function togglePanel(): void {
panelOpen.value = !panelOpen.value;
}
async function submitMessage(): Promise<void> {
if (disposed || sending.value || !messageDraft.value.trim() || tab.value === "events") return;
if (!connected.value) { sendError.value = "chatNotConnected"; return; }
@@ -199,6 +219,9 @@ export function useWebClientChat({
sending.value = pending.has(next);
sendError.value = errors.get(next) ?? "";
}, { flush: "sync" });
watch(isMobileViewport, (mobile) => {
panelOpen.value = !mobile;
}, { flush: "sync" });
watch(sessionEpoch, () => {
historyGeneration++;
persistedMessageIds.clear();
@@ -208,6 +231,7 @@ export function useWebClientChat({
privateClientId.value = 0;
privateConversationKey.value = "";
tab.value = "channel";
panelOpen.value = !isMobileViewport.value;
messageDraft.value = "";
drafts.clear();
sending.value = false;
@@ -250,6 +274,8 @@ export function useWebClientChat({
return {
tab,
panelOpen,
togglePanel,
privateClientId,
privateConversationKey,
sending, sendError, canSend, status,
@@ -160,7 +160,7 @@ export function useWebClientConnection({
})();
}
function doDisconnect(): void {
function doDisconnect(notify = true): void {
serverPasswordLookupAttempt += 1;
resolvingServerPassword = false;
attemptedServerCredential = null;
@@ -168,7 +168,7 @@ export function useWebClientConnection({
attemptedChannelCredential = null;
disconnect();
selectedChannelId.value = "";
showToast(t("leftToast"));
if (notify) showToast(t("leftToast"));
}
function submitServerPassword(): void {
+37 -19
View File
@@ -48,10 +48,11 @@ export function useWebClientMembers({
const memberMoveMenuOpen = ref(false);
const draggedMember = ref<ChannelMember | null>(null);
const dragOverChannelId = ref("");
const memberPointerDrag = reactive({
member: null as ChannelMember | null,
pointerId: null as number | null,
startX: 0,
const memberPointerDrag = reactive({
member: null as ChannelMember | null,
pointerId: null as number | null,
suppressNativeDragPointerId: null as number | null,
startX: 0,
startY: 0,
active: false,
targetChannelId: "",
@@ -125,8 +126,12 @@ export function useWebClientMembers({
}
}
function onMemberDragStart(member: ChannelMember, event: DragEvent): void {
if (member.isSelf) {
function onMemberDragStart(member: ChannelMember, event: DragEvent): void {
if (memberPointerDrag.suppressNativeDragPointerId !== null) {
event.preventDefault();
return;
}
if (member.isSelf) {
event.preventDefault();
return;
}
@@ -136,15 +141,20 @@ export function useWebClientMembers({
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
}
function onMemberDragEnd(): void {
draggedMember.value = null;
dragOverChannelId.value = "";
}
function onMemberPointerDown(member: ChannelMember, event: PointerEvent): void {
if (member.isSelf || event.button !== 0) return;
const target = event.target instanceof Element ? event.target : null;
if (target?.closest("input,button")) return;
function onMemberDragEnd(): void {
draggedMember.value = null;
dragOverChannelId.value = "";
memberPointerDrag.suppressNativeDragPointerId = null;
}
function onMemberPointerDown(member: ChannelMember, event: PointerEvent): void {
if (member.isSelf || event.button !== 0) return;
const target = event.target instanceof Element ? event.target : null;
if (target?.closest("input,button,select,textarea,[contenteditable=\"true\"],.member-volume")) {
memberPointerDrag.suppressNativeDragPointerId = event.pointerId;
return;
}
memberPointerDrag.suppressNativeDragPointerId = null;
event.preventDefault();
memberPointerDrag.member = member;
memberPointerDrag.pointerId = event.pointerId;
@@ -175,8 +185,12 @@ export function useWebClientMembers({
dragOverChannelId.value = targetChannelId;
}
function onMemberPointerUp(event: PointerEvent): void {
if (!memberPointerDrag.member || memberPointerDrag.pointerId !== event.pointerId) return;
function onMemberPointerUp(event: PointerEvent): void {
if (memberPointerDrag.suppressNativeDragPointerId === event.pointerId) {
memberPointerDrag.suppressNativeDragPointerId = null;
return;
}
if (!memberPointerDrag.member || memberPointerDrag.pointerId !== event.pointerId) return;
const member = memberPointerDrag.member;
const targetChannelId = memberPointerDrag.targetChannelId;
const currentTarget = event.currentTarget as HTMLElement | null;
@@ -190,8 +204,12 @@ export function useWebClientMembers({
if (targetChannelId) void moveMemberDirect(member, targetChannelId);
}
function onMemberPointerCancel(event: PointerEvent): void {
if (!memberPointerDrag.member || memberPointerDrag.pointerId !== event.pointerId) return;
function onMemberPointerCancel(event: PointerEvent): void {
if (memberPointerDrag.suppressNativeDragPointerId === event.pointerId) {
memberPointerDrag.suppressNativeDragPointerId = null;
return;
}
if (!memberPointerDrag.member || memberPointerDrag.pointerId !== event.pointerId) return;
const currentTarget = event.currentTarget as HTMLElement | null;
currentTarget?.releasePointerCapture?.(event.pointerId);
memberPointerDrag.member = null;
+25 -2
View File
@@ -26,7 +26,9 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
notConfigured: "WebSpeak 尚未配置 TeamSpeak 目标。",
configureNow: "打开管理控制台",
privateAudio: "私密社区语音",
mytsLogin: "使用myts登录",
identityProviderLogin: "使用 {{provider}} 登录",
identityProviderInDevelopment: "{{provider}}登录功能还在开发中",
identityProviderLoginFailed: "无法启动 {{provider}} 登录,请稍后重试",
featureInDevelopment: "这个功能还在开发中",
joinLine1: "连接服务器,",
joinLine2: "马上开始交流。",
@@ -111,6 +113,8 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
enterVoice: "进入语音空间",
connectionAuthorized: "连接信息仅用于本次语音会话",
githubRepository: "GitHub 仓库",
communityLinks: "社区与管理入口",
serverAnnouncement: "服务器公告",
qqGroup: "QQ群",
qqGroupQrAlt: "QQ群二维码",
qqJoinDirect: "或通过群聊链接直接加入",
@@ -448,7 +452,9 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
notConfigured: "The WebSpeak TeamSpeak target has not been configured.",
configureNow: "Open admin console",
privateAudio: "Private community audio",
mytsLogin: "Sign in with myTS",
identityProviderLogin: "Sign in with {{provider}}",
identityProviderInDevelopment: "{{provider}} sign-in is still in development.",
identityProviderLoginFailed: "Could not start {{provider}} sign-in. Try again later.",
featureInDevelopment: "This feature is still in development.",
joinLine1: "Connect to your server,",
joinLine2: "start the conversation.",
@@ -533,6 +539,8 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
enterVoice: "Enter voice space",
connectionAuthorized: "Connection details are used only for this voice session",
githubRepository: "GitHub repository",
communityLinks: "Community and administration links",
serverAnnouncement: "Server announcement",
qqGroup: "QQ group",
qqGroupQrAlt: "QQ group QR code",
qqJoinDirect: "Or join directly via the group link",
@@ -849,6 +857,9 @@ export const webClientTranslations: Record<string, Record<string, string>> = {
webClientTranslations.de = {
...webClientTranslations.en,
identityProviderLogin: "Mit {{provider}} anmelden",
identityProviderInDevelopment: "Die Anmeldung mit {{provider}} ist noch in Entwicklung.",
identityProviderLoginFailed: "Die Anmeldung mit {{provider}} konnte nicht gestartet werden. Bitte später erneut versuchen.",
chatSending: "Warte auf die Bestätigung des Servers…",
chatSendFailed: "Versand nicht bestätigt; der Entwurf bleibt erhalten. Die Nachricht kann trotz Zeitüberschreitung angekommen sein. Vor dem erneuten Senden prüfen.",
chatNotConnected: "Senden ist nach Wiederherstellung der Verbindung möglich. Der Entwurf bleibt erhalten.",
@@ -956,6 +967,8 @@ webClientTranslations.de = {
enterVoice: "Sprachbereich betreten",
connectionAuthorized: "Verbindungsdaten werden nur für diese Sprachsitzung verwendet",
githubRepository: "GitHub-Repository",
communityLinks: "Community- und Verwaltungslinks",
serverAnnouncement: "Serverankündigung",
qqGroup: "QQ-Gruppe",
qqGroupQrAlt: "QR-Code der QQ-Gruppe",
qqJoinDirect: "Oder direkt über den Gruppenlink beitreten",
@@ -1262,6 +1275,11 @@ webClientTranslations.de = {
webClientTranslations.ru = {
...webClientTranslations.en,
identityProviderLogin: "Войти через {{provider}}",
identityProviderInDevelopment: "Вход через {{provider}} ещё разрабатывается",
identityProviderLoginFailed: "Не удалось запустить вход через {{provider}}. Повторите попытку позже.",
communityLinks: "Ссылки на сообщество и панель администратора",
serverAnnouncement: "Объявление сервера",
serverWelcome: "Приветствие сервера",
chatSending: "Ожидание подтверждения сервера…",
chatSendFailed: "Отправка не подтверждена; черновик сохранён. При тайм-ауте сообщение могло дойти. Проверьте перед повторной отправкой.",
@@ -1469,6 +1487,11 @@ webClientTranslations.ru = {
webClientTranslations.ja = {
...webClientTranslations.en,
identityProviderLogin: "{{provider}}でログイン",
identityProviderInDevelopment: "{{provider}}でのログインは開発中です",
identityProviderLoginFailed: "{{provider}}でのログインを開始できませんでした。後でもう一度お試しください。",
communityLinks: "コミュニティと管理へのリンク",
serverAnnouncement: "サーバーのお知らせ",
serverWelcome: "サーバーからのメッセージ",
chatSending: "サーバーの確認を待っています…",
chatSendFailed: "送信を確認できませんでした。下書きは保持されています。タイムアウトしても届いている場合があるため、再送前に確認してください。",
@@ -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");
});
+144 -95
View File
@@ -364,7 +364,7 @@
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
:disabled="voiceState.connecting && isQuickServerTarget(server)"
:aria-disabled="!serverCanSwitch(server)"
:title="serverCanSwitch(server) ? server.label + '\n' + server.address : t('serverSwitchRestricted')"
@click.stop="connectQuickServer(server)"
@@ -416,7 +416,7 @@
:data-ws-server-kind="server.isFavorite ? 'favorite' : 'recent'"
:aria-label="t('switchToServer', { server: server.label })"
:aria-pressed="isQuickServerTarget(server)"
:disabled="voiceState.connecting"
:disabled="voiceState.connecting && isQuickServerTarget(server)"
:aria-disabled="!serverCanSwitch(server)"
:title="serverCanSwitch(server) ? server.label : t('serverSwitchRestricted')"
@click="connectQuickServer(server)"
@@ -689,18 +689,18 @@
:avatar-style="avatarStyle"
:avatar-initial="avatarInitial"
:t="t"
@member-actions="openMemberActions"
@stop-share="stopScreenShare"
/>
<WhisperControls
v-if="whisperTargetIds.size"
:targets="whisperTargets"
:active="whisperActive"
:enabled="!isMobileViewport || mobileSection === 'voice'"
:controls="audioControls"
:t="t"
@clear="clearWhisperTargets"
/>
@member-actions="openMemberActions"
@stop-share="stopScreenShare"
/>
<WhisperControls
v-if="whisperTargetIds.size"
:targets="whisperTargets"
:active="whisperActive"
:enabled="!isMobileViewport || mobileSection === 'voice'"
:controls="audioControls"
:t="t"
@clear="clearWhisperTargets"
/>
<div class="mobile-voice-controls">
<button
type="button"
@@ -924,7 +924,7 @@
v-model="channelPasswordDialog.password"
:busy="channelPasswordDialog.submitting"
:error="channelPasswordDialog.error"
:submit-label="activeSkin?.id === BUILTIN_KAAK_SKIN_ID ? t('passwordDialogConfirm') : undefined"
:submit-label="skinMessageOverrides.passwordDialogConfirm"
:t="t"
@cancel="cancelChannelPassword"
@submit="submitChannelPassword"
@@ -935,7 +935,7 @@
v-if="serverPasswordDialog.open"
v-model="serverPasswordDialog.password"
:error-code="serverPasswordDialog.errorCode"
:submit-label="activeSkin?.id === BUILTIN_KAAK_SKIN_ID ? t('passwordDialogConfirm') : undefined"
:submit-label="skinMessageOverrides.passwordDialogConfirm"
:t="t"
@cancel="cancelFavoriteServerPassword"
@submit="submitServerPassword"
@@ -1023,9 +1023,10 @@ 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 { isQuickServerAddressLabel, type QuickServer } from "../services/quick-servers.js";
import { isQuickServerAddressLabel, quickServerTargetsEqual, type QuickServer } from "../services/quick-servers.js";
import { requestIdentityProviderLogin as dispatchIdentityProviderLogin } from "../services/identity-provider.js";
import type { InstalledSkin, SkinHomeCopy } from "../services/skin-pack.js";
import { BUILTIN_KAAK_SKIN_ID, isPublicSkinEnabled } from "../services/skin-catalog.js";
import { isPublicSkinEnabled } from "../services/skin-catalog.js";
import { BUILTIN_DARK_SKIN, BUILTIN_LIGHT_SKIN } from "../services/skin-runtime.js";
import { applyTheme, getStoredTheme, type ThemeMode } from "../services/theme.js";
import { createScreenWakeLockController, getScreenWakeLockApi, type ScreenWakeLockController, type ScreenWakeLockSnapshot } from "../services/screen-wake-lock.js";
@@ -1142,8 +1143,9 @@ const favoriteSwitchFailed = ref(false);
const favoriteSwitchError = ref("");
const channelPasswordDialog = reactive({ open: false, channelId: "", password: "", error: "", submitting: false });
const serverPasswordDialog = reactive({ open: false, password: "", errorCode: "" });
const qqModalOpen = ref(false);
const qqJoinUrl = "http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475";
const qqModalOpen = ref(false);
const qqJoinUrl = "http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=yhumUMDD9PmyYFWdXWUb_x7hM5trFQY8&authKey=Pw3HBGT7GwMinTQnuFGfnpf0aRSzXOJKcAiujVP1%2BXMpjheAKrncTRivicBJxpjV&noverify=0&group_code=869500475";
const githubRepositoryUrl = "https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak";
const toast = ref("");
const localPersistenceAvailable = isLocalPersistenceAvailable();
const identityReady = ref(!localPersistenceAvailable);
@@ -1452,12 +1454,13 @@ const showVoiceShell = computed(() => Boolean(
voiceState.connected || voiceState.reconnecting || voiceState.reconnectFailed
|| favoriteSwitchPending.value || favoriteSwitchFailed.value,
));
const favoriteSwitchLabel = computed(() => quickServers.value.find((server) =>
server.id === currentServerTarget().toLocaleLowerCase(),
)?.label ?? currentServerTarget());
const favoriteSwitchLabel = computed(() => quickServers.value.find((server) =>
isQuickServerTarget(server),
)?.label ?? currentServerTarget());
function isQuickServerTarget(server: QuickServer): boolean {
return server.id === currentServerTarget().toLocaleLowerCase();
return server.id === currentServerTarget().toLocaleLowerCase()
|| quickServerTargetsEqual(server.address, currentServerTarget());
}
function serverCanSwitch(_server: QuickServer): boolean {
@@ -1479,12 +1482,15 @@ const quickServersForDisplay = computed(() => quickServers.value.map((server) =>
}));
function connectQuickServer(server: QuickServer): void {
if (voiceState.connecting || (voiceState.connected && isQuickServerTarget(server))) return;
if ((voiceState.connecting || voiceState.connected) && isQuickServerTarget(server)) return;
if (accessMode.value !== "open") {
showToast(t("serverSwitchRestricted"));
return;
}
const target = splitTeamSpeakTarget(server.address);
// A slow TeamSpeak handshake can leave the previous attempt pending for a
// long time. Stop its ticket request/socket before starting the new target.
if (voiceState.connecting) doDisconnect(false);
const target = splitTeamSpeakTarget(server.address);
serverHost.value = target.address;
serverPort.value = target.port || DEFAULT_TEAM_SPEAK_PORT;
nickname.value = server.nickname?.trim() || nickname.value.trim();
@@ -1581,6 +1587,17 @@ const skinPluginQuickList = computed(() => skinPluginQuickServers.project(
t("serverSwitchRestricted"),
));
const currentServerDisplayName = computed(() => {
// The skin/plugin projection deliberately hides names that look like an
// address. The host's own server header should still show TeamSpeak's
// configured public server name instead of a synthetic "Recent N" label.
const liveName = cleanServerDisplayName(voiceServerInfo.value?.name);
if (liveName) return liveName;
const savedCurrent = quickServers.value.find(isQuickServerTarget);
const savedName = cleanServerDisplayName(savedCurrent?.serverName);
const savedLabel = savedCurrent?.label.trim() ?? "";
return savedName || (savedCurrent && savedLabel && !isQuickServerAddressLabel(savedLabel, savedCurrent.address) ? savedLabel : "TeamSpeak");
});
const currentServerPluginLabel = computed(() => {
const target = currentServerTarget();
const liveName = safeSkinServerDisplayName(voiceServerInfo.value?.name ?? "", target);
if (liveName) return liveName;
@@ -1588,6 +1605,10 @@ const currentServerDisplayName = computed(() => {
const savedName = savedCurrent ? safeSkinServerDisplayName(savedCurrent.serverName ?? "", savedCurrent.address) : "";
return savedName || skinPluginQuickList.value.find((server) => server.current)?.label || "TeamSpeak";
});
function cleanServerDisplayName(value: string | undefined): string {
return value?.trim().replace(/\u0000/g, "").slice(0, 160) ?? "";
}
const skinPluginFavorites = computed(() => skinPluginQuickList.value
.filter((server) => server.favorite)
.map(({ favorite: _favorite, ...server }) => server));
@@ -1615,7 +1636,7 @@ const skinPluginContext = computed(() => ({
channelId: currentChannel.value?.id ?? "",
channelName: currentChannelName.value,
userName: nickname.value,
serverLabel: currentServerDisplayName.value,
serverLabel: currentServerPluginLabel.value,
},
channels: channelTree.value.map((item) => {
const members = skinPluginMembers.value.filter((member) => member.channelId === item.id);
@@ -1635,10 +1656,15 @@ const skinPluginContext = computed(() => ({
}),
members: skinPluginMembers.value,
},
favorites: { items: skinPluginFavorites.value },
servers: { quickList: skinPluginQuickList.value },
chat: {
messages: chat.visibleMessages.value.filter((message) => message.scope === "channel").map((message) => ({
favorites: { items: skinPluginFavorites.value },
servers: { quickList: skinPluginQuickList.value },
chat: {
status: {
panelOpen: chat.panelOpen.value,
tab: chat.tab.value,
tabLabel: chat.tabLabel.value,
},
messages: chat.visibleMessages.value.filter((message) => message.scope === "channel").map((message) => ({
id: message.id,
author: message.invokerName,
text: message.message,
@@ -1647,10 +1673,12 @@ const skinPluginContext = computed(() => ({
channelId: message.targetId ?? currentChannel.value?.id ?? "",
})),
},
audio: {
status: {
microphoneMuted: microphoneMuted.value,
outputMuted: outputMuted.value,
audio: {
status: {
microphoneMuted: microphoneMuted.value,
outputMuted: outputMuted.value,
noiseSuppressionEnabled: noiseSuppressionEnabled.value,
accompanimentActive: accompanimentActive.value,
},
},
whisper: {
@@ -1707,14 +1735,18 @@ const skinPluginActions = {
if (typeof args.quickServerId !== "string") return;
switchQuickServerByOpaqueId(args.quickServerId);
},
"chat.sendMessage": (args: Record<string, string | number | boolean>) => {
"chat.sendMessage": (args: Record<string, string | number | boolean>) => {
if (!voiceState.connected || typeof args.text !== "string" || !currentChannel.value?.id) return;
const text = args.text.trim();
if (!text || text.length > 1000 || text.includes("\u0000")) return;
void sendTextMessage(text, currentChannel.value.id);
},
"voice.toggleMicrophone": () => { if (voiceState.connected) toggleMicrophone(); },
"voice.toggleOutputMute": () => { if (voiceState.connected) toggleOutputMute(); },
void sendTextMessage(text, currentChannel.value.id);
},
"chat.togglePanel": () => chat.togglePanel(),
"voice.toggleMicrophone": () => { if (voiceState.connected) toggleMicrophone(); },
"voice.toggleOutputMute": () => { if (voiceState.connected) toggleOutputMute(); },
"audio.openSettings": () => { settingsOpen.value = true; },
"audio.toggleNoiseSuppression": () => { if (voiceState.connected) audioControls.toggleNoiseSuppression(); },
"audio.toggleAccompaniment": () => { if (voiceState.connected) void audioControls.toggleAccompaniment(); },
"voice.setOutputVolume": (args: Record<string, string | number | boolean>) => {
if (!voiceState.connected) return;
const volume = typeof args.volume === "number" ? args.volume
@@ -1753,7 +1785,38 @@ const homeConnectionStatus = computed(() => {
});
const skinPluginWidgets = {
"voice.screen-share-start": () => h("button", {
"home.server-announcement": () => h("section", {
"data-ws-part": "home.server-announcement",
"aria-label": t("serverAnnouncement"),
}, [
h("h2", { "data-ws-part": "home.server-announcement.title" }, t("serverAnnouncement")),
h("p", { "data-ws-part": "home.server-announcement.body" }, localizedWelcomeText.value),
]),
"home.social-links": () => h("nav", {
"data-ws-part": "home.social-links",
"aria-label": t("communityLinks"),
}, [
h("a", {
href: githubRepositoryUrl,
target: "_blank",
rel: "noreferrer",
title: t("githubRepository"),
"aria-label": t("githubRepository"),
}, [h(Icon, { name: "github", size: 20 })]),
h("a", {
href: qqJoinUrl,
target: "_blank",
rel: "noreferrer",
title: t("qqGroup"),
"aria-label": t("qqGroup"),
}, [h(Icon, { name: "qq", size: 20 })]),
h("a", {
href: "/admin",
title: t("adminConsole"),
"aria-label": t("adminConsole"),
}, [h(Icon, { name: "settings", size: 20 })]),
]),
"voice.screen-share-start": () => h("button", {
type: "button",
class: "skin-runtime-screen-share-start",
disabled: !voiceState.connected || screenShareActive.value || screenShareStarting.value,
@@ -1797,16 +1860,21 @@ const skinPluginWidgets = {
onExportIdentity: exportIdentity,
}),
"home.connection-status": () => h("p", {
class: "kaak-home-status",
"data-ws-part": "home.connection-status",
role: "status",
"aria-live": "polite",
}, homeConnectionStatus.value),
"home.myts-login": () => h("button", {
type: "button",
class: "kaak-myts-login",
"aria-label": t("mytsLogin"),
onClick: () => showToast(t("featureInDevelopment")),
}, [h("span", { class: "kaak-myts-wordmark", "aria-hidden": "true" }, "myts")]),
"home.identity-provider": (options?: SkinPluginWidgetOptions) => {
const providerId = options?.identityProviderId ?? "external";
const providerLabel = options?.identityProviderLabel ?? providerId;
return h("button", {
type: "button",
class: "ws-home-identity-provider-button",
"data-ws-part": "home.identity-provider.button",
"aria-label": t("identityProviderLogin", { provider: providerLabel }),
onClick: () => requestIdentityProviderLogin(providerId, providerLabel),
}, [h("span", { class: "ws-home-identity-provider-label", "data-ws-part": "home.identity-provider.label", "aria-hidden": "true" }, providerLabel)]);
},
"app.skin-switcher": () => h(SkinSwitcher, {
modelValue: activeSkinId.value,
"onUpdate:modelValue": (value: string) => { activeSkinId.value = value; },
@@ -1900,59 +1968,31 @@ const skinPluginWidgets = {
messageAvatar,
formatTime,
}),
"voice.audio-controls": (options?: SkinPluginWidgetOptions) => isMobileViewport.value
"voice.audio-controls": () => isMobileViewport.value
? h("div", { class: "mobile-voice-controls", role: "toolbar", "aria-label": t("desktopAudioControls") }, [
...(options?.layout === "room-panel" ? [
h("button", {
type: "button",
class: "mobile-voice-activity",
"aria-label": t("voiceSettings"),
title: t("voiceSettings"),
onClick: () => { settingsOpen.value = true; },
}, [h(Icon, { name: "settings", size: 16 }), h("span", null, t("voiceSettings"))]),
h("button", {
type: "button",
class: ["mobile-voice-toggle", "mobile-noise-suppression", noiseSuppressionEnabled.value ? "active" : "inactive"],
"aria-label": t("noiseSuppression"),
title: t("noiseSuppression"),
"aria-pressed": noiseSuppressionEnabled.value,
onClick: audioControls.toggleNoiseSuppression,
}, [h(Icon, { name: "noise-suppression", size: 20 }), h("span", null, t("noiseSuppression"))]),
] : []),
h("button", {
type: "button",
type: "button",
class: ["mobile-voice-toggle", "mobile-microphone-toggle", microphoneMuted.value && "muted"],
"aria-label": t("microphone"),
"aria-pressed": !microphoneMuted.value,
onClick: toggleMicrophone,
}, [h(Icon, { name: microphoneMuted.value ? "mic-off" : "mic", size: 20 }), h("span", null, t("microphone"))]),
h("button", {
type: "button",
"aria-label": t("microphone"),
"aria-pressed": !microphoneMuted.value,
onClick: toggleMicrophone,
}, [h(Icon, { name: microphoneMuted.value ? "mic-off" : "mic", size: 20 }), h("span", null, t("microphone"))]),
h("button", {
type: "button",
class: ["mobile-voice-toggle", "mobile-output-toggle", outputMuted.value && "muted"],
"aria-label": t("speaker"),
"aria-pressed": !outputMuted.value,
onClick: toggleOutputMute,
"aria-label": t("speaker"),
"aria-pressed": !outputMuted.value,
onClick: toggleOutputMute,
}, [h(Icon, { name: outputMuted.value ? "volume-off" : "volume", size: 20 }), h("span", null, t("speaker"))]),
...(options?.layout === "room-panel" ? [
h("button", {
type: "button",
class: ["mobile-voice-toggle", "mobile-accompaniment-toggle", accompanimentActive.value && "active"],
"aria-label": accompanimentActive.value ? t("stopAccompaniment") : t("startAccompaniment"),
title: accompanimentActive.value ? t("stopAccompaniment") : t("startAccompaniment"),
"aria-pressed": accompanimentActive.value,
onClick: audioControls.toggleAccompaniment,
}, [h(Icon, { name: "music", size: 18 })]),
] : []),
])
])
: h(AudioDock, {
model: audioDockState,
controls: audioControls,
layout: options?.layout === "room-panel" ? "room-panel" : "default",
t,
rangeStyle,
onSettings: () => { settingsOpen.value = true; },
onOutputMute: toggleOutputMute,
}),
t,
rangeStyle,
onSettings: () => { settingsOpen.value = true; },
onOutputMute: toggleOutputMute,
}),
"voice.screen-share-player": () => screenShareViewing.value ? h(ScreenSharePlayer, {
model: screenShareControls,
screenShareRemoteStream: screenShareRemoteStream.value,
@@ -1993,7 +2033,16 @@ const skinPluginWidgets = {
"aria-label": t("exit"),
onClick: leaveVoiceWorkspace,
}, [h(Icon, { name: "power", size: 18 }), h("span", null, t("exit"))]),
};
};
async function requestIdentityProviderLogin(providerId: string, providerLabel: string): Promise<void> {
try {
const handled = await dispatchIdentityProviderLogin({ providerId, providerLabel });
if (!handled) showToast(t("identityProviderInDevelopment", { provider: providerLabel }));
} catch {
showToast(t("identityProviderLoginFailed", { provider: providerLabel }));
}
}
watch(() => pokeNotifications.length, (length, previousLength) => {
const latest = pokeNotifications[length - 1];