import { createDecorator, Provide } from '@alilc/lowcode-shared'; import { Registry } from '../extension'; import { ICommandRegistry, Extension } from './commandRegistry'; export interface ICommandService { executeCommand(commandId: string, ...args: any[]): Promise; } export const ICommandService = createDecorator('commandService'); @Provide(ICommandService) export class CommandService implements ICommandService { executeCommand(id: string, ...args: any[]): Promise { const command = Registry.as(Extension.command).getCommand(id); if (!command) { return Promise.reject(new Error(`command '${id}' not found`)); } } }