import { PureComponent, type ReactNode } from "react"; import { type ReadStream, type WriteStream } from "../types/io.js"; import { EventEmitter } from "../utils/event-emitter.js"; /** * Props for the App component. */ interface AppProps { /** * The child components to render. */ readonly children: ReactNode; /** * input stream. */ readonly stdin: ReadStream; /** * output stream. */ readonly stdout: WriteStream; /** * error stream. */ readonly stderr: WriteStream; /** * Function to write data to stdout. */ readonly writeToStdout: (data: string) => void; /** * Function to write data to stderr. */ readonly writeToStderr: (data: string) => void; /** * Whether to exit on Ctrl+C. */ readonly exitOnCtrlC: boolean; /** * Callback called when the app exits. */ readonly onExit: (error?: Error) => void; /** * Environment variables. */ readonly env?: Record; } /** * State for the App component. */ interface State { /** * Whether focus management is enabled. */ readonly isFocusEnabled: boolean; /** * The ID of the currently focused component. */ readonly activeFocusId?: string; /** * List of focusable components. */ readonly focusables: Focusable[]; /** * Current error, if any. */ readonly error?: Error; } /** * Represents a focusable component. */ interface Focusable { /** * Unique ID of the component. */ readonly id: string; /** * Whether the component is active (focusable). */ readonly isActive: boolean; } /** * Root component for all Tinky apps. * * It renders stdin, stdout, and stderr contexts, making them available to * children. It coordinates focus management and global error handling. * It also handles Ctrl+C exiting and cursor visibility. */ export declare class App extends PureComponent { static displayName: string; static getDerivedStateFromError(error: Error): { error: Error; }; state: { isFocusEnabled: boolean; activeFocusId: undefined; focusables: never[]; error: undefined; }; rawModeEnabledCount: number; internal_eventEmitter: EventEmitter; isRawModeSupported(): boolean; render(): import("react").JSX.Element; componentDidMount(): void; componentWillUnmount(): void; componentDidCatch(error: Error): void; /** * Enables or disables raw mode on the input stream. * * @param isEnabled - true to enable raw mode, false to disable. */ handleSetRawMode: (isEnabled: boolean) => void; /** * Reader function for handling standard input. * Reads data from stdin and emits it to the internal event emitter. */ handleReadable: (chunk: unknown) => void; /** * Handles keyboard input. * - Handles Ctrl+C for exiting. * - Handles Tab/Shift+Tab for focus navigation. * - Handles Esc for resetting focus. */ handleInput: (input: string) => void; /** * Handles app exit. * Cleans up raw mode and calls the onExit prop. */ handleExit: (error?: Error) => void; /** * Enables focus management. */ enableFocus: () => void; /** * Disables focus management. */ disableFocus: () => void; /** * Focuses a component by its ID. */ focus: (id: string) => void; /** * Focuses the next focusable component. */ focusNext: () => void; /** * Focuses the previous focusable component. */ focusPrevious: () => void; /** * Registers a component as focusable. */ addFocusable: (id: string, { autoFocus }: { autoFocus: boolean; }) => void; /** * Unregisters a focusable component. */ removeFocusable: (id: string) => void; /** * Activates a focusable component (makes it eligible for focus). */ activateFocusable: (id: string) => void; /** * Deactivates a focusable component (makes it ineligible for focus). */ deactivateFocusable: (id: string) => void; /** * Finds the next focusable component ID. */ findNextFocusable: (state: State) => string | undefined; /** * Finds the previous focusable component ID. */ findPreviousFocusable: (state: State) => string | undefined; } export {};