fix(skins): expose screen-share status to custom members

This commit is contained in:
illusia committed 2026-10-11 23:06:06 +08:00
1 parent 7fe8719812
commit 8b5db8af1f
20 files changed
+295 -41

No files matched your search

+18 -10
View File
@@ -246,14 +246,20 @@ const COLLECTION_PERMISSION: Record<string, SkinPluginPermission> = {
"chat.messages": "chat.channel.read",
"screenShare.streams": "voice.screenShare.read",
};
const COLLECTION_FIELDS: Record<string, ReadonlySet<string>> = {
"session.channels": new Set(["id", "name", "parentId", "depth", "memberCount", "memberCountLabel", "maxClients", "maxClientsLimited", "current"]),
"session.members": new Set(["id", "name", "avatarInitial", "channelId", "status", "speaking", "self"]),
const COLLECTION_FIELDS: Record<string, ReadonlySet<string>> = {
"session.channels": new Set(["id", "name", "parentId", "depth", "memberCount", "memberCountLabel", "maxClients", "maxClientsLimited", "current"]),
"session.members": new Set(["id", "name", "avatarInitial", "channelId", "status", "speaking", "self", "screenSharing", "screenShareStreamId"]),
"favorites.items": new Set(["id", "label", "current", "kind"]),
"servers.quickList": new Set(["id", "label", "monogram", "icon", "tone", "current", "kind", "favorite"]),
"chat.messages": new Set(["id", "author", "text", "time", "kind", "channelId"]),
"screenShare.streams": new Set(["streamId", "source", "ownerClientId", "ownerNickname", "name", "audio", "viewerCount"]),
};
"screenShare.streams": new Set(["streamId", "source", "ownerClientId", "ownerNickname", "name", "audio", "viewerCount"]),
};
const COLLECTION_FIELD_PERMISSIONS: Record<string, Partial<Record<string, SkinPluginPermission>>> = {
"session.members": {
screenSharing: "voice.screenShare.read",
screenShareStreamId: "voice.screenShare.read",
},
};
const SESSION_STATUS_FIELDS = new Set(["connected", "connecting", "connectionState", "serverLabel", "channelId", "channelName", "userName"]);
const CONTEXT_FIELDS: Record<string, ReadonlySet<string>> = {
"audio.status": new Set(["microphoneMuted", "outputMuted"]),
@@ -299,11 +305,13 @@ function bindingPermissions(value: string, aliases: ReadonlyMap<string, string>,
if (path.length !== 2 || !stateKeys.has(path[1])) fail("SKIN_PLUGIN_BINDING_INVALID", "A state binding must reference a declared local state key.");
continue;
}
const aliasCollection = aliases.get(path[0]);
if (aliasCollection) {
if (path.length !== 2 || !COLLECTION_FIELDS[aliasCollection]?.has(path[1])) fail("SKIN_PLUGIN_BINDING_INVALID", "A repeated item binding references an unsupported public field.");
continue;
}
const aliasCollection = aliases.get(path[0]);
if (aliasCollection) {
if (path.length !== 2 || !COLLECTION_FIELDS[aliasCollection]?.has(path[1])) fail("SKIN_PLUGIN_BINDING_INVALID", "A repeated item binding references an unsupported public field.");
const fieldPermission = COLLECTION_FIELD_PERMISSIONS[aliasCollection]?.[path[1]];
if (fieldPermission) found.add(fieldPermission);
continue;
}
if (path[0] === "session" && path.length === 3 && path[1] === "status" && SESSION_STATUS_FIELDS.has(path[2])) {
found.add("session.status.read");
continue;