mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
feat(skin): bridge trusted plugin actions
This commit is contained in:
1 parent
1aa29158ef
commit
35cb6ad6df
13 files changed
+276
-45
No files matched your search
@@ -183,6 +183,9 @@ const ACTION_PERMISSION: Record<SkinPluginAction, SkinPluginPermission | null> =
|
||||
"voice.joinScreenShare": "voice.screenShare.control",
|
||||
"voice.leaveScreenShare": "voice.screenShare.control",
|
||||
};
|
||||
export const SKIN_PLUGIN_ACTION_PERMISSIONS: readonly SkinPluginPermission[] = Object.freeze([...new Set(
|
||||
Object.values(ACTION_PERMISSION).filter((permission): permission is SkinPluginPermission => permission !== null),
|
||||
)]);
|
||||
const COLLECTION_PERMISSION: Record<string, SkinPluginPermission> = {
|
||||
"session.channels": "session.channels.read",
|
||||
"session.members": "session.members.read",
|
||||
@@ -499,6 +502,31 @@ export function parseSkinPluginJson(source: string): SkinPluginDocument {
|
||||
return parseSkinPluginDocument(input);
|
||||
}
|
||||
|
||||
/** Parse a single runtime action using the same schema and permission rules as declarative skin actions. */
|
||||
export function parseSkinPluginRuntimeAction(
|
||||
input: unknown,
|
||||
permissions: readonly SkinPluginPermission[],
|
||||
): SkinPluginActionDefinition {
|
||||
if (!isRecord(input)) fail("SKIN_PLUGIN_ACTION_INVALID", "A runtime action request must be an object.");
|
||||
const parsed = parseSkinPluginDocument({
|
||||
schemaVersion: 3,
|
||||
components: [{
|
||||
id: "runtime-action",
|
||||
name: "Runtime action",
|
||||
page: "voice",
|
||||
accessibleName: "Runtime action",
|
||||
permissions: [...permissions],
|
||||
actions: { request: input },
|
||||
root: { tag: "main", children: [{ text: "Runtime action" }] },
|
||||
}],
|
||||
});
|
||||
const action = parsed.components[0].actions.request;
|
||||
if (!action || action.type === "ui.setState" || action.type === "ui.toggleState") {
|
||||
fail("SKIN_PLUGIN_ACTION_INVALID", "A runtime action request must name a host capability.");
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
export function listSkinPluginAssetPaths(document: SkinPluginDocument): string[] {
|
||||
const paths = new Set<string>();
|
||||
const visit = (node: SkinPluginNode) => {
|
||||
|
||||
Reference in new issue
Block a user