@embedpdf/engine-core 3.0.0-next.13 → 3.0.0-next.15
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/AnnotationList-CkijRHet.d.cts +27163 -0
- package/dist/AnnotationList-CkijRHet.d.ts +27163 -0
- package/dist/Change-CKoxfTNY.js +889 -0
- package/dist/Change-CKoxfTNY.js.map +1 -0
- package/dist/Change-CjImsrN0.cjs +1020 -0
- package/dist/Change-CjImsrN0.cjs.map +1 -0
- package/dist/DocumentRenderService-BfFdFSwI.cjs +120 -0
- package/dist/DocumentRenderService-BfFdFSwI.cjs.map +1 -0
- package/dist/DocumentRenderService-DV3J9lMz.js +85 -0
- package/dist/DocumentRenderService-DV3J9lMz.js.map +1 -0
- package/dist/{DocumentSecurityService-_JRjqvoI.d.ts → DocumentSecurityService-CU1M6Q7m.d.ts} +100 -112
- package/dist/{DocumentSecurityService-ClTZc0zO.d.cts → DocumentSecurityService-e6vp2de8.d.cts} +100 -112
- package/dist/LocalDocumentHandle-D02FMm-Z.cjs +53 -0
- package/dist/LocalDocumentHandle-D02FMm-Z.cjs.map +1 -0
- package/dist/LocalDocumentHandle-DAPdaOt_.js +30 -0
- package/dist/LocalDocumentHandle-DAPdaOt_.js.map +1 -0
- package/dist/LocalEngine-DFoBm4B3.d.cts +1565 -0
- package/dist/LocalEngine-DPriFujS.d.ts +1565 -0
- package/dist/PageInsertBlankInput-CXHAM7l6.cjs +17 -0
- package/dist/PageInsertBlankInput-CXHAM7l6.cjs.map +1 -0
- package/dist/PageInsertBlankInput-DhVYVJ_S.js +12 -0
- package/dist/PageInsertBlankInput-DhVYVJ_S.js.map +1 -0
- package/dist/authority-B3BklsB4.js +2239 -0
- package/dist/authority-B3BklsB4.js.map +1 -0
- package/dist/authority-DLMNR7ff.cjs +2676 -0
- package/dist/authority-DLMNR7ff.cjs.map +1 -0
- package/dist/builders-CNj0POeY.js +161 -0
- package/dist/builders-CNj0POeY.js.map +1 -0
- package/dist/builders-Cgdp_YCn.cjs +184 -0
- package/dist/builders-Cgdp_YCn.cjs.map +1 -0
- package/dist/calibrate-7T3fnP8-.js +2404 -0
- package/dist/calibrate-7T3fnP8-.js.map +1 -0
- package/dist/calibrate-DJBXnhLE.cjs +2919 -0
- package/dist/calibrate-DJBXnhLE.cjs.map +1 -0
- package/dist/charmap-Cprti1ta.js +239 -0
- package/dist/charmap-Cprti1ta.js.map +1 -0
- package/dist/charmap-aYlefQP9.cjs +304 -0
- package/dist/charmap-aYlefQP9.cjs.map +1 -0
- package/dist/conformance.cjs +16753 -5247
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +928 -165
- package/dist/conformance.d.ts +928 -165
- package/dist/conformance.js +16731 -5268
- package/dist/conformance.js.map +1 -1
- package/dist/format-Bp3QFSH1.cjs +574 -0
- package/dist/format-Bp3QFSH1.cjs.map +1 -0
- package/dist/format-Dgg428Kb.js +461 -0
- package/dist/format-Dgg428Kb.js.map +1 -0
- package/dist/index.cjs +330 -103
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -5
- package/dist/pageRefs-B3ur7Ckm.cjs +51 -0
- package/dist/pageRefs-B3ur7Ckm.cjs.map +1 -0
- package/dist/pageRefs-DkbuxSCV.js +40 -0
- package/dist/pageRefs-DkbuxSCV.js.map +1 -0
- package/dist/public.cjs +57 -0
- package/dist/public.d.cts +5 -0
- package/dist/public.d.ts +5 -0
- package/dist/public.js +9 -0
- package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs +3646 -0
- package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs.map +1 -0
- package/dist/resolveAnnotationDraft-CUpf0SMh.js +3167 -0
- package/dist/resolveAnnotationDraft-CUpf0SMh.js.map +1 -0
- package/dist/{resolver-inAVzsWt.js → resolver-CzxmD9Ck.js} +294 -144
- package/dist/resolver-CzxmD9Ck.js.map +1 -0
- package/dist/{resolver-CYVNV4hn.cjs → resolver-D2OCtE8F.cjs} +347 -143
- package/dist/resolver-D2OCtE8F.cjs.map +1 -0
- package/dist/runtime-Cl0v56mm.d.ts +2032 -0
- package/dist/runtime-p1WDzDo4.d.cts +2032 -0
- package/dist/runtime.cjs +733 -284
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +5 -1348
- package/dist/runtime.d.ts +5 -1348
- package/dist/runtime.js +396 -179
- package/dist/runtime.js.map +1 -1
- package/dist/schema-C-gU4vj7.cjs +3034 -0
- package/dist/schema-C-gU4vj7.cjs.map +1 -0
- package/dist/schema-DzlUNk38.js +2081 -0
- package/dist/schema-DzlUNk38.js.map +1 -0
- package/dist/schemas-Berf1swF.cjs +2481 -0
- package/dist/schemas-Berf1swF.cjs.map +1 -0
- package/dist/schemas-D6xOGjqg.js +1654 -0
- package/dist/schemas-D6xOGjqg.js.map +1 -0
- package/dist/subtype-CG4WpIRj.js +129 -0
- package/dist/subtype-CG4WpIRj.js.map +1 -0
- package/dist/subtype-aDt5TFmK.cjs +158 -0
- package/dist/subtype-aDt5TFmK.cjs.map +1 -0
- package/dist/validation.cjs +578 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.d.cts +174 -0
- package/dist/validation.d.ts +174 -0
- package/dist/validation.js +571 -0
- package/dist/validation.js.map +1 -0
- package/dist/value-BFS1R8ek.cjs +435 -0
- package/dist/value-BFS1R8ek.cjs.map +1 -0
- package/dist/value-Dhc8eYcx.js +340 -0
- package/dist/value-Dhc8eYcx.js.map +1 -0
- package/dist/viewport-BJW13EGZ.js +540 -0
- package/dist/viewport-BJW13EGZ.js.map +1 -0
- package/dist/viewport-DlL5Bxbg.cjs +671 -0
- package/dist/viewport-DlL5Bxbg.cjs.map +1 -0
- package/dist/wire.cjs +1056 -379
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +15069 -725
- package/dist/wire.d.ts +15069 -725
- package/dist/wire.js +825 -239
- package/dist/wire.js.map +1 -1
- package/package.json +10 -1
- package/dist/AbortError-Cq2igpZ6.cjs +0 -38
- package/dist/AbortError-Cq2igpZ6.cjs.map +0 -1
- package/dist/AbortError-DHqPBnYc.js +0 -27
- package/dist/AbortError-DHqPBnYc.js.map +0 -1
- package/dist/AnnotationListSnapshot-D3mFut1e.d.cts +0 -6871
- package/dist/AnnotationListSnapshot-D3mFut1e.d.ts +0 -6871
- package/dist/Engine-Bx0NOfmd.d.cts +0 -1264
- package/dist/Engine-DxtpCYcP.d.ts +0 -1264
- package/dist/PageInsertBlankInput-CqXBmFhN.cjs +0 -449
- package/dist/PageInsertBlankInput-CqXBmFhN.cjs.map +0 -1
- package/dist/PageInsertBlankInput-cHq9-i-z.js +0 -378
- package/dist/PageInsertBlankInput-cHq9-i-z.js.map +0 -1
- package/dist/builders-Bqm8yTpi.cjs +0 -3564
- package/dist/builders-Bqm8yTpi.cjs.map +0 -1
- package/dist/builders-Dqo2X-dt.js +0 -3121
- package/dist/builders-Dqo2X-dt.js.map +0 -1
- package/dist/fold-2V29cxCV.cjs +0 -447
- package/dist/fold-2V29cxCV.cjs.map +0 -1
- package/dist/fold-CdEJTBTn.js +0 -334
- package/dist/fold-CdEJTBTn.js.map +0 -1
- package/dist/resolver-CYVNV4hn.cjs.map +0 -1
- package/dist/resolver-inAVzsWt.js.map +0 -1
- package/dist/schemas-BLARNCgx.js +0 -3113
- package/dist/schemas-BLARNCgx.js.map +0 -1
- package/dist/schemas-DIqFMmrC.cjs +0 -4468
- package/dist/schemas-DIqFMmrC.cjs.map +0 -1
|
@@ -0,0 +1,1565 @@
|
|
|
1
|
+
import { $c as FormMutationMeta, $f as DownloadOptions, $h as SignatureCompleteResult, $l as PageFlattenResult, $n as PageDeleteResult, Aa as FormFieldValue, Bh as BaseVersionInfo, Bl as AnnotationImportResult, Bu as AttachmentContent, Dl as WidgetPatch, Gl as FormFieldCreateOptions, Gn as RedactionApplyResult, Gu as AttachmentRef, Hl as AnnotationCreateOptions, Ho as SearchSlice, I_ as DocumentActionsSnapshot, Jf as FontHandle, Jl as WriteOptions, Jm as CustomMetadata, Kl as FormWidgetAddOptions, Kn as RedactionApplyScope, Ko as TextLayout, Mc as AttachmentDeleteResult, Md as AnnotationResourceRole, Mi as FormSubmissionReceipt, Ng as PageBox, Np as TextRange, P_ as AbortablePromise, Pa as FormFieldPatch, Pi as FormSubmissionRequest, Qc as FormFieldUpdateResult, Qh as SignatureCompleteInput, Qn as PageInsertResult, Qp as PageRenderImage, Rc as FormImportOptions, Sa as CustomMetadataUpdateResult, To as WidgetPlacement, Uc as FormValuesImportOptions, Ul as AnnotationUpdateOptions, Up as PageImageOptions, Uu as AttachmentFileSource, Vh as DigestAlgorithm, Vm as PageListSnapshot, Vo as SearchRequest, Wc as FormValuesImportResult, Wl as FlattenWriteOptions, Wu as AttachmentList, Xc as FormFieldCreateResult, Xf as FontKey, Xh as SignatureAppearanceInput, Xm as OpenInput, Yc as FormCalculationsReorderResult, Yg as PdfRotation, Ym as MetadataPatch, Zc as FormFieldDeleteResult, Zf as FontSpec, Zg as FormFieldRef, Zh as SignatureCancelResult, Zi as Change, Zn as PageInsertBlankSpec, _a as PagePosition, _g as FormFieldDTO, _v as DocumentMetadata, ah as OpenOptions, al as FormWidgetRestoreResult, ap as AnnotationAppearanceImageOptions, au as AnnotationUpdateResult, bs as AnnotationDraft, bv as IsoDateTime, cg as SignatureSnapshot, cl as FormWidgetsReorderResult, cr as PageNameInput, dp as AnnotationAppearancesResult, ef as ObjectNumberPool, el as FormRepairResult, em as PageRenderOptions, fg as MutationMeta, fl as FormExportSelection, gl as FormSnapshot, gu as AnnotationExportSelection, ha as FieldPosition, hd as PdfMeasure, hi as ChangeAnalysis, hn as PageScaleResult, hu as AnnotationListMutationMeta, ig as SignaturePrepared, il as FormWidgetLinkResult, im as PageRenderViewport, iu as AnnotationReorderResult, jc as AttachmentCreateResult, lp as AnnotationAppearanceRenderOptions, lr as PageRemoveNameInput, ma as AnnotationPosition, n as AnnotationListOptions, na as ChangeResult, nl as FormSetValueResult, nm as PageRenderRaster, nu as AnnotationCreateResult, o_ as AnnotationRef, op as AnnotationAppearanceImagesResult, or as AnnotationFlattenResult, pa as MetadataUpdateResult, pd as PageMeasurementViewportList, pi as AnalyzeInput, ql as PageInsertBlankOptions, qm as CustomMetadataPatch, rg as SignaturePrepareInput, rl as FormWidgetDeleteResult, ru as AnnotationDeleteResult, sl as FormWidgetUpdateResult, sr as PageNameResult, t as AnnotationList, tl as FormResetResult, tr as PageRotateResult, tu as PageFlattenUsage, ur as PageReorderResult, uv as PageRef, vl as FormBundle, vo as FormFieldDraft, vs as Annotation, vu as AnnotationBundle, wl as WidgetAnnotation, wp as PageTextSnapshot, xs as AnnotationPatch, zc as FormImportResult, zl as AnnotationImportOptions } from "./AnnotationList-CkijRHet.cjs";
|
|
2
|
+
import { c as DocumentSecurityService } from "./DocumentSecurityService-e6vp2de8.cjs";
|
|
3
|
+
//#region src/engine/DocumentActionsService.d.ts
|
|
4
|
+
/** Lazy, catalog-owned PDF action read. This API extracts; it never executes. */
|
|
5
|
+
interface DocumentActionsService {
|
|
6
|
+
get(): AbortablePromise<DocumentActionsSnapshot>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/engine/DocumentAnnotationsService.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Document-scoped annotation service exposed via
|
|
12
|
+
* `DocumentHandle.annotations`.
|
|
13
|
+
*/
|
|
14
|
+
interface DocumentAnnotationsService {
|
|
15
|
+
/**
|
|
16
|
+
* The annotations of the given pages, or of every page. A raw read: no
|
|
17
|
+
* page is loaded, so listing a whole document is cheap. Returns what
|
|
18
|
+
* `page.annotations.list()` returns for each page.
|
|
19
|
+
*/
|
|
20
|
+
list(options?: AnnotationListOptions): AbortablePromise<AnnotationList>;
|
|
21
|
+
/**
|
|
22
|
+
* Take annotations out of the document, with the bytes beside them, as one
|
|
23
|
+
* bundle: every annotation, or the selection with what it points at and,
|
|
24
|
+
* by default, its threads (see {@link AnnotationExportSelection}). One
|
|
25
|
+
* drawing is one resource however many stamps place it. Refused with
|
|
26
|
+
* `PayloadTooLarge`, naming the limit, when the bundle would pass one of
|
|
27
|
+
* the import limits, and with `NotFound` for a selected page or
|
|
28
|
+
* annotation the document doesn't have. Needs `doc.annotate.read` and
|
|
29
|
+
* `doc.download`.
|
|
30
|
+
*/
|
|
31
|
+
export(selection?: AnnotationExportSelection): AbortablePromise<AnnotationBundle>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a bundle's annotations in this document, as one change: every
|
|
34
|
+
* item is checked, its pages mapped and what can't be carried left out
|
|
35
|
+
* (`dropped`) before the first write, and a failure while writing leaves
|
|
36
|
+
* the document as it was. `reply.to` and a popup's `parent` link to the
|
|
37
|
+
* items they name in the bundle. Emits one `annotations.created` per
|
|
38
|
+
* annotation, sharing `origin.tx`. Needs `doc.annotate.modify`; the
|
|
39
|
+
* default `attribution: 'restore'` also needs `doc.annotate.import`.
|
|
40
|
+
*/
|
|
41
|
+
import(bundle: AnnotationBundle, options?: AnnotationImportOptions): AbortablePromise<AnnotationImportResult>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/engine/DocumentAttachmentsService.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* Document-level attachments: the catalog's `/EmbeddedFiles` name tree
|
|
47
|
+
* (ISO 32000 §7.11.4). Exposed via `DocumentHandle.attachments`.
|
|
48
|
+
*
|
|
49
|
+
* Addressing is by name-tree key (`AttachmentRef`), unique by
|
|
50
|
+
* construction (see the ref's doc comment). `list()` returns metadata only;
|
|
51
|
+
* bytes leave the engine exclusively through {@link download}. The
|
|
52
|
+
* annotation-level counterpart is
|
|
53
|
+
* `PageAnnotationsService.downloadResource(ref, 'file')`.
|
|
54
|
+
*/
|
|
55
|
+
interface DocumentAttachmentsService {
|
|
56
|
+
/** Snapshot of the `/EmbeddedFiles` name tree, in tree (key-sorted) order. */
|
|
57
|
+
list(): AbortablePromise<AttachmentList>;
|
|
58
|
+
/**
|
|
59
|
+
* Decode and return one embedded file's bytes plus the metadata needed
|
|
60
|
+
* to hand it to a user (name, mime type). Throws
|
|
61
|
+
* `EngineError(NotFound)` when no entry has the ref's key and
|
|
62
|
+
* `EngineError(InvalidArg)` when the entry has no embedded file stream.
|
|
63
|
+
*/
|
|
64
|
+
download(ref: AttachmentRef): AbortablePromise<AttachmentContent>;
|
|
65
|
+
/**
|
|
66
|
+
* Create an embedded file in the name tree. The file's `name` becomes
|
|
67
|
+
* the tree key (`/UF` = `/F` = key); a duplicate key rejects with
|
|
68
|
+
* `EngineError(InvalidArg)` — rename and retry. A mutation: layer
|
|
69
|
+
* sessions persist an artifact and an `attachments.created` event is
|
|
70
|
+
* published. Note the tree is key-sorted, so other entries' indices
|
|
71
|
+
* may shift; keys never move.
|
|
72
|
+
*/
|
|
73
|
+
create(file: AttachmentFileSource, options?: WriteOptions): AbortablePromise<AttachmentCreateResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Delete an embedded file from the name tree. Unlinks the entry only —
|
|
76
|
+
* the stream bytes remain in the document until a full rewrite (the
|
|
77
|
+
* immutable-base/layer model). Throws `EngineError(NotFound)` for an
|
|
78
|
+
* unknown key. A mutation: layer sessions persist an artifact and an
|
|
79
|
+
* `attachments.deleted` event is published.
|
|
80
|
+
*/
|
|
81
|
+
delete(ref: AttachmentRef, options?: WriteOptions): AbortablePromise<AttachmentDeleteResult>;
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/engine/DocumentFormsService.d.ts
|
|
85
|
+
/** Options for {@link DocumentFormsService.repair}. */
|
|
86
|
+
interface FormRepairOptions extends WriteOptions {
|
|
87
|
+
/**
|
|
88
|
+
* Also regenerate widget appearance streams: widgets with no /AP get
|
|
89
|
+
* one, and when the /AcroForm sets /NeedAppearances every widget is
|
|
90
|
+
* re-baked and the flag cleared, making rendering deterministic across
|
|
91
|
+
* viewers.
|
|
92
|
+
*/
|
|
93
|
+
bakeAppearances?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The document's interactive form: a document-scoped record system where
|
|
97
|
+
* fields hold the values and widget annotations are their page-scoped
|
|
98
|
+
* views. A form field's widgets come with the form, never with the
|
|
99
|
+
* annotations: `list()` holds the fields and every widget's row, and widget
|
|
100
|
+
* writes are form writes.
|
|
101
|
+
*
|
|
102
|
+
* Reads are gated by `doc.forms.read`, value writes and imports by
|
|
103
|
+
* `doc.forms.fill`, and repair by `doc.forms.modify`. On layer documents
|
|
104
|
+
* every write lands as a minimal delta over the shared immutable base — a
|
|
105
|
+
* filled form layer is semantically an FDF diff.
|
|
106
|
+
*/
|
|
107
|
+
interface DocumentFormsService {
|
|
108
|
+
/**
|
|
109
|
+
* The complete reconciled form state: every terminal field with its
|
|
110
|
+
* effective value and options, and every widget with its place, look and
|
|
111
|
+
* state. Fields broken producers left out of /AcroForm /Fields are
|
|
112
|
+
* included with `origin: 'recovered'`.
|
|
113
|
+
*/
|
|
114
|
+
list(): AbortablePromise<FormSnapshot>;
|
|
115
|
+
/**
|
|
116
|
+
* One field by ref. Prefer `objectNumber` refs (durable); `fqn` refs
|
|
117
|
+
* resolve against the current field tree. Fails with `NotFound` when
|
|
118
|
+
* the ref matches nothing.
|
|
119
|
+
*/
|
|
120
|
+
get(ref: FormFieldRef): AbortablePromise<FormFieldDTO>;
|
|
121
|
+
/**
|
|
122
|
+
* Write one field's value, in the fields a read of it returns (see
|
|
123
|
+
* {@link FormFieldValue}). Validation happens before any write — a failed
|
|
124
|
+
* call leaves the document untouched. Appearance streams regenerate for
|
|
125
|
+
* text/choice widgets; toggles flip their appearance state. Emits
|
|
126
|
+
* `forms.valueSet`.
|
|
127
|
+
*/
|
|
128
|
+
setValue(ref: FormFieldRef, value: FormFieldValue, options?: WriteOptions): AbortablePromise<FormSetValueResult>;
|
|
129
|
+
/**
|
|
130
|
+
* Put fields back to their default value (/DV), or empty them when they
|
|
131
|
+
* have none: the whole form without an argument, else the fields named.
|
|
132
|
+
* Fields that hold no value (push buttons, signature fields) are skipped,
|
|
133
|
+
* and so, in a whole-form reset, are fields a signature locked; naming a
|
|
134
|
+
* locked field fails with `ProtectedDocument`. The result lists the
|
|
135
|
+
* fields that changed. Emits one `forms.valueSet` per changed field,
|
|
136
|
+
* sharing `origin.tx`.
|
|
137
|
+
*/
|
|
138
|
+
reset(fields?: FormFieldRef | FormFieldRef[], options?: WriteOptions): AbortablePromise<FormResetResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Deliver a resolved form submission to the document's home. Present only
|
|
141
|
+
* where the document has a home that accepts submissions — the cloud
|
|
142
|
+
* engine when the deployment advertises the capability; the local engine
|
|
143
|
+
* truthfully lacks it (an in-process document has no home, and this
|
|
144
|
+
* contract is never a callback trampoline). Gated by `doc.forms.submit`
|
|
145
|
+
* (grant-minted; no PDF permission bit exists for submission), asserted
|
|
146
|
+
* at the home's boundary where enforcement is real. The home stores the
|
|
147
|
+
* dataset with the declared intent as metadata and derives who submitted
|
|
148
|
+
* from its own verified session — it never fetches the PDF's URL.
|
|
149
|
+
*/
|
|
150
|
+
submit?(request: FormSubmissionRequest): AbortablePromise<FormSubmissionReceipt>;
|
|
151
|
+
/**
|
|
152
|
+
* The fields `selection` takes, each whole with all of its widgets, their
|
|
153
|
+
* values and who made and filled them, as one bundle (every field without
|
|
154
|
+
* a selection). A field the form doesn't export comes without its value,
|
|
155
|
+
* a signature field without its signature. Needs `doc.forms.read` and
|
|
156
|
+
* `doc.download`.
|
|
157
|
+
*/
|
|
158
|
+
export(selection?: FormExportSelection): AbortablePromise<FormBundle>;
|
|
159
|
+
/**
|
|
160
|
+
* Copy a bundle's design into this document: its fields, their widgets,
|
|
161
|
+
* scripts and actions, values (`options.values`), and their place in the
|
|
162
|
+
* calculation order, created as one change, all or nothing. A field whose
|
|
163
|
+
* name is taken, and what can't be carried, is left out and reported in
|
|
164
|
+
* `dropped`. Needs `doc.forms.modify`; `doc.forms.import` to restore who
|
|
165
|
+
* made and filled the fields (the default); `doc.forms.script` to keep
|
|
166
|
+
* scripts, submits and links. Emits one `forms.created` per field.
|
|
167
|
+
*/
|
|
168
|
+
import(bundle: FormBundle, options?: FormImportOptions): AbortablePromise<FormImportResult>;
|
|
169
|
+
/**
|
|
170
|
+
* Fill this document's fields from a bundle, by full name, as one change.
|
|
171
|
+
* A field the document doesn't have, of another family, that can't take
|
|
172
|
+
* the value or that a signature locked is left out and reported. Runs no
|
|
173
|
+
* scripts. Needs `doc.forms.fill`; `doc.forms.import` to restore who
|
|
174
|
+
* filled the fields (the default). Emits one `forms.valueSet` per field.
|
|
175
|
+
*/
|
|
176
|
+
importValues(bundle: FormBundle, options?: FormValuesImportOptions): AbortablePromise<FormValuesImportResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Create a logical form field, optionally with styled widgets, in one
|
|
179
|
+
* atomic job. Widgets are born through the annotation plane and adopted
|
|
180
|
+
* (see {@link addWidget}); the inline `widget(s)` config is sugar for
|
|
181
|
+
* exactly that composition. Gated by `doc.forms.modify`. Emits
|
|
182
|
+
* `forms.created`.
|
|
183
|
+
*
|
|
184
|
+
* `options.objectNumber` names the field and `options.widgetObjectNumbers`
|
|
185
|
+
* its widgets (in `draft.widgets` order), all taken from
|
|
186
|
+
* `doc.objectNumbers`, so their refs are known before the engine answers.
|
|
187
|
+
* Parent fields created on the way get the next free numbers. A number
|
|
188
|
+
* this session doesn't hold, or one an object already has, is refused
|
|
189
|
+
* with `ObjectNumberUnavailable`.
|
|
190
|
+
*/
|
|
191
|
+
create(draft: FormFieldDraft, options?: FormFieldCreateOptions): AbortablePromise<FormFieldCreateResult>;
|
|
192
|
+
/**
|
|
193
|
+
* Update field-plane properties (name, universal and family flags,
|
|
194
|
+
* options, default value, names). The patch's `family` must match the
|
|
195
|
+
* target field. Validate-then-apply per property. Emits
|
|
196
|
+
* `forms.updated`.
|
|
197
|
+
*/
|
|
198
|
+
update(ref: FormFieldRef, patch: FormFieldPatch, options?: WriteOptions): AbortablePromise<FormFieldUpdateResult>;
|
|
199
|
+
/**
|
|
200
|
+
* Draw a PDF page into every widget of an unsigned signature field — the
|
|
201
|
+
* visual "sign" of a viewer that has no signer. The field's value stays
|
|
202
|
+
* empty and nothing is sealed; a signed field is refused. Gated by
|
|
203
|
+
* `doc.forms.fill`. Emits `forms.updated`.
|
|
204
|
+
*/
|
|
205
|
+
setSignatureAppearance(ref: FormFieldRef, appearance: SignatureAppearanceInput, options?: WriteOptions): AbortablePromise<FormFieldUpdateResult>;
|
|
206
|
+
/**
|
|
207
|
+
* Delete a terminal field and cascade: every widget is removed from its
|
|
208
|
+
* page, the field leaves the tree, and empty ancestors are pruned.
|
|
209
|
+
* Emits `forms.deleted`.
|
|
210
|
+
*/
|
|
211
|
+
delete(ref: FormFieldRef, options?: WriteOptions): AbortablePromise<FormFieldDeleteResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Show the field in one more place: a new widget, placed and styled like
|
|
214
|
+
* an entry of a draft's `widgets`, in one change. A radio button needs
|
|
215
|
+
* its `exportValue`. Adding a widget to a legacy merged field splits it:
|
|
216
|
+
* the field keeps its object number and its widget moves to a new one
|
|
217
|
+
* (`options.splitObjectNumber`, or the next free one). Emits
|
|
218
|
+
* `forms.widgetAdded`.
|
|
219
|
+
*
|
|
220
|
+
* `options.objectNumber` names the new widget, taken from
|
|
221
|
+
* `doc.objectNumbers` like `splitObjectNumber`. A number this session
|
|
222
|
+
* doesn't hold, or one an object already has, is refused with
|
|
223
|
+
* `ObjectNumberUnavailable`.
|
|
224
|
+
*/
|
|
225
|
+
addWidget(ref: FormFieldRef, placement: WidgetPlacement, options?: FormWidgetAddOptions): AbortablePromise<FormWidgetLinkResult>;
|
|
226
|
+
/**
|
|
227
|
+
* Take a widget out of its field: it keeps its page placement and last
|
|
228
|
+
* appearance but belongs to no field any more (its `field` is `null`;
|
|
229
|
+
* `deleteWidget` takes it off the page). The field survives, "unplaced"
|
|
230
|
+
* when this was its last widget. Emits `forms.widgetRemoved`.
|
|
231
|
+
*/
|
|
232
|
+
removeWidget(ref: FormFieldRef, widget: AnnotationRef, options?: WriteOptions): AbortablePromise<FormWidgetLinkResult>;
|
|
233
|
+
/**
|
|
234
|
+
* Delete a widget: it leaves its page, and its field when it has one. The
|
|
235
|
+
* field survives, "unplaced" when this was its last widget. A widget that
|
|
236
|
+
* is its field's own dictionary (a merged field/widget) is refused with
|
|
237
|
+
* `InvalidArg`: delete the field with `delete`. A widget is the form's, so
|
|
238
|
+
* `annotations.delete` refuses one. Gated by `doc.forms.modify`. Emits
|
|
239
|
+
* `forms.widgetDeleted`.
|
|
240
|
+
*/
|
|
241
|
+
deleteWidget(widget: AnnotationRef, options?: WriteOptions): AbortablePromise<FormWidgetDeleteResult>;
|
|
242
|
+
/**
|
|
243
|
+
* Change a widget's place and look: what `annotations.update` takes for a
|
|
244
|
+
* widget (rect, colors, border, font, alignment, flags). A widget is the
|
|
245
|
+
* form's, so `annotations.update` refuses one. Gated by
|
|
246
|
+
* `doc.forms.modify`. Emits `forms.widgetUpdated`.
|
|
247
|
+
*/
|
|
248
|
+
updateWidget(widget: AnnotationRef, patch: WidgetPatch, options?: WriteOptions): AbortablePromise<FormWidgetUpdateResult>;
|
|
249
|
+
/**
|
|
250
|
+
* Change the widgets' stacking order on their page: they go together, in
|
|
251
|
+
* the order given, to `position` among the page's widgets, next to a
|
|
252
|
+
* neighbour widget or at `'start'` (bottom) / `'end'` (top). Widgets paint
|
|
253
|
+
* above every annotation, so only widgets are named here; an annotation is
|
|
254
|
+
* refused with `InvalidArg` (`page.annotations.reorder()` orders those).
|
|
255
|
+
* Where a page's `/Tabs` is `/A` or `/W`, this is also the fields' tab
|
|
256
|
+
* order. Gated by `doc.forms.modify`. Emits `forms.widgetsReordered`.
|
|
257
|
+
*/
|
|
258
|
+
reorderWidgets(widgets: AnnotationRef[], position: AnnotationPosition, options?: WriteOptions): AbortablePromise<FormWidgetsReorderResult>;
|
|
259
|
+
/**
|
|
260
|
+
* Change the form's calculation order (`/AcroForm /CO`), the order the
|
|
261
|
+
* fields' calculate scripts run in: the fields go together, in the order
|
|
262
|
+
* given, to `position`, next to a neighbour or at `'start'` / `'end'`.
|
|
263
|
+
* Every field named must be in the order already: a `calculate` script
|
|
264
|
+
* puts a field in it (`create`, `update`). `doc.forms.list()` reads the
|
|
265
|
+
* order as `calculationOrder`. Gated by `doc.forms.modify`. Emits
|
|
266
|
+
* `forms.calculationsReordered`.
|
|
267
|
+
*/
|
|
268
|
+
reorderCalculations(fields: FormFieldRef[], position: FieldPosition, options?: WriteOptions): AbortablePromise<FormCalculationsReorderResult>;
|
|
269
|
+
/**
|
|
270
|
+
* Make the engine's read-time reconciliation durable in the document
|
|
271
|
+
* ("form doctor"): bootstrap a missing /AcroForm, link recovered field
|
|
272
|
+
* roots into /Fields, re-attach stray widgets to their parent's /Kids,
|
|
273
|
+
* and optionally bake appearances. Validate-then-apply and idempotent —
|
|
274
|
+
* a second call reports zero fixes. Emits `forms.repaired`.
|
|
275
|
+
*/
|
|
276
|
+
repair(options?: FormRepairOptions): AbortablePromise<FormRepairResult>;
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/engine/DocumentPagesService.d.ts
|
|
280
|
+
/**
|
|
281
|
+
* Document-scoped page service exposed via `DocumentHandle.pages`.
|
|
282
|
+
*
|
|
283
|
+
* Mirrors the shape of `DocumentAnnotationsService` so that anything
|
|
284
|
+
* touching "many things at the document level" lives in one place: the
|
|
285
|
+
* structure verbs (`reorder`, `rotate`, `delete`, `insert`, `insertBlank`),
|
|
286
|
+
* `extract`, `flatten` and the page names.
|
|
287
|
+
*
|
|
288
|
+
* Identity rule: pages are addressed by `PageRef` (the durable object
|
|
289
|
+
* number) everywhere except `list()`, which exposes display order through
|
|
290
|
+
* `PageLayout.index`. Structure verbs never change the names of the
|
|
291
|
+
* annotations on surviving pages.
|
|
292
|
+
*/
|
|
293
|
+
interface DocumentPagesService {
|
|
294
|
+
/**
|
|
295
|
+
* Snapshot of every page in display order. Cheap; never acquires a
|
|
296
|
+
* `pagePtr`.
|
|
297
|
+
*/
|
|
298
|
+
list(): AbortablePromise<PageListSnapshot>;
|
|
299
|
+
/**
|
|
300
|
+
* Reorder pages: they go together, in the order given, to `position`,
|
|
301
|
+
* next to a neighbour (`{ before: page }`, `{ after: page }`) or at
|
|
302
|
+
* `'start'` / `'end'`. Annotation refs the caller is holding stay valid
|
|
303
|
+
* across a page reorder. A neighbour that isn't in the document is
|
|
304
|
+
* `NotFound`; one of the pages that move is `InvalidArg`. Emits
|
|
305
|
+
* `pages.reordered`.
|
|
306
|
+
*/
|
|
307
|
+
reorder(pages: PageRef[], position: PagePosition, options?: WriteOptions): AbortablePromise<PageReorderResult>;
|
|
308
|
+
/**
|
|
309
|
+
* Set the absolute display rotation of the supplied pages (one value
|
|
310
|
+
* for all — the multi-select thumbnail gesture). Pure presentation
|
|
311
|
+
* metadata: content coordinates are normalized, so cached renders and
|
|
312
|
+
* annotation refs survive untouched. See
|
|
313
|
+
* `PageRotateInput` for why the wire is absolute, never relative.
|
|
314
|
+
*/
|
|
315
|
+
rotate(pages: PageRef[], rotation: PdfRotation, options?: WriteOptions): AbortablePromise<PageRotateResult>;
|
|
316
|
+
/**
|
|
317
|
+
* Delete pages. Deleting every page is rejected (`InvalidArg`) — a
|
|
318
|
+
* document must keep at least one. Deleted page object numbers are retired, never
|
|
319
|
+
* recycled; surviving pages keep their identity and revisions.
|
|
320
|
+
*/
|
|
321
|
+
delete(pages: PageRef[], options?: WriteOptions): AbortablePromise<PageDeleteResult>;
|
|
322
|
+
/**
|
|
323
|
+
* Register `name` → page in the catalog's `/Names /Pages` tree (create,
|
|
324
|
+
* or replace what an existing key points at); with `replace`, drop that
|
|
325
|
+
* other key in the same job (rename). Named pages are layout — read them
|
|
326
|
+
* back from `list().namedPages` — so this is a page-structure mutation:
|
|
327
|
+
* `docVersion` + `layoutVersion` advance, per-page pins do not. Gated like
|
|
328
|
+
* `reorder` (`doc.pages.assemble`).
|
|
329
|
+
*
|
|
330
|
+
* Rejects with `InvalidArg` for an empty name and `NotFound` for a page
|
|
331
|
+
* that is not in the page tree (hidden templates included).
|
|
332
|
+
*/
|
|
333
|
+
setName(input: PageNameInput, options?: WriteOptions): AbortablePromise<PageNameResult>;
|
|
334
|
+
/**
|
|
335
|
+
* Remove one `/Names /Pages` registration; the page itself is untouched.
|
|
336
|
+
* `NotFound` when no registration has that decoded key. Page deletion
|
|
337
|
+
* removes registrations by itself — callers never need to pair the two.
|
|
338
|
+
*/
|
|
339
|
+
removeName(input: PageRemoveNameInput, options?: WriteOptions): AbortablePromise<PageNameResult>;
|
|
340
|
+
/**
|
|
341
|
+
* Paint eligible annotation appearances into page content and remove only
|
|
342
|
+
* those annotations that were painted. This changes content and annotation
|
|
343
|
+
* liveness, not layout. The default usage is normal display.
|
|
344
|
+
*/
|
|
345
|
+
flatten(pages: PageRef[], options?: FlattenWriteOptions): AbortablePromise<PageFlattenResult>;
|
|
346
|
+
/**
|
|
347
|
+
* Export the given pages, in the supplied order, as a standalone PDF
|
|
348
|
+
* (bytes of a new document containing copies of those pages). A read:
|
|
349
|
+
* the source document is untouched — no revisions bump, no event is
|
|
350
|
+
* published. This is how a page becomes a portable asset (a vector
|
|
351
|
+
* stamp, a signature) that re-enters a document as a stamp's `appearance`
|
|
352
|
+
* resource. Gated by `doc.download` (it egresses content), not
|
|
353
|
+
* `doc.pages.assemble`.
|
|
354
|
+
*
|
|
355
|
+
* Required-parity, delivered: the local engine runs it in the worker,
|
|
356
|
+
* the cloud engine as POST /pages/extract.
|
|
357
|
+
*/
|
|
358
|
+
extract(pages: PageRef[]): AbortablePromise<Uint8Array>;
|
|
359
|
+
/**
|
|
360
|
+
* Insert every page of a standalone PDF (`bytes`) at `position`
|
|
361
|
+
* (default `'end'`). The pages are copied in; the inserted copies get
|
|
362
|
+
* fresh object numbers, returned in insertion order. Bytes are a call
|
|
363
|
+
* argument (the same law as annotation binaries): the local engine
|
|
364
|
+
* transfers them to its worker, the cloud engine ships them as a
|
|
365
|
+
* multipart mutation (POST /pages/insert).
|
|
366
|
+
*
|
|
367
|
+
* Required-parity, delivered — a cloud viewer must be able to add pages,
|
|
368
|
+
* so this is a mandatory member: any engine implements it or is not a
|
|
369
|
+
* conforming engine.
|
|
370
|
+
*/
|
|
371
|
+
insert(bytes: Uint8Array | ArrayBuffer, position?: PagePosition, options?: WriteOptions): AbortablePromise<PageInsertResult>;
|
|
372
|
+
/**
|
|
373
|
+
* Create `spec.count` (default 1) blank pages of `spec.size` (PDF points)
|
|
374
|
+
* at `position` (default `'end'`). The blank-page sibling of `insert`:
|
|
375
|
+
* same gate (`doc.pages.assemble`), same result shape, same
|
|
376
|
+
* `pages.inserted` event — it is a separate verb because its wire is pure
|
|
377
|
+
* parameters where `insert`'s is a binary payload (cloud: JSON
|
|
378
|
+
* POST /pages/insert-blank). Every pre-existing page keeps its identity.
|
|
379
|
+
* Mandatory, like `insert`.
|
|
380
|
+
*
|
|
381
|
+
* `options.objectNumbers` names the new pages, one number per page in
|
|
382
|
+
* order, taken from `doc.objectNumbers`: their refs are known before the
|
|
383
|
+
* engine answers, so they can be annotated at once. Without them the
|
|
384
|
+
* engine picks the next free numbers. A number this session doesn't hold,
|
|
385
|
+
* or one an object already has, is refused with `ObjectNumberUnavailable`.
|
|
386
|
+
*/
|
|
387
|
+
insertBlank(spec: PageInsertBlankSpec, position?: PagePosition, options?: PageInsertBlankOptions): AbortablePromise<PageInsertResult>;
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/engine/DocumentRedactionService.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* The destructive half of the two-stage redaction model (ISO 32000-2
|
|
393
|
+
* 12.5.6.23). Marking is annotation-plane work: a `redact` annotation rides
|
|
394
|
+
* the normal create/update/delete verbs and destroys nothing. Applying —
|
|
395
|
+
* this service — permanently removes the content under each marked region,
|
|
396
|
+
* paints the configured overlay in its place, and removes the consumed
|
|
397
|
+
* redact annotations along with any annotation intersecting the region.
|
|
398
|
+
*
|
|
399
|
+
* Trust boundary (deliberate, documented): on a layered document, apply
|
|
400
|
+
* rewrites this layer's bytes only. The immutable base document still
|
|
401
|
+
* contains the original content — byte-perfect original recovery is a
|
|
402
|
+
* feature of the storage model, not a leak. Redacted content becomes truly
|
|
403
|
+
* unrecoverable only in a full-rewrite export after apply. Callers must select
|
|
404
|
+
* `download({ mode: 'rewrite' })` (or the corresponding file/cloud save mode)
|
|
405
|
+
* before sharing the redacted PDF. The default incremental download preserves
|
|
406
|
+
* the original content in prior revisions; apply does not change that default.
|
|
407
|
+
* Surfaces that promise "permanent removal" must scope that promise to the
|
|
408
|
+
* full-rewrite exported artifact.
|
|
409
|
+
*
|
|
410
|
+
* Applying is irreversible within the layer (no undo). Emits a
|
|
411
|
+
* `redaction.applied` document event; content-scope raster invalidation and
|
|
412
|
+
* search-corpus refresh ride the normal content-version machinery.
|
|
413
|
+
*/
|
|
414
|
+
interface DocumentRedactionService {
|
|
415
|
+
/**
|
|
416
|
+
* Apply redactions in `scope`. Ordered batch verb: pages are processed
|
|
417
|
+
* independently and a failed page is recorded in its item result rather
|
|
418
|
+
* than throwing after the first native write; `unchanged` means the page
|
|
419
|
+
* had no matching redact annotation. Returns no `meta` only when nothing
|
|
420
|
+
* changed.
|
|
421
|
+
*/
|
|
422
|
+
apply(scope: RedactionApplyScope, options?: WriteOptions): AbortablePromise<RedactionApplyResult>;
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/engine/DocumentRenderService.d.ts
|
|
426
|
+
/**
|
|
427
|
+
* The engine's render-parameter policy.
|
|
428
|
+
*
|
|
429
|
+
* - `continuous` — any viewport renders exactly as requested. The local
|
|
430
|
+
* engine always answers this: rendering is in-process, there is no
|
|
431
|
+
* shared cache to protect, and exactness is the local product promise.
|
|
432
|
+
* - `lattice` — the deployment treats a finite set of render points as
|
|
433
|
+
* durable, CDN-shared artifacts. The bounded quantity
|
|
434
|
+
* is output pixels, never zoom:
|
|
435
|
+
*
|
|
436
|
+
* - `fullPage.widths` — full-page renders quantize on `viewport.width`
|
|
437
|
+
* (a scale lattice bounds artifact count but not size: PDF page space
|
|
438
|
+
* is effectively unbounded, so scale 1 of a poster page is a memory
|
|
439
|
+
* bomb while width caps the dominant dimension by construction).
|
|
440
|
+
* - `tiles` — reserved for the deep-zoom vertical: a scale-based
|
|
441
|
+
* pyramid × fixed tile size, where per-job cost is constant. Absent
|
|
442
|
+
* until the tiling plugin ships; reserving the shape keeps the SDK
|
|
443
|
+
* contract from churning twice.
|
|
444
|
+
* - `maxRenderPixels` — the worker-side output budget for degenerate
|
|
445
|
+
* geometry (width bounds width, not height).
|
|
446
|
+
*
|
|
447
|
+
* The SDK never conforms a request implicitly — the same `render.image`
|
|
448
|
+
* call must not return different pixels on local vs cloud. Conformance is
|
|
449
|
+
* the caller's visible choice via {@link snapFullPageViewport}.
|
|
450
|
+
*/
|
|
451
|
+
type EngineRenderPolicy = {
|
|
452
|
+
readonly kind: 'continuous';
|
|
453
|
+
} | {
|
|
454
|
+
readonly kind: 'lattice';
|
|
455
|
+
readonly fullPage: {
|
|
456
|
+
readonly widths: readonly number[];
|
|
457
|
+
};
|
|
458
|
+
readonly tiles?: {
|
|
459
|
+
readonly tileSizes: readonly number[];
|
|
460
|
+
readonly scales: readonly number[];
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Annotation-appearance lattice — scale-based, unlike full pages:
|
|
464
|
+
* an appearance is sized by `annotation.rect × scale`, rects span
|
|
465
|
+
* orders of magnitude (a 4pt caret vs a page-sized stamp), and the
|
|
466
|
+
* composite must track the page's effective render scale or
|
|
467
|
+
* annotations sit blurry on a crisp raster. Small images → the
|
|
468
|
+
* ladder affords finer, taller steps than pages ever could.
|
|
469
|
+
*/
|
|
470
|
+
readonly appearances?: {
|
|
471
|
+
readonly scales: readonly number[];
|
|
472
|
+
};
|
|
473
|
+
readonly maxRenderPixels?: number;
|
|
474
|
+
readonly formats: readonly ('webp' | 'png')[];
|
|
475
|
+
readonly background: 'white';
|
|
476
|
+
readonly enforced: boolean;
|
|
477
|
+
};
|
|
478
|
+
declare const CONTINUOUS_RENDER_POLICY: EngineRenderPolicy;
|
|
479
|
+
/**
|
|
480
|
+
* Document-scoped render policy surface (`doc.render`). Async because the
|
|
481
|
+
* cloud engine learns its policy from `/v1/access`; the local engine
|
|
482
|
+
* resolves immediately with `continuous`.
|
|
483
|
+
*
|
|
484
|
+
* Per-page rendering itself stays on `page(pon).render` — this service
|
|
485
|
+
* carries policy, not pixels.
|
|
486
|
+
*/
|
|
487
|
+
interface DocumentRenderService {
|
|
488
|
+
getPolicy(): AbortablePromise<EngineRenderPolicy>;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Conform a full-page viewport to a render policy — the one snap
|
|
492
|
+
* implementation, shared by every engine and plugin. Pure and explicit
|
|
493
|
+
* by design:
|
|
494
|
+
*
|
|
495
|
+
* - `continuous` → identity (local/cloud plugin code stays byte-identical).
|
|
496
|
+
* - `lattice` → returns a `width`-kind viewport at the smallest ladder
|
|
497
|
+
* width ≥ the requested detail (snap up: always crisp, CSS downscales
|
|
498
|
+
* for free), capped at the largest width — detail beyond the cap is the
|
|
499
|
+
* tile pyramid's job, by design.
|
|
500
|
+
* - `scale`-kind requests convert through the page's width in PDF user
|
|
501
|
+
* units — pass `opts.pageWidth` (the caller has it from the layout);
|
|
502
|
+
* omitting it for a scale viewport under a lattice policy is a
|
|
503
|
+
* programmer error and throws `InvalidArg`.
|
|
504
|
+
*/
|
|
505
|
+
declare function snapFullPageViewport(policy: EngineRenderPolicy, viewport: PageRenderViewport, opts?: {
|
|
506
|
+
pageWidth?: number;
|
|
507
|
+
}): PageRenderViewport;
|
|
508
|
+
/**
|
|
509
|
+
* Conform an annotation-appearance scale to the policy's appearance
|
|
510
|
+
* lattice. Same discipline as {@link snapFullPageViewport}: identity on
|
|
511
|
+
* continuous (and when the policy carries no appearance block), snap up,
|
|
512
|
+
* cap at the largest point. Callers derive `scale` from the page's
|
|
513
|
+
* effective render scale (`snappedWidth / pageWidth`, × devicePixelRatio
|
|
514
|
+
* as needed) so composites stay crisp against the page raster.
|
|
515
|
+
*/
|
|
516
|
+
declare function snapAppearanceScale(policy: EngineRenderPolicy, scale: number): number;
|
|
517
|
+
/**
|
|
518
|
+
* The scale an appearance render's viewport puts on the appearance lattice:
|
|
519
|
+
* a `scale` viewport's scale (1 when omitted), and `undefined` for a
|
|
520
|
+
* `width` viewport, whose scale depends on the page's size and so is never
|
|
521
|
+
* on the lattice.
|
|
522
|
+
*/
|
|
523
|
+
declare function appearanceLatticeScale(viewport: PageRenderViewport | undefined): number | undefined;
|
|
524
|
+
/**
|
|
525
|
+
* Conform a tile-pyramid scale to the policy's tile lattice — the third
|
|
526
|
+
* member of the `snap<PolicyBlock><Quantity>` family. Identity on
|
|
527
|
+
* continuous and while the deployment doesn't advertise a `tiles` block
|
|
528
|
+
* (the block is reserved until the deep-zoom vertical ships server-side;
|
|
529
|
+
* the tiling client uses its own default pyramid then — see
|
|
530
|
+
* plugin-render). Snap up, cap at the largest scale: per-tile cost is
|
|
531
|
+
* constant by construction (`tileSize²` pixels regardless of level), so
|
|
532
|
+
* the cap bounds artifact count, not memory.
|
|
533
|
+
*/
|
|
534
|
+
declare function snapTileScale(policy: EngineRenderPolicy, scale: number): number;
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/engine/DocumentSearchService.d.ts
|
|
537
|
+
/**
|
|
538
|
+
* Document-scoped text search, exposed via `DocumentHandle.search`.
|
|
539
|
+
*
|
|
540
|
+
* The contract is a client-driven cursor loop over bounded slices: each
|
|
541
|
+
* `query()` call scans at most a budgeted amount of work (pages/matches)
|
|
542
|
+
* and returns what it found plus a resume cursor. There is no job to
|
|
543
|
+
* start or cancel — a 40K-page document is searched by asking for slices
|
|
544
|
+
* until `nextCursor` is null or the user stops caring. Engines clamp the
|
|
545
|
+
* requested budget to their own ceilings, so no single call can hold a
|
|
546
|
+
* worker (or the server) for minutes.
|
|
547
|
+
*
|
|
548
|
+
* Reads are gated by `doc.text.search`; `snippets: true` also requires
|
|
549
|
+
* `doc.text.copy` — see {@link SearchRequest.snippets}. Results always
|
|
550
|
+
* reflect the current layer view: text removed by redaction in this
|
|
551
|
+
* layer is unfindable, and a cursor issued before a content mutation is
|
|
552
|
+
* rejected rather than resumed over stale pages.
|
|
553
|
+
*
|
|
554
|
+
* Matches carry canonical visual-line segments from the same layout as text
|
|
555
|
+
* selection (never per-glyph boxes) and text-page character offsets that
|
|
556
|
+
* join the selection/geometry subsystem directly.
|
|
557
|
+
*/
|
|
558
|
+
interface DocumentSearchService {
|
|
559
|
+
query(request: SearchRequest): AbortablePromise<SearchSlice>;
|
|
560
|
+
}
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/engine/DocumentSignaturesService.d.ts
|
|
563
|
+
/**
|
|
564
|
+
* Digital signatures on the document: the read side (what is signed, what
|
|
565
|
+
* it seals, what it forbids) and the two-phase signing protocol. The
|
|
566
|
+
* engine does the PDF job — candidate file, digest, sealing — and never
|
|
567
|
+
* holds a key; the CMS comes from the caller (`@embedpdf/core-signature`
|
|
568
|
+
* builds one from a raw signer, or a signing service returns it).
|
|
569
|
+
*
|
|
570
|
+
* Every read here describes the bytes the document was loaded from
|
|
571
|
+
* (for a layer document: base + the delta it was opened with). Unsaved
|
|
572
|
+
* edits are not part of any revision until `prepare` snapshots them.
|
|
573
|
+
*
|
|
574
|
+
* Reads ride `doc.forms.read`; `revisionBytes` rides `doc.download`;
|
|
575
|
+
* `prepare`/`complete`/`abort` ride `doc.sign`, a certification
|
|
576
|
+
* additionally `doc.sign.certify`.
|
|
577
|
+
*/
|
|
578
|
+
interface DocumentSignaturesService {
|
|
579
|
+
/** Revisions, every signature field with its signed state, and the protection in force. */
|
|
580
|
+
list(): AbortablePromise<SignatureSnapshot>;
|
|
581
|
+
/** The DER `/Contents` of a signed field (exactly `contentsSize` bytes, padding stripped). `NotFound` for an unsigned field. */
|
|
582
|
+
getContents(field: FormFieldRef): AbortablePromise<Uint8Array>;
|
|
583
|
+
/**
|
|
584
|
+
* Hash the signed field's `/ByteRange` with `algorithm`, straight from
|
|
585
|
+
* the loaded bytes. What a CMS verifier compares its message digest to.
|
|
586
|
+
*/
|
|
587
|
+
getDigest(field: FormFieldRef, algorithm: DigestAlgorithm): AbortablePromise<Uint8Array>;
|
|
588
|
+
/** The exact bytes of revision `revisionIndex` (`[0, end)`): what a signature over it signed. */
|
|
589
|
+
downloadRevision(revisionIndex: number): AbortablePromise<Uint8Array>;
|
|
590
|
+
/**
|
|
591
|
+
* What changed after a signature (or after any revision), judged
|
|
592
|
+
* revision by revision against the restrictions in force: every object
|
|
593
|
+
* whose cross-reference mapping moved, with its value and every
|
|
594
|
+
* reference to it in both revisions, and the rule that explains each —
|
|
595
|
+
* or the reference no rule explains. `until: 'working-copy'` snapshots
|
|
596
|
+
* unsaved edits as one more revision first. A truncated value is never
|
|
597
|
+
* permitted; a broken chain is `indeterminate`.
|
|
598
|
+
*/
|
|
599
|
+
analyze(input: AnalyzeInput): AbortablePromise<ChangeAnalysis>;
|
|
600
|
+
/**
|
|
601
|
+
* Build the candidate (unsaved edits become their own revision, the
|
|
602
|
+
* signature lands in a fresh update over it), seal it, and return the
|
|
603
|
+
* digest to sign. The live document is untouched and read-only until
|
|
604
|
+
* `complete` or `abort` (`SigningPending`). Refusals are
|
|
605
|
+
* `SignatureRefused` with the reason in the message.
|
|
606
|
+
*/
|
|
607
|
+
prepare(input: SignaturePrepareInput, options?: WriteOptions): AbortablePromise<SignaturePrepared>;
|
|
608
|
+
/**
|
|
609
|
+
* Write the CMS into the candidate and install the sealed bytes as the
|
|
610
|
+
* document's new version. `expectedVersion` must be what `prepare`
|
|
611
|
+
* returned (`SigningVersionMismatch` otherwise). Idempotent: a replay
|
|
612
|
+
* with the same CMS answers `already-completed`. Emits
|
|
613
|
+
* `signatures.completed` and `document.versioned`.
|
|
614
|
+
*/
|
|
615
|
+
complete(input: SignatureCompleteInput, options?: WriteOptions): AbortablePromise<SignatureCompleteResult>;
|
|
616
|
+
/** Discard a pending candidate. */
|
|
617
|
+
cancel(signingId: string, options?: WriteOptions): AbortablePromise<SignatureCancelResult>;
|
|
618
|
+
}
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/engine/CustomMetadataService.d.ts
|
|
621
|
+
/**
|
|
622
|
+
* The document's own Info-dict keys, as an object of their own: each key is
|
|
623
|
+
* a top-level field, so an update follows the one write rule (a key left
|
|
624
|
+
* out stays, `null` removes it, a string sets it).
|
|
625
|
+
*/
|
|
626
|
+
interface CustomMetadataService {
|
|
627
|
+
get(): AbortablePromise<CustomMetadata>;
|
|
628
|
+
/**
|
|
629
|
+
* Set and remove keys via a {@link CustomMetadataPatch}. Returns the keys
|
|
630
|
+
* as they are after the write plus cloud coherence pins (`null` for local
|
|
631
|
+
* engines). Gated by `doc.metadata.modify` on the cloud.
|
|
632
|
+
*/
|
|
633
|
+
update(patch: CustomMetadataPatch, options?: WriteOptions): AbortablePromise<CustomMetadataUpdateResult>;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/engine/MetadataService.d.ts
|
|
637
|
+
interface MetadataService {
|
|
638
|
+
get(): AbortablePromise<DocumentMetadata>;
|
|
639
|
+
/**
|
|
640
|
+
* Rewrite the standard Info-dict fields via a three-state
|
|
641
|
+
* {@link MetadataPatch} (undefined=leave, null=clear, value=set). Returns
|
|
642
|
+
* the re-read metadata plus cloud coherence pins (`null` for local
|
|
643
|
+
* engines). Gated by `doc.metadata.modify` on the cloud.
|
|
644
|
+
*/
|
|
645
|
+
update(patch: MetadataPatch, options?: WriteOptions): AbortablePromise<MetadataUpdateResult>;
|
|
646
|
+
/** The Info dict's other keys: an object of their own. */
|
|
647
|
+
readonly custom: CustomMetadataService;
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/engine/PageAnnotationsService.d.ts
|
|
651
|
+
/**
|
|
652
|
+
* Per-page annotation service exposed via `PageHandle.annotations`.
|
|
653
|
+
*
|
|
654
|
+
* `list()` returns the page's fully typed annotations except widgets, which
|
|
655
|
+
* are the form's (`doc.forms.list()`); every annotation write of one page
|
|
656
|
+
* goes through this service.
|
|
657
|
+
*/
|
|
658
|
+
interface PageAnnotationsService {
|
|
659
|
+
/** This page's annotations except widgets, in display order: `doc.annotations.list()` for one page. */
|
|
660
|
+
list(): AbortablePromise<AnnotationList>;
|
|
661
|
+
/**
|
|
662
|
+
* Batch-render every annotation appearance (`/AP`) stream on the page,
|
|
663
|
+
* widgets excepted (`page.forms.renderAppearances()` has those), into
|
|
664
|
+
* its own image, sized to the annotation's `/Rect`: encoded by the engine's
|
|
665
|
+
* image encoder (local) or fetched as a `multipart/form-data` body (cloud),
|
|
666
|
+
* each a lazily-resolved `PageImageHandle`. Read-only and gated by
|
|
667
|
+
* `doc.annotate.read`: reading an annotation implies you may see its
|
|
668
|
+
* rendered appearance (the Adobe boundary).
|
|
669
|
+
*/
|
|
670
|
+
renderAppearances(options?: AnnotationAppearanceImageOptions): AbortablePromise<AnnotationAppearanceImagesResult>;
|
|
671
|
+
/**
|
|
672
|
+
* One of an annotation's resources: the bytes `create(data, { resources })`
|
|
673
|
+
* takes to make the same annotation again. A read never contains them.
|
|
674
|
+
*
|
|
675
|
+
* - `appearance` (stamps): the drawing, as a one-page PDF, before the fit,
|
|
676
|
+
* rotation and opacity the data describes. A stamp another tool made is
|
|
677
|
+
* drawn as the page shows it, on a page the size of its `/Rect`.
|
|
678
|
+
* - `file` (file attachments): the attached file's exact bytes; its name,
|
|
679
|
+
* MIME type and description are the data's `file`.
|
|
680
|
+
*
|
|
681
|
+
* Egresses content, so it needs `doc.download`. A role the annotation's
|
|
682
|
+
* kind doesn't take is refused with `InvalidArg`.
|
|
683
|
+
*/
|
|
684
|
+
downloadResource(ref: AnnotationRef, role: AnnotationResourceRole): AbortablePromise<Uint8Array>;
|
|
685
|
+
/**
|
|
686
|
+
* Create an annotation on this page from its data. The options say how:
|
|
687
|
+
* bytes beside the data by role (`resources`: a stamp needs its
|
|
688
|
+
* `appearance`, a file attachment its `file`; a resource the kind doesn't
|
|
689
|
+
* take is refused), and the object number it gets (`objectNumber`, taken
|
|
690
|
+
* from `doc.objectNumbers`), which makes its ref known before the engine
|
|
691
|
+
* answers. Without a number the engine picks the next free one. Without
|
|
692
|
+
* an `nm` in the data the annotation gets a fresh UUIDv7 `/NM`.
|
|
693
|
+
*
|
|
694
|
+
* A number this session doesn't hold, or one an object already has, is
|
|
695
|
+
* refused with `ObjectNumberUnavailable`.
|
|
696
|
+
*/
|
|
697
|
+
create(data: AnnotationDraft, options?: AnnotationCreateOptions): AbortablePromise<AnnotationCreateResult>;
|
|
698
|
+
/**
|
|
699
|
+
* Change the fields `patch` names; the others stay. A resource replaces
|
|
700
|
+
* what it is for: a stamp's drawing, an attached file's bytes.
|
|
701
|
+
*/
|
|
702
|
+
update(ref: AnnotationRef, patch: AnnotationPatch, options?: AnnotationUpdateOptions): AbortablePromise<AnnotationUpdateResult>;
|
|
703
|
+
delete(ref: AnnotationRef, options?: WriteOptions): AbortablePromise<AnnotationDeleteResult>;
|
|
704
|
+
/**
|
|
705
|
+
* Change the stacking order: the annotations go together, in the order
|
|
706
|
+
* given, to `position` in the page's paint order (later paints over
|
|
707
|
+
* earlier): next to a neighbour (`{ before: ref }`, `{ after: ref }`) or at
|
|
708
|
+
* `'start'` (bottom) / `'end'` (top). Widgets paint above every annotation
|
|
709
|
+
* and have their own order (`doc.forms.reorderWidgets()`): a widget, as a
|
|
710
|
+
* row or a neighbour, is refused with `InvalidArg`. A neighbour that isn't
|
|
711
|
+
* on the page is `NotFound`. Answers the page's new order. Emits
|
|
712
|
+
* `annotations.reordered`.
|
|
713
|
+
*/
|
|
714
|
+
reorder(refs: AnnotationRef[], position: AnnotationPosition, options?: WriteOptions): AbortablePromise<AnnotationReorderResult>;
|
|
715
|
+
/**
|
|
716
|
+
* Flatten the given annotations of this page into its content —
|
|
717
|
+
* `pages.flatten` for a chosen set. Painted annotations are removed from
|
|
718
|
+
* the page; ones that are ineligible (hidden for `usage`, Popups, no
|
|
719
|
+
* usable appearance) stay and report `unchanged`, so a caller can say
|
|
720
|
+
* "2 of 3 flattened". A content + annotation mutation of this page: its
|
|
721
|
+
* content and annotation pins advance, layout does not; a
|
|
722
|
+
* `annotations.flattened` event is published when anything was applied.
|
|
723
|
+
* Gated like `pages.flatten` (`doc.pages.modify` + `doc.annotate.modify`).
|
|
724
|
+
* `InvalidArg` for a ref on another page; `NotFound` for an unknown ref.
|
|
725
|
+
*/
|
|
726
|
+
flatten(refs: AnnotationRef[], options?: FlattenWriteOptions): AbortablePromise<AnnotationFlattenResult>;
|
|
727
|
+
/**
|
|
728
|
+
* Flatten the normal appearances of the given annotations of this page
|
|
729
|
+
* into a new single-page PDF sized to their union `/Rect` — vector,
|
|
730
|
+
* positions preserved, exactly as this page shows them. The same plan as
|
|
731
|
+
* `flatten` aimed at a fresh page; the source document is untouched. A
|
|
732
|
+
* derived read that egresses content, so it is gated by `doc.download`
|
|
733
|
+
* like `pages.extract`. All-or-nothing: `InvalidArg` when any ref is not
|
|
734
|
+
* on this page, hidden, or has no appearance (a stamp silently missing a
|
|
735
|
+
* part would be worse than an error).
|
|
736
|
+
*/
|
|
737
|
+
exportAppearance(refs: AnnotationRef[]): AbortablePromise<Uint8Array>;
|
|
738
|
+
}
|
|
739
|
+
/** A local engine page's annotations: the shared service and the raw appearance pixels. */
|
|
740
|
+
interface LocalPageAnnotationsService extends PageAnnotationsService {
|
|
741
|
+
/**
|
|
742
|
+
* The same appearances as `renderAppearances()`, each as its own raw RGBA
|
|
743
|
+
* raster instead of an encoded image.
|
|
744
|
+
*/
|
|
745
|
+
renderAppearancesRaw(options?: AnnotationAppearanceRenderOptions): AbortablePromise<AnnotationAppearancesResult>;
|
|
746
|
+
}
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/engine/PageFormsService.d.ts
|
|
749
|
+
/**
|
|
750
|
+
* Per-page form service exposed via `PageHandle.forms`: the page's widget
|
|
751
|
+
* images. The widgets themselves are rows of the form
|
|
752
|
+
* (`doc.forms.list().widgets`).
|
|
753
|
+
*/
|
|
754
|
+
interface PageFormsService {
|
|
755
|
+
/**
|
|
756
|
+
* Batch-render every widget appearance (`/AP`) on the page, every mode and
|
|
757
|
+
* every state, each into its own image sized to the widget's `/Rect` —
|
|
758
|
+
* what `page.annotations.renderAppearances()` does for the other
|
|
759
|
+
* annotations. Gated by `doc.forms.read`.
|
|
760
|
+
*/
|
|
761
|
+
renderAppearances(options?: AnnotationAppearanceImageOptions): AbortablePromise<AnnotationAppearanceImagesResult>;
|
|
762
|
+
}
|
|
763
|
+
/** A local engine page's form: the shared service and the raw appearance pixels. */
|
|
764
|
+
interface LocalPageFormsService extends PageFormsService {
|
|
765
|
+
/** The same appearances as `renderAppearances()`, each as its own raw RGBA raster. */
|
|
766
|
+
renderAppearancesRaw(options?: AnnotationAppearanceRenderOptions): AbortablePromise<AnnotationAppearancesResult>;
|
|
767
|
+
}
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region src/engine/PageRenderService.d.ts
|
|
770
|
+
interface PageRenderService {
|
|
771
|
+
image(options?: PageImageOptions): AbortablePromise<PageRenderImage>;
|
|
772
|
+
}
|
|
773
|
+
/** A local engine page's rendering: an image, or the pixels themselves. */
|
|
774
|
+
interface LocalPageRenderService extends PageRenderService {
|
|
775
|
+
/** The page's pixels, with the transform they were made with, not encoded as an image. */
|
|
776
|
+
raw(options?: PageRenderOptions): AbortablePromise<PageRenderRaster>;
|
|
777
|
+
}
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/engine/PageTextService.d.ts
|
|
780
|
+
/**
|
|
781
|
+
* Per-page text service exposed via `PageHandle.text`. Text changes only
|
|
782
|
+
* with the page's content.
|
|
783
|
+
*/
|
|
784
|
+
interface PageTextService {
|
|
785
|
+
/**
|
|
786
|
+
* The page's text in reading order, its character count and, when the two
|
|
787
|
+
* numberings differ, the character↔text map. Needs `doc.text.copy`.
|
|
788
|
+
*/
|
|
789
|
+
get(): AbortablePromise<PageTextSnapshot>;
|
|
790
|
+
/** The text of a character range: the copy primitive. Needs `doc.text.copy`. */
|
|
791
|
+
slice(range: TextRange): AbortablePromise<string>;
|
|
792
|
+
/**
|
|
793
|
+
* Where the page's characters are: hit-testing, words and lines, and the
|
|
794
|
+
* segments to draw a selection or a highlight. Needs `doc.text.select`
|
|
795
|
+
* (where text is, not what it says).
|
|
796
|
+
*/
|
|
797
|
+
layout(): AbortablePromise<TextLayout>;
|
|
798
|
+
}
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/engine/PageMeasureService.d.ts
|
|
801
|
+
interface PageMeasureService {
|
|
802
|
+
/** Viewports in drawing order. Last containing viewport wins, including foreign ones. */
|
|
803
|
+
listViewports(): AbortablePromise<PageMeasurementViewportList>;
|
|
804
|
+
/** Upsert/remove EmbedPDF's full-page calibration. Other producers' entries survive.
|
|
805
|
+
* Existing annotations retain their own scale snapshots. */
|
|
806
|
+
setScale(measure: PdfMeasure | null, options?: WriteOptions): AbortablePromise<PageScaleResult>;
|
|
807
|
+
}
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/engine/PageHandle.d.ts
|
|
810
|
+
/**
|
|
811
|
+
* Page-scoped handle returned by `DocumentHandle.page(ref)`. The handle is
|
|
812
|
+
* keyed on the page's durable address (its PDF indirect object number),
|
|
813
|
+
* never the page index, so it survives page-list mutations.
|
|
814
|
+
*/
|
|
815
|
+
interface PageHandle {
|
|
816
|
+
readonly ref: PageRef;
|
|
817
|
+
readonly annotations: PageAnnotationsService;
|
|
818
|
+
readonly forms: PageFormsService;
|
|
819
|
+
readonly text: PageTextService;
|
|
820
|
+
readonly render: PageRenderService;
|
|
821
|
+
readonly measure: PageMeasureService;
|
|
822
|
+
}
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/events/DocumentEvent.d.ts
|
|
825
|
+
/**
|
|
826
|
+
* Provenance of a `DocumentEvent` — whose hand caused the mutation, never
|
|
827
|
+
* which transport delivered it (transport is invisible by design).
|
|
828
|
+
*
|
|
829
|
+
* `kind: 'local'` means made through this open document (this handle), not
|
|
830
|
+
* "this user". Every open is its own session: the same user in two tabs, or
|
|
831
|
+
* an app that opens one cloud document twice, is two sessions, and a
|
|
832
|
+
* mutation made through one arrives in the other as `'remote'` (with the
|
|
833
|
+
* same `sub`). Rule of thumb for consumers: "is this my action" → check
|
|
834
|
+
* `kind` / `sessionId` (undo stacks, optimism reconciliation); "is this my
|
|
835
|
+
* user" → check `sub` (attribution).
|
|
836
|
+
*/
|
|
837
|
+
interface EventOrigin {
|
|
838
|
+
/** 'local' = made through this handle; 'remote' = another session. */
|
|
839
|
+
kind: 'local' | 'remote';
|
|
840
|
+
/** Identifies the session (the open document handle) that made the mutation. */
|
|
841
|
+
sessionId: string;
|
|
842
|
+
/** Authenticated subject of the originator (cloud); `null` locally. */
|
|
843
|
+
sub: string | null;
|
|
844
|
+
/** Mutation timestamp (server ts for remote, client ts for local). */
|
|
845
|
+
ts: number;
|
|
846
|
+
/** Server audit-log row id — monotonic per document, the resume cursor.
|
|
847
|
+
* `null` until the mutation has a server identity (local engines; cloud
|
|
848
|
+
* own-mutation events before the server echoes the id). */
|
|
849
|
+
serverId: number | null;
|
|
850
|
+
/**
|
|
851
|
+
* Set when this fact is one of several committed together, such as the
|
|
852
|
+
* annotations of one import: they share `id`, and `index` counts from 0 to
|
|
853
|
+
* `count - 1` in the order they were emitted.
|
|
854
|
+
*/
|
|
855
|
+
tx?: {
|
|
856
|
+
id: string;
|
|
857
|
+
index: number;
|
|
858
|
+
count: number;
|
|
859
|
+
};
|
|
860
|
+
/** Set on the events of an undo: the `opId` of the change it undid. */
|
|
861
|
+
undoOf?: string;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* The one event stream both engines speak — the model is the contract, the
|
|
865
|
+
* transport differs (local: in-process after the worker confirms; cloud:
|
|
866
|
+
* in-process for your own mutations, SSE for everyone else's).
|
|
867
|
+
*
|
|
868
|
+
* Invariants (locked — the collaboration design rests on these):
|
|
869
|
+
*
|
|
870
|
+
* - exactly once: every mutation that touches your document appears in
|
|
871
|
+
* your stream exactly once. The handle that performs a mutation emits
|
|
872
|
+
* the event itself at confirmation time; the remote channel exists to
|
|
873
|
+
* tell everyone else (own echoes are dropped by `sessionId`). A change
|
|
874
|
+
* that commits several facts at once, such as an import, emits one
|
|
875
|
+
* event per fact, back to back, sharing `origin.tx`.
|
|
876
|
+
* - ground truth only: events fire after the mutation is confirmed —
|
|
877
|
+
* never optimistically. Optimism is a plugin concern.
|
|
878
|
+
* - results ride verbatim: each event embeds the mutation result the
|
|
879
|
+
* caller received, unmodified — which (cloud) is byte-identical to the
|
|
880
|
+
* audit-log payload. A handler sees the same fact whether it performed
|
|
881
|
+
* the mutation, watched it locally, or received it over the wire.
|
|
882
|
+
* - published before settlement: the event for a session's own mutation
|
|
883
|
+
* reaches subscribers before the mutation's promise settles, so a caller
|
|
884
|
+
* awaiting the mutation already sees every state derived from the event.
|
|
885
|
+
*
|
|
886
|
+
* Handlers updating UI/document state should be origin-agnostic ("a page
|
|
887
|
+
* was removed → update the registry"); `origin` is metadata for the few
|
|
888
|
+
* provenance-aware features (undo, attribution toasts, camera etiquette).
|
|
889
|
+
*/
|
|
890
|
+
type DocumentEvent = ({
|
|
891
|
+
type: 'pages.scaleSet';
|
|
892
|
+
origin: EventOrigin;
|
|
893
|
+
} & PageScaleResult) | ({
|
|
894
|
+
type: 'annotations.created';
|
|
895
|
+
page: PageRef;
|
|
896
|
+
origin: EventOrigin;
|
|
897
|
+
} & AnnotationCreateResult) | ({
|
|
898
|
+
type: 'annotations.updated';
|
|
899
|
+
page: PageRef;
|
|
900
|
+
origin: EventOrigin;
|
|
901
|
+
} & AnnotationUpdateResult) | ({
|
|
902
|
+
type: 'annotations.deleted';
|
|
903
|
+
page: PageRef;
|
|
904
|
+
origin: EventOrigin;
|
|
905
|
+
/**
|
|
906
|
+
* What was deleted: the annotation and what went with it (replies,
|
|
907
|
+
* grouped parts, review states, popups), the annotation first; see
|
|
908
|
+
* `deletedAnnotationsOf`.
|
|
909
|
+
*/
|
|
910
|
+
deleted: AnnotationRef[];
|
|
911
|
+
} & AnnotationDeleteResult) | ({
|
|
912
|
+
/** A stacking-order change: the page's annotations in their new order. */
|
|
913
|
+
type: 'annotations.reordered';
|
|
914
|
+
page: PageRef;
|
|
915
|
+
origin: EventOrigin;
|
|
916
|
+
} & AnnotationReorderResult) | {
|
|
917
|
+
/**
|
|
918
|
+
* An undo brought deleted annotations back: the same objects, under
|
|
919
|
+
* the refs they had, with their owner, replies and popup. A listener
|
|
920
|
+
* that keeps things by ref (comments, links) attaches them again.
|
|
921
|
+
*/
|
|
922
|
+
type: 'annotations.restored';
|
|
923
|
+
page: PageRef;
|
|
924
|
+
origin: EventOrigin;
|
|
925
|
+
/** What came back, in `/Annots` order: the annotation first, then what went with it. */
|
|
926
|
+
annotations: Annotation[];
|
|
927
|
+
meta: AnnotationListMutationMeta;
|
|
928
|
+
} | ({
|
|
929
|
+
type: 'annotations.flattened';
|
|
930
|
+
origin: EventOrigin;
|
|
931
|
+
} & AnnotationFlattenResult) | ({
|
|
932
|
+
type: 'pages.reordered';
|
|
933
|
+
origin: EventOrigin;
|
|
934
|
+
} & PageReorderResult) | ({
|
|
935
|
+
type: 'pages.rotated';
|
|
936
|
+
pages: PageRef[];
|
|
937
|
+
rotation: PdfRotation;
|
|
938
|
+
origin: EventOrigin;
|
|
939
|
+
} & PageRotateResult) | ({
|
|
940
|
+
type: 'pages.deleted';
|
|
941
|
+
/** The retired pages — not derivable from the surviving `layout`. */
|
|
942
|
+
pages: PageRef[];
|
|
943
|
+
origin: EventOrigin;
|
|
944
|
+
} & PageDeleteResult) | ({
|
|
945
|
+
type: 'pages.inserted';
|
|
946
|
+
origin: EventOrigin;
|
|
947
|
+
} & PageInsertResult) | ({
|
|
948
|
+
type: 'pages.named';
|
|
949
|
+
/** The decoded key that was registered, renamed, or removed. */
|
|
950
|
+
name: string;
|
|
951
|
+
/** The page it now points at; `null` when the registration was removed. */
|
|
952
|
+
page: PageRef | null;
|
|
953
|
+
origin: EventOrigin;
|
|
954
|
+
} & PageNameResult) | ({
|
|
955
|
+
type: 'attachments.created';
|
|
956
|
+
origin: EventOrigin;
|
|
957
|
+
} & AttachmentCreateResult) | ({
|
|
958
|
+
type: 'attachments.deleted';
|
|
959
|
+
origin: EventOrigin;
|
|
960
|
+
/** What was deleted (see `deletedAttachmentOf`). */
|
|
961
|
+
deleted: AttachmentRef | null;
|
|
962
|
+
} & AttachmentDeleteResult) | ({
|
|
963
|
+
type: 'metadata.updated';
|
|
964
|
+
origin: EventOrigin;
|
|
965
|
+
} & MetadataUpdateResult) | ({
|
|
966
|
+
type: 'metadata.customUpdated';
|
|
967
|
+
origin: EventOrigin;
|
|
968
|
+
} & CustomMetadataUpdateResult) | ({
|
|
969
|
+
type: 'forms.valueSet';
|
|
970
|
+
origin: EventOrigin;
|
|
971
|
+
} & FormSetValueResult) | ({
|
|
972
|
+
type: 'forms.repaired';
|
|
973
|
+
origin: EventOrigin;
|
|
974
|
+
} & FormRepairResult) | ({
|
|
975
|
+
type: 'forms.created';
|
|
976
|
+
origin: EventOrigin;
|
|
977
|
+
} & FormFieldCreateResult) | ({
|
|
978
|
+
type: 'forms.updated';
|
|
979
|
+
origin: EventOrigin;
|
|
980
|
+
} & FormFieldUpdateResult) | ({
|
|
981
|
+
type: 'forms.deleted';
|
|
982
|
+
origin: EventOrigin;
|
|
983
|
+
/** The field that went (see `deletedFieldOf`). */
|
|
984
|
+
deleted: FormFieldRef | null;
|
|
985
|
+
} & FormFieldDeleteResult) | {
|
|
986
|
+
/**
|
|
987
|
+
* An undo brought a deleted field back: the same field and widgets,
|
|
988
|
+
* under the refs they had, at their places, with its value.
|
|
989
|
+
*/
|
|
990
|
+
type: 'forms.restored';
|
|
991
|
+
origin: EventOrigin;
|
|
992
|
+
field: FormFieldDTO;
|
|
993
|
+
widgets: WidgetAnnotation[];
|
|
994
|
+
meta: FormMutationMeta;
|
|
995
|
+
} | ({
|
|
996
|
+
type: 'forms.widgetAdded';
|
|
997
|
+
origin: EventOrigin;
|
|
998
|
+
} & FormWidgetLinkResult) | ({
|
|
999
|
+
type: 'forms.widgetRemoved';
|
|
1000
|
+
origin: EventOrigin;
|
|
1001
|
+
} & FormWidgetLinkResult) | ({
|
|
1002
|
+
type: 'forms.widgetDeleted';
|
|
1003
|
+
origin: EventOrigin;
|
|
1004
|
+
} & FormWidgetDeleteResult) | ({
|
|
1005
|
+
/** An undo brought a deleted widget back: onto its page at its place, into its field. */
|
|
1006
|
+
type: 'forms.widgetRestored';
|
|
1007
|
+
origin: EventOrigin;
|
|
1008
|
+
} & FormWidgetRestoreResult) | ({
|
|
1009
|
+
type: 'forms.widgetUpdated';
|
|
1010
|
+
origin: EventOrigin;
|
|
1011
|
+
} & FormWidgetUpdateResult) | ({
|
|
1012
|
+
/** A stacking-order change: the page's widgets in their new order. */
|
|
1013
|
+
type: 'forms.widgetsReordered';
|
|
1014
|
+
origin: EventOrigin;
|
|
1015
|
+
} & FormWidgetsReorderResult) | ({
|
|
1016
|
+
/** A calculation-order change: the form's whole new order. */
|
|
1017
|
+
type: 'forms.calculationsReordered';
|
|
1018
|
+
origin: EventOrigin;
|
|
1019
|
+
} & FormCalculationsReorderResult) | ({
|
|
1020
|
+
type: 'pages.flattened';
|
|
1021
|
+
pages: PageRef[];
|
|
1022
|
+
usage: PageFlattenUsage;
|
|
1023
|
+
origin: EventOrigin;
|
|
1024
|
+
} & PageFlattenResult) | ({
|
|
1025
|
+
type: 'redaction.applied';
|
|
1026
|
+
origin: EventOrigin;
|
|
1027
|
+
} & RedactionApplyResult) | ({
|
|
1028
|
+
/** A signing candidate was parked: the document is read-only until it completes or is cancelled. */
|
|
1029
|
+
type: 'signatures.prepared';
|
|
1030
|
+
field: FormFieldRef;
|
|
1031
|
+
origin: EventOrigin;
|
|
1032
|
+
} & SignaturePrepared) | ({
|
|
1033
|
+
/** The sealed bytes are installed; `version` is what they became. */
|
|
1034
|
+
type: 'signatures.completed';
|
|
1035
|
+
signingId: string;
|
|
1036
|
+
origin: EventOrigin;
|
|
1037
|
+
} & SignatureCompleteResult) | {
|
|
1038
|
+
type: 'signatures.cancelled';
|
|
1039
|
+
signingId: string;
|
|
1040
|
+
origin: EventOrigin;
|
|
1041
|
+
} | {
|
|
1042
|
+
/**
|
|
1043
|
+
* The session moved to a new saved version (a completed signature,
|
|
1044
|
+
* here or in another session). Byte-level facts — revisions,
|
|
1045
|
+
* coverage, digests, verdicts — must be re-read.
|
|
1046
|
+
*/
|
|
1047
|
+
type: 'document.versioned';
|
|
1048
|
+
version: BaseVersionInfo;
|
|
1049
|
+
origin: EventOrigin;
|
|
1050
|
+
} | {
|
|
1051
|
+
/**
|
|
1052
|
+
* Cloud only: the live event stream fell too far behind to replay
|
|
1053
|
+
* (the server's SSE `full-refresh`) — state derived from earlier
|
|
1054
|
+
* events or snapshots may be stale, and the gap's mutations will
|
|
1055
|
+
* never arrive as events. Consumers must re-read the snapshots they
|
|
1056
|
+
* keep fresh from this stream (`doc.annotations.list()`,
|
|
1057
|
+
* `doc.forms.list()`, …).
|
|
1058
|
+
*
|
|
1059
|
+
* Carries no `EventOrigin`: it is a transport notice, not a
|
|
1060
|
+
* document mutation — the exactly-once / results-ride-verbatim
|
|
1061
|
+
* invariants above apply to mutation events only. The local engine
|
|
1062
|
+
* never emits it.
|
|
1063
|
+
*/
|
|
1064
|
+
type: 'stream.desynced';
|
|
1065
|
+
reason: 'backlog-overflow';
|
|
1066
|
+
ts: number;
|
|
1067
|
+
};
|
|
1068
|
+
type DocumentEventType = DocumentEvent['type'];
|
|
1069
|
+
/** The event of one type, such as `DocumentEventOf<'annotations.created'>`. */
|
|
1070
|
+
type DocumentEventOf<T extends DocumentEventType> = Extract<DocumentEvent, {
|
|
1071
|
+
type: T;
|
|
1072
|
+
}>;
|
|
1073
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
1074
|
+
/** A `DocumentEvent` before provenance is stamped — what mutation paths
|
|
1075
|
+
* hand to their engine's publisher, which adds `origin`. Transport
|
|
1076
|
+
* notices (`stream.desynced`) are excluded: they are published directly
|
|
1077
|
+
* by the remote channel, never through a mutation publisher. */
|
|
1078
|
+
type DocumentEventInit = DistributiveOmit<Exclude<DocumentEvent, {
|
|
1079
|
+
type: 'stream.desynced';
|
|
1080
|
+
}>, 'origin'>;
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region src/events/DocumentEventStream.d.ts
|
|
1083
|
+
/**
|
|
1084
|
+
* The subscription surface on `DocumentHandle.events`: every event with
|
|
1085
|
+
* `subscribe`, one type with `on`. No replay-from-id: plugins build their
|
|
1086
|
+
* own filter wrappers (per-page, …) on top.
|
|
1087
|
+
*
|
|
1088
|
+
* Delivery is synchronous fan-out with error isolation: a throwing
|
|
1089
|
+
* listener never blocks other listeners, and never fails the mutation
|
|
1090
|
+
* whose confirmation produced the event.
|
|
1091
|
+
*/
|
|
1092
|
+
interface DocumentEventStream {
|
|
1093
|
+
/** Subscribe to every event for this document. Returns the unsubscriber. */
|
|
1094
|
+
subscribe(listener: (event: DocumentEvent) => void): () => void;
|
|
1095
|
+
/** Subscribe to one type of event, typed by it. Returns the unsubscriber. */
|
|
1096
|
+
on<T extends DocumentEventType>(type: T, listener: (event: DocumentEventOf<T>) => void): () => void;
|
|
1097
|
+
/**
|
|
1098
|
+
* Highest `origin.serverId` observed so far — the reconnect/backfill
|
|
1099
|
+
* cursor for the remote channel. `null` until a remote-identified event
|
|
1100
|
+
* has been seen (always `null` on purely-local engines).
|
|
1101
|
+
*/
|
|
1102
|
+
lastServerId(): number | null;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* `on(type, listener)` built on a stream's `subscribe`, so both engines
|
|
1106
|
+
* filter the same way and a type listener counts as a subscriber (the cloud
|
|
1107
|
+
* opens its live stream for the first one).
|
|
1108
|
+
*/
|
|
1109
|
+
declare function subscribeToType<T extends DocumentEventType>(subscribe: DocumentEventStream['subscribe'], type: T, listener: (event: DocumentEventOf<T>) => void): () => void;
|
|
1110
|
+
//#endregion
|
|
1111
|
+
//#region src/scheduling/facts.d.ts
|
|
1112
|
+
/**
|
|
1113
|
+
* How much a call matters, with `fetch`'s words. The caller says it, so the
|
|
1114
|
+
* engine knows no feature: a viewer gives `high` to what its views are for.
|
|
1115
|
+
* Most calls say nothing (`auto`).
|
|
1116
|
+
*
|
|
1117
|
+
* - `high`: the main thing a view shows of a page: its picture, in a viewer.
|
|
1118
|
+
* - `auto`: everything else about the document and what's shown (the default).
|
|
1119
|
+
* - `low`: background work, about nothing the views show (a search scan): it
|
|
1120
|
+
* runs after everything else.
|
|
1121
|
+
*
|
|
1122
|
+
* Where a page is on screen counts before `high` and `auto` (see `rank`), so
|
|
1123
|
+
* a caller never says where its page is: the views say that.
|
|
1124
|
+
*/
|
|
1125
|
+
type CallPriority = 'high' | 'auto' | 'low';
|
|
1126
|
+
/**
|
|
1127
|
+
* What's true about a call for as long as it waits (`doc.with(facts)`). Both
|
|
1128
|
+
* are fixed once the call is made; when a result becomes urgent later, its
|
|
1129
|
+
* owner asks again.
|
|
1130
|
+
*/
|
|
1131
|
+
interface CallFacts {
|
|
1132
|
+
/** Default `auto`. */
|
|
1133
|
+
readonly priority?: CallPriority;
|
|
1134
|
+
/**
|
|
1135
|
+
* The view the call serves, when its result is that view's own (a render
|
|
1136
|
+
* layer's pixels): the call then ranks by where its page is in that view.
|
|
1137
|
+
* Absent: the result is shared by every view (text, links, annotations),
|
|
1138
|
+
* and the call ranks by the best place its page has in any of them.
|
|
1139
|
+
*/
|
|
1140
|
+
readonly view?: string;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* A page a view shows (`doc.setWorkingSet`). The engine ranks the calls for
|
|
1144
|
+
* the page by it, and keeps the pages it shows parsed longest.
|
|
1145
|
+
*/
|
|
1146
|
+
interface WorkingSetPage {
|
|
1147
|
+
readonly page: PageRef;
|
|
1148
|
+
/** `visible`: some of it is on screen. `near`: placed just off screen, where the view goes next. */
|
|
1149
|
+
readonly role: 'visible' | 'near';
|
|
1150
|
+
/** The part on screen, in page space. Absent: the whole page, or none of a near page. */
|
|
1151
|
+
readonly visible?: PageBox;
|
|
1152
|
+
/** Device pixels of it on screen: what ranks visible pages among themselves. 0 for a near page. */
|
|
1153
|
+
readonly pixels: number;
|
|
1154
|
+
}
|
|
1155
|
+
//#endregion
|
|
1156
|
+
//#region src/engine/DocumentHandle.d.ts
|
|
1157
|
+
/**
|
|
1158
|
+
* A document an engine opened: the same on every engine. What only the local
|
|
1159
|
+
* engine can do lives on `LocalDocumentHandle` (see `isLocalDocument`).
|
|
1160
|
+
*/
|
|
1161
|
+
interface DocumentHandle {
|
|
1162
|
+
readonly id: string;
|
|
1163
|
+
readonly security: DocumentSecurityService;
|
|
1164
|
+
readonly metadata: MetadataService;
|
|
1165
|
+
readonly annotations: DocumentAnnotationsService;
|
|
1166
|
+
/** Lazy catalog-owned action extraction. The engine never executes scripts. */
|
|
1167
|
+
readonly actions: DocumentActionsService;
|
|
1168
|
+
/**
|
|
1169
|
+
* Document-level attachments (the catalog's `/EmbeddedFiles` name tree).
|
|
1170
|
+
* Files attached to annotations are read via
|
|
1171
|
+
* `page(ref).annotations.downloadResource(ref, 'file')`.
|
|
1172
|
+
*/
|
|
1173
|
+
readonly attachments: DocumentAttachmentsService;
|
|
1174
|
+
/** The document's interactive form (AcroForm): fields, values, interchange. */
|
|
1175
|
+
readonly forms: DocumentFormsService;
|
|
1176
|
+
/** Document text search: budgeted, cursor-resumable slices. */
|
|
1177
|
+
readonly search: DocumentSearchService;
|
|
1178
|
+
/**
|
|
1179
|
+
* Render policy surface (`doc.render.getPolicy()`): the engine's render
|
|
1180
|
+
* lattice, or `continuous` on engines that render any viewport exactly
|
|
1181
|
+
* (the local engine). Pixels stay on `page(ref).render` — this carries
|
|
1182
|
+
* policy only. Conformance is explicit via `snapFullPageViewport`; no
|
|
1183
|
+
* engine ever snaps a render call implicitly.
|
|
1184
|
+
*/
|
|
1185
|
+
readonly render: DocumentRenderService;
|
|
1186
|
+
/**
|
|
1187
|
+
* Document-scoped page service. Use for cross-page operations:
|
|
1188
|
+
* - `pages.list()` for the current display order.
|
|
1189
|
+
* - `pages.reorder(refs, position)` for reorder.
|
|
1190
|
+
*
|
|
1191
|
+
* Per-page reads/writes still live on `page(ref).annotations`.
|
|
1192
|
+
*/
|
|
1193
|
+
readonly pages: DocumentPagesService;
|
|
1194
|
+
/**
|
|
1195
|
+
* Destructive redaction apply (the second stage of the two-stage model;
|
|
1196
|
+
* marking rides the normal annotation verbs).
|
|
1197
|
+
*/
|
|
1198
|
+
readonly redaction: DocumentRedactionService;
|
|
1199
|
+
/**
|
|
1200
|
+
* Digital signatures: the read side (revisions, signed fields, the
|
|
1201
|
+
* protection they impose) and the two-phase signing protocol.
|
|
1202
|
+
*/
|
|
1203
|
+
readonly signatures: DocumentSignaturesService;
|
|
1204
|
+
/**
|
|
1205
|
+
* The document's event stream — every confirmed mutation, exactly once,
|
|
1206
|
+
* identical shape on local and cloud engines (see `DocumentEvent`). Each
|
|
1207
|
+
* open is its own session, named on each event's `origin.sessionId`.
|
|
1208
|
+
*/
|
|
1209
|
+
readonly events: DocumentEventStream;
|
|
1210
|
+
/**
|
|
1211
|
+
* This session's reserved object numbers: take one to name an object
|
|
1212
|
+
* before creating it (`page.annotations.create(data, { objectNumber })`,
|
|
1213
|
+
* `pages.insertBlank(spec, position, { objectNumbers })`, `forms.create`,
|
|
1214
|
+
* `forms.addWidget`). Its ref is then known at once and stays its name
|
|
1215
|
+
* for life. Creates without a number still work; the engine picks one.
|
|
1216
|
+
*/
|
|
1217
|
+
readonly objectNumbers: ObjectNumberPool;
|
|
1218
|
+
/**
|
|
1219
|
+
* A handle for the page `ref` names: an address with the page's verbs,
|
|
1220
|
+
* made without asking the engine anything (so synchronous). The page is
|
|
1221
|
+
* looked up when a call runs; a page the document doesn't have fails that
|
|
1222
|
+
* call with `NotFound`. It carries no page data: `pages.list()` does.
|
|
1223
|
+
*/
|
|
1224
|
+
page(ref: PageRef): PageHandle;
|
|
1225
|
+
/**
|
|
1226
|
+
* Apply one change, as one transaction: its ops in order, all of them or
|
|
1227
|
+
* none (`{ ops }`), or the reverse of an earlier write (`{ undoOf: opId }`).
|
|
1228
|
+
* Put everything one user action does into one change; it is one audit
|
|
1229
|
+
* row, one burst of events and one undo step. An undo applies where the
|
|
1230
|
+
* document still shows what the write set, and its items list what it left
|
|
1231
|
+
* alone (`skipped`). Its own result is undoable: that is redo.
|
|
1232
|
+
*/
|
|
1233
|
+
apply(change: Change, options?: WriteOptions): AbortablePromise<ChangeResult>;
|
|
1234
|
+
/**
|
|
1235
|
+
* The same document, every call made through it carrying `facts`: whether
|
|
1236
|
+
* a person waits on it, and the view it serves (see {@link CallFacts}). Most
|
|
1237
|
+
* calls need none. The local engine ranks the jobs it runs by them; the
|
|
1238
|
+
* cloud engine sends every call as it's made, so it ignores them.
|
|
1239
|
+
*/
|
|
1240
|
+
with(facts: CallFacts): DocumentHandle;
|
|
1241
|
+
/**
|
|
1242
|
+
* What `view` shows of the document. The local engine ranks the jobs for
|
|
1243
|
+
* those pages by it, ranking again whatever waits each time a set arrives,
|
|
1244
|
+
* and keeps the pages it shows parsed longest. Each call replaces the view's
|
|
1245
|
+
* last set; an empty set withdraws it. A hint: it changes no result. The
|
|
1246
|
+
* cloud engine ignores it.
|
|
1247
|
+
*/
|
|
1248
|
+
setWorkingSet(view: string, pages: readonly WorkingSetPage[]): void;
|
|
1249
|
+
download(options?: DownloadOptions): AbortablePromise<Uint8Array>;
|
|
1250
|
+
close(): AbortablePromise<void>;
|
|
1251
|
+
}
|
|
1252
|
+
//#endregion
|
|
1253
|
+
//#region src/engine/Engine.d.ts
|
|
1254
|
+
/**
|
|
1255
|
+
* Engine contract shared by `@embedpdf/engine` and
|
|
1256
|
+
* `@cloudpdf/engine`. Both implementations expose the same
|
|
1257
|
+
* `open()` surface and return the same {@link DocumentHandle} shape;
|
|
1258
|
+
* the only observable difference is transport — local goes through a
|
|
1259
|
+
* Worker + WASM PDFium, cloud goes through HTTPS to a remote server. What
|
|
1260
|
+
* only the local engine can do lives on `LocalEngine` (see `isLocalEngine`).
|
|
1261
|
+
*
|
|
1262
|
+
* Authorization parity:
|
|
1263
|
+
* - Cloud reads scope + identity from the doc-scoped JWT it gets at
|
|
1264
|
+
* transport setup time. `OpenOptions.scope` / `OpenOptions.identity`
|
|
1265
|
+
* are silently ignored by cloud (the JWT is the authority).
|
|
1266
|
+
* - Local reads scope + identity from `OpenOptions.scope` /
|
|
1267
|
+
* `OpenOptions.identity` (no JWT involved). Defaults to `['*']`
|
|
1268
|
+
* wildcard with a one-time console warning.
|
|
1269
|
+
*
|
|
1270
|
+
* Both engines run the same resolver against the same `pdf.permissions`
|
|
1271
|
+
* expansion → identical allow/deny decisions for the same
|
|
1272
|
+
* scope+identity+PDF-bits inputs. The parity test at
|
|
1273
|
+
* `engine-core/test/scope-parity.test.ts` (commit 17) locks this in.
|
|
1274
|
+
*/
|
|
1275
|
+
interface Engine {
|
|
1276
|
+
/**
|
|
1277
|
+
* Whether `open()` takes a file's own bytes (`{ kind: 'bytes' }`), such as a file someone
|
|
1278
|
+
* picked on their computer. The local engine does; the cloud engine opens only the documents
|
|
1279
|
+
* your server holds (`'id'`, `'token'`, `'share'`).
|
|
1280
|
+
*/
|
|
1281
|
+
readonly canOpenFiles: boolean;
|
|
1282
|
+
open(input: OpenInput, options?: OpenOptions): AbortablePromise<DocumentHandle>;
|
|
1283
|
+
destroy(): AbortablePromise<void>;
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* A thunk that constructs a fresh {@link Engine}. Construction is synchronous
|
|
1287
|
+
* and cheap — engines allocate no live resources (no Worker, no WASM, no
|
|
1288
|
+
* socket) until first use — so the thunk exists purely to express ownership:
|
|
1289
|
+
*
|
|
1290
|
+
* - Pass an `Engine` instance to an adapter (`<Viewer>`, `provideEmbedPdf`)
|
|
1291
|
+
* and it is borrowed: the adapter never destroys it. You own the
|
|
1292
|
+
* lifetime — the module-scope singleton case.
|
|
1293
|
+
* - Pass a thunk (`() => localEngine()`) and the adapter owns the result:
|
|
1294
|
+
* it calls the thunk on mount and destroys the engine on unmount. Use
|
|
1295
|
+
* this for per-mount isolation (StrictMode/HMR-clean teardown,
|
|
1296
|
+
* multi-viewer independence).
|
|
1297
|
+
*
|
|
1298
|
+
* Deliberately synchronous — an async thunk would reintroduce a "maybe
|
|
1299
|
+
* engine" that every consumer must await (the deferredEngine problem this
|
|
1300
|
+
* design removed). Async acquisition (dynamic `import()`, remote config)
|
|
1301
|
+
* belongs outside the thunk: await it, then hand over the instance. Code
|
|
1302
|
+
* that genuinely needs a lazily-resolved engine models that itself with
|
|
1303
|
+
* `Engine | Promise<Engine>` (see the stamp plugin's `assetEngine`).
|
|
1304
|
+
*/
|
|
1305
|
+
type EngineFactory = () => Engine;
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region src/engine/FontService.d.ts
|
|
1308
|
+
/**
|
|
1309
|
+
* Engine-level service for registering runtime fonts and configuring the
|
|
1310
|
+
* ordered glyph-fallback chain. Runtime-global, not document-scoped: a
|
|
1311
|
+
* registered font is shared by every page render and annotation-authoring
|
|
1312
|
+
* call on the engine's PDFium thread, and survives document open/close.
|
|
1313
|
+
*
|
|
1314
|
+
* Availability is the deliberate local-vs-cloud split:
|
|
1315
|
+
* - `@embedpdf/engine` (local/WASM) implements it: the developer embedding
|
|
1316
|
+
* the viewer decides what fonts ship to the client runtime.
|
|
1317
|
+
* - `@cloudpdf/engine` (cloud) does not expose it (`Engine.fonts` is
|
|
1318
|
+
* undefined). Fallback fonts are a server policy decision, loaded once on
|
|
1319
|
+
* the server runtime; clients cannot influence them.
|
|
1320
|
+
*
|
|
1321
|
+
* `register` and `addFallback` are intentionally separate calls: registering a
|
|
1322
|
+
* font makes it available for explicit annotation authoring
|
|
1323
|
+
* (a free text's `fontFamily`); adding it to the fallback chain *also*
|
|
1324
|
+
* makes it eligible for automatic missing-glyph substitution during page
|
|
1325
|
+
* rendering and appearance generation. Many fonts want one without the other.
|
|
1326
|
+
*/
|
|
1327
|
+
interface FontService {
|
|
1328
|
+
/**
|
|
1329
|
+
* Register a single font under its `key`. Idempotent: registering a `key`
|
|
1330
|
+
* already known resolves to the existing handle without re-uploading bytes
|
|
1331
|
+
* to the runtime.
|
|
1332
|
+
*
|
|
1333
|
+
* Rejects with `EngineErrorCode.InvalidArg` when the runtime cannot load the
|
|
1334
|
+
* font (corrupt file, unsupported format, no glyphs), and for a key that is
|
|
1335
|
+
* empty or one of the 14 standard font names (`'helvetica'`, …), which a
|
|
1336
|
+
* `fontFamily` always resolves to the standard font.
|
|
1337
|
+
*/
|
|
1338
|
+
register(spec: FontSpec): AbortablePromise<FontHandle>;
|
|
1339
|
+
/** Register several fonts, preserving order. */
|
|
1340
|
+
registerAll(specs: FontSpec[]): AbortablePromise<FontHandle[]>;
|
|
1341
|
+
/**
|
|
1342
|
+
* Append a registered font to the ordered fallback chain. Order is
|
|
1343
|
+
* precedence: the first registered font that covers a missing glyph wins,
|
|
1344
|
+
* with style (weight/italic) used as a tie-breaker by the runtime.
|
|
1345
|
+
*/
|
|
1346
|
+
addFallback(font: FontHandle | FontKey): AbortablePromise<void>;
|
|
1347
|
+
/** Clear the fallback chain without unregistering the fonts themselves. */
|
|
1348
|
+
clearFallbacks(): AbortablePromise<void>;
|
|
1349
|
+
/** Unregister every font and reset the fallback chain. */
|
|
1350
|
+
clear(): AbortablePromise<void>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Assert that the application holds a licence permitting editing with a
|
|
1353
|
+
* preview-and-print font, so FreeText authoring and missing-glyph fallback
|
|
1354
|
+
* may use it. Resolves to the updated handle (`editingAuthorized: true`).
|
|
1355
|
+
* Rejects with `InvalidArg` for an unregistered key.
|
|
1356
|
+
*/
|
|
1357
|
+
authorizeEditing(font: FontHandle | FontKey): AbortablePromise<FontHandle>;
|
|
1358
|
+
/** Currently registered fonts, in registration order. */
|
|
1359
|
+
list(): readonly FontHandle[];
|
|
1360
|
+
}
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region src/engine/DocumentFontSettings.d.ts
|
|
1363
|
+
/**
|
|
1364
|
+
* How much of a registered font's program the appearances authored in this
|
|
1365
|
+
* document carry. `default` subsets annotation text (FreeText, redaction
|
|
1366
|
+
* labels) and embeds form-field text whole; `subset` and `full` apply to
|
|
1367
|
+
* both. A font whose licence forbids subsetting is embedded whole under
|
|
1368
|
+
* every policy; programs already in the document are never re-embedded.
|
|
1369
|
+
*/
|
|
1370
|
+
type FontEmbeddingPolicy = 'default' | 'subset' | 'full';
|
|
1371
|
+
/**
|
|
1372
|
+
* Per-document font and text-layout settings: session state of this
|
|
1373
|
+
* document handle, never written to the file, applied to appearances
|
|
1374
|
+
* generated after the call. Local engine only (`doc.fonts` is undefined on
|
|
1375
|
+
* engines that do not lay text out in-process).
|
|
1376
|
+
*/
|
|
1377
|
+
interface DocumentFontSettings {
|
|
1378
|
+
setEmbeddingPolicy(policy: FontEmbeddingPolicy): AbortablePromise<void>;
|
|
1379
|
+
/**
|
|
1380
|
+
* Latin typographic features (kerning, ligatures) when shaping rich text.
|
|
1381
|
+
* Off by default: Acrobat's appearances show plain advance widths and no
|
|
1382
|
+
* ligatures, and parity with what Acrobat draws wins.
|
|
1383
|
+
*/
|
|
1384
|
+
setTypographicFeatures(enabled: boolean): AbortablePromise<void>;
|
|
1385
|
+
}
|
|
1386
|
+
//#endregion
|
|
1387
|
+
//#region src/dto/PieceInfo.d.ts
|
|
1388
|
+
/**
|
|
1389
|
+
* Page-piece metadata (ISO 32000 §14.5): private, application-scoped data
|
|
1390
|
+
* under `/PieceInfo` on a page or on the document catalog. The engine
|
|
1391
|
+
* round-trips a constrained, wire-safe value vocabulary; anything else in
|
|
1392
|
+
* the file is preserved untouched and surfaced as `{ type: 'unknown' }`.
|
|
1393
|
+
*
|
|
1394
|
+
* Reads are lossless-tagged (a PDF name and a PDF string both arrive as
|
|
1395
|
+
* JS strings, so the tag is what keeps them distinguishable); writes take
|
|
1396
|
+
* plain JS values, with `{ name: '...' }` as the one wrapper needed to
|
|
1397
|
+
* request a PDF name. `/LastModified` bookkeeping (application dict, page
|
|
1398
|
+
* dict, doc /Info /ModDate) is engine-managed on every write.
|
|
1399
|
+
*/
|
|
1400
|
+
/** One `/Private` value as read from the file. */
|
|
1401
|
+
type PieceInfoEntry = {
|
|
1402
|
+
type: 'string';
|
|
1403
|
+
value: string;
|
|
1404
|
+
} | {
|
|
1405
|
+
type: 'name';
|
|
1406
|
+
value: string;
|
|
1407
|
+
} | {
|
|
1408
|
+
type: 'number';
|
|
1409
|
+
value: number;
|
|
1410
|
+
} | {
|
|
1411
|
+
type: 'boolean';
|
|
1412
|
+
value: boolean;
|
|
1413
|
+
} | {
|
|
1414
|
+
type: 'string-array';
|
|
1415
|
+
value: string[];
|
|
1416
|
+
} |
|
|
1417
|
+
/** Present in the file but outside the supported vocabulary — preserved
|
|
1418
|
+
* by writes to sibling keys, not readable through this API. */
|
|
1419
|
+
{
|
|
1420
|
+
type: 'unknown';
|
|
1421
|
+
};
|
|
1422
|
+
/** A write value: plain JS, `{ name }` requests a PDF name, `null` deletes. */
|
|
1423
|
+
type PieceInfoPatchValue = string | number | boolean | readonly string[] | {
|
|
1424
|
+
name: string;
|
|
1425
|
+
};
|
|
1426
|
+
type PieceInfoPatch = Record<string, PieceInfoPatchValue | null>;
|
|
1427
|
+
interface PieceInfoSnapshot {
|
|
1428
|
+
/** The application's `/Private` entries, keyed by PDF key name. */
|
|
1429
|
+
entries: Record<string, PieceInfoEntry>;
|
|
1430
|
+
/** The application data dict's `/LastModified` (null if absent). */
|
|
1431
|
+
modifiedAt: IsoDateTime | null;
|
|
1432
|
+
}
|
|
1433
|
+
//#endregion
|
|
1434
|
+
//#region src/engine/PieceInfoService.d.ts
|
|
1435
|
+
/** Result of `pieceInfo.update()`: the application's data after the write. */
|
|
1436
|
+
interface PieceInfoUpdateResult {
|
|
1437
|
+
pieceInfo: PieceInfoSnapshot | null;
|
|
1438
|
+
meta: MutationMeta;
|
|
1439
|
+
}
|
|
1440
|
+
/** Result of `pieceInfo.delete()`: nothing exists after it, so only `meta`. */
|
|
1441
|
+
interface PieceInfoDeleteResult {
|
|
1442
|
+
meta: MutationMeta;
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Access to `/PieceInfo` private application data (ISO 32000 §14.5). The
|
|
1446
|
+
* same interface serves both levels — `DocumentHandle.pieceInfo?` reads and
|
|
1447
|
+
* writes the catalog's `/PieceInfo`, `PageHandle.pieceInfo?` the page's —
|
|
1448
|
+
* mirroring the native API's doc/page symmetry.
|
|
1449
|
+
*
|
|
1450
|
+
* Optional on the contract while the cloud endpoints ship (the
|
|
1451
|
+
* `downloadLayer?` pattern): the local engine implements it; the cloud
|
|
1452
|
+
* engine omits it until a cloud consumer exists (writes there also need an
|
|
1453
|
+
* authorization-scope decision — currently they ride `doc.metadata.modify`
|
|
1454
|
+
* locally). Feature-detect with `handle.pieceInfo !== undefined`.
|
|
1455
|
+
*
|
|
1456
|
+
* Writes are engine-managed for spec bookkeeping: every update refreshes
|
|
1457
|
+
* the application dict's `/LastModified`, the page's `/LastModified`
|
|
1458
|
+
* (required once `/PieceInfo` is present), and — for catalog writes — the
|
|
1459
|
+
* document `/Info` `/ModDate`. No document event is published: piece data
|
|
1460
|
+
* is private app state, not rendered document state.
|
|
1461
|
+
*/
|
|
1462
|
+
interface PieceInfoService {
|
|
1463
|
+
/**
|
|
1464
|
+
* The application's data, or null when the holder has no well-formed
|
|
1465
|
+
* entry for it. Unknown value types arrive as `{ type: 'unknown' }` and
|
|
1466
|
+
* survive sibling writes untouched.
|
|
1467
|
+
*/
|
|
1468
|
+
get(application: string): AbortablePromise<PieceInfoSnapshot | null>;
|
|
1469
|
+
/**
|
|
1470
|
+
* Merge-write entries into the application's `/Private` dictionary:
|
|
1471
|
+
* strings/numbers/booleans/string-arrays write as the corresponding PDF
|
|
1472
|
+
* types, `{ name }` writes a PDF name, `null` deletes the key. One call
|
|
1473
|
+
* is one worker job — atomic with respect to every other engine
|
|
1474
|
+
* operation on this document.
|
|
1475
|
+
*/
|
|
1476
|
+
update(application: string, patch: PieceInfoPatch, options?: WriteOptions): AbortablePromise<PieceInfoUpdateResult>;
|
|
1477
|
+
/** Application names present under this holder's `/PieceInfo`. */
|
|
1478
|
+
list(): AbortablePromise<string[]>;
|
|
1479
|
+
/** Remove the application's entire entry (sibling applications survive). */
|
|
1480
|
+
delete(application: string, options?: WriteOptions): AbortablePromise<PieceInfoDeleteResult>;
|
|
1481
|
+
}
|
|
1482
|
+
//#endregion
|
|
1483
|
+
//#region src/engine/LocalPageHandle.d.ts
|
|
1484
|
+
/**
|
|
1485
|
+
* A page of a document the local engine opened (`LocalDocumentHandle.page()`):
|
|
1486
|
+
* the shared {@link PageHandle}, its raw pixels and its `/PieceInfo`.
|
|
1487
|
+
*/
|
|
1488
|
+
interface LocalPageHandle extends PageHandle {
|
|
1489
|
+
readonly annotations: LocalPageAnnotationsService;
|
|
1490
|
+
readonly forms: LocalPageFormsService;
|
|
1491
|
+
readonly render: LocalPageRenderService;
|
|
1492
|
+
/**
|
|
1493
|
+
* Page-level `/PieceInfo` private application data (ISO 32000 §14.5), such
|
|
1494
|
+
* as a stamp page's name and subject.
|
|
1495
|
+
*/
|
|
1496
|
+
readonly pieceInfo: PieceInfoService;
|
|
1497
|
+
}
|
|
1498
|
+
/** Whether `page` is a page of a local engine's document, with its raw pixels and `/PieceInfo`. */
|
|
1499
|
+
declare function isLocalPage(page: PageHandle): page is LocalPageHandle;
|
|
1500
|
+
//#endregion
|
|
1501
|
+
//#region src/engine/LocalDocumentHandle.d.ts
|
|
1502
|
+
/**
|
|
1503
|
+
* A document the local engine opened: the shared {@link DocumentHandle} and
|
|
1504
|
+
* what only an engine running PDFium itself can do. Code that takes any
|
|
1505
|
+
* document checks with {@link isLocalDocument}.
|
|
1506
|
+
*/
|
|
1507
|
+
interface LocalDocumentHandle extends DocumentHandle {
|
|
1508
|
+
/** Font embedding and text layout settings of this document (session state). */
|
|
1509
|
+
readonly fonts: DocumentFontSettings;
|
|
1510
|
+
/**
|
|
1511
|
+
* Catalog-level `/PieceInfo` private application data (ISO 32000 §14.5),
|
|
1512
|
+
* such as a stamp library's display name. Per-page piece data lives on
|
|
1513
|
+
* `page(ref).pieceInfo`.
|
|
1514
|
+
*/
|
|
1515
|
+
readonly pieceInfo: PieceInfoService;
|
|
1516
|
+
page(ref: PageRef): LocalPageHandle;
|
|
1517
|
+
with(facts: CallFacts): LocalDocumentHandle;
|
|
1518
|
+
/**
|
|
1519
|
+
* Node only: write the document to a local file without moving its bytes
|
|
1520
|
+
* through JS. An untouched session (no unsaved edits, incremental mode) is
|
|
1521
|
+
* streamed out verbatim; for a signed document, exactly as sealed.
|
|
1522
|
+
*/
|
|
1523
|
+
downloadToFile(path: string, options?: DownloadOptions): AbortablePromise<void>;
|
|
1524
|
+
/**
|
|
1525
|
+
* The saved version this session is on: SHA-256 and length of the loaded
|
|
1526
|
+
* bytes (for a layer session, of its base). Changes only when a signature
|
|
1527
|
+
* completes.
|
|
1528
|
+
*/
|
|
1529
|
+
version(): AbortablePromise<BaseVersionInfo>;
|
|
1530
|
+
/**
|
|
1531
|
+
* Export just this document's layer as a self-contained artifact (the small
|
|
1532
|
+
* overlay diff over the unchanged base), which `open()` takes back with
|
|
1533
|
+
* `{ kind: 'artifact', bytes }`.
|
|
1534
|
+
*/
|
|
1535
|
+
downloadLayer(): AbortablePromise<Uint8Array>;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Whether `doc` is a local engine's document, with its fonts, `/PieceInfo`,
|
|
1539
|
+
* layers, raw pixels and files.
|
|
1540
|
+
*/
|
|
1541
|
+
declare function isLocalDocument(doc: DocumentHandle): doc is LocalDocumentHandle;
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/engine/LocalEngine.d.ts
|
|
1544
|
+
/**
|
|
1545
|
+
* The engine that runs PDFium itself, in the browser or in Node: the shared
|
|
1546
|
+
* {@link Engine} and what only it can do. `localEngine()` returns one, so an
|
|
1547
|
+
* app built on it reaches these without a check; code that takes any engine
|
|
1548
|
+
* checks with {@link isLocalEngine}.
|
|
1549
|
+
*/
|
|
1550
|
+
interface LocalEngine extends Engine {
|
|
1551
|
+
open(input: OpenInput, options?: OpenOptions): AbortablePromise<LocalDocumentHandle>;
|
|
1552
|
+
/**
|
|
1553
|
+
* Start booting the engine (Worker spawn, WASM compile) without doing any
|
|
1554
|
+
* work. Idempotent and non-blocking: the engine boots on first use anyway,
|
|
1555
|
+
* so this only overlaps that boot with the app's own start.
|
|
1556
|
+
*/
|
|
1557
|
+
warmup(): void;
|
|
1558
|
+
/** Runtime font registration and fallback fonts. See {@link FontService}. */
|
|
1559
|
+
readonly fonts: FontService;
|
|
1560
|
+
}
|
|
1561
|
+
/** Whether `engine` is the local engine, with its fonts and `warmup()`. */
|
|
1562
|
+
declare function isLocalEngine(engine: Engine): engine is LocalEngine;
|
|
1563
|
+
//#endregion
|
|
1564
|
+
export { FormRepairOptions as $, PageHandle as A, CustomMetadataService as B, DocumentEventStream as C, DocumentEventOf as D, DocumentEventInit as E, LocalPageFormsService as F, EngineRenderPolicy as G, DocumentSearchService as H, PageFormsService as I, snapFullPageViewport as J, appearanceLatticeScale as K, LocalPageAnnotationsService as L, PageTextService as M, LocalPageRenderService as N, DocumentEventType as O, PageRenderService as P, DocumentFormsService as Q, PageAnnotationsService as R, WorkingSetPage as S, DocumentEvent as T, CONTINUOUS_RENDER_POLICY as U, DocumentSignaturesService as V, DocumentRenderService as W, DocumentRedactionService as X, snapTileScale as Y, DocumentPagesService as Z, Engine as _, LocalPageHandle as a, CallFacts as b, PieceInfoService as c, PieceInfoPatch as d, DocumentAttachmentsService as et, PieceInfoPatchValue as f, FontService as g, FontEmbeddingPolicy as h, isLocalDocument as i, PageMeasureService as j, EventOrigin as k, PieceInfoUpdateResult as l, DocumentFontSettings as m, isLocalEngine as n, DocumentActionsService as nt, isLocalPage as o, PieceInfoSnapshot as p, snapAppearanceScale as q, LocalDocumentHandle as r, PieceInfoDeleteResult as s, LocalEngine as t, DocumentAnnotationsService as tt, PieceInfoEntry as u, EngineFactory as v, subscribeToType as w, CallPriority as x, DocumentHandle as y, MetadataService as z };
|
|
1565
|
+
//# sourceMappingURL=LocalEngine-DFoBm4B3.d.cts.map
|