mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat: add host chrome theming and a skin-proof recovery layer
Allow skins to theme host chrome through a second scope and explicit visibleParts. Official and built-in skins stay decoration-free by default. Harden the CSS compiler so skins cannot hide the document root, push protected controls off-screen, or target the host layer with sibling selectors. Move recovery and authorization UI into a closed Shadow DOM on the top layer, so a third-party skin cannot block the built-in skin reset.
This commit is contained in:
1 parent
33ba062686
commit
f8d61d22ef
45 files changed
+3535
-558
No files matched your search
@@ -4,6 +4,7 @@ import { listInstalledSkins, loadLocalPreferences, saveLocalPreferences } from "
|
||||
import { BUILTIN_SKIN_CATALOG, getPublicDefaultSkinId, isPublicSkinEnabled, listPublicSkins, type SkinCatalogEntry } from "../services/skin-catalog.js";
|
||||
import { activateSkin, BUILTIN_DARK_SKIN, BUILTIN_LIGHT_SKIN, clearCustomSkinStyle, getStoredSkinId } from "../services/skin-runtime.js";
|
||||
import { createSkinOperation } from "../services/skin-operation.js";
|
||||
import { setSkinHostChromeParts, setHostChromeActiveSkin, hostBuiltInSkinRequests } from "../services/host-chrome.js";
|
||||
import { getStoredTheme, isDarkTheme, saveTheme, type ThemeMode } from "../services/theme.js";
|
||||
import type { InstalledSkin } from "../services/skin-pack.js";
|
||||
|
||||
@@ -36,6 +37,14 @@ export function usePublicSkin(options: PublicSkinOptions = {}) {
|
||||
return current = createSkinOperation({ timeoutMs: options.timeoutMs });
|
||||
}
|
||||
onScopeDispose(() => { disposed = true; cancel(); });
|
||||
// Host decorations depend on the active skin's chrome.json opt-in. Built-in
|
||||
// skins leave `activeSkin` empty, which keeps host chrome hidden by default.
|
||||
// Only `visibleParts` opts in: chrome.json hiddenParts/icons generate host
|
||||
// CSS containing `data-ws-part="host.…"`, so inspecting the combined stylesheet
|
||||
// would wrongly treat every hiddenParts-only pack as host-chrome themed.
|
||||
watch(activeSkin, (skin) => setSkinHostChromeParts(skin?.chromeData), { immediate: true, flush: "sync" });
|
||||
// The recovery affordance is persistent while a non-bundled skin is applied.
|
||||
watch(activeSkinId, (id) => setHostChromeActiveSkin(id), { immediate: true, flush: "sync" });
|
||||
|
||||
async function apply(id: string, operation: ReturnType<typeof createSkinOperation>, persist = true, updateTheme = false, clearLoadError = true) {
|
||||
operation.check();
|
||||
@@ -133,6 +142,10 @@ export function usePublicSkin(options: PublicSkinOptions = {}) {
|
||||
skinReady.value = true;
|
||||
void select(fallbackId());
|
||||
}, { flush: 'sync' });
|
||||
// Host-owned recovery's guaranteed action: reset to the built-in skin. It is
|
||||
// independent of the skinnable plugin overlay, so it also works when that
|
||||
// overlay is hidden with `display: none`.
|
||||
watch(hostBuiltInSkinRequests, () => { if (!disposed) void switchToBuiltIn(); }, { flush: 'sync' });
|
||||
return { activeSkin, activeSkinId, skinReady, skinLoadError,
|
||||
installedSkins: computed(() => installedSkins.value.filter(skin => canUseSkin(skin.id))),
|
||||
catalogSkins: computed(() => catalogSkins.value.filter(skin => canUseSkin(skin.id))),
|
||||
|
||||
Reference in new issue
Block a user