@embedpdf/engine-core 3.0.0-next.1 → 3.0.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{AbortError-CjSasIlL.js → AbortError-8-9JAX1Y.js} +2 -2
  2. package/dist/{AbortError-CjSasIlL.js.map → AbortError-8-9JAX1Y.js.map} +1 -1
  3. package/dist/{AbortError-ByBflvEl.cjs → AbortError-CRSooKsk.cjs} +2 -2
  4. package/dist/{AbortError-ByBflvEl.cjs.map → AbortError-CRSooKsk.cjs.map} +1 -1
  5. package/dist/{AnnotationListSnapshot-W0RCsyDE.d.cts → AnnotationListSnapshot-C1U3XUxP.d.cts} +846 -127
  6. package/dist/{AnnotationListSnapshot-W0RCsyDE.d.ts → AnnotationListSnapshot-C1U3XUxP.d.ts} +846 -127
  7. package/dist/{DocumentSecurityService-Df79fgpe.d.cts → DocumentSecurityService-6rhztZlz.d.cts} +33 -2
  8. package/dist/{DocumentSecurityService-B-tULKNY.d.ts → DocumentSecurityService-7nL9aY75.d.ts} +33 -2
  9. package/dist/{Engine-B7Oe7f5i.d.ts → Engine-CWnAKccD.d.ts} +62 -19
  10. package/dist/{Engine-D9loFZc1.d.cts → Engine-D3868xIU.d.cts} +62 -19
  11. package/dist/{subtype-qejjVr6h.cjs → PageInsertBlankInput-CzShuSJI.cjs} +184 -1
  12. package/dist/PageInsertBlankInput-CzShuSJI.cjs.map +1 -0
  13. package/dist/{subtype-BvAzLCGC.js → PageInsertBlankInput-WKY0tr6S.js} +149 -2
  14. package/dist/PageInsertBlankInput-WKY0tr6S.js.map +1 -0
  15. package/dist/{builders-C548U47M.js → builders-Cdz34nbF.js} +566 -164
  16. package/dist/builders-Cdz34nbF.js.map +1 -0
  17. package/dist/{builders-BvikWRuO.cjs → builders-Do6_4KnS.cjs} +628 -220
  18. package/dist/builders-Do6_4KnS.cjs.map +1 -0
  19. package/dist/conformance.cjs +1039 -204
  20. package/dist/conformance.cjs.map +1 -1
  21. package/dist/conformance.d.cts +130 -6
  22. package/dist/conformance.d.ts +130 -6
  23. package/dist/conformance.js +994 -163
  24. package/dist/conformance.js.map +1 -1
  25. package/dist/{fold-CB4fAOOy.js → fold-BfyxxwS6.js} +162 -3
  26. package/dist/fold-BfyxxwS6.js.map +1 -0
  27. package/dist/{fold-IaMph3CO.cjs → fold-C7I5GpBz.cjs} +235 -4
  28. package/dist/fold-C7I5GpBz.cjs.map +1 -0
  29. package/dist/index.cjs +38 -19
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +5 -5
  33. package/dist/{resolver-DiPMTfcy.js → resolver-CHG4waXL.js} +2 -1
  34. package/dist/resolver-CHG4waXL.js.map +1 -0
  35. package/dist/{resolver-DAZWVoJL.cjs → resolver-D-jumvgM.cjs} +2 -1
  36. package/dist/resolver-D-jumvgM.cjs.map +1 -0
  37. package/dist/runtime.cjs +43 -24
  38. package/dist/runtime.cjs.map +1 -1
  39. package/dist/runtime.d.cts +103 -5
  40. package/dist/runtime.d.ts +103 -5
  41. package/dist/runtime.js +6 -6
  42. package/dist/{schemas-B_1VyFsm.cjs → schemas-CS5iPpX5.cjs} +305 -111
  43. package/dist/schemas-CS5iPpX5.cjs.map +1 -0
  44. package/dist/{schemas-9OpSSeM6.js → schemas-XGrNVMDd.js} +250 -92
  45. package/dist/schemas-XGrNVMDd.js.map +1 -0
  46. package/dist/wire.cjs +131 -4
  47. package/dist/wire.cjs.map +1 -1
  48. package/dist/wire.d.cts +277 -20
  49. package/dist/wire.d.ts +277 -20
  50. package/dist/wire.js +120 -5
  51. package/dist/wire.js.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/builders-BvikWRuO.cjs.map +0 -1
  54. package/dist/builders-C548U47M.js.map +0 -1
  55. package/dist/fold-CB4fAOOy.js.map +0 -1
  56. package/dist/fold-IaMph3CO.cjs.map +0 -1
  57. package/dist/resolver-DAZWVoJL.cjs.map +0 -1
  58. package/dist/resolver-DiPMTfcy.js.map +0 -1
  59. package/dist/schemas-9OpSSeM6.js.map +0 -1
  60. package/dist/schemas-B_1VyFsm.cjs.map +0 -1
  61. package/dist/subtype-BvAzLCGC.js.map +0 -1
  62. package/dist/subtype-qejjVr6h.cjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Hs as DocCapability, Us as IdentityClaims, Ys as PdfBits } from "./AnnotationListSnapshot-W0RCsyDE.cjs";
1
+ import { Dc as DocCapability, Oc as IdentityClaims, Pc as PdfBits, cc as CollabTarget } from "./AnnotationListSnapshot-C1U3XUxP.cjs";
2
2
  //#region src/promise/AbortablePromise.d.ts
3
3
  type AbortableExecutor<T, P> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: unknown) => void, progress: (p: P) => void, signal: AbortSignal) => void;
4
4
  /**
@@ -312,6 +312,37 @@ interface DocumentSecurityService {
312
312
  * only to *display* the concrete grants.
313
313
  */
314
314
  allows(capability: DocCapability): boolean;
315
+ /**
316
+ * Per-record annotation authorization mirrors — the SAME resolver the
317
+ * engine enforces with (`checkCollab`'s narrowing rule: an applicable
318
+ * `annotations:<action>:<filter>` grant SHADOWS the coarse
319
+ * `doc.annotate.modify` fallback for that action), over the same
320
+ * inputs (raw scope + identity claims + PDF bits). `allows()` cannot
321
+ * answer these: it enumerates capabilities, and a filtered collab
322
+ * grant is not a capability — whether "update" is allowed depends on
323
+ * WHOSE annotation you're touching.
324
+ *
325
+ * Three surfaces because the questions genuinely differ:
326
+ * - create derives its target from the caller's OWN identity
327
+ * (`:self` trivially passes; `:group=X` matches the caller's
328
+ * default group),
329
+ * - update/delete are asked about the TARGET record's stamped
330
+ * owner (`userId`/`groupId` from its EMBD metadata; pass `{}`
331
+ * when unstamped — matching the engine, which denies unstamped
332
+ * targets under any narrowed grant),
333
+ * - group assignment is asked about the DESTINATION group
334
+ * (`annotations:set-group:` ladder; the caller's own default
335
+ * group is always assignable).
336
+ *
337
+ * These are a courtesy for UI gating — the engine (and the server,
338
+ * on cloud) independently enforces every mutation with the same
339
+ * predicates, so a stale or bypassed answer here never widens
340
+ * access. Returns false when no scope context exists (legacy local
341
+ * open without `scope`, cloud open without a token before /access).
342
+ */
343
+ allowsAnnotationCreate(): boolean;
344
+ allowsAnnotationMutation(action: 'update' | 'delete', target: CollabTarget): boolean;
345
+ allowsAnnotationGroupAssignment(groupId: string): boolean;
315
346
  /**
316
347
  * Identity of the current caller, or null when anonymous.
317
348
  */
@@ -329,4 +360,4 @@ interface DocumentSecurityService {
329
360
  }
330
361
  //#endregion
331
362
  export { DocumentEncryptionState as a, DocumentSecurityState as c, PdfPermissionAdvisory as d, PdfPermissionInfo as f, AbortablePromise as g, AbortableExecutor as h, DocumentAccessReason as i, DocumentUnlockInput as l, passwordPromptFromState as m, CdnAdapter as n, DocumentOpenMode as o, PasswordPrompt as p, DocumentAccessInfo as r, DocumentSecurityService as s, CdnAccessInfo as t, DocumentUnlockResult as u };
332
- //# sourceMappingURL=DocumentSecurityService-Df79fgpe.d.cts.map
363
+ //# sourceMappingURL=DocumentSecurityService-6rhztZlz.d.cts.map
@@ -1,4 +1,4 @@
1
- import { Hs as DocCapability, Us as IdentityClaims, Ys as PdfBits } from "./AnnotationListSnapshot-W0RCsyDE.js";
1
+ import { Dc as DocCapability, Oc as IdentityClaims, Pc as PdfBits, cc as CollabTarget } from "./AnnotationListSnapshot-C1U3XUxP.js";
2
2
  //#region src/promise/AbortablePromise.d.ts
3
3
  type AbortableExecutor<T, P> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason: unknown) => void, progress: (p: P) => void, signal: AbortSignal) => void;
4
4
  /**
@@ -312,6 +312,37 @@ interface DocumentSecurityService {
312
312
  * only to *display* the concrete grants.
313
313
  */
314
314
  allows(capability: DocCapability): boolean;
315
+ /**
316
+ * Per-record annotation authorization mirrors — the SAME resolver the
317
+ * engine enforces with (`checkCollab`'s narrowing rule: an applicable
318
+ * `annotations:<action>:<filter>` grant SHADOWS the coarse
319
+ * `doc.annotate.modify` fallback for that action), over the same
320
+ * inputs (raw scope + identity claims + PDF bits). `allows()` cannot
321
+ * answer these: it enumerates capabilities, and a filtered collab
322
+ * grant is not a capability — whether "update" is allowed depends on
323
+ * WHOSE annotation you're touching.
324
+ *
325
+ * Three surfaces because the questions genuinely differ:
326
+ * - create derives its target from the caller's OWN identity
327
+ * (`:self` trivially passes; `:group=X` matches the caller's
328
+ * default group),
329
+ * - update/delete are asked about the TARGET record's stamped
330
+ * owner (`userId`/`groupId` from its EMBD metadata; pass `{}`
331
+ * when unstamped — matching the engine, which denies unstamped
332
+ * targets under any narrowed grant),
333
+ * - group assignment is asked about the DESTINATION group
334
+ * (`annotations:set-group:` ladder; the caller's own default
335
+ * group is always assignable).
336
+ *
337
+ * These are a courtesy for UI gating — the engine (and the server,
338
+ * on cloud) independently enforces every mutation with the same
339
+ * predicates, so a stale or bypassed answer here never widens
340
+ * access. Returns false when no scope context exists (legacy local
341
+ * open without `scope`, cloud open without a token before /access).
342
+ */
343
+ allowsAnnotationCreate(): boolean;
344
+ allowsAnnotationMutation(action: 'update' | 'delete', target: CollabTarget): boolean;
345
+ allowsAnnotationGroupAssignment(groupId: string): boolean;
315
346
  /**
316
347
  * Identity of the current caller, or null when anonymous.
317
348
  */
@@ -329,4 +360,4 @@ interface DocumentSecurityService {
329
360
  }
330
361
  //#endregion
331
362
  export { DocumentEncryptionState as a, DocumentSecurityState as c, PdfPermissionAdvisory as d, PdfPermissionInfo as f, AbortablePromise as g, AbortableExecutor as h, DocumentAccessReason as i, DocumentUnlockInput as l, passwordPromptFromState as m, CdnAdapter as n, DocumentOpenMode as o, PasswordPrompt as p, DocumentAccessInfo as r, DocumentSecurityService as s, CdnAccessInfo as t, DocumentUnlockResult as u };
332
- //# sourceMappingURL=DocumentSecurityService-B-tULKNY.d.ts.map
363
+ //# sourceMappingURL=DocumentSecurityService-7nL9aY75.d.ts.map
@@ -1,5 +1,5 @@
1
- import { Aa as EmbeddedFileItem, Ai as AnnotationCreateResult, Ao as PageImageHandle, Ar as FormFieldDeleteResult, Bo as PageRenderOptions, Di as FormWidgetRef, Ea as AttachmentContent, Ei as FormFieldRef, Fn as RedactionApplyScope, Fr as FormWidgetLinkResult, Gn as PageRotateResult, Gr as FormFieldPatch, Hn as PageInsertResult, Hr as FormFieldValue, Io as PageRaster, Ir as FormEffect, Jn as PageMoveResult, Jo as PageTextSnapshot, Mc as DocumentActionsSnapshot, Mi as AnnotationMoveResult, Mn as MetadataUpdateResult, Mo as PageImageOptions, Mr as FormImportResult, Ni as AnnotationUpdateResult, Nr as FormRepairResult, Or as FormDataExport, Pn as RedactionApplyResult, Pr as FormSetValueResult, So as AnnotationAppearanceRenderOptions, Tr as SearchSlice, Un as PageDeleteResult, Uo as PageRenderViewport, Vc as DocumentMetadata, Vn as PageFlattenUsage, Vr as FormDataFormat, Zr as FormFieldDraft, Zs as AnnotationRef, _o as AnnotationAppearanceImagesResult, _s as OpenOptions, do as FontSpec, ds as OpenInput, ec as PageObjectNumber, go as AnnotationAppearanceImageOptions, ii as FormSnapshot, ja as EmbeddedFileRef, ji as AnnotationDeleteResult, jr as FormFieldUpdateResult, ka as AttachmentFileSource, kc as PdfRotation, kr as FormFieldCreateResult, l as AnnotationPatch, la as AttachmentCreateResult, lo as FontHandle, n as AnnotationListSnapshotAllPages, o as AnnotationDraft, os as PageListSnapshot, pi as FormFieldDTO, po as PdfSaveMode, qo as PageGeometrySnapshot, t as AnnotationListPageSnapshot, ua as AttachmentDeleteResult, uo as FontKey, us as MetadataPatch, wo as AnnotationAppearancesResult, wr as SearchRequest, zn as PageFlattenResult, zr as FormEffectsResult } from "./AnnotationListSnapshot-W0RCsyDE.js";
2
- import { g as AbortablePromise, s as DocumentSecurityService } from "./DocumentSecurityService-B-tULKNY.js";
1
+ import { $i as AnnotationUpdateResult, $r as FormEffectsResult, Dr as SearchRequest, Fa as AttachmentDeleteResult, Fn as RedactionApplyScope, Fo as FontKey, Gn as PageDeleteResult, Gr as FormFieldUpdateResult, Ho as AnnotationAppearanceImagesResult, Hr as FormDataExport, Ic as AnnotationRef, Io as FontSpec, Jr as FormSetValueResult, Js as MetadataPatch, Ki as FormFieldRef, Kr as FormImportResult, Mn as MetadataUpdateResult, Ni as FormFieldDTO, Or as SearchSlice, Pa as AttachmentCreateResult, Pn as RedactionApplyResult, Po as FontHandle, Qi as AnnotationMoveResult, Ro as PdfSaveMode, Ts as PageTextSnapshot, Un as PageInsertBlankSpec, Ur as FormFieldCreateResult, Vn as PageFlattenUsage, Vo as AnnotationAppearanceImageOptions, Wn as PageInsertResult, Wr as FormFieldDeleteResult, Ws as PageListSnapshot, Xi as AnnotationCreateResult, Xn as PageMoveResult, Xr as FormEffect, Yo as AnnotationAppearancesResult, Yr as FormWidgetLinkResult, Ys as OpenInput, Za as AttachmentContent, Zi as AnnotationDeleteResult, _i as FormFieldDraft, ai as FormSubmissionRequest, ci as FormFieldValue, di as FormFieldPatch, ds as PageRenderOptions, eo as AttachmentFileSource, fl as PdfRotation, hl as DocumentActionsSnapshot, jl as DocumentMetadata, kl as PageObjectNumber, l as AnnotationPatch, ms as PageRenderViewport, n as AnnotationListSnapshotAllPages, nc as OpenOptions, no as EmbeddedFileRef, o as AnnotationDraft, qi as FormWidgetRef, qn as PageRotateResult, qo as AnnotationAppearanceRenderOptions, qr as FormRepairResult, ri as FormSubmissionReceipt, rs as PageImageOptions, si as FormDataFormat, ss as PageRaster, t as AnnotationListPageSnapshot, to as EmbeddedFileItem, ts as PageImageHandle, vs as PageGeometrySnapshot, wi as FormSnapshot, zn as PageFlattenResult } from "./AnnotationListSnapshot-C1U3XUxP.js";
2
+ import { g as AbortablePromise, s as DocumentSecurityService } from "./DocumentSecurityService-7nL9aY75.js";
3
3
  //#region src/engine/DocumentActionsService.d.ts
4
4
  /** Lazy, catalog-owned PDF action read. This API extracts; it never executes. */
5
5
  interface DocumentActionsService {
@@ -139,6 +139,18 @@ interface DocumentFormsService {
139
139
  * skipped and any landed state is finalized as one artifact/event/version.
140
140
  */
141
141
  applyEffects?(effects: FormEffect[]): AbortablePromise<FormEffectsResult>;
142
+ /**
143
+ * Deliver a resolved form submission to the document's HOME. Present only
144
+ * where the document HAS a home that accepts submissions — the cloud
145
+ * engine when the deployment advertises the capability; the local engine
146
+ * truthfully lacks it (an in-process document has no home, and this
147
+ * contract is never a callback trampoline). Gated by `doc.forms.submit`
148
+ * (grant-minted; no PDF permission bit exists for submission), asserted
149
+ * at the home's boundary where enforcement is real. The home stores the
150
+ * dataset with the declared intent as metadata and derives WHO submitted
151
+ * from its own verified session — it never fetches the PDF's URL.
152
+ */
153
+ submit?(request: FormSubmissionRequest): AbortablePromise<FormSubmissionReceipt>;
142
154
  /**
143
155
  * Serialize the form data for interchange. Defaults to `'xfdf'` (the
144
156
  * XML sibling; UTF-8, friendliest to web pipelines) — pass `'fdf'` for
@@ -262,27 +274,37 @@ interface DocumentPagesService {
262
274
  * the source document is untouched — no revisions bump, no event is
263
275
  * published. This is how a page becomes a portable asset (a vector
264
276
  * stamp, a signature) that re-enters a document as a stamp draft's
265
- * `source` bytes.
277
+ * `source` bytes. Gated by `doc.download` (it egresses content), not
278
+ * `doc.pages.assemble`.
266
279
  *
267
- * Optional while the cloud endpoint ships (the `downloadLayer?`
268
- * pattern): the local engine implements it; the cloud engine omits it
269
- * until the server exposes extraction. Feature-detect with
270
- * `pages.extract !== undefined`.
280
+ * REQUIRED-parity, delivered: the local engine runs it in the worker,
281
+ * the cloud engine as POST /pages/extract.
271
282
  */
272
- extract?(pageObjectNumbers: PageObjectNumber[]): AbortablePromise<Uint8Array>;
283
+ extract(pageObjectNumbers: PageObjectNumber[]): AbortablePromise<Uint8Array>;
273
284
  /**
274
285
  * Insert every page of a standalone PDF (`bytes`) at `destIndex`
275
286
  * (omitted → append). The pages are COPIED in; the inserted copies get
276
287
  * fresh object numbers, returned in insertion order. Bytes are a call
277
288
  * ARGUMENT (the same law as annotation binaries): the local engine
278
- * transfers them to its worker, the cloud engine will ship them as a
279
- * multipart mutation.
289
+ * transfers them to its worker, the cloud engine ships them as a
290
+ * multipart mutation (POST /pages/insert).
280
291
  *
281
- * Slated REQUIRED-parity (a cloud viewer must be able to add pages);
282
- * optional only until the server endpoint ships — feature-detect with
283
- * `pages.insert !== undefined`.
292
+ * REQUIRED-parity, delivered — a cloud viewer must be able to add pages,
293
+ * so this is a mandatory member: any engine implements it or is not a
294
+ * conforming engine.
284
295
  */
285
- insert?(bytes: Uint8Array | ArrayBuffer, destIndex?: number): AbortablePromise<PageInsertResult>;
296
+ insert(bytes: Uint8Array | ArrayBuffer, destIndex?: number): AbortablePromise<PageInsertResult>;
297
+ /**
298
+ * Create `spec.count` (default 1) blank pages of `spec.size` (PDF points)
299
+ * at `destIndex` (omitted → append). The blank-page sibling of `insert`:
300
+ * same gate (`doc.pages.assemble`), same result shape, same
301
+ * `pages.inserted` event — it is a separate verb because its wire is pure
302
+ * parameters where `insert`'s is a binary payload (cloud: JSON
303
+ * POST /pages/insert-blank). The new pages get fresh, never-recycled
304
+ * object numbers; every pre-existing page keeps its identity and
305
+ * revisions. Mandatory, like `insert`.
306
+ */
307
+ insertBlank(spec: PageInsertBlankSpec, destIndex?: number): AbortablePromise<PageInsertResult>;
286
308
  }
287
309
  //#endregion
288
310
  //#region src/engine/DocumentRedactionService.d.ts
@@ -439,7 +461,7 @@ declare function snapTileScale(policy: EngineRenderPolicy, scale: number): numbe
439
461
  * layer is unfindable, and a cursor issued before a content mutation is
440
462
  * rejected rather than resumed over stale pages.
441
463
  *
442
- * Matches carry merged line rects from the same line-merge as text
464
+ * Matches carry canonical visual-line segments from the same layout as text
443
465
  * selection (never per-glyph boxes) and text-page character offsets that
444
466
  * join the selection/geometry subsystem directly.
445
467
  */
@@ -790,12 +812,33 @@ type DocumentEvent = ({
790
812
  } & PageFlattenResult) | ({
791
813
  type: 'redaction.applied';
792
814
  origin: EventOrigin;
793
- } & RedactionApplyResult);
815
+ } & RedactionApplyResult) | {
816
+ /**
817
+ * Cloud only: the live event stream fell too far behind to replay
818
+ * (the server's SSE `full-refresh`) — state derived from earlier
819
+ * events or snapshots may be stale, and the gap's mutations will
820
+ * NEVER arrive as events. Consumers must re-read the snapshots they
821
+ * keep fresh from this stream (`doc.annotations.listRawAll()`,
822
+ * `doc.forms.list()`, …).
823
+ *
824
+ * Carries no `EventOrigin`: it is a transport notice, not a
825
+ * document mutation — the exactly-once / results-ride-verbatim
826
+ * invariants above apply to mutation events only. The local engine
827
+ * never emits it.
828
+ */
829
+ type: 'stream.desynced';
830
+ reason: 'backlog-overflow';
831
+ ts: number;
832
+ };
794
833
  type DocumentEventType = DocumentEvent['type'];
795
834
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
796
835
  /** A `DocumentEvent` before provenance is stamped — what mutation paths
797
- * hand to their engine's publisher, which adds `origin`. */
798
- type DocumentEventInit = DistributiveOmit<DocumentEvent, 'origin'>;
836
+ * hand to their engine's publisher, which adds `origin`. Transport
837
+ * notices (`stream.desynced`) are excluded: they are published directly
838
+ * by the remote channel, never through a mutation publisher. */
839
+ type DocumentEventInit = DistributiveOmit<Exclude<DocumentEvent, {
840
+ type: 'stream.desynced';
841
+ }>, 'origin'>;
799
842
  //#endregion
800
843
  //#region src/events/DocumentEventStream.d.ts
801
844
  /**
@@ -1010,4 +1053,4 @@ interface Engine {
1010
1053
  type EngineFactory = () => Engine;
1011
1054
  //#endregion
1012
1055
  export { DocumentPagesService as A, CONTINUOUS_RENDER_POLICY as C, snapFullPageViewport as D, snapAppearanceScale as E, WeakAnnotationEditSession as F, DocumentActionsService as I, FormRepairOptions as M, DocumentAttachmentsService as N, snapTileScale as O, DocumentAnnotationsService as P, DocumentSearchService as S, EngineRenderPolicy as T, PageTextService as _, DocumentHandle as a, PageAnnotationsService as b, DocumentEventInit as c, PageHandle as d, PieceInfoService as f, PieceInfoSnapshot as g, PieceInfoPatchValue as h, DocumentCapabilities as i, DocumentFormsService as j, DocumentRedactionService as k, DocumentEventType as l, PieceInfoPatch as m, EngineFactory as n, DocumentEventStream as o, PieceInfoEntry as p, FontService as r, DocumentEvent as s, Engine as t, EventOrigin as u, PageRenderService as v, DocumentRenderService as w, MetadataService as x, PageGeometryService as y };
1013
- //# sourceMappingURL=Engine-B7Oe7f5i.d.ts.map
1056
+ //# sourceMappingURL=Engine-CWnAKccD.d.ts.map
@@ -1,5 +1,5 @@
1
- import { Aa as EmbeddedFileItem, Ai as AnnotationCreateResult, Ao as PageImageHandle, Ar as FormFieldDeleteResult, Bo as PageRenderOptions, Di as FormWidgetRef, Ea as AttachmentContent, Ei as FormFieldRef, Fn as RedactionApplyScope, Fr as FormWidgetLinkResult, Gn as PageRotateResult, Gr as FormFieldPatch, Hn as PageInsertResult, Hr as FormFieldValue, Io as PageRaster, Ir as FormEffect, Jn as PageMoveResult, Jo as PageTextSnapshot, Mc as DocumentActionsSnapshot, Mi as AnnotationMoveResult, Mn as MetadataUpdateResult, Mo as PageImageOptions, Mr as FormImportResult, Ni as AnnotationUpdateResult, Nr as FormRepairResult, Or as FormDataExport, Pn as RedactionApplyResult, Pr as FormSetValueResult, So as AnnotationAppearanceRenderOptions, Tr as SearchSlice, Un as PageDeleteResult, Uo as PageRenderViewport, Vc as DocumentMetadata, Vn as PageFlattenUsage, Vr as FormDataFormat, Zr as FormFieldDraft, Zs as AnnotationRef, _o as AnnotationAppearanceImagesResult, _s as OpenOptions, do as FontSpec, ds as OpenInput, ec as PageObjectNumber, go as AnnotationAppearanceImageOptions, ii as FormSnapshot, ja as EmbeddedFileRef, ji as AnnotationDeleteResult, jr as FormFieldUpdateResult, ka as AttachmentFileSource, kc as PdfRotation, kr as FormFieldCreateResult, l as AnnotationPatch, la as AttachmentCreateResult, lo as FontHandle, n as AnnotationListSnapshotAllPages, o as AnnotationDraft, os as PageListSnapshot, pi as FormFieldDTO, po as PdfSaveMode, qo as PageGeometrySnapshot, t as AnnotationListPageSnapshot, ua as AttachmentDeleteResult, uo as FontKey, us as MetadataPatch, wo as AnnotationAppearancesResult, wr as SearchRequest, zn as PageFlattenResult, zr as FormEffectsResult } from "./AnnotationListSnapshot-W0RCsyDE.cjs";
2
- import { g as AbortablePromise, s as DocumentSecurityService } from "./DocumentSecurityService-Df79fgpe.cjs";
1
+ import { $i as AnnotationUpdateResult, $r as FormEffectsResult, Dr as SearchRequest, Fa as AttachmentDeleteResult, Fn as RedactionApplyScope, Fo as FontKey, Gn as PageDeleteResult, Gr as FormFieldUpdateResult, Ho as AnnotationAppearanceImagesResult, Hr as FormDataExport, Ic as AnnotationRef, Io as FontSpec, Jr as FormSetValueResult, Js as MetadataPatch, Ki as FormFieldRef, Kr as FormImportResult, Mn as MetadataUpdateResult, Ni as FormFieldDTO, Or as SearchSlice, Pa as AttachmentCreateResult, Pn as RedactionApplyResult, Po as FontHandle, Qi as AnnotationMoveResult, Ro as PdfSaveMode, Ts as PageTextSnapshot, Un as PageInsertBlankSpec, Ur as FormFieldCreateResult, Vn as PageFlattenUsage, Vo as AnnotationAppearanceImageOptions, Wn as PageInsertResult, Wr as FormFieldDeleteResult, Ws as PageListSnapshot, Xi as AnnotationCreateResult, Xn as PageMoveResult, Xr as FormEffect, Yo as AnnotationAppearancesResult, Yr as FormWidgetLinkResult, Ys as OpenInput, Za as AttachmentContent, Zi as AnnotationDeleteResult, _i as FormFieldDraft, ai as FormSubmissionRequest, ci as FormFieldValue, di as FormFieldPatch, ds as PageRenderOptions, eo as AttachmentFileSource, fl as PdfRotation, hl as DocumentActionsSnapshot, jl as DocumentMetadata, kl as PageObjectNumber, l as AnnotationPatch, ms as PageRenderViewport, n as AnnotationListSnapshotAllPages, nc as OpenOptions, no as EmbeddedFileRef, o as AnnotationDraft, qi as FormWidgetRef, qn as PageRotateResult, qo as AnnotationAppearanceRenderOptions, qr as FormRepairResult, ri as FormSubmissionReceipt, rs as PageImageOptions, si as FormDataFormat, ss as PageRaster, t as AnnotationListPageSnapshot, to as EmbeddedFileItem, ts as PageImageHandle, vs as PageGeometrySnapshot, wi as FormSnapshot, zn as PageFlattenResult } from "./AnnotationListSnapshot-C1U3XUxP.cjs";
2
+ import { g as AbortablePromise, s as DocumentSecurityService } from "./DocumentSecurityService-6rhztZlz.cjs";
3
3
  //#region src/engine/DocumentActionsService.d.ts
4
4
  /** Lazy, catalog-owned PDF action read. This API extracts; it never executes. */
5
5
  interface DocumentActionsService {
@@ -139,6 +139,18 @@ interface DocumentFormsService {
139
139
  * skipped and any landed state is finalized as one artifact/event/version.
140
140
  */
141
141
  applyEffects?(effects: FormEffect[]): AbortablePromise<FormEffectsResult>;
142
+ /**
143
+ * Deliver a resolved form submission to the document's HOME. Present only
144
+ * where the document HAS a home that accepts submissions — the cloud
145
+ * engine when the deployment advertises the capability; the local engine
146
+ * truthfully lacks it (an in-process document has no home, and this
147
+ * contract is never a callback trampoline). Gated by `doc.forms.submit`
148
+ * (grant-minted; no PDF permission bit exists for submission), asserted
149
+ * at the home's boundary where enforcement is real. The home stores the
150
+ * dataset with the declared intent as metadata and derives WHO submitted
151
+ * from its own verified session — it never fetches the PDF's URL.
152
+ */
153
+ submit?(request: FormSubmissionRequest): AbortablePromise<FormSubmissionReceipt>;
142
154
  /**
143
155
  * Serialize the form data for interchange. Defaults to `'xfdf'` (the
144
156
  * XML sibling; UTF-8, friendliest to web pipelines) — pass `'fdf'` for
@@ -262,27 +274,37 @@ interface DocumentPagesService {
262
274
  * the source document is untouched — no revisions bump, no event is
263
275
  * published. This is how a page becomes a portable asset (a vector
264
276
  * stamp, a signature) that re-enters a document as a stamp draft's
265
- * `source` bytes.
277
+ * `source` bytes. Gated by `doc.download` (it egresses content), not
278
+ * `doc.pages.assemble`.
266
279
  *
267
- * Optional while the cloud endpoint ships (the `downloadLayer?`
268
- * pattern): the local engine implements it; the cloud engine omits it
269
- * until the server exposes extraction. Feature-detect with
270
- * `pages.extract !== undefined`.
280
+ * REQUIRED-parity, delivered: the local engine runs it in the worker,
281
+ * the cloud engine as POST /pages/extract.
271
282
  */
272
- extract?(pageObjectNumbers: PageObjectNumber[]): AbortablePromise<Uint8Array>;
283
+ extract(pageObjectNumbers: PageObjectNumber[]): AbortablePromise<Uint8Array>;
273
284
  /**
274
285
  * Insert every page of a standalone PDF (`bytes`) at `destIndex`
275
286
  * (omitted → append). The pages are COPIED in; the inserted copies get
276
287
  * fresh object numbers, returned in insertion order. Bytes are a call
277
288
  * ARGUMENT (the same law as annotation binaries): the local engine
278
- * transfers them to its worker, the cloud engine will ship them as a
279
- * multipart mutation.
289
+ * transfers them to its worker, the cloud engine ships them as a
290
+ * multipart mutation (POST /pages/insert).
280
291
  *
281
- * Slated REQUIRED-parity (a cloud viewer must be able to add pages);
282
- * optional only until the server endpoint ships — feature-detect with
283
- * `pages.insert !== undefined`.
292
+ * REQUIRED-parity, delivered — a cloud viewer must be able to add pages,
293
+ * so this is a mandatory member: any engine implements it or is not a
294
+ * conforming engine.
284
295
  */
285
- insert?(bytes: Uint8Array | ArrayBuffer, destIndex?: number): AbortablePromise<PageInsertResult>;
296
+ insert(bytes: Uint8Array | ArrayBuffer, destIndex?: number): AbortablePromise<PageInsertResult>;
297
+ /**
298
+ * Create `spec.count` (default 1) blank pages of `spec.size` (PDF points)
299
+ * at `destIndex` (omitted → append). The blank-page sibling of `insert`:
300
+ * same gate (`doc.pages.assemble`), same result shape, same
301
+ * `pages.inserted` event — it is a separate verb because its wire is pure
302
+ * parameters where `insert`'s is a binary payload (cloud: JSON
303
+ * POST /pages/insert-blank). The new pages get fresh, never-recycled
304
+ * object numbers; every pre-existing page keeps its identity and
305
+ * revisions. Mandatory, like `insert`.
306
+ */
307
+ insertBlank(spec: PageInsertBlankSpec, destIndex?: number): AbortablePromise<PageInsertResult>;
286
308
  }
287
309
  //#endregion
288
310
  //#region src/engine/DocumentRedactionService.d.ts
@@ -439,7 +461,7 @@ declare function snapTileScale(policy: EngineRenderPolicy, scale: number): numbe
439
461
  * layer is unfindable, and a cursor issued before a content mutation is
440
462
  * rejected rather than resumed over stale pages.
441
463
  *
442
- * Matches carry merged line rects from the same line-merge as text
464
+ * Matches carry canonical visual-line segments from the same layout as text
443
465
  * selection (never per-glyph boxes) and text-page character offsets that
444
466
  * join the selection/geometry subsystem directly.
445
467
  */
@@ -790,12 +812,33 @@ type DocumentEvent = ({
790
812
  } & PageFlattenResult) | ({
791
813
  type: 'redaction.applied';
792
814
  origin: EventOrigin;
793
- } & RedactionApplyResult);
815
+ } & RedactionApplyResult) | {
816
+ /**
817
+ * Cloud only: the live event stream fell too far behind to replay
818
+ * (the server's SSE `full-refresh`) — state derived from earlier
819
+ * events or snapshots may be stale, and the gap's mutations will
820
+ * NEVER arrive as events. Consumers must re-read the snapshots they
821
+ * keep fresh from this stream (`doc.annotations.listRawAll()`,
822
+ * `doc.forms.list()`, …).
823
+ *
824
+ * Carries no `EventOrigin`: it is a transport notice, not a
825
+ * document mutation — the exactly-once / results-ride-verbatim
826
+ * invariants above apply to mutation events only. The local engine
827
+ * never emits it.
828
+ */
829
+ type: 'stream.desynced';
830
+ reason: 'backlog-overflow';
831
+ ts: number;
832
+ };
794
833
  type DocumentEventType = DocumentEvent['type'];
795
834
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
796
835
  /** A `DocumentEvent` before provenance is stamped — what mutation paths
797
- * hand to their engine's publisher, which adds `origin`. */
798
- type DocumentEventInit = DistributiveOmit<DocumentEvent, 'origin'>;
836
+ * hand to their engine's publisher, which adds `origin`. Transport
837
+ * notices (`stream.desynced`) are excluded: they are published directly
838
+ * by the remote channel, never through a mutation publisher. */
839
+ type DocumentEventInit = DistributiveOmit<Exclude<DocumentEvent, {
840
+ type: 'stream.desynced';
841
+ }>, 'origin'>;
799
842
  //#endregion
800
843
  //#region src/events/DocumentEventStream.d.ts
801
844
  /**
@@ -1010,4 +1053,4 @@ interface Engine {
1010
1053
  type EngineFactory = () => Engine;
1011
1054
  //#endregion
1012
1055
  export { DocumentPagesService as A, CONTINUOUS_RENDER_POLICY as C, snapFullPageViewport as D, snapAppearanceScale as E, WeakAnnotationEditSession as F, DocumentActionsService as I, FormRepairOptions as M, DocumentAttachmentsService as N, snapTileScale as O, DocumentAnnotationsService as P, DocumentSearchService as S, EngineRenderPolicy as T, PageTextService as _, DocumentHandle as a, PageAnnotationsService as b, DocumentEventInit as c, PageHandle as d, PieceInfoService as f, PieceInfoSnapshot as g, PieceInfoPatchValue as h, DocumentCapabilities as i, DocumentFormsService as j, DocumentRedactionService as k, DocumentEventType as l, PieceInfoPatch as m, EngineFactory as n, DocumentEventStream as o, PieceInfoEntry as p, FontService as r, DocumentEvent as s, Engine as t, EventOrigin as u, PageRenderService as v, DocumentRenderService as w, MetadataService as x, PageGeometryService as y };
1013
- //# sourceMappingURL=Engine-D9loFZc1.d.cts.map
1056
+ //# sourceMappingURL=Engine-D3868xIU.d.cts.map
@@ -6,6 +6,14 @@ const EngineErrorCode = {
6
6
  DocOpenFailed: "DocOpenFailed",
7
7
  DocPasswordRequired: "DocPasswordRequired",
8
8
  DocPasswordIncorrect: "DocPasswordIncorrect",
9
+ /**
10
+ * A share-token exchange (`open({ kind: 'share' })`) needs the grant's
11
+ * passphrase: none was supplied, or the supplied one was rejected —
12
+ * indistinguishable by design, mirroring the server. Prompt and retry
13
+ * with `sharePassword`. Distinct from `DocPasswordRequired`, which is
14
+ * about the PDF's own encryption password.
15
+ */
16
+ SharePasswordRequired: "SharePasswordRequired",
9
17
  Aborted: "Aborted",
10
18
  Network: "Network",
11
19
  Unauthenticated: "Unauthenticated",
@@ -191,6 +199,145 @@ function subtypeFromCode(code) {
191
199
  return PDF_CODE_TO_SUBTYPE[code] ?? "unsupported";
192
200
  }
193
201
  //#endregion
202
+ //#region src/text/charmap.ts
203
+ const clampInt = (value, lo, hi) => Math.min(Math.max(Math.floor(value), lo), hi);
204
+ /** The greatest anchor with `anchor.char <= boundary` (implicit head [0,0]). */
205
+ function anchorAtOrBefore(map, boundary) {
206
+ let lo = 0;
207
+ let hi = map.length - 1;
208
+ let best = null;
209
+ while (lo <= hi) {
210
+ const mid = lo + hi >> 1;
211
+ if (map[mid][0] <= boundary) {
212
+ best = map[mid];
213
+ lo = mid + 1;
214
+ } else hi = mid - 1;
215
+ }
216
+ return best ?? [0, 0];
217
+ }
218
+ /**
219
+ * Text offset of character boundary `boundary` (clamped into
220
+ * [0, charCount]). For a dropped character this is the offset of the next
221
+ * real text unit — exactly what half-open slicing needs at either end.
222
+ */
223
+ function boundaryTextOffset(snapshot, boundary) {
224
+ const b = clampInt(boundary, 0, snapshot.charCount);
225
+ const map = snapshot.charMap;
226
+ if (!map || map.length === 0) return Math.min(b, snapshot.text.length);
227
+ const [char, text] = anchorAtOrBefore(map, b);
228
+ return text + (b - char);
229
+ }
230
+ /**
231
+ * The character boundary for a text offset, with explicit plateau bias:
232
+ *
233
+ * - `'start'`: the GREATEST boundary whose text offset is <= `offset` —
234
+ * scans forward past zero-width characters, so a range start never
235
+ * includes a dropped character that precedes its first real unit.
236
+ * - `'end'`: the SMALLEST boundary whose text offset is >= `offset` —
237
+ * stops before zero-width characters, so a range end never swallows a
238
+ * dropped character that follows its last real unit.
239
+ *
240
+ * An offset inside a surrogate pair resolves outward under both biases
241
+ * (start → the pair's character, end → past it), so a clipped astral
242
+ * character is always covered whole. Prefer {@link charRangeForTextOffsets}
243
+ * — the two biases exist to be used as a PAIR.
244
+ */
245
+ function charBoundaryAtTextOffset(snapshot, offset, bias) {
246
+ const target = clampInt(offset, 0, snapshot.text.length);
247
+ let lo = 0;
248
+ let hi = snapshot.charCount;
249
+ if (bias === "start") {
250
+ while (lo < hi) {
251
+ const mid = lo + Math.ceil((hi - lo) / 2);
252
+ if (boundaryTextOffset(snapshot, mid) <= target) lo = mid;
253
+ else hi = mid - 1;
254
+ }
255
+ return lo;
256
+ }
257
+ while (lo < hi) {
258
+ const mid = lo + hi >> 1;
259
+ if (boundaryTextOffset(snapshot, mid) >= target) hi = mid;
260
+ else lo = mid + 1;
261
+ }
262
+ return lo;
263
+ }
264
+ /**
265
+ * The character range whose text projection is exactly
266
+ * `text.slice(startOffset, endOffset)` — THE inverse used by search-hit
267
+ * conversion and select-by-text. Start is right-biased and end left-biased
268
+ * (see {@link charBoundaryAtTextOffset}), so zero-width characters adjacent
269
+ * to the range fall OUTSIDE it on both sides.
270
+ *
271
+ * A non-empty text range can never invert: `end > start` implies
272
+ * `B(end) >= endOffset > startOffset >= B(start)`, which forces
273
+ * `end > start` by monotonicity. Empty input (`endOffset <= startOffset`)
274
+ * normalizes to the end-rule boundary of `startOffset` on both sides.
275
+ */
276
+ function charRangeForTextOffsets(snapshot, startOffset, endOffset) {
277
+ if (endOffset <= startOffset) {
278
+ const b = charBoundaryAtTextOffset(snapshot, startOffset, "end");
279
+ return {
280
+ start: b,
281
+ end: b
282
+ };
283
+ }
284
+ return {
285
+ start: charBoundaryAtTextOffset(snapshot, startOffset, "start"),
286
+ end: charBoundaryAtTextOffset(snapshot, endOffset, "end")
287
+ };
288
+ }
289
+ /**
290
+ * THE copy primitive: the text projection of the half-open character range
291
+ * `[charStart, charEnd)`. Dropped characters inside the range contribute
292
+ * nothing; a supplementary character contributes its full surrogate pair.
293
+ * `sliceTextByChars(s, 0, s.charCount) === s.text` always.
294
+ */
295
+ function sliceTextByChars(snapshot, charStart, charEnd) {
296
+ if (charEnd <= charStart) return "";
297
+ return snapshot.text.slice(boundaryTextOffset(snapshot, charStart), boundaryTextOffset(snapshot, charEnd));
298
+ }
299
+ /**
300
+ * First invariant violation of a snapshot's char map, or null when valid.
301
+ * Shared by the wire schema (rejects malformed bodies) and engine builders
302
+ * (dev-mode assertion). The invariants:
303
+ *
304
+ * 1. absent/empty map ⇒ identity, so `charCount === text.length`;
305
+ * 2. anchor chars strictly increasing, each in [1, charCount];
306
+ * 3. step rule: against the previous anchor (implicit head [0, 0]), the
307
+ * character just before each anchor contributed exactly 0 units
308
+ * (dropped) or 2 (surrogate pair):
309
+ * `t₂ - (t₁ + (c₂ - c₁ - 1)) ∈ {0, 2}`;
310
+ * 4. tail: `lastText + (charCount - lastChar) === text.length`
311
+ * (equivalently `boundaryTextOffset(s, charCount) === text.length`).
312
+ */
313
+ function charMapViolation(charCount, textLength, charMap) {
314
+ if (!charMap || charMap.length === 0) return charCount === textLength ? null : `identity map requires charCount (${charCount}) === text length (${textLength})`;
315
+ let prevChar = 0;
316
+ let prevText = 0;
317
+ for (let i = 0; i < charMap.length; i++) {
318
+ const [char, text] = charMap[i];
319
+ if (!Number.isInteger(char) || !Number.isInteger(text)) return `anchor ${i} is not integer-valued`;
320
+ if (char <= prevChar) return `anchor ${i} char ${char} not strictly after ${prevChar}`;
321
+ if (char > charCount) return `anchor ${i} char ${char} outside [1, ${charCount}]`;
322
+ const step = text - (prevText + (char - prevChar - 1));
323
+ if (step !== 0 && step !== 2) return `anchor ${i} implies a character contributing ${step} text units (expected 0 or 2)`;
324
+ prevChar = char;
325
+ prevText = text;
326
+ }
327
+ const tail = prevText + (charCount - prevChar);
328
+ if (tail !== textLength) return `map projects charCount to ${tail}, but text length is ${textLength}`;
329
+ return null;
330
+ }
331
+ //#endregion
332
+ //#region src/mutation/PageInsertBlankInput.ts
333
+ /**
334
+ * Upper bound on `count` for a single `pages.insertBlank()` call. A CONTRACT
335
+ * cap, enforced identically by every engine (the cloud input schema carries
336
+ * the same number), so a UI never discovers a lower server limit by surprise.
337
+ * Larger batches are a loop at the call site.
338
+ */
339
+ const PAGE_INSERT_BLANK_MAX_COUNT = 100;
340
+ //#endregion
194
341
  Object.defineProperty(exports, "ANNOTATION_SUBTYPES", {
195
342
  enumerable: true,
196
343
  get: function() {
@@ -203,6 +350,12 @@ Object.defineProperty(exports, "EngineErrorCode", {
203
350
  return EngineErrorCode;
204
351
  }
205
352
  });
353
+ Object.defineProperty(exports, "PAGE_INSERT_BLANK_MAX_COUNT", {
354
+ enumerable: true,
355
+ get: function() {
356
+ return PAGE_INSERT_BLANK_MAX_COUNT;
357
+ }
358
+ });
206
359
  Object.defineProperty(exports, "PDF_CODE_TO_SUBTYPE", {
207
360
  enumerable: true,
208
361
  get: function() {
@@ -221,6 +374,36 @@ Object.defineProperty(exports, "PdfAnnotationSubtypeCode", {
221
374
  return PdfAnnotationSubtypeCode;
222
375
  }
223
376
  });
377
+ Object.defineProperty(exports, "boundaryTextOffset", {
378
+ enumerable: true,
379
+ get: function() {
380
+ return boundaryTextOffset;
381
+ }
382
+ });
383
+ Object.defineProperty(exports, "charBoundaryAtTextOffset", {
384
+ enumerable: true,
385
+ get: function() {
386
+ return charBoundaryAtTextOffset;
387
+ }
388
+ });
389
+ Object.defineProperty(exports, "charMapViolation", {
390
+ enumerable: true,
391
+ get: function() {
392
+ return charMapViolation;
393
+ }
394
+ });
395
+ Object.defineProperty(exports, "charRangeForTextOffsets", {
396
+ enumerable: true,
397
+ get: function() {
398
+ return charRangeForTextOffsets;
399
+ }
400
+ });
401
+ Object.defineProperty(exports, "sliceTextByChars", {
402
+ enumerable: true,
403
+ get: function() {
404
+ return sliceTextByChars;
405
+ }
406
+ });
224
407
  Object.defineProperty(exports, "subtypeFromCode", {
225
408
  enumerable: true,
226
409
  get: function() {
@@ -228,4 +411,4 @@ Object.defineProperty(exports, "subtypeFromCode", {
228
411
  }
229
412
  });
230
413
 
231
- //# sourceMappingURL=subtype-qejjVr6h.cjs.map
414
+ //# sourceMappingURL=PageInsertBlankInput-CzShuSJI.cjs.map