feat(kaak): refine interaction feedback and permissions

This commit is contained in:
illusia committed 2026-10-11 01:31:44 +08:00
1 parent bdd0c3473c
commit 83902e0fb5
19 files changed
+236 -54

No files matched your search

+3 -2
View File
@@ -12,6 +12,7 @@ import {
type SkinPluginDocument,
type SkinPluginHostWidget,
type SkinPluginNode,
type SkinPluginWidgetOptions,
type SkinPluginPermission,
} from "../../../src/shared/skin-plugin.js";
import { parseSkinExtensionUiOutput } from "../../../src/shared/skin-extension-ui.js";
@@ -22,7 +23,7 @@ import { createSkinPluginAssetUrlCache } from "../services/skin-plugin-asset-url
type Scalar = string | number | boolean;
type SafeContext = Record<string, unknown>;
type HostAction = (args: Record<string, Scalar>, component: SkinPluginComponent) => void | Promise<void>;
type HostWidget = () => VNodeChild;
type HostWidget = (options?: SkinPluginWidgetOptions) => VNodeChild;
const eventProps: Record<string, string> = {
click: "onClick", dblclick: "onDblclick", change: "onChange", input: "onInput", submit: "onSubmit", keydown: "onKeydown", keyup: "onKeyup",
@@ -265,7 +266,7 @@ export default defineComponent({
"data-ws-plugin-part": node.part ? `${component.id}.${node.part}` : component.id,
"data-ws-part": layoutPart(component, node, nodePath),
"aria-label": component.accessibleName,
}, [widget()]);
}, [widget(node.options)]);
}
if (!node.tag) {
const text = interpolate(node.text ?? "", context, state);
+2 -2
View File
@@ -3,7 +3,7 @@ import type { SkinExtensionSessionStatus } from "../../../src/shared/skin-extens
import { computeSkinRuntimePluginDigest, createSkinRuntimePluginApproval, isSkinRuntimePluginApproved, type SkinRuntimePluginApproval } from "../../../src/shared/skin-runtime-plugin-approval.js";
import type { SkinRuntimePlugin, SkinRuntimePluginDocument, SkinRuntimePluginPage } from "../../../src/shared/skin-runtime-plugins.js";
import { parseSkinExtensionUiInput, type SkinExtensionUiInput } from "../../../src/shared/skin-extension-ui-input.js";
import { SKIN_PLUGIN_ACTION_PERMISSIONS, SKIN_PLUGIN_PERMISSIONS, skinPluginActionPermission, type SkinPluginAction, type SkinPluginDocument, type SkinPluginHostWidget } from "../../../src/shared/skin-plugin.js";
import { SKIN_PLUGIN_ACTION_PERMISSIONS, SKIN_PLUGIN_PERMISSIONS, skinPluginActionPermission, type SkinPluginAction, type SkinPluginDocument, type SkinPluginHostWidget, type SkinPluginWidgetOptions } from "../../../src/shared/skin-plugin.js";
import { SKIN_RUNTIME_PLUGIN_DATA_PERMISSIONS } from "../../../src/shared/skin-runtime-plugin-context.js";
import SkinPluginOutlet from "./SkinPluginOutlet.js";
import { approveSkinRuntimePlugin, getSkinRuntimePluginApproval, revokeSkinRuntimePluginApprovals } from "../services/skin-runtime-plugin-approval.js";
@@ -102,7 +102,7 @@ export default defineComponent({
mountRevision: { type: String, default: "" },
context: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },
actions: { type: Object as PropType<Partial<Record<SkinPluginAction, HostActionHandler>>>, default: () => ({}) },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, () => VNodeChild>>>, default: () => ({}) },
widgets: { type: Object as PropType<Partial<Record<SkinPluginHostWidget, (options?: SkinPluginWidgetOptions) => VNodeChild>>>, default: () => ({}) },
readSessionStatus: { type: Function as PropType<(signal: AbortSignal) => SkinExtensionSessionStatus | Promise<SkinExtensionSessionStatus>>, required: true },
},
emits: {
@@ -51,7 +51,7 @@
><Icon name="mic-off" :size="14" /></span
>
<span
v-if="screenShareStreamForMember(member)"
v-if="shareEnabled && screenShareStreamForMember(member)"
class="screen-share-live-indicator"
data-ws-part="voice.member.live-indicator"
><span
@@ -65,7 +65,7 @@
><span>{{ t("sharingScreen") }}</span></span
>
<button
v-if="member.isSelf && (screenShareActive || screenShareStarting)"
v-if="shareEnabled && member.isSelf && (screenShareActive || screenShareStarting)"
type="button"
class="screen-share-stop-button"
data-ws-part="voice.member.stop-share"
@@ -84,7 +84,7 @@
isSpeaking(member) ? t("speaking") : member.isSelf ? t("connectedYou") : t("connected")
}}</span>
<div
v-if="member.isSelf || screenShareStreamForMember(member)"
v-if="shareEnabled && (member.isSelf || screenShareStreamForMember(member))"
class="screen-share-card-actions"
data-ws-part="voice.member.share-actions"
>
@@ -106,7 +106,7 @@
:aria-label="t('screenShareSettings')"
:aria-expanded="screenShareSettingsOpen"
:title="t('screenShareSettings')"
@click.stop="screenShareSettingsOpen = !screenShareSettingsOpen"
@click.stop="toggleScreenShareSettings"
><Icon
name="settings"
:size="13"
@@ -156,18 +156,30 @@
<script setup lang="ts">
import Icon from "../Icon.vue";
import { computed } from "vue";
import type { ChannelMember, useVoiceWebSocket } from "../../composables/useVoiceWebSocket.js";
import type { useWebClientScreenShare } from "../../composables/useWebClientScreenShare.js";
const props = defineProps<{
currentMembers: ChannelMember[]; isMobileViewport: boolean;
sharing: Pick<ReturnType<typeof useVoiceWebSocket>, "screenShareActive" | "screenShareStarting" | "screenShareViewingStreamId"> & Pick<ReturnType<typeof useWebClientScreenShare>, "settingsOpen">;
controls: Pick<ReturnType<typeof useWebClientScreenShare>, "streamForMember" | "toggleForMember" | "startWithSettings">;
showScreenShare?: boolean;
sharing?: Pick<ReturnType<typeof useVoiceWebSocket>, "screenShareActive" | "screenShareStarting" | "screenShareViewingStreamId"> & Pick<ReturnType<typeof useWebClientScreenShare>, "settingsOpen">;
controls?: Pick<ReturnType<typeof useWebClientScreenShare>, "streamForMember" | "toggleForMember" | "startWithSettings">;
isSpeaking: (member: ChannelMember) => boolean;
avatarStyle: (name: string, isSelf?: boolean, avatar?: string) => Record<string, string>;
avatarInitial: (name: string) => string; t: (key: string) => string;
}>();
const { screenShareActive, screenShareStarting, screenShareViewingStreamId, settingsOpen: screenShareSettingsOpen } = props.sharing;
const { streamForMember: screenShareStreamForMember, toggleForMember: toggleScreenShareForMember, startWithSettings: startScreenShareWithSettings } = props.controls;
const shareEnabled = computed(() => props.showScreenShare !== false && Boolean(props.sharing && props.controls));
const screenShareActive = computed(() => shareEnabled.value && Boolean(props.sharing?.screenShareActive.value));
const screenShareStarting = computed(() => shareEnabled.value && Boolean(props.sharing?.screenShareStarting.value));
const screenShareViewingStreamId = computed(() => shareEnabled.value ? props.sharing?.screenShareViewingStreamId.value ?? null : null);
const screenShareSettingsOpen = computed(() => shareEnabled.value && Boolean(props.sharing?.settingsOpen.value));
const screenShareStreamForMember = (member: ChannelMember) => shareEnabled.value ? props.controls?.streamForMember(member) ?? null : null;
const toggleScreenShareForMember = (member: ChannelMember) => { if (shareEnabled.value) props.controls?.toggleForMember(member); };
const startScreenShareWithSettings = () => { if (shareEnabled.value) void props.controls?.startWithSettings(); };
function toggleScreenShareSettings() {
if (!shareEnabled.value || !props.sharing) return;
props.sharing.settingsOpen.value = !props.sharing.settingsOpen.value;
}
const emit = defineEmits<{ memberActions: [member: ChannelMember]; stopShare: [] }>();
const screenShareIndicatorBars = [5, 10, 7, 12, 8, 10];
</script>
@@ -145,7 +145,7 @@
}}</p
>
<section
v-if="screenShareWebRtcStats.peers.length"
v-if="showScreenShare && screenShareWebRtcStats.peers.length"
class="webrtc-stats"
data-ws-part="voice.performance.webrtc-stats"
aria-live="polite"
@@ -218,7 +218,8 @@ import { computed } from "vue";
import Icon from "../Icon.vue";
import type { useWebClientPerformance } from "../../composables/useWebClientPerformance.js";
import type { ScreenShareWebRtcStats } from "../../composables/useVoiceWebSocket.js";
const props = defineProps<{ model: ReturnType<typeof useWebClientPerformance>; screenShareWebRtcStats: ScreenShareWebRtcStats; t: (key: string) => string }>();
const props = defineProps<{ model: ReturnType<typeof useWebClientPerformance>; screenShareWebRtcStats: ScreenShareWebRtcStats; showScreenShare?: boolean; t: (key: string) => string }>();
const showScreenShare = props.showScreenShare !== false;
const { panelOpen: performancePanelOpen, running: performanceRunning, stats: performanceStats, togglePanel: togglePerformancePanel, refresh: refreshPerformanceProbe } = props.model;
const t = props.t;
const voiceHealthLabel = computed(() => t(({ disconnected: "voiceHealthDisconnected", sampling: "voiceHealthSampling", connecting: "voiceHealthConnecting", warning: "voiceHealthWarning", active: "voiceHealthActive", quiet: "voiceHealthQuiet" } as const)[performanceStats.value.health]));
+1 -1
View File
@@ -46,7 +46,7 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
{
id: BUILTIN_KAAK_SKIN_ID,
name: "KAAK",
version: "3.1.27",
version: "3.1.28",
author: "WebSpeak Project",
license: "AGPL-3.0-only",
description: "A KOOK-inspired voice-room workspace with collapsible voice groups and current voice-channel chat, TeamSpeak profile cards, and host-owned voice controls.",
+5 -3
View File
@@ -464,7 +464,7 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
const file = new File([archive], "kaak-voice.wskin", { type: "application/octet-stream" });
const skin = await importSkinPack(file);
assert.equal(skin.id, "community.kaak-voice");
assert.equal(skin.version, "3.1.27");
assert.equal(skin.version, "3.1.28");
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");
@@ -483,8 +483,8 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.ok(voice?.permissions.includes("chat.channel.send"));
assert.ok(voice?.permissions.includes("audio.microphone.control"));
assert.ok(voice?.permissions.includes("audio.output.control"));
assert.ok(voice?.permissions.includes("voice.screenShare.read"));
assert.ok(voice?.permissions.includes("voice.screenShare.control"));
assert.equal(voice?.permissions.includes("voice.screenShare.read"), false);
assert.equal(voice?.permissions.includes("voice.screenShare.control"), false);
function findPart(node: SkinPluginNode | undefined, part: string): SkinPluginNode | undefined {
if (!node) return undefined;
if (node.part === part) return node;
@@ -527,9 +527,11 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
assert.equal(findPart(voice?.root, "channel-member-avatar")?.children?.[0]?.text, "{{voicemember.avatarInitial}}");
assert.equal(findPart(voice?.root, "voice-stage")?.attributes?.["aria-label"], "语音房间 / Voice room");
assert.equal(findPart(voice?.root, "member-cards")?.widget, "voice.member-cards");
assert.deepEqual(findPart(voice?.root, "member-cards")?.options, { screenShare: false });
assert.equal(findPart(voice?.root, "member-list"), undefined);
assert.equal(findPart(voice?.root, "screen-player"), undefined);
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, "#");
+11 -6
View File
@@ -1020,7 +1020,7 @@ import { createScreenWakeLockController, getScreenWakeLockApi, type ScreenWakeLo
import { createMobileAwayController, type MobileAwayController } from "../services/mobile-away.js";
import { createSkinPluginQuickServerProjection } from "../services/skin-plugin-context.js";
import { loadSkinPluginAuthoringDocument } from "../services/skin-plugin-authoring.js";
import type { SkinPluginDocument } from "../../../src/shared/skin-plugin.js";
import type { SkinPluginDocument, SkinPluginWidgetOptions } from "../../../src/shared/skin-plugin.js";
import { combineTeamSpeakTarget, DEFAULT_TEAM_SPEAK_PORT, isValidTeamSpeakPort, splitTeamSpeakTarget } from "../services/teamspeak-target.js";
const {
@@ -1740,11 +1740,12 @@ const skinPluginWidgets = {
onSelectChannel: selectChannel,
onVolumeInput: onVolInput,
}),
"voice.member-cards": () => h(VoiceMemberCards, {
"voice.member-cards": (options?: SkinPluginWidgetOptions) => h(VoiceMemberCards, {
currentMembers: currentMembers.value,
isMobileViewport: isMobileViewport.value,
sharing: memberSharingState,
controls: screenShareControls,
showScreenShare: options?.screenShare !== false,
sharing: options?.screenShare === false ? undefined : memberSharingState,
controls: options?.screenShare === false ? undefined : screenShareControls,
isSpeaking,
avatarStyle,
avatarInitial,
@@ -1805,9 +1806,10 @@ const skinPluginWidgets = {
t,
onClear: clearWhisperTargets,
}) : null,
"voice.performance-panel": () => h(VoicePerformancePanel, {
"voice.performance-panel": (options?: SkinPluginWidgetOptions) => h(VoicePerformancePanel, {
model: performance,
screenShareWebRtcStats,
showScreenShare: options?.screenShare !== false,
t,
}),
"voice.connection-controls": () => h("div", { class: "ws-plugin-connection-controls", role: "toolbar", "aria-label": t("desktopAudioControls") }, [
@@ -2009,7 +2011,10 @@ function formatTime(timestamp: number) {
function rangeStyle(value: number, max: number) {
const percent = Math.max(0, Math.min(100, (value / max) * 100));
return { background: `linear-gradient(to right, #006a64 0%, #006a64 ${percent}%, #e7eceb ${percent}%, #e7eceb 100%)` };
return {
"--ws-range-progress": `${percent}%`,
background: `linear-gradient(to right, #006a64 0%, #006a64 ${percent}%, #e7eceb ${percent}%, #e7eceb 100%)`,
};
}
function onVolInput(clientId: number, event: Event) {