import { BodyElement, Chart, Comment, DocumentInfo, Numbering, Section, SectionProperties, ShapeFill, StyleSheet } from '../document-model/index.js'; import { FontRegistry } from '../font/index.js'; import { ResourceStore } from './resources.js'; /** * The semantic IR tree (ir-design §5): everything a reader extracts from the * document bytes, format-neutrally — the flow `body` plus its document-scoped * companions (styles, numbering, header/footer bands, notes, charts, binary * resources, metadata). Caller-supplied conversion options (fonts, PDF/A * profile, signature, …) are deliberately NOT part of the tree; they * parameterize transforms, not the document. * * `body` carries FINAL effective properties — readers materialize list markers * and resolve the style cascade while building it — so render projections must * not re-apply `styles`/`numbering`, which remain only as round-trip material. */ export interface FlowDoc { /** Discriminant for {@link SourceDoc} (a FlowDoc passes through projection). */ readonly kind: 'flow'; /** The document flow content, carrying resolved, effective properties. */ readonly body: ReadonlyArray; /** Multi-section page geometry (docx). Empty for single-geometry sources. */ readonly sections: ReadonlyArray
; /** Single-section page geometry (xlsx print setup). */ readonly section?: SectionProperties; /** Resolved style sheet, kept as round-trip material (already folded into `body`). */ readonly styles: StyleSheet; /** * Raw numbering definitions (round-trip material). `body` already carries the * materialized list markers — readers apply numbering as a FlowDoc transform, * so render projections must not re-apply it. */ readonly numbering?: Numbering; readonly headersFooters?: ReadonlyMap>; /** §17.11 footnotes/endnotes content by id (separator stubs excluded). */ readonly footnotes?: ReadonlyMap>; readonly endnotes?: ReadonlyMap>; /** §17.13.4 review comments by id, anchored from a run's `commentRef`. */ readonly comments?: ReadonlyMap; /** Parsed charts keyed by relationship id (ChartBlock.chartRelId). */ readonly charts?: ReadonlyMap; /** Content-addressed binary resources (images). */ readonly resources: ResourceStore; /** Fonts embedded in the source document itself (docx fontTable), by name. */ readonly embeddedFonts?: ReadonlyMap; /** Document metadata from docProps/core.xml. */ readonly info?: DocumentInfo; /** Document natural language hint (BCP-47), e.g. for tagged-PDF /Lang. */ readonly language?: string; /** * ECMA-376 §17.15.1.35 `w:doNotExpandShiftReturn` — a justified line that * ends at a soft line break keeps its natural width. */ readonly doNotExpandShiftReturn?: boolean; /** * ECMA-376 §17.2.1 `w:background` — the colour every page is painted, when * the document asks for one AND §17.15.1.28 `w:displayBackgroundShape` says * to draw it. */ readonly pageBackgroundColorHex?: string; /** * ECMA-376 §17.2.1 — the same background as the FILL it is, when that is more * than a flat colour: the `v:background`'s gradient or picture. The colour * above stays the flat fallback, for writers that paint only colours. */ readonly pageBackgroundFill?: ShapeFill; /** * ECMA-376 §17.15.1.38 `w:gutterAtTop` — the binding space `w:pgMar * @w:gutter` reserves belongs to the TOP margin rather than the left. */ readonly gutterAtTop?: boolean; }