/** * Image-paste wiring shared by every editing view. * * Both gestures the readline editor offers have to work the same way wherever * the user types: Ctrl+V reads the clipboard, and a terminal that pastes a * screenshot writes an OSC 1337 sequence which arrives split across key events. * Each save is async and writes a temp file the caller deletes on teardown, so * every one of them joins the view's pending work. */ import type { Key } from 'ink'; import type { PastedImage } from '../interactive/inlineImagePaste.js'; /** Async work a view must drain before it hands control back. */ export interface PendingWork { readonly controller: AbortController; readonly completion: Promise; } /** * Waits for everything a view still has running, letting it finish. * * A capture that lands while the user is pressing Enter still belongs to the * text being submitted, so the exit that reads the draft waits rather than * cutting the capture short. Looping, because work that finishes can start more * of it — inserting a placeholder is itself a state change. */ export declare function awaitPendingWork(pending: Set): Promise; /** * Stops everything a view still has running and waits for it to settle. * * This is the exit that does not want what is in flight: an interrupt, or a * decision that ends the run. Each piece of work owns state the caller cleans up * afterwards, so leaving one running would resurrect a temp file or leave a * provider call talking to a view that is gone. */ export declare function drainPendingWork(pending: Set): Promise; export interface ImagePasteSink { pasteClipboardImage(abortSignal: AbortSignal): Promise; saveInlineImage(image: PastedImage): Promise; /** Refuse further images: the run ended and its temp files are being cleaned up. */ sealImages(): void; } export interface ImagePasteInput { readonly sink: ImagePasteSink; readonly lang: 'en' | 'ja'; readonly insertAtCaret: (text: string) => void; readonly setNotice: (message: string | null) => void; readonly track: (work: PendingWork) => void; /** True once the view stopped accepting state changes. */ readonly isStopped: () => boolean; } export interface ImagePasteHandlers { /** True when the event belonged to a paste and needs no further key handling. */ readonly routeInput: (input: string, key: Key) => boolean; /** Ctrl+V: read the clipboard image and insert its placeholder. */ readonly captureClipboard: () => void; } export declare function useImagePaste({ sink, lang, insertAtCaret, setNotice, track, isStopped, }: ImagePasteInput): ImagePasteHandlers; //# sourceMappingURL=useImagePaste.d.ts.map