@embedpdf/engine-services 3.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1481 @@
1
+ import { ActionReadBudget, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentSecurityProbeInfo, EmbeddedFileItem, EmbeddedFileRef, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometrySnapshot, PageInsertResult, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
2
+ import { PdfFunctions, PdfRuntimeMemory, PdfRuntimeModule, Ptr } from "@embedpdf/engine-runtime";
3
+ //#region src/runtime/lifecycle/bootstrap.d.ts
4
+ /**
5
+ * Initialize the thread-confined PDFium runtime for the calling thread. Each
6
+ * worker thread owns its own PDFium state, so this must run on every thread
7
+ * that uses the runtime. Safe to call multiple times.
8
+ */
9
+ declare function ensureInitialized(runtime: PdfRuntimeModule): void;
10
+ /**
11
+ * Tear down PDFium for the calling thread. Lifecycle-strict: every PDFium
12
+ * handle created on this thread must already be closed.
13
+ */
14
+ declare function destroyLibrary(runtime: PdfRuntimeModule): void;
15
+ //#endregion
16
+ //#region src/shared/abort.d.ts
17
+ /**
18
+ * Throw if the AbortSignal has been aborted. Service code peppers calls to
19
+ * this between PDFium calls so cooperative cancellation works without
20
+ * needing async/await.
21
+ */
22
+ declare function throwIfAborted(signal: AbortSignal): void;
23
+ //#endregion
24
+ //#region src/shared/uuid.d.ts
25
+ /**
26
+ * Generate an RFC 4122 v4 UUID using the Web Crypto API surface that's
27
+ * available in every realm we ship to: Node 19+ (global), Web Workers,
28
+ * browsers (https), browsers (http/intranet/file:), and Edge runtimes.
29
+ *
30
+ * Why this implementation, exactly:
31
+ * - `crypto.randomUUID()` was historically gated to *secure contexts*
32
+ * in older browsers and we shipped that bug to production once.
33
+ * `getRandomValues()` has no such restriction.
34
+ * - `import { randomUUID } from 'crypto'` makes Vite externalize the
35
+ * `crypto` module for browser builds and emit a build-time warning;
36
+ * we then crash at runtime in the rare path that hits it.
37
+ * - 16 bytes + RFC 4122 bit-twiddling is six lines and correct.
38
+ *
39
+ * Output is the canonical hex form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`,
40
+ * where `y` is one of `8/9/a/b` (variant nibble = 10xx).
41
+ */
42
+ declare function generateUuid(): string;
43
+ //#endregion
44
+ //#region src/shared/pdf-date.d.ts
45
+ /**
46
+ * PDF date string format conversion utilities.
47
+ *
48
+ * PDF stores timestamps as ASCII strings shaped like
49
+ * `D:YYYYMMDDHHmmSSOHH'mm'`, where `O` is `+` / `-` / `Z` (Z means
50
+ * UTC and omits the offset). See ISO 32000 §7.9.4.
51
+ *
52
+ * The wire format used by the engine DTOs is always ISO 8601;
53
+ * readers convert PDF → ISO via {@link pdfDateToIso}, writers convert
54
+ * the other way via {@link formatPdfDate}.
55
+ */
56
+ /**
57
+ * Parse a PDF date string `D:YYYYMMDDHHmmSSOHH'mm'` to an ISO 8601
58
+ * string. Returns null if the input is malformed.
59
+ *
60
+ * When the timezone is omitted, PDF defines the relationship to UTC as
61
+ * unknown. Since the engine DTO wire format requires an absolute ISO 8601
62
+ * timestamp, this converter retains the pre-existing fallback of treating
63
+ * an omitted timezone as UTC.
64
+ */
65
+ declare function pdfDateToIso(pdf: string): string | null;
66
+ /**
67
+ * Format a JS Date as a PDF date string `D:YYYYMMDDHHmmSSOHH'mm'`.
68
+ *
69
+ * Emits the offset in PDF's funny `OHH'mm'` form, where the apostrophe
70
+ * after the hour is literal and the offset always carries a sign. UTC
71
+ * is emitted as `+00'00'` (not `Z`) for maximum reader compatibility —
72
+ * the `Z` shorthand is allowed by the spec but not universally
73
+ * supported.
74
+ *
75
+ * Always uses the supplied Date's local fields and offset. For
76
+ * server-side stamps callers typically pass `new Date()` (default).
77
+ */
78
+ declare function formatPdfDate(d?: Date): string;
79
+ //#endregion
80
+ //#region src/runtime/memory/bits.d.ts
81
+ /**
82
+ * Coerce a value to an unsigned 32-bit integer. PDFium permission words
83
+ * arrive as signed JS numbers (the high bit makes them negative); reading
84
+ * them as `u32` restores the bit pattern the PDF spec describes.
85
+ */
86
+ declare function u32(value: number): number;
87
+ //#endregion
88
+ //#region src/shared/securityPermissions.d.ts
89
+ /**
90
+ * PDF Standard security handlers reserve bits 1-2 as 0, and PDFium masks
91
+ * even owner permissions through that convention — so "all permissions"
92
+ * for an encrypted document is `0xFFFFFFFC`, not `0xFFFFFFFF`.
93
+ */
94
+ declare const ALL_STANDARD_SECURITY_PERMISSIONS = 4294967292;
95
+ /** Coerce PDFium's signed permission word to its unsigned 32-bit value. */
96
+ declare const normalizeU32: typeof u32;
97
+ /** True when `bits` grants every standard security permission. */
98
+ declare function hasAllStandardSecurityPermissions(bits: number): boolean;
99
+ //#endregion
100
+ //#region src/events/EventHub.d.ts
101
+ /**
102
+ * The in-process implementation of `DocumentEventStream`, shared by both
103
+ * engine shells (one hub per open `DocumentHandle`). The engine that
104
+ * performs a mutation publishes here at confirmation time; the cloud
105
+ * engine's remote channel will also publish here for OTHER sessions'
106
+ * mutations — listeners never learn which transport delivered an event.
107
+ *
108
+ * Delivery contract:
109
+ * - synchronous fan-out in subscription order;
110
+ * - error isolation: a throwing listener is re-thrown on a microtask
111
+ * (so it surfaces to the host's unhandled-error reporting) without
112
+ * blocking other listeners or failing the mutation path;
113
+ * - `lastServerId` tracks the highest remote cursor seen, for the
114
+ * remote channel's reconnect/backfill.
115
+ */
116
+ declare class EventHub implements DocumentEventStream {
117
+ /** Where a throwing listener's error goes. Defaults to an async
118
+ * rethrow so it reaches the host's unhandled-error reporting. */
119
+ private readonly onListenerError;
120
+ private readonly listeners;
121
+ private serverId;
122
+ constructor(
123
+ /** Where a throwing listener's error goes. Defaults to an async
124
+ * rethrow so it reaches the host's unhandled-error reporting. */
125
+ onListenerError?: (err: unknown) => void);
126
+ subscribe(listener: (event: DocumentEvent) => void): () => void;
127
+ publish(event: DocumentEvent): void;
128
+ lastServerId(): number | null;
129
+ /** Drop every listener (handle close). Idempotent. */
130
+ clear(): void;
131
+ }
132
+ /**
133
+ * Stamps provenance onto events a mutation path produces. One per open
134
+ * handle: the engine shell constructs it with the instance's `sessionId`
135
+ * (and, on cloud, the authenticated `sub` when known) and hands it to the
136
+ * mutation services — they publish results, never build origins.
137
+ */
138
+ declare class SessionEventPublisher {
139
+ private readonly hub;
140
+ private readonly sessionId;
141
+ private readonly sub;
142
+ constructor(hub: EventHub, sessionId: string, sub?: string | null);
143
+ /** Publish a mutation THIS engine instance just confirmed. */
144
+ publishLocal(event: DocumentEventInit): void;
145
+ }
146
+ //#endregion
147
+ //#region src/document-session/lifecycle/PdfDocumentOpener.d.ts
148
+ type OpenedPdfDocumentKind = 'fat-memory' | 'layer';
149
+ interface OpenedPdfDocument {
150
+ readonly kind: OpenedPdfDocumentKind;
151
+ readonly docPtr: Ptr;
152
+ close(): void;
153
+ }
154
+ interface AcquiredBaseDocument {
155
+ readonly key: string;
156
+ readonly basePtr: Ptr;
157
+ release(): void;
158
+ }
159
+ type LayerSource = {
160
+ readonly kind: 'fresh';
161
+ } | {
162
+ readonly kind: 'raw-delta';
163
+ readonly bytes: Uint8Array | ArrayBuffer;
164
+ } | {
165
+ readonly kind: 'artifact';
166
+ readonly bytes: Uint8Array | ArrayBuffer;
167
+ } | {
168
+ readonly kind: 'artifact-file';
169
+ readonly path: string;
170
+ };
171
+ declare class CloseStack {
172
+ private readonly actions;
173
+ private closed;
174
+ push(action: () => void): void;
175
+ close(): void;
176
+ }
177
+ declare function openFatMemoryDocument(runtime: PdfRuntimeModule, bytes: Uint8Array, password?: string | null): OpenedPdfDocument;
178
+ declare function openLayerDocument(runtime: PdfRuntimeModule, base: AcquiredBaseDocument, layer?: LayerSource, password?: string | null): OpenedPdfDocument;
179
+ //#endregion
180
+ //#region src/document-session/pages/PagePtrPool.d.ts
181
+ /**
182
+ * Manages pagePtr lifetime for a single open `DocumentSession`.
183
+ *
184
+ * `acquire(pon)` returns a loaded pagePtr for the given PDF object number,
185
+ * loading it via `EPDFDoc_LoadPageByObjectNumberNormalized` (rotation forced
186
+ * to 0deg so render/text/geometry/annotation coordinates all share one
187
+ * normalized space) if not already in the pool. `release(pon)` decrements the
188
+ * refcount and closes when it reaches
189
+ * zero; `closeAll()` is called by `DocumentSession.close()`.
190
+ *
191
+ * While at least one holder is active the pagePtr is shared (refcounted),
192
+ * so overlapping `acquire(pon)` calls for the same page reuse a single
193
+ * load. Once the refcount reaches zero the page is closed; a later
194
+ * `acquire` reloads it — there is no LRU retention across the zero-ref
195
+ * boundary. A future slice could add that without changing callers.
196
+ */
197
+ declare class PagePtrPool {
198
+ private readonly runtime;
199
+ private readonly docPtr;
200
+ private readonly counts;
201
+ constructor(runtime: PdfRuntimeModule, docPtr: Ptr);
202
+ acquire(pageObjectNumber: PageObjectNumber): Ptr;
203
+ /**
204
+ * True while at least one holder has the page open. Page-STRUCTURE
205
+ * mutations (delete) assert on this: thread confinement means no other
206
+ * job can be mid-flight, so a held pagePtr during a structural mutation
207
+ * is a leaked `acquire` (an internal bug) — the mutator fails loudly
208
+ * instead of mutating under a live handle.
209
+ */
210
+ isHeld(pageObjectNumber: PageObjectNumber): boolean;
211
+ release(pageObjectNumber: PageObjectNumber): void;
212
+ closeAll(): void;
213
+ }
214
+ //#endregion
215
+ //#region src/document-session/pages/PageRecord.d.ts
216
+ /**
217
+ * Record of one page within a `DocumentSession`. Built lazily by
218
+ * `DocumentSession.ensurePageRegistry()`; the registry is only forced
219
+ * to populate fully when a path that needs `pageIndex -> pageObjectNumber`
220
+ * for the whole document is invoked (most notably `listRawAll()`).
221
+ *
222
+ * Carries no `pagePtr`. Lifetime of the actual PDFium page handle is owned
223
+ * by the `PagePtrPool`; the page record is metadata only.
224
+ */
225
+ interface PageRecord {
226
+ pageObjectNumber: PageObjectNumber;
227
+ pageIndex: number;
228
+ }
229
+ //#endregion
230
+ //#region src/document-session/DocumentSession.d.ts
231
+ /**
232
+ * Owns the lifecycle of a single open PDFium document and the v3
233
+ * identity machinery: page registry (pageObjectNumber <-> pageIndex),
234
+ * `RevisionAuthority` (per-page generation counters), and `PagePtrPool`
235
+ * (refcounted pagePtr access).
236
+ *
237
+ * Both the local browser Worker and the server worker_thread instantiate
238
+ * this exactly the same way; the only thing that differs is the
239
+ * underlying PdfRuntimeModule (WASM vs native).
240
+ */
241
+ declare class DocumentSession {
242
+ private readonly runtime;
243
+ private docPtr;
244
+ private closeDocument;
245
+ private _kind;
246
+ private readonly _sessionId;
247
+ /** pon -> record */
248
+ private readonly recordsByObjectNumber;
249
+ /** pageIndex -> record */
250
+ private readonly recordsByIndex;
251
+ private fullyEnumerated;
252
+ private revisions;
253
+ private mutationSeqCounter;
254
+ private pages;
255
+ constructor(runtime: PdfRuntimeModule, sessionId?: string);
256
+ get sessionId(): string;
257
+ get kind(): OpenedPdfDocumentKind | null;
258
+ isOpen(): boolean;
259
+ open(bytes: Uint8Array, password?: string | null): void;
260
+ openFromHandle(handle: OpenedPdfDocument): void;
261
+ /**
262
+ * Park this session in the password-locked state: the document could not
263
+ * be loaded because a (correct) password is missing, so the session keeps
264
+ * the already-transferred bytes and waits for an unlock attempt to load
265
+ * them. A locked session occupies its docId key like an open one — every
266
+ * operation except the password check rejects with DocPasswordRequired.
267
+ */
268
+ parkLocked(bytes: Uint8Array): void;
269
+ isLocked(): boolean;
270
+ /** The bytes retained for a later unlock attempt. Locked sessions only. */
271
+ lockedBytes(): Uint8Array;
272
+ private parkedBytes;
273
+ /** Number of pages in the document. */
274
+ pageCount(): number;
275
+ /**
276
+ * Lazily enumerate every page and cache (pageObjectNumber, pageIndex).
277
+ * Necessary before `listRawAll()` and any pon -> pageIndex resolution.
278
+ */
279
+ ensureFullPageRegistry(): void;
280
+ /** Lookup; populates the cache for one page only on cache miss. */
281
+ recordByObjectNumber(pageObjectNumber: PageObjectNumber): PageRecord;
282
+ /** All page records, in display order. Forces full enumeration. */
283
+ allRecords(): PageRecord[];
284
+ /**
285
+ * Drop the cached `pageIndex <-> pageObjectNumber` mapping and force a
286
+ * fresh enumeration on next access. Called by `PagesMutator`
287
+ * after `FPDF_MovePages` shuffles page positions; we keep
288
+ * weak-annotation knowledge and per-page revision counters intact, both of
289
+ * which are keyed by durable `pageObjectNumber` and survive a page reorder.
290
+ */
291
+ refreshPageRegistry(): void;
292
+ /** Per-page liveness envelope used by annotation read/mutation results. */
293
+ pageState(pageObjectNumber: PageObjectNumber): PageState;
294
+ /** Set by readers as they discover whether a page has weak annotations. */
295
+ recordWeakFlag(pageObjectNumber: PageObjectNumber, hasWeak: boolean): void;
296
+ recordWeakAnnotationState(pageObjectNumber: PageObjectNumber, state: WeakAnnotationState): void;
297
+ weakAnnotationState(pageObjectNumber: PageObjectNumber): WeakAnnotationState;
298
+ /** Bump and return the new revision token; called by mutation paths. */
299
+ bumpRevision(pageObjectNumber: PageObjectNumber): RevisionToken;
300
+ /**
301
+ * Monotonic count of successful document mutations in this session.
302
+ * Version key for detached-snapshot caches (e.g. the forms model):
303
+ * a cache entry built at sequence N is exactly valid while the
304
+ * sequence is still N. Coarse on purpose — widgets are annotations
305
+ * and page ops move widgets, so ANY mutation may affect derived
306
+ * form state; per-domain counters are a later optimization.
307
+ */
308
+ mutationSeq(): number;
309
+ /** Record one successful mutation; called by mutation paths. */
310
+ noteMutation(): void;
311
+ /**
312
+ * Forget a page's per-session state (revision generation + weak-annotation
313
+ * flag). Called by `pages.delete` after the page object is retired; the
314
+ * PON is never recycled, so this is hygiene, not correctness.
315
+ */
316
+ dropPageState(pageObjectNumber: PageObjectNumber): void;
317
+ validateRevision(token: RevisionToken): void;
318
+ pagePool(): PagePtrPool;
319
+ requireDocPtr(): Ptr;
320
+ /**
321
+ * Park a disposer to run when THIS session closes. Used by operations
322
+ * whose native side leaves the session document referencing another
323
+ * resource — e.g. `pages.insert`: `FPDF_ImportPagesByIndex` does not
324
+ * fully detach imported objects from their source document, so the
325
+ * source doc + its byte buffer must stay alive until the destination
326
+ * can no longer be saved (i.e. until this session closes).
327
+ */
328
+ retainUntilClose(dispose: () => void): void;
329
+ private readonly retained;
330
+ close(): void;
331
+ private requireRevisions;
332
+ }
333
+ //#endregion
334
+ //#region src/document-session/lifecycle/BaseDocumentRegistry.d.ts
335
+ declare class BaseDocumentRegistry {
336
+ private readonly runtime;
337
+ private readonly entries;
338
+ constructor(runtime: PdfRuntimeModule);
339
+ acquireMemoryBase(opts: {
340
+ key: string;
341
+ bytes: Uint8Array;
342
+ password?: string | null;
343
+ }): AcquiredBaseDocument;
344
+ acquireFileBase(opts: {
345
+ key: string;
346
+ path: string;
347
+ password?: string | null;
348
+ }): AcquiredBaseDocument;
349
+ releaseAll(): void;
350
+ /** @internal Test-only probe of the per-key share refcount. */
351
+ getRefCountForTesting(key: string): number;
352
+ private retain;
353
+ private insert;
354
+ private handleFor;
355
+ }
356
+ //#endregion
357
+ //#region src/document-session/revisions/RevisionAuthority.d.ts
358
+ interface RevisionAuthority {
359
+ readonly docSessionId: string;
360
+ token(pageObjectNumber: PageObjectNumber): RevisionToken;
361
+ bump(pageObjectNumber: PageObjectNumber): RevisionToken;
362
+ validate(token: RevisionToken): void;
363
+ weakAnnotationState(pageObjectNumber: PageObjectNumber): WeakAnnotationState;
364
+ recordWeakAnnotationState(pageObjectNumber: PageObjectNumber, state: WeakAnnotationState): void;
365
+ /** Forget a page entirely (generation + weak state). Called when the page
366
+ * is DELETED — its object number is retired, never recycled, so dropping
367
+ * is hygiene, not correctness. */
368
+ drop(pageObjectNumber: PageObjectNumber): void;
369
+ clear(): void;
370
+ }
371
+ /**
372
+ * Per-page generation counter. Backs `RevisionToken` so weak
373
+ * `AnnotationRef.kind === 'index'` references can be validated against the
374
+ * exact page state they were minted from.
375
+ *
376
+ * `bump()` is the only mutator; mutation services call it after a
377
+ * structural change to the page (annotation create/delete/reorder).
378
+ * Read paths never mutate the store.
379
+ */
380
+ declare class LocalRevisionAuthority implements RevisionAuthority {
381
+ readonly docSessionId: string;
382
+ private readonly generations;
383
+ private readonly weakAnnotationStates;
384
+ constructor(docSessionId: string);
385
+ /** Returns the current generation, defaulting to 0 for first read. */
386
+ current(pageObjectNumber: PageObjectNumber): number;
387
+ /** Mints a fresh `RevisionToken` for the page's current generation. */
388
+ token(pageObjectNumber: PageObjectNumber): RevisionToken;
389
+ /**
390
+ * Increments the generation counter for a page. Returns the new token.
391
+ * Called by mutation services after every structural change.
392
+ */
393
+ bump(pageObjectNumber: PageObjectNumber): RevisionToken;
394
+ /**
395
+ * Strict equality check. Throws `EngineError(InvalidReference)` when the
396
+ * caller's token does not match what the store currently holds.
397
+ */
398
+ validate(token: RevisionToken): void;
399
+ weakAnnotationState(pageObjectNumber: PageObjectNumber): WeakAnnotationState;
400
+ recordWeakAnnotationState(pageObjectNumber: PageObjectNumber, state: WeakAnnotationState): void;
401
+ drop(pageObjectNumber: PageObjectNumber): void;
402
+ clear(): void;
403
+ }
404
+ //#endregion
405
+ //#region src/features/metadata/MetadataReader.d.ts
406
+ /**
407
+ * Synchronous, runtime-agnostic implementation of the metadata read.
408
+ *
409
+ * Lives in @embedpdf/engine-services so it can be reused unchanged by:
410
+ * - @embedpdf/engine (inside a browser Worker, WASM runtime)
411
+ * - @cloudpdf/server (inside a Node worker_thread, native runtime)
412
+ *
413
+ * Async-ness lives at the worker boundary, not here.
414
+ */
415
+ declare class MetadataReader {
416
+ private readonly runtime;
417
+ private readonly session;
418
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
419
+ read(signal: AbortSignal): DocumentMetadata;
420
+ }
421
+ //#endregion
422
+ //#region src/features/metadata/MetadataMutator.d.ts
423
+ /**
424
+ * Synchronous orchestrator for document metadata writes. Lives next to
425
+ * `MetadataReader` (one orchestrator per feature) so both worker hosts
426
+ * (browser Web Worker and Node `worker_thread`) share the same code path.
427
+ *
428
+ * A metadata write rewrites the document Info dictionary in place. Like
429
+ * `PagesMutator.move`, it is a structural layer edit: it returns the
430
+ * re-read metadata and a `null` cache (the worker never fills cloud
431
+ * coherence pins — the server does, after persisting the artifact and
432
+ * bumping `metadataVersion`).
433
+ */
434
+ declare class MetadataMutator {
435
+ private readonly runtime;
436
+ private readonly session;
437
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
438
+ update(patch: MetadataPatch, signal: AbortSignal): MetadataUpdateResult;
439
+ }
440
+ //#endregion
441
+ //#region src/features/pages/PagesReader.d.ts
442
+ /**
443
+ * Runtime-agnostic page geometry reader. Produces the `pages.list()`
444
+ * snapshot from the lightweight `...ByIndex` PDFium bindings, none of which
445
+ * load or parse a page (no `pagePtr`), so listing stays cheap. Shared
446
+ * verbatim by the local WASM worker and the server native worker, so a
447
+ * given PDF yields an identical `PageListSnapshot` on both engines.
448
+ */
449
+ declare class PagesReader {
450
+ private readonly runtime;
451
+ private readonly session;
452
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
453
+ read(signal: AbortSignal): PageListSnapshot;
454
+ }
455
+ //#endregion
456
+ //#region src/features/pages/PagesMutator.d.ts
457
+ /**
458
+ * Synchronous orchestrator for page-level reads and reorder mutations.
459
+ * Lives next to `AnnotationMutator` (one orchestrator per
460
+ * mutation domain) so both worker hosts (browser Web Worker and Node
461
+ * `worker_thread`) share the same code path.
462
+ *
463
+ * Architectural anchor — locked with the user, do not loosen without
464
+ * re-reading the doc comments on `PageMoveResult` and `RevisionAuthority`:
465
+ *
466
+ * - Pages are addressed by their durable `pageObjectNumber`. There is
467
+ * no "weak page ref" model in the engine; therefore there is no
468
+ * document-level revision token, no `DocumentRevisionStore`, and no
469
+ * "doc-level shouldRefetch" semantic. Anything that *is* listed
470
+ * here must remain stable across every reorder permutation.
471
+ *
472
+ * - Per-page `RevisionToken`s do NOT bump on `move()`. The /Annots
473
+ * array of each affected page is untouched (PDFium just rewrites
474
+ * pointer entries in the doc-level pages tree), so weak
475
+ * `AnnotationRef.kind === 'index'` references the caller is
476
+ * holding remain valid across a page reorder. This is the right
477
+ * semantic for an editing UI: shuffling pages must NOT silently
478
+ * break a pending highlight edit.
479
+ *
480
+ * - Identity strengthening (the opportunistic `/NM` stamping that
481
+ * applies to weak annotations on `update()` / `move()`) is also
482
+ * intentionally absent here. Pages are durable by construction;
483
+ * there is nothing to upgrade.
484
+ */
485
+ declare class PagesMutator {
486
+ private readonly runtime;
487
+ private readonly session;
488
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
489
+ /**
490
+ * Reorder pages. Mirrors `FPDF_MovePages`: detach the supplied pages,
491
+ * then re-insert them as a contiguous block at `destIndex` in the
492
+ * post-removal index space, preserving caller order.
493
+ *
494
+ * Atomicity:
495
+ * - `FPDF_MovePages` rejects atomically: if it returns false, no
496
+ * change has happened. We surface that as `InvalidArg`.
497
+ * - On success we refresh the per-session page registry and read the
498
+ * new layout back, which is what the result returns.
499
+ *
500
+ * Validation done up front (the helper repeats these checks; we do
501
+ * them here for clean error messages):
502
+ * - non-empty inputs;
503
+ * - duplicate `pageObjectNumber`s rejected;
504
+ * - every `pon` resolvable via the session's page registry;
505
+ * - `destIndex` in `[0, pageCount - len]`.
506
+ */
507
+ move(pageObjectNumbers: PageObjectNumber[], destIndex: number, signal: AbortSignal): PageMoveResult;
508
+ /**
509
+ * Set the ABSOLUTE display rotation of the supplied pages. Rotation is
510
+ * presentation metadata over normalized content (pages always load with
511
+ * rotation forced to 0 — see `PagePtrPool`), so:
512
+ * - no cached render, text run, or geometry coordinate changes;
513
+ * - per-page `RevisionToken`s do NOT bump;
514
+ * - page identity and order are untouched — no registry refresh.
515
+ *
516
+ * Atomicity: every PON is resolved up front (`NotFound` on caller error),
517
+ * so the apply loop below operates on validated pages only and each write
518
+ * is absolute + idempotent — a retry after an unexpected mid-loop engine
519
+ * fault converges to the requested state. Abort is honored BEFORE the
520
+ * loop, never inside it.
521
+ */
522
+ rotate(pageObjectNumbers: PageObjectNumber[], rotation: PageRotation, signal: AbortSignal): PageRotateResult;
523
+ /**
524
+ * Delete pages. Deleted object numbers are RETIRED — the engine nulls the
525
+ * page object rather than freeing the number — so per-page state keyed by
526
+ * PON can never silently attach to an unrelated future page; we still drop
527
+ * the session's revision/weak entries as hygiene. Surviving pages keep
528
+ * their identity and `RevisionToken`s.
529
+ *
530
+ * Guards:
531
+ * - a document must keep at least one page (`InvalidArg`);
532
+ * - every PON must resolve (`NotFound`);
533
+ * - no target page may have a live pooled `pagePtr`. Thread confinement
534
+ * means no other job can be mid-flight, so a held ptr here is a leaked
535
+ * `acquire` — an internal bug we surface loudly instead of deleting
536
+ * under a live handle.
537
+ *
538
+ * Abort is honored BEFORE the apply loop, never inside it.
539
+ */
540
+ delete(pageObjectNumbers: PageObjectNumber[], signal: AbortSignal): PageDeleteResult;
541
+ /** Shared input check: non-empty, no duplicate PONs. */
542
+ private requireUniquePons;
543
+ }
544
+ //#endregion
545
+ //#region src/features/pages/PagesExtractor.d.ts
546
+ /**
547
+ * Export a subset of pages as a standalone PDF. A READ over the session:
548
+ * `FPDF_ImportPagesByIndex` copies pages into a scratch document, so the
549
+ * source is untouched — no revision bumps, no registry refresh, no layer
550
+ * artifact. Lives next to `PagesReader`/`PagesMutator` (one file per page
551
+ * verb family) so both worker hosts share the code path.
552
+ */
553
+ declare class PagesExtractor {
554
+ private readonly runtime;
555
+ private readonly session;
556
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
557
+ /**
558
+ * Copy the given pages, in the supplied caller order, into a new
559
+ * document and serialize it. Validation up front: non-empty, no
560
+ * duplicates, every PON resolvable (`NotFound` from the session on a
561
+ * bad one). The scratch document is always closed, success or throw.
562
+ */
563
+ extract(pageObjectNumbers: PageObjectNumber[], signal: AbortSignal): {
564
+ bytes: ArrayBuffer;
565
+ size: number;
566
+ };
567
+ }
568
+ //#endregion
569
+ //#region src/features/pages/PagesInserter.d.ts
570
+ /**
571
+ * Insert every page of a standalone PDF into the session document. A
572
+ * structural MUTATION (like move/delete): the source bytes are loaded as a
573
+ * throwaway PDFium document, `FPDF_ImportPagesByIndex` deep-copies its
574
+ * pages in at `destIndex`, and the page registry is rebuilt. Pre-existing
575
+ * pages keep their identity and `RevisionToken`s; the inserted copies get
576
+ * fresh object numbers, resolved from the post-insert registry.
577
+ */
578
+ declare class PagesInserter {
579
+ private readonly runtime;
580
+ private readonly session;
581
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
582
+ insert(bytes: ArrayBuffer, destIndex: number | undefined, signal: AbortSignal): PageInsertResult;
583
+ }
584
+ //#endregion
585
+ //#region src/features/pages/PagesFlattener.d.ts
586
+ /** Layer-safe page flattening. Content and annotation liveness change together. */
587
+ declare class PagesFlattener {
588
+ private readonly runtime;
589
+ private readonly session;
590
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
591
+ flatten(pageObjectNumbers: PageObjectNumber[], usage: PageFlattenUsage, signal: AbortSignal): PageFlattenResult;
592
+ }
593
+ //#endregion
594
+ //#region src/features/redaction/RedactionApplier.d.ts
595
+ /**
596
+ * The destructive half of redaction (see `DocumentRedactionService` for the
597
+ * model and the layer trust boundary). Content and annotation liveness
598
+ * change together, exactly like {@link PagesFlattener} — this class mirrors
599
+ * its validate-then-apply boundary and ordered-batch semantics.
600
+ *
601
+ * Scope semantics:
602
+ * - `pages`: every REDACT annotation on each listed page is applied; a
603
+ * page with none is `unchanged`.
604
+ * - `annotations`: exactly the referenced REDACT annotations are applied.
605
+ * Every ref is resolved and subtype-checked BEFORE the first native
606
+ * write; a non-REDACT ref rejects the whole call with `InvalidArg`.
607
+ *
608
+ * The per-page `removedAnnotationCount` is the native collateral count:
609
+ * annotations other than REDACT ones removed alongside the apply (popup
610
+ * cascades and detached widgets included).
611
+ */
612
+ declare class RedactionApplier {
613
+ private readonly runtime;
614
+ private readonly session;
615
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
616
+ apply(scope: RedactionApplyScope, signal: AbortSignal): RedactionApplyResult;
617
+ /**
618
+ * Normalize the scope into an ordered per-page plan. `null` refs means
619
+ * "every REDACT annotation on the page" (the `pages` scope).
620
+ */
621
+ private buildPlan;
622
+ /**
623
+ * Validate every ref BEFORE the first native write: it must resolve and
624
+ * it must be a REDACT annotation. After this returns, the apply loop's
625
+ * writes begin and per-page failures are recorded, not thrown.
626
+ */
627
+ private preflight;
628
+ private applyAllOnPage;
629
+ private applyRefsOnPage;
630
+ }
631
+ //#endregion
632
+ //#region src/features/text/PageTextReader.d.ts
633
+ /**
634
+ * Per-page slow-path text reader. Acquires a `pagePtr` from the
635
+ * `PagePtrPool`, opens a PDFium text page (`FPDFText_LoadPage`),
636
+ * extracts the full UTF-16 buffer with `FPDFText_GetText`, decodes,
637
+ * and releases everything in reverse order.
638
+ *
639
+ * Memory model:
640
+ * - `count` is in UTF-16 code units (FPDFText's "char").
641
+ * - The buffer needs `(count + 1) * 2` bytes (PDFium writes a
642
+ * trailing NUL terminator).
643
+ * - `mem.readU16String` walks the buffer up to the NUL and decodes
644
+ * to a JS string, faithfully preserving surrogate pairs.
645
+ *
646
+ * Errors:
647
+ * - `EPDFDoc_LoadPageByObjectNumber` returning 0 is `NotFound`
648
+ * (raised by `PagePtrPool.acquire`).
649
+ * - `FPDFText_LoadPage` returning 0 is `RuntimeUnavailable` — should
650
+ * not happen on a healthy page; treat it as a runtime bug rather
651
+ * than user error.
652
+ */
653
+ declare class PageTextReader {
654
+ private readonly runtime;
655
+ private readonly session;
656
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
657
+ read(pageObjectNumber: PageObjectNumber, signal: AbortSignal): PageTextSnapshot;
658
+ }
659
+ //#endregion
660
+ //#region src/features/geometry/PageGeometryReader.d.ts
661
+ /**
662
+ * Geometry-only text layout reader.
663
+ *
664
+ * Emits geometry in PDF user space (y-up edges) — the canonical engine
665
+ * geometry. The viewer converts to content/view space via the page geometry
666
+ * matrix; this reader applies NO Y-flip or device transform.
667
+ */
668
+ declare class PageGeometryReader {
669
+ private readonly runtime;
670
+ private readonly session;
671
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
672
+ read(pageObjectNumber: PageObjectNumber, signal: AbortSignal): PageGeometrySnapshot;
673
+ private buildRunsFromGlyphs;
674
+ private readGlyphInfo;
675
+ }
676
+ //#endregion
677
+ //#region src/features/render/PageRenderReader.d.ts
678
+ declare class PageRenderReader {
679
+ private readonly runtime;
680
+ private readonly session;
681
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
682
+ render(pageObjectNumber: PageObjectNumber, options: PageRenderOptions, signal: AbortSignal): import("@embedpdf/engine-core/runtime").PageRaster;
683
+ }
684
+ //#endregion
685
+ //#region src/features/annotations/AnnotationReader.d.ts
686
+ /**
687
+ * Per-page slow-path reader. Acquires a `pagePtr` from the
688
+ * `PagePtrPool`, dispatches the same per-subtype catalog as the raw
689
+ * reader (via `collectPageAnnotations`), and releases the page on exit.
690
+ *
691
+ * Currently the dispatched readers do not use the `pagePtr` parameter
692
+ * (text-markup is fully readable from the dict). Subtype readers that
693
+ * need form/widget access (e.g. widget) will plug into this code path
694
+ * as they land - the public DTO surface stays the same.
695
+ */
696
+ declare class AnnotationReader {
697
+ private readonly runtime;
698
+ private readonly session;
699
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
700
+ list(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
701
+ }
702
+ //#endregion
703
+ //#region src/features/annotations/AnnotationAppearanceReader.d.ts
704
+ /**
705
+ * Batch-renders the appearance streams (`/AP`) of every annotation on a page,
706
+ * one bitmap per requested mode. Ported from the v2 PDFium engine's
707
+ * `renderPageAnnotationsRaw` / `renderSingleAnnotAppearance`, but expressed in
708
+ * PDF user space and against the `PdfRuntimeModule` (`fn` + `mem`).
709
+ *
710
+ * Each appearance bitmap is sized to its annotation's `/Rect` scaled by
711
+ * `options.scale`. The shared raster helper handles PDFium's display matrix
712
+ * convention, so this reader stays in normalized PDF page coordinates.
713
+ */
714
+ declare class AnnotationAppearanceReader {
715
+ private readonly runtime;
716
+ private readonly session;
717
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
718
+ render(pageObjectNumber: PageObjectNumber, options: AnnotationAppearanceRenderOptions, signal: AbortSignal): AnnotationAppearancesResult;
719
+ /**
720
+ * Render a single annotation appearance into its own raster. Returns `null`
721
+ * when the mode has no appearance stream (after an optional form-field AP
722
+ * generation fallback) or the render fails.
723
+ */
724
+ private renderOne;
725
+ }
726
+ //#endregion
727
+ //#region src/features/annotations/RawAnnotationReader.d.ts
728
+ /**
729
+ * Whole-document and per-page raw read paths. Never acquires a pagePtr;
730
+ * uses `EPDFPage_GetAnnotCountRaw` / `EPDFPage_GetAnnotRaw` /
731
+ * `EPDFAnnot_GetObjectNumber` directly off the docPtr.
732
+ *
733
+ * Per-subtype dispatch is the same as the full reader (both share
734
+ * `collectPageAnnotations`), so the wire shape `AnnotationDTO[]` is
735
+ * identical between raw and full read paths for the subtypes that don't
736
+ * actually need a pagePtr to materialise their fields.
737
+ */
738
+ declare class RawAnnotationReader {
739
+ private readonly runtime;
740
+ private readonly session;
741
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
742
+ listAll(signal: AbortSignal): AnnotationListSnapshotAllPages;
743
+ listOne(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
744
+ }
745
+ //#endregion
746
+ //#region src/features/fonts/FontRegistrar.d.ts
747
+ /**
748
+ * A font to register at thread startup from a local file. Used by hosts that
749
+ * own their font policy (the cloud server's fallback fonts), as opposed to the
750
+ * per-request `fonts.register` wire path the browser engine drives.
751
+ *
752
+ * Registration is by path, mirroring how the server opens base documents
753
+ * (`fileAccess.fromNodeFile`): the bytes are range-read on demand and never
754
+ * held resident in the JS heap, so a deployment can configure many large
755
+ * fallback fonts (CJK families) without paying RAM per font.
756
+ */
757
+ interface StartupFontSpec {
758
+ key: string;
759
+ /** Absolute path to a TTF/OTF file (native/node runtimes only). */
760
+ path: string;
761
+ familyName?: string;
762
+ weight?: number;
763
+ /** `undefined` → infer from the file. */
764
+ italic?: boolean;
765
+ /** Also add to the glyph-fallback chain (automatic missing-glyph fill). */
766
+ fallback?: boolean;
767
+ }
768
+ /**
769
+ * Thread-confined runtime font registry binding.
770
+ *
771
+ * Wraps the `EPDFFont_*` C API on a single PDFium thread. PDFium's font
772
+ * registry is thread-local: a font registered here is visible only to this
773
+ * thread's page rendering and annotation-authoring calls, and the numeric
774
+ * `CFX_FontRegistry::FontId` it returns is a per-thread `next_font_id++`.
775
+ *
776
+ * That id is volatile, so we never let it cross the worker boundary. The host
777
+ * owns the `fontKey → id` map (passed in by reference) and every wire message
778
+ * references the stable `fontKey`. The FreeText writer resolves a key to the
779
+ * current thread's id through {@link idFor} at authoring time.
780
+ *
781
+ * Lives in `engine-services` (not a worker host) so the browser Web Worker,
782
+ * the Node `worker_thread` server, and any future direct-thread embedding
783
+ * share the exact same binding — only the `PdfRuntimeModule` (WASM vs native)
784
+ * differs.
785
+ */
786
+ declare class FontRegistrar {
787
+ private readonly runtime;
788
+ /** Host-owned `fontKey → native FontId` map for this thread. */
789
+ private readonly ids;
790
+ /**
791
+ * File-access handles retained for path-registered fonts. PDFium range-reads
792
+ * the file lazily (on each face creation), so the FPDF_FILEACCESS must stay
793
+ * alive until the registry is cleared — same lifetime rule as a file-backed
794
+ * base document. Closed in {@link clear}.
795
+ */
796
+ private readonly fileHandles;
797
+ constructor(runtime: PdfRuntimeModule,
798
+ /** Host-owned `fontKey → native FontId` map for this thread. */
799
+ ids: Map<string, number>);
800
+ /**
801
+ * Register a font from its bytes. Copies into the WASM heap, hands the
802
+ * pointer to `EPDFFont_RegisterMemFont64` (which copies the bytes into the
803
+ * native registry), then frees the scratch — so the heap holds exactly one
804
+ * retained copy per registered font.
805
+ *
806
+ * Throws `InvalidArg` when the runtime rejects the font (corrupt, no glyphs).
807
+ */
808
+ register(fontKey: string, familyName: string, weight: number, italic: number, bytes: Uint8Array): void;
809
+ /**
810
+ * Register a font from a local file via `EPDFFont_RegisterFont`. The runtime
811
+ * range-reads the file on demand (it is not loaded into the JS heap), and the
812
+ * file-access handle is retained until {@link clear}. Native/node only.
813
+ *
814
+ * Throws `InvalidArg` when the runtime rejects the font (corrupt, no glyphs).
815
+ */
816
+ registerFromNodeFile(fontKey: string, familyName: string, weight: number, italic: number, path: string): void;
817
+ /**
818
+ * Register host-owned startup fonts on this thread, in order, optionally
819
+ * adding each to the fallback chain. Order matters: it fixes both the native
820
+ * FontIds and the fallback precedence, so every worker thread that runs the
821
+ * same list ends up identical.
822
+ */
823
+ registerStartup(specs: readonly StartupFontSpec[]): void;
824
+ /** Append a registered font to the ordered glyph-fallback chain. */
825
+ addFallback(fontKey: string): void;
826
+ clearFallbacks(): void;
827
+ /** Unregister every font and reset the fallback chain (clears the map too). */
828
+ clear(): void;
829
+ /** Resolve a stable key to this thread's native FontId. Throws if unknown. */
830
+ idFor(fontKey: string): number;
831
+ private requireId;
832
+ }
833
+ //#endregion
834
+ //#region src/features/annotations/AnnotationMutator.d.ts
835
+ /**
836
+ * Synchronous orchestrator for `create` / `update` / `delete` annotation
837
+ * mutations. Owns the dance between PDFium calls, identity bookkeeping,
838
+ * revision bumping (only for structural ops), and the
839
+ * `AnnotationListMutationMeta` envelope every result type carries.
840
+ *
841
+ * Lives in `engine-services` (not the worker hosts) so the local Web
842
+ * Worker, the Node `worker_thread` server, and any future direct-thread
843
+ * embedding share the exact same code path. The only difference between
844
+ * them is the underlying `PdfRuntimeModule` (WASM vs native).
845
+ *
846
+ * Identity rules enforced here, locked with the user:
847
+ * - `create` always uses `EPDFPage_CreateAnnot` (the fork helper that
848
+ * creates an INDIRECT object) so new annotations are born durable.
849
+ * If the fork helper ever returns a direct object, we throw — never
850
+ * silently produce a weak annotation.
851
+ * - `update` is non-structural. /NM is monotonic per annotation:
852
+ * * already durable (objectNumber > 0 OR /NM present) -> NEVER touched.
853
+ * * weak (no objectNumber, no /NM) -> stamp engine-generated UUID v4.
854
+ * The patch type has no `nm` field, so the writer surface enforces
855
+ * "callers cannot rename a stable id" at the type level. Updates do
856
+ * not bump the revision.
857
+ * - `delete` is subtype-agnostic. Three native fork helpers handle the
858
+ * three ref kinds without round-tripping through index. For weak
859
+ * deletes (`AnnotationStableId | null`-shaped result), we set
860
+ * `deleted: null` so callers can detect that no durable id was
861
+ * reportable.
862
+ */
863
+ declare class AnnotationMutator {
864
+ private readonly runtime;
865
+ private readonly session;
866
+ /**
867
+ * Registered-font registry for this thread. Optional: when absent, the
868
+ * registered-font authoring path is unavailable and a draft/patch carrying
869
+ * a `registeredFontKey` fails loud (rather than silently using a standard
870
+ * font). Standard-font FreeText and all other subtypes are unaffected.
871
+ */
872
+ private readonly fonts?;
873
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession,
874
+ /**
875
+ * Registered-font registry for this thread. Optional: when absent, the
876
+ * registered-font authoring path is unavailable and a draft/patch carrying
877
+ * a `registeredFontKey` fails loud (rather than silently using a standard
878
+ * font). Standard-font FreeText and all other subtypes are unaffected.
879
+ */
880
+ fonts?: FontRegistrar | undefined);
881
+ /** Build the per-write context handed to subtype writers: font resolver
882
+ * (FreeText `/DA`), doc/page pointers and binary resources (stamp). */
883
+ private writeContext;
884
+ create(pageObjectNumber: PageObjectNumber, draft: WireAnnotationDraft, signal: AbortSignal, actor?: AnnotationActor, resources?: WireResourceMap): AnnotationCreateResult;
885
+ update(ref: AnnotationRef, patch: WireAnnotationPatch, signal: AbortSignal, actor?: AnnotationActor, resources?: WireResourceMap): AnnotationUpdateResult;
886
+ /**
887
+ * Attached widgets are views of a form field: deleting one here would
888
+ * orphan the field's /Kids (the corruption class doc.forms.repair
889
+ * exists to fix). Detach first, or use the forms-plane cascade.
890
+ */
891
+ private assertNotAttachedWidget;
892
+ delete(ref: AnnotationRef, signal: AbortSignal): AnnotationDeleteResult;
893
+ /**
894
+ * Batch reorder of a contiguous block of annotations within a single
895
+ * page's /Annots array. Symmetric with `pages.move()` for pages.
896
+ *
897
+ * Semantics (locked with the user, mirrors `EPDFPage_MoveAnnots`):
898
+ * - Each ref in `refs` is resolved to its current /Annots index.
899
+ * The block is detached, then re-inserted at `toIndex` in the
900
+ * post-removal index space, preserving caller-supplied order.
901
+ * - Single-annotation case is `move([ref], toIndex)`. There is no
902
+ * separate single-move path; one batch primitive serves both.
903
+ * - Atomic from the caller's perspective:
904
+ * * one revision bump per batch, regardless of `refs.length`.
905
+ * * one `AnnotationListMutationMeta` envelope.
906
+ * * if `EPDFPage_MoveAnnots` rejects (returns false) the page is
907
+ * untouched and we throw `InvalidArg` without bumping.
908
+ * - Identity strengthening: each weak ref in the batch (no
909
+ * `objectNumber`, no `/NM`) is opportunistically stamped with a
910
+ * fresh engine-generated UUID v4 BEFORE the move. So
911
+ * `meta.changed` always lists durable stable ids, and the moved
912
+ * DTOs come out durable. Same monotonic `/NM` rule as `update()`.
913
+ *
914
+ * Validation rules applied here BEFORE calling the helper, so callers
915
+ * get clean errors instead of an opaque `false` return code:
916
+ * - `refs.length >= 1`.
917
+ * - All refs target the page identified by `pageObjectNumber`.
918
+ * - `toIndex >= 0` and `toIndex <= count - refs.length` (count is
919
+ * captured AFTER ref resolution, so the helper sees the same view).
920
+ * - Resolved indices have no duplicates.
921
+ *
922
+ * The `EPDFPage_MoveAnnots` helper itself enforces the same rules; the
923
+ * up-front validation is purely for a usable error surface.
924
+ */
925
+ move(pageObjectNumber: PageObjectNumber, refs: AnnotationRef[], toIndex: number, signal: AbortSignal): AnnotationMoveResult;
926
+ /**
927
+ * Bake (or re-bake) an annotation's `/AP` normal appearance stream from
928
+ * its current dictionary properties using PDFium's native AP generator,
929
+ * then flush the page content so the result is persisted into the
930
+ * page/object tree. Same path the v2 engine used after every
931
+ * create/update; runs for every writable subtype (shapes + text-markup).
932
+ *
933
+ * Best-effort: `EPDFAnnot_GenerateAppearance` returns false for subtypes
934
+ * PDFium has no generator for (e.g. widgets), in which case the
935
+ * annotation simply ships without a baked `/AP` and viewers synthesize
936
+ * one — so a false return is not a hard error; it is surfaced to `update`
937
+ * callers as the `generation-unavailable` appearance outcome. This step is
938
+ * non-structural: it never shifts annotation indices or bumps revisions.
939
+ */
940
+ private regenerateAppearance;
941
+ private captureOrStampStableId;
942
+ private ensureKnownWeakStateFromPage;
943
+ private recordWeakStateFromPage;
944
+ private computeHasWeakAnnotations;
945
+ }
946
+ //#endregion
947
+ //#region src/features/annotations/internal/mutations/computeMutationImpact.d.ts
948
+ /**
949
+ * The kind of mutation that just happened on a page.
950
+ *
951
+ * Index-space behaviour drives whether weak (`kind: 'index'`) refs
952
+ * the client may be holding stay valid:
953
+ *
954
+ * - `update` does not touch the /Annots array at all.
955
+ * - `create` is append-only — the new annotation lands at
956
+ * `index = previousCount`, so no existing index ever shifts.
957
+ * The array grows, but every pre-existing weak ref still points
958
+ * at the same physical annotation.
959
+ * - `delete` removes an entry and shifts every later index down by
960
+ * one. Pre-existing weak refs at or after the removed index are
961
+ * now off-by-one and stale.
962
+ * - `move` detaches a contiguous block and re-inserts it, rewriting
963
+ * indices on both ends of the gap. Existing weak refs across that
964
+ * range are stale.
965
+ *
966
+ * So the doctrine for `MutationKind` is: only `delete` and `move`
967
+ * actually invalidate weak refs. `update` and `create` leave them
968
+ * alone. (A future explicit-position `createAt(index)` API would
969
+ * shift indices >= toIndex and would join the structural cohort —
970
+ * see `MutationKind` extension note in `compute()` below.)
971
+ */
972
+ type MutationKind = AnnotationMutationKind;
973
+ /**
974
+ * Inputs that decide whether a mutation should make a client refetch.
975
+ *
976
+ * `pageStateBefore` is captured BEFORE the mutation. Its known
977
+ * `weakAnnotationState` drives the locked rule:
978
+ * index-shifting mutation × any weak annotation on the page ⇒ refetch.
979
+ *
980
+ * `pageStateAfter` is captured AFTER the mutation. It carries the
981
+ * bumped revision token (for index-shifting ops) and the recomputed
982
+ * weak-annotation state (for any op that might have changed it, e.g.
983
+ * opportunistic /NM stamping during update).
984
+ *
985
+ * `changed` is the list of stable ids the mutation actually touched.
986
+ * Empty for a weak delete (we have no durable id to report).
987
+ */
988
+ interface ImpactInputs {
989
+ mutation: MutationKind;
990
+ pageStateBefore: PageState;
991
+ pageStateAfter: PageState;
992
+ changed: AnnotationStableId[];
993
+ }
994
+ /**
995
+ * Pure helper: turn a mutation outcome into the side-effect envelope
996
+ * every result type carries on its `meta` field.
997
+ *
998
+ * The rules — locked with the user, do not change without re-reading
999
+ * the doc comment on `AnnotationListMutationMeta` and the
1000
+ * `MutationKind` definition above:
1001
+ *
1002
+ * 1. `update` and `create` are non-invalidating.
1003
+ *
1004
+ * - `update` doesn't touch the /Annots array; indices on the page
1005
+ * do not move, so weak refs the client may be holding stay
1006
+ * valid. Opportunistic /NM stamping during an update is also
1007
+ * non-structural — it changes the annotation's identity quality
1008
+ * but not its position.
1009
+ *
1010
+ * - `create` is append-only. The new annotation goes at
1011
+ * `index = previousCount`, so no existing index shifts and no
1012
+ * pre-existing weak ref ever becomes stale. We treat `create`
1013
+ * the same as `update` for impact purposes: no revision bump,
1014
+ * `weakRefsInvalidated = false`, `shouldRefetch = null`.
1015
+ *
1016
+ * The "revisions exist solely for weak-ref authentication"
1017
+ * doctrine (see `pages.move()`'s identical reasoning) means we
1018
+ * deliberately do NOT bump on `create` — bumping a revision
1019
+ * that nobody's weak ref depends on would erode the invariant
1020
+ * and turn revisions into a generic "something changed" signal.
1021
+ *
1022
+ * 2. `delete` and `move` ARE index-shifting. They genuinely move
1023
+ * pre-existing indices:
1024
+ * - `delete` removes an annotation, shifting every later index
1025
+ * down by one.
1026
+ * - `move` detaches a contiguous block and re-inserts it
1027
+ * elsewhere, rewriting indices on both ends of the gap.
1028
+ * They invalidate weak refs iff the page actually had any weak
1029
+ * refs *before* the mutation — if every annotation already had a
1030
+ * durable identity, no client could possibly be holding a stale
1031
+ * index, and we keep `shouldRefetch = null`.
1032
+ *
1033
+ * (`move` opportunistically stamps /NM on weak refs in the batch
1034
+ * BEFORE the move, so the annotations actually being moved end up
1035
+ * durable on the way out; but other weak annotations on the page
1036
+ * still need a refetch.)
1037
+ *
1038
+ * 3. When rule (2) fires, the reason is always `'weakRefsInvalidated'`.
1039
+ * `'pageRebuilt'` and `'externalChange'` are reserved for higher-
1040
+ * level signals the engine doesn't emit yet (insert/delete-page
1041
+ * that rebuilds /Annots, watch-based refresh). Page **reorder**
1042
+ * explicitly does NOT bump per-page revisions and does NOT emit
1043
+ * `pageRebuilt` — see `PagesMutator`.
1044
+ *
1045
+ * Future note: when an explicit-position `createAt(index)` API
1046
+ * ships, add `'createAt'` to `MutationKind` and slot it into rule
1047
+ * (2) — it shifts every index >= toIndex and is structural in the
1048
+ * same way `delete` and `move` are.
1049
+ */
1050
+ declare function computeMutationImpact(inputs: ImpactInputs): AnnotationListMutationMeta;
1051
+ //#endregion
1052
+ //#region src/features/attachments/AttachmentReader.d.ts
1053
+ /**
1054
+ * Read-only access to embedded files, at both of their homes: the
1055
+ * document catalog's `/EmbeddedFiles` name tree (list / readFile by
1056
+ * index) and a FileAttachment annotation's `/FS` (readAnnotationFile by
1057
+ * ref). Pure READS over the session — no revision bumps, no layer
1058
+ * artifacts (the `PagesExtractor` shape).
1059
+ *
1060
+ * Byte delivery mirrors the request's `path?`: absent → a standalone
1061
+ * buffer for the transfer list (browser); present → the decoded file is
1062
+ * streamed to `path` via `FPDF_FILEWRITE` (server), and only metadata
1063
+ * rides the response.
1064
+ */
1065
+ declare class AttachmentReader {
1066
+ private readonly runtime;
1067
+ private readonly session;
1068
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1069
+ /** Snapshot of the `/EmbeddedFiles` name tree, in tree (key-sorted) order. */
1070
+ list(signal: AbortSignal): EmbeddedFileItem[];
1071
+ /** Decode one document-level embedded file, addressed by key. */
1072
+ readFile(ref: EmbeddedFileRef, path: string | undefined, maxDecodedBytes: number | undefined, signal: AbortSignal): AttachmentFileWorkerPayload;
1073
+ /** Decode the file embedded in a FileAttachment annotation's `/FS`. */
1074
+ readAnnotationFile(pageObjectNumber: PageObjectNumber, ref: AnnotationRef, path: string | undefined, maxDecodedBytes: number | undefined, signal: AbortSignal): AttachmentFileWorkerPayload;
1075
+ private extract;
1076
+ }
1077
+ //#endregion
1078
+ //#region src/features/attachments/AttachmentMutator.d.ts
1079
+ /**
1080
+ * Create/delete mutations over the document catalog's `/EmbeddedFiles`
1081
+ * name tree — the doc-level sibling of `AnnotationMutator`, sharing the
1082
+ * write path (`writeAttachmentFilePayload`) with the file-attachment
1083
+ * annotation writer.
1084
+ *
1085
+ * Identity is the name-tree KEY (unique by construction), so unlike
1086
+ * annotations there is no weak-ref/revision bookkeeping here. Note the
1087
+ * tree is key-sorted: both mutations shift OTHER entries' indices; keys
1088
+ * never move. Layer persistence (`finishMutation`) and event publication
1089
+ * happen in the callers, exactly like every other mutation family.
1090
+ */
1091
+ declare class AttachmentMutator {
1092
+ private readonly runtime;
1093
+ private readonly session;
1094
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1095
+ /**
1096
+ * Create an embedded file. `file.name` becomes the tree key (PDFium
1097
+ * writes key = /UF = /F); a duplicate key rejects with `InvalidArg`.
1098
+ * The result carries the read-back entry, `checksum`/`size`/dates
1099
+ * included.
1100
+ */
1101
+ create(file: WireAttachmentFile, resources: WireResourceMap | undefined, signal: AbortSignal): AttachmentCreateResult;
1102
+ /** Delete an embedded file by key. Unlinks the tree entry only. */
1103
+ delete(ref: EmbeddedFileRef, signal: AbortSignal): AttachmentDeleteResult;
1104
+ }
1105
+ //#endregion
1106
+ //#region src/features/attachments/internal/attachmentPrimitives.d.ts
1107
+ /**
1108
+ * Write an embedded file's payload onto an existing FPDF_ATTACHMENT:
1109
+ * bytes via FPDFAttachment_SetFile (which also writes /Params
1110
+ * Size/CheckSum/CreationDate), declared mime via EPDFAttachment_SetSubtype
1111
+ * (attachments accept any format — no sniffing), optional /Desc. Shared
1112
+ * by the file-attachment annotation writer and the document-level
1113
+ * `attachments.create` mutation — the write half of the one attachment
1114
+ * vocabulary.
1115
+ */
1116
+ declare function writeAttachmentFilePayload(fn: PdfFunctions, mem: PdfRuntimeMemory, attachmentPtr: Ptr, docPtr: Ptr, file: {
1117
+ mimeType?: string;
1118
+ description?: string;
1119
+ }, resource: WireResource): void;
1120
+ /** Read the metadata projection of an embedded file (never its bytes). */
1121
+ declare function readAttachmentFileInfo(fn: PdfFunctions, mem: PdfRuntimeMemory, attachmentPtr: Ptr): AttachmentFileInfo;
1122
+ //#endregion
1123
+ //#region src/features/security/SecurityReader.d.ts
1124
+ /**
1125
+ * Reads document security/permission state. Three entry points:
1126
+ *
1127
+ * - `probeFile` is the only doc-less path: it opens, inspects, and
1128
+ * closes its own document straight off a file. It is the intentional
1129
+ * exception to the package's `(runtime, session)` reader shape — it
1130
+ * answers "what is this file's security?" before any session exists.
1131
+ * - `readLiveSecurityInfo` / `checkPasswordPermissions` inspect an
1132
+ * already-open `DocumentSession`.
1133
+ */
1134
+ declare class SecurityReader {
1135
+ private readonly runtime;
1136
+ constructor(runtime: PdfRuntimeModule);
1137
+ probeFile(path: string, password?: string | null): DocumentSecurityProbeInfo;
1138
+ /**
1139
+ * Snapshot of the live session's EFFECTIVE security state.
1140
+ * `FPDF_GetDocUserPermissions` reports the permission word in force
1141
+ * right now (e.g. after an owner unlock), as opposed to the declared
1142
+ * word the cold `probeFile` path reads.
1143
+ */
1144
+ readLiveSecurityInfo(session: DocumentSession): DocumentSecurityProbeInfo;
1145
+ /**
1146
+ * Verify a password against the live session and report the resulting
1147
+ * effective permissions. Throws `DocPasswordIncorrect` when the
1148
+ * password is rejected, or (in `'owner'` mode) when it unlocks only as
1149
+ * a user.
1150
+ */
1151
+ checkPasswordPermissions(session: DocumentSession, password: string, mode?: 'any' | 'owner'): DocumentSecurityProbeInfo;
1152
+ }
1153
+ //#endregion
1154
+ //#region src/features/save/DocumentSaver.d.ts
1155
+ /**
1156
+ * Owns every "serialize the open document" path for a `DocumentSession`.
1157
+ * Two distinct outputs:
1158
+ *
1159
+ * - Layer artifacts (`saveLayerArtifact*`) are the storage-optimized
1160
+ * `.layer` delta used by server-side persistence. Only valid for a
1161
+ * `layer` session.
1162
+ * - Standalone saves (`saveStandalone*`) export a self-contained PDF
1163
+ * view (base + applied delta) via `FPDF_SaveAsCopy` /
1164
+ * `EPDF_SaveDocumentToOwnedBuffer`, valid for any session kind.
1165
+ *
1166
+ * Lives in `engine-services` so the browser Worker and the Node
1167
+ * `worker_thread` server share the exact same save code path.
1168
+ */
1169
+ declare class DocumentSaver {
1170
+ private readonly runtime;
1171
+ private readonly session;
1172
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1173
+ saveLayerArtifact(): {
1174
+ bytes: ArrayBuffer;
1175
+ size: number;
1176
+ };
1177
+ saveLayerArtifactToFile(path: string): {
1178
+ path: string;
1179
+ };
1180
+ saveStandaloneToBuffer(mode: PdfSaveMode): {
1181
+ bytes: ArrayBuffer;
1182
+ size: number;
1183
+ };
1184
+ saveStandaloneToFile(path: string, mode: PdfSaveMode): {
1185
+ path: string;
1186
+ };
1187
+ private requireLayer;
1188
+ }
1189
+ //#endregion
1190
+ //#region src/features/forms/FormReader.d.ts
1191
+ /**
1192
+ * Read side of the forms feature. All reads go through the session's
1193
+ * version-keyed model cache, so repeated reads between mutations reuse
1194
+ * one native snapshot build.
1195
+ */
1196
+ declare class FormReader {
1197
+ private readonly runtime;
1198
+ private readonly session;
1199
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1200
+ snapshot(signal: AbortSignal): FormSnapshot;
1201
+ field(ref: FormFieldRef, signal: AbortSignal): FormFieldDTO;
1202
+ /**
1203
+ * Serialize form data. Exports read the reconciled view (recovered
1204
+ * fields included; on layers, promoted values win) straight from the
1205
+ * document — the model cache is not involved.
1206
+ */
1207
+ exportData(format: FormDataFormat, signal: AbortSignal): {
1208
+ format: FormDataFormat;
1209
+ bytes: ArrayBuffer;
1210
+ };
1211
+ }
1212
+ //#endregion
1213
+ //#region src/features/forms/FormMutator.d.ts
1214
+ /**
1215
+ * Write side of the forms feature. Every method is a validate-then-apply
1216
+ * transaction over the native EPDFForm_* write API: a failed call leaves
1217
+ * the document untouched (on layers: nothing promoted), and each success
1218
+ * bumps the session's mutation sequence so version-keyed caches rebuild.
1219
+ */
1220
+ declare class FormMutator {
1221
+ private readonly runtime;
1222
+ private readonly session;
1223
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1224
+ setValue(ref: FormFieldRef, value: FormFieldValue, signal: AbortSignal): FormSetValueResult;
1225
+ reset(ref: FormFieldRef, signal: AbortSignal): FormSetValueResult;
1226
+ importData(data: ArrayBuffer, format: FormDataFormat | undefined, signal: AbortSignal): FormImportResult;
1227
+ repair(bakeAppearances: boolean, signal: AbortSignal): FormRepairResult;
1228
+ /**
1229
+ * Create a field and (optionally) its widgets in one composed
1230
+ * transaction: native field creation, widget birth through the
1231
+ * annotation plane, adoption, then field-plane setters. A failure
1232
+ * mid-composition throws; earlier steps stay applied (the document is
1233
+ * never inconsistent - at worst a partially configured field exists).
1234
+ */
1235
+ createField(draft: FormFieldDraft, signal: AbortSignal): {
1236
+ field: FormFieldDTO;
1237
+ };
1238
+ updateField(ref: FormFieldRef, patch: FormFieldPatch, signal: AbortSignal): {
1239
+ field: FormFieldDTO;
1240
+ };
1241
+ /**
1242
+ * Delete a terminal field. Widgets are DETACHED here (they become inert
1243
+ * annotations); the worker host cascades their annotation deletion so
1244
+ * page /Annots bookkeeping flows through the annotation feature.
1245
+ */
1246
+ deleteField(ref: FormFieldRef, signal: AbortSignal): {
1247
+ deletedFieldObjectNumber: number;
1248
+ detachedWidgets: FormWidgetRef[];
1249
+ };
1250
+ attachWidget(ref: FormFieldRef, widget: FormWidgetRef, onState: string | undefined, signal: AbortSignal): {
1251
+ field: FormFieldDTO;
1252
+ };
1253
+ detachWidget(ref: FormFieldRef, widget: FormWidgetRef, signal: AbortSignal): {
1254
+ field: FormFieldDTO;
1255
+ };
1256
+ private placementsOf;
1257
+ private applyOptions;
1258
+ private applyWideSetter;
1259
+ private applyDefaultValues;
1260
+ private readBackField;
1261
+ private assertWritable;
1262
+ /** Dispatch the typed native write. Returns the changed widget objnums. */
1263
+ private applyWrite;
1264
+ /** Run a native write with the changed-widgets out buffer wired up. */
1265
+ private withChangedWidgets;
1266
+ /** Bump the session version, rebuild the model, and read the field back. */
1267
+ private readBack;
1268
+ }
1269
+ //#endregion
1270
+ //#region src/features/forms/FormsEffectsApplier.d.ts
1271
+ /** Ordered, non-rollback-atomic sink for one committed client script run. */
1272
+ declare class FormsEffectsApplier {
1273
+ private readonly runtime;
1274
+ private readonly session;
1275
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1276
+ apply(effects: FormEffect[], signal: AbortSignal): FormEffectsResult;
1277
+ private preflight;
1278
+ private resolve;
1279
+ private readField;
1280
+ private readFieldsBestEffort;
1281
+ private applyNative;
1282
+ private applyValue;
1283
+ private withChangedWidgets;
1284
+ }
1285
+ //#endregion
1286
+ //#region src/features/forms/internal/formModelCache.d.ts
1287
+ /** Close and forget the session's cached model, if any. */
1288
+ declare function disposeFormModel(runtime: PdfRuntimeModule, session: DocumentSession): void;
1289
+ //#endregion
1290
+ //#region src/features/search/SearchReader.d.ts
1291
+ /**
1292
+ * The whole search pipeline for one budgeted slice, running inside the
1293
+ * trust boundary (worker locally, server process in the cloud):
1294
+ *
1295
+ * extract — page text via the session corpus cache (version-keyed on
1296
+ * `mutationSeq`, so results always reflect the CURRENT layer
1297
+ * view — text a redaction removed is unfindable),
1298
+ * match — the pure engine-core matcher (identical code on every
1299
+ * engine; parity by construction),
1300
+ * anchor — geometry read only for pages that actually matched, rects
1301
+ * via the selection line-merge (one rect per visual line).
1302
+ *
1303
+ * Scope gating (`doc.text.search`, `doc.text.copy` for `'full'`) is the
1304
+ * caller's job — this reader assumes an authorized request.
1305
+ */
1306
+ declare class SearchReader {
1307
+ private readonly runtime;
1308
+ private readonly session;
1309
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1310
+ query(request: SearchRequest, signal: AbortSignal): SearchSlice;
1311
+ }
1312
+ //#endregion
1313
+ //#region src/features/actions/ActionModelReader.d.ts
1314
+ /** Mutable aggregate budget shared by every action model in one read job. */
1315
+ declare class ActionReadBudgetTracker {
1316
+ private readonly limits;
1317
+ private models;
1318
+ private nodes;
1319
+ private scriptCodeUnits;
1320
+ constructor(limits?: ActionReadBudget);
1321
+ addModel(nodeCount: number): void;
1322
+ addScript(script: string): void;
1323
+ private assertWithinBudget;
1324
+ }
1325
+ /**
1326
+ * Convert and close one detached native action model. This is the only
1327
+ * native-model walker used by document, page, field, and annotation reads.
1328
+ */
1329
+ declare function readActionModel(fn: PdfFunctions, mem: PdfRuntimeMemory, modelPtr: Ptr, budget: ActionReadBudgetTracker): PdfActionTree | null;
1330
+ //#endregion
1331
+ //#region src/features/actions/DocumentActionsReader.d.ts
1332
+ /** Read catalog-owned actions. Extraction only; no action is executed. */
1333
+ declare class DocumentActionsReader {
1334
+ private readonly runtime;
1335
+ private readonly session;
1336
+ constructor(runtime: PdfRuntimeModule, session: DocumentSession);
1337
+ read(signal: AbortSignal): DocumentActionsSnapshot;
1338
+ }
1339
+ //#endregion
1340
+ //#region src/worker-host/WorkerHost.d.ts
1341
+ /**
1342
+ * The piece that runs "inside the worker": owns runtime, manages document
1343
+ * sessions, dispatches requests to the engine-services synchronous code.
1344
+ *
1345
+ * Environment-agnostic. Wrap it with a Web Worker entry, a Node
1346
+ * worker_thread entry, or an inline transport. The wrapper owns
1347
+ * postMessage plumbing and any process/lifecycle concerns; the host only
1348
+ * knows about PdfRuntimeModule, DocumentSession, AbortController, and the
1349
+ * worker wire shape from @embedpdf/engine-core.
1350
+ */
1351
+ declare class WorkerHost {
1352
+ private readonly runtime;
1353
+ /**
1354
+ * Receives a fully-typed `WirePack<WorkerResponse>` (the envelope
1355
+ * payload plus its transfer manifest). The wrapper (browser
1356
+ * `worker-entry.ts`, Node `worker-entry.ts`, or `InlineTransport`)
1357
+ * is responsible for actually invoking `postMessage(pack.payload,
1358
+ * pack.transfer)` — the host doesn't know which environment it
1359
+ * runs in.
1360
+ */
1361
+ private readonly post;
1362
+ private readonly sessions;
1363
+ private readonly baseDocuments;
1364
+ private readonly aborts;
1365
+ /**
1366
+ * Runtime-global registered fonts for this thread. The registry is
1367
+ * thread-local in PDFium, so it lives on the host (one per thread), not per
1368
+ * document session. `fontIds` maps the stable wire `fontKey` to this
1369
+ * thread's volatile native FontId.
1370
+ */
1371
+ private readonly fontIds;
1372
+ private readonly fonts;
1373
+ private destroyed;
1374
+ constructor(runtime: PdfRuntimeModule,
1375
+ /**
1376
+ * Receives a fully-typed `WirePack<WorkerResponse>` (the envelope
1377
+ * payload plus its transfer manifest). The wrapper (browser
1378
+ * `worker-entry.ts`, Node `worker-entry.ts`, or `InlineTransport`)
1379
+ * is responsible for actually invoking `postMessage(pack.payload,
1380
+ * pack.transfer)` — the host doesn't know which environment it
1381
+ * runs in.
1382
+ */
1383
+ post: (pack: WirePack<WorkerResponse>) => void);
1384
+ /**
1385
+ * Register deployment-owned fonts on this worker thread, after init and
1386
+ * before serving requests. Server-only: the cloud engine never exposes font
1387
+ * configuration to clients, so the host (not a wire message) seeds the
1388
+ * thread's fallback fonts. Browser engines drive fonts through the
1389
+ * `fonts.*` wire path instead. Throws if any font fails to load.
1390
+ */
1391
+ registerStartupFonts(specs: readonly StartupFontSpec[]): void;
1392
+ receive(msg: WorkerRequest): void;
1393
+ private handleOpen;
1394
+ private handleMetadataRead;
1395
+ private handleMetadataUpdate;
1396
+ private handleActionsRead;
1397
+ private handleAnnotationsListRawAll;
1398
+ private handleAnnotationsListRawPage;
1399
+ private handleAnnotationsListFullPage;
1400
+ private handleAnnotationsRenderAppearances;
1401
+ private handleAnnotationsCreate;
1402
+ private handleAnnotationsUpdate;
1403
+ private handleAnnotationsDelete;
1404
+ private handleAnnotationsMove;
1405
+ private handlePagesList;
1406
+ private handlePagesMove;
1407
+ private handlePagesRotate;
1408
+ private handlePagesDelete;
1409
+ private handlePagesFlatten;
1410
+ private handleRedactionApply;
1411
+ private handlePagesExtract;
1412
+ private handlePagesInsert;
1413
+ private handleAttachmentsList;
1414
+ private handleAttachmentsReadFile;
1415
+ private handleAttachmentsCreate;
1416
+ private handleAttachmentsDelete;
1417
+ private handleAnnotationsReadFile;
1418
+ private handlePieceInfoRead;
1419
+ private handlePieceInfoUpdate;
1420
+ private handlePieceInfoApplications;
1421
+ private handlePieceInfoClear;
1422
+ private handlePagesText;
1423
+ private handlePagesGeometry;
1424
+ private handleSearchQuery;
1425
+ private handlePagesRender;
1426
+ private handleDocumentSaveBuffer;
1427
+ private handleDocumentSaveFile;
1428
+ private handleDocumentSaveLayerBuffer;
1429
+ private handleDocumentProbeSecurityFile;
1430
+ /**
1431
+ * One-shot file render (the derived-artifact warmer's producer): open the
1432
+ * base from a file path into a TRANSIENT session — never stored in
1433
+ * `this.sessions`, so it can't collide with (or leak into) live document
1434
+ * sessions — resolve the display index to its durable page object number,
1435
+ * render, close. Shares the base parse with concurrent ad-hoc opens of
1436
+ * the same file via the registry refcount.
1437
+ */
1438
+ private handleDocumentRenderPageFile;
1439
+ private handleDocumentCheckPasswordPermissions;
1440
+ private handleFontsRegister;
1441
+ private handleFontsAddFallback;
1442
+ private handleFontsClearFallbacks;
1443
+ private handleFontsClear;
1444
+ /**
1445
+ * Close exactly ONE layer session — the reload seam for layer-session
1446
+ * freshness. The base document's refcount releases through the session's
1447
+ * close stack, so sibling layer sessions (and the base session) are
1448
+ * untouched. Idempotent: closing an absent session is a no-op ack,
1449
+ * because the caller may be reloading a layer this worker never held
1450
+ * (e.g. after a pool eviction).
1451
+ */
1452
+ private handleLayerClose;
1453
+ private handleClose;
1454
+ private handleShutdown;
1455
+ private requireSession;
1456
+ /**
1457
+ * Finalize a mutation response. For a standalone session the mutation
1458
+ * result is returned as-is. For a layer session we additionally persist
1459
+ * the layer artifact (to file when `artifactPath` is given, otherwise to
1460
+ * a transferable buffer) and merge it onto the response envelope. This
1461
+ * is the one place the layer-vs-standalone branch lives, shared by every
1462
+ * annotation and page mutation handler.
1463
+ */
1464
+ private handleFormsList;
1465
+ private handleFormsSetValue;
1466
+ private handleFormsReset;
1467
+ private handleFormsApplyEffects;
1468
+ private handleFormsExport;
1469
+ private handleFormsImport;
1470
+ private handleFormsRepair;
1471
+ private handleFormsCreateField;
1472
+ private handleFormsUpdateField;
1473
+ private handleFormsDeleteField;
1474
+ private handleFormsAttachWidget;
1475
+ private handleFormsDetachWidget;
1476
+ private finishMutation;
1477
+ private saveLayerArtifact;
1478
+ }
1479
+ //#endregion
1480
+ export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EventHub, FontRegistrar, FormMutator, FormReader, FormsEffectsApplier, type ImpactInputs, type LayerSource, LocalRevisionAuthority, MetadataMutator, MetadataReader, type MutationKind, type OpenedPdfDocument, type OpenedPdfDocumentKind, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, WorkerHost, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
1481
+ //# sourceMappingURL=index.d.ts.map