/** * Event-driven UI Engine * * A flexible engine for building custom interactive terminal UIs * with support for key events, timers, and async updates. */ import { Readable, Writable } from 'stream'; import { TerminalKeypress } from '../keypress'; import { UIEvent, UIScreenConfig } from './types'; /** * ANSI escape codes for terminal control */ declare const ANSI: { clearScreen: string; hideCursor: string; showCursor: string; cursorUp: (n: number) => string; cursorDown: (n: number) => string; cursorTo: (x: number, y: number) => string; clearLine: string; clearToEnd: string; saveCursor: string; restoreCursor: string; }; export interface UIEngineOptions { input?: Readable; output?: Writable; noTty?: boolean; /** Existing keypress instance to reuse (avoids multiple listeners on stdin) */ keypress?: TerminalKeypress; /** If true, engine owns the keypress and will destroy it on cleanup. Default: true if keypress not provided */ ownsKeypress?: boolean; /** If true, clear the entire screen on start instead of just overwriting lines */ clearScreenOnStart?: boolean; } export declare class UIEngine { private input; private output; private noTty; private keypress; private ownsKeypress; private clearScreenOnStart; private tickTimer; private lastLineCount; constructor(options?: UIEngineOptions); /** * Write to output */ private write; /** * Clear the screen */ private clearScreen; /** * Hide the cursor */ private hideCursor; /** * Show the cursor */ private showCursor; /** * Render lines to the terminal, clearing previous output */ private render; /** * Run a custom UI screen */ run(config: UIScreenConfig): Promise; /** * Dispatch an external event (for async updates) */ dispatch(event: UIEvent): void; /** * Cleanup resources */ destroy(): void; } export { ANSI };