/** * Inline-image paste reassembly for the Ink TUI. * * A terminal that pastes a screenshot writes an OSC 1337 sequence onto stdin. * Ink splits stdin at every ESC and drops the ESC from the event it resolves, so * a real sequence arrives as `"]"` on its own followed by `"1337;File=…"`, while * the same characters typed or pasted as literal text arrive as a single event * (measured on Ink 7.1.1). That event boundary is the only signal left once the * ESC is gone, so holding starts **only** at a lone `"]"` — literal text is never * mistaken for a paste and swallowed. * * The module stays free of React, Ink and IO so the rules can be pinned down * without a terminal attached, and every function returns fresh state. */ import { type PastedImage } from '../interactive/inlineImagePaste.js'; export type ImagePasteOutcome = /** Nothing image-related; the caller handles the event as a normal key. */ { readonly kind: 'none'; } /** The held bytes may still become an image; the caller swallows the event. */ | { readonly kind: 'pending'; } /** A complete inline image, plus the bytes that followed it in the event. */ | { readonly kind: 'image'; readonly image: PastedImage; readonly rest: string; } /** * Held bytes that are not an image after all; the caller types them. * `consumed` is false when the event that ended the hold was not part of the * released text — the caller must still run its own handling for that key. */ | { readonly kind: 'passthrough'; readonly text: string; readonly consumed: boolean; }; export interface ImagePasteBuffer { /** Bytes withheld from the editor because they may still open an image. */ readonly held: string; } export interface ImagePasteResult { readonly buffer: ImagePasteBuffer; readonly outcome: ImagePasteOutcome; } export declare function createImagePasteBuffer(): ImagePasteBuffer; /** * Reads one key event against the buffer. * * `chunk` is the text the event carries; pass an empty string for an event that * carries none — a non-printable key or a control chord — because such an event * can never extend a held sequence and the held bytes belong back in the editor. * An event whose text carries a control character other than the sequence's own * terminator (Enter, Ctrl+J) is treated the same way and reported as unconsumed. * * Never throws: a malformed or oversized sequence is returned as `passthrough` * so the held bytes reach the editor instead of being dropped. */ export declare function consumeImagePasteInput(buffer: ImagePasteBuffer, chunk: string): ImagePasteResult; //# sourceMappingURL=imagePasteInput.d.ts.map