feat(skin): expose visitor count widget for skins

This commit is contained in:
illusia committed 2026-10-14 00:43:43 +08:00
1 parent 26c638c2a2
commit 42a0755ad0
14 files changed
+256 -159

No files matched your search

+6
View File
@@ -162,6 +162,12 @@ const PUBLIC_PART_IDS = new Set<string>([
"home.server-history.select",
"home.server-target",
"home.visitors",
"home.visitors.divider",
"home.visitors.icon",
"home.visitors.label",
"home.visitors.orbit",
"home.visitors.spark",
"home.visitors.total",
"language.menu",
"language.option",
"language.trigger",
+17
View File
@@ -237,6 +237,22 @@ test("home connection status widget requires the public session status permissio
assert.deepEqual(skinPluginWidgetPermissions("home.connection-status"), ["session.status.read"]);
});
test("visitor count is a permission-free public home widget and cannot mount on other pages", () => {
const document = validDocument();
document.schemaVersion = 3;
document.components[0].page = "home";
document.components[0].permissions = [];
document.components[0].actions = {};
document.components[0].root = { tag: "main", children: [{ widget: "home.visitor-count", part: "visitors" }] };
const parsed = parseSkinPluginDocument(document);
assert.equal(parsed.components[0].root.children?.[0].widget, "home.visitor-count");
assert.deepEqual(skinPluginWidgetPermissions("home.visitor-count"), []);
document.components[0].page = "voice";
errorCode(() => parseSkinPluginDocument(document), "SKIN_PLUGIN_WIDGET_INVALID");
});
test("generic identity-provider entry is a host button with no connection permission or skin action", () => {
const document = validDocument();
document.schemaVersion = 3;
@@ -519,6 +535,7 @@ test("KAAK v3 example declares the connection home and complete voice workspace"
const heroMedia = home.root.children?.[0].children?.[3];
assert.equal(heroMedia?.part, "hero-media");
assert.equal(heroMedia?.children?.[0].tag, "svg");
assert.equal(heroMedia?.children?.[1].widget, "home.visitor-count");
assert.equal(workspace.page, "voice");
assert.equal(workspace.mode, "surface");
+2
View File
@@ -45,6 +45,7 @@ export type SkinPluginComponentMode = "widget" | "surface";
export const SKIN_PLUGIN_HOST_WIDGETS = Object.freeze([
"home.connection-form",
"home.connection-status",
"home.visitor-count",
"home.server-announcement",
"home.social-links",
"home.identity-provider",
@@ -470,6 +471,7 @@ export function parseSkinPluginDocument(input: unknown): SkinPluginDocument {
if (rawNode.widget !== undefined) {
if (typeof rawNode.widget !== "string" || !HOST_WIDGETS.has(rawNode.widget)) fail("SKIN_PLUGIN_WIDGET_INVALID", "The component requests an unsupported host widget.");
if (page === "demo") fail("SKIN_PLUGIN_WIDGET_INVALID", "Host widgets are available only on the home and voice client pages.");
if (rawNode.widget === "home.visitor-count" && page !== "home") fail("SKIN_PLUGIN_WIDGET_INVALID", "The visitor count widget is available only on the home page.");
if (rawNode.options !== undefined && inputSchemaVersion < 3) fail("SKIN_PLUGIN_SCHEMA_UNSUPPORTED", "Host widget options require components schema version 3.");
// Preserve existing schema v2 packages; newly authored v3 widgets must declare every
// permission needed by the trusted host UI they embed. Screen-share start was already gated.