type CommandArguments = Command extends (...args: infer Arguments extends unknown[]) => unknown ? Arguments : never; type CommandResult = Command extends (...args: never[]) => infer Result ? Result : never; export interface OfficeEditorCommandDefinition { canExecute?: (context: Context, ...args: CommandArguments) => boolean; execute: (context: Context, ...args: CommandArguments) => CommandResult; } export type OfficeEditorCommandDefinitions = { [Name in keyof Commands]?: OfficeEditorCommandDefinition; }; export type OfficeEditorCanCommands = { [Name in keyof Commands]: (...args: CommandArguments) => boolean; }; export interface OfficeEditorExtensionLifecycle { context: Context; storage: Storage; } export interface OfficeEditorExtensionUpdate extends OfficeEditorExtensionLifecycle { previousContext: Context; } export interface OfficeEditorKeyboardShortcutProps { can: OfficeEditorCanCommands; commands: Commands; context: Context; storage: Storage; } export type OfficeEditorKeyboardShortcutHandler = (props: OfficeEditorKeyboardShortcutProps, event: KeyboardEvent) => boolean; export interface OfficeEditorExtensionConfig> { name: string; priority?: number; addStorage?: () => Storage; addCommands?: (extension: { storage: Storage; }) => OfficeEditorCommandDefinitions; addKeyboardShortcuts?: (extension: { storage: Storage; }) => Record>; onCreate?: (extension: OfficeEditorExtensionLifecycle) => void; onUpdate?: (extension: OfficeEditorExtensionUpdate) => void; onDestroy?: (extension: OfficeEditorExtensionLifecycle) => void; } interface ErasedOfficeEditorCommand { canExecute?: (context: Context, args: readonly unknown[]) => boolean; execute: (context: Context, args: readonly unknown[]) => unknown; } interface OfficeEditorExtensionInstance { commands: ReadonlyMap>; keyboardShortcuts: readonly ErasedOfficeEditorKeyboardShortcut[]; onCreate: (context: Context) => void; onDestroy: (context: Context) => void; onUpdate: (context: Context, previousContext: Context) => void; storage: unknown; } interface ErasedOfficeEditorKeyboardShortcut { handler: (context: Context, commands: unknown, can: unknown, event: KeyboardEvent) => boolean; shortcut: string; } export interface OfficeEditorExtension { readonly name: string; readonly priority: number; createInstance: () => OfficeEditorExtensionInstance; /** * Type-only marker used to keep command maps aligned across extensions. * It is intentionally absent at runtime. */ readonly commandTypes?: Commands; } export interface OfficeEditorRuntime { readonly commands: Commands; readonly extensionNames: readonly string[]; readonly storage: Readonly>; can: () => OfficeEditorCanCommands; handleKeyDown: (event: KeyboardEvent) => boolean; mount: () => void; unmount: () => void; updateContext: (context: Context) => void; } export interface OfficeEditorRuntimeOptions { /** * Supplies render-current controlled state to commands and can() checks. * Lifecycle callbacks still receive contexts through updateContext(). */ getCurrentContext?: () => Context; } export declare function createOfficeEditorExtension>(config: OfficeEditorExtensionConfig): OfficeEditorExtension; export declare function createOfficeEditorRuntime(initialContext: Context, extensions: readonly OfficeEditorExtension[], options?: OfficeEditorRuntimeOptions): OfficeEditorRuntime; export { matchesOfficeEditorKeyboardShortcut } from '../../../keyboard-shortcuts';