import { Keymap } from "@opentui/keymap"; import type { ErrorEvent, HostMetadata, KeymapEvent, KeymapHost, WarningEvent } from "@opentui/keymap"; export type TestKeyModifierOptions = Partial>; export type TestHostMetadataOptions = Partial> & { modifiers?: Partial; }; export interface CreateTestKeymapHostOptions { metadata?: HostMetadata | TestHostMetadataOptions; } export interface CreateTestKeymapOptions extends CreateTestKeymapHostOptions { defaultKeys?: boolean; } export interface TestDiagnosticCapture { readonly warnings: readonly string[]; readonly errors: readonly string[]; readonly warningEvents: readonly WarningEvent[]; readonly errorEvents: readonly ErrorEvent[]; takeWarnings(): { warnings: string[]; warningEvents: WarningEvent[]; }; takeErrors(): { errors: string[]; errorEvents: ErrorEvent[]; }; clear(): void; dispose(): void; } export interface TestKeymapHarness { keymap: Keymap; host: TestKeymapHost; root: TestKeymapTarget; diagnostics: TestDiagnosticCapture; cleanup(): void; } export declare const DEFAULT_TEST_HOST_METADATA: HostMetadata; export declare class TestKeymapTarget { readonly id: string; parent: TestKeymapTarget | null; isDestroyed: boolean; constructor(id: string); append(child: TestKeymapTarget): TestKeymapTarget; } export declare class TestKeymapEvent implements KeymapEvent { readonly name: string; readonly ctrl: boolean; readonly shift: boolean; readonly meta: boolean; readonly super: boolean; readonly hyper?: boolean; propagationStopped: boolean; defaultPrevented: boolean; constructor(name: string, modifiers?: TestKeyModifierOptions); preventDefault(): void; stopPropagation(): void; } export declare class TestKeymapHost implements KeymapHost { readonly metadata: HostMetadata; readonly rootTarget: TestKeymapTarget; isDestroyed: boolean; private focusedTarget; private readonly keyPressListeners; private readonly keyReleaseListeners; private readonly focusListeners; private readonly destroyListeners; private readonly rawListeners; private readonly targetDestroyListeners; constructor(options?: CreateTestKeymapHostOptions); createTarget(id: string): TestKeymapTarget; getFocusedTarget(): TestKeymapTarget | null; getParentTarget(target: TestKeymapTarget): TestKeymapTarget | null; isTargetDestroyed(target: TestKeymapTarget): boolean; onKeyPress(listener: (event: TestKeymapEvent) => void): () => void; onKeyRelease(listener: (event: TestKeymapEvent) => void): () => void; onFocusChange(listener: (target: TestKeymapTarget | null) => void): () => void; onDestroy(listener: () => void): () => void; onTargetDestroy(target: TestKeymapTarget, listener: () => void): () => void; onRawInput(listener: (sequence: string) => boolean): () => void; createCommandEvent(): TestKeymapEvent; focus(target: TestKeymapTarget | null): void; press(name: string, modifiers?: TestKeyModifierOptions): TestKeymapEvent; release(name: string, modifiers?: TestKeyModifierOptions): TestKeymapEvent; raw(sequence: string): boolean; destroyTarget(target: TestKeymapTarget): void; destroy(): void; } export declare function createTestHostMetadata(options?: HostMetadata | TestHostMetadataOptions): HostMetadata; export declare function createTestKeymapHost(options?: CreateTestKeymapHostOptions): TestKeymapHost; export declare function createTestKeymap(options?: CreateTestKeymapOptions): TestKeymapHarness; export declare function captureKeymapDiagnostics(keymap: Keymap): TestDiagnosticCapture;