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]));