/** * StdinBuffer buffers input and emits complete sequences. * * This is necessary because stdin data events can arrive in partial chunks, * especially for escape sequences like mouse events. Without buffering, * partial sequences can be misinterpreted as regular keypresses. * * For example, the mouse SGR sequence `\x1b[<35;20;5m` might arrive as: * - Event 1: `\x1b` * - Event 2: `[<35` * - Event 3: `;20;5m` * * The buffer accumulates these until a complete sequence is detected. * Call the `process()` method to feed input data. * * Based on code from OpenTUI (https://github.com/anomalyco/opentui) * MIT License - Copyright (c) 2025 opentui */ import { EventEmitter } from "events"; /** True for complete SGR mouse CSI reports. These remain control input, never text. */ export declare function isSgrMouseSequence(sequence: string): boolean; export type StdinBufferOptions = { /** * Maximum time to wait for sequence completion (default: 10ms) * After this time, the buffer is flushed even if incomplete */ timeout?: number; }; export type StdinBufferEventMap = { data: [string]; paste: [string]; }; /** * Buffers stdin input and emits complete sequences via the 'data' event. * Handles partial escape sequences that arrive across multiple chunks. * * StdinBuffer is the single raw-stdin decoding boundary: raw terminal bytes * enter via `process()` and decoded string events leave via the 'data' and * 'paste' events. UTF-8 is decoded exactly once here (using a persistent * StringDecoder) so multi-byte characters split across chunk boundaries are * reassembled rather than corrupted into U+FFFD. All downstream parsing * (escape sequences, bracketed paste, Kitty/CSI, OSC/DA1) operates on strings. */ export declare class StdinBuffer extends EventEmitter { #private; constructor(options?: StdinBufferOptions); process(data: string | Buffer): void; /** * ProcessTerminal calls this right after writing a capability probe so a lone * ESC arriving inside the reply window is treated as a possible reply fragment * rather than a keypress. */ noteProbeIssued(windowMs?: number): void; flush(): string[]; clear(): void; getBuffer(): string; destroy(): void; }