import { type DeriveContext, type DeriveMiss, type DeriveOutcome } from "./derive.js"; import type { MadeBy, Provider, ProviderCall, ProviderSource, RenderedImage } from "./provider.js"; /** Time for one document's text: the time hosts already give `pdftotext` (read 2026-10-11). */ export declare const PDF_TEXT_TIMEOUT_MS = 120000; /** Time for one page's render: a 200 dpi scan takes 0.9 s in poppler and 0.5 s in PDFium (measured 2026-10-11); a page that takes a minute is not one to read. */ export declare const PDF_RENDER_TIMEOUT_MS = 60000; /** The memory of a worker reading a PDF, its JavaScript heap and, for PDFium, its WASM memory: pdf.js held 455 MB for 200 pages (measured 2026-10-11). */ export declare const PDF_WORKER_MEMORY_MB = 1024; /** The most pixels one page render may have: a 150 dpi render of an A0 sheet. The planner asks for at most 2,000 px on a long edge (4 MP); a bitmap is 4 bytes a pixel in WASM beside a copy and the PNG's rows (2026-10-11). */ export declare const PDF_RENDER_MAX_PIXELS = 25000000; /** Why a PDF could not be read, as the model reads it after the file's name. */ export type PdfMiss = DeriveMiss; /** What a PDF operation gave: its value, or the miss that says why there is none. */ export type PdfOutcome = DeriveOutcome; /** What the file's own structure says: pages and their sizes in points, with each page's rotation applied. */ export type PdfInfo = { readonly pages: number; readonly pageSizes: readonly { readonly width: number; readonly height: number; }[]; readonly producer?: string; readonly creator?: string; }; /** The free facts of a document. `revisions` counts the times the file was saved (1 for a file written once) and * `signatures` the signature dictionaries in it; both are null for a file over `SOURCE_BYTES_IN_PROCESS`, which is not * scanned. */ export type PdfFacts = PdfInfo & { /** The 1-based pages that have a text layer. */ readonly textPages: readonly number[]; readonly revisions: number | null; readonly signatures: number | null; }; /** A document read: the facts and the text layer of every page ("" for a page with none). */ export type PdfDocument = { readonly madeBy: MadeBy; readonly facts: PdfFacts; readonly pages: readonly string[]; }; /** A provider of PDF text that also reads the file's structure in the same pass. A provider that only declares `text` is * used too, and its document has no page sizes. */ export type PdfProvider = Provider & { document(source: ProviderSource, call: ProviderCall): Promise<{ readonly madeBy: MadeBy; readonly pages: readonly string[]; readonly info?: PdfInfo; }>; }; export { ProviderMiss as PdfProviderError } from "./derive.js"; /** What a PDF operation runs with: the environment, the providers to try, where derivations are kept and the signal. */ export type PdfContext = DeriveContext; /** What a worker may use: milliseconds and megabytes of heap, and the signal that stops it. */ export type PdfWorkerCaps = { readonly timeoutMs: number; readonly memoryMb: number; readonly signal?: AbortSignal; }; /** Runs `script`, plain JavaScript with no `require` or `import` statement, in a worker thread of a child process of its * own, with `input` as its `workerData`. The script posts `{ value }` or `{ error: { name, message } }` once. A file can * make an engine run out of heap past the point where V8 can still stop one thread, and V8 then aborts the whole * process: that ends the child, never the host. A child that runs out of time or heap is killed and the call is an * `over_budget` error; one that cannot be started is a `needs` error. The child has no environment variables, no output * and no way to outlive its host. The script is a string, so a bundled host carries it. */ export declare function runPdfWorker(script: string, input: Record, caps: PdfWorkerCaps): Promise; /** The module URL and installed version of a dependency, as the package's own manifest says them. */ export declare function resolvePdfDependency(name: string): Promise<{ readonly url: string; readonly version: string; }>; /** The bytes of a source for a reader that holds the whole file: refused over the in-process cap. */ export declare function readPdfBytes(source: ProviderSource, call: ProviderCall): Promise; /** The facts and the text of every page, from the first provider that reads the file; kept once per content and provider. */ export declare function pdfDocument(source: ProviderSource, ctx: PdfContext): Promise>; /** A page as a PNG at `dpi`: its size is the page's size in points times dpi over 72, rounded up. `path` is where the * render is kept, or null when the host keeps nothing. */ export declare function pdfPage(source: ProviderSource, ctx: PdfContext, request: { readonly page: number; readonly dpi: number; }): Promise>; /** The text with a mark before each page, as `read` shows a document: a page with no text layer is listed, not dropped. */ export declare const pdfMarkedText: (pages: readonly string[]) => string; /** The text of a PDF held in memory, each page headed `[page N]`; null when no page has text (a scan), no provider can * read it, or the caller has stopped waiting. The bytes are written to the environment for the providers, and removed. */ export declare function pdfText(bytes: Uint8Array, ctx: Omit): Promise;