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:
OddTurtleHead committed 2026-11-11 18:06:20 +08:00
1 parent 33ba062686
commit f8d61d22ef
45 files changed
+3535 -558

No files matched your search

+9 -1
View File
@@ -13,7 +13,7 @@
:aria-controls="menuId"
@click.stop="toggle"
>
<Icon :name="selectedOption.icon || 'compass'" :size="15" />
<Icon :name="selectedOption.icon || 'compass'" :size="15" data-ws-icon-slot="skin.trigger" />
<span>{{ menuLabel }}</span>
<Icon name="chevron-down" :size="12" />
</button>
@@ -38,6 +38,9 @@
<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>
<button v-if="thirdPartyAllowed" type="button" class="skin-option skin-library" data-ws-part="skin.library" role="option" :aria-selected="false" @click="openLibrary">
<Icon name="grid" :size="16" /><span>{{ libraryLabel }}</span>
</button>
</div>
</div>
</template>
@@ -47,6 +50,8 @@ 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';
import { hostChromeCopy } from '../i18n/host-chrome.js';
import { openPluginLibrary } from '../services/host-chrome.js';
export interface SkinOption {
value: string;
@@ -67,7 +72,9 @@ const emit = defineEmits<{
const options = computed(() => props.options.filter(option => canUseSkin(option.value)));
const authorizationCopy = computed(() => instanceAuthorizationCopy[authorizationLanguage.value]);
const libraryLabel = computed(() => hostChromeCopy[authorizationLanguage.value]?.library ?? hostChromeCopy.en.library);
function authorization() { close(); openInstanceAuthorization(); }
function openLibrary() { close(); openPluginLibrary(); }
const selectedOption = computed(() => options.value.find((option) => option.value === props.modelValue) ?? options.value[0] ?? {
value: props.modelValue,
label: props.menuLabel,
@@ -101,6 +108,7 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
}
.skin-authorization{margin-top:6px;border-top:1px solid #8bdad8!important}
.skin-authorization small{margin-left:auto;font-size:10px;opacity:.75}
.skin-library{opacity:.9}
.skin-trigger {
display: inline-flex;