orca/src/main/plugins/plugin-command-invocation.ts

14 lines
670 B
TypeScript

import type { ValidDiscoveredPlugin } from './plugin-discovery'
export function assertPluginWorkerCommand(plugin: ValidDiscoveredPlugin, commandId: string): void {
const command = plugin.manifest.contributes.commands.find((entry) => entry.id === commandId)
if (!command) {
throw new Error(`plugin ${plugin.pluginKey} does not contribute command ${commandId}`)
}
// Declarative aliases are renderer-owned and must never cross the worker
// activation boundary, even if a compromised renderer invokes IPC directly.
if (command.action !== undefined) {
throw new Error(`plugin ${plugin.pluginKey} command ${commandId} is a built-in action alias`)
}
}