/** * UI-free browser materializer for deterministic, standalone paginated HTML. * * Conversion happens in the existing WASM worker. Layout happens in a private, * attached browsing context so no caller styles, globals, or editor state can * influence the artifact. */ import { canonicalJson } from "./canonical.js"; import { type PageMap } from "./pagination.js"; import { type MarkupMode } from "./markup-balloons.js"; export { renderedSourceMeasurerExpression } from "./pagination.js"; import type { FontConfigurationIdentity, FontObservation, FontResolution, FontResolver } from "./font-contract.js"; export { fontFamilyKey, FONT_RESOLVER_CONTRACT_ID, FONT_RESOLVER_SCHEMA_VERSION, FONT_SUBSTITUTION_CONTRACT, FONT_SUBSTITUTION_CONTRACT_MATERIAL, FONT_SUBSTITUTION_CONTRACT_VERSION, normalizeFontFamilyName, FONT_REQUEST_ATTRIBUTE, } from "./font-contract.js"; export { inventoryDocumentFontRequests, parseCssFontFamily } from "./font-runtime.js"; export type { FontConfigurationIdentity, FontObservation, FontEmbeddingKind, FontFamilyKind, FontFaceMatch, FontFaceStyle, FontFileFormat, FontGlyphCoverage, FontLicenseEvidence, FontMediaType, FontRequest, FontResolution, FontResolutionSource, FontResolutionStatus, FontResolver, FontResolverFace, FontResolverOutcome, FontResolverRequest, FontResolverResponse, FontSubstitutionEntry, } from "./font-contract.js"; export type ReviewProfile = "final" | "original" | "markup"; /** * How the markup profile draws tracked changes (issue #851): `docxodus` (default) is Docxodus's own * review style; `word` is close to Word's All Markup print — per-author colours, underline and * strikethrough only, no fills or pilcrows, and left-margin change bars. */ export type MarkupPresentation = "docxodus" | "word"; export type CommentProfile = "hidden" | "inline" | "endnotes" | "margin"; /** * Where margin comments go. `margin` keeps them in the page's right margin; `balloons` is Word's * All Markup print layout: each page is shrunk beside a markup area whose balloons hold the * comments and, with the Word presentation, the formatting changes. */ export type CommentColumnPlacement = "margin" | "balloons"; /** * Under balloons, what becomes of the rest of a comment cut short to fit beside its page: * `truncate` prints it nowhere (Word's Save as PDF), `appendix` prints it on pages after the last * (Word's Print to PDF). */ export type BalloonOverflow = "truncate" | "appendix"; export type { MarkupMode }; export type UnsupportedContentPolicy = "warn" | "strict"; export type ExportPhase = "input_validation" | "package_preflight" | "browser_launch" | "wasm_initialization" | "docx_conversion" | "font_loading" | "image_decoding" | "chart_svg_materialization" | "pagination" | "running_story_placement" | "page_tree_stability" | "pdf_print" | "output_verification" | "output_write" | "filesystem_commit" | "cleanup"; export type DocxodusExportErrorCode = "invalid_argument" | "invalid_document" | "source_digest_mismatch" | "document_version_unrepresentable" | "conversion_failure" | "browser_launch_failure" | "resource_policy_failure" | "readiness_timeout" | "operation_cancelled" | "pagination_failure" | "pdf_write_failure" | "output_write_failure" | "output_verification_failure" | "resource_limit" | "unsupported_runtime" | "filesystem_failure"; export interface ExportResourceLimits { compressedDocxBytes: number; opcEntries: number; expandedOpcBytes: number; xmlPartBytes: number; opcUriCharacters: number; opcCompressionRatio: number; htmlOutputBytes: number; pdfOutputBytes: number; pageMapOutputBytes: number; renderReportOutputBytes: number; pdfParserExpandedBytes: number; finalPages: number; domNodes: number; automaticResources: number; automaticResourceBytes: number; renderDiagnostics: number; fontDirectoryEntries: number; fontFiles: number; fontFileBytes: number; fontTotalBytes: number; fontRequests: number; fontSampleCodePoints: number; } export declare const DEFAULT_EXPORT_RESOURCE_LIMITS: Readonly; export declare const HARD_EXPORT_RESOURCE_LIMITS: Readonly; export declare const DEFAULT_EXPORT_TIMEOUT_MS: number; export declare const HARD_EXPORT_TIMEOUT_MS: number; /** Display controls; omitted flags are visible. Revision flags affect only the markup profile. */ export interface MarkupVisibility { formatting?: boolean; /** Hidden text revisions display current text without accepting revisions in the input. */ insertionsAndDeletions?: boolean; /** Visible comments still honor commentProfile, including its hidden setting. */ comments?: boolean; } /** Shared browser/Node validation; keep only false flags so explicit defaults preserve digests. */ export declare function normalizeMarkupVisibility(value: unknown): Readonly; export interface PaginatedHtmlOptions { documentVersion?: number; expectedSourceDigest?: string; reviewProfile: ReviewProfile; reviewProfileAlreadyApplied?: boolean; /** Only with reviewProfile "markup"; default "docxodus". */ markupPresentation?: MarkupPresentation; markupVisibility?: MarkupVisibility; commentProfile: CommentProfile; /** * Default "margin". "balloons" takes any comment profile but inline (margin comments go in the * balloons; endnotes keep their list; hidden prints formatting balloons only), and with the * markup profile needs the Word presentation. */ commentColumnPlacement?: CommentColumnPlacement; /** * Only with the balloon layout; default "truncate". "appendix" numbers each cut comment's box and * prints every cut comment in full on pages added after the last, so the PDF gains pages. */ balloonOverflow?: BalloonOverflow; /** * Only with the balloon layout; default "mixed", Word's own default setting, "Show Only Comments * and Formatting in Balloons". "inline" is Word's "Show All Revisions Inline": the balloons hold * comments only, so a document whose only markup is formatting changes prints at full size. */ markupMode?: MarkupMode; title?: string; /** CSS appended to the converter stylesheet before pagination. */ additionalCss?: string; unsupportedContent?: UnsupportedContentPolicy; strictFonts?: boolean; timeoutMs?: number; limits?: Partial; signal?: AbortSignal; /** Ephemeral browser-side resolver; never serialized into standalone output. */ fontResolver?: FontResolver; /** Trusted runtime assets only; never a document-resource base URL. */ wasmBasePath?: string; } export interface RenderWarning { code: string; severity: "warning"; phase: ExportPhase; message: string; remediation: string; detail?: string; partUri?: string; anchorId?: string; resource?: string; } export interface ReadinessOutcome { phase: ExportPhase; status: "complete" | "failed" | "cancelled"; elapsedMs: number; pending: string[]; } export interface ResourceOutcome { kind: "image" | "svg" | "chart" | "external_link"; status: "embedded" | "inline" | "allowed_user_link" | "omitted"; resource?: string; mediaType?: string; byteLength?: number; } export interface UnsupportedContentOutcome { contentType: string; elementName?: string; anchorId?: string; action: "placeholder"; } export interface RenderReportBase { schema: "https://docxodus.dev/schemas/render/render-report/v2"; schemaVersion: 2; source: { rawPackageBytesDigest: string; byteLength: number; documentVersion: number; }; derivedProfileSource?: { rawPackageBytesDigest: string; byteLength: number; }; options: { reviewProfile: ReviewProfile; reviewProfileAlreadyApplied: boolean; /** Present only when the markup profile used the Word presentation. */ markupPresentation?: "word"; /** Present only for non-default visibility, with false flags in canonical order. */ markupVisibility?: MarkupVisibility; commentProfile: CommentProfile; /** Present only for the balloon layout. */ commentColumnPlacement?: "balloons"; /** Present only when the balloon layout printed cut comments in full after the last page. */ balloonOverflow?: "appendix"; /** Present only when the balloon layout used Word's "Show All Revisions Inline" setting. */ markupMode?: "inline"; title: string; /** Present only when a nonempty additional stylesheet was applied. */ additionalCss?: string; outputs: Array<"html" | "pdf">; layoutDigest: string; runtimePolicyDigest: string; policy: { unsupportedContent: UnsupportedContentPolicy; strictFonts: boolean; timeoutMs: number; limits: ExportResourceLimits; }; }; readiness: ReadinessOutcome[]; fonts: FontResolution[]; fontObservation?: FontObservation; fontObservationDigest?: string; resources: ResourceOutcome[]; unsupportedContent: UnsupportedContentOutcome[]; warnings: RenderWarning[]; fontIdentity?: FontConfigurationIdentity; } export type EnvironmentVerification = "nodeVerified" | "browserObserved" | "callerAttested"; export type FidelityTier = "releaseBaselined" | "experimental" | "unbaselined"; export interface ExportRuntimeObservedFacts { runtimeKind: "browser" | "nodeChromium"; playwrightVersion?: string; browserProduct?: string; browserBuild?: string; executableSha256?: string; launchFlags?: string[]; operatingSystem?: string; architecture?: string; locale: string; timezone: string; viewport: [number, number]; deviceScaleFactor: number; media: { colorScheme: "light" | "dark" | "no-preference"; reducedMotion: "reduce" | "no-preference"; forcedColors: "active" | "none"; printMedia: true; }; networkIsolation: "ownedProcessRestricted" | "contextRestricted"; } export interface ExportRuntimeAttestationEvidence { chromiumProduct: string; chromiumBuild: string; executableSha256: string; launchFlags: string[]; hostFontsDigest: string; basis: string; } export interface CompleteRenderReport extends RenderReportBase { status: "complete"; fontIdentity: FontConfigurationIdentity; environment: { rendererFingerprint: string; verification: EnvironmentVerification; fidelityTier: FidelityTier; observed: ExportRuntimeObservedFacts; attested?: ExportRuntimeAttestationEvidence; attestationDigest?: string; }; pages: Array<{ pageNumber: number; pageInSection: number; pageName: string; width: number; height: number; sectionIndex?: number; }>; bindings: { pageMapDigest: string; htmlDigest?: string; pdfDigest?: string; artifactRequestIds: string[]; pdfByteDeterministic?: false; volatilePdfMetadata?: Record; }; } export interface FailedRenderReport extends RenderReportBase { status: "failed"; failure: { code: DocxodusExportErrorCode; severity: "error"; phase: ExportPhase; message: string; remediation: string; detail?: string; pending?: string[]; partUri?: string; anchorId?: string; resource?: string; }; environment?: { rendererFingerprint?: string; verification: EnvironmentVerification; fidelityTier?: FidelityTier; observed?: ExportRuntimeObservedFacts; attested?: ExportRuntimeAttestationEvidence; attestationDigest?: string; }; partial?: { pages?: CompleteRenderReport["pages"]; bindings?: Partial; }; unavailable: Array<{ field: "environment.rendererFingerprint" | "bindings.pageMapDigest" | "bindings.htmlDigest" | "bindings.pdfDigest"; reasonCode: "notReached" | "notRequested" | "failedVerification" | "discardedOnFailure"; detail: string; }>; } export type RenderReport = CompleteRenderReport | FailedRenderReport; export interface PaginatedRenderMetadata { pageCount: number; pageMap: PageMap; renderReport: CompleteRenderReport; warnings: RenderWarning[]; rendererFingerprint: string; } export interface PaginatedHtmlResult extends PaginatedRenderMetadata { html: string; } export declare class DocxodusExportError extends Error { readonly code: DocxodusExportErrorCode; readonly phase: ExportPhase; readonly remediation: string; readonly detail?: string; readonly pending?: readonly string[]; readonly partUri?: string; readonly anchorId?: string; readonly resource?: string; readonly cause?: unknown; report?: FailedRenderReport; constructor(code: DocxodusExportErrorCode, phase: ExportPhase, message: string, remediation: string, options?: { detail?: string; pending?: readonly string[]; partUri?: string; anchorId?: string; resource?: string; cause?: unknown; report?: FailedRenderReport; }); toJSON(): Record; } /** * Rebuilds a `DocxodusExportError` from a `DocxodusExportError.toJSON()`-shaped object that * crossed a serialization boundary (a Node-backed `FontResolver` reaching the page as a * Playwright binding, for instance), so the original code/phase/remediation survive instead * of collapsing into a generic message string. Returns `undefined` for anything that isn't * recognizably a serialized `DocxodusExportError`. */ export declare function reconstructDocxodusExportError(value: unknown): DocxodusExportError | undefined; /** * Host integration only — `@docxodus/export` calls this from the bootstrap module it generates and * serves. The host reads and hashes the whole runtime asset graph once per process and serves exactly * those verified bytes, so when the manifest this page fetches hashes to the attested digest, the page * does not fetch and hash all ~26 MB of runtime assets again for every document. The manifest itself * and the materializer bundle are still checked here. A page that never receives an attestation (any * browser-only deployment) verifies every asset as before. */ export declare function attestHostVerifiedRuntimeAssets(manifestSha256: string): void; export { canonicalJson }; /** * Convert DOCX bytes into a complete offline HTML document containing only the * finalized fixed page tree and its inline resources. */ export declare function convertDocxToPaginatedHtml(document: File | Uint8Array, requestedOptions: PaginatedHtmlOptions): Promise; //# sourceMappingURL=export-browser.d.ts.map