@embedpdf/engine-core 3.0.0-next.14 → 3.0.0-next.16

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