@embedpdf/engine-services 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.
- package/dist/index.cjs +16810 -9943
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1688 -649
- package/dist/index.d.ts +1688 -649
- package/dist/index.js +16861 -10007
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ActionReadBudget, AnalyzeInput, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult,
|
|
1
|
+
import { ActionReadBudget, AnalyzeInput, Annotation, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationAuthority, AnnotationCreateResult, AnnotationDeleteResult, AnnotationDraft, AnnotationExportSelection, AnnotationFamily, AnnotationFlattenResult, AnnotationImportResult, AnnotationList, AnnotationListMutationMeta, AnnotationPatch, AnnotationRef, AnnotationReplyType, AnnotationUpdateResult, Attachment, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileBase, AttachmentFileInfo, AttachmentFileWorkerPayload, AttachmentMutationMeta, AttachmentRef, BaseVersionInfo, BundleImportPages, BundleLimits, ChangeAnalysis, ChangeAuthority, ChangeItem, ChangeItemType, ChangeRecordPayload, ChangeResult, Coordinates, CustomMetadata, CustomMetadataPatch, CustomMetadataUpdateResult, DateInput, DigestAlgorithm, DocumentActionsSnapshot, DocumentMetadata, DocumentProtection, DocumentSecurityProbeInfo, DocumentVersionRef, EngineError, FieldPosition, FontIdentityInfo, FormExportSelection, FormFieldDTO, FormFieldDisplay, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormResetResult, FormSetValueResult, FormSnapshot, FormValuesImportDrop, FormWidget, IsoDateTime, MetadataPatch, MetadataUpdateResult, ObjectNumberRange, OutlineItemPatch, OutlineItemRef, PageCoordinates, PageDeleteResult, PageExtractFlatten, PageFlattenResult, PageFlattenUsage, PageGeometryRun, PageGeometrySnapshot, PageInsertBlankSpec, PageInsertResult, PageListSnapshot, PageNameInput, PageNameResult, PageNetworkRenderFormat, PageObjectNumber, PagePosition, PageRaster, PageRef, PageRemoveNameInput, PageRenderOptions, PageReorderResult, PageRotateResult, PageTextSnapshot, PdfActionTree, PdfCoordinates, PdfDestination, PdfQuad, PdfRect, PdfRevision, PdfRotation, PdfSaveMode, RecordedOp, RedactionApplyResult, RedactionApplyScope, RevisionStructure, SearchScanRequest, SearchSlice, SerializedEngineError, SignatureCancelResult, SignatureCompleteInput, SignatureCompleteResult, SignatureDTO, SignaturePrepareInput, SignaturePrepared, SignatureSnapshot, SignedDocumentPolicy, VisibleBoxOf, WidgetAnnotation, WidgetPlacement, WireAnnotationBundle, WireAnnotationResources, WireFormBundle, WirePack, WireResource, WorkerRequest, WorkerResponse, WorkingSetPage, generateUuid } from "@embedpdf/engine-core/runtime";
|
|
2
2
|
import { PdfFunctions, PdfRuntimeMemory, PdfRuntimeModule, Ptr } from "@embedpdf/engine-runtime";
|
|
3
|
+
import { PlannedValueWrite } from "@embedpdf/engine-core/validation";
|
|
3
4
|
//#region src/runtime/lifecycle/bootstrap.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Initialize the thread-confined PDFium runtime for the calling thread. Each
|
|
@@ -15,67 +16,29 @@ declare function destroyLibrary(runtime: PdfRuntimeModule): void;
|
|
|
15
16
|
//#endregion
|
|
16
17
|
//#region src/shared/abort.d.ts
|
|
17
18
|
/**
|
|
18
|
-
* Throw if the AbortSignal has been aborted. Service code
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* Throw if the AbortSignal has been aborted. Service code calls this between
|
|
20
|
+
* PDFium calls. It only sees an abort the thread has received, and a worker
|
|
21
|
+
* thread receives messages only while it awaits: work that never pauses (see
|
|
22
|
+
* `Slices`) sees an abort sent while it ran only when it is done.
|
|
21
23
|
*/
|
|
22
24
|
declare function throwIfAborted(signal: AbortSignal): void;
|
|
23
25
|
//#endregion
|
|
24
|
-
//#region src/shared/uuid.d.ts
|
|
25
|
-
/**
|
|
26
|
-
* Generate an RFC 4122 v4 UUID using the Web Crypto API surface that's
|
|
27
|
-
* available in every realm we ship to: Node 19+ (global), Web Workers,
|
|
28
|
-
* browsers (https), browsers (http/intranet/file:), and Edge runtimes.
|
|
29
|
-
*
|
|
30
|
-
* Why this implementation, exactly:
|
|
31
|
-
* - `crypto.randomUUID()` was historically gated to *secure contexts*
|
|
32
|
-
* in older browsers and we shipped that bug to production once.
|
|
33
|
-
* `getRandomValues()` has no such restriction.
|
|
34
|
-
* - `import { randomUUID } from 'crypto'` makes Vite externalize the
|
|
35
|
-
* `crypto` module for browser builds and emit a build-time warning;
|
|
36
|
-
* we then crash at runtime in the rare path that hits it.
|
|
37
|
-
* - 16 bytes + RFC 4122 bit-twiddling is six lines and correct.
|
|
38
|
-
*
|
|
39
|
-
* Output is the canonical hex form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`,
|
|
40
|
-
* where `y` is one of `8/9/a/b` (variant nibble = 10xx).
|
|
41
|
-
*/
|
|
42
|
-
declare function generateUuid(): string;
|
|
43
|
-
//#endregion
|
|
44
26
|
//#region src/shared/pdf-date.d.ts
|
|
45
27
|
/**
|
|
46
|
-
* PDF date
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* The wire format used by the engine DTOs is always ISO 8601;
|
|
53
|
-
* readers convert PDF → ISO via {@link pdfDateToIso}, writers convert
|
|
54
|
-
* the other way via {@link formatPdfDate}.
|
|
28
|
+
* A PDF date as ISO 8601, keeping its offset: zero reads as `Z`, and a date
|
|
29
|
+
* without an offset reads without one. Fields the date leaves out take the
|
|
30
|
+
* spec's defaults (month and day 1, the rest 0). The `D:` prefix and the
|
|
31
|
+
* apostrophes of the offset are optional, as readers in the wild treat them.
|
|
32
|
+
* Returns `null` when the text isn't a date.
|
|
55
33
|
*/
|
|
34
|
+
declare function pdfDateToIso(pdf: string): IsoDateTime | null;
|
|
56
35
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* unknown. Since the engine DTO wire format requires an absolute ISO 8601
|
|
62
|
-
* timestamp, this converter retains the pre-existing fallback of treating
|
|
63
|
-
* an omitted timezone as UTC.
|
|
64
|
-
*/
|
|
65
|
-
declare function pdfDateToIso(pdf: string): string | null;
|
|
66
|
-
/**
|
|
67
|
-
* Format a JS Date as a PDF date string `D:YYYYMMDDHHmmSSOHH'mm'`.
|
|
68
|
-
*
|
|
69
|
-
* Emits the offset in PDF's funny `OHH'mm'` form, where the apostrophe
|
|
70
|
-
* after the hour is literal and the offset always carries a sign. UTC
|
|
71
|
-
* is emitted as `+00'00'` (not `Z`) for maximum reader compatibility —
|
|
72
|
-
* the `Z` shorthand is allowed by the spec but not universally
|
|
73
|
-
* supported.
|
|
74
|
-
*
|
|
75
|
-
* Always uses the supplied Date's local fields and offset. For
|
|
76
|
-
* server-side stamps callers typically pass `new Date()` (default).
|
|
36
|
+
* A moment as a PDF date. A string keeps its own offset (none if it has
|
|
37
|
+
* none); a `Date` is an instant, written in UTC. A fraction of a second is
|
|
38
|
+
* dropped: PDF dates have whole seconds. UTC is written as `+00'00'` rather
|
|
39
|
+
* than `Z`, which some readers don't accept.
|
|
77
40
|
*/
|
|
78
|
-
declare function formatPdfDate(
|
|
41
|
+
declare function formatPdfDate(value?: DateInput): string;
|
|
79
42
|
//#endregion
|
|
80
43
|
//#region src/runtime/memory/bits.d.ts
|
|
81
44
|
/**
|
|
@@ -97,51 +60,37 @@ declare const normalizeU32: typeof u32;
|
|
|
97
60
|
/** True when `bits` grants every standard security permission. */
|
|
98
61
|
declare function hasAllStandardSecurityPermissions(bits: number): boolean;
|
|
99
62
|
//#endregion
|
|
100
|
-
//#region src/
|
|
63
|
+
//#region src/document-session/DrawingIndex.d.ts
|
|
101
64
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* mutations — listeners never learn which transport delivered an event.
|
|
65
|
+
* An open document's stamp drawings, known by content, so stamps with the
|
|
66
|
+
* same artwork place one drawing. It lives in memory for as long as the
|
|
67
|
+
* native document does; nothing of it is written into the PDF, and a reopen
|
|
68
|
+
* rebuilds it from what the drawings are then.
|
|
107
69
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* blocking other listeners or failing the mutation path;
|
|
113
|
-
* - `lastServerId` tracks the highest remote cursor seen, for the
|
|
114
|
-
* remote channel's reconnect/backfill.
|
|
115
|
-
*/
|
|
116
|
-
declare class EventHub implements DocumentEventStream {
|
|
117
|
-
/** Where a throwing listener's error goes. Defaults to an async
|
|
118
|
-
* rethrow so it reaches the host's unhandled-error reporting. */
|
|
119
|
-
private readonly onListenerError;
|
|
120
|
-
private readonly listeners;
|
|
121
|
-
private serverId;
|
|
122
|
-
constructor(
|
|
123
|
-
/** Where a throwing listener's error goes. Defaults to an async
|
|
124
|
-
* rethrow so it reaches the host's unhandled-error reporting. */
|
|
125
|
-
onListenerError?: (err: unknown) => void);
|
|
126
|
-
subscribe(listener: (event: DocumentEvent) => void): () => void;
|
|
127
|
-
publish(event: DocumentEvent): void;
|
|
128
|
-
lastServerId(): number | null;
|
|
129
|
-
/** Drop every listener (handle close). Idempotent. */
|
|
130
|
-
clear(): void;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Stamps provenance onto events a mutation path produces. One per open
|
|
134
|
-
* handle: the engine shell constructs it with the instance's `sessionId`
|
|
135
|
-
* (and, on cloud, the authenticated `sub` when known) and hands it to the
|
|
136
|
-
* mutation services — they publish results, never build origins.
|
|
70
|
+
* Both maps stay true because no writer edits a drawing in place: a stamp
|
|
71
|
+
* that changes gets a new wrapper, and new artwork is a new drawing. Anything
|
|
72
|
+
* that deletes objects or reuses object numbers (a rollback) must call
|
|
73
|
+
* {@link DrawingIndex.forget}.
|
|
137
74
|
*/
|
|
138
|
-
declare class
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
75
|
+
declare class DrawingIndex {
|
|
76
|
+
/**
|
|
77
|
+
* Content id (the SHA-256, in hex, of a drawing's canonical bytes) → the
|
|
78
|
+
* drawing's object number. `null` until the first lookup builds it from
|
|
79
|
+
* the drawings the document's stamps place.
|
|
80
|
+
*/
|
|
81
|
+
byContent: Map<string, number> | null;
|
|
82
|
+
/**
|
|
83
|
+
* SHA-256 (hex) of bytes as a caller gave them → the drawing made from
|
|
84
|
+
* them, so placing the same bytes again skips making the drawing.
|
|
85
|
+
*/
|
|
86
|
+
readonly bySource: Map<string, number>;
|
|
87
|
+
/**
|
|
88
|
+
* SHA-256 (hex) of bytes already hashed, by the buffer holding them. The
|
|
89
|
+
* stamps of one import share one buffer per resource, so it is copied and
|
|
90
|
+
* hashed once. A fact about the bytes, so {@link forget} keeps it.
|
|
91
|
+
*/
|
|
92
|
+
readonly hashes: WeakMap<ArrayBuffer, string>;
|
|
93
|
+
forget(): void;
|
|
145
94
|
}
|
|
146
95
|
//#endregion
|
|
147
96
|
//#region src/document-session/lifecycle/PdfDocumentOpener.d.ts
|
|
@@ -202,38 +151,198 @@ declare class CloseStack {
|
|
|
202
151
|
declare function openFatMemoryDocument(runtime: PdfRuntimeModule, bytes: Uint8Array, password?: string | null): OpenedPdfDocument;
|
|
203
152
|
declare function openLayerDocument(runtime: PdfRuntimeModule, base: AcquiredBaseDocument, layer?: LayerSource, password?: string | null): OpenedPdfDocument;
|
|
204
153
|
//#endregion
|
|
154
|
+
//#region src/shared/slices.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* How long work runs before it lets the thread receive messages. PDFium works
|
|
157
|
+
* for `budgetMs` at a time - a slice of a page render or of a page load - and
|
|
158
|
+
* the caller awaits `between()` before it goes on, so the thread can receive
|
|
159
|
+
* messages meanwhile: an abort stops the work at the next slice. The result is
|
|
160
|
+
* that of the work done at once, however it is sliced.
|
|
161
|
+
*/
|
|
162
|
+
interface Slices {
|
|
163
|
+
readonly budgetMs: number;
|
|
164
|
+
between(): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/document-session/pages/PageResidency.d.ts
|
|
168
|
+
/**
|
|
169
|
+
* The parsed pages of every document on one runtime - one WASM heap, or one
|
|
170
|
+
* server thread - kept within a budget of bytes.
|
|
171
|
+
*
|
|
172
|
+
* Parsing a page is the costly part of using it: seconds for a page of
|
|
173
|
+
* millions of vector objects, where one tile of it renders in milliseconds.
|
|
174
|
+
* So a page stays parsed after the job that used it, for the next one, as long
|
|
175
|
+
* as memory allows:
|
|
176
|
+
* - A page costs what its parse made (`EPDFPage_GetParsedSize`) and a fixed
|
|
177
|
+
* overhead for the page itself.
|
|
178
|
+
* - Room is made before a page loads, for its size when it was last open, and
|
|
179
|
+
* again after every slice of a load, as the page grows. A page a job holds
|
|
180
|
+
* never closes, so one page may be over the budget on its own: the one a
|
|
181
|
+
* job needs.
|
|
182
|
+
* - A page bigger than the whole budget stays parsed after its job too, or
|
|
183
|
+
* every job on it would parse it again: of such pages, the one that would
|
|
184
|
+
* close last is kept, and the budget holds every other page beside it. It
|
|
185
|
+
* closes when the pages jobs hold need the budget's room themselves.
|
|
186
|
+
* - What the viewers show decides what closes first (`setWorkingSet`): pages
|
|
187
|
+
* in no working set, then `near` pages, then `visible` pages from the
|
|
188
|
+
* fewest device pixels on screen up, so a thumbnail rail's pages close
|
|
189
|
+
* before the main view's. Least recently used first among equals.
|
|
190
|
+
* - A render loads its page in slices, between which its job can be aborted.
|
|
191
|
+
* An aborted load is set aside half parsed, and the next job that needs the
|
|
192
|
+
* page goes on with it.
|
|
193
|
+
* - A page whose content changed since it was parsed closes when it is next
|
|
194
|
+
* taken (`EPDFPage_IsContentCurrent`). That sees writes made in layer
|
|
195
|
+
* transactions; the worker host closes a document's pages around the writes
|
|
196
|
+
* that change content in place.
|
|
197
|
+
* - A page's image cache is emptied when its last job releases it, so its next
|
|
198
|
+
* job renders images as a newly loaded page does.
|
|
199
|
+
* - Pages no job uses and no viewer shows close after a while, giving their
|
|
200
|
+
* memory back to the allocator.
|
|
201
|
+
*
|
|
202
|
+
* Pages belong to an owner, one per open document ({@link PagePtrPool}).
|
|
203
|
+
*/
|
|
204
|
+
interface PageResidencyPolicy {
|
|
205
|
+
/**
|
|
206
|
+
* Bytes of parsed pages kept at once; a page a job holds, or one page bigger
|
|
207
|
+
* than the budget, may be over it alone.
|
|
208
|
+
*/
|
|
209
|
+
budgetBytes: number;
|
|
210
|
+
/** Pages no job uses close after this many milliseconds; 0 disables the timer. */
|
|
211
|
+
idleMs: number;
|
|
212
|
+
}
|
|
213
|
+
declare class PageResidency {
|
|
214
|
+
private readonly runtime;
|
|
215
|
+
private readonly policy;
|
|
216
|
+
/**
|
|
217
|
+
* True while a job is between two of its steps, such as a page render
|
|
218
|
+
* between slices, when nothing else may use PDFium: the idle timer then
|
|
219
|
+
* waits another period instead of closing pages.
|
|
220
|
+
*/
|
|
221
|
+
private readonly busy;
|
|
222
|
+
private readonly pages;
|
|
223
|
+
/** What each closed page cost when it was last open: the room its next load needs. */
|
|
224
|
+
private readonly closedSizes;
|
|
225
|
+
/** Per owner, per view: where the pages it shows are (see {@link setWorkingSet}). */
|
|
226
|
+
private readonly workingSets;
|
|
227
|
+
private totalBytes;
|
|
228
|
+
private clock;
|
|
229
|
+
private timer;
|
|
230
|
+
constructor(runtime: PdfRuntimeModule, policy?: PageResidencyPolicy,
|
|
231
|
+
/**
|
|
232
|
+
* True while a job is between two of its steps, such as a page render
|
|
233
|
+
* between slices, when nothing else may use PDFium: the idle timer then
|
|
234
|
+
* waits another period instead of closing pages.
|
|
235
|
+
*/
|
|
236
|
+
busy?: () => boolean);
|
|
237
|
+
/** The page, loaded in one go when it isn't parsed; held until {@link release}. */
|
|
238
|
+
acquire(owner: object, docPtr: Ptr, pageObjectNumber: PageObjectNumber): Ptr;
|
|
239
|
+
/**
|
|
240
|
+
* The page, loaded in slices when it isn't parsed: between slices the
|
|
241
|
+
* caller's thread receives messages, and an abort stops the load there. An
|
|
242
|
+
* aborted load is set aside, to go on when a job next needs the page. Held
|
|
243
|
+
* until {@link release}.
|
|
244
|
+
*/
|
|
245
|
+
acquireInSlices(owner: object, docPtr: Ptr, pageObjectNumber: PageObjectNumber, signal: AbortSignal, slices: Slices): Promise<Ptr>;
|
|
246
|
+
/** A job is done with the page; it stays parsed while there is room. */
|
|
247
|
+
release(owner: object, pageObjectNumber: PageObjectNumber): void;
|
|
248
|
+
/**
|
|
249
|
+
* What `view` shows of `owner`'s pages, replacing its last set; an empty set
|
|
250
|
+
* withdraws it. Decides which kept pages close first (see the class notes).
|
|
251
|
+
* Only bookkeeping: it touches no PDFium state, so it may run mid-render.
|
|
252
|
+
*/
|
|
253
|
+
setWorkingSet(owner: object, view: string, pages: Iterable<{
|
|
254
|
+
pageObjectNumber: PageObjectNumber;
|
|
255
|
+
} & Pick<WorkingSetPage, 'role' | 'pixels'>>): void;
|
|
256
|
+
/** True while a job holds the page; an idle page is not held. */
|
|
257
|
+
isHeld(owner: object, pageObjectNumber: PageObjectNumber): boolean;
|
|
258
|
+
/** True while the page is kept, parsed or loading: a job for it parses nothing new. */
|
|
259
|
+
isKept(owner: object, pageObjectNumber: PageObjectNumber): boolean;
|
|
260
|
+
/** Closes every page of `owner`, held or not: its document closes. */
|
|
261
|
+
closeOwner(owner: object): void;
|
|
262
|
+
/** Closes the pages of `owner` no job holds: a write changed its content in place. */
|
|
263
|
+
closeIdleOf(owner: object): void;
|
|
264
|
+
/** Closes every page no job holds. */
|
|
265
|
+
closeIdle(): void;
|
|
266
|
+
/** Closes the pages no job holds and no viewer shows on screen: the idle timer. */
|
|
267
|
+
private closeUnshown;
|
|
268
|
+
/** Pages kept, held or not (tests and diagnostics). */
|
|
269
|
+
get size(): number;
|
|
270
|
+
/** What the pages kept cost, as last measured (tests and diagnostics). */
|
|
271
|
+
get bytes(): number;
|
|
272
|
+
/** The page when it is kept, unless its content changed meanwhile. */
|
|
273
|
+
private take;
|
|
274
|
+
private add;
|
|
275
|
+
private measure;
|
|
276
|
+
private expectedBytes;
|
|
277
|
+
/**
|
|
278
|
+
* Closes pages no job holds until `incoming` more bytes fit: the worst
|
|
279
|
+
* placed first (see the class notes), least recently used first among
|
|
280
|
+
* equals.
|
|
281
|
+
*
|
|
282
|
+
* A page bigger than the budget on its own may stay over it: of such pages,
|
|
283
|
+
* the one that would close last. So it stays parsed between the jobs that
|
|
284
|
+
* use it, instead of parsing again for each one. Every other page fits in
|
|
285
|
+
* the budget beside it; when the pages jobs hold don't, they are the pages
|
|
286
|
+
* over it, and the spared page closes too. A budget of 0 keeps nothing.
|
|
287
|
+
*/
|
|
288
|
+
private makeRoom;
|
|
289
|
+
/** The page no job holds that closes first, other than `spared`. */
|
|
290
|
+
private firstToClose;
|
|
291
|
+
/**
|
|
292
|
+
* Of the pages bigger than the budget, the one that closes last: the best
|
|
293
|
+
* placed, the most recently used among equals.
|
|
294
|
+
*/
|
|
295
|
+
private lastToCloseOverBudget;
|
|
296
|
+
/** Where the working sets have the page: the best place any view gives it. */
|
|
297
|
+
private placeOf;
|
|
298
|
+
private close;
|
|
299
|
+
/** Closes the page without remembering its size. */
|
|
300
|
+
private drop;
|
|
301
|
+
private armTimer;
|
|
302
|
+
private disarmTimer;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
205
305
|
//#region src/document-session/pages/PagePtrPool.d.ts
|
|
206
306
|
/**
|
|
207
|
-
*
|
|
307
|
+
* The pages of one open `DocumentSession`, kept by the runtime's
|
|
308
|
+
* {@link PageResidency}.
|
|
208
309
|
*
|
|
209
|
-
* `acquire(pon)` returns
|
|
210
|
-
*
|
|
211
|
-
* to 0deg so render
|
|
212
|
-
* normalized space)
|
|
213
|
-
*
|
|
214
|
-
*
|
|
310
|
+
* `acquire(pon)` returns the page with that PDF object number, loaded with
|
|
311
|
+
* `EPDFDoc_LoadPageByObjectNumberNormalized` when it isn't kept (rotation
|
|
312
|
+
* forced to 0deg, so render, text, geometry and annotation coordinates all
|
|
313
|
+
* share one normalized space); `acquireInSlices` loads it in slices, for a
|
|
314
|
+
* render. Overlapping acquires of one page share it; `release(pon)` hands it
|
|
315
|
+
* back to the residency, which keeps it parsed while there is room.
|
|
316
|
+
* `closeAll()` is called by `DocumentSession.close()`.
|
|
215
317
|
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* load. Once the refcount reaches zero the page is closed; a later
|
|
219
|
-
* `acquire` reloads it — there is no LRU retention across the zero-ref
|
|
220
|
-
* boundary. A future slice could add that without changing callers.
|
|
318
|
+
* A session made without a residency (a one-off render of a file) gets one
|
|
319
|
+
* of its own that keeps nothing: its pages close when released.
|
|
221
320
|
*/
|
|
222
321
|
declare class PagePtrPool {
|
|
223
|
-
private readonly runtime;
|
|
224
322
|
private readonly docPtr;
|
|
225
|
-
private readonly
|
|
226
|
-
constructor(runtime: PdfRuntimeModule, docPtr: Ptr);
|
|
323
|
+
private readonly residency;
|
|
324
|
+
constructor(runtime: PdfRuntimeModule, docPtr: Ptr, residency?: PageResidency | null);
|
|
227
325
|
acquire(pageObjectNumber: PageObjectNumber): Ptr;
|
|
326
|
+
/** {@link acquire}, loading the page in slices between which `signal` can abort. */
|
|
327
|
+
acquireInSlices(pageObjectNumber: PageObjectNumber, signal: AbortSignal, slices: Slices): Promise<Ptr>;
|
|
228
328
|
/**
|
|
229
|
-
* True while at least one holder has the page open
|
|
230
|
-
*
|
|
231
|
-
* job can be mid-flight, so a
|
|
232
|
-
* is a leaked `acquire` (an
|
|
233
|
-
* instead of mutating under a live
|
|
329
|
+
* True while at least one holder has the page open; a page the residency
|
|
330
|
+
* keeps between jobs is not held. Page-structure mutations (delete) assert
|
|
331
|
+
* on this: thread confinement means no other job can be mid-flight, so a
|
|
332
|
+
* held pagePtr during a structural mutation is a leaked `acquire` (an
|
|
333
|
+
* internal bug) - the mutator fails loudly instead of mutating under a live
|
|
334
|
+
* handle.
|
|
234
335
|
*/
|
|
235
336
|
isHeld(pageObjectNumber: PageObjectNumber): boolean;
|
|
337
|
+
/** True while the residency keeps the page, parsed or loading, held or not. */
|
|
338
|
+
isKept(pageObjectNumber: PageObjectNumber): boolean;
|
|
236
339
|
release(pageObjectNumber: PageObjectNumber): void;
|
|
340
|
+
/** What `view` shows of the document, replacing its last set (see {@link PageResidency}). */
|
|
341
|
+
setWorkingSet(view: string, pages: Iterable<{
|
|
342
|
+
pageObjectNumber: PageObjectNumber;
|
|
343
|
+
} & Pick<WorkingSetPage, 'role' | 'pixels'>>): void;
|
|
344
|
+
/** Closes the pages no job holds: a write changed the document's content in place. */
|
|
345
|
+
closeIdle(): void;
|
|
237
346
|
closeAll(): void;
|
|
238
347
|
}
|
|
239
348
|
//#endregion
|
|
@@ -242,7 +351,7 @@ declare class PagePtrPool {
|
|
|
242
351
|
* Record of one page within a `DocumentSession`. Built lazily by
|
|
243
352
|
* `DocumentSession.ensurePageRegistry()`; the registry is only forced
|
|
244
353
|
* to populate fully when a path that needs `pageIndex -> pageObjectNumber`
|
|
245
|
-
* for the whole document is invoked (most notably
|
|
354
|
+
* for the whole document is invoked (most notably a whole-document annotation list).
|
|
246
355
|
*
|
|
247
356
|
* Carries no `pagePtr`. Lifetime of the actual PDFium page handle is owned
|
|
248
357
|
* by the `PagePtrPool`; the page record is metadata only.
|
|
@@ -254,10 +363,9 @@ interface PageRecord {
|
|
|
254
363
|
//#endregion
|
|
255
364
|
//#region src/document-session/DocumentSession.d.ts
|
|
256
365
|
/**
|
|
257
|
-
* Owns the lifecycle of a single open PDFium document and the
|
|
258
|
-
* identity machinery: page registry (pageObjectNumber <-> pageIndex)
|
|
259
|
-
* `
|
|
260
|
-
* (refcounted pagePtr access).
|
|
366
|
+
* Owns the lifecycle of a single open PDFium document and the
|
|
367
|
+
* identity machinery: page registry (pageObjectNumber <-> pageIndex) and
|
|
368
|
+
* `PagePtrPool` (refcounted pagePtr access).
|
|
261
369
|
*
|
|
262
370
|
* Both the local browser Worker and the server worker_thread instantiate
|
|
263
371
|
* this exactly the same way; the only thing that differs is the
|
|
@@ -300,6 +408,11 @@ interface SigningCompletion {
|
|
|
300
408
|
readonly cms: Uint8Array;
|
|
301
409
|
readonly result: SignatureCompleteResult;
|
|
302
410
|
}
|
|
411
|
+
/** What every meta of a write carries: its id, and whether it can be undone. */
|
|
412
|
+
interface WriteStamp {
|
|
413
|
+
readonly opId: string;
|
|
414
|
+
readonly undoable: boolean;
|
|
415
|
+
}
|
|
303
416
|
declare class DocumentSession {
|
|
304
417
|
private readonly runtime;
|
|
305
418
|
private docPtr;
|
|
@@ -312,33 +425,36 @@ declare class DocumentSession {
|
|
|
312
425
|
/** pageIndex -> record */
|
|
313
426
|
private readonly recordsByIndex;
|
|
314
427
|
private fullyEnumerated;
|
|
315
|
-
|
|
316
|
-
private
|
|
428
|
+
/** Bumped by {@link invalidateDerived}: the version caches built from the document key on. */
|
|
429
|
+
private cacheSeqCounter;
|
|
430
|
+
/** Bumped by {@link noteEdit}: one per committed write, never inside or for an abort. */
|
|
431
|
+
private editsSeqCounter;
|
|
432
|
+
/** The open layer transaction, if any (see {@link beginTransaction}). */
|
|
433
|
+
private transaction;
|
|
434
|
+
/** Why the session can't be used anymore, after a transaction neither committed nor aborted. */
|
|
435
|
+
private unusableReason;
|
|
317
436
|
private pages;
|
|
437
|
+
/**
|
|
438
|
+
* The runtime's parsed pages, kept between jobs. Set before the document
|
|
439
|
+
* loads; without it every page closes when its last holder releases it.
|
|
440
|
+
*/
|
|
441
|
+
residency: PageResidency | null;
|
|
318
442
|
/**
|
|
319
443
|
* Whether writers honour what the document's signatures forbid (locked
|
|
320
444
|
* fields, structural edits). Set at open from the engine option; the
|
|
321
445
|
* main-thread guard subtracts the matching capabilities.
|
|
322
446
|
*/
|
|
323
447
|
signedDocumentPolicy: SignedDocumentPolicy;
|
|
324
|
-
/**
|
|
325
|
-
* The shape the caller asked for when opening plain bytes. `layer` (the
|
|
326
|
-
* default) opens them as an immutable base with a fresh layer; `plain`
|
|
327
|
-
* keeps one in-memory document unless the bytes already carry a
|
|
328
|
-
* signature, which always opens as a layer.
|
|
329
|
-
*/
|
|
330
|
-
sessionKind: SessionKind;
|
|
331
448
|
/** The password the document was opened with; signing candidates open with the same one. */
|
|
332
449
|
password: string | null;
|
|
333
450
|
/**
|
|
334
451
|
* Whether mutations on a layer session also serialize the layer artifact
|
|
335
|
-
* into their response (what a server persists). False for a session
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* asked for artifacts.
|
|
452
|
+
* into their response (what a server persists). False for a session opened
|
|
453
|
+
* from bytes (`WorkerHost.openBytesAsLayer`): the caller holds the document
|
|
454
|
+
* and never asked for artifacts.
|
|
339
455
|
*/
|
|
340
456
|
persistLayerArtifact: boolean;
|
|
341
|
-
/** The
|
|
457
|
+
/** The edits sequence the current bytes were loaded at (see `hasUnsavedEdits`). */
|
|
342
458
|
private loadedSeq;
|
|
343
459
|
/** SHA-256 (hex) of a plain session's loaded bytes, hashed once per load. */
|
|
344
460
|
private plainSha256;
|
|
@@ -346,6 +462,8 @@ declare class DocumentSession {
|
|
|
346
462
|
pendingSigning: PendingSigning | null;
|
|
347
463
|
/** The last completed signing, so a replayed `complete` answers `already-completed`. */
|
|
348
464
|
lastCompletion: SigningCompletion | null;
|
|
465
|
+
/** The stamp drawings of the open document, by content; dropped with it. */
|
|
466
|
+
private drawings;
|
|
349
467
|
constructor(runtime: PdfRuntimeModule, sessionId?: string);
|
|
350
468
|
get sessionId(): string;
|
|
351
469
|
get kind(): OpenedPdfDocumentKind | null;
|
|
@@ -359,8 +477,8 @@ declare class DocumentSession {
|
|
|
359
477
|
open(bytes: Uint8Array, password?: string | null): void;
|
|
360
478
|
openFromHandle(handle: OpenedPdfDocument): void;
|
|
361
479
|
/**
|
|
362
|
-
* Whether
|
|
363
|
-
* false, the loaded bytes
|
|
480
|
+
* Whether a write was committed since the current bytes were loaded. When
|
|
481
|
+
* false, the loaded bytes are the document: a save returns them verbatim
|
|
364
482
|
* and a signing candidate is built straight on them.
|
|
365
483
|
*/
|
|
366
484
|
hasUnsavedEdits(): boolean;
|
|
@@ -373,8 +491,9 @@ declare class DocumentSession {
|
|
|
373
491
|
* installs its sealed file. The session id, its page object numbers
|
|
374
492
|
* (an incremental save never renumbers) and its retained resources
|
|
375
493
|
* survive; the old document is closed, every page is re-pinned (its
|
|
376
|
-
*
|
|
377
|
-
*
|
|
494
|
+
* cached pointer dropped), and both sequences
|
|
495
|
+
* advance, so every version-keyed cache rebuilds and the new bytes count as
|
|
496
|
+
* loaded.
|
|
378
497
|
*/
|
|
379
498
|
install(handle: OpenedPdfDocument): void;
|
|
380
499
|
/** The two publish fences a candidate is built on. */
|
|
@@ -382,64 +501,139 @@ declare class DocumentSession {
|
|
|
382
501
|
/**
|
|
383
502
|
* Park this session in the password-locked state: the document could not
|
|
384
503
|
* be loaded because a (correct) password is missing, so the session keeps
|
|
385
|
-
* the already-transferred bytes
|
|
386
|
-
*
|
|
387
|
-
* operation except the password check
|
|
504
|
+
* how to load it (the already-transferred bytes, a base's path, the layer
|
|
505
|
+
* to open) and waits for an unlock attempt. A locked session occupies its
|
|
506
|
+
* docId key like an open one — every operation except the password check
|
|
507
|
+
* rejects with DocPasswordRequired.
|
|
388
508
|
*/
|
|
389
|
-
parkLocked(
|
|
509
|
+
parkLocked(load: (password: string | null) => void): void;
|
|
390
510
|
isLocked(): boolean;
|
|
391
|
-
/**
|
|
392
|
-
|
|
393
|
-
|
|
511
|
+
/**
|
|
512
|
+
* Load a locked session with `password`. A wrong one throws
|
|
513
|
+
* `DocPasswordIncorrect` and leaves the session parked for another try.
|
|
514
|
+
*/
|
|
515
|
+
unlockWith(password: string | null): void;
|
|
516
|
+
private parkedLoad;
|
|
394
517
|
/** Number of pages in the document. */
|
|
395
518
|
pageCount(): number;
|
|
396
519
|
/**
|
|
397
520
|
* Lazily enumerate every page and cache (pageObjectNumber, pageIndex).
|
|
398
|
-
* Necessary before
|
|
521
|
+
* Necessary before a whole-document list and any pon -> pageIndex resolution.
|
|
399
522
|
*/
|
|
400
523
|
ensureFullPageRegistry(): void;
|
|
401
524
|
/** Lookup; populates the cache for one page only on cache miss. */
|
|
402
525
|
recordByObjectNumber(pageObjectNumber: PageObjectNumber): PageRecord;
|
|
526
|
+
/**
|
|
527
|
+
* Resolve a page address to its registry record — the one boundary where
|
|
528
|
+
* a `PageRef` becomes a page object number. Throws `NotFound` for an
|
|
529
|
+
* unknown page.
|
|
530
|
+
*/
|
|
531
|
+
resolvePageRef(ref: PageRef): PageRecord;
|
|
532
|
+
/** `resolvePageRef` over a batch, preserving order. */
|
|
533
|
+
resolvePageRefs(refs: readonly PageRef[]): PageObjectNumber[];
|
|
403
534
|
/** All page records, in display order. Forces full enumeration. */
|
|
404
535
|
allRecords(): PageRecord[];
|
|
405
536
|
/**
|
|
406
537
|
* Drop the cached `pageIndex <-> pageObjectNumber` mapping and force a
|
|
407
538
|
* fresh enumeration on next access. Called by `PagesMutator`
|
|
408
|
-
* after `FPDF_MovePages` shuffles page positions
|
|
409
|
-
* weak-annotation knowledge and per-page revision counters intact, both of
|
|
410
|
-
* which are keyed by durable `pageObjectNumber` and survive a page reorder.
|
|
539
|
+
* after `FPDF_MovePages` shuffles page positions.
|
|
411
540
|
*/
|
|
412
541
|
refreshPageRegistry(): void;
|
|
413
|
-
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
542
|
+
/**
|
|
543
|
+
* The version key for caches built from the document (the forms model,
|
|
544
|
+
* the signature model, search text): an entry built at sequence N is
|
|
545
|
+
* exactly valid while the sequence is still N. Coarse on purpose: widgets
|
|
546
|
+
* are annotations and page edits move widgets, so any write may change
|
|
547
|
+
* derived form state.
|
|
548
|
+
*/
|
|
549
|
+
cacheSeq(): number;
|
|
550
|
+
/**
|
|
551
|
+
* Make every cache keyed on {@link cacheSeq} build again. Writers call it
|
|
552
|
+
* after a write, before they read back; an abort calls it too, because a
|
|
553
|
+
* cache may have been built from what the transaction wrote.
|
|
554
|
+
*/
|
|
555
|
+
invalidateDerived(): void;
|
|
556
|
+
/**
|
|
557
|
+
* The count of committed writes: what {@link hasUnsavedEdits} and a signing
|
|
558
|
+
* candidate's `editsVersion` compare.
|
|
559
|
+
*/
|
|
560
|
+
editsSeq(): number;
|
|
561
|
+
/** Count one committed write. Called once per write, after its commit. */
|
|
562
|
+
noteEdit(): void;
|
|
563
|
+
/** Whether a layer transaction is open (see {@link beginTransaction}). */
|
|
564
|
+
inTransaction(): boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Open a layer transaction: until {@link commitTransaction} or
|
|
567
|
+
* {@link abortTransaction}, every write lands in an overlay that only a
|
|
568
|
+
* commit keeps, and every read sees it. Only a layer document has
|
|
569
|
+
* transactions. `opId` names the write it runs (see {@link writeStamp}).
|
|
570
|
+
*/
|
|
571
|
+
beginTransaction(opId: string): void;
|
|
572
|
+
/**
|
|
573
|
+
* What every meta of the running write carries: its `opId`, and whether
|
|
574
|
+
* it can be undone. A write is undoable once {@link markUndoable} said so,
|
|
575
|
+
* which a write does when it records its reverse.
|
|
576
|
+
*/
|
|
577
|
+
writeStamp(): WriteStamp;
|
|
578
|
+
/** The running write records its reverse, so `{ undoOf: opId }` can undo it. */
|
|
579
|
+
markUndoable(): void;
|
|
580
|
+
/**
|
|
581
|
+
* Keep everything the open transaction wrote. A commit that fails can't
|
|
582
|
+
* say how far it got, so the session becomes unusable.
|
|
583
|
+
*/
|
|
584
|
+
commitTransaction(): void;
|
|
585
|
+
/**
|
|
586
|
+
* Drop everything the open transaction wrote, and forget what this session
|
|
587
|
+
* learned from it. Never throws: it runs while a failure is on its way out,
|
|
588
|
+
* and a failed abort makes the session unusable instead.
|
|
589
|
+
*/
|
|
590
|
+
abortTransaction(): void;
|
|
591
|
+
/**
|
|
592
|
+
* Who decides which object numbers a create may name: `'session'` hands
|
|
593
|
+
* them out ({@link reserveObjectNumbers}) and refuses a number it doesn't
|
|
594
|
+
* hold; `'caller'` checked every number before sending the job (a server
|
|
595
|
+
* that hands numbers to editing sessions).
|
|
596
|
+
*/
|
|
597
|
+
objectNumberAuthority: 'session' | 'caller';
|
|
598
|
+
/** Numbers this session handed out that no committed create has used. */
|
|
599
|
+
private readonly heldObjectNumbers;
|
|
600
|
+
/** Held numbers the open transaction made objects at: spent when it commits. */
|
|
601
|
+
private objectNumbersInUse;
|
|
602
|
+
/** The layer's last object number: every object it has is at or below it. */
|
|
603
|
+
lastObjectNumber(): number;
|
|
604
|
+
/**
|
|
605
|
+
* Raise the layer's last object number to at least `last`, so the objects
|
|
606
|
+
* the next write makes for itself get numbers above it. A raise outlives
|
|
607
|
+
* an abort: numbers once passed are never handed out again.
|
|
608
|
+
*/
|
|
609
|
+
raiseLastObjectNumber(last: number): void;
|
|
610
|
+
/**
|
|
611
|
+
* Hand out `count` more numbers: the layer's last object number moves up
|
|
612
|
+
* by `count`, so nothing the engine makes lands on them, and they are this
|
|
613
|
+
* session's to name objects with.
|
|
614
|
+
*/
|
|
615
|
+
reserveObjectNumbers(count: number): ObjectNumberRange;
|
|
616
|
+
/**
|
|
617
|
+
* Checks the number a create names before anything is written, and counts
|
|
618
|
+
* it as used by the open transaction: spent when it commits, held again
|
|
619
|
+
* if it aborts. A session that hands numbers out refuses one it doesn't
|
|
620
|
+
* hold (`not-held`); a number the transaction already used is `taken`.
|
|
621
|
+
* Nothing else creates objects at held numbers, so a held number is free
|
|
622
|
+
* otherwise; the fork checks that again as it creates.
|
|
623
|
+
*/
|
|
624
|
+
claimObjectNumber(objectNumber: number): void;
|
|
625
|
+
/**
|
|
626
|
+
* Throws once a transaction neither committed nor aborted, so nothing reads
|
|
627
|
+
* or writes a document in an unknown state.
|
|
628
|
+
*/
|
|
629
|
+
assertUsable(): void;
|
|
630
|
+
private requireTransaction;
|
|
439
631
|
pagePool(): PagePtrPool;
|
|
632
|
+
/** The open document's stamp drawings, by content (see {@link DrawingIndex}). */
|
|
633
|
+
drawingIndex(): DrawingIndex;
|
|
440
634
|
requireDocPtr(): Ptr;
|
|
441
635
|
/**
|
|
442
|
-
* Park a disposer to run when
|
|
636
|
+
* Park a disposer to run when this session closes. Used by operations
|
|
443
637
|
* whose native side leaves the session document referencing another
|
|
444
638
|
* resource — e.g. `pages.insert`: `FPDF_ImportPagesByIndex` does not
|
|
445
639
|
* fully detach imported objects from their source document, so the
|
|
@@ -449,7 +643,6 @@ declare class DocumentSession {
|
|
|
449
643
|
retainUntilClose(dispose: () => void): void;
|
|
450
644
|
private readonly retained;
|
|
451
645
|
close(): void;
|
|
452
|
-
private requireRevisions;
|
|
453
646
|
}
|
|
454
647
|
//#endregion
|
|
455
648
|
//#region src/document-session/lifecycle/BaseDocumentRegistry.d.ts
|
|
@@ -492,54 +685,6 @@ declare class BaseDocumentRegistry {
|
|
|
492
685
|
private handleFor;
|
|
493
686
|
}
|
|
494
687
|
//#endregion
|
|
495
|
-
//#region src/document-session/revisions/RevisionAuthority.d.ts
|
|
496
|
-
interface RevisionAuthority {
|
|
497
|
-
readonly docSessionId: string;
|
|
498
|
-
token(pageObjectNumber: PageObjectNumber): RevisionToken;
|
|
499
|
-
bump(pageObjectNumber: PageObjectNumber): RevisionToken;
|
|
500
|
-
validate(token: RevisionToken): void;
|
|
501
|
-
weakAnnotationState(pageObjectNumber: PageObjectNumber): WeakAnnotationState;
|
|
502
|
-
recordWeakAnnotationState(pageObjectNumber: PageObjectNumber, state: WeakAnnotationState): void;
|
|
503
|
-
/** Forget a page entirely (generation + weak state). Called when the page
|
|
504
|
-
* is DELETED — its object number is retired, never recycled, so dropping
|
|
505
|
-
* is hygiene, not correctness. */
|
|
506
|
-
drop(pageObjectNumber: PageObjectNumber): void;
|
|
507
|
-
clear(): void;
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Per-page generation counter. Backs `RevisionToken` so weak
|
|
511
|
-
* `AnnotationRef.kind === 'index'` references can be validated against the
|
|
512
|
-
* exact page state they were minted from.
|
|
513
|
-
*
|
|
514
|
-
* `bump()` is the only mutator; mutation services call it after a
|
|
515
|
-
* structural change to the page (annotation create/delete/reorder).
|
|
516
|
-
* Read paths never mutate the store.
|
|
517
|
-
*/
|
|
518
|
-
declare class LocalRevisionAuthority implements RevisionAuthority {
|
|
519
|
-
readonly docSessionId: string;
|
|
520
|
-
private readonly generations;
|
|
521
|
-
private readonly weakAnnotationStates;
|
|
522
|
-
constructor(docSessionId: string);
|
|
523
|
-
/** Returns the current generation, defaulting to 0 for first read. */
|
|
524
|
-
current(pageObjectNumber: PageObjectNumber): number;
|
|
525
|
-
/** Mints a fresh `RevisionToken` for the page's current generation. */
|
|
526
|
-
token(pageObjectNumber: PageObjectNumber): RevisionToken;
|
|
527
|
-
/**
|
|
528
|
-
* Increments the generation counter for a page. Returns the new token.
|
|
529
|
-
* Called by mutation services after every structural change.
|
|
530
|
-
*/
|
|
531
|
-
bump(pageObjectNumber: PageObjectNumber): RevisionToken;
|
|
532
|
-
/**
|
|
533
|
-
* Strict equality check. Throws `EngineError(InvalidReference)` when the
|
|
534
|
-
* caller's token does not match what the store currently holds.
|
|
535
|
-
*/
|
|
536
|
-
validate(token: RevisionToken): void;
|
|
537
|
-
weakAnnotationState(pageObjectNumber: PageObjectNumber): WeakAnnotationState;
|
|
538
|
-
recordWeakAnnotationState(pageObjectNumber: PageObjectNumber, state: WeakAnnotationState): void;
|
|
539
|
-
drop(pageObjectNumber: PageObjectNumber): void;
|
|
540
|
-
clear(): void;
|
|
541
|
-
}
|
|
542
|
-
//#endregion
|
|
543
688
|
//#region src/features/metadata/MetadataReader.d.ts
|
|
544
689
|
/**
|
|
545
690
|
* Synchronous, runtime-agnostic implementation of the metadata read.
|
|
@@ -555,6 +700,8 @@ declare class MetadataReader {
|
|
|
555
700
|
private readonly session;
|
|
556
701
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
557
702
|
read(signal: AbortSignal): DocumentMetadata;
|
|
703
|
+
/** The Info dict's custom keys: every key but the standard ones. */
|
|
704
|
+
readCustom(signal: AbortSignal): CustomMetadata;
|
|
558
705
|
}
|
|
559
706
|
//#endregion
|
|
560
707
|
//#region src/features/metadata/MetadataMutator.d.ts
|
|
@@ -574,6 +721,8 @@ declare class MetadataMutator {
|
|
|
574
721
|
private readonly session;
|
|
575
722
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
576
723
|
update(patch: MetadataPatch, signal: AbortSignal): MetadataUpdateResult;
|
|
724
|
+
/** Set and remove custom keys, then re-read them the same way. */
|
|
725
|
+
updateCustom(patch: CustomMetadataPatch, signal: AbortSignal): CustomMetadataUpdateResult;
|
|
577
726
|
}
|
|
578
727
|
//#endregion
|
|
579
728
|
//#region src/features/pages/PagesReader.d.ts
|
|
@@ -588,8 +737,16 @@ declare class PagesReader {
|
|
|
588
737
|
private readonly runtime;
|
|
589
738
|
private readonly session;
|
|
590
739
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
591
|
-
read(signal: AbortSignal): PageListSnapshot
|
|
740
|
+
read(signal: AbortSignal): PageListSnapshot<PdfCoordinates>;
|
|
592
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Each page's visible box, read the first time it is asked for: what a
|
|
744
|
+
* result's destinations are measured on. A page that isn't in the document
|
|
745
|
+
* has none.
|
|
746
|
+
*/
|
|
747
|
+
declare function visibleBoxReader(runtime: PdfRuntimeModule, session: DocumentSession): VisibleBoxOf;
|
|
748
|
+
/** The turn of the page at `index` as it reads: its own `/Rotate`, or the one it inherits. */
|
|
749
|
+
declare function rotationAt(runtime: PdfRuntimeModule, docPtr: Ptr, index: number): PdfRotation;
|
|
593
750
|
//#endregion
|
|
594
751
|
//#region src/features/pages/PagesMutator.d.ts
|
|
595
752
|
/**
|
|
@@ -599,35 +756,26 @@ declare class PagesReader {
|
|
|
599
756
|
* `worker_thread`) share the same code path.
|
|
600
757
|
*
|
|
601
758
|
* Architectural anchor — locked with the user, do not loosen without
|
|
602
|
-
* re-reading the doc
|
|
603
|
-
*
|
|
604
|
-
* - Pages are addressed by their durable `pageObjectNumber`. There is
|
|
605
|
-
* no "weak page ref" model in the engine; therefore there is no
|
|
606
|
-
* document-level revision token, no `DocumentRevisionStore`, and no
|
|
607
|
-
* "doc-level shouldRefetch" semantic. Anything that *is* listed
|
|
608
|
-
* here must remain stable across every reorder permutation.
|
|
759
|
+
* re-reading the doc comment on `PageReorderResult`:
|
|
609
760
|
*
|
|
610
|
-
* -
|
|
611
|
-
*
|
|
612
|
-
* pointer entries in the doc-level pages tree), so weak
|
|
613
|
-
* `AnnotationRef.kind === 'index'` references the caller is
|
|
614
|
-
* holding remain valid across a page reorder. This is the right
|
|
615
|
-
* semantic for an editing UI: shuffling pages must NOT silently
|
|
616
|
-
* break a pending highlight edit.
|
|
761
|
+
* - Pages are addressed by their durable `pageObjectNumber`, which must
|
|
762
|
+
* remain stable across every reorder permutation.
|
|
617
763
|
*
|
|
618
|
-
* -
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
764
|
+
* - The /Annots array of each page is untouched by `reorder()` (PDFium just
|
|
765
|
+
* rewrites pointer entries in the doc-level pages tree), so every
|
|
766
|
+
* annotation ref the caller is holding stays valid across a page
|
|
767
|
+
* reorder: shuffling pages must not silently break a pending
|
|
768
|
+
* highlight edit.
|
|
622
769
|
*/
|
|
623
770
|
declare class PagesMutator {
|
|
624
771
|
private readonly runtime;
|
|
625
772
|
private readonly session;
|
|
626
773
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
627
774
|
/**
|
|
628
|
-
* Reorder pages
|
|
629
|
-
*
|
|
630
|
-
*
|
|
775
|
+
* Reorder pages: they go together, in the order given, to `position`, next
|
|
776
|
+
* to a neighbour page or at the start or end. Mirrors `FPDF_MovePages`,
|
|
777
|
+
* which detaches the pages and re-inserts them as a block at an index in
|
|
778
|
+
* the pages left: the neighbour's index there, or the one after it.
|
|
631
779
|
*
|
|
632
780
|
* Atomicity:
|
|
633
781
|
* - `FPDF_MovePages` rejects atomically: if it returns false, no
|
|
@@ -635,68 +783,67 @@ declare class PagesMutator {
|
|
|
635
783
|
* - On success we refresh the per-session page registry and read the
|
|
636
784
|
* new layout back, which is what the result returns.
|
|
637
785
|
*
|
|
638
|
-
* Validation done up front
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* - duplicate `pageObjectNumber`s rejected;
|
|
642
|
-
* - every `pon` resolvable via the session's page registry;
|
|
643
|
-
* - `destIndex` in `[0, pageCount - len]`.
|
|
786
|
+
* Validation done up front, for clean error messages: at least one page,
|
|
787
|
+
* none twice, and a neighbour that isn't one of them (`InvalidArg`); every
|
|
788
|
+
* page and the neighbour pages of the document (`NotFound`).
|
|
644
789
|
*/
|
|
645
|
-
|
|
790
|
+
reorder(pages: PageRef[], position: PagePosition, signal: AbortSignal): PageReorderResult<PdfCoordinates>;
|
|
646
791
|
/**
|
|
647
|
-
* Set the
|
|
792
|
+
* Set the absolute display rotation of the supplied pages. Rotation is
|
|
648
793
|
* presentation metadata over normalized content (pages always load with
|
|
649
794
|
* rotation forced to 0 — see `PagePtrPool`), so:
|
|
650
795
|
* - no cached render, text run, or geometry coordinate changes;
|
|
651
|
-
* - per-page `RevisionToken`s do
|
|
796
|
+
* - per-page `RevisionToken`s do not bump;
|
|
652
797
|
* - page identity and order are untouched — no registry refresh.
|
|
653
798
|
*
|
|
654
|
-
* Atomicity: every
|
|
799
|
+
* Atomicity: every page object number is resolved up front (`NotFound` on caller error),
|
|
655
800
|
* so the apply loop below operates on validated pages only and each write
|
|
656
801
|
* is absolute + idempotent — a retry after an unexpected mid-loop engine
|
|
657
|
-
* fault converges to the requested state. Abort is honored
|
|
802
|
+
* fault converges to the requested state. Abort is honored before the
|
|
658
803
|
* loop, never inside it.
|
|
659
804
|
*/
|
|
660
|
-
rotate(
|
|
805
|
+
rotate(pages: PageRef[], rotation: PdfRotation, signal: AbortSignal): PageRotateResult<PdfCoordinates>;
|
|
661
806
|
/**
|
|
662
|
-
* Delete pages. Deleted object numbers are
|
|
807
|
+
* Delete pages. Deleted object numbers are retired — the engine nulls the
|
|
663
808
|
* page object rather than freeing the number — so per-page state keyed by
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
809
|
+
* page object number can never silently attach to an unrelated future
|
|
810
|
+
* page. Surviving pages keep their identity, and their annotations their
|
|
811
|
+
* names.
|
|
667
812
|
*
|
|
668
813
|
* Guards:
|
|
669
814
|
* - a document must keep at least one page (`InvalidArg`);
|
|
670
|
-
* - every
|
|
815
|
+
* - every page object number must resolve (`NotFound`);
|
|
671
816
|
* - no target page may have a live pooled `pagePtr`. Thread confinement
|
|
672
817
|
* means no other job can be mid-flight, so a held ptr here is a leaked
|
|
673
818
|
* `acquire` — an internal bug we surface loudly instead of deleting
|
|
674
819
|
* under a live handle.
|
|
675
820
|
*
|
|
676
|
-
* Abort is honored
|
|
821
|
+
* Abort is honored before the apply loop, never inside it.
|
|
677
822
|
*/
|
|
678
|
-
delete(
|
|
823
|
+
delete(pages: PageRef[], signal: AbortSignal): PageDeleteResult<PdfCoordinates>;
|
|
679
824
|
/**
|
|
680
825
|
* Register `name` → page in `/Names /Pages` (create, or replace what the
|
|
681
826
|
* key points at); with `replace`, drop that other key first — a rename as
|
|
682
|
-
* one job. Named pages are
|
|
683
|
-
* (no registry refresh
|
|
827
|
+
* one job. Named pages are layout: page identity and order are untouched
|
|
828
|
+
* (no registry refresh) and the fresh snapshot is
|
|
684
829
|
* returned like `move()`.
|
|
685
830
|
*/
|
|
686
|
-
setName(input: PageNameInput, signal: AbortSignal): PageNameResult
|
|
831
|
+
setName(input: PageNameInput, signal: AbortSignal): PageNameResult<PdfCoordinates>;
|
|
687
832
|
/** Remove one `/Names /Pages` registration; the page stays. */
|
|
688
|
-
removeName(input: PageRemoveNameInput, signal: AbortSignal): PageNameResult
|
|
689
|
-
/** Shared input check: non-empty, no duplicate
|
|
690
|
-
private
|
|
833
|
+
removeName(input: PageRemoveNameInput, signal: AbortSignal): PageNameResult<PdfCoordinates>;
|
|
834
|
+
/** Shared input check: non-empty, no duplicate page object numbers. */
|
|
835
|
+
private requireUniquePageObjectNumbers;
|
|
691
836
|
}
|
|
692
837
|
//#endregion
|
|
693
838
|
//#region src/features/pages/PagesExtractor.d.ts
|
|
694
839
|
/**
|
|
695
|
-
* Export a subset of pages as a standalone PDF. A
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
840
|
+
* Export a subset of pages as a standalone PDF. A read over the session:
|
|
841
|
+
* the pages are copied into a scratch document, so the source is untouched —
|
|
842
|
+
* no registry refresh, no layer artifact. A plain copy is
|
|
843
|
+
* `FPDF_ImportPagesByIndex`; a flattened one `EPDFDoc_ExportPagesFlattened`,
|
|
844
|
+
* which copies the pages as they draw. Either keeps the document's title.
|
|
845
|
+
* Lives next to `PagesReader`/`PagesMutator` (one file per page verb family)
|
|
846
|
+
* so both worker hosts share the code path.
|
|
700
847
|
*/
|
|
701
848
|
declare class PagesExtractor {
|
|
702
849
|
private readonly runtime;
|
|
@@ -704,22 +851,32 @@ declare class PagesExtractor {
|
|
|
704
851
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
705
852
|
/**
|
|
706
853
|
* Copy the given pages, in the supplied caller order, into a new
|
|
707
|
-
* document and serialize it
|
|
708
|
-
*
|
|
709
|
-
*
|
|
854
|
+
* document and serialize it: as they are, or, with `flatten`, as they draw
|
|
855
|
+
* (checked against the caller's rights before it gets here). Validation up
|
|
856
|
+
* front: non-empty, no duplicates, every page object number resolvable
|
|
857
|
+
* (`NotFound` from the session on a bad one). The scratch document is
|
|
858
|
+
* always closed, success or throw.
|
|
710
859
|
*/
|
|
711
|
-
extract(
|
|
860
|
+
extract(pages: PageRef[], flatten: PageExtractFlatten | undefined, signal: AbortSignal): {
|
|
712
861
|
bytes: ArrayBuffer;
|
|
713
862
|
size: number;
|
|
714
863
|
};
|
|
864
|
+
/** A new document with copies of the pages at `indices`, as they are. */
|
|
865
|
+
private copyPlain;
|
|
866
|
+
/**
|
|
867
|
+
* A new document with the pages at `indices` as they draw for
|
|
868
|
+
* `flatten.usage`: what `flatten` includes painted in, nothing interactive
|
|
869
|
+
* left, layers in their state for the usage.
|
|
870
|
+
*/
|
|
871
|
+
private copyFlattened;
|
|
715
872
|
}
|
|
716
873
|
//#endregion
|
|
717
874
|
//#region src/features/pages/PagesInserter.d.ts
|
|
718
875
|
/**
|
|
719
876
|
* Insert every page of a standalone PDF into the session document. A
|
|
720
|
-
* structural
|
|
877
|
+
* structural mutation (like move/delete): the source bytes are loaded as a
|
|
721
878
|
* throwaway PDFium document, `FPDF_ImportPagesByIndex` deep-copies its
|
|
722
|
-
* pages in at `
|
|
879
|
+
* pages in at `position`, and the page registry is rebuilt. Pre-existing
|
|
723
880
|
* pages keep their identity and `RevisionToken`s; the inserted copies get
|
|
724
881
|
* fresh object numbers, resolved from the post-insert registry.
|
|
725
882
|
*/
|
|
@@ -727,43 +884,49 @@ declare class PagesInserter {
|
|
|
727
884
|
private readonly runtime;
|
|
728
885
|
private readonly session;
|
|
729
886
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
730
|
-
insert(bytes: ArrayBuffer,
|
|
887
|
+
insert(bytes: ArrayBuffer, position: PagePosition, signal: AbortSignal): PageInsertResult<PdfCoordinates>;
|
|
731
888
|
/**
|
|
732
|
-
* Create `count` blank pages of `size` at `
|
|
733
|
-
* contract as `insert`, but native creation (`
|
|
734
|
-
* deep copy: no source document,
|
|
735
|
-
* lifetime hazard above.
|
|
736
|
-
*
|
|
737
|
-
*
|
|
889
|
+
* Create `count` blank pages of `size` at `position`. Same mutation
|
|
890
|
+
* contract as `insert`, but native creation (`EPDFPage_InsertBlankRaw`,
|
|
891
|
+
* which never loads the page) instead of a deep copy: no source document,
|
|
892
|
+
* so none of the retain-until-close lifetime hazard above. A blank page has
|
|
893
|
+
* no `/Contents`, which ISO 32000-2 defines as an empty page.
|
|
894
|
+
*
|
|
895
|
+
* `objectNumbers`, one per page, names the pages: numbers the session
|
|
896
|
+
* holds, each checked before the first page is made.
|
|
738
897
|
*/
|
|
739
|
-
insertBlank(spec: PageInsertBlankSpec,
|
|
898
|
+
insertBlank(spec: PageInsertBlankSpec, position: PagePosition, signal: AbortSignal, objectNumbers?: readonly number[]): PageInsertResult<PdfCoordinates>;
|
|
740
899
|
}
|
|
741
900
|
//#endregion
|
|
742
901
|
//#region src/features/pages/PagesFlattener.d.ts
|
|
743
|
-
/**
|
|
902
|
+
/**
|
|
903
|
+
* Layer-safe page flattening. Content and annotation liveness change
|
|
904
|
+
* together, all or nothing: a page that fails, or a cancel, aborts the whole
|
|
905
|
+
* flatten.
|
|
906
|
+
*/
|
|
744
907
|
declare class PagesFlattener {
|
|
745
908
|
private readonly runtime;
|
|
746
909
|
private readonly session;
|
|
747
910
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
748
|
-
flatten(
|
|
911
|
+
flatten(pages: PageRef[], usage: PageFlattenUsage, signal: AbortSignal): PageFlattenResult;
|
|
749
912
|
}
|
|
750
913
|
//#endregion
|
|
751
914
|
//#region src/features/redaction/RedactionApplier.d.ts
|
|
752
915
|
/**
|
|
753
916
|
* The destructive half of redaction (see `DocumentRedactionService` for the
|
|
754
917
|
* model and the layer trust boundary). Content and annotation liveness
|
|
755
|
-
* change together, exactly like {@link PagesFlattener}
|
|
756
|
-
*
|
|
918
|
+
* change together, exactly like {@link PagesFlattener}: all or nothing, so a
|
|
919
|
+
* page that fails, or a cancel, aborts the whole apply.
|
|
757
920
|
*
|
|
758
921
|
* Scope semantics:
|
|
759
|
-
* - `pages`: every
|
|
922
|
+
* - `pages`: every redact annotation on each listed page is applied; a
|
|
760
923
|
* page with none is `unchanged`.
|
|
761
|
-
* - `annotations`: exactly the referenced
|
|
762
|
-
* Every ref is resolved and subtype-checked
|
|
763
|
-
* write; a non-
|
|
924
|
+
* - `annotations`: exactly the referenced redact annotations are applied.
|
|
925
|
+
* Every ref is resolved and subtype-checked before the first native
|
|
926
|
+
* write; a non-redact ref rejects the whole call with `InvalidArg`.
|
|
764
927
|
*
|
|
765
928
|
* The per-page `removedAnnotationCount` is the native collateral count:
|
|
766
|
-
* annotations other than
|
|
929
|
+
* annotations other than redact ones removed alongside the apply (popup
|
|
767
930
|
* cascades and detached widgets included).
|
|
768
931
|
*/
|
|
769
932
|
declare class RedactionApplier {
|
|
@@ -773,29 +936,34 @@ declare class RedactionApplier {
|
|
|
773
936
|
apply(scope: RedactionApplyScope, signal: AbortSignal): RedactionApplyResult;
|
|
774
937
|
/**
|
|
775
938
|
* Normalize the scope into an ordered per-page plan. `null` refs means
|
|
776
|
-
* "every
|
|
939
|
+
* "every redact annotation on the page" (the `pages` scope).
|
|
777
940
|
*/
|
|
778
941
|
private buildPlan;
|
|
779
942
|
/**
|
|
780
|
-
* Validate every ref
|
|
781
|
-
* it must be a
|
|
943
|
+
* Validate every ref before the first native write: it must resolve and
|
|
944
|
+
* it must be a redact annotation. After this returns, the apply loop's
|
|
782
945
|
* writes begin and per-page failures are recorded, not thrown.
|
|
783
946
|
*/
|
|
784
947
|
private preflight;
|
|
785
948
|
private applyAllOnPage;
|
|
786
949
|
private pageHasRedactAnnotations;
|
|
950
|
+
/**
|
|
951
|
+
* Applies `refs` in one native call: their regions are redacted together,
|
|
952
|
+
* so an image under several of them is read and written once.
|
|
953
|
+
*/
|
|
787
954
|
private applyRefsOnPage;
|
|
788
955
|
}
|
|
789
956
|
//#endregion
|
|
790
957
|
//#region src/features/text/PageTextReader.d.ts
|
|
791
958
|
/**
|
|
792
959
|
* Per-page slow-path text reader. Acquires a `pagePtr` from the
|
|
793
|
-
* `PagePtrPool
|
|
794
|
-
*
|
|
960
|
+
* `PagePtrPool` (a page not parsed yet loads in slices, so an abort stops the
|
|
961
|
+
* load), opens a PDFium text page (`FPDFText_LoadPage`), extracts the page
|
|
962
|
+
* text, and releases everything in reverse order.
|
|
795
963
|
*
|
|
796
964
|
* Index spaces (see engine-core `text/charmap.ts`): `charCount` is the
|
|
797
|
-
*
|
|
798
|
-
* `text` is the
|
|
965
|
+
* character space (`FPDFText_CountChars` — the space geometry runs tile);
|
|
966
|
+
* `text` is the text projection. The two diverge when a character
|
|
799
967
|
* contributes zero text units (non-printing) or two (supplementary plane);
|
|
800
968
|
* `charMap` anchors encode exactly those deviations.
|
|
801
969
|
*
|
|
@@ -815,7 +983,7 @@ declare class PageTextReader {
|
|
|
815
983
|
private readonly runtime;
|
|
816
984
|
private readonly session;
|
|
817
985
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
818
|
-
read(pageObjectNumber: PageObjectNumber, signal: AbortSignal): PageTextSnapshot
|
|
986
|
+
read(pageObjectNumber: PageObjectNumber, signal: AbortSignal, slices: Slices): Promise<PageTextSnapshot>;
|
|
819
987
|
}
|
|
820
988
|
//#endregion
|
|
821
989
|
//#region src/features/geometry/PageGeometryReader.d.ts
|
|
@@ -830,9 +998,9 @@ interface RawGeometryGlyphRecord {
|
|
|
830
998
|
/** Sampled at each text object's first glyph (run splits inherit it). */
|
|
831
999
|
fontSize?: number;
|
|
832
1000
|
/**
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
1001
|
+
* `FLAG_SPACE` and `FLAG_EMPTY`. Synthesized-but-visible glyphs
|
|
1002
|
+
* (/ActualText pieces) stay 0, exactly like the legacy reader — they
|
|
1003
|
+
* represent real, selectable text.
|
|
836
1004
|
*/
|
|
837
1005
|
flags: number;
|
|
838
1006
|
/** Page-space AABB (zeroed when empty). */
|
|
@@ -844,7 +1012,7 @@ interface RawGeometryGlyphRecord {
|
|
|
844
1012
|
/** Native uprightness of the char matrix (empty glyphs: true, inert). */
|
|
845
1013
|
upright: boolean;
|
|
846
1014
|
/** Baseline angle (radians CCW, PDF y-up); 0 when upright. */
|
|
847
|
-
|
|
1015
|
+
baselineAngle: number;
|
|
848
1016
|
/** True when the ascent vector maps opposite the rotated +y (det < 0). */
|
|
849
1017
|
ascentFlip: boolean;
|
|
850
1018
|
}
|
|
@@ -853,7 +1021,7 @@ interface RawGeometryGlyphRecord {
|
|
|
853
1021
|
*
|
|
854
1022
|
* Emits geometry in PDF user space (y-up edges) — the canonical engine
|
|
855
1023
|
* geometry. The viewer converts to content/view space via the page geometry
|
|
856
|
-
* matrix; this reader applies
|
|
1024
|
+
* matrix; this reader applies no Y-flip or device transform.
|
|
857
1025
|
*
|
|
858
1026
|
* One `EPDFText_GetCharGeometry` call per glyph supplies boxes, oriented
|
|
859
1027
|
* cells, and flags together; `buildRunsFromRawGlyphs` then groups glyphs
|
|
@@ -865,7 +1033,12 @@ declare class PageGeometryReader {
|
|
|
865
1033
|
private readonly runtime;
|
|
866
1034
|
private readonly session;
|
|
867
1035
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
868
|
-
|
|
1036
|
+
/**
|
|
1037
|
+
* A page's text geometry. The page loads in slices when it isn't parsed, and
|
|
1038
|
+
* the glyph loop pauses once a slice's budget is spent, so an abort stops the
|
|
1039
|
+
* read at either.
|
|
1040
|
+
*/
|
|
1041
|
+
read(pageObjectNumber: PageObjectNumber, signal: AbortSignal, slices: Slices): Promise<PageGeometrySnapshot<PdfCoordinates>>;
|
|
869
1042
|
private readGlyphRaw;
|
|
870
1043
|
}
|
|
871
1044
|
/**
|
|
@@ -873,16 +1046,16 @@ declare class PageGeometryReader {
|
|
|
873
1046
|
*
|
|
874
1047
|
* Runs split on text-object change (the legacy rule) and on orientation
|
|
875
1048
|
* change between classifiable glyphs (θ drift / mixed orientation). A run's
|
|
876
|
-
* variant is decided by its
|
|
1049
|
+
* variant is decided by its first classifiable glyph:
|
|
877
1050
|
* - empty glyphs never classify (they adopt the run's variant);
|
|
878
|
-
* - real glyphs
|
|
1051
|
+
* - real glyphs without an oriented cell (singular matrix, synthesized
|
|
879
1052
|
* /ActualText pieces) classify as upright — box-only data degrades to
|
|
880
1053
|
* exactly the legacy behavior;
|
|
881
1054
|
* - real glyphs with a non-upright matrix classify as rotated.
|
|
882
1055
|
* Runs that never see a classifiable glyph emit as upright (degenerate,
|
|
883
1056
|
* legacy behavior).
|
|
884
1057
|
*/
|
|
885
|
-
declare function buildRunsFromRawGlyphs(records: RawGeometryGlyphRecord[]): PageGeometryRun[];
|
|
1058
|
+
declare function buildRunsFromRawGlyphs(records: RawGeometryGlyphRecord[]): PageGeometryRun<PdfCoordinates>[];
|
|
886
1059
|
//#endregion
|
|
887
1060
|
//#region src/runtime/memory/structs.d.ts
|
|
888
1061
|
/** Generated from `EPDF_CHAR_GEOMETRY`; pinned by native static_asserts. */
|
|
@@ -912,7 +1085,15 @@ declare class PageRenderReader {
|
|
|
912
1085
|
private readonly runtime;
|
|
913
1086
|
private readonly session;
|
|
914
1087
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
915
|
-
|
|
1088
|
+
/**
|
|
1089
|
+
* Renders a page in slices, and says which area of it the pixels show.
|
|
1090
|
+
* Until it settles, PDFium holds the page's render: the caller must not let
|
|
1091
|
+
* anything else use PDFium between slices.
|
|
1092
|
+
*/
|
|
1093
|
+
render(pageObjectNumber: PageObjectNumber, options: PageRenderOptions<PdfCoordinates>, signal: AbortSignal, slices: Slices): Promise<{
|
|
1094
|
+
raster: PageRaster;
|
|
1095
|
+
area: PdfRect;
|
|
1096
|
+
}>;
|
|
916
1097
|
}
|
|
917
1098
|
//#endregion
|
|
918
1099
|
//#region src/features/fonts/FontRegistrar.d.ts
|
|
@@ -1038,29 +1219,38 @@ declare class AnnotationReader {
|
|
|
1038
1219
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1039
1220
|
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1040
1221
|
fonts?: FontRegistrar | undefined);
|
|
1041
|
-
list(pageObjectNumber: PageObjectNumber, signal: AbortSignal):
|
|
1222
|
+
list(pageObjectNumber: PageObjectNumber, signal: AbortSignal): AnnotationList<PdfCoordinates>;
|
|
1042
1223
|
}
|
|
1043
1224
|
//#endregion
|
|
1044
1225
|
//#region src/features/annotations/AnnotationAppearanceReader.d.ts
|
|
1045
1226
|
/**
|
|
1046
|
-
* Batch-renders the
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
* PDF user space and against the `PdfRuntimeModule` (`fn` + `mem`).
|
|
1227
|
+
* Batch-renders the appearances of one family of a page's annotations (its
|
|
1228
|
+
* annotations except widgets, or its widgets), one bitmap per mode it stores
|
|
1229
|
+
* (or each requested one) and per state of that mode, each labelled with
|
|
1230
|
+
* both, in PDF user space and against the `PdfRuntimeModule` (`fn` + `mem`).
|
|
1050
1231
|
*
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1232
|
+
* A stored appearance (`/AP`) renders into its annotation's `/Rect`. An
|
|
1233
|
+
* annotation with no normal appearance renders as PDFium draws it in memory,
|
|
1234
|
+
* into the box that drawing takes (`EPDFAnnot_GetDrawingRect`), which can
|
|
1235
|
+
* reach past `/Rect`; nothing is written. One PDFium can draw only by
|
|
1236
|
+
* generating an appearance into the file has no raster. Each bitmap is sized
|
|
1237
|
+
* to its box at the scale the page has at `options.viewport`. The shared
|
|
1238
|
+
* raster helper handles PDFium's display matrix convention, so this reader
|
|
1239
|
+
* stays in normalized PDF page coordinates.
|
|
1054
1240
|
*/
|
|
1055
1241
|
declare class AnnotationAppearanceReader {
|
|
1056
1242
|
private readonly runtime;
|
|
1057
1243
|
private readonly session;
|
|
1058
1244
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1059
|
-
render(pageObjectNumber: PageObjectNumber, options: AnnotationAppearanceRenderOptions, signal: AbortSignal): AnnotationAppearancesResult;
|
|
1060
1245
|
/**
|
|
1061
|
-
*
|
|
1062
|
-
*
|
|
1063
|
-
|
|
1246
|
+
* The page loads in slices when it isn't parsed, and the loop pauses between
|
|
1247
|
+
* annotations once a slice's budget is spent, so an abort stops it at either.
|
|
1248
|
+
*/
|
|
1249
|
+
render(pageObjectNumber: PageObjectNumber, family: AnnotationFamily, options: AnnotationAppearanceRenderOptions, signal: AbortSignal, slices: Slices): Promise<AnnotationAppearancesResult<PdfCoordinates>>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Render a single annotation appearance into its own raster, sized to
|
|
1252
|
+
* `rect`: the stored appearance, or the one PDFium draws in memory. Returns
|
|
1253
|
+
* `null` when the render fails.
|
|
1064
1254
|
*/
|
|
1065
1255
|
private renderOne;
|
|
1066
1256
|
}
|
|
@@ -1072,9 +1262,13 @@ declare class AnnotationAppearanceReader {
|
|
|
1072
1262
|
* `EPDFAnnot_GetObjectNumber` directly off the docPtr.
|
|
1073
1263
|
*
|
|
1074
1264
|
* Per-subtype dispatch is the same as the full reader (both share
|
|
1075
|
-
* `collectPageAnnotations`), so the wire shape `
|
|
1265
|
+
* `collectPageAnnotations`), so the wire shape `Annotation[]` is
|
|
1076
1266
|
* identical between raw and full read paths for the subtypes that don't
|
|
1077
1267
|
* actually need a pagePtr to materialise their fields.
|
|
1268
|
+
*
|
|
1269
|
+
* `family` builds only one family's rows: the public reads pass it
|
|
1270
|
+
* (`'annotations'` for `annotations.list()`, `'widgets'` for the form);
|
|
1271
|
+
* the change internals read every row, by its `/Annots` index.
|
|
1078
1272
|
*/
|
|
1079
1273
|
declare class RawAnnotationReader {
|
|
1080
1274
|
private readonly runtime;
|
|
@@ -1084,16 +1278,16 @@ declare class RawAnnotationReader {
|
|
|
1084
1278
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1085
1279
|
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1086
1280
|
fonts?: FontRegistrar | undefined);
|
|
1087
|
-
|
|
1088
|
-
|
|
1281
|
+
/** The given pages in their order, or every page in document order. */
|
|
1282
|
+
list(pages: readonly PageObjectNumber[] | undefined, signal: AbortSignal, family?: AnnotationFamily): AnnotationList<PdfCoordinates>;
|
|
1283
|
+
listOne(pageObjectNumber: PageObjectNumber, signal: AbortSignal, family?: AnnotationFamily): AnnotationList<PdfCoordinates>;
|
|
1089
1284
|
}
|
|
1090
1285
|
//#endregion
|
|
1091
1286
|
//#region src/features/annotations/AnnotationMutator.d.ts
|
|
1092
1287
|
/**
|
|
1093
1288
|
* Synchronous orchestrator for `create` / `update` / `delete` annotation
|
|
1094
|
-
* mutations. Owns the dance between PDFium calls, identity bookkeeping,
|
|
1095
|
-
*
|
|
1096
|
-
* `AnnotationListMutationMeta` envelope every result type carries.
|
|
1289
|
+
* mutations. Owns the dance between PDFium calls, identity bookkeeping, and
|
|
1290
|
+
* the `AnnotationListMutationMeta` envelope every result type carries.
|
|
1097
1291
|
*
|
|
1098
1292
|
* Lives in `engine-services` (not the worker hosts) so the local Web
|
|
1099
1293
|
* Worker, the Node `worker_thread` server, and any future direct-thread
|
|
@@ -1101,21 +1295,19 @@ declare class RawAnnotationReader {
|
|
|
1101
1295
|
* them is the underlying `PdfRuntimeModule` (WASM vs native).
|
|
1102
1296
|
*
|
|
1103
1297
|
* Identity rules enforced here, locked with the user:
|
|
1104
|
-
* - `create`
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1117
|
-
* `deleted: null` so callers can detect that no durable id was
|
|
1118
|
-
* reportable.
|
|
1298
|
+
* - `create` is a one-item change set on `AnnotationBatchApplier`, which
|
|
1299
|
+
* makes the annotation with `EPDFPage_CreateAnnotRaw` (an indirect
|
|
1300
|
+
* object, on a page that isn't loaded), so a new annotation is named by
|
|
1301
|
+
* its object number. If the fork helper ever returns a direct object, it
|
|
1302
|
+
* throws.
|
|
1303
|
+
* - Every annotation keeps its name through every write (see
|
|
1304
|
+
* `annotationRefOf`). No write stamps an /NM to name one, and the patch
|
|
1305
|
+
* type has no `nm` field, so callers cannot rename one either.
|
|
1306
|
+
* - `delete` is subtype-agnostic and names everything it removed.
|
|
1307
|
+
*
|
|
1308
|
+
* Every write finds its annotations from the page's dictionaries (raw
|
|
1309
|
+
* handles), so none parses the page's content. Each runs inside its job's
|
|
1310
|
+
* layer transaction: a failure after the first write aborts all of it.
|
|
1119
1311
|
*/
|
|
1120
1312
|
declare class AnnotationMutator {
|
|
1121
1313
|
private readonly runtime;
|
|
@@ -1136,69 +1328,52 @@ declare class AnnotationMutator {
|
|
|
1136
1328
|
*/
|
|
1137
1329
|
fonts?: FontRegistrar | undefined);
|
|
1138
1330
|
/** Build the per-write context handed to subtype writers: font resolver
|
|
1139
|
-
* (FreeText `/DA`),
|
|
1331
|
+
* (FreeText `/DA`), the document pointer and binary resources (stamp). */
|
|
1140
1332
|
private writeContext;
|
|
1141
|
-
|
|
1142
|
-
|
|
1333
|
+
/**
|
|
1334
|
+
* A one-item change set on {@link AnnotationBatchApplier}: checked before
|
|
1335
|
+
* the first write, made without loading its page, all or nothing. A
|
|
1336
|
+
* `reply` or a popup's `parent` names an annotation the document has.
|
|
1337
|
+
*/
|
|
1338
|
+
create(pageObjectNumber: PageObjectNumber, draft: AnnotationDraft<PdfCoordinates>, signal: AbortSignal, options?: {
|
|
1339
|
+
/** Who creates it: stamped as its author. */
|
|
1340
|
+
readonly actor?: AnnotationActor;
|
|
1341
|
+
/** The bytes beside the draft, by role. */
|
|
1342
|
+
readonly resources?: WireAnnotationResources;
|
|
1343
|
+
/** The object number it gets; the next free one when absent. */
|
|
1344
|
+
readonly objectNumber?: number;
|
|
1345
|
+
}): AnnotationCreateResult<PdfCoordinates>;
|
|
1346
|
+
/**
|
|
1347
|
+
* Edit an annotation in place. `authority` is checked against the
|
|
1348
|
+
* annotation as it reads before the first write, and gives the actor the
|
|
1349
|
+
* write stamps.
|
|
1350
|
+
*/
|
|
1351
|
+
update(ref: AnnotationRef, patch: AnnotationPatch<PdfCoordinates>, authority: AnnotationAuthority, signal: AbortSignal, resources?: WireAnnotationResources): AnnotationUpdateResult<PdfCoordinates>;
|
|
1143
1352
|
/**
|
|
1144
1353
|
* Attached widgets are views of a form field: deleting one here would
|
|
1145
1354
|
* orphan the field's /Kids (the corruption class doc.forms.repair
|
|
1146
|
-
* exists to fix).
|
|
1355
|
+
* exists to fix). Remove it from its field first, or delete the field. A
|
|
1356
|
+
* merged field/widget is the field's own dictionary and has nothing to be
|
|
1357
|
+
* removed from, so only the field's delete removes it; that cascade passes
|
|
1358
|
+
* the field it has unlinked as `releasedFieldObjectNumber`.
|
|
1147
1359
|
*/
|
|
1148
1360
|
private assertNotAttachedWidget;
|
|
1149
|
-
delete(ref: AnnotationRef, signal: AbortSignal): AnnotationDeleteResult;
|
|
1150
1361
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
* - Each ref in `refs` is resolved to its current /Annots index.
|
|
1156
|
-
* The block is detached, then re-inserted at `toIndex` in the
|
|
1157
|
-
* post-removal index space, preserving caller-supplied order.
|
|
1158
|
-
* - Single-annotation case is `move([ref], toIndex)`. There is no
|
|
1159
|
-
* separate single-move path; one batch primitive serves both.
|
|
1160
|
-
* - Atomic from the caller's perspective:
|
|
1161
|
-
* * one revision bump per batch, regardless of `refs.length`.
|
|
1162
|
-
* * one `AnnotationListMutationMeta` envelope.
|
|
1163
|
-
* * if `EPDFPage_MoveAnnots` rejects (returns false) the page is
|
|
1164
|
-
* untouched and we throw `InvalidArg` without bumping.
|
|
1165
|
-
* - Identity strengthening: each weak ref in the batch (no
|
|
1166
|
-
* `objectNumber`, no `/NM`) is opportunistically stamped with a
|
|
1167
|
-
* fresh engine-generated UUID v4 BEFORE the move. So
|
|
1168
|
-
* `meta.changed` always lists durable stable ids, and the moved
|
|
1169
|
-
* DTOs come out durable. Same monotonic `/NM` rule as `update()`.
|
|
1170
|
-
*
|
|
1171
|
-
* Validation rules applied here BEFORE calling the helper, so callers
|
|
1172
|
-
* get clean errors instead of an opaque `false` return code:
|
|
1173
|
-
* - `refs.length >= 1`.
|
|
1174
|
-
* - All refs target the page identified by `pageObjectNumber`.
|
|
1175
|
-
* - `toIndex >= 0` and `toIndex <= count - refs.length` (count is
|
|
1176
|
-
* captured AFTER ref resolution, so the helper sees the same view).
|
|
1177
|
-
* - Resolved indices have no duplicates.
|
|
1178
|
-
*
|
|
1179
|
-
* The `EPDFPage_MoveAnnots` helper itself enforces the same rules; the
|
|
1180
|
-
* up-front validation is purely for a usable error surface.
|
|
1362
|
+
* Delete an annotation with everything that goes with it
|
|
1363
|
+
* ({@link deletedWith}): its replies and theirs, grouped parts, review
|
|
1364
|
+
* states and every popup, in one change. `authority` is checked against
|
|
1365
|
+
* each of them, and every check runs before the first write.
|
|
1181
1366
|
*/
|
|
1182
|
-
|
|
1367
|
+
delete(ref: AnnotationRef, authority: AnnotationAuthority, signal: AbortSignal): AnnotationDeleteResult;
|
|
1183
1368
|
/**
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
* annotation simply ships without a baked `/AP` and viewers synthesize
|
|
1193
|
-
* one — so a false return is not a hard error; it is surfaced to `update`
|
|
1194
|
-
* callers as the `generation-unavailable` appearance outcome. This step is
|
|
1195
|
-
* non-structural: it never shifts annotation indices or bumps revisions.
|
|
1196
|
-
*/
|
|
1197
|
-
private regenerateAppearance;
|
|
1198
|
-
private captureOrStampStableId;
|
|
1199
|
-
private ensureKnownWeakStateFromPage;
|
|
1200
|
-
private recordWeakStateFromPage;
|
|
1201
|
-
private computeHasWeakAnnotations;
|
|
1369
|
+
* Remove a widget of the field `doc.forms.delete` has just unlinked from
|
|
1370
|
+
* the field tree, including the field's own dictionary when it is a
|
|
1371
|
+
* merged field/widget. The cascade runs past that mutation's apply
|
|
1372
|
+
* boundary, so it takes no abort signal.
|
|
1373
|
+
*/
|
|
1374
|
+
deleteReleasedWidget(ref: AnnotationRef, releasedFieldObjectNumber: number): AnnotationDeleteResult;
|
|
1375
|
+
/** An annotation of the page opened raw at `index`, closed after `body`. */
|
|
1376
|
+
private withAnnotAt;
|
|
1202
1377
|
}
|
|
1203
1378
|
//#endregion
|
|
1204
1379
|
//#region src/features/annotations/AnnotationFlattener.d.ts
|
|
@@ -1206,7 +1381,7 @@ declare class AnnotationMutator {
|
|
|
1206
1381
|
* The annotation-plane flatten verbs — `pages.flatten` for a chosen set:
|
|
1207
1382
|
* in place (`flatten`) or into a new single-page document
|
|
1208
1383
|
* (`exportAppearance`). Both resolve refs to native handles on the page,
|
|
1209
|
-
* hand the
|
|
1384
|
+
* hand the set to the fork (one candidate plan, one placement writer — the
|
|
1210
1385
|
* same code whole-page flatten runs), and release every handle afterwards.
|
|
1211
1386
|
*/
|
|
1212
1387
|
declare class AnnotationFlattener {
|
|
@@ -1218,126 +1393,673 @@ declare class AnnotationFlattener {
|
|
|
1218
1393
|
bytes: ArrayBuffer;
|
|
1219
1394
|
size: number;
|
|
1220
1395
|
};
|
|
1221
|
-
/**
|
|
1222
|
-
*
|
|
1396
|
+
/**
|
|
1397
|
+
* An annotation's `appearance` resource: what its normal appearance draws
|
|
1398
|
+
* apart from what its data describes, as a one-page PDF
|
|
1399
|
+
* (`EPDFAnnot_ExportAppearance`). Only a kind that takes an appearance
|
|
1400
|
+
* resource has one; a copy is created from these bytes and the data.
|
|
1401
|
+
*/
|
|
1402
|
+
readAppearance(pageObjectNumber: PageObjectNumber, ref: AnnotationRef, signal: AbortSignal): {
|
|
1403
|
+
bytes: ArrayBuffer;
|
|
1404
|
+
size: number;
|
|
1405
|
+
};
|
|
1406
|
+
/** Resolve every ref on `pagePtr` (NotFound from the resolver on caller
|
|
1407
|
+
* error); on any failure, close what was opened. */
|
|
1223
1408
|
private resolveAll;
|
|
1224
1409
|
/** Marshal an `FPDF_ANNOTATION*` array for the call's duration. */
|
|
1225
1410
|
private withHandleArray;
|
|
1226
1411
|
private requireRefs;
|
|
1227
1412
|
}
|
|
1228
1413
|
//#endregion
|
|
1229
|
-
//#region src/features/annotations/
|
|
1414
|
+
//#region src/features/annotations/AnnotationExporter.d.ts
|
|
1230
1415
|
/**
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
* at the same physical annotation.
|
|
1241
|
-
* - `delete` removes an entry and shifts every later index down by
|
|
1242
|
-
* one. Pre-existing weak refs at or after the removed index are
|
|
1243
|
-
* now off-by-one and stale.
|
|
1244
|
-
* - `move` detaches a contiguous block and re-inserts it, rewriting
|
|
1245
|
-
* indices on both ends of the gap. Existing weak refs across that
|
|
1246
|
-
* range are stale.
|
|
1247
|
-
*
|
|
1248
|
-
* So the doctrine for `MutationKind` is: only `delete` and `move`
|
|
1249
|
-
* actually invalidate weak refs. `update` and `create` leave them
|
|
1250
|
-
* alone. (A future explicit-position `createAt(index)` API would
|
|
1251
|
-
* shift indices >= toIndex and would join the structural cohort —
|
|
1252
|
-
* see `MutationKind` extension note in `compute()` below.)
|
|
1416
|
+
* `doc.annotations.export`: the annotations a selection takes
|
|
1417
|
+
* ({@link closeExportSelection}) and the bytes beside them, as one bundle.
|
|
1418
|
+
* No page is loaded or parsed: annotations are read raw, and each resource
|
|
1419
|
+
* is exported from a raw handle, so a large document costs dictionary reads.
|
|
1420
|
+
* A drawing is one resource however many stamps place it, and equal bytes
|
|
1421
|
+
* are one resource under their hash. A bundle is page space, like
|
|
1422
|
+
* everything the engine hands out: each item is measured from the top-left
|
|
1423
|
+
* of its page. It is checked against `limits` as it is built, in the form
|
|
1424
|
+
* it leaves in, so an export never makes one an import refuses.
|
|
1253
1425
|
*/
|
|
1254
|
-
|
|
1426
|
+
declare class AnnotationExporter {
|
|
1427
|
+
private readonly runtime;
|
|
1428
|
+
private readonly session;
|
|
1429
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1430
|
+
private readonly fonts?;
|
|
1431
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1432
|
+
/** This thread's font registry: FreeText faces read back as keys. */
|
|
1433
|
+
fonts?: FontRegistrar | undefined);
|
|
1434
|
+
export(selection: AnnotationExportSelection, limits: BundleLimits, signal: AbortSignal): WireAnnotationBundle;
|
|
1435
|
+
}
|
|
1436
|
+
//#endregion
|
|
1437
|
+
//#region src/features/annotations/AnnotationImporter.d.ts
|
|
1438
|
+
interface AnnotationImportRequest {
|
|
1439
|
+
/** In page space, as bundles are: each item converts on the page it goes to. */
|
|
1440
|
+
readonly bundle: WireAnnotationBundle;
|
|
1441
|
+
readonly pages?: BundleImportPages;
|
|
1442
|
+
readonly attribution: 'restore' | 'stamp';
|
|
1443
|
+
/**
|
|
1444
|
+
* The session's identity: who `'stamp'` attributes each annotation to, and
|
|
1445
|
+
* whose user `'restore'` records as `importedBy`.
|
|
1446
|
+
*/
|
|
1447
|
+
readonly actor?: AnnotationActor;
|
|
1448
|
+
readonly limits: BundleLimits;
|
|
1449
|
+
/**
|
|
1450
|
+
* Checks each annotation the import will create, before anything is
|
|
1451
|
+
* written: what its create would need. A refusal refuses the import.
|
|
1452
|
+
*/
|
|
1453
|
+
readonly authorizeCreate?: (draft: AnnotationDraft<PdfCoordinates>) => void;
|
|
1454
|
+
}
|
|
1255
1455
|
/**
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1456
|
+
* `doc.annotations.import`: a bundle's annotations, created in this document
|
|
1457
|
+
* as one change. The bundle is checked first, cheapest checks first: its
|
|
1458
|
+
* shape, counts and sizes against the limits, each resource against its id,
|
|
1459
|
+
* and each image's decoded size, before any image is decoded. Then
|
|
1460
|
+
* {@link planAnnotationImport} maps pages and works out what to leave out,
|
|
1461
|
+
* each create is measured on the page it goes to, from that page's
|
|
1462
|
+
* top-left, and {@link AnnotationBatchApplier} writes them, all or nothing. No
|
|
1463
|
+
* page is loaded: names are looked up in the page dictionaries, and
|
|
1464
|
+
* annotations made on raw handles.
|
|
1465
|
+
*/
|
|
1466
|
+
declare class AnnotationImporter {
|
|
1467
|
+
private readonly runtime;
|
|
1468
|
+
private readonly session;
|
|
1469
|
+
/** This thread's font registry: FreeText faces by key. */
|
|
1470
|
+
private readonly fonts?;
|
|
1471
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1472
|
+
/** This thread's font registry: FreeText faces by key. */
|
|
1473
|
+
fonts?: FontRegistrar | undefined);
|
|
1474
|
+
import(request: AnnotationImportRequest, signal: AbortSignal): AnnotationImportResult<PdfCoordinates>;
|
|
1475
|
+
private assertBundle;
|
|
1476
|
+
}
|
|
1477
|
+
//#endregion
|
|
1478
|
+
//#region src/features/annotations/internal/write/writeEmbedMetadata.d.ts
|
|
1479
|
+
/** The `/EMBD_Metadata` fields a restoring import writes as the bundle has them. */
|
|
1480
|
+
interface RestoredEmbedMetadata {
|
|
1481
|
+
readonly userId: string | null;
|
|
1482
|
+
readonly createdBy: string | null;
|
|
1483
|
+
readonly modifiedBy: string | null;
|
|
1484
|
+
readonly groupId: string | null;
|
|
1485
|
+
}
|
|
1486
|
+
//#endregion
|
|
1487
|
+
//#region src/features/annotations/internal/write/restoreAttribution.d.ts
|
|
1488
|
+
/** The attribution a restoring import writes: the fields a read returned, as they are. */
|
|
1489
|
+
interface RestoredAttribution extends RestoredEmbedMetadata {
|
|
1490
|
+
readonly author: string | null;
|
|
1491
|
+
readonly createdAt: string | null;
|
|
1492
|
+
readonly modifiedAt: string | null;
|
|
1493
|
+
}
|
|
1494
|
+
//#endregion
|
|
1495
|
+
//#region src/features/annotations/AnnotationBatchApplier.d.ts
|
|
1496
|
+
/**
|
|
1497
|
+
* What a link points at: another create of the same change, by its place in
|
|
1498
|
+
* it, so creates can refer to each other before any exists; or an annotation
|
|
1499
|
+
* the document has.
|
|
1269
1500
|
*/
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1501
|
+
type BatchLinkTarget = {
|
|
1502
|
+
readonly planned: number;
|
|
1503
|
+
} | {
|
|
1504
|
+
readonly existing: AnnotationRef;
|
|
1505
|
+
};
|
|
1506
|
+
/** One create of a change. */
|
|
1507
|
+
interface BatchCreate {
|
|
1508
|
+
/** The page it goes on. */
|
|
1509
|
+
readonly page: PageRef;
|
|
1510
|
+
/** Its data, without its links, which are the two fields below. */
|
|
1511
|
+
readonly draft: AnnotationDraft<PdfCoordinates>;
|
|
1512
|
+
/** `reply`: the annotation it replies to, on the same page. */
|
|
1513
|
+
readonly replyTo?: {
|
|
1514
|
+
readonly to: BatchLinkTarget;
|
|
1515
|
+
readonly type: AnnotationReplyType;
|
|
1516
|
+
};
|
|
1517
|
+
/** For a popup: the annotation it shows, on the same page. */
|
|
1518
|
+
readonly parent?: BatchLinkTarget;
|
|
1519
|
+
/** The bytes beside the draft, by role. */
|
|
1520
|
+
readonly resources?: WireAnnotationResources;
|
|
1521
|
+
/** The object number it gets; the next free one when absent. */
|
|
1522
|
+
readonly objectNumber?: number;
|
|
1523
|
+
/**
|
|
1524
|
+
* Who wrote the annotation, and when: the session now, as `create`
|
|
1525
|
+
* stamps it, or the attribution it already had, restored as it is. A
|
|
1526
|
+
* stamped one is a new annotation: without an `nm` in its data it gets a
|
|
1527
|
+
* fresh UUIDv7 name. A restored one keeps the name it had, or none.
|
|
1528
|
+
*/
|
|
1529
|
+
readonly attribution: {
|
|
1530
|
+
readonly kind: 'stamp';
|
|
1531
|
+
readonly actor?: AnnotationActor;
|
|
1532
|
+
} | {
|
|
1533
|
+
readonly kind: 'restore';
|
|
1534
|
+
readonly from: RestoredAttribution;
|
|
1535
|
+
/** The importing session's user, recorded as `importedBy`. */
|
|
1536
|
+
readonly importedBy?: string;
|
|
1537
|
+
};
|
|
1538
|
+
/** A copied file attachment's file dates, kept in either attribution. */
|
|
1539
|
+
readonly fileDates?: Pick<AttachmentFileInfo, 'createdAt' | 'modifiedAt'>;
|
|
1540
|
+
/** Names the create in an error, such as `import: item 3`. */
|
|
1541
|
+
readonly label?: string;
|
|
1542
|
+
}
|
|
1543
|
+
interface BatchCreateResult {
|
|
1544
|
+
/** In the order of the creates, each as it is now. */
|
|
1545
|
+
created: Annotation<PdfCoordinates>[];
|
|
1546
|
+
meta: AnnotationListMutationMeta;
|
|
1275
1547
|
}
|
|
1276
1548
|
/**
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
* the doc comment on `AnnotationListMutationMeta` and the
|
|
1282
|
-
* `MutationKind` definition above:
|
|
1283
|
-
*
|
|
1284
|
-
* 1. `update` and `create` are non-invalidating.
|
|
1549
|
+
* Applies a change set as one unit: every item is checked before the first
|
|
1550
|
+
* write, and the writes run inside the job's layer transaction, so any
|
|
1551
|
+
* failure, an abort included, leaves the document as it was. It currently
|
|
1552
|
+
* applies annotation creates for imports.
|
|
1285
1553
|
*
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* non-structural — it changes the annotation's identity quality
|
|
1290
|
-
* but not its position.
|
|
1554
|
+
* No page is loaded or parsed. Each annotation is made on a raw handle
|
|
1555
|
+
* (`EPDFPage_CreateAnnotRaw`) and opened again the same way, by its place in
|
|
1556
|
+
* its page's `/Annots`, for each pass:
|
|
1291
1557
|
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1558
|
+
* 1. create every annotation in order, so each page's `/Annots` keeps it,
|
|
1559
|
+
* with its data and its appearance;
|
|
1560
|
+
* 2. link replies and popups to what they name: another create, or an
|
|
1561
|
+
* annotation the document has (one born inline becomes an object, which
|
|
1562
|
+
* a link needs, and keeps its name);
|
|
1563
|
+
* 3. attribute each, stamped as the session or restored as it was, last,
|
|
1564
|
+
* so no later write touches `/M`.
|
|
1297
1565
|
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1566
|
+
* A create that names its object number makes the annotation at exactly
|
|
1567
|
+
* that number: one the session holds, checked before the first write, and
|
|
1568
|
+
* free in the layer, which the create itself checks.
|
|
1569
|
+
*/
|
|
1570
|
+
declare class AnnotationBatchApplier {
|
|
1571
|
+
private readonly runtime;
|
|
1572
|
+
private readonly session;
|
|
1573
|
+
/** This thread's font registry: FreeText faces by key. */
|
|
1574
|
+
private readonly fonts?;
|
|
1575
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
1576
|
+
/** This thread's font registry: FreeText faces by key. */
|
|
1577
|
+
fonts?: FontRegistrar | undefined);
|
|
1578
|
+
create(creates: readonly BatchCreate[], signal: AbortSignal): BatchCreateResult;
|
|
1579
|
+
/**
|
|
1580
|
+
* A name must be free on its page (ISO 32000-2 §12.5.2): not used there,
|
|
1581
|
+
* and not by an earlier create of the change.
|
|
1582
|
+
*/
|
|
1583
|
+
private claimName;
|
|
1584
|
+
/**
|
|
1585
|
+
* A link's target, checked before the first write: another create of the
|
|
1586
|
+
* change, or an annotation the document has, on the same page (ISO
|
|
1587
|
+
* 32000-2 §12.5.6.2). Creates only append, so its place holds.
|
|
1588
|
+
*/
|
|
1589
|
+
private linkTarget;
|
|
1590
|
+
private writeContext;
|
|
1591
|
+
private withOpen;
|
|
1592
|
+
private withOpenExisting;
|
|
1593
|
+
}
|
|
1594
|
+
//#endregion
|
|
1595
|
+
//#region src/features/changes/ChangeRecord.d.ts
|
|
1596
|
+
/**
|
|
1597
|
+
* What the engine keeps of a change so it can undo it: who made it, and the
|
|
1598
|
+
* steps that reverse it, in the order they run (the reverses of its ops, in
|
|
1599
|
+
* reverse op order). Each step is guarded by what the change left: it applies
|
|
1600
|
+
* where the document still shows that, and is skipped, and reported, where it
|
|
1601
|
+
* doesn't. Running a step records the step that reverses it in turn, so the
|
|
1602
|
+
* undo of an undo is a redo.
|
|
1603
|
+
*/
|
|
1604
|
+
interface ChangeRecord {
|
|
1605
|
+
/** Who made the change: only they may undo it. */
|
|
1606
|
+
readonly userId: string | null;
|
|
1607
|
+
readonly steps: readonly ReverseStep[];
|
|
1608
|
+
}
|
|
1609
|
+
type ReverseStep = ObjectsRevertStep | AnnotationRemoveStep | AnnotationRestoreStep | AnnotationReorderStep | FieldRemoveStep | FieldRestoreStep | WidgetRestoreStep | WidgetDeleteStep | CalculationOrderStep | MetadataRevertStep | OutlineRemoveStep | OutlineRestoreStep | OutlineMoveStep | OutlineReopenStep | PageRotateStep | PageReorderStep | PageRestoreStep | PageRemoveStep | AttachmentRemoveStep | AttachmentRestoreStep;
|
|
1610
|
+
/**
|
|
1611
|
+
* One dictionary a change wrote, as it was before (the capture, with the
|
|
1612
|
+
* objects under `deep` the layer held) and as the change left it (a shallow
|
|
1613
|
+
* capture, the guard). `before` is null for a dictionary the change made.
|
|
1614
|
+
*/
|
|
1615
|
+
interface CapturedObject {
|
|
1616
|
+
readonly objectNumber: number;
|
|
1617
|
+
readonly deep: readonly string[];
|
|
1618
|
+
readonly before: Uint8Array | null;
|
|
1619
|
+
readonly after: Uint8Array;
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Puts back the dictionaries an op wrote, exactly as they were, when each
|
|
1623
|
+
* still reads as the op left it. When one doesn't, someone changed it since:
|
|
1624
|
+
* an annotation update, a field update or a form value write puts back, by
|
|
1625
|
+
* value, only what still shows what the op set (`fallback`); any other op is
|
|
1626
|
+
* skipped.
|
|
1627
|
+
*/
|
|
1628
|
+
interface ObjectsRevertStep {
|
|
1629
|
+
readonly kind: 'objects.revert';
|
|
1630
|
+
/** What its item reports doing: the op it puts back, or its opposite (a widget's add undoes its removal). */
|
|
1631
|
+
readonly reports: ChangeItemType;
|
|
1632
|
+
readonly objects: readonly CapturedObject[];
|
|
1633
|
+
/** What the item reads back: the annotation, the form fields, or the outline item. */
|
|
1634
|
+
readonly subject: {
|
|
1635
|
+
readonly annotation: AnnotationRef;
|
|
1636
|
+
} | {
|
|
1637
|
+
readonly fields: readonly number[];
|
|
1638
|
+
} | {
|
|
1639
|
+
readonly outlineItem: OutlineItemRef;
|
|
1640
|
+
};
|
|
1641
|
+
/** Whether the op changed what the annotation shows (its update's `appearance.changed`). */
|
|
1642
|
+
readonly appearanceChanged?: boolean;
|
|
1643
|
+
readonly fallback?: RevertFallback;
|
|
1644
|
+
/** The rights it takes beside its op's: an import's (see {@link StepRights}). */
|
|
1645
|
+
readonly rights?: StepRights;
|
|
1646
|
+
}
|
|
1647
|
+
/** How a revert puts values back when the dictionaries it wrote changed since. */
|
|
1648
|
+
type RevertFallback = {
|
|
1649
|
+
readonly kind: 'annotation';
|
|
1650
|
+
/** The old values of the fields the update changed. */
|
|
1651
|
+
readonly restore: AnnotationPatch<PdfCoordinates>;
|
|
1652
|
+
/** The values the update left in them: a field still holding its value is put back. */
|
|
1653
|
+
readonly left: AnnotationPatch<PdfCoordinates>;
|
|
1654
|
+
} | {
|
|
1655
|
+
readonly kind: 'properties';
|
|
1656
|
+
readonly objectNumber: number;
|
|
1657
|
+
/** The old values of the properties a field update changed, as a patch. */
|
|
1658
|
+
readonly restore: FormFieldPatch;
|
|
1659
|
+
/** The values it left in them: a property still holding its value is put back. */
|
|
1660
|
+
readonly left: FormFieldPatch;
|
|
1661
|
+
} | {
|
|
1662
|
+
readonly kind: 'outline';
|
|
1663
|
+
/** The old values of the fields an outline item update changed, as a patch. */
|
|
1664
|
+
readonly restore: OutlineItemPatch<PdfDestination>;
|
|
1665
|
+
/** The values it left in them: a field still holding its value is put back. */
|
|
1666
|
+
readonly left: OutlineItemPatch<PdfDestination>;
|
|
1667
|
+
} | {
|
|
1668
|
+
readonly kind: 'value';
|
|
1669
|
+
/** Each field the op wrote: its value before, and the value the op left. */
|
|
1670
|
+
readonly fields: readonly {
|
|
1671
|
+
readonly objectNumber: number;
|
|
1672
|
+
readonly before: FormFieldValue;
|
|
1673
|
+
readonly left: FormFieldValue;
|
|
1674
|
+
}[];
|
|
1675
|
+
};
|
|
1676
|
+
/**
|
|
1677
|
+
* Deletes what a create, an import or a restore brought back, when nobody
|
|
1678
|
+
* changed it since and deleting it takes nothing else: undoing a create
|
|
1679
|
+
* never deletes someone else's reply.
|
|
1680
|
+
*/
|
|
1681
|
+
interface AnnotationRemoveStep {
|
|
1682
|
+
readonly kind: 'annotation.remove';
|
|
1683
|
+
readonly ref: AnnotationRef;
|
|
1684
|
+
/** What the delete takes, as the change left it: the annotation first. */
|
|
1685
|
+
readonly left: readonly Annotation<PdfCoordinates>[];
|
|
1686
|
+
/** The rights it takes: an import's (see {@link StepRights}); a delete's when absent. */
|
|
1687
|
+
readonly rights?: StepRights;
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* The rights a step takes as a restoring import's undo or redo: what the
|
|
1691
|
+
* import took. For annotations, `doc.annotate.modify` and
|
|
1692
|
+
* `doc.annotate.import` instead of the per-annotation rules: a restoring
|
|
1693
|
+
* import gives annotations other people's `userId`, which a delete's rules
|
|
1694
|
+
* (`annotations:delete:self`) would never let the importer remove. For
|
|
1695
|
+
* forms, `doc.forms.import` beside `doc.forms.modify` or `doc.forms.fill`:
|
|
1696
|
+
* putting back who made or filled a field is restoring attribution too.
|
|
1697
|
+
*/
|
|
1698
|
+
type StepRights = 'import';
|
|
1699
|
+
/**
|
|
1700
|
+
* Brings back what a delete removed: the same objects, at the same numbers and
|
|
1701
|
+
* positions, from the capture taken in the delete's transaction.
|
|
1702
|
+
*/
|
|
1703
|
+
interface AnnotationRestoreStep {
|
|
1704
|
+
readonly kind: 'annotation.restore';
|
|
1705
|
+
readonly page: PageRef;
|
|
1706
|
+
/** What came back: the annotation first, then what went with it. */
|
|
1707
|
+
readonly members: readonly AnnotationRef[];
|
|
1708
|
+
readonly capture: Uint8Array;
|
|
1709
|
+
/** Annotations the delete unlinked a popup from, put back as they were. */
|
|
1710
|
+
readonly unlinked: readonly CapturedObject[];
|
|
1711
|
+
/** The rights it takes: those of the remove it reverses (see {@link StepRights}). */
|
|
1712
|
+
readonly rights?: StepRights;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Puts rows of one family on a page back beside the neighbours they had
|
|
1716
|
+
* before a reorder: its reverse, and, the other way round, its redo. A row
|
|
1717
|
+
* runs only when it is still where the reorder left it.
|
|
1718
|
+
*/
|
|
1719
|
+
interface AnnotationReorderStep {
|
|
1720
|
+
readonly kind: 'annotation.reorder';
|
|
1721
|
+
readonly page: PageRef;
|
|
1722
|
+
readonly family: AnnotationFamily;
|
|
1723
|
+
/** The rows the reorder moved, in the order it was given them. */
|
|
1724
|
+
readonly refs: readonly AnnotationRef[];
|
|
1725
|
+
/** The family's order before the reorder, bottom to top: where the rows go back to. */
|
|
1726
|
+
readonly before: readonly AnnotationRef[];
|
|
1727
|
+
/** The family's order it left. */
|
|
1728
|
+
readonly after: readonly AnnotationRef[];
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Takes back what a change did to the form's calculation order, by field
|
|
1732
|
+
* object number, where nobody changed it since (see `orderBack`): a field it
|
|
1733
|
+
* added leaves, one it took out comes back, one it moved goes back beside
|
|
1734
|
+
* its old neighbour.
|
|
1735
|
+
*/
|
|
1736
|
+
interface CalculationOrderStep {
|
|
1737
|
+
readonly kind: 'calculations.restore';
|
|
1738
|
+
/** The order before the change. */
|
|
1739
|
+
readonly before: readonly number[];
|
|
1740
|
+
/** The order the change left. */
|
|
1741
|
+
readonly after: readonly number[];
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Brings back a widget a delete removed: onto its page at its place, and into
|
|
1745
|
+
* its field again when it had one. Left alone when the page is gone, the
|
|
1746
|
+
* widget is back already, or its field changed since.
|
|
1747
|
+
*/
|
|
1748
|
+
interface WidgetRestoreStep {
|
|
1749
|
+
readonly kind: 'widget.restore';
|
|
1750
|
+
readonly page: PageRef;
|
|
1751
|
+
readonly widget: AnnotationRef;
|
|
1752
|
+
/** The widget as it was on its page, out of its field. */
|
|
1753
|
+
readonly capture: Uint8Array;
|
|
1754
|
+
/** The field it was in; `null` for a widget in no field. */
|
|
1755
|
+
readonly fieldObjectNumber: number | null;
|
|
1756
|
+
/** The field's dictionary and the widget's, before and after it left the field. */
|
|
1757
|
+
readonly detached: readonly CapturedObject[];
|
|
1758
|
+
}
|
|
1759
|
+
/** Deletes a widget a restore brought back, when nobody changed it since: the redo of a delete. */
|
|
1760
|
+
interface WidgetDeleteStep {
|
|
1761
|
+
readonly kind: 'widget.delete';
|
|
1762
|
+
readonly widget: AnnotationRef;
|
|
1763
|
+
readonly left: WidgetAnnotation<PdfCoordinates>;
|
|
1764
|
+
}
|
|
1765
|
+
/** Deletes a field a create or an import made, when nobody changed it since. */
|
|
1766
|
+
interface FieldRemoveStep {
|
|
1767
|
+
readonly kind: 'field.remove';
|
|
1768
|
+
readonly objectNumber: number;
|
|
1769
|
+
/** The field as the change left it. */
|
|
1770
|
+
readonly left: FormFieldDTO<PdfCoordinates>;
|
|
1771
|
+
/** The rights it takes beside `doc.forms.modify`: an import's (see {@link StepRights}). */
|
|
1772
|
+
readonly rights?: StepRights;
|
|
1773
|
+
}
|
|
1774
|
+
/** Brings back a field a delete removed, its widgets and the parents it pruned. */
|
|
1775
|
+
interface FieldRestoreStep {
|
|
1776
|
+
readonly kind: 'field.restore';
|
|
1777
|
+
readonly objectNumber: number;
|
|
1778
|
+
/** Its fully qualified name: the restore is skipped when another field took it. */
|
|
1779
|
+
readonly name: string;
|
|
1780
|
+
/** The pages its widgets were on: the restore is skipped when one is gone. */
|
|
1781
|
+
readonly pages: readonly PageRef[];
|
|
1782
|
+
readonly capture: Uint8Array;
|
|
1783
|
+
/** The rights it takes: those of the remove it reverses (see {@link StepRights}). */
|
|
1784
|
+
readonly rights?: StepRights;
|
|
1785
|
+
}
|
|
1786
|
+
/** Puts metadata back, entry by entry, where an entry still holds what the change set. */
|
|
1787
|
+
interface MetadataRevertStep {
|
|
1788
|
+
readonly kind: 'metadata.revert';
|
|
1789
|
+
readonly op: 'metadata.update' | 'metadata.updateCustom';
|
|
1790
|
+
readonly restore: MetadataPatch | CustomMetadataPatch;
|
|
1791
|
+
readonly left: MetadataPatch | CustomMetadataPatch;
|
|
1792
|
+
}
|
|
1793
|
+
/**
|
|
1794
|
+
* Deletes outline items a create or a restore brought back, when nobody
|
|
1795
|
+
* changed them since: the item and the items under it are the same ones, and
|
|
1796
|
+
* their dictionaries read exactly as the change left them. Undoing a create
|
|
1797
|
+
* never deletes an item someone gave a child, or renamed, since; a page its
|
|
1798
|
+
* target goes to going away changes nothing of it.
|
|
1799
|
+
*/
|
|
1800
|
+
interface OutlineRemoveStep {
|
|
1801
|
+
readonly kind: 'outline.remove';
|
|
1802
|
+
readonly ref: OutlineItemRef;
|
|
1803
|
+
/** The item and the items under it, depth first, each as the change left it (the guard). */
|
|
1804
|
+
readonly left: readonly CapturedObject[];
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Opens again a parent that the op this step follows emptied, as it was open
|
|
1808
|
+
* before: a parent without children has no open state, so it comes back
|
|
1809
|
+
* closed with its first child. Only while its children are just the ones the
|
|
1810
|
+
* undo put back: a parent someone filled since keeps what they left.
|
|
1811
|
+
*/
|
|
1812
|
+
interface OutlineReopenStep {
|
|
1813
|
+
readonly kind: 'outline.reopen';
|
|
1814
|
+
readonly ref: OutlineItemRef;
|
|
1815
|
+
/** The children it has once the undo put them back. */
|
|
1816
|
+
readonly children: readonly number[];
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Brings back what an outline delete removed: the same items, at the same
|
|
1820
|
+
* numbers, at the place the item had (`EPDFOutline_ImportItemRaw`). Left
|
|
1821
|
+
* alone when its parent is gone or it is back already.
|
|
1822
|
+
*/
|
|
1823
|
+
interface OutlineRestoreStep {
|
|
1824
|
+
readonly kind: 'outline.restore';
|
|
1825
|
+
readonly ref: OutlineItemRef;
|
|
1826
|
+
/** Its parent when it went; `null` for the top level. */
|
|
1827
|
+
readonly parent: OutlineItemRef | null;
|
|
1828
|
+
readonly capture: Uint8Array;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Puts outline items back where they were before a move: its reverse, and,
|
|
1832
|
+
* the other way round, its redo. Each item goes only while it is still under
|
|
1833
|
+
* the parent the move left it under, and its parent is still there.
|
|
1834
|
+
*/
|
|
1835
|
+
interface OutlineMoveStep {
|
|
1836
|
+
readonly kind: 'outline.move';
|
|
1837
|
+
/**
|
|
1838
|
+
* Where each goes back to, by object number (parent 0: the top level;
|
|
1839
|
+
* after 0: first), in document order, so an anchor is placed before what
|
|
1840
|
+
* follows it.
|
|
1841
|
+
*/
|
|
1842
|
+
readonly placements: readonly {
|
|
1843
|
+
readonly item: number;
|
|
1844
|
+
readonly parent: number;
|
|
1845
|
+
readonly after: number;
|
|
1846
|
+
}[];
|
|
1847
|
+
/** The parent each was left under (0: the top level). */
|
|
1848
|
+
readonly left: readonly {
|
|
1849
|
+
readonly item: number;
|
|
1850
|
+
readonly parent: number;
|
|
1851
|
+
}[];
|
|
1852
|
+
}
|
|
1853
|
+
/**
|
|
1854
|
+
* Turns pages to `rotation`: its reverse, and, the other way round, its redo.
|
|
1855
|
+
* Each page turns only while it still has the rotation the change left it
|
|
1856
|
+
* with (`left`). A change that turned pages from several rotations has one
|
|
1857
|
+
* step for each.
|
|
1858
|
+
*/
|
|
1859
|
+
interface PageRotateStep {
|
|
1860
|
+
readonly kind: 'pages.rotate';
|
|
1861
|
+
/** The pages, by object number. */
|
|
1862
|
+
readonly pages: readonly number[];
|
|
1863
|
+
readonly rotation: PdfRotation;
|
|
1864
|
+
readonly left: PdfRotation;
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Puts pages back where they were before a move: its reverse, and, the other
|
|
1868
|
+
* way round, its redo. Each page goes only while it still follows the page the
|
|
1869
|
+
* move left it after, and the page it goes after is still there.
|
|
1870
|
+
*/
|
|
1871
|
+
interface PageReorderStep {
|
|
1872
|
+
readonly kind: 'pages.reorder';
|
|
1873
|
+
/**
|
|
1874
|
+
* Where each goes back to, by object number (after 0: first), in display
|
|
1875
|
+
* order, so an anchor is placed before what follows it.
|
|
1876
|
+
*/
|
|
1877
|
+
readonly placements: readonly {
|
|
1878
|
+
readonly page: number;
|
|
1879
|
+
readonly after: number;
|
|
1880
|
+
}[];
|
|
1881
|
+
/** The page each was left after (0: first). */
|
|
1882
|
+
readonly left: readonly {
|
|
1883
|
+
readonly page: number;
|
|
1884
|
+
readonly after: number;
|
|
1885
|
+
}[];
|
|
1886
|
+
}
|
|
1887
|
+
/**
|
|
1888
|
+
* Brings back what a page delete removed: the same pages, at the same
|
|
1889
|
+
* numbers, each after the page it followed while that is still there, else
|
|
1890
|
+
* first (`EPDFPage_ImportRaw`), with their annotations and names. A page that
|
|
1891
|
+
* is back already is left alone.
|
|
1892
|
+
*/
|
|
1893
|
+
interface PageRestoreStep {
|
|
1894
|
+
readonly kind: 'pages.restore';
|
|
1895
|
+
/** Each page and its capture, in the display order they had. */
|
|
1896
|
+
readonly pages: readonly {
|
|
1897
|
+
readonly page: number;
|
|
1898
|
+
readonly capture: Uint8Array;
|
|
1899
|
+
}[];
|
|
1900
|
+
}
|
|
1901
|
+
/**
|
|
1902
|
+
* Deletes pages an insert or a restore brought, each while it reads as the
|
|
1903
|
+
* change left it: the page and what the layer holds of its annotations,
|
|
1904
|
+
* contents and resources. Undoing an insert never deletes a page someone
|
|
1905
|
+
* annotated, or turned, since. A step that would delete every page is left
|
|
1906
|
+
* alone: a document keeps one.
|
|
1907
|
+
*/
|
|
1908
|
+
interface PageRemoveStep {
|
|
1909
|
+
readonly kind: 'pages.remove';
|
|
1910
|
+
/** Each page, and the digest of how the change left it. */
|
|
1911
|
+
readonly pages: readonly {
|
|
1912
|
+
readonly page: number;
|
|
1913
|
+
readonly left: string;
|
|
1914
|
+
}[];
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Deletes the embedded file a create or a restore brought, while it is still
|
|
1918
|
+
* that file, as the change left it: undoing an upload never deletes a file
|
|
1919
|
+
* someone put under its name since, even one with the same bytes.
|
|
1920
|
+
*/
|
|
1921
|
+
interface AttachmentRemoveStep {
|
|
1922
|
+
readonly kind: 'attachments.remove';
|
|
1923
|
+
readonly ref: AttachmentRef;
|
|
1924
|
+
/** The file as the change left it, in canonical bytes (the guard). */
|
|
1925
|
+
readonly left: Uint8Array;
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Brings back the file a delete removed, under its key, with its file
|
|
1929
|
+
* specification and bytes as they were (`EPDFAttachment_ImportRaw`). Left
|
|
1930
|
+
* alone when another file has the key now.
|
|
1931
|
+
*/
|
|
1932
|
+
interface AttachmentRestoreStep {
|
|
1933
|
+
readonly kind: 'attachments.restore';
|
|
1934
|
+
readonly ref: AttachmentRef;
|
|
1935
|
+
readonly capture: Uint8Array;
|
|
1936
|
+
}
|
|
1937
|
+
//#endregion
|
|
1938
|
+
//#region src/features/changes/ChangeApplier.d.ts
|
|
1939
|
+
/** What a change did: one item per op (or per step of an undo), and the record that undoes it. */
|
|
1940
|
+
interface AppliedChange<C extends Coordinates = PdfCoordinates> {
|
|
1941
|
+
readonly items: ChangeItem<C>[];
|
|
1942
|
+
/** Its steps are empty when nothing was written: there is nothing to undo. */
|
|
1943
|
+
readonly record: ChangeRecord;
|
|
1944
|
+
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Where a change's places are measured. Each op's places turn into the
|
|
1947
|
+
* file's coordinates right before it runs, and each item's into the
|
|
1948
|
+
* answer's space right after its op (or an undo's step) ran, against the
|
|
1949
|
+
* document as it is then: an earlier op can add, remove or put back a page a
|
|
1950
|
+
* later one names.
|
|
1951
|
+
*/
|
|
1952
|
+
interface ChangeSpace<In extends Coordinates, Out extends Coordinates> {
|
|
1953
|
+
opInFileSpace(op: RecordedOp<In, WireAnnotationResources>): RecordedOp<PdfCoordinates, WireAnnotationResources>;
|
|
1954
|
+
itemOut(item: ChangeItem<PdfCoordinates>): ChangeItem<Out>;
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* The file's own coordinates, in and out: for a single verb's one-op change,
|
|
1958
|
+
* whose job converts at the worker's boundary.
|
|
1959
|
+
*/
|
|
1960
|
+
declare const FILE_SPACE: ChangeSpace<PdfCoordinates, PdfCoordinates>;
|
|
1961
|
+
/**
|
|
1962
|
+
* Runs changes inside the job's layer transaction, which its caller opens and
|
|
1963
|
+
* ends, so a failure anywhere leaves the document as it was: a change's ops in
|
|
1964
|
+
* order (`apply`), or the steps of a recorded reverse (`undo`). Each op and
|
|
1965
|
+
* step is checked against the change's authority as it runs, as its single
|
|
1966
|
+
* verb's job checks it.
|
|
1319
1967
|
*
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1968
|
+
* Every op records the steps that reverse it as it runs, from what it found
|
|
1969
|
+
* and wrote; the record lists them in reverse op order, so each step meets the
|
|
1970
|
+
* document as the op after it left it.
|
|
1971
|
+
*/
|
|
1972
|
+
declare class ChangeApplier {
|
|
1973
|
+
private readonly runtime;
|
|
1974
|
+
private readonly session;
|
|
1975
|
+
private readonly fonts?;
|
|
1976
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession, fonts?: FontRegistrar | undefined);
|
|
1977
|
+
apply<In extends Coordinates, Out extends Coordinates>(ops: readonly RecordedOp<In, WireAnnotationResources>[], authority: ChangeAuthority, signal: AbortSignal, space: ChangeSpace<In, Out>): AppliedChange<Out>;
|
|
1978
|
+
undo<Out extends Coordinates>(record: ChangeRecord, authority: ChangeAuthority, signal: AbortSignal, space: Pick<ChangeSpace<Coordinates, Out>, 'itemOut'>): AppliedChange<Out>;
|
|
1979
|
+
private context;
|
|
1980
|
+
}
|
|
1981
|
+
//#endregion
|
|
1982
|
+
//#region src/features/changes/ChangeLedger.d.ts
|
|
1983
|
+
/**
|
|
1984
|
+
* An applied change's answer, in the space its job answered in: page space
|
|
1985
|
+
* for a change (`doc.apply`), the file's for a single verb's job, whose
|
|
1986
|
+
* boundary converts it.
|
|
1987
|
+
*/
|
|
1988
|
+
type KeptResult = ChangeResult<PdfCoordinates> | ChangeResult<PageCoordinates>;
|
|
1989
|
+
/** What one change answered, kept under its `opId`. */
|
|
1990
|
+
type ChangeOutcome = {
|
|
1991
|
+
readonly kind: 'applied';
|
|
1992
|
+
readonly fingerprint: string;
|
|
1993
|
+
readonly result: KeptResult;
|
|
1994
|
+
} | {
|
|
1995
|
+
readonly kind: 'refused';
|
|
1996
|
+
readonly fingerprint: string;
|
|
1997
|
+
readonly error: SerializedEngineError;
|
|
1998
|
+
};
|
|
1999
|
+
/** Why a change can't be undone (`UndoUnavailable`'s `details.reason`). */
|
|
2000
|
+
type UndoUnavailableReason = 'final-change' | 'expired';
|
|
2001
|
+
/**
|
|
2002
|
+
* What a local session keeps of its changes: every answer under its `opId`,
|
|
2003
|
+
* refusals included, so a retry gets the same one; and each undoable change's
|
|
2004
|
+
* record, until a final change ends undo for everything before it, or the
|
|
2005
|
+
* capture budget runs out (the oldest go first, as `expired`).
|
|
1326
2006
|
*
|
|
1327
|
-
*
|
|
1328
|
-
*
|
|
1329
|
-
|
|
1330
|
-
|
|
2007
|
+
* The cloud keeps the same in its database; a cloud worker's session keeps
|
|
2008
|
+
* nothing here between requests.
|
|
2009
|
+
*/
|
|
2010
|
+
declare class ChangeLedger {
|
|
2011
|
+
private readonly entries;
|
|
2012
|
+
private bytes;
|
|
2013
|
+
/** The answer kept under `opId`, if any. */
|
|
2014
|
+
outcome(opId: string): ChangeOutcome | undefined;
|
|
2015
|
+
/**
|
|
2016
|
+
* The record of the change `opId`, or why it can't be undone. Undefined for
|
|
2017
|
+
* a change this session has no answer for.
|
|
2018
|
+
*/
|
|
2019
|
+
record(opId: string): {
|
|
2020
|
+
readonly record: ChangeRecord | null;
|
|
2021
|
+
} | {
|
|
2022
|
+
readonly unavailable: UndoUnavailableReason;
|
|
2023
|
+
} | undefined;
|
|
2024
|
+
/** Keeps an applied change's answer, and its record when it can be undone. */
|
|
2025
|
+
keepApplied(opId: string, fingerprint: string, result: KeptResult, record: ChangeRecord | null): void;
|
|
2026
|
+
/** Keeps a refusal: asking again answers it again. */
|
|
2027
|
+
keepRefused(opId: string, fingerprint: string, error: SerializedEngineError): void;
|
|
2028
|
+
/**
|
|
2029
|
+
* A final change (redaction apply, flatten, signing, form repair) ended undo
|
|
2030
|
+
* for itself and every change before it: their records go.
|
|
2031
|
+
*/
|
|
2032
|
+
endUndo(): void;
|
|
2033
|
+
private add;
|
|
2034
|
+
private trimCaptures;
|
|
2035
|
+
private drop;
|
|
2036
|
+
}
|
|
2037
|
+
/** The ledger of `session`'s changes. */
|
|
2038
|
+
declare function changeLedgerOf(session: DocumentSession): ChangeLedger;
|
|
2039
|
+
//#endregion
|
|
2040
|
+
//#region src/features/changes/recordCodec.d.ts
|
|
2041
|
+
/**
|
|
2042
|
+
* A change's record as a caller stores it: the steps as JSON, every capture's
|
|
2043
|
+
* bytes moved into one blob and named in the JSON by where they are in it
|
|
2044
|
+
* (`{ "$capture": [offset, length] }`). `capture` is null when the record
|
|
2045
|
+
* holds no bytes.
|
|
1331
2046
|
*/
|
|
1332
|
-
|
|
2047
|
+
interface PackedChangeRecord {
|
|
2048
|
+
readonly reverse: string;
|
|
2049
|
+
readonly capture: Uint8Array | null;
|
|
2050
|
+
}
|
|
2051
|
+
/** A record, packed for storage (see `PackedChangeRecord`). */
|
|
2052
|
+
declare function packChangeRecord(record: ChangeRecordPayload): PackedChangeRecord;
|
|
2053
|
+
/** A record unpacked from its JSON and its capture blob. */
|
|
2054
|
+
declare function unpackChangeRecord(reverse: string, capture: Uint8Array | null): ChangeRecordPayload;
|
|
1333
2055
|
//#endregion
|
|
1334
2056
|
//#region src/features/attachments/AttachmentReader.d.ts
|
|
1335
2057
|
/**
|
|
1336
2058
|
* Read-only access to embedded files, at both of their homes: the
|
|
1337
2059
|
* document catalog's `/EmbeddedFiles` name tree (list / readFile by
|
|
1338
2060
|
* index) and a FileAttachment annotation's `/FS` (readAnnotationFile by
|
|
1339
|
-
* ref). Pure
|
|
1340
|
-
*
|
|
2061
|
+
* ref). Pure reads over the session — no layer artifacts (the
|
|
2062
|
+
* `PagesExtractor` shape).
|
|
1341
2063
|
*
|
|
1342
2064
|
* Byte delivery mirrors the request's `path?`: absent → a standalone
|
|
1343
2065
|
* buffer for the transfer list (browser); present → the decoded file is
|
|
@@ -1349,40 +2071,43 @@ declare class AttachmentReader {
|
|
|
1349
2071
|
private readonly session;
|
|
1350
2072
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1351
2073
|
/** Snapshot of the `/EmbeddedFiles` name tree, in tree (key-sorted) order. */
|
|
1352
|
-
list(signal: AbortSignal):
|
|
2074
|
+
list(signal: AbortSignal): Attachment[];
|
|
1353
2075
|
/** Decode one document-level embedded file, addressed by key. */
|
|
1354
|
-
readFile(ref:
|
|
2076
|
+
readFile(ref: AttachmentRef, path: string | undefined, maxDecodedBytes: number | undefined, signal: AbortSignal): AttachmentFileWorkerPayload;
|
|
1355
2077
|
/** Decode the file embedded in a FileAttachment annotation's `/FS`. */
|
|
1356
|
-
|
|
2078
|
+
/** A file attachment annotation's file; a page not parsed yet loads in slices. */
|
|
2079
|
+
readAnnotationFile(pageObjectNumber: PageObjectNumber, ref: AnnotationRef, path: string | undefined, maxDecodedBytes: number | undefined, signal: AbortSignal, slices: Slices): Promise<AttachmentFileWorkerPayload>;
|
|
1357
2080
|
private extract;
|
|
1358
2081
|
}
|
|
1359
2082
|
//#endregion
|
|
1360
2083
|
//#region src/features/attachments/AttachmentMutator.d.ts
|
|
1361
2084
|
/**
|
|
1362
|
-
* Create/delete
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
2085
|
+
* Create/delete writes over the document catalog's `/EmbeddedFiles` name
|
|
2086
|
+
* tree, sharing the write path (`writeAttachmentFilePayload`) with the
|
|
2087
|
+
* file-attachment annotation writer. The change ops run them
|
|
2088
|
+
* (`attachmentChanges.ts`), which decide what an undo needs.
|
|
1366
2089
|
*
|
|
1367
|
-
* Identity is the name-tree
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
* never move. Layer persistence (`finishMutation`) and event publication
|
|
1371
|
-
* happen in the callers, exactly like every other mutation family.
|
|
2090
|
+
* Identity is the name-tree key (unique by construction). Note the
|
|
2091
|
+
* tree is key-sorted: both writes shift other entries' indices; keys
|
|
2092
|
+
* never move.
|
|
1372
2093
|
*/
|
|
1373
2094
|
declare class AttachmentMutator {
|
|
1374
2095
|
private readonly runtime;
|
|
1375
2096
|
private readonly session;
|
|
1376
2097
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1377
2098
|
/**
|
|
1378
|
-
* Create an embedded file
|
|
1379
|
-
* writes key = /UF = /F); a duplicate key rejects with
|
|
1380
|
-
* The result carries the read-back entry,
|
|
1381
|
-
* included.
|
|
2099
|
+
* Create an embedded file from `bytes`. `file.name` becomes the tree key
|
|
2100
|
+
* (PDFium writes key = /UF = /F); a duplicate key rejects with
|
|
2101
|
+
* `InvalidArg`. The result carries the read-back entry,
|
|
2102
|
+
* `checksum`/`size`/dates included.
|
|
1382
2103
|
*/
|
|
1383
|
-
create(file:
|
|
2104
|
+
create(file: AttachmentFileBase, bytes: ArrayBuffer | undefined, signal: AbortSignal): AttachmentCreateResult;
|
|
2105
|
+
/** The entry under `ref`'s key as it reads now; `null` when no file has the key. */
|
|
2106
|
+
find(ref: AttachmentRef): Attachment | null;
|
|
2107
|
+
/** A write's meta, naming the file it changed. Cloud coherence pins are a server concern. */
|
|
2108
|
+
meta(ref: AttachmentRef): AttachmentMutationMeta;
|
|
1384
2109
|
/** Delete an embedded file by key. Unlinks the tree entry only. */
|
|
1385
|
-
delete(ref:
|
|
2110
|
+
delete(ref: AttachmentRef, signal: AbortSignal): AttachmentDeleteResult;
|
|
1386
2111
|
}
|
|
1387
2112
|
//#endregion
|
|
1388
2113
|
//#region src/features/attachments/internal/attachmentPrimitives.d.ts
|
|
@@ -1396,7 +2121,7 @@ declare class AttachmentMutator {
|
|
|
1396
2121
|
* vocabulary.
|
|
1397
2122
|
*/
|
|
1398
2123
|
declare function writeAttachmentFilePayload(fn: PdfFunctions, mem: PdfRuntimeMemory, attachmentPtr: Ptr, docPtr: Ptr, file: {
|
|
1399
|
-
mimeType?: string;
|
|
2124
|
+
mimeType?: string | null;
|
|
1400
2125
|
description?: string;
|
|
1401
2126
|
}, resource: WireResource): void;
|
|
1402
2127
|
/** Read the metadata projection of an embedded file (never its bytes). */
|
|
@@ -1418,7 +2143,7 @@ declare class SecurityReader {
|
|
|
1418
2143
|
constructor(runtime: PdfRuntimeModule);
|
|
1419
2144
|
probeFile(path: string, password?: string | null): DocumentSecurityProbeInfo;
|
|
1420
2145
|
/**
|
|
1421
|
-
* Snapshot of the live session's
|
|
2146
|
+
* Snapshot of the live session's effective security state.
|
|
1422
2147
|
* `FPDF_GetDocUserPermissions` reports the permission word in force
|
|
1423
2148
|
* right now (e.g. after an owner unlock), as opposed to the declared
|
|
1424
2149
|
* word the cold `probeFile` path reads.
|
|
@@ -1534,7 +2259,7 @@ declare class DocumentSaver {
|
|
|
1534
2259
|
* `saveLayerDelta` that says whether anything reachable changed since the
|
|
1535
2260
|
* layer was opened; empty bytes when nothing did (keep what you have), or
|
|
1536
2261
|
* when the layer came to equal its base (then `changedSinceLoad` is true
|
|
1537
|
-
* and the document
|
|
2262
|
+
* and the document is the base).
|
|
1538
2263
|
*/
|
|
1539
2264
|
saveLayerDeltaEx(): {
|
|
1540
2265
|
bytes: ArrayBuffer;
|
|
@@ -1603,10 +2328,7 @@ declare class SignatureReader {
|
|
|
1603
2328
|
index: number;
|
|
1604
2329
|
fieldObjectNumber: number;
|
|
1605
2330
|
signed: boolean;
|
|
1606
|
-
widget:
|
|
1607
|
-
annotObjectNumber: number;
|
|
1608
|
-
pageObjectNumber: number;
|
|
1609
|
-
} | null;
|
|
2331
|
+
widget: FormWidget | null;
|
|
1610
2332
|
};
|
|
1611
2333
|
/** One signature by field object number, from the current model. */
|
|
1612
2334
|
readSignatureByObjectNumber(fieldObjectNumber: number): SignatureDTO;
|
|
@@ -1631,14 +2353,14 @@ declare class SignatureReader {
|
|
|
1631
2353
|
/**
|
|
1632
2354
|
* The two-phase signing protocol on a session, local and native alike.
|
|
1633
2355
|
*
|
|
1634
|
-
* `prepare` never touches the live document: it builds a
|
|
2356
|
+
* `prepare` never touches the live document: it builds a candidate — a
|
|
1635
2357
|
* fresh layer over the session's own immutable base (see `openCandidate`)
|
|
1636
2358
|
* — writes the signature there, saves it through a `CandidateStore`
|
|
1637
2359
|
* (memory locally, a file beside the base on file-backed sessions), seals
|
|
1638
2360
|
* it, and parks the saved candidate on the session. `complete` writes the
|
|
1639
2361
|
* CMS into it, opens it as a new base with a fresh layer, proves the new
|
|
1640
2362
|
* signature seals a whole revision, and installs it as the session's
|
|
1641
|
-
* document. `
|
|
2363
|
+
* document. `cancel` discards the candidate.
|
|
1642
2364
|
*/
|
|
1643
2365
|
declare class SignatureMutator {
|
|
1644
2366
|
private readonly runtime;
|
|
@@ -1649,15 +2371,27 @@ declare class SignatureMutator {
|
|
|
1649
2371
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession, baseDocuments: BaseDocumentRegistry,
|
|
1650
2372
|
/** Where a file-backed session's candidate is written; defaults to beside the base file. */
|
|
1651
2373
|
candidatePath?: ((basePath: string, signingId: string) => string) | undefined);
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
2374
|
+
/**
|
|
2375
|
+
* Prepare a signing of `input.field`, which `authority` must be allowed to
|
|
2376
|
+
* sign (its group, `fields:sign`). A field in a group, signed without a
|
|
2377
|
+
* `lock`, locks the rest of its group: nobody changes the buyer's fields
|
|
2378
|
+
* once the buyer signed.
|
|
2379
|
+
*/
|
|
2380
|
+
prepare(input: SignaturePrepareInput, authority: ChangeAuthority): SignaturePrepared;
|
|
2381
|
+
/**
|
|
2382
|
+
* `opId` names the write. A signing runs outside a layer transaction (it
|
|
2383
|
+
* replaces the document's bytes), so it takes its id here, and it is final:
|
|
2384
|
+
* never undoable.
|
|
2385
|
+
*/
|
|
2386
|
+
/** Complete the pending signing; `authority` must still be allowed to sign its field. */
|
|
2387
|
+
complete(input: SignatureCompleteInput, opId: string, authority: ChangeAuthority): SignatureCompleteResult;
|
|
2388
|
+
cancel(signingId: string): SignatureCancelResult;
|
|
1655
2389
|
private callPrepare;
|
|
1656
2390
|
/** Draw a page of `pdf` into the widget's appearance stream on the candidate. */
|
|
1657
2391
|
/**
|
|
1658
2392
|
* File-backed sessions (a file base in the registry: the server) persist
|
|
1659
2393
|
* the candidate as a file beside the base; everything else keeps it in
|
|
1660
|
-
* memory. The choice follows the
|
|
2394
|
+
* memory. The choice follows the session's base, not the candidate's.
|
|
1661
2395
|
*/
|
|
1662
2396
|
private storeFor;
|
|
1663
2397
|
/**
|
|
@@ -1673,7 +2407,7 @@ declare class SignatureMutator {
|
|
|
1673
2407
|
private verifySealed;
|
|
1674
2408
|
/**
|
|
1675
2409
|
* The candidate the signature is authored on. A layer session reopens a
|
|
1676
|
-
* fresh layer over
|
|
2410
|
+
* fresh layer over its own immutable base (a registry retain, no copy of
|
|
1677
2411
|
* the file), fed the layer it was opened with — or, with unsaved edits,
|
|
1678
2412
|
* the artifact a save would write, which is cumulative: the edits and
|
|
1679
2413
|
* the signature then share one revision, as Acrobat saves a
|
|
@@ -1723,14 +2457,14 @@ declare class SignatureAnalyzer {
|
|
|
1723
2457
|
* the session's own document is the working copy. `working-copy`: a
|
|
1724
2458
|
* layer session composes its immutable base with the cumulative delta
|
|
1725
2459
|
* the pass emits (`EPDFDoc_OpenBaseOverlay`: no copy of the base, one
|
|
1726
|
-
* cross-reference parse, the loaded delta's revision
|
|
2460
|
+
* cross-reference parse, the loaded delta's revision replaced, as an
|
|
1727
2461
|
* artifact is), or — when every edit brought the layer back to its base
|
|
1728
2462
|
* — a fresh layer over that base; a plain session (unsigned by law 9, so
|
|
1729
2463
|
* this is exploratory) materialises a standalone incremental save and
|
|
1730
2464
|
* opens it whole.
|
|
1731
2465
|
*/
|
|
1732
2466
|
private openWorkingCopy;
|
|
1733
|
-
/** Changed since load, nothing to write: the layer equals its base, and a fresh layer over it
|
|
2467
|
+
/** Changed since load, nothing to write: the layer equals its base, and a fresh layer over it is that document. */
|
|
1734
2468
|
private freshLayerOverBase;
|
|
1735
2469
|
/**
|
|
1736
2470
|
* The fork's exact object diff between two revision documents,
|
|
@@ -1763,9 +2497,12 @@ interface FinalizeCandidateInput {
|
|
|
1763
2497
|
password: string | null;
|
|
1764
2498
|
}
|
|
1765
2499
|
interface FinalizedCandidate {
|
|
2500
|
+
/** In page space: no session outlives the finalize to measure it later. */
|
|
1766
2501
|
signature: SignatureDTO;
|
|
1767
2502
|
protection: DocumentProtection;
|
|
1768
2503
|
version: BaseVersionInfo;
|
|
2504
|
+
/** The sealed file's last object number: every object it has is at or below it. */
|
|
2505
|
+
lastObjectNumber: number;
|
|
1769
2506
|
}
|
|
1770
2507
|
/**
|
|
1771
2508
|
* The session-less half of a durable signing. A server prepares a
|
|
@@ -1806,25 +2543,130 @@ declare function readStructure(runtime: PdfRuntimeModule, docPtr: Ptr): Revision
|
|
|
1806
2543
|
//#endregion
|
|
1807
2544
|
//#region src/features/forms/FormReader.d.ts
|
|
1808
2545
|
/**
|
|
1809
|
-
* Read side of the forms feature.
|
|
2546
|
+
* Read side of the forms feature. Field reads go through the session's
|
|
1810
2547
|
* version-keyed model cache, so repeated reads between mutations reuse
|
|
1811
|
-
* one native snapshot build.
|
|
2548
|
+
* one native snapshot build; widget rows are read from the pages.
|
|
1812
2549
|
*/
|
|
1813
2550
|
declare class FormReader {
|
|
1814
2551
|
private readonly runtime;
|
|
1815
2552
|
private readonly session;
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
2553
|
+
/** This thread's font registry, for the widget rows. */
|
|
2554
|
+
private readonly fonts?;
|
|
2555
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
2556
|
+
/** This thread's font registry, for the widget rows. */
|
|
2557
|
+
fonts?: FontRegistrar | undefined);
|
|
2558
|
+
snapshot(signal: AbortSignal): FormSnapshot<PdfCoordinates>;
|
|
2559
|
+
field(ref: FormFieldRef, signal: AbortSignal): FormFieldDTO<PdfCoordinates>;
|
|
2560
|
+
}
|
|
2561
|
+
//#endregion
|
|
2562
|
+
//#region src/features/forms/FormExporter.d.ts
|
|
2563
|
+
/**
|
|
2564
|
+
* `doc.forms.export`: the fields a selection takes, each whole with all of
|
|
2565
|
+
* its widgets, as one bundle in page space (see `formExportRowsOf`). It
|
|
2566
|
+
* reads the form as `list()` does and writes nothing. A widget is drawn
|
|
2567
|
+
* from its data, so the bundle holds no resources. It is checked against
|
|
2568
|
+
* `limits` as it is built, so an export never makes one an import refuses.
|
|
2569
|
+
*/
|
|
2570
|
+
declare class FormExporter {
|
|
2571
|
+
private readonly runtime;
|
|
2572
|
+
private readonly session;
|
|
2573
|
+
/** This thread's font registry, for the widget rows. */
|
|
2574
|
+
private readonly fonts?;
|
|
2575
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
2576
|
+
/** This thread's font registry, for the widget rows. */
|
|
2577
|
+
fonts?: FontRegistrar | undefined);
|
|
2578
|
+
export(selection: FormExportSelection, limits: BundleLimits, signal: AbortSignal): WireFormBundle;
|
|
2579
|
+
}
|
|
2580
|
+
//#endregion
|
|
2581
|
+
//#region src/features/forms/FormImporter.d.ts
|
|
2582
|
+
interface FormImportRequest {
|
|
2583
|
+
/** In page space, as bundles are: each widget is measured on the page it goes to. */
|
|
2584
|
+
readonly bundle: WireFormBundle;
|
|
2585
|
+
readonly pages?: BundleImportPages;
|
|
2586
|
+
readonly attribution: 'restore' | 'stamp';
|
|
2587
|
+
/** Whether each field gets the value the bundle holds. */
|
|
2588
|
+
readonly values: boolean;
|
|
2589
|
+
/**
|
|
2590
|
+
* The session's identity: whom `'stamp'` makes each field's creator and
|
|
2591
|
+
* filler, and whose user `'restore'` records as `importedBy`.
|
|
2592
|
+
*/
|
|
2593
|
+
readonly actor: AnnotationActor;
|
|
2594
|
+
readonly limits: BundleLimits;
|
|
2595
|
+
/** Whether scripts, submits and links are kept (`doc.forms.script`); without it they're left out. */
|
|
2596
|
+
readonly mayScript: boolean;
|
|
2597
|
+
/**
|
|
2598
|
+
* The group a field goes in, given the one it had in the bundle (if any):
|
|
2599
|
+
* checked by the caller, which refuses one it may not set.
|
|
2600
|
+
*/
|
|
2601
|
+
readonly groupOf: (groupId: string | undefined) => string | undefined;
|
|
2602
|
+
}
|
|
2603
|
+
/** What a values import writes, decided before the first write. */
|
|
2604
|
+
interface FormValuesImportPlan {
|
|
2605
|
+
/** Each against the field as it is now; a write that changes nothing isn't among them. */
|
|
2606
|
+
readonly writes: readonly PlannedValueWrite<FormFieldDTO<PdfCoordinates>>[];
|
|
2607
|
+
readonly dropped: readonly FormValuesImportDrop[];
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* `doc.forms.import` and `doc.forms.importValues`: a bundle's fields, copied
|
|
2611
|
+
* into this document or filled in from it. The bundle is checked first: its
|
|
2612
|
+
* shape, counts and sizes against the limits, and each resource against its
|
|
2613
|
+
* id. Then the core plans (`planFormImport`, `planFormValuesImport`), so all
|
|
2614
|
+
* that is left out is decided before the first write, and the writes go
|
|
2615
|
+
* through the form's own: `createField` and `setValue`.
|
|
2616
|
+
*/
|
|
2617
|
+
declare class FormImporter {
|
|
2618
|
+
private readonly runtime;
|
|
2619
|
+
private readonly session;
|
|
2620
|
+
/** This thread's font registry, for the widget rows. */
|
|
2621
|
+
private readonly fonts?;
|
|
2622
|
+
constructor(runtime: PdfRuntimeModule, session: DocumentSession,
|
|
2623
|
+
/** This thread's font registry, for the widget rows. */
|
|
2624
|
+
fonts?: FontRegistrar | undefined);
|
|
1819
2625
|
/**
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
1822
|
-
*
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
2626
|
+
* The design: each field `planFormImport` keeps, created with its widgets on
|
|
2627
|
+
* their mapped pages, their flags, and, with `values`, the value the
|
|
2628
|
+
* bundle holds; then the calculation order among them, appended to the
|
|
2629
|
+
* form's in bundle order; then who made and filled each, restored or
|
|
2630
|
+
* stamped.
|
|
2631
|
+
*/
|
|
2632
|
+
import(request: FormImportRequest, signal: AbortSignal): FormImportResult<PdfCoordinates>;
|
|
2633
|
+
/**
|
|
2634
|
+
* What a values import of `bundle` writes, nothing written yet: each
|
|
2635
|
+
* field the bundle holds a value for, matched by full name, when it can
|
|
2636
|
+
* take the value (`fieldValueWriteOf`) and no signature locked it. A field
|
|
2637
|
+
* stored as a direct object can't be written, so it can't take the value
|
|
2638
|
+
* either.
|
|
2639
|
+
*/
|
|
2640
|
+
planValues(bundle: WireFormBundle, limits: BundleLimits, signal: AbortSignal,
|
|
2641
|
+
/** Whether the session may fill the field in; one it may not is left out. */
|
|
2642
|
+
mayFill: (field: FormFieldDTO<PdfCoordinates>) => boolean): FormValuesImportPlan;
|
|
2643
|
+
/**
|
|
2644
|
+
* One write of a values import: the value, then, for `'restore'`, who
|
|
2645
|
+
* filled it in as the bundle has it. `'stamp'` leaves the session as the
|
|
2646
|
+
* filler, as `setValue` stamps it.
|
|
2647
|
+
*/
|
|
2648
|
+
writeValue(write: PlannedValueWrite<FormFieldDTO<PdfCoordinates>>, bundle: WireFormBundle, attribution: 'restore' | 'stamp', actor: AnnotationActor, signal: AbortSignal): FormFieldDTO<PdfCoordinates>;
|
|
2649
|
+
/** A new widget's flags, as its row in the bundle has them: a create writes none. */
|
|
2650
|
+
private writeFlags;
|
|
2651
|
+
/** The full name of every field of the form. */
|
|
2652
|
+
private fieldNames;
|
|
2653
|
+
/** Every field of the form, as it is now. */
|
|
2654
|
+
private readFields;
|
|
2655
|
+
private readField;
|
|
2656
|
+
private calculationOrder;
|
|
2657
|
+
}
|
|
2658
|
+
//#endregion
|
|
2659
|
+
//#region src/features/forms/internal/calculationOrder.d.ts
|
|
2660
|
+
/**
|
|
2661
|
+
* The form's calculation order (`/AcroForm /CO`): the fields whose calculate
|
|
2662
|
+
* scripts run, in the order they run, by object number. A field's calculate
|
|
2663
|
+
* script keeps it in the order; the order is a list like a page's
|
|
2664
|
+
* annotations, moved by neighbour.
|
|
2665
|
+
*/
|
|
2666
|
+
/** The calculation order before a write and as the write left it. */
|
|
2667
|
+
interface OrderChange {
|
|
2668
|
+
readonly before: readonly number[];
|
|
2669
|
+
readonly after: readonly number[];
|
|
1828
2670
|
}
|
|
1829
2671
|
//#endregion
|
|
1830
2672
|
//#region src/features/forms/FormMutator.d.ts
|
|
@@ -1834,91 +2676,160 @@ declare class FormReader {
|
|
|
1834
2676
|
* the document untouched (on layers: nothing promoted), and each success
|
|
1835
2677
|
* bumps the session's mutation sequence so version-keyed caches rebuild.
|
|
1836
2678
|
*/
|
|
2679
|
+
/**
|
|
2680
|
+
* A form write's result as the mutator gives it: the fields, without the
|
|
2681
|
+
* widget rows, which the change that ran it reads (`withWidgetRows`).
|
|
2682
|
+
*/
|
|
2683
|
+
type FieldWriteResult<T> = Omit<T, 'widgets'>;
|
|
1837
2684
|
declare class FormMutator {
|
|
1838
2685
|
private readonly runtime;
|
|
1839
2686
|
private readonly session;
|
|
1840
2687
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1841
|
-
setValue(ref: FormFieldRef, value: FormFieldValue, signal: AbortSignal): FormSetValueResult;
|
|
1842
|
-
reset(ref: FormFieldRef, signal: AbortSignal): FormSetValueResult;
|
|
1843
|
-
importData(data: ArrayBuffer, format: FormDataFormat | undefined, signal: AbortSignal): FormImportResult;
|
|
1844
|
-
repair(bakeAppearances: boolean, signal: AbortSignal): FormRepairResult;
|
|
1845
2688
|
/**
|
|
1846
|
-
*
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
|
|
2689
|
+
* Set a field's value, as `actor` filled it in: what engine-core's rules
|
|
2690
|
+
* (`fieldAfterValue`) leave the field holding. A write that changes the
|
|
2691
|
+
* field names who filled it in; one that leaves it as it was writes
|
|
2692
|
+
* nothing.
|
|
2693
|
+
*/
|
|
2694
|
+
setValue(ref: FormFieldRef, value: FormFieldValue, signal: AbortSignal, actor: AnnotationActor): FieldWriteResult<FormSetValueResult<PdfCoordinates>>;
|
|
2695
|
+
/**
|
|
2696
|
+
* Show, hide or keep from printing every widget of a field, as a script's
|
|
2697
|
+
* `Field.display` does: only the four flags it names change.
|
|
2698
|
+
*/
|
|
2699
|
+
setDisplay(ref: FormFieldRef, display: FormFieldDisplay, signal: AbortSignal): FieldWriteResult<FormSetValueResult<PdfCoordinates>>;
|
|
2700
|
+
/**
|
|
2701
|
+
* Draw a text field's or dropdown's widgets with `text` (a format script's
|
|
2702
|
+
* result) without changing its value.
|
|
1851
2703
|
*/
|
|
1852
|
-
|
|
1853
|
-
|
|
2704
|
+
setAppearanceText(ref: FormFieldRef, text: string, signal: AbortSignal): FieldWriteResult<FormSetValueResult<PdfCoordinates>>;
|
|
2705
|
+
/**
|
|
2706
|
+
* The meta of a value write that changed no page list: the cloud layer
|
|
2707
|
+
* computes its own cache delta server-side.
|
|
2708
|
+
*/
|
|
2709
|
+
private emptyMeta;
|
|
2710
|
+
/**
|
|
2711
|
+
* Put fields back to their default value: the ones named, or, with
|
|
2712
|
+
* `refs` absent, every field of the form. Fields that hold no value are
|
|
2713
|
+
* skipped; so, in a whole-form reset, are fields stored inline or locked
|
|
2714
|
+
* by a signature (named, they are refused). Every field is checked before
|
|
2715
|
+
* the first write. Returns the fields that changed.
|
|
2716
|
+
*/
|
|
2717
|
+
reset(refs: FormFieldRef[] | undefined, signal: AbortSignal): FieldWriteResult<FormResetResult<PdfCoordinates>>;
|
|
2718
|
+
/** Every field a whole-form reset puts back: those with a value, written directly, unlocked. */
|
|
2719
|
+
private wholeFormTargets;
|
|
2720
|
+
/** The named fields with a value, each once; one that can't be written is refused. */
|
|
2721
|
+
private namedTargets;
|
|
2722
|
+
repair(bakeAppearances: boolean, signal: AbortSignal): FormRepairResult;
|
|
2723
|
+
/**
|
|
2724
|
+
* Create a field and (optionally) its widgets as one change: native
|
|
2725
|
+
* field creation, widget birth through the annotation plane, adoption,
|
|
2726
|
+
* then field-plane setters, stamped as `actor` created it. Everything a
|
|
2727
|
+
* caller can get wrong is checked before the first write; any failure
|
|
2728
|
+
* after it aborts the job's layer transaction, so a rejected draft creates
|
|
2729
|
+
* nothing.
|
|
2730
|
+
*/
|
|
2731
|
+
createField(draft: FormFieldDraft<PdfCoordinates>, signal: AbortSignal, actor: AnnotationActor, numbers?: {
|
|
2732
|
+
/** The field's object number; the next free one when absent. */
|
|
2733
|
+
readonly objectNumber?: number;
|
|
2734
|
+
/** Its widgets', in `draft.widgets` order; the next free ones when absent. */
|
|
2735
|
+
readonly widgetObjectNumbers?: readonly number[];
|
|
2736
|
+
}): {
|
|
2737
|
+
field: FormFieldDTO<PdfCoordinates>;
|
|
2738
|
+
calculationOrder: OrderChange | null;
|
|
1854
2739
|
};
|
|
2740
|
+
/** EPDFForm_DeleteField: unlink the field and detach its kid widgets. */
|
|
2741
|
+
private nativeDeleteField;
|
|
2742
|
+
/** Check a widget placement before anything is written; returns its page index. */
|
|
2743
|
+
private preflightPlacement;
|
|
1855
2744
|
/**
|
|
1856
|
-
*
|
|
2745
|
+
* The native field node, linked into the tree, at `objectNumber` (checked
|
|
2746
|
+
* by the session) or the next free number.
|
|
2747
|
+
*/
|
|
2748
|
+
private createFieldNode;
|
|
2749
|
+
/** The draft's field-plane settings, on a field just created. */
|
|
2750
|
+
private configureNewField;
|
|
2751
|
+
/**
|
|
2752
|
+
* Draw a PDF page into every widget of an unsigned signature field: the
|
|
1857
2753
|
* visual "sign" of a viewer without a signer. The field's value stays
|
|
1858
2754
|
* empty and nothing is sealed; a signed field is refused (its appearance
|
|
1859
|
-
* is part of what the signature covers).
|
|
1860
|
-
* reported so their renders re-pin.
|
|
2755
|
+
* is part of what the signature covers).
|
|
1861
2756
|
*/
|
|
1862
|
-
setSignatureAppearance(ref: FormFieldRef, pdf: Uint8Array,
|
|
1863
|
-
field: FormFieldDTO
|
|
1864
|
-
pages: PageObjectNumber[];
|
|
2757
|
+
setSignatureAppearance(ref: FormFieldRef, pdf: Uint8Array, signal: AbortSignal): {
|
|
2758
|
+
field: FormFieldDTO<PdfCoordinates>;
|
|
1865
2759
|
};
|
|
1866
2760
|
updateField(ref: FormFieldRef, patch: FormFieldPatch, signal: AbortSignal): {
|
|
1867
|
-
field: FormFieldDTO
|
|
2761
|
+
field: FormFieldDTO<PdfCoordinates>;
|
|
2762
|
+
calculationOrder: OrderChange | null;
|
|
2763
|
+
};
|
|
2764
|
+
/**
|
|
2765
|
+
* Move fields in the calculation order: they go together, in the order
|
|
2766
|
+
* given, to `position`. Every field named must be in the order.
|
|
2767
|
+
*/
|
|
2768
|
+
reorderCalculations(fields: readonly FormFieldRef[], position: FieldPosition, signal: AbortSignal): OrderChange & {
|
|
2769
|
+
moved: number[];
|
|
1868
2770
|
};
|
|
1869
2771
|
/**
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
2772
|
+
* Keep the calculation order in step with a field's calculate script, as
|
|
2773
|
+
* a write left it: a script puts the field at the end when it isn't in the
|
|
2774
|
+
* order, removing the script takes the field out. Returns the order before
|
|
2775
|
+
* and after, when it changed.
|
|
2776
|
+
*/
|
|
2777
|
+
private followCalculateScript;
|
|
2778
|
+
/**
|
|
2779
|
+
* Delete a terminal field and its widgets in one mutation. The native
|
|
2780
|
+
* write detaches kid widgets and unlinks the field from /Fields or its
|
|
2781
|
+
* parent's /Kids; the cascade then removes every placed widget from its
|
|
2782
|
+
* page through the annotation feature, which owns /Annots bookkeeping. A
|
|
2783
|
+
* merged field/widget has no
|
|
2784
|
+
* kid to detach: its own dictionary leaves its page in the same cascade.
|
|
1873
2785
|
*/
|
|
1874
2786
|
deleteField(ref: FormFieldRef, signal: AbortSignal): {
|
|
1875
|
-
|
|
1876
|
-
|
|
2787
|
+
deleted: FormFieldRef;
|
|
2788
|
+
removedWidgets: FormWidget[];
|
|
2789
|
+
calculationOrder: OrderChange | null;
|
|
1877
2790
|
};
|
|
1878
|
-
|
|
1879
|
-
|
|
2791
|
+
/**
|
|
2792
|
+
* Show a field in one more place: create the widget where the placement
|
|
2793
|
+
* says, styled by it, and add it to the field, as one change. A failure
|
|
2794
|
+
* after the first write rolls the page and the form back.
|
|
2795
|
+
*/
|
|
2796
|
+
addWidget(ref: FormFieldRef, placement: WidgetPlacement<PdfCoordinates>, signal: AbortSignal, numbers?: {
|
|
2797
|
+
/** The new widget's object number; the next free one when absent. */
|
|
2798
|
+
readonly objectNumber?: number;
|
|
2799
|
+
/** Where a merged field's widget moves; the next free one when absent. */
|
|
2800
|
+
readonly splitObjectNumber?: number;
|
|
2801
|
+
}): {
|
|
2802
|
+
field: FormFieldDTO<PdfCoordinates>;
|
|
2803
|
+
widget: FormWidget;
|
|
1880
2804
|
};
|
|
1881
|
-
detachWidget(ref: FormFieldRef, widget:
|
|
1882
|
-
field: FormFieldDTO
|
|
2805
|
+
detachWidget(ref: FormFieldRef, widget: AnnotationRef, signal: AbortSignal): {
|
|
2806
|
+
field: FormFieldDTO<PdfCoordinates>;
|
|
2807
|
+
widget: FormWidget;
|
|
1883
2808
|
};
|
|
1884
|
-
private placementsOf;
|
|
1885
2809
|
private applyOptions;
|
|
1886
2810
|
private applyWideSetter;
|
|
1887
|
-
|
|
2811
|
+
/** Write a field's default (`/DV`) when it changes. */
|
|
2812
|
+
private writeDefault;
|
|
1888
2813
|
private readBackField;
|
|
1889
2814
|
private assertWritable;
|
|
2815
|
+
/** A field an earlier signature locked refuses every write (see `readFieldLocks`). */
|
|
2816
|
+
private assertNotLockedBySignature;
|
|
2817
|
+
/** Run the native value write. Returns the changed widget objnums. */
|
|
1890
2818
|
/**
|
|
1891
|
-
*
|
|
1892
|
-
*
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
2819
|
+
* Write what `after` holds that `before` doesn't, as engine-core worked it
|
|
2820
|
+
* out: `/V`; a checkbox's or radio group's widgets on or off; a choice
|
|
2821
|
+
* field's selected options (`/I`); and a text or choice field's new
|
|
2822
|
+
* pictures (also with `redraw`, for new options). Returns the widgets whose
|
|
2823
|
+
* pictures changed, or `null` when the field already held it all and
|
|
2824
|
+
* nothing was written.
|
|
1896
2825
|
*/
|
|
1897
|
-
private
|
|
1898
|
-
/** Dispatch the typed native write. Returns the changed widget objnums. */
|
|
1899
|
-
private applyWrite;
|
|
2826
|
+
private writeFieldAfter;
|
|
1900
2827
|
/** Run a native write with the changed-widgets out buffer wired up. */
|
|
1901
2828
|
private withChangedWidgets;
|
|
1902
2829
|
/** Bump the session version, rebuild the model, and read the field back. */
|
|
1903
2830
|
private readBack;
|
|
1904
2831
|
}
|
|
1905
2832
|
//#endregion
|
|
1906
|
-
//#region src/features/forms/FormsEffectsApplier.d.ts
|
|
1907
|
-
/** Ordered, non-rollback-atomic sink for one committed client script run. */
|
|
1908
|
-
declare class FormsEffectsApplier {
|
|
1909
|
-
private readonly runtime;
|
|
1910
|
-
private readonly session;
|
|
1911
|
-
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1912
|
-
apply(effects: FormEffect[], signal: AbortSignal): FormEffectsResult;
|
|
1913
|
-
private preflight;
|
|
1914
|
-
private resolve;
|
|
1915
|
-
private readField;
|
|
1916
|
-
private readFieldsBestEffort;
|
|
1917
|
-
private applyNative;
|
|
1918
|
-
private applyValue;
|
|
1919
|
-
private withChangedWidgets;
|
|
1920
|
-
}
|
|
1921
|
-
//#endregion
|
|
1922
2833
|
//#region src/features/forms/internal/formModelCache.d.ts
|
|
1923
2834
|
/** Close and forget the session's cached model, if any. */
|
|
1924
2835
|
declare function disposeFormModel(runtime: PdfRuntimeModule, session: DocumentSession): void;
|
|
@@ -1929,26 +2840,26 @@ declare function disposeFormModel(runtime: PdfRuntimeModule, session: DocumentSe
|
|
|
1929
2840
|
* trust boundary (worker locally, server process in the cloud):
|
|
1930
2841
|
*
|
|
1931
2842
|
* extract — page text via the session corpus cache (version-keyed on
|
|
1932
|
-
* `
|
|
2843
|
+
* `cacheSeq`, so results always reflect the current layer
|
|
1933
2844
|
* view — text a redaction removed is unfindable),
|
|
1934
2845
|
* match — the pure engine-core matcher (identical code on every
|
|
1935
2846
|
* engine; parity by construction),
|
|
1936
2847
|
* anchor — geometry read only for pages that actually matched, rects
|
|
1937
2848
|
* via the selection line-merge (one rect per visual line).
|
|
1938
2849
|
*
|
|
1939
|
-
* Scope gating (`doc.text.search`, `doc.text.copy` for
|
|
2850
|
+
* Scope gating (`doc.text.search`, `doc.text.copy` for snippets) is the
|
|
1940
2851
|
* caller's job — this reader assumes an authorized request.
|
|
1941
2852
|
*/
|
|
1942
2853
|
declare class SearchReader {
|
|
1943
2854
|
private readonly runtime;
|
|
1944
2855
|
private readonly session;
|
|
1945
2856
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1946
|
-
query(request:
|
|
2857
|
+
query(request: SearchScanRequest, signal: AbortSignal, slices: Slices): Promise<SearchSlice<PdfCoordinates>>;
|
|
1947
2858
|
}
|
|
1948
2859
|
//#endregion
|
|
1949
2860
|
//#region src/features/actions/ActionModelReader.d.ts
|
|
1950
2861
|
/** Mutable aggregate budget shared by every action model in one read job.
|
|
1951
|
-
* Payload budgets are
|
|
2862
|
+
* Payload budgets are reserved before the backing buffer is allocated. */
|
|
1952
2863
|
declare class ActionReadBudgetTracker {
|
|
1953
2864
|
private readonly limits;
|
|
1954
2865
|
private models;
|
|
@@ -1959,9 +2870,9 @@ declare class ActionReadBudgetTracker {
|
|
|
1959
2870
|
constructor(limits?: ActionReadBudget);
|
|
1960
2871
|
addModel(nodeCount: number): void;
|
|
1961
2872
|
addScript(script: string): void;
|
|
1962
|
-
/** Charge target entries
|
|
2873
|
+
/** Charge target entries before the target array is walked. */
|
|
1963
2874
|
reserveTargets(count: number): void;
|
|
1964
|
-
/** Charge payload text
|
|
2875
|
+
/** Charge payload text before the scratch buffer for it is allocated. */
|
|
1965
2876
|
reservePayloadBytes(length: number): void;
|
|
1966
2877
|
private assertWithinBudget;
|
|
1967
2878
|
}
|
|
@@ -1978,7 +2889,7 @@ declare class ActionReadBudgetTracker {
|
|
|
1978
2889
|
* `subtype`, and the tree gains the `'payload-dropped'` warning — impossible
|
|
1979
2890
|
* states stay unrepresentable while malformed documents stay readable.
|
|
1980
2891
|
*/
|
|
1981
|
-
declare function readActionModel(fn: PdfFunctions, mem: PdfRuntimeMemory, docPtr: Ptr, modelPtr: Ptr, budget: ActionReadBudgetTracker): PdfActionTree | null;
|
|
2892
|
+
declare function readActionModel(fn: PdfFunctions, mem: PdfRuntimeMemory, docPtr: Ptr, modelPtr: Ptr, budget: ActionReadBudgetTracker): PdfActionTree<PdfDestination> | null;
|
|
1982
2893
|
//#endregion
|
|
1983
2894
|
//#region src/features/actions/DocumentActionsReader.d.ts
|
|
1984
2895
|
/** Read catalog-owned actions. Extraction only; no action is executed. */
|
|
@@ -1986,11 +2897,11 @@ declare class DocumentActionsReader {
|
|
|
1986
2897
|
private readonly runtime;
|
|
1987
2898
|
private readonly session;
|
|
1988
2899
|
constructor(runtime: PdfRuntimeModule, session: DocumentSession);
|
|
1989
|
-
read(signal: AbortSignal): DocumentActionsSnapshot
|
|
2900
|
+
read(signal: AbortSignal): DocumentActionsSnapshot<PdfDestination>;
|
|
1990
2901
|
}
|
|
1991
2902
|
//#endregion
|
|
1992
2903
|
//#region src/worker-host/WorkerHost.d.ts
|
|
1993
|
-
/** The image a {@link WorkerImageEncoder} produced. `bytes` must
|
|
2904
|
+
/** The image a {@link WorkerImageEncoder} produced. `bytes` must own its
|
|
1994
2905
|
* buffer (a fresh allocation, not a pooled `Buffer` slab view) — it is
|
|
1995
2906
|
* placed on the transfer manifest and moved zero-copy. */
|
|
1996
2907
|
interface WorkerEncodedImage {
|
|
@@ -1999,7 +2910,7 @@ interface WorkerEncodedImage {
|
|
|
1999
2910
|
}
|
|
2000
2911
|
/**
|
|
2001
2912
|
* Injected image-encode capability for the `*.renderEncoded` wire kinds.
|
|
2002
|
-
* Dependency inversion keeps the native encoder
|
|
2913
|
+
* Dependency inversion keeps the native encoder out of this shared
|
|
2003
2914
|
* package: the cloud server's worker entry injects a sharp/libvips
|
|
2004
2915
|
* implementation; browser/local entries inject nothing (they encode via
|
|
2005
2916
|
* canvas) and the encoded kinds reject with `NotImplemented`.
|
|
@@ -2019,6 +2930,23 @@ interface WorkerHostOptions {
|
|
|
2019
2930
|
* the sealed file can be published by rename.
|
|
2020
2931
|
*/
|
|
2021
2932
|
signingCandidatePath?: (basePath: string, signingId: string) => string;
|
|
2933
|
+
/**
|
|
2934
|
+
* Bytes of decoded images kept between jobs that write nothing (see
|
|
2935
|
+
* {@link DecodedImageStore}). Defaults to 128 MB; 0 keeps none.
|
|
2936
|
+
*/
|
|
2937
|
+
decodedImageBudgetBytes?: number;
|
|
2938
|
+
/**
|
|
2939
|
+
* Bytes of parsed pages kept between jobs, for every document on this
|
|
2940
|
+
* thread (see {@link PageResidency}). Defaults to
|
|
2941
|
+
* {@link DEFAULT_PAGE_RESIDENCY_POLICY}'s; 0 keeps none.
|
|
2942
|
+
*/
|
|
2943
|
+
parsedPageBudgetBytes?: number;
|
|
2944
|
+
/**
|
|
2945
|
+
* Milliseconds a job's PDFium work runs (a page render, a page load, a loop
|
|
2946
|
+
* over glyphs or annotations) before it lets this thread receive messages,
|
|
2947
|
+
* so an abort stops it about this soon. Defaults to {@link DEFAULT_SLICE_MS}.
|
|
2948
|
+
*/
|
|
2949
|
+
sliceMs?: number;
|
|
2022
2950
|
}
|
|
2023
2951
|
/**
|
|
2024
2952
|
* The piece that runs "inside the worker": owns runtime, manages document
|
|
@@ -2054,6 +2982,21 @@ declare class WorkerHost {
|
|
|
2054
2982
|
*/
|
|
2055
2983
|
private readonly fontIds;
|
|
2056
2984
|
private readonly fonts;
|
|
2985
|
+
/** Parsed pages kept between jobs, for every session on this runtime. */
|
|
2986
|
+
private readonly residency;
|
|
2987
|
+
/** Image decodes kept between jobs that write nothing, for every session on this runtime. */
|
|
2988
|
+
private readonly decodedImages;
|
|
2989
|
+
private readonly slices;
|
|
2990
|
+
/**
|
|
2991
|
+
* True while a job's PDFium work is in progress across slices (a render, a
|
|
2992
|
+
* page load, a glyph loop). It pauses between slices so this thread can
|
|
2993
|
+
* receive an abort, but nothing else may use PDFium meanwhile (a render
|
|
2994
|
+
* holds its page until it ends): requests that arrive are held (see
|
|
2995
|
+
* {@link receive}).
|
|
2996
|
+
*/
|
|
2997
|
+
private busy;
|
|
2998
|
+
/** Requests that arrived while a job was busy, in arrival order (see {@link takeHeld}). */
|
|
2999
|
+
private readonly held;
|
|
2057
3000
|
private destroyed;
|
|
2058
3001
|
constructor(runtime: PdfRuntimeModule,
|
|
2059
3002
|
/**
|
|
@@ -2076,20 +3019,47 @@ declare class WorkerHost {
|
|
|
2076
3019
|
*/
|
|
2077
3020
|
registerStartupFonts(specs: readonly StartupFontSpec[]): void;
|
|
2078
3021
|
receive(msg: WorkerRequest): void;
|
|
3022
|
+
/** What a view shows of a document: the order its kept pages close in. Never answered. */
|
|
3023
|
+
private setWorkingSet;
|
|
3024
|
+
/** Stops a running job, or answers a held one as aborted without running it. */
|
|
3025
|
+
private abort;
|
|
3026
|
+
/** Runs held requests until one is busy across slices. */
|
|
3027
|
+
private drain;
|
|
3028
|
+
/**
|
|
3029
|
+
* The next held request. Requests run in arrival order, except that of page
|
|
3030
|
+
* renders held one after another, a render whose page is parsed runs before
|
|
3031
|
+
* one that must parse it. A render never passes another kind of request, nor
|
|
3032
|
+
* the other way round.
|
|
3033
|
+
*/
|
|
3034
|
+
private takeHeld;
|
|
3035
|
+
/** Whether the render's page is kept, so the render parses nothing. */
|
|
3036
|
+
private pageIsKept;
|
|
3037
|
+
private run;
|
|
3038
|
+
/**
|
|
3039
|
+
* The session a job writes to, when it runs as a transaction: a write to an
|
|
3040
|
+
* open, usable layer document. Anything else (no such session, a locked
|
|
3041
|
+
* one) gets its handler's own error.
|
|
3042
|
+
*/
|
|
3043
|
+
private transactedSession;
|
|
3044
|
+
/** Closes the pages a job of this effect may change, as no job holds them. */
|
|
3045
|
+
private closePagesChangedBy;
|
|
3046
|
+
/**
|
|
3047
|
+
* Answers a job with its result in page space. The handler decided which
|
|
3048
|
+
* buffers to move; the host relays that decision on the `resolve` envelope.
|
|
3049
|
+
*/
|
|
3050
|
+
private resolve;
|
|
3051
|
+
/** The visible boxes of the request's document, read only when a result asks for one. */
|
|
3052
|
+
private visibleBoxesFor;
|
|
2079
3053
|
private handleOpen;
|
|
2080
3054
|
/**
|
|
2081
|
-
* Open
|
|
2082
|
-
*
|
|
2083
|
-
*
|
|
2084
|
-
*
|
|
2085
|
-
*
|
|
2086
|
-
*
|
|
2087
|
-
* carry a signature value, which always opens as a layer, because a plain
|
|
2088
|
-
* save rewrites every loaded object into the new revision and strict
|
|
2089
|
-
* validators reject that. Auto-layered sessions serialize no artifact per
|
|
2090
|
-
* mutation: the caller never asked for one.
|
|
3055
|
+
* Open bytes into `session` as an immutable base with a fresh layer on top:
|
|
3056
|
+
* reads fall through to the base, a write promotes only what it touches and
|
|
3057
|
+
* runs as a layer transaction, a save appends exactly that, and a signature
|
|
3058
|
+
* keeps its validity across later edits because the signature dictionary is
|
|
3059
|
+
* never rewritten. The session serializes no artifact per mutation: the
|
|
3060
|
+
* caller holds the document, not a layer.
|
|
2091
3061
|
*/
|
|
2092
|
-
private
|
|
3062
|
+
private openBytesAsLayer;
|
|
2093
3063
|
/**
|
|
2094
3064
|
* What the document's signatures forbid, read at open and after an
|
|
2095
3065
|
* unlock so the main-thread guard can subtract capabilities before the
|
|
@@ -2112,64 +3082,124 @@ declare class WorkerHost {
|
|
|
2112
3082
|
* session that is never stored in `this.sessions`.
|
|
2113
3083
|
*/
|
|
2114
3084
|
private handleSignaturesFinalizeCandidate;
|
|
2115
|
-
private
|
|
3085
|
+
private handleSignaturesCancel;
|
|
2116
3086
|
/**
|
|
2117
|
-
* The dispatch fence for a parked signing candidate. Only
|
|
2118
|
-
*
|
|
2119
|
-
* to its handler's own `DocNotOpen`.
|
|
3087
|
+
* The dispatch fence for a parked signing candidate. Only writes are
|
|
3088
|
+
* refused, except the signing's own completion; a request for a session
|
|
3089
|
+
* that is not open falls through to its handler's own `DocNotOpen`.
|
|
2120
3090
|
*/
|
|
2121
3091
|
private assertNoPendingSigning;
|
|
2122
3092
|
private handleMetadataRead;
|
|
2123
3093
|
private handleMetadataUpdate;
|
|
3094
|
+
private handleMetadataReadCustom;
|
|
3095
|
+
private handleMetadataUpdateCustom;
|
|
2124
3096
|
private handleActionsRead;
|
|
2125
|
-
private
|
|
2126
|
-
private
|
|
2127
|
-
private handleAnnotationsListFullPage;
|
|
3097
|
+
private handleOutlineRead;
|
|
3098
|
+
private handleAnnotationsList;
|
|
2128
3099
|
private handleAnnotationsRenderAppearances;
|
|
2129
3100
|
private handleAnnotationsCreate;
|
|
2130
3101
|
private handleAnnotationsUpdate;
|
|
2131
3102
|
private handleAnnotationsDelete;
|
|
2132
3103
|
private handleAnnotationsFlatten;
|
|
2133
3104
|
private handleAnnotationsExportAppearance;
|
|
2134
|
-
private
|
|
3105
|
+
private handleAnnotationsExport;
|
|
3106
|
+
/**
|
|
3107
|
+
* An import, as a one-op change: kept under its `opId` with the record
|
|
3108
|
+
* that undoes it, and a retry under it gets the first answer.
|
|
3109
|
+
*/
|
|
3110
|
+
private handleAnnotationsImport;
|
|
3111
|
+
private handleAnnotationsReadAppearance;
|
|
3112
|
+
private handleAnnotationsReorder;
|
|
3113
|
+
/**
|
|
3114
|
+
* `doc.apply`: one change, in the job's transaction. A change asked again
|
|
3115
|
+
* under its `opId` answers what it answered the first time, refusals
|
|
3116
|
+
* included, and a different change under it is refused. An undo runs the
|
|
3117
|
+
* record its change left, when the same user asks and nothing ended undo
|
|
3118
|
+
* since.
|
|
3119
|
+
*/
|
|
3120
|
+
private handleDocumentApply;
|
|
3121
|
+
/**
|
|
3122
|
+
* A single verb as a one-op change: the same op, checks and record as
|
|
3123
|
+
* `doc.apply`, so its `opId` undoes it, and a retry under it gets the first
|
|
3124
|
+
* answer. What the handle may do was checked before the job; `authority`
|
|
3125
|
+
* carries who the write acts for, and what it checks per annotation.
|
|
3126
|
+
*/
|
|
3127
|
+
private applyOne;
|
|
3128
|
+
/**
|
|
3129
|
+
* A change's answer the first time, kept under its `opId`; a retry's
|
|
3130
|
+
* checks. The answer is in the space its job answered in (`ChangeOutcome`).
|
|
3131
|
+
*/
|
|
3132
|
+
private replayed;
|
|
3133
|
+
/**
|
|
3134
|
+
* Runs a change and keeps its answer under `opId`: the result and the record
|
|
3135
|
+
* that undoes it, or a refusal the change keeps (see `isKeptRefusal`).
|
|
3136
|
+
*/
|
|
3137
|
+
private recorded;
|
|
3138
|
+
/**
|
|
3139
|
+
* A server request's changes (`POST …/changes`) as one job: each in its own
|
|
3140
|
+
* transaction, committed or rolled back on its own, its record handed back
|
|
3141
|
+
* for the server to keep. An undo of an earlier change of the same request
|
|
3142
|
+
* runs the record this job kept for it. One artifact for all that applied.
|
|
3143
|
+
*/
|
|
3144
|
+
private handleDocumentApplyChanges;
|
|
3145
|
+
/**
|
|
3146
|
+
* Page space for a change, measured as each op runs: the page boxes are read
|
|
3147
|
+
* anew each time, as an op can add, remove or put back the page a later
|
|
3148
|
+
* one names.
|
|
3149
|
+
*/
|
|
3150
|
+
private pageSpaceOf;
|
|
3151
|
+
/** A change's ops, or the steps of the record an undo names. */
|
|
3152
|
+
private runChange;
|
|
2135
3153
|
private handlePagesList;
|
|
2136
|
-
private handlePagesMove;
|
|
2137
|
-
private handlePagesRotate;
|
|
2138
|
-
private handlePagesDelete;
|
|
2139
3154
|
private handlePagesSetName;
|
|
2140
3155
|
private handlePagesRemoveName;
|
|
2141
3156
|
private handlePagesFlatten;
|
|
2142
3157
|
private handleRedactionApply;
|
|
2143
3158
|
private handlePagesExtract;
|
|
2144
|
-
private handlePagesInsert;
|
|
2145
|
-
private handlePagesInsertBlank;
|
|
2146
3159
|
private handleAttachmentsList;
|
|
2147
3160
|
private handleAttachmentsReadFile;
|
|
2148
|
-
private handleAttachmentsCreate;
|
|
2149
|
-
private handleAttachmentsDelete;
|
|
2150
3161
|
private handleAnnotationsReadFile;
|
|
2151
3162
|
private handleMeasureViewports;
|
|
2152
3163
|
private handleMeasureSetScale;
|
|
2153
3164
|
private handlePieceInfoRead;
|
|
2154
3165
|
private handlePieceInfoUpdate;
|
|
2155
3166
|
private handlePieceInfoApplications;
|
|
2156
|
-
private
|
|
3167
|
+
private handlePieceInfoDelete;
|
|
2157
3168
|
private handlePagesText;
|
|
2158
3169
|
private handlePagesGeometry;
|
|
2159
3170
|
private handleSearchQuery;
|
|
2160
3171
|
private handlePagesRender;
|
|
2161
|
-
|
|
3172
|
+
/**
|
|
3173
|
+
* The work of a job that pauses between slices, or null for one that runs in
|
|
3174
|
+
* one go: renders, and the reads that load a page (its text, geometry,
|
|
3175
|
+
* annotation appearances, measurement viewports, an annotation's file) or
|
|
3176
|
+
* many (a search). Writes never pause: a read must never see half of one.
|
|
3177
|
+
*/
|
|
3178
|
+
private slicedWork;
|
|
3179
|
+
/**
|
|
3180
|
+
* A job that pauses between slices of its PDFium work, so this thread can
|
|
3181
|
+
* receive an abort meanwhile. Until that work ends (`busy`), requests are
|
|
3182
|
+
* held. An encoded kind then encodes while other requests run.
|
|
3183
|
+
*/
|
|
3184
|
+
private runSliced;
|
|
2162
3185
|
private encodeRaster;
|
|
2163
|
-
|
|
2164
|
-
private
|
|
2165
|
-
|
|
3186
|
+
/** The encoded reply of a page render's raw one. */
|
|
3187
|
+
private encodeRendered;
|
|
3188
|
+
/** The encoded reply of an appearance render's raw one, its rasters encoded one by one. */
|
|
3189
|
+
private encodeAppearances;
|
|
3190
|
+
/**
|
|
3191
|
+
* A rewrite drops every revision, and with them every signature: a signed
|
|
3192
|
+
* document refuses it unless the session permits breaking signatures
|
|
3193
|
+
* (`signedDocumentPolicy: 'permit'`). One rule for both engines.
|
|
3194
|
+
*/
|
|
3195
|
+
private assertRewriteKeepsSignatures;
|
|
2166
3196
|
private handleDocumentSaveBuffer;
|
|
2167
3197
|
private handleDocumentSaveFile;
|
|
2168
3198
|
private handleDocumentSaveLayerBuffer;
|
|
2169
3199
|
private handleDocumentProbeSecurityFile;
|
|
2170
3200
|
/**
|
|
2171
3201
|
* One-shot file render (the derived-artifact warmer's producer): open the
|
|
2172
|
-
* base from a file path into a
|
|
3202
|
+
* base from a file path into a transient session — never stored in
|
|
2173
3203
|
* `this.sessions`, so it can't collide with (or leak into) live document
|
|
2174
3204
|
* sessions — resolve the display index to its durable page object number,
|
|
2175
3205
|
* render, close. Shares the base parse with concurrent ad-hoc opens of
|
|
@@ -2185,7 +3215,7 @@ declare class WorkerHost {
|
|
|
2185
3215
|
private handleFontsClearFallbacks;
|
|
2186
3216
|
private handleFontsClear;
|
|
2187
3217
|
/**
|
|
2188
|
-
* Close exactly
|
|
3218
|
+
* Close exactly one layer session — the reload seam for layer-session
|
|
2189
3219
|
* freshness. The base document's refcount releases through the session's
|
|
2190
3220
|
* close stack, so sibling layer sessions (and the base session) are
|
|
2191
3221
|
* untouched. Idempotent: closing an absent session is a no-op ack,
|
|
@@ -2207,19 +3237,28 @@ declare class WorkerHost {
|
|
|
2207
3237
|
private handleFormsList;
|
|
2208
3238
|
private handleFormsSetValue;
|
|
2209
3239
|
private handleFormsReset;
|
|
2210
|
-
private handleFormsApplyEffects;
|
|
2211
3240
|
private handleFormsExport;
|
|
3241
|
+
/**
|
|
3242
|
+
* A design import, as a one-op change: kept under its `opId` with the
|
|
3243
|
+
* record that undoes it, and a retry under it gets the first answer.
|
|
3244
|
+
*/
|
|
2212
3245
|
private handleFormsImport;
|
|
3246
|
+
/** A values import, as a one-op change (see {@link handleFormsImport}). */
|
|
3247
|
+
private handleFormsImportValues;
|
|
2213
3248
|
private handleFormsRepair;
|
|
2214
3249
|
private handleFormsCreateField;
|
|
2215
3250
|
private handleFormsUpdateField;
|
|
2216
3251
|
private handleFormsSetSignatureAppearance;
|
|
2217
3252
|
private handleFormsDeleteField;
|
|
2218
|
-
private
|
|
3253
|
+
private handleFormsAddWidget;
|
|
2219
3254
|
private handleFormsDetachWidget;
|
|
3255
|
+
private handleFormsUpdateWidget;
|
|
3256
|
+
private handleFormsDeleteWidget;
|
|
3257
|
+
private handleFormsReorderCalculations;
|
|
3258
|
+
private handleFormsReorderWidgets;
|
|
2220
3259
|
private finishMutation;
|
|
2221
3260
|
private saveLayerArtifact;
|
|
2222
3261
|
}
|
|
2223
3262
|
//#endregion
|
|
2224
|
-
export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationFlattener, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CandidateFinalizer, CloseStack, DIGEST_CODE, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT,
|
|
3263
|
+
export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationBatchApplier, AnnotationExporter, AnnotationFlattener, AnnotationImporter, AnnotationMutator, AnnotationReader, type AppliedChange, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, type BatchCreate, type BatchCreateResult, CandidateFinalizer, ChangeApplier, ChangeLedger, type ChangeOutcome, type ChangeRecord, type ChangeSpace, CloseStack, DIGEST_CODE, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT, FILE_SPACE, FontRegistrar, FormExporter, FormImporter, FormMutator, FormReader, type KeptResult, type LayerSource, MetadataMutator, MetadataReader, type OpenedPdfDocument, type OpenedPdfDocumentKind, type PackedChangeRecord, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, type RawGeometryGlyphRecord, RedactionApplier, type ReverseStep, SearchReader, SecurityReader, SignatureAnalyzer, SignatureMutator, SignatureReader, type StartupFontSpec, type UndoUnavailableReason, type WorkerEncodedImage, WorkerHost, type WorkerHostOptions, type WorkerImageEncoder, acquireSignatureModel, buildRunsFromRawGlyphs, changeLedgerOf, destroyLibrary, disposeFormModel, disposeSignatureModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, hasSignedSignature, normalizeU32, openFatMemoryDocument, openLayerDocument, packChangeRecord, pdfDateToIso, readActionModel, readAttachmentFileInfo, readRevisions, readSignaturesFromModel, readStructure, rotationAt, throwIfAborted, unpackChangeRecord, visibleBoxReader, writeAttachmentFilePayload };
|
|
2225
3264
|
//# sourceMappingURL=index.d.ts.map
|