import { CommandEvent, CompositeDisposable, Disposable } from "../index"; export interface CommandRegistryTargetMap extends HTMLElementTagNameMap { [key: string]: EventTarget; } export type CommandRegistryListener = | { didDispatch(event: CommandEvent): void | Promise; displayName?: string | undefined; description?: string | undefined; hiddenInCommandPalette?: boolean | undefined; } | ((event: CommandEvent) => void | Promise); /** * Associates listener functions with commands in a context-sensitive way * using CSS selectors. */ export interface CommandRegistry { /** Register a single command. */ add( target: T, commandName: string, listener: CommandRegistryListener, ): Disposable; /** Register a single command. */ add(target: T, commandName: string, listener: CommandRegistryListener): Disposable; /** Register multiple commands. */ add( target: T, commands: { [key: string]: CommandRegistryListener; }, ): CompositeDisposable; /** Register multiple commands. */ add( target: T, commands: { [key: string]: CommandRegistryListener; }, ): CompositeDisposable; /** Find all registered commands matching a query. */ findCommands(params: { target: string | Node; }): Array<{ name: string; displayName: string; description?: string | undefined; tags?: string[] | undefined; }>; /** * Simulate the dispatch of a command on a DOM node. * @return Either a Promise that resolves after all handlers complete or null if * no handlers were matched. */ dispatch(target: Node, commandName: string): Promise | null; /** Invoke the given callback before dispatching a command event. */ onWillDispatch(callback: (event: CommandEvent) => void): Disposable; /** Invoke the given callback after dispatching a command event. */ onDidDispatch(callback: (event: CommandEvent) => void): Disposable; }