/** * Rasterize an aelea tree to an image by going directly through * `@takumi-rs/core`'s `Renderer` — no React-element shape emulation. * * const bytes = await renderToImage($App, { width: 1200, height: 630 }) * * Internally: subscribe → settle → materialize the resolved tree once → * project to takumi's `container`/`text`/`image` nodes → `renderer.render`. * * Settle is deterministic: with the default `SettleScheduler` the renderer * waits on the scheduler's `idle()` signal and finishes the instant the * tree's synchronous and timer-driven behaviors quiesce — no fixed * wall-clock delay. `settleMs` (default 0) only adds an extra quiet window * for trees whose data arrives via untracked promises; `timeoutMs` is a hard * ceiling. This keeps per-render latency at microtask scale, which matters * when a service streams snapshots per request. * * A single default `Renderer` is created lazily and reused across calls so * font / image caches amortize. Pass `renderer` to use a configured instance. */ import { Renderer } from '@takumi-rs/core'; import type { I$Node, I$Scheduler } from '../ui/index.js'; export type ImageFormat = 'webp' | 'png' | 'jpeg' | 'ico' | 'raw'; type ConstructRendererOptions = Record; export interface RenderToImageOptions { width: number; height: number; format?: ImageFormat; /** Pixel ratio forwarded to takumi (default 1). */ devicePixelRatio?: number; /** JPEG quality (0–100) when `format: 'jpeg'`. */ quality?: number; /** Draw debug borders around laid-out nodes. */ drawDebugBorder?: boolean; /** * Pre-fetched image resources keyed by `src`, passed through to takumi * so it doesn't need to resolve them itself. See takumi's * `fetchedResources` / `extractResourceUrls` docs. */ fetchedResources?: unknown[]; /** * Supply a pre-configured `Renderer` instance (for persistent fonts, * image caching, etc.). Defaults to a lazily-created shared renderer. */ renderer?: Renderer; /** * Init options for the default shared renderer on first use. Ignored if * `renderer` is supplied, and ignored after the shared renderer already * exists — the first caller's options win for the process lifetime. */ rendererOptions?: ConstructRendererOptions; /** * Scheduler override — defaults to a headless scheduler with a * deterministic `idle()` signal. A scheduler without `idle()` falls back * to a wall-clock quiet window of `settleMs` (min 16ms). */ scheduler?: I$Scheduler; /** * Extra quiet window (ms) required after the tree goes idle before * settling. Default 0 — settle as soon as the scheduler is idle. Raise it * only for trees whose content arrives via untracked promises. */ settleMs?: number; /** Hard timeout for the whole rasterize call (default 5000ms). */ timeoutMs?: number; /** AbortSignal forwarded to the renderer and used to cancel the wait. */ signal?: AbortSignal; } export declare function renderToImage($root: I$Node, opts: RenderToImageOptions): Promise; export {};