@embedpdf/engine-services 3.0.0-next.11 → 3.0.0-next.13
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.
- package/dist/index.cjs +3524 -351
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +671 -63
- package/dist/index.d.ts +671 -63
- package/dist/index.js +3514 -353
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PdfFunctions, PdfRuntimeMemory, PdfRuntimeModule, Ptr } from "@embedpdf/engine-runtime";
|
|
2
|
-
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, PageGeometryRun, PageGeometrySnapshot, PageInsertBlankSpec, PageInsertResult, PageListSnapshot, PageMoveResult, PageNetworkRenderFormat, PageObjectNumber, PageRaster, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfQuad, PdfRect, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
|
|
2
|
+
import { ActionReadBudget, AnalyzeInput, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationFlattenResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, BaseVersionInfo, ChangeAnalysis, DigestAlgorithm, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentProtection, DocumentSecurityProbeInfo, DocumentVersionRef, EmbeddedFileItem, EmbeddedFileRef, FontIdentityInfo, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometryRun, PageGeometrySnapshot, PageInsertBlankSpec, PageInsertResult, PageListSnapshot, PageMoveResult, PageNameInput, PageNameResult, PageNetworkRenderFormat, PageObjectNumber, PageRaster, PageRemoveNameInput, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfQuad, PdfRect, PdfRevision, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionStructure, RevisionToken, SearchRequest, SearchSlice, SessionKind, SignatureAbortResult, SignatureCompleteInput, SignatureCompleteResult, SignatureDTO, SignaturePrepareInput, SignaturePrepared, SignatureSnapshot, SignedDocumentPolicy, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
|
|
3
3
|
//#region src/runtime/lifecycle/bootstrap.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Initialize the thread-confined PDFium runtime for the calling thread. Each
|
|
@@ -146,13 +146,38 @@ declare class SessionEventPublisher {
|
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region src/document-session/lifecycle/PdfDocumentOpener.d.ts
|
|
148
148
|
type OpenedPdfDocumentKind = 'fat-memory' | 'layer';
|
|
149
|
+
/**
|
|
150
|
+
* Where a session's bytes come from, retained for the session's lifetime
|
|
151
|
+
* so that every consumer (signing candidates, overlays, verbatim reads)
|
|
152
|
+
* shares one interpretation: an immutable base in the registry (by key;
|
|
153
|
+
* file bases also carry their path) and the layer the session was opened
|
|
154
|
+
* with. A plain session has neither. Byte-backed layer sources keep their
|
|
155
|
+
* bytes: they are what a candidate reopens over the same base.
|
|
156
|
+
*/
|
|
157
|
+
type BaseSource = {
|
|
158
|
+
readonly kind: 'memory';
|
|
159
|
+
readonly key: string;
|
|
160
|
+
} | {
|
|
161
|
+
readonly kind: 'file';
|
|
162
|
+
readonly key: string;
|
|
163
|
+
readonly path: string;
|
|
164
|
+
};
|
|
165
|
+
interface DocumentSource {
|
|
166
|
+
readonly base: BaseSource | null;
|
|
167
|
+
readonly layer: LayerSource | null;
|
|
168
|
+
readonly password: string | null;
|
|
169
|
+
}
|
|
149
170
|
interface OpenedPdfDocument {
|
|
150
171
|
readonly kind: OpenedPdfDocumentKind;
|
|
151
172
|
readonly docPtr: Ptr;
|
|
173
|
+
readonly source: DocumentSource;
|
|
152
174
|
close(): void;
|
|
153
175
|
}
|
|
154
176
|
interface AcquiredBaseDocument {
|
|
155
177
|
readonly key: string;
|
|
178
|
+
readonly kind: 'memory' | 'file';
|
|
179
|
+
/** File bases only. */
|
|
180
|
+
readonly path?: string;
|
|
156
181
|
readonly basePtr: Ptr;
|
|
157
182
|
release(): void;
|
|
158
183
|
}
|
|
@@ -238,11 +263,49 @@ interface PageRecord {
|
|
|
238
263
|
* this exactly the same way; the only thing that differs is the
|
|
239
264
|
* underlying PdfRuntimeModule (WASM vs native).
|
|
240
265
|
*/
|
|
266
|
+
/**
|
|
267
|
+
* A serialised signing candidate: the sealed-to-be file with the
|
|
268
|
+
* zero-filled /Contents hole, either as one buffer in JS memory (the local
|
|
269
|
+
* engine) or as a file beside the session's base (the server), plus where
|
|
270
|
+
* the signature value object lies in it.
|
|
271
|
+
*/
|
|
272
|
+
type SavedCandidate = {
|
|
273
|
+
kind: 'memory';
|
|
274
|
+
bytes: Uint8Array;
|
|
275
|
+
size: number;
|
|
276
|
+
objectOffset: number;
|
|
277
|
+
objectLength: number;
|
|
278
|
+
} | {
|
|
279
|
+
kind: 'file';
|
|
280
|
+
path: string;
|
|
281
|
+
size: number;
|
|
282
|
+
objectOffset: number;
|
|
283
|
+
objectLength: number;
|
|
284
|
+
};
|
|
285
|
+
/**
|
|
286
|
+
* A sealed-to-be candidate parked on a session between `prepare` and
|
|
287
|
+
* `complete`/`abort`. The native candidate documents are closed as soon as
|
|
288
|
+
* the seal is computed; only the serialised candidate remains.
|
|
289
|
+
*/
|
|
290
|
+
interface PendingSigning {
|
|
291
|
+
readonly prepared: SignaturePrepared;
|
|
292
|
+
readonly fieldObjectNumber: number;
|
|
293
|
+
readonly saved: SavedCandidate;
|
|
294
|
+
readonly contentsOffset: number;
|
|
295
|
+
readonly contentsHexLength: number;
|
|
296
|
+
}
|
|
297
|
+
/** What a completed signing left behind, for idempotent replays. */
|
|
298
|
+
interface SigningCompletion {
|
|
299
|
+
readonly signingId: string;
|
|
300
|
+
readonly cms: Uint8Array;
|
|
301
|
+
readonly result: SignatureCompleteResult;
|
|
302
|
+
}
|
|
241
303
|
declare class DocumentSession {
|
|
242
304
|
private readonly runtime;
|
|
243
305
|
private docPtr;
|
|
244
306
|
private closeDocument;
|
|
245
307
|
private _kind;
|
|
308
|
+
private _source;
|
|
246
309
|
private readonly _sessionId;
|
|
247
310
|
/** pon -> record */
|
|
248
311
|
private readonly recordsByObjectNumber;
|
|
@@ -252,12 +315,70 @@ declare class DocumentSession {
|
|
|
252
315
|
private revisions;
|
|
253
316
|
private mutationSeqCounter;
|
|
254
317
|
private pages;
|
|
318
|
+
/**
|
|
319
|
+
* Whether writers honour what the document's signatures forbid (locked
|
|
320
|
+
* fields, structural edits). Set at open from the engine option; the
|
|
321
|
+
* main-thread guard subtracts the matching capabilities.
|
|
322
|
+
*/
|
|
323
|
+
signedDocumentPolicy: SignedDocumentPolicy;
|
|
324
|
+
/**
|
|
325
|
+
* The shape the caller asked for when opening plain bytes. `layer` (the
|
|
326
|
+
* default) opens them as an immutable base with a fresh layer; `plain`
|
|
327
|
+
* keeps one in-memory document unless the bytes already carry a
|
|
328
|
+
* signature, which always opens as a layer.
|
|
329
|
+
*/
|
|
330
|
+
sessionKind: SessionKind;
|
|
331
|
+
/** The password the document was opened with; signing candidates open with the same one. */
|
|
332
|
+
password: string | null;
|
|
333
|
+
/**
|
|
334
|
+
* Whether mutations on a layer session also serialize the layer artifact
|
|
335
|
+
* into their response (what a server persists). False for a session that
|
|
336
|
+
* became a layer only because its document is signed (see
|
|
337
|
+
* `WorkerHost.openSignedAware`): the caller opened plain bytes and never
|
|
338
|
+
* asked for artifacts.
|
|
339
|
+
*/
|
|
340
|
+
persistLayerArtifact: boolean;
|
|
341
|
+
/** The mutation sequence the current bytes were loaded at (see `hasUnsavedEdits`). */
|
|
342
|
+
private loadedSeq;
|
|
343
|
+
/** SHA-256 (hex) of a plain session's loaded bytes, hashed once per load. */
|
|
344
|
+
private plainSha256;
|
|
345
|
+
/** The signing candidate parked by `signatures.prepare`, if any. */
|
|
346
|
+
pendingSigning: PendingSigning | null;
|
|
347
|
+
/** The last completed signing, so a replayed `complete` answers `already-completed`. */
|
|
348
|
+
lastCompletion: SigningCompletion | null;
|
|
255
349
|
constructor(runtime: PdfRuntimeModule, sessionId?: string);
|
|
256
350
|
get sessionId(): string;
|
|
257
351
|
get kind(): OpenedPdfDocumentKind | null;
|
|
352
|
+
/**
|
|
353
|
+
* Where the current bytes come from: the immutable base (registry key,
|
|
354
|
+
* file path for file bases) and the layer the session was opened with.
|
|
355
|
+
* One interpretation for signing candidates, overlays and verbatim reads.
|
|
356
|
+
*/
|
|
357
|
+
get source(): DocumentSource;
|
|
258
358
|
isOpen(): boolean;
|
|
259
359
|
open(bytes: Uint8Array, password?: string | null): void;
|
|
260
360
|
openFromHandle(handle: OpenedPdfDocument): void;
|
|
361
|
+
/**
|
|
362
|
+
* Whether anything was mutated since the current bytes were loaded. When
|
|
363
|
+
* false, the loaded bytes ARE the document: a save returns them verbatim
|
|
364
|
+
* and a signing candidate is built straight on them.
|
|
365
|
+
*/
|
|
366
|
+
hasUnsavedEdits(): boolean;
|
|
367
|
+
/** Cached hash of the current loaded bytes, or `null` when not computed since the last load. */
|
|
368
|
+
cachedPlainSha256(): string | null;
|
|
369
|
+
rememberPlainSha256(sha256: string): void;
|
|
370
|
+
/**
|
|
371
|
+
* Re-point this session at new bytes — the one operation that changes
|
|
372
|
+
* what an open session is backed by, used when a completed signature
|
|
373
|
+
* installs its sealed file. The session id, its page object numbers
|
|
374
|
+
* (an incremental save never renumbers) and its retained resources
|
|
375
|
+
* survive; the old document is closed, every page is re-pinned (its
|
|
376
|
+
* revision bumped, its cached pointer dropped), and the mutation
|
|
377
|
+
* sequence advances so every version-keyed cache rebuilds.
|
|
378
|
+
*/
|
|
379
|
+
install(handle: OpenedPdfDocument): void;
|
|
380
|
+
/** The two publish fences a candidate is built on. */
|
|
381
|
+
versionRef(baseSha256: string): DocumentVersionRef;
|
|
261
382
|
/**
|
|
262
383
|
* Park this session in the password-locked state: the document could not
|
|
263
384
|
* be loaded because a (correct) password is missing, so the session keeps
|
|
@@ -340,12 +461,29 @@ declare class BaseDocumentRegistry {
|
|
|
340
461
|
key: string;
|
|
341
462
|
bytes: Uint8Array;
|
|
342
463
|
password?: string | null;
|
|
464
|
+
/** A verified SHA-256 (hex) of `bytes`; spares the runtime a full hashing pass. */
|
|
465
|
+
knownSha256?: string;
|
|
343
466
|
}): AcquiredBaseDocument;
|
|
344
467
|
acquireFileBase(opts: {
|
|
345
468
|
key: string;
|
|
346
469
|
path: string;
|
|
347
470
|
password?: string | null;
|
|
471
|
+
/** A verified SHA-256 (hex) of the file; spares the runtime a full hashing pass. */
|
|
472
|
+
knownSha256?: string;
|
|
348
473
|
}): AcquiredBaseDocument;
|
|
474
|
+
/**
|
|
475
|
+
* One more retain on a base already in the registry (a session holds one
|
|
476
|
+
* for its lifetime, so its key is live while it is open), or null. The
|
|
477
|
+
* way a signing candidate reopens over its session's own base without
|
|
478
|
+
* copying a byte.
|
|
479
|
+
*/
|
|
480
|
+
retainByKey(key: string): AcquiredBaseDocument | null;
|
|
481
|
+
/**
|
|
482
|
+
* Hand the runtime a hash the host already verified for these exact
|
|
483
|
+
* bytes, so it never hashes them itself. Malformed values are ignored:
|
|
484
|
+
* the runtime then hashes lazily on first use, which is always correct.
|
|
485
|
+
*/
|
|
486
|
+
private supplyKnownSha;
|
|
349
487
|
releaseAll(): void;
|
|
350
488
|
/** @internal Test-only probe of the per-key share refcount. */
|
|
351
489
|
getRefCountForTesting(key: string): number;
|
|
@@ -538,6 +676,16 @@ declare class PagesMutator {
|
|
|
538
676
|
* Abort is honored BEFORE the apply loop, never inside it.
|
|
539
677
|
*/
|
|
540
678
|
delete(pageObjectNumbers: PageObjectNumber[], signal: AbortSignal): PageDeleteResult;
|
|
679
|
+
/**
|
|
680
|
+
* Register `name` → page in `/Names /Pages` (create, or replace what the
|
|
681
|
+
* key points at); with `replace`, drop that other key first — a rename as
|
|
682
|
+
* one job. Named pages are LAYOUT: page identity and order are untouched
|
|
683
|
+
* (no registry refresh, no revision bumps) and the fresh snapshot is
|
|
684
|
+
* returned like `move()`.
|
|
685
|
+
*/
|
|
686
|
+
setName(input: PageNameInput, signal: AbortSignal): PageNameResult;
|
|
687
|
+
/** Remove one `/Names /Pages` registration; the page stays. */
|
|
688
|
+
removeName(input: PageRemoveNameInput, signal: AbortSignal): PageNameResult;
|
|
541
689
|
/** Shared input check: non-empty, no duplicate PONs. */
|
|
542
690
|
private requireUniquePons;
|
|
543
691
|
}
|
|
@@ -767,67 +915,6 @@ declare class PageRenderReader {
|
|
|
767
915
|
render(pageObjectNumber: PageObjectNumber, options: PageRenderOptions, signal: AbortSignal): import("@embedpdf/engine-core/runtime").PageRaster;
|
|
768
916
|
}
|
|
769
917
|
//#endregion
|
|
770
|
-
//#region src/features/annotations/AnnotationReader.d.ts
|
|
771
|
-
/**
|
|
772
|
-
* Per-page slow-path reader. Acquires a `pagePtr` from the
|
|
773
|
-
* `PagePtrPool`, dispatches the same per-subtype catalog as the raw
|
|
774
|
-
* reader (via `collectPageAnnotations`), and releases the page on exit.
|
|
775
|
-
*
|
|
776
|
-
* Currently the dispatched readers do not use the `pagePtr` parameter
|
|
777
|
-
* (text-markup is fully readable from the dict). Subtype readers that
|
|
778
|
-
* need form/widget access (e.g. widget) will plug into this code path
|
|
779
|
-
* as they land - the public DTO surface stays the same.
|
|
780
|
-
*/
|
|
781
|
-
declare class AnnotationReader {
|
|
782
|
-
private readonly runtime;
|
|
783
|
-
private readonly session;
|
|
784
|
-
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
785
|
-
list(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
|
|
786
|
-
}
|
|
787
|
-
//#endregion
|
|
788
|
-
//#region src/features/annotations/AnnotationAppearanceReader.d.ts
|
|
789
|
-
/**
|
|
790
|
-
* Batch-renders the appearance streams (`/AP`) of every annotation on a page,
|
|
791
|
-
* one bitmap per requested mode. Ported from the v2 PDFium engine's
|
|
792
|
-
* `renderPageAnnotationsRaw` / `renderSingleAnnotAppearance`, but expressed in
|
|
793
|
-
* PDF user space and against the `PdfRuntimeModule` (`fn` + `mem`).
|
|
794
|
-
*
|
|
795
|
-
* Each appearance bitmap is sized to its annotation's `/Rect` scaled by
|
|
796
|
-
* `options.scale`. The shared raster helper handles PDFium's display matrix
|
|
797
|
-
* convention, so this reader stays in normalized PDF page coordinates.
|
|
798
|
-
*/
|
|
799
|
-
declare class AnnotationAppearanceReader {
|
|
800
|
-
private readonly runtime;
|
|
801
|
-
private readonly session;
|
|
802
|
-
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
803
|
-
render(pageObjectNumber: PageObjectNumber, options: AnnotationAppearanceRenderOptions, signal: AbortSignal): AnnotationAppearancesResult;
|
|
804
|
-
/**
|
|
805
|
-
* Render a single annotation appearance into its own raster. Returns `null`
|
|
806
|
-
* when the mode has no appearance stream (after an optional form-field AP
|
|
807
|
-
* generation fallback) or the render fails.
|
|
808
|
-
*/
|
|
809
|
-
private renderOne;
|
|
810
|
-
}
|
|
811
|
-
//#endregion
|
|
812
|
-
//#region src/features/annotations/RawAnnotationReader.d.ts
|
|
813
|
-
/**
|
|
814
|
-
* Whole-document and per-page raw read paths. Never acquires a pagePtr;
|
|
815
|
-
* uses `EPDFPage_GetAnnotCountRaw` / `EPDFPage_GetAnnotRaw` /
|
|
816
|
-
* `EPDFAnnot_GetObjectNumber` directly off the docPtr.
|
|
817
|
-
*
|
|
818
|
-
* Per-subtype dispatch is the same as the full reader (both share
|
|
819
|
-
* `collectPageAnnotations`), so the wire shape `AnnotationDTO[]` is
|
|
820
|
-
* identical between raw and full read paths for the subtypes that don't
|
|
821
|
-
* actually need a pagePtr to materialise their fields.
|
|
822
|
-
*/
|
|
823
|
-
declare class RawAnnotationReader {
|
|
824
|
-
private readonly runtime;
|
|
825
|
-
private readonly session;
|
|
826
|
-
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
827
|
-
listAll(signal: AbortSignal): AnnotationListSnapshotAllPages;
|
|
828
|
-
listOne(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
|
|
829
|
-
}
|
|
830
|
-
//#endregion
|
|
831
918
|
//#region src/features/fonts/FontRegistrar.d.ts
|
|
832
919
|
/**
|
|
833
920
|
* A font to register at thread startup from a local file. Used by hosts that
|
|
@@ -879,6 +966,9 @@ declare class FontRegistrar {
|
|
|
879
966
|
* base document. Closed in {@link clear}.
|
|
880
967
|
*/
|
|
881
968
|
private readonly fileHandles;
|
|
969
|
+
/** What the runtime resolved for each key: the identity a document names
|
|
970
|
+
* the face by, and the licence. */
|
|
971
|
+
private readonly identities;
|
|
882
972
|
constructor(runtime: PdfRuntimeModule,
|
|
883
973
|
/** Host-owned `fontKey → native FontId` map for this thread. */
|
|
884
974
|
ids: Map<string, number>);
|
|
@@ -899,6 +989,19 @@ declare class FontRegistrar {
|
|
|
899
989
|
* Throws `InvalidArg` when the runtime rejects the font (corrupt, no glyphs).
|
|
900
990
|
*/
|
|
901
991
|
registerFromNodeFile(fontKey: string, familyName: string, weight: number, italic: number, path: string): void;
|
|
992
|
+
/** The identity and licence the runtime resolved for a key. Throws if unknown. */
|
|
993
|
+
describe(fontKey: string): FontIdentityInfo;
|
|
994
|
+
/** {@link describe} for callers that treat an unknown key as "not a key". */
|
|
995
|
+
describeOrUndefined(fontKey: string): FontIdentityInfo | undefined;
|
|
996
|
+
/**
|
|
997
|
+
* The key of the registered font whose identity matches a face (family
|
|
998
|
+
* compared the engine's way; the closest weight, italic first), or
|
|
999
|
+
* undefined when no registered family matches.
|
|
1000
|
+
*/
|
|
1001
|
+
keyForFace(family: string, weight: number, italic: boolean): string | undefined;
|
|
1002
|
+
/** The application asserts a licence permitting editing with the font. */
|
|
1003
|
+
authorizeEditing(fontKey: string): FontIdentityInfo;
|
|
1004
|
+
private readIdentity;
|
|
902
1005
|
/**
|
|
903
1006
|
* Register host-owned startup fonts on this thread, in order, optionally
|
|
904
1007
|
* adding each to the fallback chain. Order matters: it fixes both the native
|
|
@@ -916,6 +1019,75 @@ declare class FontRegistrar {
|
|
|
916
1019
|
private requireId;
|
|
917
1020
|
}
|
|
918
1021
|
//#endregion
|
|
1022
|
+
//#region src/features/annotations/AnnotationReader.d.ts
|
|
1023
|
+
/**
|
|
1024
|
+
* Per-page slow-path reader. Acquires a `pagePtr` from the
|
|
1025
|
+
* `PagePtrPool`, dispatches the same per-subtype catalog as the raw
|
|
1026
|
+
* reader (via `collectPageAnnotations`), and releases the page on exit.
|
|
1027
|
+
*
|
|
1028
|
+
* Currently the dispatched readers do not use the `pagePtr` parameter
|
|
1029
|
+
* (text-markup is fully readable from the dict). Subtype readers that
|
|
1030
|
+
* need form/widget access (e.g. widget) will plug into this code path
|
|
1031
|
+
* as they land - the public DTO surface stays the same.
|
|
1032
|
+
*/
|
|
1033
|
+
declare class AnnotationReader {
|
|
1034
|
+
private readonly runtime;
|
|
1035
|
+
private readonly session;
|
|
1036
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1037
|
+
private readonly fonts?;
|
|
1038
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1039
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1040
|
+
fonts?: FontRegistrar | undefined);
|
|
1041
|
+
list(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
|
|
1042
|
+
}
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/features/annotations/AnnotationAppearanceReader.d.ts
|
|
1045
|
+
/**
|
|
1046
|
+
* Batch-renders the appearance streams (`/AP`) of every annotation on a page,
|
|
1047
|
+
* one bitmap per requested mode. Ported from the v2 PDFium engine's
|
|
1048
|
+
* `renderPageAnnotationsRaw` / `renderSingleAnnotAppearance`, but expressed in
|
|
1049
|
+
* PDF user space and against the `PdfRuntimeModule` (`fn` + `mem`).
|
|
1050
|
+
*
|
|
1051
|
+
* Each appearance bitmap is sized to its annotation's `/Rect` scaled by
|
|
1052
|
+
* `options.scale`. The shared raster helper handles PDFium's display matrix
|
|
1053
|
+
* convention, so this reader stays in normalized PDF page coordinates.
|
|
1054
|
+
*/
|
|
1055
|
+
declare class AnnotationAppearanceReader {
|
|
1056
|
+
private readonly runtime;
|
|
1057
|
+
private readonly session;
|
|
1058
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1059
|
+
render(pageObjectNumber: PageObjectNumber, options: AnnotationAppearanceRenderOptions, signal: AbortSignal): AnnotationAppearancesResult;
|
|
1060
|
+
/**
|
|
1061
|
+
* Render a single annotation appearance into its own raster. Returns `null`
|
|
1062
|
+
* when the mode has no appearance stream (after an optional form-field AP
|
|
1063
|
+
* generation fallback) or the render fails.
|
|
1064
|
+
*/
|
|
1065
|
+
private renderOne;
|
|
1066
|
+
}
|
|
1067
|
+
//#endregion
|
|
1068
|
+
//#region src/features/annotations/RawAnnotationReader.d.ts
|
|
1069
|
+
/**
|
|
1070
|
+
* Whole-document and per-page raw read paths. Never acquires a pagePtr;
|
|
1071
|
+
* uses `EPDFPage_GetAnnotCountRaw` / `EPDFPage_GetAnnotRaw` /
|
|
1072
|
+
* `EPDFAnnot_GetObjectNumber` directly off the docPtr.
|
|
1073
|
+
*
|
|
1074
|
+
* Per-subtype dispatch is the same as the full reader (both share
|
|
1075
|
+
* `collectPageAnnotations`), so the wire shape `AnnotationDTO[]` is
|
|
1076
|
+
* identical between raw and full read paths for the subtypes that don't
|
|
1077
|
+
* actually need a pagePtr to materialise their fields.
|
|
1078
|
+
*/
|
|
1079
|
+
declare class RawAnnotationReader {
|
|
1080
|
+
private readonly runtime;
|
|
1081
|
+
private readonly session;
|
|
1082
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1083
|
+
private readonly fonts?;
|
|
1084
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1085
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1086
|
+
fonts?: FontRegistrar | undefined);
|
|
1087
|
+
listAll(signal: AbortSignal): AnnotationListSnapshotAllPages;
|
|
1088
|
+
listOne(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationListPageSnapshot;
|
|
1089
|
+
}
|
|
1090
|
+
//#endregion
|
|
919
1091
|
//#region src/features/annotations/AnnotationMutator.d.ts
|
|
920
1092
|
/**
|
|
921
1093
|
* Synchronous orchestrator for `create` / `update` / `delete` annotation
|
|
@@ -1029,6 +1201,31 @@ declare class AnnotationMutator {
|
|
|
1029
1201
|
private computeHasWeakAnnotations;
|
|
1030
1202
|
}
|
|
1031
1203
|
//#endregion
|
|
1204
|
+
//#region src/features/annotations/AnnotationFlattener.d.ts
|
|
1205
|
+
/**
|
|
1206
|
+
* The annotation-plane flatten verbs — `pages.flatten` for a chosen set:
|
|
1207
|
+
* in place (`flatten`) or into a new single-page document
|
|
1208
|
+
* (`exportAppearance`). Both resolve refs to native handles on the page,
|
|
1209
|
+
* hand the SET to the fork (one candidate plan, one placement writer — the
|
|
1210
|
+
* same code whole-page flatten runs), and release every handle afterwards.
|
|
1211
|
+
*/
|
|
1212
|
+
declare class AnnotationFlattener {
|
|
1213
|
+
private readonly runtime;
|
|
1214
|
+
private readonly session;
|
|
1215
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1216
|
+
flatten(pageObjectNumber: PageObjectNumber, refs: AnnotationRef[], usage: PageFlattenUsage, signal: AbortSignal): AnnotationFlattenResult;
|
|
1217
|
+
exportAppearance(pageObjectNumber: PageObjectNumber, refs: AnnotationRef[], signal: AbortSignal): {
|
|
1218
|
+
bytes: ArrayBuffer;
|
|
1219
|
+
size: number;
|
|
1220
|
+
};
|
|
1221
|
+
/** Resolve every ref on `pagePtr` (NotFound / InvalidReference from the
|
|
1222
|
+
* resolver on caller error); on any failure, close what was opened. */
|
|
1223
|
+
private resolveAll;
|
|
1224
|
+
/** Marshal an `FPDF_ANNOTATION*` array for the call's duration. */
|
|
1225
|
+
private withHandleArray;
|
|
1226
|
+
private requireRefs;
|
|
1227
|
+
}
|
|
1228
|
+
//#endregion
|
|
1032
1229
|
//#region src/features/annotations/internal/mutations/computeMutationImpact.d.ts
|
|
1033
1230
|
/**
|
|
1034
1231
|
* The kind of mutation that just happened on a page.
|
|
@@ -1237,6 +1434,8 @@ declare class SecurityReader {
|
|
|
1237
1434
|
}
|
|
1238
1435
|
//#endregion
|
|
1239
1436
|
//#region src/features/save/DocumentSaver.d.ts
|
|
1437
|
+
/** Whose bytes a snapshot holds: the loaded file, or the file a save would write. */
|
|
1438
|
+
type SaveSource = 'loaded' | 'working-copy';
|
|
1240
1439
|
/**
|
|
1241
1440
|
* Owns every "serialize the open document" path for a `DocumentSession`.
|
|
1242
1441
|
* Two distinct outputs:
|
|
@@ -1255,10 +1454,94 @@ declare class DocumentSaver {
|
|
|
1255
1454
|
private readonly runtime;
|
|
1256
1455
|
private readonly session;
|
|
1257
1456
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1457
|
+
/**
|
|
1458
|
+
* The bytes a save would produce, and whether they are the loaded bytes.
|
|
1459
|
+
* Three answers, cheapest first: nothing was mutated since load (the
|
|
1460
|
+
* session's counter); something was mutated but the document is still
|
|
1461
|
+
* the one it was opened with — the fork's save pass found no reachable
|
|
1462
|
+
* object that differs from its loaded version, an annotation added and
|
|
1463
|
+
* removed again being the common case; or a real delta. The one pass
|
|
1464
|
+
* answers the second and produces the third, comparing only the objects
|
|
1465
|
+
* that were touched. A signed file must come back exactly as sealed, so
|
|
1466
|
+
* the loaded bytes are returned verbatim in the first two cases.
|
|
1467
|
+
*/
|
|
1468
|
+
snapshot(): {
|
|
1469
|
+
bytes: ArrayBuffer;
|
|
1470
|
+
source: SaveSource;
|
|
1471
|
+
};
|
|
1472
|
+
/** The complete loaded bytes: a plain file, or a layer's base plus the delta it was opened with. */
|
|
1473
|
+
loadedBytes(): ArrayBuffer;
|
|
1474
|
+
/**
|
|
1475
|
+
* The loaded bytes streamed to `path` in chunks: a plain file, or a
|
|
1476
|
+
* layer's base plus the delta it was opened with, never the base alone.
|
|
1477
|
+
* Native only. Replaces whatever `path` held.
|
|
1478
|
+
*/
|
|
1479
|
+
copyLoadedBytesToFile(path: string): void;
|
|
1480
|
+
/**
|
|
1481
|
+
* `snapshot()` onto a file: `path` ends up holding the document a save
|
|
1482
|
+
* would write — the loaded bytes when nothing changed, else the standalone
|
|
1483
|
+
* save — without the document ever being an in-memory buffer. Native only.
|
|
1484
|
+
*/
|
|
1485
|
+
snapshotToFile(path: string): {
|
|
1486
|
+
path: string;
|
|
1487
|
+
source: SaveSource;
|
|
1488
|
+
};
|
|
1489
|
+
/** Whether this runtime and session can put scratch output beside the base file. */
|
|
1490
|
+
canWriteScratchFiles(): boolean;
|
|
1258
1491
|
saveLayerArtifact(): {
|
|
1259
1492
|
bytes: ArrayBuffer;
|
|
1260
1493
|
size: number;
|
|
1261
1494
|
};
|
|
1495
|
+
/**
|
|
1496
|
+
* `saveLayerArtifact` that says whether anything reachable changed since
|
|
1497
|
+
* the layer was opened. When nothing did, `bytes` is empty and the
|
|
1498
|
+
* artifact the session was opened with stands. The artifact written
|
|
1499
|
+
* otherwise is cumulative against the base (empty delta when the layer
|
|
1500
|
+
* came to equal its base).
|
|
1501
|
+
*/
|
|
1502
|
+
saveLayerArtifactEx(): {
|
|
1503
|
+
bytes: ArrayBuffer;
|
|
1504
|
+
size: number;
|
|
1505
|
+
changedSinceLoad: boolean;
|
|
1506
|
+
};
|
|
1507
|
+
/**
|
|
1508
|
+
* `saveLayerArtifactEx` onto a file: nothing reaches `path` when nothing
|
|
1509
|
+
* changed since load. The delta inside is streamed, never held whole.
|
|
1510
|
+
* Native only.
|
|
1511
|
+
*/
|
|
1512
|
+
saveLayerArtifactToFileEx(path: string): {
|
|
1513
|
+
path: string;
|
|
1514
|
+
changedSinceLoad: boolean;
|
|
1515
|
+
};
|
|
1516
|
+
/** `saveLayerDeltaEx` onto a file: the cumulative delta, or nothing when nothing changed since load. Native only. */
|
|
1517
|
+
saveLayerDeltaToFileEx(path: string): {
|
|
1518
|
+
path: string;
|
|
1519
|
+
changedSinceLoad: boolean;
|
|
1520
|
+
};
|
|
1521
|
+
private saveLayerToFileImpl;
|
|
1522
|
+
private saveLayerArtifactImpl;
|
|
1523
|
+
/**
|
|
1524
|
+
* The raw cumulative delta a layer save writes (every promoted object,
|
|
1525
|
+
* offsets notional from the base's append offset), without the artifact
|
|
1526
|
+
* header: what `EPDFDoc_OpenBaseOverlay` composes with the base. Empty
|
|
1527
|
+
* when nothing was promoted.
|
|
1528
|
+
*/
|
|
1529
|
+
saveLayerDelta(): {
|
|
1530
|
+
bytes: ArrayBuffer;
|
|
1531
|
+
size: number;
|
|
1532
|
+
};
|
|
1533
|
+
/**
|
|
1534
|
+
* `saveLayerDelta` that says whether anything reachable changed since the
|
|
1535
|
+
* layer was opened; empty bytes when nothing did (keep what you have), or
|
|
1536
|
+
* when the layer came to equal its base (then `changedSinceLoad` is true
|
|
1537
|
+
* and the document IS the base).
|
|
1538
|
+
*/
|
|
1539
|
+
saveLayerDeltaEx(): {
|
|
1540
|
+
bytes: ArrayBuffer;
|
|
1541
|
+
size: number;
|
|
1542
|
+
changedSinceLoad: boolean;
|
|
1543
|
+
};
|
|
1544
|
+
private saveLayerDeltaImpl;
|
|
1262
1545
|
saveLayerArtifactToFile(path: string): {
|
|
1263
1546
|
path: string;
|
|
1264
1547
|
};
|
|
@@ -1266,12 +1549,261 @@ declare class DocumentSaver {
|
|
|
1266
1549
|
bytes: ArrayBuffer;
|
|
1267
1550
|
size: number;
|
|
1268
1551
|
};
|
|
1552
|
+
/**
|
|
1553
|
+
* `saveStandaloneToBuffer` that says whether the save wrote anything. An
|
|
1554
|
+
* incremental save of a layer never rewrites an object equal to its base
|
|
1555
|
+
* twin, and when no reachable object differs from the document the layer
|
|
1556
|
+
* was opened with it writes nothing at all: `unchangedSinceLoad`, empty
|
|
1557
|
+
* bytes — the loaded bytes are the document.
|
|
1558
|
+
*/
|
|
1559
|
+
saveStandaloneToBufferEx(mode: PdfSaveMode): {
|
|
1560
|
+
bytes: ArrayBuffer;
|
|
1561
|
+
size: number;
|
|
1562
|
+
unchangedSinceLoad: boolean;
|
|
1563
|
+
};
|
|
1269
1564
|
saveStandaloneToFile(path: string, mode: PdfSaveMode): {
|
|
1270
1565
|
path: string;
|
|
1271
1566
|
};
|
|
1567
|
+
/**
|
|
1568
|
+
* `saveStandaloneToFile` with the report of `saveStandaloneToBufferEx`.
|
|
1569
|
+
* On `unchangedSinceLoad` no byte reached the file: the caller streams
|
|
1570
|
+
* the loaded bytes instead.
|
|
1571
|
+
*/
|
|
1572
|
+
saveStandaloneToFileEx(path: string, mode: PdfSaveMode): {
|
|
1573
|
+
path: string;
|
|
1574
|
+
unchangedSinceLoad: boolean;
|
|
1575
|
+
};
|
|
1272
1576
|
private requireLayer;
|
|
1273
1577
|
}
|
|
1274
1578
|
//#endregion
|
|
1579
|
+
//#region src/features/signature/SignatureReader.d.ts
|
|
1580
|
+
declare const DIGEST_CODE: Record<DigestAlgorithm, number>;
|
|
1581
|
+
/**
|
|
1582
|
+
* Reads the signature model of a session: revisions, every signature
|
|
1583
|
+
* field with its signed state, and the protection those signatures
|
|
1584
|
+
* impose. Byte facts (revisions, coverage, digests, loaded bytes) come
|
|
1585
|
+
* from the bytes the document was loaded from — for a layer session the
|
|
1586
|
+
* base plus the delta it was opened with — never from unsaved edits.
|
|
1587
|
+
*/
|
|
1588
|
+
declare class SignatureReader {
|
|
1589
|
+
private readonly runtime;
|
|
1590
|
+
private readonly session;
|
|
1591
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1592
|
+
readSnapshot(): SignatureSnapshot;
|
|
1593
|
+
/** The protection alone, for the open probe and the form write guard. */
|
|
1594
|
+
readProtection(): DocumentProtection;
|
|
1595
|
+
/** The DER `/Contents` of a signed field, padding stripped. */
|
|
1596
|
+
readContents(ref: FormFieldRef): ArrayBuffer;
|
|
1597
|
+
/** Hash a signed field's `/ByteRange` straight from the loaded bytes. */
|
|
1598
|
+
digest(ref: FormFieldRef, algorithm: DigestAlgorithm): ArrayBuffer;
|
|
1599
|
+
/** The exact bytes of one revision. */
|
|
1600
|
+
revisionBytes(revisionIndex: number): ArrayBuffer;
|
|
1601
|
+
/** Resolve a signature-field ref to its identity in the current model. */
|
|
1602
|
+
resolveField(ref: FormFieldRef): {
|
|
1603
|
+
index: number;
|
|
1604
|
+
fieldObjectNumber: number;
|
|
1605
|
+
signed: boolean;
|
|
1606
|
+
widget: {
|
|
1607
|
+
annotObjectNumber: number;
|
|
1608
|
+
pageObjectNumber: number;
|
|
1609
|
+
} | null;
|
|
1610
|
+
};
|
|
1611
|
+
/** One signature by field object number, from the current model. */
|
|
1612
|
+
readSignatureByObjectNumber(fieldObjectNumber: number): SignatureDTO;
|
|
1613
|
+
/** The complete loaded bytes (a plain file, or a layer's base + delta). */
|
|
1614
|
+
loadedBytes(): ArrayBuffer;
|
|
1615
|
+
/**
|
|
1616
|
+
* SHA-256 and length of the base the session is on. A layer session
|
|
1617
|
+
* reports its base's hash (supplied by the host or computed once by the
|
|
1618
|
+
* runtime); a plain session hashes its loaded bytes once per load.
|
|
1619
|
+
*/
|
|
1620
|
+
version(): BaseVersionInfo;
|
|
1621
|
+
private digestRange;
|
|
1622
|
+
/** `[offset, offset + length)` of the loaded bytes (base + loaded delta for a layer), copied out. */
|
|
1623
|
+
readLoadedBytes(offset: number, length: number): ArrayBuffer;
|
|
1624
|
+
private indexOf;
|
|
1625
|
+
private requireSignedIndex;
|
|
1626
|
+
private readString;
|
|
1627
|
+
private readWide;
|
|
1628
|
+
}
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region src/features/signature/SignatureMutator.d.ts
|
|
1631
|
+
/**
|
|
1632
|
+
* The two-phase signing protocol on a session, local and native alike.
|
|
1633
|
+
*
|
|
1634
|
+
* `prepare` never touches the live document: it builds a CANDIDATE — a
|
|
1635
|
+
* fresh layer over the session's own immutable base (see `openCandidate`)
|
|
1636
|
+
* — writes the signature there, saves it through a `CandidateStore`
|
|
1637
|
+
* (memory locally, a file beside the base on file-backed sessions), seals
|
|
1638
|
+
* it, and parks the saved candidate on the session. `complete` writes the
|
|
1639
|
+
* CMS into it, opens it as a new base with a fresh layer, proves the new
|
|
1640
|
+
* signature seals a whole revision, and installs it as the session's
|
|
1641
|
+
* document. `abort` discards the candidate.
|
|
1642
|
+
*/
|
|
1643
|
+
declare class SignatureMutator {
|
|
1644
|
+
private readonly runtime;
|
|
1645
|
+
private readonly session;
|
|
1646
|
+
private readonly baseDocuments;
|
|
1647
|
+
/** Where a file-backed session's candidate is written; defaults to beside the base file. */
|
|
1648
|
+
private readonly candidatePath?;
|
|
1649
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession, baseDocuments: BaseDocumentRegistry,
|
|
1650
|
+
/** Where a file-backed session's candidate is written; defaults to beside the base file. */
|
|
1651
|
+
candidatePath?: ((basePath: string, signingId: string) => string) | undefined);
|
|
1652
|
+
prepare(input: SignaturePrepareInput): SignaturePrepared;
|
|
1653
|
+
complete(input: SignatureCompleteInput): SignatureCompleteResult;
|
|
1654
|
+
abort(signingId: string): SignatureAbortResult;
|
|
1655
|
+
private callPrepare;
|
|
1656
|
+
/** Draw a page of `pdf` into the widget's appearance stream on the candidate. */
|
|
1657
|
+
/**
|
|
1658
|
+
* File-backed sessions (a file base in the registry: the server) persist
|
|
1659
|
+
* the candidate as a file beside the base; everything else keeps it in
|
|
1660
|
+
* memory. The choice follows the SESSION's base, not the candidate's.
|
|
1661
|
+
*/
|
|
1662
|
+
private storeFor;
|
|
1663
|
+
/**
|
|
1664
|
+
* Prove the sealed bytes carry a whole-revision signature on the field
|
|
1665
|
+
* before anything is installed; closes the handle on failure.
|
|
1666
|
+
*/
|
|
1667
|
+
/**
|
|
1668
|
+
* Read the sealed candidate back before it is installed: the checks in
|
|
1669
|
+
* `assertSealedSignature` are made on a model loaded from the sealed
|
|
1670
|
+
* bytes themselves, so a candidate the writer got wrong never becomes
|
|
1671
|
+
* the session's bytes.
|
|
1672
|
+
*/
|
|
1673
|
+
private verifySealed;
|
|
1674
|
+
/**
|
|
1675
|
+
* The candidate the signature is authored on. A layer session reopens a
|
|
1676
|
+
* fresh layer over ITS OWN immutable base (a registry retain, no copy of
|
|
1677
|
+
* the file), fed the layer it was opened with — or, with unsaved edits,
|
|
1678
|
+
* the artifact a save would write, which is cumulative: the edits and
|
|
1679
|
+
* the signature then share one revision, as Acrobat saves a
|
|
1680
|
+
* fill-and-sign. The fallback freezes the complete loaded bytes as a new
|
|
1681
|
+
* memory base: for a plain session, and for a layer whose loaded delta
|
|
1682
|
+
* already holds signed bytes (a layer save rewrites the delta and would
|
|
1683
|
+
* drop them; the fork refuses to prepare such a candidate).
|
|
1684
|
+
*/
|
|
1685
|
+
private openCandidate;
|
|
1686
|
+
/** Whether a signature's byte range reaches into the layer's loaded delta (past the base). */
|
|
1687
|
+
private loadedDeltaHoldsSignedBytes;
|
|
1688
|
+
}
|
|
1689
|
+
//#endregion
|
|
1690
|
+
//#region src/features/signature/SignatureAnalyzer.d.ts
|
|
1691
|
+
/**
|
|
1692
|
+
* Modification analysis over a session: which revisions to compare, the
|
|
1693
|
+
* fork's exact object diff for each adjacent pair, each revision's
|
|
1694
|
+
* structure, and the pure rule engine's verdict per step. Every revision
|
|
1695
|
+
* is opened as its own prefix document from the target's loaded bytes;
|
|
1696
|
+
* `working-copy` first snapshots the session the way a save would.
|
|
1697
|
+
*/
|
|
1698
|
+
declare class SignatureAnalyzer {
|
|
1699
|
+
private readonly runtime;
|
|
1700
|
+
private readonly session;
|
|
1701
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1702
|
+
/**
|
|
1703
|
+
* The signature snapshot of the session's working copy: the unsaved
|
|
1704
|
+
* state snapshotted the way a save would write it, as one more revision
|
|
1705
|
+
* over the loaded bytes. Identical to the loaded-bytes snapshot when
|
|
1706
|
+
* nothing is unsaved.
|
|
1707
|
+
*/
|
|
1708
|
+
readWorkingCopySnapshot(): SignatureSnapshot;
|
|
1709
|
+
analyze(input: AnalyzeInput): ChangeAnalysis;
|
|
1710
|
+
/** Revision `index` of `target`'s bytes as its own document, owned by `stack`. */
|
|
1711
|
+
private openPrefix;
|
|
1712
|
+
/**
|
|
1713
|
+
* Every pairwise step between `since` and `until`, two prefix documents
|
|
1714
|
+
* open at a time whatever the revision count. `sealedStructure` is the
|
|
1715
|
+
* structure of `since` (already read); every later structure is read once
|
|
1716
|
+
* and dropped with its document.
|
|
1717
|
+
*/
|
|
1718
|
+
private walkSteps;
|
|
1719
|
+
/**
|
|
1720
|
+
* The document as a save would write it, opened read-only, and whose
|
|
1721
|
+
* bytes that is. `loaded`: nothing was mutated since load, or the saver's
|
|
1722
|
+
* pass found no reachable object that differs from its loaded version —
|
|
1723
|
+
* the session's own document is the working copy. `working-copy`: a
|
|
1724
|
+
* layer session composes its immutable base with the cumulative delta
|
|
1725
|
+
* the pass emits (`EPDFDoc_OpenBaseOverlay`: no copy of the base, one
|
|
1726
|
+
* cross-reference parse, the loaded delta's revision REPLACED, as an
|
|
1727
|
+
* artifact is), or — when every edit brought the layer back to its base
|
|
1728
|
+
* — a fresh layer over that base; a plain session (unsigned by law 9, so
|
|
1729
|
+
* this is exploratory) materialises a standalone incremental save and
|
|
1730
|
+
* opens it whole.
|
|
1731
|
+
*/
|
|
1732
|
+
private openWorkingCopy;
|
|
1733
|
+
/** Changed since load, nothing to write: the layer equals its base, and a fresh layer over it IS that document. */
|
|
1734
|
+
private freshLayerOverBase;
|
|
1735
|
+
/**
|
|
1736
|
+
* The fork's exact object diff between two revision documents,
|
|
1737
|
+
* marshalled: values in pass one, anchored edges in pass two (the anchors
|
|
1738
|
+
* are the changed objects plus each side's structural objects).
|
|
1739
|
+
*/
|
|
1740
|
+
private compare;
|
|
1741
|
+
/** What the fork learned about one revision as a whole (see `RevisionHealth`). */
|
|
1742
|
+
private readHealth;
|
|
1743
|
+
/**
|
|
1744
|
+
* Pass two: every changed object's inbound edges, resolved through
|
|
1745
|
+
* unchanged non-structural objects to the nearest anchor (the fork's
|
|
1746
|
+
* referrer index covers every reachable object, so the walk never leaves
|
|
1747
|
+
* the diff). An object whose edges exceed the resolver's budget is
|
|
1748
|
+
* marked `usageIncomplete` and the evaluator refuses to permit it.
|
|
1749
|
+
*/
|
|
1750
|
+
private withAnchoredUsage;
|
|
1751
|
+
private readValue;
|
|
1752
|
+
private readReferrers;
|
|
1753
|
+
}
|
|
1754
|
+
//#endregion
|
|
1755
|
+
//#region src/features/signature/CandidateFinalizer.d.ts
|
|
1756
|
+
interface FinalizeCandidateInput {
|
|
1757
|
+
/** The rebuilt candidate on this filesystem; patched in place. */
|
|
1758
|
+
path: string;
|
|
1759
|
+
byteRange: [number, number, number, number];
|
|
1760
|
+
contentsSize: number;
|
|
1761
|
+
fieldObjectNumber: number;
|
|
1762
|
+
cms: Uint8Array;
|
|
1763
|
+
password: string | null;
|
|
1764
|
+
}
|
|
1765
|
+
interface FinalizedCandidate {
|
|
1766
|
+
signature: SignatureDTO;
|
|
1767
|
+
protection: DocumentProtection;
|
|
1768
|
+
version: BaseVersionInfo;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* The session-less half of a durable signing. A server prepares a
|
|
1772
|
+
* candidate on one replica, keeps only its tail, and may complete it on
|
|
1773
|
+
* another: the completing replica rebuilds base ⊕ tail into a private
|
|
1774
|
+
* file and hands it here with what the prepare reported. The CMS is
|
|
1775
|
+
* hex-encoded into the /Contents hole in place — never more than the
|
|
1776
|
+
* hole itself is held in memory — and the file is then opened like any
|
|
1777
|
+
* other base and read back through the signature model, so the version
|
|
1778
|
+
* returned is the file's own hash and the signature is what the file
|
|
1779
|
+
* says, not what the writer meant. Nothing here touches a live session.
|
|
1780
|
+
*/
|
|
1781
|
+
declare class CandidateFinalizer {
|
|
1782
|
+
private readonly runtime;
|
|
1783
|
+
private readonly baseDocuments;
|
|
1784
|
+
constructor(runtime: PdfRuntimeModule, baseDocuments: BaseDocumentRegistry);
|
|
1785
|
+
finalize(input: FinalizeCandidateInput): FinalizedCandidate;
|
|
1786
|
+
}
|
|
1787
|
+
//#endregion
|
|
1788
|
+
//#region src/features/signature/internal/signatureModelCache.d.ts
|
|
1789
|
+
declare function acquireSignatureModel(runtime: PdfRuntimeModule, session: DocumentSession): Ptr;
|
|
1790
|
+
declare function disposeSignatureModel(runtime: PdfRuntimeModule, session: DocumentSession): void;
|
|
1791
|
+
//#endregion
|
|
1792
|
+
//#region src/features/signature/internal/readSignatureModel.d.ts
|
|
1793
|
+
/** Every signature field of a native signature model, in model order. */
|
|
1794
|
+
declare function readSignaturesFromModel(runtime: PdfRuntimeModule, model: Ptr): SignatureDTO[];
|
|
1795
|
+
/** The chained revisions of a document, oldest first; empty when the chain is not valid. */
|
|
1796
|
+
declare function readRevisions(runtime: PdfRuntimeModule, docPtr: Ptr, signatures: ReadonlyArray<SignatureDTO>): PdfRevision[];
|
|
1797
|
+
/** Whether any signature field of the document carries a signed value (fields alone do not count). */
|
|
1798
|
+
declare function hasSignedSignature(runtime: PdfRuntimeModule, docPtr: Ptr): boolean;
|
|
1799
|
+
/**
|
|
1800
|
+
* The structure of one document (a revision prefix, usually): catalog,
|
|
1801
|
+
* AcroForm and page-tree object numbers, the pages, the terminal fields
|
|
1802
|
+
* with their widgets, and the signatures. What the rule engine needs to
|
|
1803
|
+
* give every changed object a role.
|
|
1804
|
+
*/
|
|
1805
|
+
declare function readStructure(runtime: PdfRuntimeModule, docPtr: Ptr): RevisionStructure;
|
|
1806
|
+
//#endregion
|
|
1275
1807
|
//#region src/features/forms/FormReader.d.ts
|
|
1276
1808
|
/**
|
|
1277
1809
|
* Read side of the forms feature. All reads go through the session's
|
|
@@ -1320,6 +1852,17 @@ declare class FormMutator {
|
|
|
1320
1852
|
createField(draft: FormFieldDraft, signal: AbortSignal): {
|
|
1321
1853
|
field: FormFieldDTO;
|
|
1322
1854
|
};
|
|
1855
|
+
/**
|
|
1856
|
+
* Draw a PDF page into every widget of an UNSIGNED signature field: the
|
|
1857
|
+
* visual "sign" of a viewer without a signer. The field's value stays
|
|
1858
|
+
* empty and nothing is sealed; a signed field is refused (its appearance
|
|
1859
|
+
* is part of what the signature covers). Pages whose widgets changed are
|
|
1860
|
+
* reported so their renders re-pin.
|
|
1861
|
+
*/
|
|
1862
|
+
setSignatureAppearance(ref: FormFieldRef, pdf: Uint8Array, pageIndex: number, signal: AbortSignal): {
|
|
1863
|
+
field: FormFieldDTO;
|
|
1864
|
+
pages: PageObjectNumber[];
|
|
1865
|
+
};
|
|
1323
1866
|
updateField(ref: FormFieldRef, patch: FormFieldPatch, signal: AbortSignal): {
|
|
1324
1867
|
field: FormFieldDTO;
|
|
1325
1868
|
};
|
|
@@ -1344,6 +1887,14 @@ declare class FormMutator {
|
|
|
1344
1887
|
private applyDefaultValues;
|
|
1345
1888
|
private readBackField;
|
|
1346
1889
|
private assertWritable;
|
|
1890
|
+
/**
|
|
1891
|
+
* A field an earlier signature froze (its FieldMDP, or the /Lock of a
|
|
1892
|
+
* signed field) refuses every write: document-derived authority, the
|
|
1893
|
+
* same way encryption bits are. Off under `signedDocumentPolicy:
|
|
1894
|
+
* 'permit'`. A document whose signature model cannot be built is not
|
|
1895
|
+
* known to be locked.
|
|
1896
|
+
*/
|
|
1897
|
+
private assertNotLockedBySignature;
|
|
1347
1898
|
/** Dispatch the typed native write. Returns the changed widget objnums. */
|
|
1348
1899
|
private applyWrite;
|
|
1349
1900
|
/** Run a native write with the changed-widgets out buffer wired up. */
|
|
@@ -1461,6 +2012,13 @@ interface WorkerImageEncoder {
|
|
|
1461
2012
|
}
|
|
1462
2013
|
interface WorkerHostOptions {
|
|
1463
2014
|
imageEncoder?: WorkerImageEncoder;
|
|
2015
|
+
/**
|
|
2016
|
+
* Where a file-backed session (a file base) writes its signing candidate
|
|
2017
|
+
* between `prepare` and `complete`. Defaults to beside the base file
|
|
2018
|
+
* (`<base>.signing-<id>.pdf`); a server maps it into its storage layout so
|
|
2019
|
+
* the sealed file can be published by rename.
|
|
2020
|
+
*/
|
|
2021
|
+
signingCandidatePath?: (basePath: string, signingId: string) => string;
|
|
1464
2022
|
}
|
|
1465
2023
|
/**
|
|
1466
2024
|
* The piece that runs "inside the worker": owns runtime, manages document
|
|
@@ -1519,6 +2077,48 @@ declare class WorkerHost {
|
|
|
1519
2077
|
registerStartupFonts(specs: readonly StartupFontSpec[]): void;
|
|
1520
2078
|
receive(msg: WorkerRequest): void;
|
|
1521
2079
|
private handleOpen;
|
|
2080
|
+
/**
|
|
2081
|
+
* Open plain bytes into `session` in the shape it asked for. The default,
|
|
2082
|
+
* `layer`, makes the bytes an immutable base with a fresh layer on top:
|
|
2083
|
+
* reads fall through to the base, a write promotes only what it touches,
|
|
2084
|
+
* a save appends exactly that, and a signature keeps its validity across
|
|
2085
|
+
* later edits because the signature dictionary is never rewritten. The
|
|
2086
|
+
* `plain` shape keeps one in-memory document — unless the bytes already
|
|
2087
|
+
* carry a signature value, which always opens as a layer, because a plain
|
|
2088
|
+
* save rewrites every loaded object into the new revision and strict
|
|
2089
|
+
* validators reject that. Auto-layered sessions serialize no artifact per
|
|
2090
|
+
* mutation: the caller never asked for one.
|
|
2091
|
+
*/
|
|
2092
|
+
private openSignedAware;
|
|
2093
|
+
/**
|
|
2094
|
+
* What the document's signatures forbid, read at open and after an
|
|
2095
|
+
* unlock so the main-thread guard can subtract capabilities before the
|
|
2096
|
+
* first mutation. A document whose signature model cannot be built
|
|
2097
|
+
* still opens: protection is then `null` (nothing is known to be
|
|
2098
|
+
* signed), and the reads report the failure on their own.
|
|
2099
|
+
*/
|
|
2100
|
+
private probeProtection;
|
|
2101
|
+
private handleSignaturesList;
|
|
2102
|
+
private handleSignaturesContents;
|
|
2103
|
+
private handleSignaturesDigest;
|
|
2104
|
+
private handleSignaturesRevisionBytes;
|
|
2105
|
+
private handleDocumentVersion;
|
|
2106
|
+
private handleSignaturesPrepare;
|
|
2107
|
+
private handleSignaturesComplete;
|
|
2108
|
+
private handleSignaturesAnalyze;
|
|
2109
|
+
/**
|
|
2110
|
+
* Session-less, like `document.renderPageFile`: the candidate file is
|
|
2111
|
+
* the caller's, patched in place and read back through a transient
|
|
2112
|
+
* session that is never stored in `this.sessions`.
|
|
2113
|
+
*/
|
|
2114
|
+
private handleSignaturesFinalizeCandidate;
|
|
2115
|
+
private handleSignaturesAbort;
|
|
2116
|
+
/**
|
|
2117
|
+
* The dispatch fence for a parked signing candidate. Only mutating kinds
|
|
2118
|
+
* are refused; a request for a session that is not open falls through
|
|
2119
|
+
* to its handler's own `DocNotOpen`.
|
|
2120
|
+
*/
|
|
2121
|
+
private assertNoPendingSigning;
|
|
1522
2122
|
private handleMetadataRead;
|
|
1523
2123
|
private handleMetadataUpdate;
|
|
1524
2124
|
private handleActionsRead;
|
|
@@ -1529,11 +2129,15 @@ declare class WorkerHost {
|
|
|
1529
2129
|
private handleAnnotationsCreate;
|
|
1530
2130
|
private handleAnnotationsUpdate;
|
|
1531
2131
|
private handleAnnotationsDelete;
|
|
2132
|
+
private handleAnnotationsFlatten;
|
|
2133
|
+
private handleAnnotationsExportAppearance;
|
|
1532
2134
|
private handleAnnotationsMove;
|
|
1533
2135
|
private handlePagesList;
|
|
1534
2136
|
private handlePagesMove;
|
|
1535
2137
|
private handlePagesRotate;
|
|
1536
2138
|
private handlePagesDelete;
|
|
2139
|
+
private handlePagesSetName;
|
|
2140
|
+
private handlePagesRemoveName;
|
|
1537
2141
|
private handlePagesFlatten;
|
|
1538
2142
|
private handleRedactionApply;
|
|
1539
2143
|
private handlePagesExtract;
|
|
@@ -1572,6 +2176,9 @@ declare class WorkerHost {
|
|
|
1572
2176
|
private handleDocumentRenderPageFile;
|
|
1573
2177
|
private handleDocumentCheckPasswordPermissions;
|
|
1574
2178
|
private handleFontsRegister;
|
|
2179
|
+
private handleFontsAuthorizeEditing;
|
|
2180
|
+
/** Per-document font and text-layout settings (session state). */
|
|
2181
|
+
private handleDocumentSetFontSettings;
|
|
1575
2182
|
private handleFontsAddFallback;
|
|
1576
2183
|
private handleFontsClearFallbacks;
|
|
1577
2184
|
private handleFontsClear;
|
|
@@ -1604,6 +2211,7 @@ declare class WorkerHost {
|
|
|
1604
2211
|
private handleFormsRepair;
|
|
1605
2212
|
private handleFormsCreateField;
|
|
1606
2213
|
private handleFormsUpdateField;
|
|
2214
|
+
private handleFormsSetSignatureAppearance;
|
|
1607
2215
|
private handleFormsDeleteField;
|
|
1608
2216
|
private handleFormsAttachWidget;
|
|
1609
2217
|
private handleFormsDetachWidget;
|
|
@@ -1611,5 +2219,5 @@ declare class WorkerHost {
|
|
|
1611
2219
|
private saveLayerArtifact;
|
|
1612
2220
|
}
|
|
1613
2221
|
//#endregion
|
|
1614
|
-
export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT, 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, type RawGeometryGlyphRecord, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, type WorkerEncodedImage, WorkerHost, type WorkerHostOptions, type WorkerImageEncoder, buildRunsFromRawGlyphs, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
|
|
2222
|
+
export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationFlattener, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CandidateFinalizer, CloseStack, DIGEST_CODE, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT, 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, type RawGeometryGlyphRecord, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, SignatureAnalyzer, SignatureMutator, SignatureReader, type StartupFontSpec, type WorkerEncodedImage, WorkerHost, type WorkerHostOptions, type WorkerImageEncoder, acquireSignatureModel, buildRunsFromRawGlyphs, computeMutationImpact, destroyLibrary, disposeFormModel, disposeSignatureModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, hasSignedSignature, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, readRevisions, readSignaturesFromModel, readStructure, throwIfAborted, writeAttachmentFilePayload };
|
|
1615
2223
|
//# sourceMappingURL=index.d.cts.map
|