/** * Lowering a native `visual` into a DocxIR drawing group. * * A raster visual leaves the tree long before compilation — it becomes an * `image`. A native one survives, and this is where it stops being an * authoring surface and becomes drawn objects: absolute EMU frames in the * group's own coordinate space, resolved colours, registered picture bytes. * * Two rules shape everything here. * * *Strict.* The native element model is narrower than the raster one, and * anything outside it is refused rather than approximated. A `chart` element, * an unresolvable colour, an image whose bytes never arrived: each stops the * document with the path that caused it. Silently drawing something else would * ship a graphic the author did not design. * * *Pure.* Every byte and every theme lookup arrives through {@link * NativeVisualDeps}, so this is a function of its inputs — same visual, same * group, which is what lets a native document be byte-deterministic and * golden-tested without a service anywhere in sight. * * Geometry is inches or a percentage of the canvas. The raster path's rule * that a number at or above 100 is already EMU is deliberately not reproduced: * a native canvas is inches all the way down. */ import type { VisualNativeProps } from '@json-to-office/shared-docx'; import type { DocxIrColor, DocxIrDrawingGroupChild } from './types'; import { inchesToEmu, emuToInches } from './units'; /** A picture resource the compiler has already loaded and registered. */ export interface NativePictureResource { resourceId: string; mediaType: string; /** Pixel size as stored, when the header could be read. */ intrinsic?: { width: number; height: number; }; } /** * What lowering needs from the compiler. * * Deliberately four narrow capabilities rather than the compile context: the * lowering has no business reaching for bookmarks, numbering or section * geometry, and saying so in the type keeps it that way. */ export interface NativeVisualDeps { /** Resolve an authored colour to hex, or `undefined` if it names nothing. */ color(value: string): DocxIrColor | undefined; /** Register an image source's bytes, or `undefined` if they never loaded. */ picture(source: string): NativePictureResource | undefined; /** Refuse the component, naming what could not be drawn. */ reject(detail: string): void; /** Report something worth knowing that did not stop the drawing. */ warn(message: string): void; } /** The canvas, in EMU, that every element resolves against. */ interface Canvas { widthEmu: number; heightEmu: number; } /** The drawn children of one native visual, in z-order. */ export interface NativeVisualGroup { canvas: Canvas; children: DocxIrDrawingGroupChild[]; } /** * Lower a native visual's canvas and elements into drawing-group children. * * Returns `undefined` when something was refused; the refusal has already been * reported through `deps.reject`, which is what stops the document. */ export declare function compileNativeVisualGroup(props: VisualNativeProps, outer: NativeVisualDeps): NativeVisualGroup | undefined; /** Exported for tests that assert the inches↔EMU contract directly. */ export declare const nativeVisualUnits: { inchesToEmu: typeof inchesToEmu; emuToInches: typeof emuToInches; }; export {}; //# sourceMappingURL=nativeVisual.d.ts.map