/** * Interactive Stream Hook. * * A utility class that hooks into Node.js WriteStreams to capture output * for interactive terminal applications. It allows temporarily intercepting * stream writes to enable features like progress bars and dynamic updates. * @example * ```typescript * const hook = new InteractiveStreamHook(process.stdout); * hook.active(); // Start capturing output * * // Output will be stored in history instead of being written to stdout * console.log("This won't appear immediately"); * * hook.inactive(); // Stop capturing and replay stored output * ``` */ declare class InteractiveStreamHook { #private; /** Constant indicating the stream write operation was successful */ static readonly DRAIN = true; /** * Creates a new InteractiveStreamHook for the given stream. * @param stream The Node.js WriteStream to hook into (usually stdout or stderr) */ constructor(stream: NodeJS.WriteStream); /** * Activates the stream hook. * * When active, all writes to the stream are captured in history instead of * being written immediately. This allows for interactive features like * progress bars that can update dynamically. */ active(): void; /** * Erases the specified number of lines from the terminal. * * Uses ANSI escape sequences to remove lines from the current cursor position * upwards, which is useful for clearing previous output in interactive applications. * @param count Number of lines to erase (including the current line) */ erase(count: number): void; /** * Deactivates the stream hook and replays captured output. * * Restores normal stream operation and outputs all captured history. * Optionally adds a newline separator before replaying the history. * @param separateHistory Whether to add a newline before replaying history */ inactive(separateHistory?: boolean): void; /** * Renews the stream hook state. * * Restores the original stream write method and shows the cursor. * This is typically called when temporarily suspending interactive mode. */ renew(): void; /** * Writes a message directly to the underlying stream. * * Bypasses the hook mechanism and writes directly using the original * stream write method. Useful for writing control sequences or * messages that should not be captured in history. * @param message The message to write to the stream */ write(message: string): void; } export default InteractiveStreamHook;