2.19 kBTypeScriptView Raw
1import { CommandRegistry } from '../command';
2import { Disposable } from '../disposable';
3import { MenuPath } from './menu-types';
4export declare type MenuCommandArguments = [menuPath: MenuPath, command: string, ...commandArgs: unknown[]];
5export declare const MenuCommandExecutor: unique symbol;
6export interface MenuCommandExecutor {
7 isVisible(...args: MenuCommandArguments): boolean;
8 isEnabled(...args: MenuCommandArguments): boolean;
9 isToggled(...args: MenuCommandArguments): boolean;
10 executeCommand(...args: MenuCommandArguments): Promise<unknown>;
12export declare const MenuCommandAdapter: unique symbol;
13export interface MenuCommandAdapter extends MenuCommandExecutor {
14 /** Return values less than or equal to 0 are treated as rejections. */
15 canHandle(...args: MenuCommandArguments): number;
17export declare const MenuCommandAdapterRegistry: unique symbol;
18export interface MenuCommandAdapterRegistry {
19 registerAdapter(adapter: MenuCommandAdapter): Disposable;
20 getAdapterFor(...args: MenuCommandArguments): MenuCommandAdapter | undefined;
22export declare class MenuCommandExecutorImpl implements MenuCommandExecutor {
23 protected readonly adapterRegistry: MenuCommandAdapterRegistry;
24 protected readonly commandRegistry: CommandRegistry;
25 executeCommand(menuPath: MenuPath, command: string, ...commandArgs: unknown[]): Promise<unknown>;
26 isVisible(menuPath: MenuPath, command: string, ...commandArgs: unknown[]): boolean;
27 isEnabled(menuPath: MenuPath, command: string, ...commandArgs: unknown[]): boolean;
28 isToggled(menuPath: MenuPath, command: string, ...commandArgs: unknown[]): boolean;
29 protected delegate<T extends keyof MenuCommandExecutor>(menuPath: MenuPath, command: string, commandArgs: unknown[], method: T): ReturnType<MenuCommandExecutor[T]>;
31export declare class MenuCommandAdapterRegistryImpl implements MenuCommandAdapterRegistry {
32 protected readonly adapters: MenuCommandAdapter[];
33 registerAdapter(adapter: MenuCommandAdapter): Disposable;
34 getAdapterFor(menuPath: MenuPath, command: string, ...commandArgs: unknown[]): MenuCommandAdapter | undefined;
36//# sourceMappingURL=menu-adapter.d.ts.map
\No newline at end of file