import { ConvertDocxOptions } from '../../word/docx-to-pdf.js'; import { DocumentReader } from '../ir/adapters.js'; import { FlowDoc } from '../ir/flow.js'; import { SheetDoc } from '../ir/sheet.js'; import { FontProvider } from '../fonts/provider.js'; import { Loss, LossReport } from '../ir/index.js'; import { FontBytesByVariant } from '../font/index.js'; import { ProjectSheetOptions } from '../../excel/sheet-to-flow.js'; /** Options for a {@link Converter.convert} call (extends the docx PDF options). */ export interface ConvertOptions extends ConvertDocxOptions { /** * Target: 'pdf' (default), 'svg' (page-stack preview), 'html'/'md'/'docx' * (flowed), or 'xlsx' (the native grid writer — spreadsheet input only). */ readonly to?: 'pdf' | 'svg' | 'html' | 'md' | 'docx' | 'xlsx'; /** * Strict mode (handoff v1 §5): throw ConversionLossError on the first * recorded loss instead of returning it in the report. */ readonly strict?: boolean; /** * E-SHEET W9 — reference date for conditional-format `timePeriod` rules and * TODAY()/NOW() in `expression` rules (spreadsheet input). An explicit input, * never the wall clock; omitted ⇒ those clock-relative rules no-op. */ readonly now?: Date; /** * §18.3.1.34 `&F` — the workbook's file name, for a spreadsheet whose header * or footer prints it. Absent, the code is dropped. */ readonly fileName?: string; /** * Font resolution chain (ir-design §8). When set (and no caller `fonts`), * the facade resolves the default font set through these providers — e.g. * [localFontProvider(), remoteFontProvider()] — and reports a 'substituted' * loss when anything below a caller/embedded answer wins. Local Font Access * stays strictly opt-in via this option (it can trigger a permission * prompt), which is why nothing wires it in by default. */ readonly fontProviders?: ReadonlyArray; } /** The output of a conversion: the encoded bytes and the accumulated losses. */ export interface ConvertResult { /** The encoded output bytes (PDF / SVG / HTML / DOCX / XLSX). */ readonly bytes: Uint8Array; /** Every {@link Loss} recorded while reading the source and writing the target. */ readonly losses: LossReport; } /** * One of the source IR trees a reader yields. The render path is {@link FlowDoc}, * so a {@link SheetDoc} is projected to a FlowDoc at the boundary (E-SHEET SB1); * the discriminant `kind` selects the projection and a FlowDoc passes through. */ export type SourceDoc = FlowDoc | SheetDoc; /** * Normalize a {@link SourceDoc} to a {@link FlowDoc}: a {@link SheetDoc} is run * through the print-model projection; a FlowDoc passes through unchanged. * * @param doc The reader's native tree. * @param options Projection options (e.g. the `now` reference date). * @returns The flow tree the render path consumes. */ export declare function toFlowDoc(doc: SourceDoc, options?: ProjectSheetOptions): FlowDoc; /** A registry-driven converter: readers → layout → writers (ir-design §7). */ export interface Converter { /** The registered readers, in sniffing order. */ readonly readers: ReadonlyArray>; /** Detect the input format by reader sniffing; undefined when unknown. */ detect: (bytes: Uint8Array) => DocumentReader | undefined; /** Read the bytes and convert them to the requested target (default `'pdf'`). */ convert: (bytes: Uint8Array, options?: ConvertOptions) => Promise; } /** Options for {@link createConverter}. */ export interface CreateConverterOptions { /** Override / extend the reader registry (defaults to {@link DEFAULT_READERS}). */ readonly readers?: ReadonlyArray>; } /** The built-in readers, in sniffing order: docx, doc, xlsx, xls, pptx, ppt, pdf. */ export declare const DEFAULT_READERS: ReadonlyArray>; /** * Build a {@link Converter} over a reader registry. The async boundary (font * fetching) lives here; readers and writers stay synchronous. * * @param opts Optional reader-registry override. * @returns A converter exposing `readers`, `detect` and `convert`. */ export declare function createConverter(opts?: CreateConverterOptions): Converter; /** * Resolve the regular/bold/italic/bold-italic variants of the document-default * family through a {@link FontProvider} chain. A `remote` or `local` winner is * reported as a substitution {@link Loss}. * * @param providers The provider chain, highest priority first. * @returns The resolved font bytes (present when the regular variant resolves) * and an optional substitution loss. */ export declare function resolveFontsViaChain(providers: ReadonlyArray): Promise<{ fonts?: FontBytesByVariant; loss?: Loss; }>;