/** * 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 → snapshot → project to takumi's * `container`/`text`/`image` node tree → `renderer.render(tree, opts)`. * * A single default `Renderer` is created lazily and reused across calls * so font / image caches amortize. Pass `renderer` in options to use a * configured instance (fonts, persistentImages, resourceCacheCapacity). */ import { Renderer } from '@takumi-rs/core'; import { type I$Node, type I$Scheduler } from '../ui/index.js'; export type ImageFormat = 'webp' | 'png' | 'jpeg' | 'ico' | 'raw'; type ConstructRendererOptions = NonNullable[0]>; 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. */ rendererOptions?: ConstructRendererOptions; /** Scheduler override — defaults to a headless (no-raf) scheduler. */ scheduler?: I$Scheduler; /** * The snapshot stream emits progressively as the tree populates. We wait * for the emit stream to be quiet for `settleMs` (default 250ms), then * take the latest snapshot. */ 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 {};