export interface ICommand { id: string; label: string; execute: (...args: any[]) => void; icon?: string; /** * Keyboard shortcut, e.g. `"Mod+S"`, `"Control+Shift+K"`, `"F1"`. `Mod` is * Cmd on macOS and Control elsewhere. Shown in menus and the palette. */ keybinding?: string; /** * When this returns `false`, the shortcut does not fire and the palette * hides the command. `executeCommand` still runs it — an explicit call is * the caller's decision. */ when?: () => boolean; /** * Whether the shortcut fires while focus is in a text field. Defaults to * `true` for bindings with Control, Alt or Meta (Mod+S should save from an * editor) and `false` for bare keys and Shift+key, which are typing. */ allowInInputs?: boolean; } type Listener = () => void; export declare class CommandRegistry { private commands; private listeners; private version; /** * Register a command, replacing any existing one with the same id. * * Replacing rather than ignoring is what lets a component register in an * effect: the newest closure wins, so a command never runs against stale * state, and React StrictMode's double mount is harmless. * * @returns A disposer that unregisters this command — and only this one, so * disposing a registration that has since been replaced does nothing. */ registerCommand(command: ICommand): () => void; /** Remove a command. Unknown ids are ignored. */ unregisterCommand(id: string): void; /** Remove every command. For tests; see `resetShell`. */ clear(): void; /** Whether a command with this id is registered. */ hasCommand(id: string): boolean; executeCommand(id: string, ...args: any[]): void; getCommand(id: string): ICommand | undefined; getCommands(): ICommand[]; /** Run `listener` whenever a command is registered or removed. */ subscribe(listener: Listener): () => void; /** Changes on every registration; for `useSyncExternalStore`. */ getVersion(): number; private notify; } export declare const commandRegistry: CommandRegistry; export {};