/** * Render pipeline: TermNode tree → Yoga layout → FrameBuffer → ANSI output. * * Connects the Solid reactive tree to terminal output: * 1. applyProps() maps JSX props to yoga layout properties * 2. setupTextMeasure() wires Bun.stringWidth into yoga measure functions * 3. layout() runs yoga calculateLayout on the tree * 4. paint() renders positioned nodes into a FrameBuffer * 5. renderFrame() diffs + serializes to an ANSI string */ import { type TermNode } from "../renderer/term-node.js"; import { type ClipRect, FrameBuffer } from "./frame-buffer.js"; import { type SelectionState } from "./selection.js"; /** Apply a TermNode's props to its yoga node. */ export declare function applyProps(node: TermNode): void; /** Collect text content from a text node's children. Cached on the node. */ export declare function collectText(node: TermNode): string; /** * Set up yoga measure functions for text nodes in the tree. * Must be called after the tree is built but before layout. */ export declare function setupMeasureFunctions(node: TermNode): void; /** Apply props and calculate layout for the entire tree. */ export declare function layout(root: TermNode, width: number, height?: number): void; /** * Inverse of cursorToRowCol — convert a (row, col) screen position * to a character offset in the value string. Clamps to value.length * if the click is past the end of the text. */ export declare function rowColToCursor(value: string, targetRow: number, targetCol: number, colWidth: number): number; /** Paint the positioned TermNode tree into a frame buffer. */ /** * A paint-time color filter: maps a glyph cell's local position within a * width×height box to a packed 24-bit fg, or `undefined` to leave it untouched. */ export type ColorField = (x: number, y: number, width: number, height: number) => number | undefined; export declare function paint(node: TermNode, buf: FrameBuffer, offsetX?: number, offsetY?: number, clip?: ClipRect): void; /** Get the total content height of a node's children (after layout). */ export declare function getScrollHeight(node: TermNode): number; /** Scroll a node to an absolute offset, clamped to valid range. */ export declare function scrollTo(node: TermNode, top: number): void; /** Scroll a node by a relative delta. */ export declare function scrollBy(node: TermNode, delta: number): void; /** Scroll a node to the bottom of its content. */ export declare function scrollToBottom(node: TermNode): void; /** * Find the deepest TermNode at screen coordinates (col, row). * Walks children in reverse order so later (visually on-top) nodes win. * Returns null if no node contains the point. */ export declare function hitTest(node: TermNode, col: number, row: number): TermNode | null; /** * Walk from a hit node up to root, looking for the first ancestor * (including itself) that has a specific handler prop. */ export declare function findHandler(node: TermNode | null, prop: string): { node: TermNode; handler: (e: unknown) => void; } | null; export interface RenderState { /** Number of rows actually used by content (updated each frame) */ activeHeight: number; buffer: FrameBuffer; cols: number; /** Whether the terminal supports OSC 8 hyperlinks */ linksEnabled: boolean; prevBuffer: FrameBuffer; rows: number; /** Text selection state */ selection: SelectionState; syncSupported: boolean; } export declare function createRenderState(cols: number, rows: number, syncSupported?: boolean, linksEnabled?: boolean): RenderState; /** Clear dirty flags after layout so unchanged frames skip layout next time. */ export declare function clearDirty(node: TermNode): void; /** * Run the full render pipeline: layout → paint → diff → serialize. * Returns the ANSI string to write to stdout. */ export declare function renderFrame(root: TermNode, state: RenderState): string; /** * Content-driven render: active region height = content height. * Ports CC's Ink primary-screen rendering model (renderer.ts + log-update.ts): * * - Yoga root height is unconstrained → content determines height * - screen.height = yogaHeight (content height, may exceed terminal rows) * - cursor.y = screen.height (parked after last content row) * - When content < viewport: only renders content rows, input near top * - When content >= viewport: log-update's cursor-restore LF naturally * scrolls old content into terminal scrollback * - Diff is only computed for rows within the terminal viewport * * @param terminalRows - the terminal's visible row count (for viewport calc) */ export declare function renderContentDriven(root: TermNode, state: RenderState, terminalRows: number): string; /** * Render a component to an ANSI string (one-shot). * Creates a temporary Solid tree, runs layout + paint, serializes, disposes. * Returns { ansi, height } — the ANSI output and the content height in rows. */ export declare function renderToAnsi(code: () => unknown, cols: number, linksEnabled?: boolean): { ansi: string; height: number; }; //# sourceMappingURL=pipeline.d.ts.map