/** * prerasterizeVisuals — per-document visual rasterization pre-pass (#153). * * The renderer walks components strictly in order, so each `visual` used to * await its own rasterization round trip: one HTTP call + one LibreOffice * launch per visual, ~25 of each for the bundled annual-report templates. * This pass runs once per document before rendering: it collects every * enabled visual, dedupes identical ones, and rasterizes them together — * through an in-process batch rasterizer, a batched HTTP call, or (failing * both) bounded-concurrency per-visual calls. * * Results land in a map keyed by `visualRasterKey`; `renderVisualComponent` * consults the map first and falls back to per-visual rasterization on any * miss. The pre-pass is therefore purely an accelerator: over-collection * wastes a little work, under-collection and every failure mode degrade to * the sequential status quo, never to a broken render. */ import { type PptxServiceConfig, type PptxRasterizeBatchSlideResult, type RasterizeFontFace } from '@json-to-office/shared'; import { type VisualRasterProps } from '@json-to-office/shared-docx'; export interface PrerasterizeOptions { /** Directory relative asset paths resolve against (#142). */ baseDir?: string; /** Max concurrent per-visual fallback rasterizations (default 4). */ concurrency?: number; /** * Font faces staged for every slide's LibreOffice render. Request-level, * like `baseDir` — never per-slide: the batch schema validates each slide * object with `additionalProperties: false`, and a uniform slide shape is * what lets the server share one disk-cache key with the single path. */ fonts?: readonly RasterizeFontFace[]; } /** Cumulative pre-pass counters for visual-work observability (#156). */ export interface VisualPrepassStats { /** Documents that entered the pre-pass with at least one visual. */ documents: number; /** Enabled visuals collected across those documents. */ collected: number; /** Unique rasterization units after dedupe (identical content+dpi). */ unique: number; } /** * Get cumulative per-document pre-pass counters. `collected - unique` is the * work saved by batch-internal deduplication. */ export declare function getVisualPrepassStats(): VisualPrepassStats; export declare function resetVisualPrepassStats(): void; /** * Collect the props of every enabled *raster* `visual` component reachable * from `root`. The walk is generic — every array element and object value is * visited — so visuals nested anywhere (columns, table cells, section * headers/footers, plugin containers) are found without enumerating * container shapes. Disabled component subtrees are pruned: they never * render, so rasterizing them is wasted work. Over-collection is harmless * (an unused map entry); under-collection is harmless (render-time * fallback) — which is what makes the generic walk safe. * * `renderMode: "native"` visuals are excluded, not merely skipped later: they * are drawn as a Word drawing group by the backend, so a native-only document * must reach no rasterizer, stage no fonts and move no pre-pass counter. This * function is also the `hasVisual` predicate the font stager consults, which * is why the exclusion belongs here rather than at each call site. */ export declare function collectVisualProps(root: unknown): VisualRasterProps[]; /** * Batch-rasterize a document's visuals ahead of rendering. Returns a map of * `visualRasterKey` → per-visual result (pixels or a recorded error). Never * throws for per-visual problems; a thrown error here indicates a pre-pass * bug and the caller should continue without the map. */ export declare function prerasterizeVisuals(root: unknown, serviceConfig: PptxServiceConfig | undefined, options?: PrerasterizeOptions): Promise>; //# sourceMappingURL=prerasterizeVisuals.d.ts.map