/** * Codex accuracy overlay for ``. * * When a host passes a `codex` client, `LensPDFDemo` fires * `extractStream` in the background. This module wraps the codex * render APIs (renderSeparations, renderHeatmap, renderLayer) into * the `ViewerServices` slot interface so the viewer can swap in * Ghostscript-accurate renders silently once they arrive. * * This module has **no import of `@printwithsynergy/codex-client`**. * It defines a minimal structural interface — any object whose shape * matches `MinimalCodexClient` (including `HttpClient` from * `@printwithsynergy/codex-client`) satisfies it. * * @public */ import type { LayerService, SeparationService, TACHeatmapService } from "../plugin/services"; import type { DetectedInk } from "./index"; /** * Minimal subset of `@printwithsynergy/codex-client`'s `HttpClient` * that `LensPDFDemo` uses for the accuracy overlay. Any object * implementing this interface (including `HttpClient`) is accepted. * * @public */ export interface MinimalCodexClient { extractStream(pdf: ArrayBuffer | Uint8Array, callbacks: { granular?: boolean; onColorWorld?: (data: Record) => void; onOcgs?: (data: Record) => void; onPhase2?: (doc: { pdf_sha256: string; [key: string]: unknown; }) => void; }): Promise<{ pdf_sha256: string; [key: string]: unknown; }>; renderSeparations(pdf: { sha256: string; }, opts?: { page?: number; dpi?: number; }): Promise<{ channels: Array<{ name: string; type: string; png_b64: string; }>; }>; renderHeatmap(pdf: { sha256: string; }, opts?: { page?: number; dpi?: number; tacLimit?: number; }): Promise<{ png: Uint8Array; }>; renderLayer(pdf: { sha256: string; }, opts: { page?: number; layerIndex: number; allLayerIndices: number[]; dpi?: number; }): Promise; /** * Ghostscript-exact per-plate ink coverage (matches codex-client's * `computeCoverage` → `POST /v1/coverage`). Optional so older clients that * predate it still satisfy this structural type — the overlay feature-detects * with `typeof client.computeCoverage === "function"`. `computed` is `false` * when the renderer (Ghostscript) is unavailable. */ computeCoverage?(pdf: { sha256: string; }, opts?: { page?: number; dpi?: number; }): Promise<{ separations: Array<{ name: string; coverage_percent: number; is_process?: boolean; is_spot?: boolean; is_technical?: boolean; }>; computed: boolean; notes?: string[]; }>; } /** * Extract a `DetectedInk[]` from codex's `color_world` SSE event payload. * * codex emits `color_world` as `{ output_intents, color_spaces }`, where the * spot colorants are **nested inside each color space** — `color_spaces[]` is a * list of `{ id, family, spot_colorants: [{ name, rgb: [0..1]³|null, … }] }` * (see codex `CodexColorSpace` / `CodexSpotColorant`). We collect every nested * spot colorant (deduped by name), and include the four CMYK process plates * **only when** the document actually uses a process color family — or when no * spots were found (a normal process doc, or one codex couldn't classify, still * shows CMYK). A spot-only file therefore lists just its spots, with no phantom * CMYK. (Earlier versions read a non-existent root `colorWorld.spot_colorants`, * so codex-detected spots never surfaced and CMYK always showed.) * * @public */ export declare function extractInksFromColorWorld(colorWorld: Record): DetectedInk[]; /** * Extract a layer list from the `ocgs` SSE event payload. * * @public */ export declare function extractLayersFromOcgs(ocgs: Record): Array<{ name: string; ocg_index: number; default_on: boolean; }>; export interface CodexOverlayServices { separations: SeparationService; tacHeatmap: TACHeatmapService; layers: LayerService; subscribe(listener: () => void): () => void; dispose(): void; } /** * Build `separations`, `tacHeatmap`, and `layers` service slots backed * by the codex render APIs. Lazy: each page's renders are fetched the * first time they're requested, then cached as blob URLs. * * Hosts swap these into `ViewerServices` after `phase2_complete` fires * so pdfjs approximations are replaced by Ghostscript renders. * * @public */ export declare function createCodexOverlayServices(client: MinimalCodexClient, sha256: string, tacLimit: number, layerData: ReadonlyArray<{ name: string; ocg_index: number; default_on: boolean; }>): CodexOverlayServices; //# sourceMappingURL=codexOverlay.d.ts.map