import type { PostextContent, PostextConfig } from '../types.js'; import type { VDTDocument } from '../vdt.js'; import type { BuildPassInfo, BuildProgress } from '../pipeline/build.js'; /** Where a build's time went (dev tooling; always attached, cheap). */ export interface BuildStats { /** Every placement pass, in build order. */ passes: BuildPassInfo[]; /** Wall time of the whole build inside the worker, in ms. */ totalMs: number; /** The document came from the worker's cache (no pass was run). */ cached?: boolean; /** Font families the document's text is set in that the worker could not * find — neither registered with `registerFonts` nor installed — so they * were measured with a fallback font. Absent when every family was there. */ missingFonts?: string[]; } export interface FontPayload { family: string; weight: string; style: string; unicodeRange?: string; /** Transferred to the worker. Becomes detached on the sender side. */ buffer: ArrayBuffer; } export type RequestMessage = { kind: 'registerFonts'; id: number; faces: FontPayload[]; } | { kind: 'unregisterFonts'; id: number; /** Family names to drop from the worker's face set. All faces whose * family matches are removed from `document.fonts` and from the * internal dedup map, so the next `registerFonts` for the same * family takes effect instead of being deduped. */ families: string[]; } | { kind: 'build'; id: number; content: PostextContent; config?: PostextConfig; /** Fingerprint of `content.resources`. When it matches the list the * worker last received, `content.resources` may be left out and the * worker lays out with the list it already holds — the resources of * a book (hundreds of tables and figures) are the bulk of a build * message and change far less often than the text. */ resourcesKey?: string; /** Fingerprint of everything the document depends on. The worker * keeps the last few documents by it: a build whose key it holds * is answered from the cache, and a finished build is stored under * it. Omit for a document not worth keeping (screen geometry). */ cacheKey?: string; /** False: build (and cache) the document but do not send it back — * warming the cache for a chapter the reader may open next. */ wantDoc?: boolean; } | { kind: 'cancel'; /** Id of the in-flight build to cancel. */ id: number; } | { kind: 'dispose'; }; export type ResponseMessage = { kind: 'built'; id: number; /** Null when the build asked for no document (`wantDoc: false`). */ doc: VDTDocument | null; stats: BuildStats; } | { kind: 'progress'; id: number; progress: BuildProgress; } | { kind: 'fontsRegistered'; id: number; } | { kind: 'fontsUnregistered'; id: number; } | { kind: 'cancelled'; id: number; } | { kind: 'error'; id: number; message: string; stack?: string; }; //# sourceMappingURL=protocol.d.ts.map