/** * 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 { FontConfigurationIdentity, 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, } from "./font-contract.js"; export { inventoryDocumentFontRequests, parseCssFontFamily } from "./font-runtime.js"; export type { FontConfigurationIdentity, 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"; export type CommentProfile = "hidden" | "inline" | "endnotes" | "margin"; 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; export interface PaginatedHtmlOptions { documentVersion?: number; expectedSourceDigest?: string; reviewProfile: ReviewProfile; reviewProfileAlreadyApplied?: boolean; commentProfile: CommentProfile; title?: 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; commentProfile: CommentProfile; title: string; outputs: Array<"html" | "pdf">; layoutDigest: string; runtimePolicyDigest: string; policy: { unsupportedContent: UnsupportedContentPolicy; strictFonts: boolean; timeoutMs: number; limits: ExportResourceLimits; }; }; readiness: ReadinessOutcome[]; fonts: FontResolution[]; 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; 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