feat: add plugin application runtime and unified instance authorization

This commit is contained in:
illusia committed 2026-11-03 20:13:01 +08:00
1 parent 8bca848c21
commit 3430a8a753
80 files changed
+2133 -1004

No files matched your search

@@ -0,0 +1,45 @@
<template>
<Teleport to="body">
<dialog ref="dialog" class="ws-instance-authorization" @cancel.prevent="cancel" @close="authorizationRequested = false">
<form @submit.prevent="save">
<div class="ws-authorization-mark" aria-hidden="true">◈</div>
<h2>{{ copy.title }}</h2>
<p>{{ copy.description }}</p>
<p>{{ copy.alternative }}</p>
<label><input v-model="checked" type="checkbox" /><span>{{ copy.choice }}</span></label>
<footer>
<button type="button" @click="decline">{{ copy.decline }}</button>
<button class="ws-authorization-primary" type="submit" :disabled="firstVisit && !checked">{{ firstVisit ? copy.accept : copy.save }}</button>
</footer>
</form>
</dialog>
</Teleport>
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import type { SiteLanguage } from '../../../src/site-copy.js';
import { authorizationDecision, authorizationLanguage, authorizationRequested, setInstanceAuthorization } from '../services/instance-authorization.js';
import { instanceAuthorizationCopy } from '../i18n/instance-authorization.js';
const props = defineProps<{ language: SiteLanguage }>();
const dialog = ref<HTMLDialogElement | null>(null), checked = ref(false), firstVisit = ref(false);
const copy = computed(() => instanceAuthorizationCopy[props.language]);
watch(() => props.language, value => { authorizationLanguage.value = value; }, { immediate: true });
watch([dialog, authorizationRequested, authorizationDecision], () => {
if (!dialog.value || dialog.value.open || (authorizationDecision.value !== null && !authorizationRequested.value)) return;
firstVisit.value = authorizationDecision.value === null;
checked.value = authorizationDecision.value === true;
dialog.value.showModal();
}, { flush: 'post' });
function finish() { authorizationRequested.value = false; dialog.value?.close(); }
function save() { if (firstVisit.value && !checked.value) return; setInstanceAuthorization(checked.value); finish(); }
function decline() { setInstanceAuthorization(false); finish(); }
function cancel() { if (firstVisit.value) decline(); else finish(); }
onBeforeUnmount(() => dialog.value?.close());
</script>
<style>
.ws-instance-authorization{box-sizing:border-box;width:min(570px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:30px;border:1px solid #dbe3f1;border-radius:20px;background:#fff;color:#25324b;font:14px/1.75 system-ui,-apple-system,"Segoe UI",sans-serif;box-shadow:0 24px 90px #101c4140;color-scheme:light;overflow:auto}
.ws-instance-authorization::backdrop{background:#10182d8c;backdrop-filter:blur(5px)}
.ws-instance-authorization form{margin:0}.ws-instance-authorization h2{margin:12px 0 16px;font-size:23px;line-height:1.4;color:#202e49}.ws-instance-authorization p{margin:12px 0;color:#526079}.ws-authorization-mark{display:grid;place-items:center;width:43px;height:43px;border-radius:13px;background:#edf0ff;color:#5265df;font-size:28px}
.ws-instance-authorization label{display:flex;align-items:flex-start;gap:12px;margin:22px 0;padding:15px;background:#f4f6fc;border:1px solid #dce3f3;border-radius:12px;cursor:pointer}.ws-instance-authorization input{appearance:auto;flex:none;width:18px;height:18px;margin:4px 0 0;accent-color:#5265df}.ws-instance-authorization footer{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-top:24px}.ws-instance-authorization button{appearance:none;min-height:42px;padding:9px 16px;border:1px solid #d9e1ef;border-radius:10px;background:#f4f6fc;color:#43516d;font:600 14px/1.5 system-ui;cursor:pointer}.ws-instance-authorization .ws-authorization-primary{background:#5265df;color:#fff;border-color:#5265df}.ws-instance-authorization button:disabled{opacity:.45;cursor:not-allowed}.ws-instance-authorization button:focus-visible,.ws-instance-authorization input:focus-visible{outline:2px solid #5265df;outline-offset:3px}
@media(max-width:600px){.ws-instance-authorization{padding:22px}.ws-instance-authorization footer button{flex:1}}
</style>
+141 -89
View File
@@ -1,111 +1,163 @@
<template>
<Teleport to="body">
<button v-if="connected" class="ws-plugin-launcher" type="button" @click="show">◈ {{ tr('title') }}</button>
<dialog ref="dialog" class="ws-plugin-dialog" :data-plugin-theme="theme" @close="closed" @cancel="closed">
<header><strong>{{ current?.manifest.name ?? tr('title') }}</strong><button type="button" @click="dialog?.close()">{{ tr('close') }}</button></header>
<p v-if="error" role="alert" class="ws-plugin-error">{{ error }}</p>
<template v-if="!current">
<div class="ws-plugin-toolbar"><button type="button" :disabled="busy" @click="refresh">{{ busy ? tr('loading') : tr('refresh') }}</button></div>
<p>{{ tr('enableNote') }}</p><p v-if="!busy && !available.length">{{ tr('empty') }}</p>
<section v-for="entry in available" :key="entry.manifest.id" class="ws-plugin-entry">
<div><strong>{{ entry.manifest.name }}</strong><small>{{ entry.scope === 'server' ? tr('server') : tr('instance') }} · {{ entry.manifest.version }}</small><p>{{ entry.manifest.description }}</p></div>
<button type="button" :disabled="busy" @click="launch(entry.manifest.id)">{{ tr('open') }}</button>
</section>
</template>
<template v-else>
<div class="ws-plugin-toolbar"><button type="button" @click="stop">← {{ tr('back') }}</button><small>{{ tr('permission') }}: {{ current.manifest.permissions.join(', ') }}</small></div>
<iframe ref="frame" :key="channel" :title="current.manifest.name" :srcdoc="documentSource" sandbox="allow-scripts" allow="fullscreen" referrerpolicy="no-referrer" @load="sendContext"></iframe>
</template>
</dialog>
<div v-if="thirdPartyAllowed && connected && sessionToken" class="ws-plugin-overlay" :data-plugin-theme="theme">
<button ref="launcher" class="ws-plugin-launcher" :style="launcherPosition" type="button" :title="tr('title')" :aria-label="tr('title')" :aria-expanded="visible" @pointerdown="startLauncherDrag" @lostpointercapture="endDrag" @click="toggle">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z" /></svg>
<span>{{ tr('title') }}</span><i v-if="current" />
</button>
<section v-show="visible" ref="windowElement" class="ws-plugin-window" :class="{ 'is-maximized': maximized, 'is-dragging': dragging }" :style="position" role="dialog" :aria-label="current && appView ? current.manifest.name : tr('title')" tabindex="-1" @keydown.esc.stop="minimize">
<header class="ws-plugin-titlebar" @pointerdown="startDrag" @lostpointercapture="endDrag" @dblclick="toggleMaximize">
<span class="ws-plugin-mark" aria-hidden="true">◈</span>
<div class="ws-plugin-window-title"><strong>{{ current && appView ? current.manifest.name : tr('title') }}</strong><small>WebSpeak</small></div>
<div class="ws-plugin-window-controls" @pointerdown.stop @dblclick.stop>
<button type="button" :title="ui.minimize" :aria-label="ui.minimize" @click="minimize"><svg viewBox="0 0 24 24"><path d="M5 17h14" /></svg></button>
<button type="button" :title="maximized ? ui.restore : ui.maximize" :aria-label="maximized ? ui.restore : ui.maximize" @click="toggleMaximize"><svg viewBox="0 0 24 24"><path :d="maximized ? 'M8 4h12v12M4 8h12v12H4z' : 'M5 5h14v14H5z'" /></svg></button>
<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')">
<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 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>
<div class="ws-plugin-grid">
<article v-for="entry in filtered" :key="entry.manifest.id" class="ws-plugin-entry">
<div class="ws-plugin-app-mark" aria-hidden="true">{{ entry.manifest.name.slice(0, 1).toUpperCase() }}</div>
<div class="ws-plugin-entry-copy"><h3>{{ entry.manifest.name }}</h3><small>v{{ entry.manifest.version }} · {{ entry.scope === 'server' ? tr('server') : tr('instance') }}</small><p>{{ entry.manifest.description }}</p></div>
<p v-if="entry.runtime.state === 'failed'" class="ws-plugin-entry-error">{{ entry.runtime.error }}</p>
<button type="button" :disabled="busy || entry.runtime.state === 'failed'" @click="launch(entry.manifest.id)">{{ tr('open') }} <span aria-hidden="true">↗</span></button>
</article>
</div>
</div>
<div v-show="appView && current" class="ws-plugin-browser">
<iframe v-if="current" ref="frame" :key="current.id" :title="current.manifest.name" :src="current.url" :allow="browserFeatures" referrerpolicy="no-referrer"></iframe>
</div>
<div v-if="dragging" class="ws-plugin-drag-shield" />
</section>
</div>
</Teleport>
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
import { parsePluginPackage, pluginRecord, parsePluginJson, type PluginManifest, type PluginScope, type PluginRoomSnapshot } from '../../../src/shared/plugins.js';
import { pluginFrameDocument } from '../services/plugin-frame.js';
import type { PluginTransport } from '../services/plugin-transport.js';
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, 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';
const props = defineProps<{ transport: PluginTransport; connected: boolean; language: SiteLanguage }>();
import { thirdPartyAllowed } from '../services/instance-authorization.js';
const props = defineProps<{ sessionToken: string; gatewayUrl: string; connected: boolean; language: SiteLanguage }>();
const tr = (key: PluginTextKey) => pluginTranslations[props.language][key];
const dialog = ref<HTMLDialogElement | null>(null), frame = ref<HTMLIFrameElement | null>(null);
const available = shallowRef<{ manifest: PluginManifest; scope: PluginScope }[]>([]);
const current = shallowRef<ReturnType<typeof parsePluginPackage> | null>(null);
const documentSource = ref(''), channel = ref(''), theme = ref<'light'|'dark'>('light');
const busy = ref(false), error = ref(''); let epoch = 0, openingId: string | undefined, context: Record<string,unknown> = {}, observer: MutationObserver | undefined;
const inFlight = new Set<number>();
const pluginId = computed(() => current.value?.manifest.id);
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 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 launcherPosition = ref<Record<string, string>>({});
const filtered = computed(() => available.value.filter(entry => `${entry.manifest.name} ${entry.manifest.description}`.toLocaleLowerCase().includes(search.value.trim().toLocaleLowerCase())));
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; kind: 'window' | 'launcher'; moved: boolean } | undefined;
let suppressLauncherClick = false, resizeObserver: ResizeObserver | undefined;
const browserFeatures = computed(() => {
const policy = (document as Document & { featurePolicy?: { features(): string[] } }).featurePolicy;
const features = policy?.features() ?? ['fullscreen', 'autoplay', 'camera', 'microphone', 'display-capture', 'clipboard-read', 'clipboard-write', 'geolocation', 'screen-wake-lock'];
return features.filter(feature => /^[a-z0-9-]+$/.test(feature)).map(feature => feature + ' *').join('; ');
});
function detectTheme() {
const root = document.querySelector('.ws-skin-root');
const color = root ? getComputedStyle(root).color.match(/[\d.]+/g)?.map(Number) : null;
theme.value = color && color.length >= 3 ? (color[0]*.2126+color[1]*.7152+color[2]*.0722 > 140 ? 'dark':'light') : matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';
const style = getComputedStyle(root ?? document.documentElement);
if (style.colorScheme === 'dark' || style.colorScheme === 'light') { theme.value = style.colorScheme; return; }
const color = root ? style.color.match(/[\d.]+/g)?.map(Number) : null;
theme.value = color && color.length >= 3 ? (color[0] * .2126 + color[1] * .7152 + color[2] * .0722 > 140 ? 'dark' : 'light') : matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
function send(value: object) { frame.value?.contentWindow?.postMessage({ channel: channel.value, ...value }, '*'); }
function sendContext() { send({ type: 'context', context: { ...context, language: props.language, theme: theme.value } }); }
function client() { return createPluginAppClient(props.gatewayUrl, props.sessionToken); }
async function refresh() {
const owner = ++epoch; busy.value = true; error.value = '';
try {
const result = await props.transport.request('list');
if (owner !== epoch) return;
if (!Array.isArray(result) || result.length > 50) throw new Error('PLUGIN_INVALID_RESPONSE');
available.value = result.map(v => { if (!pluginRecord(v)) throw new Error('PLUGIN_INVALID_RESPONSE');
const manifest = v.manifest; if (!pluginRecord(manifest) || typeof manifest.id !== 'string' || typeof manifest.name !== 'string' || (v.scope !== 'server' && v.scope !== 'instance')) throw new Error('PLUGIN_INVALID_RESPONSE');
return { manifest: manifest as unknown as PluginManifest, scope: v.scope }; });
} catch (e) { if (owner === epoch) error.value = `${tr('error')}: ${e instanceof Error ? e.message : ''}`; }
finally { if (owner === epoch) busy.value = false; }
if (!thirdPartyAllowed.value) return;
const owner = ++epoch; pending?.abort(); const controller = new AbortController(); pending = controller; busy.value = true; error.value = '';
try { const entries = await client().list(controller.signal); if (owner === epoch) available.value = entries; }
catch (e) { if (owner === epoch && !controller.signal.aborted) error.value = `${tr('error')}: ${e instanceof Error ? e.message : ''}`; }
finally { if (owner === epoch) { busy.value = false; pending = undefined; } }
}
function show() { detectTheme(); dialog.value?.showModal(); void refresh(); }
function toggle() {
if (suppressLauncherClick) { suppressLauncherClick = false; return; }
if (visible.value) { minimize(); return; }
detectTheme(); visible.value = true;
if (!current.value) { appView.value = false; void refresh(); }
void nextTick(() => { fitWindow(); windowElement.value?.focus(); });
}
function minimize() { endDrag(); visible.value = false; launcher.value?.focus(); }
function close() { stop(); error.value = ''; available.value = []; search.value = ''; minimize(); }
function stop() {
const id = pluginId.value ?? openingId; ++epoch; openingId = undefined; inFlight.clear(); current.value = null; documentSource.value = ''; context = {}; channel.value = ''; busy.value = false;
if (id) void props.transport.request('close', { pluginId: id }).catch(() => undefined);
++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);
}
function closed() { stop(); error.value = ''; available.value = []; }
async function launch(id: string) {
const owner = ++epoch; openingId = id; busy.value = true; error.value = '';
if (!thirdPartyAllowed.value) return;
if (current.value?.manifest.id === id) { appView.value = true; 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 result = await props.transport.request('open', { pluginId: id });
// stop() queues the close after this open on the same ordered socket.
// A late response must never close a newer opening of the same plugin.
const app = await service.open(id, { openId: key, theme: theme.value, language: props.language }, controller.signal);
if (owner !== epoch) return;
if (!pluginRecord(result) || !pluginRecord(result.snapshot)) throw new Error('PLUGIN_INVALID_RESPONSE');
const pack = parsePluginPackage(result.package);
if (pack.manifest.id !== id) throw new Error('PLUGIN_INVALID_RESPONSE');
current.value = pack; context = { config: result.config, self: result.self, scope: result.scope, snapshot: result.snapshot };
channel.value = crypto.randomUUID(); documentSource.value = pluginFrameDocument(pack, channel.value);
} catch (e) { if (owner === epoch) error.value = `${tr('error')}: ${e instanceof Error ? e.message : ''}`; }
finally { if (owner === epoch) { openingId = undefined; busy.value = false; } }
if (new URL(app.url).origin === location.origin) throw new Error('PLUGIN_SEPARATE_ORIGIN_REQUIRED');
current.value = app; appView.value = true;
} 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; } }
}
async function receive(event: MessageEvent) {
if (!frame.value || event.source !== frame.value.contentWindow || !pluginRecord(event.data) || event.data.channel !== channel.value || !current.value) return;
const value = event.data;
if (value.type === 'ready') { sendContext(); return; }
if (value.type !== 'request' || !Number.isSafeInteger(value.id) || inFlight.has(value.id as number) || inFlight.size >= 8) return;
const id = value.id as number, owner = epoch, plugin = pluginId.value!; inFlight.add(id);
try {
let result: unknown;
if (value.method === 'room.snapshot') result = await props.transport.request('snapshot', { pluginId: plugin });
else if (value.method === 'room.update' && pluginRecord(value.args) && Number.isSafeInteger(value.args.revision)) {
result = await props.transport.request('update', { pluginId: plugin, revision: value.args.revision as number, state: parsePluginJson(value.args.state) });
} else throw new Error('PLUGIN_PERMISSION_DENIED');
if (owner === epoch) send({ type: 'reply', id, result });
} catch (e) { if (owner === epoch) send({ type: 'reply', id, error: e instanceof Error ? e.message : 'PLUGIN_FAILED' }); }
finally { if (owner === epoch) inFlight.delete(id); }
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'); }
}
const unsubscribe = props.transport.subscribe(message => {
if (message.type === 'pluginReset') { stop(); available.value = []; dialog.value?.close(); return; }
if (message.type !== 'pluginEvent' || message.pluginId !== pluginId.value) return;
if (!message.snapshot) { stop(); error.value = tr('context'); return; }
context.snapshot = message.snapshot as PluginRoomSnapshot; send({ type: 'snapshot', snapshot: message.snapshot });
function appearance() { if (current.value && opening) void opening.client.appearance(current.value.id, theme.value, props.language).catch(() => undefined); }
function fitWindow() {
if (launcher.value && launcherPosition.value.left) {
const box = launcher.value.getBoundingClientRect();
launcherPosition.value = { left: `${Math.max(8, Math.min(box.left, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(box.top, innerHeight - box.height - 8))}px`, right: 'auto', bottom: 'auto' };
}
if (!visible.value || maximized.value || !windowElement.value) return;
const box = windowElement.value.getBoundingClientRect();
position.value = { left: `${Math.max(8, Math.min(box.left, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(box.top, innerHeight - box.height - 8))}px`, transform: 'none' };
}
function toggleMaximize() { endDrag(); maximized.value = !maximized.value; if (!maximized.value) void nextTick(fitWindow); }
function startDrag(event: PointerEvent) {
if (event.button !== 0 || maximized.value || (event.target as HTMLElement).closest('button')) return;
const box = windowElement.value?.getBoundingClientRect(); if (!box) return;
event.preventDefault(); const handle = event.currentTarget as HTMLElement;
drag = { id: event.pointerId, x: event.clientX, y: event.clientY, left: box.left, top: box.top, handle, kind: 'window', moved: false }; dragging.value = true;
handle.setPointerCapture(event.pointerId);
}
function startLauncherDrag(event: PointerEvent) {
if (event.button !== 0 || !launcher.value) return;
const box = launcher.value.getBoundingClientRect(); suppressLauncherClick = false;
drag = { id: event.pointerId, x: event.clientX, y: event.clientY, left: box.left, top: box.top, handle: launcher.value, kind: 'launcher', moved: false };
launcher.value.setPointerCapture(event.pointerId);
}
function moveDrag(event: PointerEvent) {
if (!drag || drag.id !== event.pointerId) return;
const target = drag.kind === 'launcher' ? launcher.value : windowElement.value; if (!target) return;
if (Math.hypot(event.clientX - drag.x, event.clientY - drag.y) < 5 && !drag.moved) return;
drag.moved = true; const box = target.getBoundingClientRect();
const next = { left: `${Math.max(8, Math.min(drag.left + event.clientX - drag.x, innerWidth - box.width - 8))}px`, top: `${Math.max(8, Math.min(drag.top + event.clientY - drag.y, innerHeight - box.height - 8))}px`, transform: 'none' };
if (drag.kind === 'launcher') launcherPosition.value = { ...next, right: 'auto', bottom: 'auto' }; else position.value = next;
}
function endDrag() {
const old = drag; drag = undefined; dragging.value = false;
if (old?.kind === 'launcher' && old.moved) suppressLauncherClick = true;
if (old?.handle.hasPointerCapture(old.id)) old.handle.releasePointerCapture(old.id);
}
watch(windowElement, element => { resizeObserver?.disconnect(); if (element) { resizeObserver = new ResizeObserver(fitWindow); resizeObserver.observe(element); } });
watch(() => [props.sessionToken, props.gatewayUrl, props.connected] as const, close);
watch(thirdPartyAllowed, allowed => { if (!allowed) close(); }, { flush: 'sync' });
watch(() => props.language, appearance); watch(theme, appearance);
onMounted(() => {
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);
observer = new MutationObserver(detectTheme); observer.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: ['data-ws-skin', 'data-theme'] });
});
watch(() => props.language, sendContext);
watch(theme, sendContext);
watch(() => props.connected, connected => { if (!connected) { closed(); dialog.value?.close(); } });
onMounted(() => { window.addEventListener('message', receive); observer = new MutationObserver(detectTheme); observer.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter:['data-ws-skin','data-theme'] }); });
onBeforeUnmount(() => { unsubscribe(); stop(); observer?.disconnect(); window.removeEventListener('message', receive); dialog.value?.close(); });
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>
.ws-plugin-launcher{all:initial;position:fixed;right:16px;top:88px;z-index:10000;font:600 14px system-ui;cursor:pointer;background:#184b48;color:white;border:1px solid #4d827e;border-radius:24px;padding:10px 16px;box-shadow:0 4px 20px #0003}
.ws-plugin-dialog{box-sizing:border-box;width:min(960px,calc(100vw - 24px));max-height:calc(100dvh - 32px);padding:20px;border:1px solid #b6c9c7;border-radius:16px;background:#fff;color:#182e2d;font:15px/1.5 system-ui;overflow:auto}
.ws-plugin-dialog[data-plugin-theme="dark"]{background:#20242b;color:#ecf2f1;border-color:#4a525d}.ws-plugin-dialog::backdrop{background:#0009}.ws-plugin-dialog header,.ws-plugin-toolbar,.ws-plugin-entry{display:flex;align-items:center;gap:12px;justify-content:space-between}.ws-plugin-dialog header strong{font-size:20px}.ws-plugin-dialog button{font:inherit;cursor:pointer;border:1px solid #779c98;border-radius:8px;padding:8px 12px;background:#e5f3f0;color:#153f3b}.ws-plugin-dialog button:disabled{opacity:.5;cursor:wait}.ws-plugin-dialog iframe{display:block;width:100%;height:min(620px,68dvh);border:1px solid #779c98;border-radius:8px;background:transparent}.ws-plugin-toolbar{margin:14px 0;flex-wrap:wrap}.ws-plugin-entry{border-top:1px solid #779c9866;padding:16px 0}.ws-plugin-entry small{display:block;opacity:.7}.ws-plugin-entry p{margin:6px 0}.ws-plugin-error{color:#c73131;overflow-wrap:anywhere}
@media(max-width:600px){.ws-plugin-launcher{top:72px;right:8px;padding:8px 12px}.ws-plugin-dialog{padding:14px}.ws-plugin-entry{align-items:start}.ws-plugin-dialog iframe{height:65dvh}}
</style>
<style src="../styles/plugin-overlay.css"></style>
+6 -6
View File
@@ -20,6 +20,7 @@ import { parseSkinExtensionUiInput } from "../../../src/shared/skin-extension-ui
import { approveSkinPluginComponents, getMissingSkinPluginApprovals, isSkinPluginComponentApproved, revokeSkinPluginApprovals } from "../services/skin-plugin-approval.js";
import { createSkinPluginAssetUrlCache } from "../services/skin-plugin-asset-urls.js";
import { PROMPT_FOR_SKIN_PERMISSIONS } from "../services/skin-permission-policy.js";
import { canUseSkin, openInstanceAuthorization } from '../services/instance-authorization.js';
import { useSkinEditorMode } from "../services/skin-editor-mode.js";
type Scalar = string | number | boolean;
@@ -108,14 +109,14 @@ export default defineComponent({
const matchingComponents = computed(() => validatedDocument.value.components.filter((component) => component.page === props.page));
const pendingApproval = computed(() => {
refresh.value;
return denied.value ? [] : getMissingSkinPluginApprovals(props.skinId, props.skinVersion, { ...validatedDocument.value, components: matchingComponents.value });
return denied.value || !canUseSkin(props.skinId) ? [] : getMissingSkinPluginApprovals(props.skinId, props.skinVersion, { ...validatedDocument.value, components: matchingComponents.value });
});
const accessComponents = computed(() => pendingApproval.value.length
? pendingApproval.value
: matchingComponents.value.filter((component) => component.permissions.length > 0));
const activeComponents = computed(() => {
refresh.value;
return matchingComponents.value.filter((component) => isSkinPluginComponentApproved(props.skinId, props.skinVersion, component));
return canUseSkin(props.skinId) ? matchingComponents.value.filter((component) => isSkinPluginComponentApproved(props.skinId, props.skinVersion, component)) : [];
});
const surfaceCandidate = computed(() => activeComponents.value.find((component) => component.mode === "surface") ?? null);
const activeSurface = computed(() => surfaceSuppressed.value ? null : surfaceCandidate.value);
@@ -220,7 +221,7 @@ export default defineComponent({
function dispatch(component: SkinPluginComponent, actionId: string, context: SafeContext, state: Record<string, Scalar>): void {
const definition = component.actions[actionId];
if (!definition || !isSkinPluginComponentApproved(props.skinId, props.skinVersion, component)) return;
if (!definition || !canUseSkin(props.skinId) || !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) {
@@ -244,7 +245,7 @@ export default defineComponent({
}
function dispatchRuntimeCallback(component: SkinPluginComponent, handlerId: string, eventName: string, event: Event, state: Record<string, Scalar>): void {
if (!component.runtimeCallbacks) return;
if (!canUseSkin(props.skinId) || !component.runtimeCallbacks) return;
const callbackEvent: Record<string, unknown> = { componentId: component.id, handlerId, eventName };
if (typeof KeyboardEvent !== "undefined" && event instanceof KeyboardEvent) callbackEvent.key = event.key;
const mayReadUserInput = props.extensionPermissions.includes("ui.input.read");
@@ -419,8 +420,7 @@ export default defineComponent({
}
function openAccessManager(): void {
denied.value = false;
manageOpen.value = true;
openInstanceAuthorization();
}
function closeOrDisable(): void {
+11 -1
View File
@@ -8,6 +8,7 @@ import { SKIN_RUNTIME_PLUGIN_DATA_PERMISSIONS } from "../../../src/shared/skin-r
import SkinPluginOutlet from "./SkinPluginOutlet.js";
import { approveSkinRuntimePlugin, getSkinRuntimePluginApproval, revokeSkinRuntimePluginApprovals } from "../services/skin-runtime-plugin-approval.js";
import { PROMPT_FOR_SKIN_PERMISSIONS } from "../services/skin-permission-policy.js";
import { canUseSkin, openInstanceAuthorization } from '../services/instance-authorization.js';
import { useSkinEditorMode } from "../services/skin-editor-mode.js";
import { createSkinRuntimePluginSession } from "../services/skin-runtime-plugin-session.js";
import { createSkinRuntimePluginWasmSandbox } from "../services/skin-runtime-plugin-wasm.js";
@@ -63,6 +64,7 @@ function createRun(
skinVersion,
plugin,
approval,
signal: abortController.signal,
files,
uiInput: input,
context,
@@ -133,6 +135,7 @@ export default defineComponent({
const pagePlugins = computed(() => props.plugins?.plugins.filter((plugin) => plugin.page === props.page) ?? []);
const approved = (plugin: SkinRuntimePlugin): SkinRuntimePluginApproval | null => {
if (!canUseSkin(props.skinId)) return null;
const digest = digests.value[plugin.id];
if (!digest) return null;
const memoryGrant = inMemoryApprovals.get(plugin.id);
@@ -243,6 +246,7 @@ export default defineComponent({
await handler(action.args);
},
onOutput: () => {
if (!canUseSkin(props.skinId) || disposed || sessions.get(plugin.id) !== session) return;
installStyle(plugin);
outputs.value = { ...outputs.value, [plugin.id]: session.output };
digestErrors.value = { ...digestErrors.value, [plugin.id]: "" };
@@ -257,6 +261,7 @@ export default defineComponent({
function reconcile(): void {
if (disposed) return;
if (!canUseSkin(props.skinId)) { stopAll('instance-authorization-revoked'); return; }
const currentIds = new Set(pagePlugins.value.map((plugin) => plugin.id));
for (const pluginId of [...sessions.keys()]) if (!currentIds.has(pluginId)) stopPlugin(pluginId, "page-changed");
for (const plugin of pagePlugins.value) {
@@ -266,6 +271,7 @@ export default defineComponent({
}
function approvePending(): void {
if (!canUseSkin(props.skinId)) return;
for (const plugin of pending.value) {
const digest = digests.value[plugin.id];
if (!digest) continue;
@@ -294,7 +300,7 @@ export default defineComponent({
}
function openManager(): void {
managerOpen.value = true;
openInstanceAuthorization();
}
function dispatch(pluginId: string, value: unknown): void {
@@ -342,6 +348,10 @@ export default defineComponent({
}, { immediate: true });
watch(() => [props.page, digests.value, revision.value], reconcile, { deep: true });
watch(() => canUseSkin(props.skinId), allowed => {
if (!allowed) { stopAll('instance-authorization-revoked'); managerOpen.value = false; }
else approvePending();
}, { flush: 'sync' });
watch(editorMode.isEnabled, (enabled) => { if (!enabled) managerOpen.value = false; });
watch(() => props.context, () => {
if (disposed) return;
+10 -1
View File
@@ -35,6 +35,9 @@
<span>{{ option.label }}</span>
<Icon v-if="modelValue === option.value" name="check" :size="14" />
</button>
<button type="button" class="skin-option skin-authorization" role="option" :aria-selected="false" @click="authorization">
<Icon name="shield" :size="16" /><span>{{ authorizationCopy.menu }}</span><small>{{ thirdPartyAllowed ? authorizationCopy.enabled : authorizationCopy.disabled }}</small>
</button>
</div>
</div>
</template>
@@ -42,6 +45,8 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from "vue";
import Icon from "./Icon.vue";
import { authorizationLanguage, canUseSkin, openInstanceAuthorization, thirdPartyAllowed } from '../services/instance-authorization.js';
import { instanceAuthorizationCopy } from '../i18n/instance-authorization.js';
export interface SkinOption {
value: string;
@@ -60,7 +65,9 @@ const emit = defineEmits<{
change: [value: string];
}>();
const options = computed(() => props.options);
const options = computed(() => props.options.filter(option => canUseSkin(option.value)));
const authorizationCopy = computed(() => instanceAuthorizationCopy[authorizationLanguage.value]);
function authorization() { close(); openInstanceAuthorization(); }
const selectedOption = computed(() => options.value.find((option) => option.value === props.modelValue) ?? options.value[0] ?? {
value: props.modelValue,
label: props.menuLabel,
@@ -92,6 +99,8 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
flex: 0 0 auto;
color: var(--text-muted);
}
.skin-authorization{margin-top:6px;border-top:1px solid #8bdad8!important}
.skin-authorization small{margin-left:auto;font-size:10px;opacity:.75}
.skin-trigger {
display: inline-flex;
+10 -7
View File
@@ -1,14 +1,16 @@
<template>
<section class="page-content plugin-admin">
<header class="plugin-hero">
<div><span class="plugin-eyebrow"><Icon name="grid" :size="14" /> EXTENSIONS</span><h2>{{ tr('store') }}</h2><p>{{ tr('lead') }}</p><div class="plugin-metrics"><span><b>{{ model.catalog.value?.entries.length ?? '—' }}</b>{{ text('available') }}</span><i></i><span><b>{{ model.installed.value.length }}</b>{{ tr('installed') }}</span><i></i><span><b>{{ enabledCount }}</b>{{ text('active') }}</span></div></div>
<div><span class="plugin-eyebrow"><Icon name="grid" :size="14" /> APPS</span><h2>{{ tr('store') }}</h2><p>{{ tr('lead') }}</p><div class="plugin-metrics"><span><b>{{ model.catalog.value?.entries.length ?? '—' }}</b>{{ text('available') }}</span><i></i><span><b>{{ model.installed.value.length }}</b>{{ tr('installed') }}</span><i></i><span><b>{{ enabledCount }}</b>{{ text('active') }}</span></div></div>
<div class="plugin-hero-art" aria-hidden="true"><i></i><i></i><i></i><i></i><b>+</b></div>
</header>
<details class="plugin-runtime-settings"><summary><Icon name="server" :size="16" />{{ tr('runtime') }}<span class="plugin-status" :class="{active:model.runtime.value?.available}"><i></i>{{ tr(model.runtime.value?.available?'running':'stopped') }} · {{ model.runtime.value?.port ?? '—' }}</span></summary><p>{{ tr('originHelp') }}</p><form @submit.prevent="model.saveRuntime"><label>{{ tr('origin') }}<input v-model="model.origin.value" type="url" placeholder="https://apps.example.com" :disabled="model.busy.value" /></label><button class="plugin-button primary" type="submit" :disabled="model.busy.value || !model.runtime.value">{{ tr('save') }}</button></form></details>
<div class="plugin-toolbar">
<nav class="plugin-tabs" :aria-label="tr('store')"><button type="button" :aria-current="tab==='store'?'page':undefined" @click="tab='store'"><Icon name="compass" :size="16" />{{ text('discover') }}</button><button type="button" :aria-current="tab==='installed'?'page':undefined" @click="tab='installed'"><Icon name="grid" :size="16" />{{ tr('installed') }}<span>{{ model.installed.value.length }}</span></button></nav>
<div class="plugin-tools"><label class="plugin-search"><Icon name="search" :size="16" /><input v-model="search" type="search" :aria-label="text('search')" :placeholder="text('search')" /></label><button class="plugin-refresh" type="button" :disabled="model.busy.value" :title="tr('refresh')" :aria-label="tr('refresh')" @click="model.load"><Icon name="refresh" :size="17" /></button></div>
</div>
<p v-if="model.error.value" class="plugin-feedback is-error" role="alert"><Icon name="info" :size="17" />{{ tr('error') }}: {{ model.error.value }}</p>
<p v-if="tab==='store' && model.catalogError.value" class="plugin-feedback is-error" role="alert"><Icon name="info" :size="17" />{{ tr('catalogError') }} · {{ model.catalogError.value }}</p>
<p v-if="notice" class="plugin-feedback" role="status"><Icon name="check" :size="17" />{{ notice }}</p>
<div class="plugin-section-heading"><div><h3>{{ tab==='store'?text('discover'):tr('installed') }}</h3><span v-if="tab==='store'" class="plugin-source"><i></i>{{ text('source') }}</span></div><a v-if="tab==='store'" :href="PLUGIN_STORE_REPOSITORY" target="_blank" rel="noopener noreferrer"><Icon name="github" :size="16" />GitHub ↗</a><button v-else class="plugin-button" type="button" :disabled="model.busy.value" @click="fileInput?.click()"><Icon name="share" :size="15" />{{ tr('upload') }}</button></div>
<input ref="fileInput" class="plugin-file-input" type="file" accept=".wplugin,application/json" @change="upload" />
@@ -16,21 +18,21 @@
<div v-if="tab==='store'" class="plugin-store-grid">
<article v-for="entry in catalogEntries" :key="entry.id" class="plugin-market-card">
<div class="plugin-card-visual"><div class="plugin-card-symbol"><Icon name="grid" :size="38" /></div><span>API {{ entry.manifest?.apiVersion ?? '—' }}</span><i aria-hidden="true"></i></div>
<div class="plugin-card-body"><div class="plugin-card-title"><h4>{{ entry.manifest?.name ?? entry.id }}</h4><small>v{{ entry.manifest?.version ?? '—' }}</small></div><p class="plugin-author">{{ entry.manifest?.author }} · {{ entry.manifest?.license }}</p><p class="plugin-description">{{ entry.manifest?.description }}</p><div class="plugin-tags"><span v-for="scope in entry.manifest?.scopes" :key="scope"><Icon name="server" :size="12" />{{ tr(scope) }}</span></div><div class="plugin-permissions"><span v-for="permission in entry.manifest?.permissions" :key="permission"><Icon name="check" :size="12" />{{ text(permission==='room.read'?'read':'write') }}</span></div><p v-if="entry.error" class="is-error">{{ entry.error }}</p></div>
<div class="plugin-card-body"><div class="plugin-card-title"><h4>{{ entry.manifest?.name ?? entry.id }}</h4><small>v{{ entry.manifest?.version ?? '—' }}</small></div><p class="plugin-author">{{ entry.manifest?.author }} · {{ entry.manifest?.license }}</p><p class="plugin-description">{{ entry.manifest?.description }}</p><div class="plugin-tags"><span v-for="scope in entry.manifest?.scopes" :key="scope"><Icon name="server" :size="12" />{{ tr(scope) }}</span></div><div class="plugin-permissions"><span>{{ tr('client') }}</span><span v-if="entry.manifest?.server">{{ tr('backend') }}</span></div><p v-if="entry.error" class="is-error">{{ entry.error }}</p></div>
<footer><a :href="entry.repository" target="_blank" rel="noopener noreferrer" :aria-label="`${entry.manifest?.name ?? entry.id} · GitHub`"><Icon name="github" :size="16" />GitHub ↗</a><button class="plugin-button primary" type="button" :disabled="model.busy.value || !entry.manifest || !!entry.error" @click="install(entry)"><Icon name="download" :size="15" />{{ installLabel(entry) }}</button></footer>
</article>
</div>
<div v-else class="plugin-installed-list">
<article v-for="plugin in installedEntries" :key="plugin.manifest.id" class="plugin-installed-card">
<header><div class="plugin-installed-icon"><Icon name="grid" :size="23" /></div><div class="plugin-installed-name"><h4>{{ plugin.manifest.name }}</h4><p>v{{ plugin.manifest.version }} · {{ plugin.manifest.author }}</p></div><span class="plugin-status" :class="{active:plugin.settings.enabled}"><i></i>{{ text(plugin.settings.enabled?'active':'inactive') }}</span></header>
<p class="plugin-description">{{ plugin.manifest.description }}</p><div class="plugin-installed-meta"><span><Icon name="server" :size="13" />{{ tr(plugin.settings.scope) }}</span><span>{{ plugin.manifest.license }}</span><span>API {{ plugin.manifest.apiVersion }}</span></div>
<header><div class="plugin-installed-icon"><Icon name="grid" :size="23" /></div><div class="plugin-installed-name"><h4>{{ plugin.manifest.name }}</h4><p>v{{ plugin.manifest.version }} · {{ plugin.manifest.author }}</p></div><span class="plugin-status" :class="{active:plugin.settings.enabled}"><i></i>{{ tr(plugin.runtime?.state ?? 'disabled') }}</span></header>
<p class="plugin-description">{{ plugin.manifest.description }}</p><p v-if="plugin.runtime?.error" class="is-error" role="alert">{{ plugin.runtime.error }}</p><div class="plugin-installed-meta"><span><Icon name="server" :size="13" />{{ tr(plugin.settings.scope) }}</span><span>{{ plugin.manifest.license }}</span><span>API {{ plugin.manifest.apiVersion }}</span></div>
<details :open="expanded===plugin.manifest.id" @toggle="onToggle($event,plugin.manifest.id)"><summary><Icon name="settings" :size="16" />{{ text('configure') }}<Icon class="plugin-chevron" name="chevron-down" :size="15" /></summary><fieldset :disabled="model.busy.value">
<div class="plugin-enable-row"><div><strong>{{ tr('enabled') }}</strong><p>{{ text('review') }}</p></div><label class="plugin-switch"><input v-model="model.drafts[plugin.manifest.id].enabled" type="checkbox" :aria-label="tr('enabled')" /><span></span></label></div>
<div class="plugin-permissions"><span v-for="permission in plugin.manifest.permissions" :key="permission"><Icon name="shield" :size="13" />{{ text(permission==='room.read'?'read':'write') }}</span></div>
<label class="plugin-trust"><input v-model="model.drafts[plugin.manifest.id].trusted" type="checkbox" />{{ tr('trust') }}</label><p class="plugin-trust-note">{{ tr('enableNote') }}</p>
<label>{{ tr('scope') }}<select v-model="model.drafts[plugin.manifest.id].scope"><option v-for="scope in plugin.manifest.scopes" :key="scope" :value="scope">{{ tr(scope) }}</option></select></label>
<label v-if="model.drafts[plugin.manifest.id].scope==='server'">{{ tr('targets') }}<textarea v-model="model.drafts[plugin.manifest.id].targets" rows="3" maxlength="15000" placeholder="voice.example.com:9987"></textarea></label>
<details class="plugin-advanced"><summary>{{ text('advanced') }}<Icon name="chevron-down" :size="14" /></summary><label>{{ tr('config') }}<textarea v-model="model.drafts[plugin.manifest.id].config" rows="5" maxlength="8192" spellcheck="false"></textarea></label></details>
<div class="plugin-settings-actions"><button class="plugin-button danger" type="button" @click="remove(plugin)"><Icon name="trash" :size="14" />{{ tr('remove') }}</button><button class="plugin-button primary" type="button" @click="save(plugin)"><Icon name="check" :size="15" />{{ tr('save') }}</button></div>
<details class="plugin-advanced"><summary>{{ text('advanced') }}<Icon name="chevron-down" :size="14" /></summary><label>{{ tr('config') }}<textarea v-model="model.drafts[plugin.manifest.id].config" rows="5" maxlength="65536" spellcheck="false"></textarea></label><template v-if="plugin.manifest.server"><label>{{ tr('privateConfig') }}<small>{{ tr(plugin.settings.hasServerConfig?'secretSaved':'secretEmpty') }}</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><textarea v-if="model.drafts[plugin.manifest.id].serverConfigAction==='replace'" v-model="model.drafts[plugin.manifest.id].serverConfig" rows="5" maxlength="65536" spellcheck="false" autocomplete="off" autocapitalize="off" autocorrect="off"></textarea></label></template></details>
<div class="plugin-settings-actions"><button v-if="plugin.manifest.server" class="plugin-button" type="button" :disabled="!plugin.settings.enabled" @click="model.restart(plugin)">{{ tr('restart') }}</button><button class="plugin-button danger" type="button" @click="remove(plugin)"><Icon name="trash" :size="14" />{{ tr('remove') }}</button><button class="plugin-button primary" type="button" @click="save(plugin)"><Icon name="check" :size="15" />{{ tr('save') }}</button></div>
</fieldset></details>
</article>
</div>
@@ -80,4 +82,5 @@ section.page-content.plugin-admin{display:grid;grid-template-columns:minmax(0,1f
.plugin-installed-card fieldset>label,.plugin-advanced label{display:grid;gap:8px;color:var(--admin-muted);font-size:11px}.plugin-installed-card textarea,.plugin-installed-card select{width:100%;min-width:0;max-width:100%;border:1px solid var(--admin-border);padding:10px 12px;border-radius:8px;background:var(--admin-field);color:var(--admin-text);font-size:12px}.plugin-installed-card textarea{resize:vertical;line-height:1.7}.plugin-advanced{border:1px solid var(--admin-border);border-radius:9px;padding:0 12px}.plugin-advanced summary{display:flex;align-items:center;justify-content:space-between;font-size:11px;color:var(--admin-muted);padding:12px 0;cursor:pointer}.plugin-advanced label{padding-bottom:12px}.plugin-advanced textarea{font-family:ui-monospace,monospace}.plugin-settings-actions{display:flex;justify-content:space-between;gap:12px;padding-top:4px}.plugin-scope-help{margin-top:8px;border-top:1px solid var(--admin-border);padding-top:20px;color:var(--admin-muted);font-size:11px}.plugin-scope-help summary{display:flex;gap:8px;align-items:center;cursor:pointer;width:fit-content}.plugin-scope-help p{line-height:1.8;margin-top:12px;max-width:850px}.plugin-empty{display:grid;justify-items:center;gap:16px;padding:60px 20px;color:var(--admin-muted);text-align:center;border:1px dashed var(--admin-border);border-radius:16px}.plugin-empty h4{font-size:14px}.plugin-admin :is(button,a,input,textarea,select,summary):focus-visible{outline:3px solid color-mix(in srgb,var(--admin-accent) 35%,transparent);outline-offset:3px}
@media(max-width:1100px){.plugin-hero-art{width:100px;flex-basis:100px;margin-right:0}.plugin-hero{padding:26px}.plugin-tools{flex:1;justify-content:end}.plugin-search{flex:1;max-width:320px}.plugin-search input{width:100%}}
@media(max-width:600px){.plugin-admin{gap:18px}.plugin-hero{padding:24px 20px;border-radius:16px}.plugin-hero h2{font-size:25px}.plugin-hero p{font-size:12px}.plugin-hero-art{position:absolute;width:110px;right:-28px;top:-35px;opacity:.12}.plugin-metrics{gap:12px}.plugin-metrics>span{gap:6px;font-size:10px}.plugin-metrics b{font-size:18px}.plugin-tabs,.plugin-tools{width:100%}.plugin-tabs button{flex:1;justify-content:center;padding:8px 10px}.plugin-search{max-width:none}.plugin-section-heading>div{gap:8px}.plugin-section-heading h3{font-size:14px}.plugin-source{font-size:9px}.plugin-card-body{padding:18px}.plugin-market-card{max-width:none}.plugin-installed-card>header{padding:18px 16px 12px;flex-wrap:wrap;gap:10px}.plugin-installed-icon{width:40px;height:40px}.plugin-installed-name h4{font-size:13px}.plugin-status{font-size:9px}.plugin-installed-card>.plugin-description,.plugin-installed-meta{padding-left:16px;padding-right:16px}.plugin-installed-card>details>summary{padding:14px 16px}.plugin-installed-card fieldset{padding:4px 16px 16px}.plugin-enable-row{padding:12px}}
.plugin-runtime-settings{border:1px solid var(--admin-border);border-radius:14px;background:var(--admin-surface);padding:18px}.plugin-runtime-settings>summary{display:flex;align-items:center;gap:12px;cursor:pointer;font-weight:650}.plugin-runtime-settings>p{margin:16px 0;color:var(--admin-muted);font-size:12px;line-height:1.7}.plugin-runtime-settings form{display:flex;align-items:end;gap:14px;flex-wrap:wrap}.plugin-runtime-settings label{display:grid;flex:1;gap:8px;font-size:12px;min-width:min(100%,260px)}.plugin-runtime-settings input{width:100%;box-sizing:border-box;border:1px solid var(--admin-border);border-radius:9px;padding:10px;background:var(--admin-raised);color:var(--admin-text)}.plugin-trust{display:flex!important;align-items:start!important;gap:10px!important;font-weight:650}.plugin-trust input{width:auto!important;margin-top:3px;flex:none}.plugin-trust-note{font-size:12px;color:var(--admin-muted);line-height:1.7}.plugin-advanced label>small{color:var(--admin-muted);font-weight:400}.plugin-settings-actions{flex-wrap:wrap}
</style>