/** * The IR-based DOCX generation path. * * Normalisation, theme resolution, font resolution, desugaring of the * service-backed components, structure and layout — and then, instead of * building renderer objects directly, it compiles to DocxIR, checks the * selected backend can express what the document needs, and hands the IR to an * adapter. * * The shape is deliberate: everything asynchronous or fallible happens before * compilation, so compiling is a pure function of the document plus the * resources already in hand. Two compilations of the same document give the * same IR, which is what makes the IR comparable, cacheable and snapshottable. */ /// /// import type { GenerationWarning, ServicesConfig } from '@json-to-office/shared'; import type { FontRuntimeOpts } from '@json-to-office/shared'; import { compileDocument, type UnsupportedComponent } from '../ir/compiler'; import type { DocxIR } from '../ir/types'; import type { DocxRendererId } from '../renderers/types'; import type { ThemeConfig } from '../styles'; import type { ReportComponentDefinition } from '../types'; import type { GenerationThemeContext } from './generationContext'; import type { DocxQualityFact, DocxQualityModel } from '../quality/facts'; import type { PreparedDocument } from '@json-to-office/quality'; export interface IrDocxGenerationOptions { customThemes?: Record; services?: ServicesConfig; fonts?: FontRuntimeOpts; warnings?: GenerationWarning[]; baseDir?: string; deterministic?: boolean; generatedAt?: string | Date; /** Backend to render with. Defaults to `docxjs`. */ renderer?: DocxRendererId; /** * Rasterize a PNG fallback for each inline SVG. Defaults to true. * * Only readers older than Word 2016 draw that raster; everything current * draws the vector. Producing it is the dominant cost of a document whose * artwork is many small SVGs, so it can be turned off. */ svgRasterFallback?: boolean; /** * A prologue already run by the caller. * * The plugin path has to resolve the theme before it expands custom * components — a component's `render` is handed the resolved theme — and * normalises the tree that expansion produced. Passing that result in means * the prologue runs once rather than twice, which matters because the * export-mode pre-pass inside it rewrites the document. */ context?: GenerationThemeContext; /** Reuse the canonical prologue shared with quality analysis. */ prepared?: PreparedDocument; } export interface IrDocxGenerationResult { buffer: Buffer; warnings: GenerationWarning[]; } /** * Thrown when the compiler meets something it does not lower yet. * * Silently dropping it would be worse than failing: the document would look * complete and not be. This disappears as the compiler covers the surface. */ export declare class UncompiledComponentError extends Error { readonly code = "UNCOMPILED_COMPONENT"; readonly components: readonly UnsupportedComponent[]; constructor(components: readonly UnsupportedComponent[]); } export interface CompiledDocx { ir: DocxIR; theme: ThemeConfig; warnings: GenerationWarning[]; required: ReturnType['required']; unsupported: UnsupportedComponent[]; } /** * Compile a report definition to DocxIR without rendering it. * * Scoped rather than plain: a relative image path resolves against the * document's own directory, and leaf utilities report warnings into the * caller's collector, both through async-local state that has to be entered * before the walk begins. */ export declare function compileDocumentToIr(document: ReportComponentDefinition, options?: IrDocxGenerationOptions, collector?: GenerationWarning[]): Promise; /** Generate a `.docx` buffer through DocxIR and the selected renderer. */ export declare function generateBufferViaIr(document: ReportComponentDefinition, options?: IrDocxGenerationOptions): Promise; //# sourceMappingURL=generateFromIr.d.ts.map