mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
Dock plugin launchers in skins and expose example app settings
This commit is contained in:
1 parent
274bd81dc3
commit
15ca32b7a8
30 files changed
+354
-66
No files matched your search
@@ -1,10 +1,24 @@
|
||||
<template>
|
||||
<Teleport v-if="toolbarTarget" :to="toolbarTarget">
|
||||
<div v-if="thirdPartyAllowed && connected && sessionToken" class="ws-plugin-toolbar">
|
||||
<button v-if="!isHostPartHidden('host.plugins.launcher')" ref="launcher" class="header-action ws-plugin-toolbar-trigger" data-ws-part="host.plugins.launcher" type="button" :title="tr('title')" :aria-label="tr('title')" :aria-expanded="visible" @click="toggle">
|
||||
<Teleport :to="toolbarTarget ?? 'body'">
|
||||
<div v-if="thirdPartyAllowed && connected && sessionToken" ref="toolbar" class="ws-plugin-toolbar" :class="{ 'ws-plugin-toolbar-fallback': !toolbarTarget }" data-ws-part="voice.plugin-launcher" :data-presentation="presentation" :data-theme="theme" @keydown.esc="dismissDrawer">
|
||||
<button v-if="!isHostPartHidden('host.plugins.launcher')" ref="launcher" class="header-action ws-plugin-toolbar-trigger" data-ws-part="host.plugins.launcher" type="button" :title="tr('title')" :aria-label="tr('title')" :aria-expanded="presentation === 'dialog' ? visible : drawerOpen" :aria-controls="drawerOpen ? drawerId : undefined" @click="toggle">
|
||||
<svg viewBox="0 0 24 24" data-ws-icon-slot="host.plugins.launcher" aria-hidden="true"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z" /></svg>
|
||||
<span v-if="presentation === 'drawer-side'">{{ tr('title') }}</span>
|
||||
</button>
|
||||
<button v-for="entry in pinnedApps" :key="entry.manifest.id" class="header-action ws-plugin-toolbar-shortcut" type="button" :title="entry.manifest.name" :aria-label="entry.manifest.name" :disabled="busy || entry.runtime.state === 'failed'" @click="launch(entry.manifest.id)">{{ entry.manifest.name.slice(0, 1).toUpperCase() }}</button>
|
||||
<section v-if="drawerOpen" :id="drawerId" ref="drawer" class="ws-plugin-drawer" data-ws-part="voice.plugin-drawer" :aria-label="tr('title')">
|
||||
<input ref="drawerSearch" v-model="search" class="ws-plugin-drawer-search" type="search" :placeholder="ui.search" :aria-label="ui.search" />
|
||||
<p v-if="error" role="alert">{{ error }}</p>
|
||||
<p v-else-if="busy && !available.length" role="status">{{ tr('loading') }}</p>
|
||||
<p v-else-if="!filtered.length">{{ available.length ? ui.noResults : tr('empty') }}</p>
|
||||
<ul v-if="filtered.length">
|
||||
<li v-for="entry in filtered" :key="entry.manifest.id">
|
||||
<button type="button" class="ws-plugin-drawer-app" data-ws-part="voice.plugin-drawer.app" :disabled="busy || entry.runtime.state === 'failed'" :title="entry.runtime.error || entry.manifest.name" @click="launch(entry.manifest.id)">
|
||||
<span class="ws-plugin-drawer-mark" aria-hidden="true">{{ entry.manifest.name.slice(0, 1).toUpperCase() }}</span>
|
||||
<span>{{ entry.manifest.name }}</span><span v-if="entry.toolbarPinned" aria-hidden="true">★</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
<Teleport to="body">
|
||||
@@ -19,13 +33,13 @@
|
||||
<button class="ws-plugin-close" type="button" :title="tr('close')" :aria-label="tr('close')" @click="close"><svg viewBox="0 0 24 24"><path d="m6 6 12 12M18 6 6 18" /></svg></button>
|
||||
</div>
|
||||
</header>
|
||||
<nav class="ws-plugin-navigation" :aria-label="tr('title')">
|
||||
<nav v-if="dialogLibrary" class="ws-plugin-navigation" :aria-label="tr('title')">
|
||||
<button type="button" :class="{ active: !appView }" @click="appView = false">{{ ui.workspace }}</button>
|
||||
<button v-if="current" type="button" :class="{ active: appView }" @click="appView = true">{{ current.manifest.name }}</button>
|
||||
<span v-if="current && appView" class="ws-plugin-version">v{{ current.manifest.version }}</span>
|
||||
</nav>
|
||||
<p v-if="error" role="alert" class="ws-plugin-error">{{ error }}</p>
|
||||
<div v-show="!appView" class="ws-plugin-library">
|
||||
<div v-if="dialogLibrary" v-show="!appView" class="ws-plugin-library">
|
||||
<div class="ws-plugin-library-heading"><div><h2>{{ tr('title') }}</h2><span>{{ available.length }} {{ ui.count }}</span></div><button type="button" :disabled="busy" @click="refresh">{{ busy ? tr('loading') : tr('refresh') }}</button></div>
|
||||
<input v-model="search" class="ws-plugin-search" type="search" :placeholder="ui.search" :aria-label="ui.search" />
|
||||
<p v-if="!busy && !filtered.length" class="ws-plugin-empty">{{ available.length ? ui.noResults : tr('empty') }}</p>
|
||||
@@ -47,24 +61,32 @@
|
||||
</Teleport>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, useId, watch } from 'vue';
|
||||
import { createPluginAppClient, type AvailablePluginApp, type PluginAppClient } from '../services/plugin-app-client.js';
|
||||
import { type PluginAppLaunch, pluginRecord } from '../../../src/shared/plugins.js';
|
||||
import { pluginTranslations, type PluginTextKey } from '../i18n/plugins.js';
|
||||
import { pluginWindowTranslations } from '../i18n/plugin-window.js';
|
||||
import type { SiteLanguage } from '../../../src/site-copy.js';
|
||||
import { thirdPartyAllowed } from '../services/instance-authorization.js';
|
||||
import { isHostPartHidden, pluginLibraryRequests } from '../services/host-chrome.js';
|
||||
const props = defineProps<{ sessionToken: string; gatewayUrl: string; connected: boolean; language: SiteLanguage; toolbarTarget: HTMLElement | null }>();
|
||||
import { isHostPartHidden, isHostPartVisuallyReachable, pluginLibraryRequests } from '../services/host-chrome.js';
|
||||
import type { SkinPluginWidgetOptions } from '../../../src/shared/skin-plugin.js';
|
||||
const props = defineProps<{ sessionToken: string; gatewayUrl: string; connected: boolean; language: SiteLanguage; toolbarTarget: HTMLElement | null; presentation: NonNullable<SkinPluginWidgetOptions['pluginPresentation']> }>();
|
||||
const tr = (key: PluginTextKey) => pluginTranslations[props.language][key];
|
||||
const ui = computed(() => pluginWindowTranslations[props.language]);
|
||||
const windowElement = ref<HTMLElement | null>(null), launcher = ref<HTMLButtonElement | null>(null), frame = ref<HTMLIFrameElement | null>(null);
|
||||
const available = shallowRef<AvailablePluginApp[]>([]), current = shallowRef<PluginAppLaunch | null>(null);
|
||||
const pinnedApps = computed(() => available.value.filter(entry => entry.toolbarPinned));
|
||||
const toolbar = ref<HTMLElement | null>(null);
|
||||
const drawerOpen = ref(false);
|
||||
const drawer = ref<HTMLElement | null>(null);
|
||||
const drawerSearch = ref<HTMLInputElement | null>(null);
|
||||
const drawerId = useId();
|
||||
const dialogLibrary = ref(false);
|
||||
const busy = ref(false), error = ref(''), theme = ref<'light' | 'dark'>('light');
|
||||
const visible = ref(false), maximized = ref(false), appView = ref(false), dragging = ref(false), search = ref('');
|
||||
const position = ref<Record<string, string>>({});
|
||||
const filtered = computed(() => available.value.filter(entry => `${entry.manifest.name} ${entry.manifest.description}`.toLocaleLowerCase().includes(search.value.trim().toLocaleLowerCase())));
|
||||
const filtered = computed(() => available.value
|
||||
.filter(entry => `${entry.manifest.name} ${entry.manifest.description}`.toLocaleLowerCase().includes(search.value.trim().toLocaleLowerCase()))
|
||||
.sort((a, b) => Number(b.toolbarPinned) - Number(a.toolbarPinned)));
|
||||
let epoch = 0, pending: AbortController | undefined, opening: { client: PluginAppClient; key: string } | undefined, observer: MutationObserver | undefined;
|
||||
let drag: { id: number; x: number; y: number; left: number; top: number; handle: HTMLElement; moved: boolean } | undefined;
|
||||
let resizeObserver: ResizeObserver | undefined;
|
||||
@@ -89,31 +111,75 @@ async function refresh() {
|
||||
finally { if (owner === epoch) { busy.value = false; pending = undefined; } }
|
||||
}
|
||||
function toggle() {
|
||||
if (visible.value) { minimize(); return; }
|
||||
detectTheme(); visible.value = true;
|
||||
if (!current.value) { appView.value = false; void refresh(); }
|
||||
if (props.presentation === 'dialog') {
|
||||
if (visible.value && dialogLibrary.value) { minimize(); return; }
|
||||
openLibraryDialog();
|
||||
return;
|
||||
}
|
||||
if (drawerOpen.value) { drawerOpen.value = false; return; }
|
||||
openDrawer();
|
||||
}
|
||||
function openDrawer() {
|
||||
drawerOpen.value = true;
|
||||
detectTheme();
|
||||
visible.value = false;
|
||||
search.value = '';
|
||||
if (!busy.value) void refresh();
|
||||
void nextTick(() => { fitDrawer(); drawerSearch.value?.focus({ preventScroll: true }); });
|
||||
}
|
||||
function openLibraryDialog() {
|
||||
drawerOpen.value = false;
|
||||
detectTheme();
|
||||
dialogLibrary.value = true;
|
||||
visible.value = true;
|
||||
appView.value = false;
|
||||
if (!busy.value) void refresh();
|
||||
void nextTick(() => { fitWindow(); windowElement.value?.focus(); });
|
||||
}
|
||||
function dismissDrawer(event: KeyboardEvent) {
|
||||
if (!drawerOpen.value) return;
|
||||
event.stopPropagation();
|
||||
drawerOpen.value = false;
|
||||
launcher.value?.focus();
|
||||
}
|
||||
function closeDrawerOutside(event: PointerEvent) {
|
||||
if (drawerOpen.value && toolbar.value && !event.composedPath().includes(toolbar.value)) drawerOpen.value = false;
|
||||
}
|
||||
function fitDrawer() {
|
||||
const element = drawer.value;
|
||||
if (!element || props.presentation !== 'drawer-below') return;
|
||||
element.style.translate = '';
|
||||
const box = element.getBoundingClientRect();
|
||||
const delta = Math.max(8 - box.left, Math.min(0, document.documentElement.clientWidth - 8 - box.right));
|
||||
if (delta) element.style.translate = `${delta}px 0`;
|
||||
}
|
||||
function minimize() { endDrag(); visible.value = false; launcher.value?.focus(); }
|
||||
function close() { stop(); error.value = ''; available.value = []; search.value = ''; minimize(); }
|
||||
function close() { drawerOpen.value = false; stop(); error.value = ''; available.value = []; search.value = ''; minimize(); }
|
||||
function stop() {
|
||||
++epoch; pending?.abort(); pending = undefined; const old = opening; opening = undefined; current.value = null; appView.value = false; busy.value = false;
|
||||
if (old) void old.client.cancelOpen(old.key).catch(() => undefined);
|
||||
}
|
||||
async function launch(id: string) {
|
||||
if (!thirdPartyAllowed.value) return;
|
||||
if (!thirdPartyAllowed.value || !props.connected || !props.sessionToken || busy.value) return;
|
||||
if (drawerOpen.value) dialogLibrary.value = false;
|
||||
drawerOpen.value = false;
|
||||
detectTheme(); visible.value = true;
|
||||
if (current.value?.manifest.id === id) { appView.value = true; return; }
|
||||
if (current.value?.manifest.id === id) { appView.value = true; focusAppWindow(); return; }
|
||||
stop(); const owner = ++epoch, controller = new AbortController(), service = client(), key = crypto.randomUUID(); pending = controller; opening = { client: service, key }; busy.value = true; error.value = '';
|
||||
try {
|
||||
const app = await service.open(id, { openId: key, theme: theme.value, language: props.language }, controller.signal);
|
||||
if (owner !== epoch) return;
|
||||
if (new URL(app.url).origin === location.origin) throw new Error('PLUGIN_SEPARATE_ORIGIN_REQUIRED');
|
||||
current.value = app; appView.value = true;
|
||||
focusAppWindow();
|
||||
} catch (e) {
|
||||
if (owner === epoch) { const old = opening; opening = undefined; if (old) void old.client.cancelOpen(old.key).catch(() => undefined); if (!controller.signal.aborted) error.value = `${tr('error')}: ${e instanceof Error ? e.message : ''}`; }
|
||||
} finally { if (owner === epoch) { busy.value = false; pending = undefined; } }
|
||||
}
|
||||
function focusAppWindow() {
|
||||
void nextTick(() => { fitWindow(); windowElement.value?.focus(); });
|
||||
}
|
||||
watch([() => props.toolbarTarget, () => props.presentation], () => { drawerOpen.value = false; });
|
||||
function message(event: MessageEvent) {
|
||||
if (!current.value || event.source !== frame.value?.contentWindow || event.origin !== new URL(current.value.url).origin || !pluginRecord(event.data)) return;
|
||||
if (event.data.type === 'webspeak-app-closed' && event.data.id === current.value.id) { stop(); error.value = tr('context'); }
|
||||
@@ -158,17 +224,20 @@ watch(() => props.language, appearance); watch(theme, appearance);
|
||||
// library reachable when a skin hides the toolbar launcher.
|
||||
watch(pluginLibraryRequests, () => {
|
||||
if (!thirdPartyAllowed.value || !props.connected || !props.sessionToken) return;
|
||||
detectTheme();
|
||||
visible.value = true;
|
||||
appView.value = false;
|
||||
if (!current.value) void refresh();
|
||||
void nextTick(() => { fitWindow(); windowElement.value?.focus(); });
|
||||
if (props.presentation !== 'dialog' && isHostPartVisuallyReachable('host.plugins.launcher')) openDrawer();
|
||||
else openLibraryDialog();
|
||||
});
|
||||
onMounted(() => {
|
||||
document.addEventListener('pointerdown', closeDrawerOutside, true);
|
||||
window.addEventListener('resize', fitDrawer);
|
||||
detectTheme(); window.addEventListener('message', message); window.addEventListener('resize', fitWindow); window.addEventListener('pointermove', moveDrag); window.addEventListener('pointerup', endDrag); window.addEventListener('pointercancel', endDrag); window.addEventListener('blur', endDrag);
|
||||
if (props.connected && thirdPartyAllowed.value) void refresh();
|
||||
observer = new MutationObserver(detectTheme); observer.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: ['data-ws-skin', 'data-ws-host-skin', 'data-theme'] });
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('pointerdown', closeDrawerOutside, true);
|
||||
window.removeEventListener('resize', fitDrawer);
|
||||
});
|
||||
onBeforeUnmount(() => { stop(); endDrag(); observer?.disconnect(); resizeObserver?.disconnect(); window.removeEventListener('message', message); window.removeEventListener('resize', fitWindow); window.removeEventListener('pointermove', moveDrag); window.removeEventListener('pointerup', endDrag); window.removeEventListener('pointercancel', endDrag); window.removeEventListener('blur', endDrag); });
|
||||
</script>
|
||||
<style src="../styles/plugin-overlay.css"></style>
|
||||
@@ -72,21 +72,50 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="plugin-config-group" role="group" :aria-label="tr('config')">
|
||||
<div v-if="plugin.manifest.id === fileTransferId" class="plugin-config-group">
|
||||
<label>{{ tr('maxFileSize') }}
|
||||
<input v-model="model.drafts[plugin.manifest.id].publicFields.maxFileMiB" type="number" min="1" max="2048" placeholder="256" />
|
||||
</label>
|
||||
<p>{{ tr('fileTransferIceHelp') }}</p>
|
||||
</div>
|
||||
<div v-else-if="plugin.manifest.id === watchTogetherId" class="plugin-config-group">
|
||||
<label>{{ tr('playbackControl') }}
|
||||
<select v-model="model.drafts[plugin.manifest.id].publicFields.control">
|
||||
<option value="">{{ tr('configDefault') }} · {{ tr('controlEveryone') }}</option>
|
||||
<option value="everyone">{{ tr('controlEveryone') }}</option>
|
||||
<option value="host">{{ tr('controlHost') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<p>{{ tr('watchTogetherConfigHelp') }}</p>
|
||||
</div>
|
||||
<div v-else class="plugin-config-group" role="group" :aria-label="tr('config')">
|
||||
<p>{{ tr('config') }}</p>
|
||||
<PluginConfigValue :labels="valueLabels" :model-value="model.configValue(plugin.manifest.id, 'config')" @update:model-value="model.setConfigValue(plugin.manifest.id, 'config', $event)" />
|
||||
</div>
|
||||
<template v-if="plugin.manifest.server">
|
||||
<p class="plugin-config-help">
|
||||
<template v-if="plugin.manifest.server && plugin.manifest.id !== watchTogetherId">
|
||||
<p v-if="plugin.manifest.id !== fileTransferId" class="plugin-config-help">
|
||||
{{ tr('privateConfigHelp') }}
|
||||
</p>
|
||||
<label>{{ tr('privateConfig') }}
|
||||
<small>{{ tr(plugin.settings.hasServerConfig?'secretSaved':'secretEmpty') }}</small>
|
||||
<small v-if="plugin.manifest.id === fileTransferId">{{ tr('replaceIceHelp') }}</small>
|
||||
<select v-model="model.drafts[plugin.manifest.id].serverConfigAction">
|
||||
<option value="keep">{{ tr('keep') }}</option><option value="replace">{{ tr('replace') }}</option><option value="remove">{{ tr('erase') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<div v-if="model.drafts[plugin.manifest.id].serverConfigAction==='replace'" class="plugin-config-group" role="group" :aria-label="tr('privateConfig')">
|
||||
<div v-if="model.drafts[plugin.manifest.id].serverConfigAction==='replace' && plugin.manifest.id === fileTransferId" class="plugin-config-group">
|
||||
<label class="plugin-trust"><input v-model="model.drafts[plugin.manifest.id].defaultIce" type="checkbox" />{{ tr('defaultIce') }}</label>
|
||||
<template v-if="!model.drafts[plugin.manifest.id].defaultIce">
|
||||
<div v-for="(server, index) in model.drafts[plugin.manifest.id].iceServers" :key="index" class="plugin-config-grid">
|
||||
<label>{{ tr('iceUrls') }}<input v-model="server.urls" type="text" placeholder="turn:turn.example.com:3478" /></label>
|
||||
<label>{{ tr('iceUsername') }}<input v-model="server.username" type="text" autocomplete="off" /></label>
|
||||
<label>{{ tr('iceCredential') }}<input v-model="server.credential" type="password" autocomplete="new-password" /></label>
|
||||
<button type="button" class="plugin-button" @click="model.drafts[plugin.manifest.id].iceServers.splice(index, 1)">{{ tr('remove') }}</button>
|
||||
</div>
|
||||
<button type="button" class="plugin-button" @click="model.drafts[plugin.manifest.id].iceServers.push({urls:'',username:'',credential:''})">{{ tr('addIce') }}</button>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="model.drafts[plugin.manifest.id].serverConfigAction==='replace'" class="plugin-config-group" role="group" :aria-label="tr('privateConfig')">
|
||||
<PluginConfigValue secret :labels="valueLabels" :model-value="model.configValue(plugin.manifest.id, 'serverConfig')" @update:model-value="model.setConfigValue(plugin.manifest.id, 'serverConfig', $event)" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -106,7 +135,7 @@ import Icon from '../Icon.vue';
|
||||
import PluginConfigValue from './PluginConfigValue.vue';
|
||||
import type { SiteLanguage } from '../../../../src/site-copy.js';
|
||||
import { PLUGIN_STORE_REPOSITORY, type InstalledPlugin, type PluginStoreEntry, type PluginManifest } from '../../../../src/shared/plugins.js';
|
||||
import { musicBotId, musicBotPrivateFields, musicBotPublicFields, musicBotRepository, type useAdminPlugins } from '../../composables/useAdminPlugins.js';
|
||||
import { fileTransferId, watchTogetherId, musicBotId, musicBotPrivateFields, musicBotPublicFields, musicBotRepository, type useAdminPlugins } from '../../composables/useAdminPlugins.js';
|
||||
import { pluginTranslations, type PluginTextKey } from '../../i18n/plugins.js';
|
||||
import { pluginStoreTranslations, type PluginStoreTextKey } from '../../i18n/plugin-store.js';
|
||||
const props=defineProps<{model:ReturnType<typeof useAdminPlugins>;language:SiteLanguage}>();
|
||||
@@ -114,6 +143,8 @@ const tr=(key:PluginTextKey)=>pluginTranslations[props.language][key],text=(key:
|
||||
const valueLabels=computed(()=>({type:tr('valueType'),key:tr('fieldKey'),value:tr('fieldValue'),add:tr('addField'),remove:tr('remove')}));
|
||||
function describeError(code:string) {
|
||||
if(code==='TSMB_API_KEY_REQUIRED')return tr('musicBotConfigHelp');
|
||||
if(code==='PLUGIN_FILE_LIMIT_INVALID')return tr('maxFileSize');
|
||||
if(code==='PLUGIN_ICE_URL_INVALID')return tr('iceInvalid');
|
||||
if(code==='PLUGIN_CHECKSUM')return tr('storeChecksum');
|
||||
if(code==='PLUGIN_PACKAGE_MISMATCH')return tr('storeMismatch');
|
||||
return `${tr('error')} (${code})`;
|
||||
@@ -139,7 +170,7 @@ function onToggle(event:Event,id:string){if((event.target as HTMLDetailsElement)
|
||||
.plugin-setup-link,.plugin-installed-meta a{color:var(--admin-accent);display:inline-flex;align-items:center;gap:5px}
|
||||
.plugin-setup-link{margin-bottom:12px;font-size:12px}
|
||||
.plugin-config-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr));column-gap:16px}
|
||||
.plugin-config-grid input{box-sizing:border-box;width:100%;min-width:0;padding:10px 12px;border:1px solid var(--admin-border);border-radius:8px;background:var(--admin-field);color:var(--admin-text);font-size:12px}
|
||||
.plugin-config-grid input,.plugin-config-group input{box-sizing:border-box;width:100%;min-width:0;padding:10px 12px;border:1px solid var(--admin-border);border-radius:8px;background:var(--admin-field);color:var(--admin-text);font-size:12px}
|
||||
.plugin-config-field,.plugin-config-group{font-size:12px;color:var(--admin-muted);min-width:0}
|
||||
.plugin-config-field [role=group],.plugin-config-group{display:grid;gap:8px;margin-bottom:12px}
|
||||
section.page-content.plugin-admin{display:grid;grid-template-columns:minmax(0,1fr);grid-auto-rows:max-content;align-content:start;gap:24px;color:var(--admin-text);min-width:0}
|
||||
|
||||
@@ -41,6 +41,14 @@ export const musicBotPublicFields: readonly ConfigField[] = [
|
||||
{key:'locale',type:'text',placeholder:'auto'},
|
||||
];
|
||||
|
||||
export const fileTransferId = 'community.p2p-file-transfer';
|
||||
export const watchTogetherId = 'community.watch-together';
|
||||
|
||||
const exampleFields: Readonly<Record<string, readonly ConfigField[]>> = {
|
||||
[fileTransferId]: [{key:'maxFileMiB',type:'number',placeholder:'256'}],
|
||||
[watchTogetherId]: [{key:'control',type:'select',choices:['everyone','host'],placeholder:'everyone'}],
|
||||
};
|
||||
|
||||
function makeConfigDraft(fields: readonly ConfigField[], config?: JsonValue): Record<string, string> {
|
||||
return Object.fromEntries(fields.map(({key,type}) => {
|
||||
const value = pluginRecord(config) ? config[key] : undefined;
|
||||
@@ -71,12 +79,12 @@ function readConfigFields(fields: readonly ConfigField[], draft: Record<string,
|
||||
export function useAdminPlugins(api: AdminApi) {
|
||||
const installed=shallowRef<InstalledPlugin[]>([]),catalog=shallowRef<PluginCatalog|null>(null),runtime=shallowRef<PluginRuntimeSettings|null>(null);
|
||||
const origin=ref(''),busy=ref(false),error=ref(''),catalogError=ref(''),requests=createAdminRequests();
|
||||
const drafts=reactive<Record<string,{enabled:boolean;trusted:boolean;toolbarPinned:boolean;scope:'server'|'instance';targets:string;config:string;serverConfigAction:'keep'|'replace'|'remove';serverConfig:string;publicFields:Record<string,string>;privateFields:Record<string,string>}>>({});
|
||||
const drafts=reactive<Record<string,{enabled:boolean;trusted:boolean;toolbarPinned:boolean;scope:'server'|'instance';targets:string;config:string;serverConfigAction:'keep'|'replace'|'remove';serverConfig:string;publicFields:Record<string,string>;privateFields:Record<string,string>;iceServers:{urls:string;username:string;credential:string}[];defaultIce:boolean}>>({});
|
||||
function apply(records:InstalledPlugin[]){
|
||||
installed.value=records;
|
||||
for(const record of records)if(!drafts[record.manifest.id]){
|
||||
const musicBot = record.manifest.id === musicBotId;
|
||||
drafts[record.manifest.id]={enabled:record.settings.enabled,trusted:record.settings.trusted,toolbarPinned:record.settings.toolbarPinned,scope:record.settings.scope,targets:record.settings.targets.join('\n'),config:JSON.stringify(record.settings.config,null,2),serverConfigAction:'keep',serverConfig:'',publicFields:musicBot?makeConfigDraft(musicBotPublicFields,record.settings.config):{},privateFields:musicBot?makeConfigDraft(musicBotPrivateFields):{}};
|
||||
drafts[record.manifest.id]={enabled:record.settings.enabled,trusted:record.settings.trusted,toolbarPinned:record.settings.toolbarPinned,scope:record.settings.scope,targets:record.settings.targets.join('\n'),config:JSON.stringify(record.settings.config,null,2),serverConfigAction:'keep',serverConfig:'',publicFields:makeConfigDraft(musicBot?musicBotPublicFields:exampleFields[record.manifest.id]??[],record.settings.config),privateFields:musicBot?makeConfigDraft(musicBotPrivateFields):{},iceServers:[],defaultIce:true};
|
||||
}
|
||||
for(const id of Object.keys(drafts))if(!records.some(r=>r.manifest.id===id))delete drafts[id];
|
||||
}
|
||||
@@ -111,9 +119,19 @@ export function useAdminPlugins(api: AdminApi) {
|
||||
function save(record:InstalledPlugin){return work(async(signal,current)=>{
|
||||
const draft=drafts[record.manifest.id],captured=JSON.stringify(draft);
|
||||
const musicBot=record.manifest.id===musicBotId;
|
||||
const settings:PluginSettingsInput={enabled:draft.enabled,trusted:draft.trusted,toolbarPinned:draft.toolbarPinned,scope:draft.scope,targets:draft.targets.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),config:musicBot?readConfigFields(musicBotPublicFields,draft.publicFields,record.settings.config):JSON.parse(draft.config),serverConfigAction:draft.serverConfigAction};
|
||||
const fields=musicBot?musicBotPublicFields:exampleFields[record.manifest.id];
|
||||
const settings:PluginSettingsInput={enabled:draft.enabled,trusted:draft.trusted,toolbarPinned:draft.toolbarPinned,scope:draft.scope,targets:draft.targets.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),config:fields?readConfigFields(fields,draft.publicFields,record.settings.config):JSON.parse(draft.config),serverConfigAction:draft.serverConfigAction};
|
||||
if(record.manifest.id===fileTransferId && pluginRecord(settings.config) && typeof settings.config.maxFileMiB==='number'
|
||||
&& (settings.config.maxFileMiB<1 || settings.config.maxFileMiB>2048)) throw new Error('PLUGIN_FILE_LIMIT_INVALID');
|
||||
if(draft.serverConfigAction==='replace'){
|
||||
settings.serverConfig=musicBot?readConfigFields(musicBotPrivateFields,draft.privateFields):JSON.parse(draft.serverConfig);
|
||||
if(record.manifest.id===fileTransferId){
|
||||
settings.serverConfig=draft.defaultIce?{}:{iceServers:draft.iceServers.map(({urls,username,credential})=>({
|
||||
urls:urls.split(/\s+/).filter(Boolean),...(username.trim()?{username:username.trim()}:{}),...(credential?{credential}:{}),
|
||||
}))};
|
||||
if(!draft.defaultIce && draft.iceServers.some(server=>!server.urls.trim() || server.urls.trim().split(/\s+/).some(url=>!/^(stun|stuns|turn|turns):\S+$/i.test(url)))) throw new Error('PLUGIN_ICE_URL_INVALID');
|
||||
}else{
|
||||
settings.serverConfig=musicBot?readConfigFields(musicBotPrivateFields,draft.privateFields):JSON.parse(draft.serverConfig || '{}');
|
||||
}
|
||||
if(musicBot && pluginRecord(settings.serverConfig) && (typeof settings.serverConfig.apiKey !== 'string' || !/^tsmb_[A-Za-z0-9_-]{20,}$/.test(settings.serverConfig.apiKey))) throw new Error('TSMB_API_KEY_REQUIRED');
|
||||
}
|
||||
if(musicBot && draft.enabled && (draft.serverConfigAction==='remove' || (draft.serverConfigAction==='keep' && !record.settings.hasServerConfig))) throw new Error('TSMB_API_KEY_REQUIRED');
|
||||
@@ -128,7 +146,7 @@ export function useAdminPlugins(api: AdminApi) {
|
||||
const result=await api.uploadPlugin(pack,installed.value.find(p=>p.manifest.id===pack.manifest.id)?.revision??null,signal);
|
||||
if(current()){delete drafts[pack.manifest.id];apply([...installed.value.filter(p=>p.manifest.id!==pack.manifest.id),result.plugin]);}
|
||||
});}
|
||||
function cancelRequests(){requests.reset();busy.value=false;for(const draft of Object.values(drafts)){draft.serverConfig='';draft.serverConfigAction='keep';for(const key of Object.keys(draft.privateFields))draft.privateFields[key]='';}}
|
||||
function cancelRequests(){requests.reset();busy.value=false;for(const draft of Object.values(drafts)){draft.serverConfig='';draft.serverConfigAction='keep';draft.iceServers=[];draft.defaultIce=true;for(const key of Object.keys(draft.privateFields))draft.privateFields[key]='';}}
|
||||
function reset(){cancelRequests();installed.value=[];catalog.value=null;runtime.value=null;origin.value='';error.value='';catalogError.value='';for(const id of Object.keys(drafts))delete drafts[id];}
|
||||
return {installed,catalog,runtime,origin,busy,error,catalogError,drafts,load,install,save,restart,saveRuntime,remove,upload,cancelRequests,reset,configValue,setConfigValue,musicBotCollection,setMusicBotCollection};
|
||||
}
|
||||
@@ -44,6 +44,19 @@ const en = {
|
||||
"addField": "Add",
|
||||
"storeChecksum": "Package checksum differs from the catalog. Refresh the store and retry.",
|
||||
"storeMismatch": "The package version, scope, or entry points differ from the catalog.",
|
||||
"maxFileSize": "Maximum file size (MiB, 1–2048; default 256)",
|
||||
"fileTransferIceHelp": "Default STUN works without setup. Add your own TURN service if peers cannot connect directly. WebRTC clients receive the TURN credentials.",
|
||||
"playbackControl": "Playback controls",
|
||||
"controlEveryone": "All viewers",
|
||||
"controlHost": "Room host only",
|
||||
"watchTogetherConfigHelp": "Controls who can play, pause, seek, or change the video. This plugin has no private settings.",
|
||||
"defaultIce": "Use default STUN",
|
||||
"iceUrls": "ICE URLs (separate with spaces)",
|
||||
"iceUsername": "TURN username",
|
||||
"iceCredential": "TURN password",
|
||||
"addIce": "Add STUN or TURN server",
|
||||
"iceInvalid": "Enter a valid STUN or TURN URL for every server.",
|
||||
"replaceIceHelp": "Replacing these settings replaces the whole ICE server list. Add every server you want to keep.",
|
||||
"setupGuide": "Plugin setup guide",
|
||||
"keep": "Keep existing secret configuration",
|
||||
"replace": "Replace secret configuration",
|
||||
@@ -107,6 +120,19 @@ zh:{
|
||||
"addField": "添加",
|
||||
"storeChecksum": "安装包的 SHA‑256 与商店记录不符。请刷新商店后重试。",
|
||||
"storeMismatch": "安装包的版本、作用域或入口与商店记录不一致。",
|
||||
"maxFileSize": "单文件上限(MiB,1–2048,默认 256)",
|
||||
"fileTransferIceHelp": "默认使用 STUN,无需配置。若成员无法直连,可添加自己的 TURN 服务。TURN 凭据会下发给参与传输的浏览器。",
|
||||
"playbackControl": "播放控制权限",
|
||||
"controlEveryone": "所有观看者",
|
||||
"controlHost": "仅房主",
|
||||
"watchTogetherConfigHelp": "决定谁可以播放、暂停、跳转进度或更换视频。此插件没有私密配置。",
|
||||
"defaultIce": "使用默认 STUN",
|
||||
"iceUrls": "ICE 地址(多个用空格分隔)",
|
||||
"iceUsername": "TURN 用户名",
|
||||
"iceCredential": "TURN 密码",
|
||||
"addIce": "添加 STUN 或 TURN 服务器",
|
||||
"iceInvalid": "请为每个服务器填写有效的 STUN 或 TURN 地址。",
|
||||
"replaceIceHelp": "替换会覆盖整个 ICE 服务器列表,请填入全部要保留的服务器。",
|
||||
"setupGuide": "插件配置说明",
|
||||
"keep": "保留现有私密配置",
|
||||
"replace": "替换私密配置",
|
||||
@@ -167,6 +193,19 @@ de:{
|
||||
"addField": "Hinzufügen",
|
||||
"storeChecksum": "Die Paketprüfsumme weicht vom Katalog ab. Aktualisieren Sie den Store.",
|
||||
"storeMismatch": "Version, Geltungsbereich oder Einstiegspunkte weichen vom Katalog ab.",
|
||||
"maxFileSize": "Maximale Dateigröße (MiB, 1–2048; Standard 256)",
|
||||
"fileTransferIceHelp": "Standardmäßig wird STUN verwendet. Bei Verbindungsproblemen kann ein eigener TURN-Dienst helfen. WebRTC-Clients erhalten die TURN-Zugangsdaten.",
|
||||
"playbackControl": "Wiedergabesteuerung",
|
||||
"controlEveryone": "Alle Zuschauer",
|
||||
"controlHost": "Nur der Raum-Host",
|
||||
"watchTogetherConfigHelp": "Legt fest, wer Wiedergabe, Position und Video ändern darf. Das Plugin hat keine privaten Einstellungen.",
|
||||
"defaultIce": "Standard-STUN verwenden",
|
||||
"iceUrls": "ICE-URLs (mit Leerzeichen trennen)",
|
||||
"iceUsername": "TURN-Benutzername",
|
||||
"iceCredential": "TURN-Passwort",
|
||||
"addIce": "STUN- oder TURN-Server hinzufügen",
|
||||
"iceInvalid": "Geben Sie für jeden Server eine gültige STUN- oder TURN-URL ein.",
|
||||
"replaceIceHelp": "Beim Ersetzen wird die gesamte Liste überschrieben. Fügen Sie alle gewünschten Server hinzu.",
|
||||
"setupGuide": "Plugin-Konfigurationsanleitung",
|
||||
"keep": "Vorhandene private Konfiguration behalten",
|
||||
"replace": "Private Konfiguration ersetzen",
|
||||
@@ -227,6 +266,19 @@ ru:{
|
||||
"addField": "Добавить",
|
||||
"storeChecksum": "Контрольная сумма пакета не совпадает с каталогом. Обновите каталог.",
|
||||
"storeMismatch": "Версия, область или точки входа пакета не совпадают с каталогом.",
|
||||
"maxFileSize": "Размер файла (МиБ, 1–2048; по умолчанию 256)",
|
||||
"fileTransferIceHelp": "По умолчанию используется STUN. Если прямое подключение не работает, добавьте свой TURN. Браузеры участников получают данные TURN.",
|
||||
"playbackControl": "Управление воспроизведением",
|
||||
"controlEveryone": "Все зрители",
|
||||
"controlHost": "Только ведущий",
|
||||
"watchTogetherConfigHelp": "Определяет, кто управляет воспроизведением и выбором видео. Приватных настроек нет.",
|
||||
"defaultIce": "Использовать STUN по умолчанию",
|
||||
"iceUrls": "Адреса ICE (через пробел)",
|
||||
"iceUsername": "Имя пользователя TURN",
|
||||
"iceCredential": "Пароль TURN",
|
||||
"addIce": "Добавить сервер STUN или TURN",
|
||||
"iceInvalid": "Укажите корректный адрес STUN или TURN для каждого сервера.",
|
||||
"replaceIceHelp": "Замена перезапишет весь список ICE. Добавьте все нужные серверы.",
|
||||
"setupGuide": "Инструкция по настройке плагина",
|
||||
"keep": "Сохранить текущие приватные настройки",
|
||||
"replace": "Заменить приватные настройки",
|
||||
@@ -287,6 +339,19 @@ ja:{
|
||||
"addField": "追加",
|
||||
"storeChecksum": "パッケージのチェックサムがカタログと一致しません。ストアを更新してください。",
|
||||
"storeMismatch": "パッケージのバージョン、スコープ、またはエントリがカタログと一致しません。",
|
||||
"maxFileSize": "最大ファイルサイズ (MiB、1~2048、既定値 256)",
|
||||
"fileTransferIceHelp": "既定の STUN は設定不要です。直接接続できない場合は TURN を追加してください。TURN 認証情報は参加者のブラウザーに渡ります。",
|
||||
"playbackControl": "再生操作の権限",
|
||||
"controlEveryone": "すべての視聴者",
|
||||
"controlHost": "ルームのホストのみ",
|
||||
"watchTogetherConfigHelp": "再生・一時停止・シーク・動画変更を操作できる人を設定します。秘密設定はありません。",
|
||||
"defaultIce": "既定の STUN を使用",
|
||||
"iceUrls": "ICE URL(空白区切り)",
|
||||
"iceUsername": "TURN ユーザー名",
|
||||
"iceCredential": "TURN パスワード",
|
||||
"addIce": "STUN または TURN サーバーを追加",
|
||||
"iceInvalid": "各サーバーに有効な STUN または TURN URL を入力してください。",
|
||||
"replaceIceHelp": "置換すると ICE サーバーの一覧全体が更新されます。使用するサーバーをすべて追加してください。",
|
||||
"setupGuide": "プラグイン設定ガイド",
|
||||
"keep": "現在の秘密設定を保持",
|
||||
"replace": "秘密設定を置換",
|
||||
|
||||
@@ -46,11 +46,11 @@ export const BUILTIN_SKIN_CATALOG: SkinCatalogEntry[] = [
|
||||
{
|
||||
id: BUILTIN_KAAK_SKIN_ID,
|
||||
name: "KAAK",
|
||||
version: "3.1.131",
|
||||
version: "3.1.132",
|
||||
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, unified chat with local history, and a compact audio dock.",
|
||||
minAppVersion: "0.2.8",
|
||||
minAppVersion: "0.3.2",
|
||||
installedAt: 0,
|
||||
builtIn: true,
|
||||
},
|
||||
|
||||
@@ -490,9 +490,9 @@ 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.131");
|
||||
assert.equal(skin.version, "3.1.132");
|
||||
assert.equal(skin.workspace, undefined);
|
||||
assert.equal(skin.minAppVersion, "0.2.8");
|
||||
assert.equal(skin.minAppVersion, "0.3.2");
|
||||
assert.equal(BUILTIN_SKIN_CATALOG.find((entry) => entry.id === skin.id)?.version, skin.version);
|
||||
assert.equal(skin.schemaVersion, 3);
|
||||
const baseMessages = skin.contentData?.locales["zh-CN"]?.messages ?? {};
|
||||
@@ -507,6 +507,8 @@ test("the distributable KAAK package provides full home and voice surfaces", asy
|
||||
const voice = skin.pluginData?.components.find((component) => component.page === "voice");
|
||||
assert.ok(voice?.permissions.includes("voice.connect"));
|
||||
assert.match(JSON.stringify(voice?.root), /"widget":"voice.connection-status"/);
|
||||
assert.match(JSON.stringify(voice?.root), /"widget":"voice.plugin-launcher".*?"pluginPresentation":"drawer-side"/);
|
||||
assert.match(JSON.stringify(voice?.root), /"widget":"home.social-links".*?"communityLinks":false/);
|
||||
assert.deepEqual(skin.pluginData?.components.map((component) => [component.id, component.mode]), [
|
||||
["kaak-home", "surface"],
|
||||
["kaak-workspace", "surface"],
|
||||
@@ -949,6 +951,7 @@ test("the Discord Voice package imports portable home and voice surfaces", async
|
||||
const file = new File([archive], "discord-voice.wskin", { type: "application/octet-stream" });
|
||||
const skin = await importSkinPack(file);
|
||||
assert.equal(skin.id, "community.discord-voice");
|
||||
assert.equal(skin.minAppVersion, "0.3.2");
|
||||
assert.equal(skin.packageType, "open-skin");
|
||||
assert.equal(skin.schemaVersion, 3);
|
||||
assert.deepEqual(skin.pluginData?.components.map(({ id, page, mode }) => [id, page, mode]), [
|
||||
@@ -963,6 +966,7 @@ test("the Discord Voice package imports portable home and voice surfaces", async
|
||||
assert.ok(voice?.permissions.includes("audio.microphone.control"));
|
||||
assert.ok(voice?.permissions.includes("voice.screenShare.control"));
|
||||
assert.equal(voice?.actions["copy-invite-link"]?.type, "session.copyInviteLink");
|
||||
assert.match(JSON.stringify(voice?.root), /"widget":"voice.plugin-launcher".*?"pluginPresentation":"drawer-side"/);
|
||||
assert.equal(skin.runtimePlugins?.plugins.length ?? 0, 0, "the open skin contains no executable plugin code");
|
||||
const baseMessageKeys = Object.keys(skin.contentData?.locales.en?.messages ?? {}).sort();
|
||||
for (const locale of ["zh-CN", "de", "ru", "ja"]) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
.ws-plugin-overlay button:focus-visible,.ws-plugin-search:focus-visible{outline:2px solid var(--po-accent);outline-offset:3px}
|
||||
.ws-plugin-overlay svg{display:block;width:19px;height:19px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
||||
.webspeak-plugin-toolbar-host{display:flex;align-items:center;flex:none;min-width:0;max-width:min(38vw,240px)}
|
||||
.ws-plugin-toolbar{display:flex;align-items:center;gap:4px;max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;scrollbar-width:none}
|
||||
.ws-plugin-toolbar{display:flex;align-items:center;gap:4px;max-width:100%;overflow:visible}
|
||||
.ws-plugin-toolbar::-webkit-scrollbar{display:none}
|
||||
.ws-plugin-toolbar .ws-plugin-toolbar-trigger,.ws-plugin-toolbar .ws-plugin-toolbar-shortcut{display:inline-flex;align-items:center;justify-content:center;flex:none;width:34px;height:34px;padding:7px;border-radius:10px;cursor:pointer}
|
||||
.ws-plugin-toolbar .ws-plugin-toolbar-trigger svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
|
||||
@@ -50,3 +50,20 @@
|
||||
.ws-plugin-browser iframe{display:block;flex:1;width:100%;height:100%;min-height:0;border:0;border-radius:0;background:var(--po-surface)}
|
||||
.ws-plugin-drag-shield{position:absolute;inset:62px 0 0;z-index:1;cursor:grabbing}
|
||||
@media(max-width:600px){.ws-plugin-window{left:8px!important;top:8px!important;transform:none!important;width:calc(100vw - 16px)!important;height:calc(100dvh - 92px);min-width:0;resize:none;border-radius:13px}.ws-plugin-titlebar{padding-left:12px;gap:8px}.ws-plugin-window-title small{display:none}.ws-plugin-library{padding:18px}.webspeak-plugin-toolbar-host{max-width:30vw}.ws-plugin-toolbar .ws-plugin-toolbar-shortcut{width:30px;height:30px}.ws-plugin-library-heading h2{font-size:21px}.ws-plugin-entry{padding:16px}.ws-plugin-navigation{padding-inline:10px}}
|
||||
|
||||
.ws-plugin-toolbar{position:relative;display:flex;align-items:center;min-width:0}
|
||||
.ws-plugin-toolbar-fallback{position:fixed;z-index:1001;right:16px;bottom:calc(16px + env(safe-area-inset-bottom));padding:4px;border-radius:12px;background:var(--ws-panel,#fff);box-shadow:0 4px 20px #0003;color:#233049}
|
||||
.ws-plugin-toolbar[data-presentation="drawer-side"]{display:grid;width:100%;gap:4px;color:inherit}
|
||||
.ws-plugin-toolbar[data-presentation="drawer-side"] .ws-plugin-toolbar-trigger{justify-content:flex-start;width:100%;gap:8px;padding:7px 10px;color:inherit;background:transparent;border:1px solid transparent;font:inherit}
|
||||
.ws-plugin-drawer{position:absolute;top:calc(100% + 8px);right:0;z-index:60;width:min(280px,calc(100vw - 32px));max-height:min(380px,60dvh);overflow:auto;overscroll-behavior:contain;padding:8px;color:var(--plugin-drawer-text,#233049);background:var(--plugin-drawer-bg,#fff);border:1px solid var(--plugin-drawer-border,#dae1ef);border-radius:12px;box-shadow:0 12px 32px #17223430;text-align:left;font:13px/1.4 system-ui,sans-serif}
|
||||
.ws-plugin-toolbar[data-theme="dark"] .ws-plugin-drawer{--plugin-drawer-text:#edf2ff;--plugin-drawer-bg:#202736;--plugin-drawer-border:#364158;--plugin-drawer-hover:#303a49}
|
||||
.ws-plugin-toolbar[data-presentation="drawer-side"] .ws-plugin-drawer{position:static;width:auto;max-height: min(250px,32dvh);box-shadow:none}
|
||||
.ws-plugin-drawer-search{box-sizing:border-box;width:100%;padding:6px 9px;border:1px solid var(--plugin-drawer-border,#dae1ef);border-radius:7px;background:transparent;color:inherit;font:inherit}
|
||||
.ws-plugin-drawer ul{display:grid;gap:2px;margin:6px 0 0;padding:0;list-style:none}
|
||||
.ws-plugin-drawer p{margin:8px 2px}
|
||||
.ws-plugin-drawer-app{display:grid;grid-template-columns:24px minmax(0,1fr) auto;align-items:center;width:100%;gap:8px;border:0;border-radius:7px;padding:5px;color:inherit;background:transparent;font:inherit;text-align:left;cursor:pointer}
|
||||
.ws-plugin-drawer-app span:nth-child(2){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.ws-plugin-drawer-app:hover,.ws-plugin-drawer-app:focus-visible{background:var(--plugin-drawer-hover,#eef1f8)}
|
||||
.ws-plugin-drawer-app:disabled{opacity:.55;cursor:default}
|
||||
.ws-plugin-drawer-mark{display:grid;place-items:center;height:24px;border:1px solid var(--plugin-drawer-border,#dae1ef);border-radius:6px}
|
||||
.ws-plugin-window .ws-plugin-error:last-of-type{overflow-wrap:anywhere}
|
||||
@@ -3007,7 +3007,7 @@
|
||||
:deep(.section-counter) {
|
||||
display: none;
|
||||
}
|
||||
.workspace-actions .header-action:first-child {
|
||||
.workspace-actions > .header-action:first-child {
|
||||
display: none;
|
||||
}
|
||||
.dock-icon {
|
||||
|
||||
@@ -874,7 +874,7 @@
|
||||
<div class="ws-skin-mount-slot" data-ws-skin-mount="voice.workspace.overlay"></div>
|
||||
</div>
|
||||
|
||||
<PluginPanel :session-token="pluginSession" :gateway-url="pluginVoiceSocket?.url ?? ''" :connected="voiceState.connected" :language="language" :toolbar-target="pluginToolbarTarget" />
|
||||
<PluginPanel :session-token="pluginSession" :gateway-url="pluginVoiceSocket?.url ?? ''" :connected="voiceState.connected" :language="language" :toolbar-target="skinPluginToolbar?.element ?? pluginToolbarTarget" :presentation="skinPluginToolbar?.presentation ?? (OFFICIAL_SKIN_IDS.has(activeSkinId) ? 'drawer-below' : 'dialog')" />
|
||||
<HostChrome :language="language" :connected="voiceState.connected" :plugin-library-available="voiceState.connected && Boolean(pluginSession)" />
|
||||
<IdentityImportDialog
|
||||
v-if="identityImportOpen"
|
||||
@@ -970,7 +970,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { observeMobileViewport } from "../services/mobile-viewport.js";
|
||||
import { computed, h, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
|
||||
import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref, shallowRef, watch } from "vue";
|
||||
import Icon from "../components/Icon.vue";
|
||||
import VoiceConnectionStatus from "../components/web-client/VoiceConnectionStatus.vue";
|
||||
import { useVoiceWorkspace } from "../composables/useVoiceWorkspace.js";
|
||||
@@ -1011,6 +1011,7 @@ import { useWebClientChannels, type TreeChannel } from "../composables/useWebCli
|
||||
import { useWebClientConnection } from "../composables/useWebClientConnection.js";
|
||||
import { useWebClientMembers } from "../composables/useWebClientMembers.js";
|
||||
import PluginPanel from "../components/PluginPanel.vue";
|
||||
import { OFFICIAL_SKIN_IDS } from "../services/instance-authorization.js";
|
||||
import HostChrome from "../components/HostChrome.vue";
|
||||
import InstanceAuthorization from '../components/InstanceAuthorization.vue';
|
||||
import WorkspaceInviteDialog from "../components/web-client/WorkspaceInviteDialog.vue";
|
||||
@@ -1176,6 +1177,7 @@ const skinPluginDocument = computed<SkinPluginDocument>(() => {
|
||||
return loadSkinPluginAuthoringDocument(skin.id, skin.version) ?? skin.pluginData ?? emptySkinPluginDocument;
|
||||
});
|
||||
const pluginToolbarTarget = ref<HTMLElement | null>(null);
|
||||
const skinPluginToolbar = shallowRef<{ element: HTMLElement; presentation: NonNullable<SkinPluginWidgetOptions["pluginPresentation"]> } | null>(null);
|
||||
const skinPluginSurfaceActive = ref(false);
|
||||
const skinRuntimePluginSurfaceActive = ref(false);
|
||||
watch(activeSkin, () => {
|
||||
@@ -1832,11 +1834,11 @@ const skinPluginWidgets = {
|
||||
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", {
|
||||
"home.social-links": (options?: SkinPluginWidgetOptions) => h("nav", {
|
||||
"data-ws-part": "home.social-links",
|
||||
"aria-label": t("communityLinks"),
|
||||
}, [
|
||||
h("a", {
|
||||
...(options?.communityLinks === false ? [] : [h("a", {
|
||||
href: githubRepositoryUrl,
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
@@ -1849,7 +1851,7 @@ const skinPluginWidgets = {
|
||||
rel: "noreferrer",
|
||||
title: t("qqGroup"),
|
||||
"aria-label": t("qqGroup"),
|
||||
}, [h(Icon, { name: "qq", size: 20 })]),
|
||||
}, [h(Icon, { name: "qq", size: 20 })])]),
|
||||
h("a", {
|
||||
href: "/admin",
|
||||
title: t("adminConsole"),
|
||||
@@ -1930,6 +1932,24 @@ const skinPluginWidgets = {
|
||||
menuLabel: t("languageMenu"),
|
||||
onChange: persistLanguage,
|
||||
}),
|
||||
"voice.plugin-launcher": (options?: SkinPluginWidgetOptions) => h("div", {
|
||||
ref: (element) => {
|
||||
if (element instanceof HTMLElement) {
|
||||
const presentation = options?.pluginPresentation ?? "dialog";
|
||||
if (skinPluginToolbar.value?.element !== element || skinPluginToolbar.value.presentation !== presentation) {
|
||||
skinPluginToolbar.value = { element, presentation };
|
||||
}
|
||||
} else if (skinPluginToolbar.value && !skinPluginToolbar.value.element.isConnected) {
|
||||
skinPluginToolbar.value = null;
|
||||
} else if (skinPluginToolbar.value) {
|
||||
const previous = skinPluginToolbar.value.element;
|
||||
void nextTick(() => {
|
||||
if (skinPluginToolbar.value?.element === previous && !previous.isConnected) skinPluginToolbar.value = null;
|
||||
});
|
||||
}
|
||||
},
|
||||
class: "webspeak-plugin-toolbar-skin-slot",
|
||||
}),
|
||||
"voice.channel-panel": () => h(ChannelMemberPanel, {
|
||||
query: memberQuery.value,
|
||||
"onUpdate:query": (value: string) => { memberQuery.value = value; },
|
||||
|
||||
Reference in new issue
Block a user