@embedpdf/engine-core 3.0.0-next.13 → 3.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/AnnotationList-CkijRHet.d.cts +27163 -0
  2. package/dist/AnnotationList-CkijRHet.d.ts +27163 -0
  3. package/dist/Change-CKoxfTNY.js +889 -0
  4. package/dist/Change-CKoxfTNY.js.map +1 -0
  5. package/dist/Change-CjImsrN0.cjs +1020 -0
  6. package/dist/Change-CjImsrN0.cjs.map +1 -0
  7. package/dist/DocumentRenderService-BfFdFSwI.cjs +120 -0
  8. package/dist/DocumentRenderService-BfFdFSwI.cjs.map +1 -0
  9. package/dist/DocumentRenderService-DV3J9lMz.js +85 -0
  10. package/dist/DocumentRenderService-DV3J9lMz.js.map +1 -0
  11. package/dist/{DocumentSecurityService-_JRjqvoI.d.ts → DocumentSecurityService-CU1M6Q7m.d.ts} +100 -112
  12. package/dist/{DocumentSecurityService-ClTZc0zO.d.cts → DocumentSecurityService-e6vp2de8.d.cts} +100 -112
  13. package/dist/LocalDocumentHandle-D02FMm-Z.cjs +53 -0
  14. package/dist/LocalDocumentHandle-D02FMm-Z.cjs.map +1 -0
  15. package/dist/LocalDocumentHandle-DAPdaOt_.js +30 -0
  16. package/dist/LocalDocumentHandle-DAPdaOt_.js.map +1 -0
  17. package/dist/LocalEngine-DFoBm4B3.d.cts +1565 -0
  18. package/dist/LocalEngine-DPriFujS.d.ts +1565 -0
  19. package/dist/PageInsertBlankInput-CXHAM7l6.cjs +17 -0
  20. package/dist/PageInsertBlankInput-CXHAM7l6.cjs.map +1 -0
  21. package/dist/PageInsertBlankInput-DhVYVJ_S.js +12 -0
  22. package/dist/PageInsertBlankInput-DhVYVJ_S.js.map +1 -0
  23. package/dist/authority-B3BklsB4.js +2239 -0
  24. package/dist/authority-B3BklsB4.js.map +1 -0
  25. package/dist/authority-DLMNR7ff.cjs +2676 -0
  26. package/dist/authority-DLMNR7ff.cjs.map +1 -0
  27. package/dist/builders-CNj0POeY.js +161 -0
  28. package/dist/builders-CNj0POeY.js.map +1 -0
  29. package/dist/builders-Cgdp_YCn.cjs +184 -0
  30. package/dist/builders-Cgdp_YCn.cjs.map +1 -0
  31. package/dist/calibrate-7T3fnP8-.js +2404 -0
  32. package/dist/calibrate-7T3fnP8-.js.map +1 -0
  33. package/dist/calibrate-DJBXnhLE.cjs +2919 -0
  34. package/dist/calibrate-DJBXnhLE.cjs.map +1 -0
  35. package/dist/charmap-Cprti1ta.js +239 -0
  36. package/dist/charmap-Cprti1ta.js.map +1 -0
  37. package/dist/charmap-aYlefQP9.cjs +304 -0
  38. package/dist/charmap-aYlefQP9.cjs.map +1 -0
  39. package/dist/conformance.cjs +16753 -5247
  40. package/dist/conformance.cjs.map +1 -1
  41. package/dist/conformance.d.cts +928 -165
  42. package/dist/conformance.d.ts +928 -165
  43. package/dist/conformance.js +16731 -5268
  44. package/dist/conformance.js.map +1 -1
  45. package/dist/format-Bp3QFSH1.cjs +574 -0
  46. package/dist/format-Bp3QFSH1.cjs.map +1 -0
  47. package/dist/format-Dgg428Kb.js +461 -0
  48. package/dist/format-Dgg428Kb.js.map +1 -0
  49. package/dist/index.cjs +330 -103
  50. package/dist/index.d.cts +2 -2
  51. package/dist/index.d.ts +2 -2
  52. package/dist/index.js +14 -5
  53. package/dist/pageRefs-B3ur7Ckm.cjs +51 -0
  54. package/dist/pageRefs-B3ur7Ckm.cjs.map +1 -0
  55. package/dist/pageRefs-DkbuxSCV.js +40 -0
  56. package/dist/pageRefs-DkbuxSCV.js.map +1 -0
  57. package/dist/public.cjs +57 -0
  58. package/dist/public.d.cts +5 -0
  59. package/dist/public.d.ts +5 -0
  60. package/dist/public.js +9 -0
  61. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs +3646 -0
  62. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs.map +1 -0
  63. package/dist/resolveAnnotationDraft-CUpf0SMh.js +3167 -0
  64. package/dist/resolveAnnotationDraft-CUpf0SMh.js.map +1 -0
  65. package/dist/{resolver-inAVzsWt.js → resolver-CzxmD9Ck.js} +294 -144
  66. package/dist/resolver-CzxmD9Ck.js.map +1 -0
  67. package/dist/{resolver-CYVNV4hn.cjs → resolver-D2OCtE8F.cjs} +347 -143
  68. package/dist/resolver-D2OCtE8F.cjs.map +1 -0
  69. package/dist/runtime-Cl0v56mm.d.ts +2032 -0
  70. package/dist/runtime-p1WDzDo4.d.cts +2032 -0
  71. package/dist/runtime.cjs +733 -284
  72. package/dist/runtime.cjs.map +1 -1
  73. package/dist/runtime.d.cts +5 -1348
  74. package/dist/runtime.d.ts +5 -1348
  75. package/dist/runtime.js +396 -179
  76. package/dist/runtime.js.map +1 -1
  77. package/dist/schema-C-gU4vj7.cjs +3034 -0
  78. package/dist/schema-C-gU4vj7.cjs.map +1 -0
  79. package/dist/schema-DzlUNk38.js +2081 -0
  80. package/dist/schema-DzlUNk38.js.map +1 -0
  81. package/dist/schemas-Berf1swF.cjs +2481 -0
  82. package/dist/schemas-Berf1swF.cjs.map +1 -0
  83. package/dist/schemas-D6xOGjqg.js +1654 -0
  84. package/dist/schemas-D6xOGjqg.js.map +1 -0
  85. package/dist/subtype-CG4WpIRj.js +129 -0
  86. package/dist/subtype-CG4WpIRj.js.map +1 -0
  87. package/dist/subtype-aDt5TFmK.cjs +158 -0
  88. package/dist/subtype-aDt5TFmK.cjs.map +1 -0
  89. package/dist/validation.cjs +578 -0
  90. package/dist/validation.cjs.map +1 -0
  91. package/dist/validation.d.cts +174 -0
  92. package/dist/validation.d.ts +174 -0
  93. package/dist/validation.js +571 -0
  94. package/dist/validation.js.map +1 -0
  95. package/dist/value-BFS1R8ek.cjs +435 -0
  96. package/dist/value-BFS1R8ek.cjs.map +1 -0
  97. package/dist/value-Dhc8eYcx.js +340 -0
  98. package/dist/value-Dhc8eYcx.js.map +1 -0
  99. package/dist/viewport-BJW13EGZ.js +540 -0
  100. package/dist/viewport-BJW13EGZ.js.map +1 -0
  101. package/dist/viewport-DlL5Bxbg.cjs +671 -0
  102. package/dist/viewport-DlL5Bxbg.cjs.map +1 -0
  103. package/dist/wire.cjs +1056 -379
  104. package/dist/wire.cjs.map +1 -1
  105. package/dist/wire.d.cts +15069 -725
  106. package/dist/wire.d.ts +15069 -725
  107. package/dist/wire.js +825 -239
  108. package/dist/wire.js.map +1 -1
  109. package/package.json +10 -1
  110. package/dist/AbortError-Cq2igpZ6.cjs +0 -38
  111. package/dist/AbortError-Cq2igpZ6.cjs.map +0 -1
  112. package/dist/AbortError-DHqPBnYc.js +0 -27
  113. package/dist/AbortError-DHqPBnYc.js.map +0 -1
  114. package/dist/AnnotationListSnapshot-D3mFut1e.d.cts +0 -6871
  115. package/dist/AnnotationListSnapshot-D3mFut1e.d.ts +0 -6871
  116. package/dist/Engine-Bx0NOfmd.d.cts +0 -1264
  117. package/dist/Engine-DxtpCYcP.d.ts +0 -1264
  118. package/dist/PageInsertBlankInput-CqXBmFhN.cjs +0 -449
  119. package/dist/PageInsertBlankInput-CqXBmFhN.cjs.map +0 -1
  120. package/dist/PageInsertBlankInput-cHq9-i-z.js +0 -378
  121. package/dist/PageInsertBlankInput-cHq9-i-z.js.map +0 -1
  122. package/dist/builders-Bqm8yTpi.cjs +0 -3564
  123. package/dist/builders-Bqm8yTpi.cjs.map +0 -1
  124. package/dist/builders-Dqo2X-dt.js +0 -3121
  125. package/dist/builders-Dqo2X-dt.js.map +0 -1
  126. package/dist/fold-2V29cxCV.cjs +0 -447
  127. package/dist/fold-2V29cxCV.cjs.map +0 -1
  128. package/dist/fold-CdEJTBTn.js +0 -334
  129. package/dist/fold-CdEJTBTn.js.map +0 -1
  130. package/dist/resolver-CYVNV4hn.cjs.map +0 -1
  131. package/dist/resolver-inAVzsWt.js.map +0 -1
  132. package/dist/schemas-BLARNCgx.js +0 -3113
  133. package/dist/schemas-BLARNCgx.js.map +0 -1
  134. package/dist/schemas-DIqFMmrC.cjs +0 -4468
  135. package/dist/schemas-DIqFMmrC.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.cjs","names":["declarationOf","FileAnnotationDraftSchema","KIND_BY_SUBTYPE","EngineError","EngineErrorCode","fileAnnotationPatchSchemaOf","pdfPrepareAnnotationDraft","pdfDeriveAnnotationDraft","pdfPrepareAnnotationPatch","pdfDeriveAnnotationPatch","bundlePageMapping","draftOf","annotationKey","encodePageKey","pageRefsIn","declarationOf","AnnotationDraftSchema","EngineError","EngineErrorCode","mapPageRefs","bundlePageMapping","pageRefsIn","annotationKey","fieldValueOf","encodeFieldRefKey","fieldMatches","fieldScriptOf","WIDGET_ACTION_EVENTS","actionWriteOf","needsScriptRight","mapPageRefs","WIDGET_FLAG_NAMES","EngineError","EngineErrorCode","FormFieldDraftSchema"],"sources":["../src/annotation/checkWrite.ts","../src/transfer/planAnnotationImport.ts","../src/transfer/planFormImport.ts"],"sourcesContent":["/**\n * The checks every annotation write runs before its first write, on both\n * engines: the prepared values against their kind's schema, not only the\n * names. A value the schema refuses is `InvalidArg` naming the field. A check\n * only accepts or refuses: it never adds, drops or changes a field, so the\n * engine writes what a viewer predicts (prepare, check, derive; the viewer\n * runs the same two steps without schema validation, `resolve/`). Built with\n * zod, so it runs where the engine does (its worker, the server), never on\n * the page: `@embedpdf/engine-core/validation` exports it.\n */\nimport type { z } from 'zod';\n\nimport {\n declarationOf,\n FileAnnotationDraftSchema,\n fileAnnotationPatchSchemaOf,\n KIND_BY_SUBTYPE,\n type AnnotationDraft,\n type Annotation,\n type AnnotationPatch,\n} from './kinds';\nimport {\n pdfDeriveAnnotationDraft,\n pdfPrepareAnnotationDraft,\n type DraftResolveOptions,\n} from './resolve/resolveAnnotationDraft';\nimport {\n pdfDeriveAnnotationPatch,\n pdfPrepareAnnotationPatch,\n type ResolveOptions,\n} from './resolve/resolveAnnotationPatch';\nimport { EngineError } from '../errors/EngineError';\nimport { EngineErrorCode } from '../errors/EngineErrorCode';\nimport type { PdfCoordinates } from '../pageSpace/coordinates';\n\n/**\n * A prepared create's data checked against its kind's schema. The caller\n * writes its own data, not the schema's output, so nothing is reshaped on its\n * way in.\n */\nexport function assertAnnotationDraft(\n draft: AnnotationDraft<PdfCoordinates>,\n options: {\n /**\n * Link fields the caller has taken out of the draft and links itself (a\n * change set's `reply` and popup `parent`); they aren't checked here.\n */\n linked?: readonly string[];\n } = {},\n): void {\n const declaration = declarationOf(String(draft.subtype));\n const linked = options.linked ?? [];\n const schema =\n declaration && linked.length > 0\n ? (declaration.fileSchemas.create as unknown as z.AnyZodObject).omit(\n Object.fromEntries(linked.map((name) => [name, true])),\n )\n : FileAnnotationDraftSchema;\n const checked = schema.safeParse(draft);\n if (!checked.success) throw invalidWrite(checked.error, `${String(draft.subtype)} create`);\n}\n\n/**\n * A prepared update's data (`pdfPrepareAnnotationPatch`) checked against the\n * kind of `current`. A `readBack()` value still in it is a change, as\n * preparation drops one sent back as it reads, so one a write can't make is\n * refused; the rest is checked against the kind's update schema.\n */\nexport function assertAnnotationPatch(\n current: Annotation<PdfCoordinates>,\n prepared: AnnotationPatch<PdfCoordinates>,\n): void {\n if (current.subtype === 'unsupported') return;\n const values = prepared as Record<string, unknown>;\n for (const [name, write] of Object.entries(KIND_BY_SUBTYPE[current.subtype].readBackWrites)) {\n const value = values[name];\n if (value === undefined || write?.safeParse(value).success) continue;\n throw new EngineError(\n EngineErrorCode.InvalidArg,\n write\n ? `${current.subtype} update field '${name}': this value can be read but not written; send it back unchanged or replace it`\n : `${current.subtype} update field '${name}': the engine works this out; send it back unchanged or leave it out`,\n { details: { field: name } },\n );\n }\n const parsed = fileAnnotationPatchSchemaOf(current.subtype).safeParse(prepared);\n if (!parsed.success) throw invalidWrite(parsed.error, `${current.subtype} update`);\n}\n\n/**\n * The draft the engine writes for `draft`, in the file's coordinates:\n * prepared (`pdfPrepareAnnotationDraft`), checked against its kind, and\n * every field that follows from it stated (`pdfDeriveAnnotationDraft`). A\n * viewer predicts the same without schema validation\n * (`pdfPredictAnnotationDraft`).\n *\n * Throws `InvalidArg` for a draft the engine refuses. Pure: it reads nothing\n * but its arguments.\n */\nexport function pdfResolveAnnotationDraft(\n draft: AnnotationDraft<PdfCoordinates>,\n options: DraftResolveOptions = {},\n): AnnotationDraft<PdfCoordinates> {\n const prepared = pdfPrepareAnnotationDraft(draft);\n assertAnnotationDraft(prepared, { linked: options.linked ?? [] });\n return pdfDeriveAnnotationDraft(prepared, options);\n}\n\n/**\n * The patch the engine writes for `patch` on `current`, in the file's\n * coordinates: prepared (`pdfPrepareAnnotationPatch`), checked against its\n * kind (`assertAnnotationPatch`), and every field that follows from it\n * stated (`pdfDeriveAnnotationPatch`). A viewer predicts the same without\n * schema validation (`pdfPredictAnnotationPatch`).\n *\n * Throws `InvalidArg` for a patch the engine refuses. Pure: it reads nothing\n * but its arguments.\n */\nexport function pdfResolveAnnotationPatch(\n current: Annotation<PdfCoordinates>,\n patch: AnnotationPatch<PdfCoordinates>,\n options: ResolveOptions = {},\n): AnnotationPatch<PdfCoordinates> {\n const prepared = pdfPrepareAnnotationPatch(current, patch);\n assertAnnotationPatch(current, prepared);\n return pdfDeriveAnnotationPatch(current, prepared, options);\n}\n\nfunction invalidWrite(error: z.ZodError, where: string): EngineError {\n const issue = error.issues[0]!;\n const field = issue.path.join('.');\n return new EngineError(\n EngineErrorCode.InvalidArg,\n `${where}${field ? ` field '${field}'` : ''}: ${issue.message}`,\n { details: field ? { field } : {} },\n );\n}\n","/**\n * What an annotation import creates and leaves out, decided before its first write: each item\n * checked against its kind's create schema. Built with zod, so it runs where the engine does,\n * from `@embedpdf/engine-core/validation`; the facts an import commits are in\n * `annotationImport.ts`.\n */\nimport type { AnnotationBundle } from './AnnotationBundle';\nimport type { AnnotationDropReason, AnnotationImportDrop } from './annotationImport';\nimport { bundlePageMapping, type BundleImportPages, type BundleImportTarget } from './bundle';\nimport { mapPageRefs, pageRefsIn } from './pageRefs';\nimport {\n AnnotationDraftSchema,\n declarationOf,\n type AnnotationDraft,\n type Annotation,\n} from '../annotation/kinds';\nimport type { KindFields } from '../annotation/declaration';\nimport type { AnnotationReplyType } from '../annotation/primitives';\nimport type { PdfActionTree } from '../dto/PdfAction';\nimport { EngineError } from '../errors/EngineError';\nimport { EngineErrorCode } from '../errors/EngineErrorCode';\nimport { annotationKey } from '../identity/annotationKey';\nimport type { AnnotationRef } from '../identity/AnnotationRef';\nimport { encodePageKey, type PageRef } from '../identity/PageRef';\n\n/** One annotation an import creates. */\nexport interface PlannedAnnotation {\n /** Its item in the bundle. */\n readonly item: number;\n /** The page it goes on. */\n readonly page: PageRef;\n /** What `create` writes: the item's data, its pages mapped, without its links and dropped fields. */\n readonly draft: AnnotationDraft;\n /** The annotation it replies to, by its place in `creates`. */\n readonly replyTo?: { readonly planned: number; readonly type: AnnotationReplyType };\n /** For a popup: the annotation it shows, by its place in `creates`. */\n readonly parent?: number;\n}\n\nexport interface AnnotationImportPlan {\n /** In bundle order. */\n readonly creates: readonly PlannedAnnotation[];\n readonly dropped: readonly AnnotationImportDrop[];\n}\n\n/**\n * What an import of `bundle` into the `target` pages creates, and what it\n * leaves out. Nothing here touches a document, so an import refuses before\n * its first write:\n *\n * - `InvalidArg` when an item's data isn't valid for its kind, or when a\n * page an item is on or points at maps to no target page (naming them);\n * - `NotFound` when a page list maps to a page the target doesn't have.\n *\n * Unsupported items and unresolved relationships are left out in this order:\n *\n * 1. an item of an unsupported kind, and a form field's widget; a field\n * marker leaves out only that field;\n * 2. an item whose `reply.to` or `parent` is no item of the bundle on the\n * same target page (`parent-missing`);\n * 3. an item whose name is used on its target page, or by an earlier item\n * going to the same page (`name-conflict`);\n * 4. then, until nothing changes, an item whose `reply.to` or `parent` was\n * left out (`parent-dropped`), so a whole branch goes together.\n *\n * `nameTaken(page, nm)` answers for the target page as it is before the import.\n */\nexport function planAnnotationImport(input: {\n readonly bundle: Pick<AnnotationBundle, 'pages' | 'items'>;\n readonly pages?: BundleImportPages;\n readonly target: readonly BundleImportTarget[];\n readonly nameTaken: (page: PageRef, nm: string) => boolean;\n}): AnnotationImportPlan {\n const { bundle, target, nameTaken } = input;\n const items = bundle.items.map((item) => item.data);\n const mapPage = bundlePageMapping({\n bundlePages: bundle.pages,\n pages: input.pages ?? 'same',\n target,\n named: items.flatMap(pagesNamedBy),\n });\n\n const drops = new Map<number, AnnotationDropReason>();\n const fieldDrops = new Map<number, Array<{ field: string; reason: AnnotationDropReason }>>();\n const drafts = new Map<number, AnnotationDraft>();\n items.forEach((data, index) => {\n if (data.subtype === 'unsupported') {\n drops.set(index, 'unsupported-kind');\n return;\n }\n if (data.subtype === 'widget') {\n drops.set(index, 'widget');\n return;\n }\n // A popup shows another annotation; one that names none can't be made.\n if (data.subtype === 'popup' && data.parent === null) {\n drops.set(index, 'parent-missing');\n return;\n }\n const unwritable = unwritableValuesOf(data);\n if (unwritable === 'item') {\n drops.set(index, 'unsupported-value');\n return;\n }\n const markers = [...fieldMarkersOf(data), ...unwritable];\n if (markers.length > 0) fieldDrops.set(index, markers);\n drafts.set(index, draftOf(data, markers, mapPage, index));\n });\n\n const byKey = new Map<string, number>();\n items.forEach((data, index) => {\n const key = annotationKey(data.ref);\n if (!byKey.has(key)) byKey.set(key, index);\n });\n // A reply and a popup are on their parent's page (ISO 32000-2 §12.5.6.2),\n // so a link finds its target only there.\n const pageOf = (index: number) => encodePageKey(mapPage(items[index]!.ref.page));\n const resolve = (ref: AnnotationRef, from: number) => {\n const found = byKey.get(annotationKey(ref));\n return found !== undefined && pageOf(found) === pageOf(from) ? found : undefined;\n };\n const linksOf = (data: Annotation) =>\n [data.reply?.to, data.subtype === 'popup' ? data.parent : null].filter(\n (ref): ref is AnnotationRef => ref != null,\n );\n\n items.forEach((data, index) => {\n if (drops.has(index)) return;\n if (linksOf(data).some((ref) => resolve(ref, index) === undefined)) {\n drops.set(index, 'parent-missing');\n }\n });\n\n const popupOf = new Map<number, number>();\n items.forEach((data, index) => {\n if (drops.has(index) || data.subtype !== 'popup' || !data.parent) return;\n const parent = resolve(data.parent, index)!;\n if (popupOf.has(parent)) drops.set(index, 'popup-taken');\n else popupOf.set(parent, index);\n });\n\n const claimed = new Set<string>();\n items.forEach((data, index) => {\n if (drops.has(index) || !data.nm) return;\n const page = mapPage(data.ref.page);\n const claim = `${encodePageKey(page)}\\u0000${data.nm}`;\n if (claimed.has(claim) || nameTaken(page, data.nm)) drops.set(index, 'name-conflict');\n else claimed.add(claim);\n });\n\n for (let changed = true; changed; ) {\n changed = false;\n items.forEach((data, index) => {\n if (drops.has(index)) return;\n if (linksOf(data).some((ref) => drops.has(resolve(ref, index)!))) {\n drops.set(index, 'parent-dropped');\n changed = true;\n }\n });\n }\n\n const planned = new Map<number, number>();\n items.forEach((_data, index) => {\n if (!drops.has(index)) planned.set(index, planned.size);\n });\n const creates: PlannedAnnotation[] = [...planned.keys()].map((index) => {\n const data = items[index]!;\n const replyTo = data.reply ? planned.get(resolve(data.reply.to, index)!) : undefined;\n const parent =\n data.subtype === 'popup' && data.parent\n ? planned.get(resolve(data.parent, index)!)\n : undefined;\n return {\n item: index,\n page: mapPage(data.ref.page),\n draft: drafts.get(index)!,\n ...(replyTo !== undefined ? { replyTo: { planned: replyTo, type: data.reply!.type } } : {}),\n ...(parent !== undefined ? { parent } : {}),\n };\n });\n\n const dropped: AnnotationImportDrop[] = [];\n items.forEach((data, index) => {\n const reason = drops.get(index);\n if (reason) dropped.push({ ref: data.ref, reason });\n else for (const drop of fieldDrops.get(index) ?? []) dropped.push({ ref: data.ref, ...drop });\n });\n return { creates, dropped };\n}\n\n/**\n * The pages an item is on or points at, apart from its links to other\n * annotations (`reply.to`, `parent`, `popup`), which resolve in the bundle.\n */\nfunction pagesNamedBy(data: Annotation): PageRef[] {\n const { ref, reply: _reply, popup: _popup, ...rest } = data;\n const fields = { ...rest } as Record<string, unknown>;\n if (data.subtype === 'popup') delete fields.parent;\n return [ref.page, ...pageRefsIn(fields)];\n}\n\n/** The fields of `data` that are markers for something the engine can't write. */\nfunction fieldMarkersOf(data: Annotation): Array<{ field: string; reason: AnnotationDropReason }> {\n const markers: Array<{ field: string; reason: AnnotationDropReason }> = [];\n const measure = (data as { measure?: { subtype?: unknown } | null }).measure;\n if (measure?.subtype === 'geospatial') markers.push({ field: 'measure', reason: 'geospatial' });\n if (measure?.subtype === 'unknown') markers.push({ field: 'measure', reason: 'unknown-measure' });\n const target = data.subtype === 'link' ? data.target : null;\n const carriedTarget = !!target && isWritableLinkTarget(target);\n if (target && !carriedTarget) markers.push({ field: 'target', reason: 'unsupported-action' });\n // `actions` reads `/A` and `/AA`, and no write takes it. A copy has only\n // the `/A` a link's target writes: one go-to or URI action, without a\n // chain or an `/IsMap`. A target a write can't make is reported above.\n const { actions } = data;\n const lost = Object.entries(actions ?? {}).some(([trigger, tree]) =>\n data.subtype !== 'link' || trigger !== 'activate' ? true : carriedTarget && !writtenAsIs(tree),\n );\n if (lost) markers.push({ field: 'actions', reason: 'unsupported-action' });\n return markers;\n}\n\n/**\n * The values `data` reads that a write can't make (a `readBack()` field's\n * read-only values), each left out; `'item'` when one is a field every\n * create needs. A link's target is reported by {@link fieldMarkersOf}.\n */\nfunction unwritableValuesOf(\n data: Annotation,\n): Array<{ field: string; reason: AnnotationDropReason }> | 'item' {\n const unwritable: Array<{ field: string; reason: AnnotationDropReason }> = [];\n const declaration = declarationOf(data.subtype);\n for (const [name, spec] of Object.entries(declaration?.fields ?? {})) {\n const { owner, readBack, required } = spec.traits;\n if (owner !== 'data' || !readBack || name === 'target') continue;\n const value = (data as unknown as Record<string, unknown>)[name];\n if (value == null || spec.write.safeParse(value).success) continue;\n if (required) return 'item';\n unwritable.push({ field: name, reason: 'unsupported-value' });\n }\n return unwritable;\n}\n\n/** Whether a link's `/A` is what writing its target writes again. */\nfunction writtenAsIs<Destination>(tree: PdfActionTree<Destination> | undefined): boolean {\n const root = tree?.root;\n if (!tree || tree.incomplete || !root || root.next.length > 0) return false;\n return !(root.type === 'uri' && root.isMap);\n}\n\n/** Whether a write can make a link's target; the others read as markers. */\nfunction isWritableLinkTarget(target: { kind: string; name?: string }): boolean {\n return target.kind === 'named'\n ? STANDARD_NAMED_ACTIONS.has(target.name ?? '')\n : target.kind === 'goto' || target.kind === 'uri';\n}\n\nconst STANDARD_NAMED_ACTIONS: ReadonlySet<string> = new Set([\n 'NextPage',\n 'PrevPage',\n 'FirstPage',\n 'LastPage',\n]);\n\n/** The create an item becomes, checked against its kind's create schema. */\nfunction draftOf(\n data: Annotation,\n markers: ReadonlyArray<{ field: string }>,\n mapPage: (page: PageRef) => PageRef,\n index: number,\n): AnnotationDraft {\n const fields = { ...data } as Record<string, unknown>;\n delete fields.reply;\n // Left out, the field is not written: `null` where a write takes it,\n // else the kind's default.\n const declared: KindFields = declarationOf(data.subtype)?.fields ?? {};\n for (const { field } of markers) {\n if (declared[field]?.traits.writeNullable) fields[field] = null;\n else delete fields[field];\n }\n // Checked with the popup's `parent`, which the import then links itself.\n const checked = AnnotationDraftSchema.safeParse(fields);\n if (data.subtype === 'popup') delete fields.parent;\n if (!checked.success) {\n const issue = checked.error.issues[0]!;\n const path = issue.path.join('.');\n throw new EngineError(\n EngineErrorCode.InvalidArg,\n `import: item ${index}${path ? ` field '${path}'` : ''}: ${issue.message}`,\n { details: { item: index, ...(path ? { field: path } : {}) } },\n );\n }\n // The item's own data, not the schema's output, so nothing a read carries\n // is reshaped on its way back in.\n return mapPageRefs(fields, mapPage) as AnnotationDraft;\n}\n","/**\n * What a form import writes and leaves out, decided before its first write: a design import's\n * fields checked against the create schema, a values import's values matched to the form's\n * fields. Built with zod, so it runs where the engine does, from\n * `@embedpdf/engine-core/validation`; the facts an import commits are in `formImport.ts`.\n */\nimport { bundlePageMapping, type BundleImportPages, type BundleImportTarget } from './bundle';\nimport type { FormBundle } from './FormBundle';\nimport { fieldMatches } from './formExport';\nimport {\n WIDGET_FLAG_NAMES,\n type FormImportDrop,\n type FormImportDropReason,\n type FormValuesImportDrop,\n type FormValuesImportDropReason,\n type WidgetFlags,\n} from './formImport';\nimport { mapPageRefs, pageRefsIn } from './pageRefs';\nimport type { WidgetAnnotation } from '../annotation/kinds/widget';\nimport {\n actionWriteOf,\n fieldScriptOf,\n needsScriptRight,\n WIDGET_ACTION_EVENTS,\n type FieldActionsPatch,\n type FieldScriptEvent,\n type WidgetActionsPatch,\n} from '../dto/PdfAction';\nimport { EngineError } from '../errors/EngineError';\nimport { EngineErrorCode } from '../errors/EngineErrorCode';\nimport type { FormFieldDraft, WidgetPlacement } from '../forms/draft';\nimport type { FormFieldDTO, FormFieldFamily } from '../forms/field';\nimport { FormFieldDraftSchema } from '../forms/schema';\nimport { fieldValueOf, type FormFieldValue } from '../forms/value';\nimport { annotationKey } from '../identity/annotationKey';\nimport { encodeFieldRefKey, type FormFieldRef } from '../identity/FormFieldRef';\nimport type { PageRef } from '../identity/PageRef';\n\n/** One field a design import creates. */\nexport interface PlannedFormField {\n /** Its row in the bundle. */\n readonly field: number;\n /** What `create` writes: the field's settings, scripts and widgets, their pages mapped. */\n readonly draft: FormFieldDraft;\n /** Each widget's row in the bundle, in `draft.widgets` order. */\n readonly widgets: readonly number[];\n /** Each widget's flags, in `draft.widgets` order. */\n readonly flags: readonly WidgetFlags[];\n /** The value it gets; absent when the import writes none. */\n readonly value?: FormFieldValue;\n}\n\nexport interface FormImportPlan {\n /** In bundle order. */\n readonly creates: readonly PlannedFormField[];\n /** The calculation order among the creates, by their place in `creates`, as the bundle has it. */\n readonly calculationOrder: readonly number[];\n readonly dropped: readonly FormImportDrop[];\n}\n\n/**\n * What a design import of `bundle` into the `target` pages creates, and what\n * it leaves out. Nothing here touches a document, so an import refuses\n * before its first write:\n *\n * - `InvalidArg` when a field's data isn't valid for its family, or when a\n * page a widget is on or points at maps to no target page;\n * - `NotFound` when a page list maps to a page the target doesn't have.\n *\n * Left out, in bundle order: a field of an unknown family, a field whose\n * name is taken (`nameTaken`, for the document as it is before the\n * import), a widget whose field isn't in the bundle, and each action that\n * is a script, a submit or a link when `mayScript` is false\n * (`doc.forms.script`), or that a write can't make. Each field keeps every\n * widget it has. With `values`, each field gets the value the bundle holds.\n */\nexport function planFormImport(input: {\n readonly bundle: Pick<FormBundle, 'pages' | 'fields' | 'widgets' | 'calculationOrder'>;\n readonly pages?: BundleImportPages;\n readonly target: readonly BundleImportTarget[];\n readonly nameTaken: (name: string) => boolean;\n readonly mayScript: boolean;\n readonly values: boolean;\n}): FormImportPlan {\n const { bundle, mayScript } = input;\n const mapPage = bundlePageMapping({\n bundlePages: bundle.pages,\n pages: input.pages ?? 'same',\n target: input.target,\n named: bundle.widgets.flatMap((row) => pageRefsIn(row.data)),\n });\n\n const rowByKey = new Map(\n bundle.widgets.map((row, index) => [annotationKey(row.data.ref), index]),\n );\n const owned = new Set<number>();\n const dropped: FormImportDrop[] = [];\n const claimed = new Set<string>();\n const creates: PlannedFormField[] = [];\n\n bundle.fields.forEach(({ data: field }, index) => {\n const rows = field.widgets.flatMap((widget) => {\n const row = widget.ref ? rowByKey.get(annotationKey(widget.ref)) : undefined;\n return row === undefined ? [] : [row];\n });\n for (const row of rows) owned.add(row);\n if (field.family === 'unknown') {\n dropped.push({ ref: field.ref, reason: 'unsupported-family' });\n return;\n }\n if (claimed.has(field.name) || input.nameTaken(field.name)) {\n dropped.push({ ref: field.ref, reason: 'name-conflict' });\n return;\n }\n claimed.add(field.name);\n const actions = fieldActionsOf(field, mayScript, dropped);\n const placements = rows.map((row) =>\n placementOf(field, bundle.widgets[row]!.data, mapPage, mayScript, dropped),\n );\n const draft = draftOf(field, actions, placements, index);\n const value = input.values && holdsValue(field) ? fieldValueOf(field) : null;\n creates.push({\n field: index,\n draft,\n widgets: rows,\n flags: rows.map((row) => flagsOf(bundle.widgets[row]!.data)),\n ...(value ? { value } : {}),\n });\n });\n\n bundle.widgets.forEach((row, index) => {\n if (!owned.has(index)) {\n dropped.push({ ref: row.data.field, widget: row.data.ref, reason: 'no-field' });\n }\n });\n\n // The order the bundle gives the fields that kept their calculate script.\n const calculationOrder = bundle.calculationOrder.flatMap((ref) => {\n const at = creates.findIndex(\n (create) =>\n encodeFieldRefKey(bundle.fields[create.field]!.data.ref) === encodeFieldRefKey(ref) &&\n create.draft.actions?.calculate,\n );\n return at < 0 ? [] : [at];\n });\n return { creates, calculationOrder, dropped };\n}\n\n/** A field of the document a values import fills. */\nexport interface FormValuesImportTarget {\n readonly ref: FormFieldRef;\n readonly name: string;\n readonly family: FormFieldFamily;\n}\n\n/** One value a values import writes. */\nexport interface PlannedValueWrite<T extends FormValuesImportTarget = FormValuesImportTarget> {\n /** Its field's row in the bundle. */\n readonly field: number;\n /** The document's field of that name. */\n readonly target: T;\n readonly value: FormFieldValue;\n}\n\n/**\n * What a values import of `bundle` writes into a form whose fields are\n * `target`: each field the bundle holds a value for gets it, matched by full\n * name. Left out, in bundle order: a field the document doesn't have\n * (`no-field`), one of another family (`wrong-family`), and one `refusal`\n * names a reason for: a value the field can't take, a field a signature\n * locked, a field the session may not fill in. So everything is decided\n * before the first write.\n */\nexport function planFormValuesImport<T extends FormValuesImportTarget>(input: {\n readonly bundle: Pick<FormBundle, 'fields'>;\n readonly target: readonly T[];\n readonly refusal?: (\n target: T,\n value: FormFieldValue,\n ) => Extract<\n FormValuesImportDropReason,\n 'value-not-allowed' | 'locked' | 'fill-not-allowed'\n > | null;\n}): {\n readonly writes: readonly PlannedValueWrite<T>[];\n readonly dropped: readonly FormValuesImportDrop[];\n} {\n const writes: PlannedValueWrite<T>[] = [];\n const dropped: FormValuesImportDrop[] = [];\n input.bundle.fields.forEach(({ data: field }, index) => {\n const value = holdsValue(field) ? fieldValueOf(field) : null;\n if (!value) return;\n const target = input.target.find((candidate) =>\n fieldMatches(candidate, { kind: 'fqn', name: field.name }),\n );\n if (!target) {\n dropped.push({ ref: field.ref, reason: 'no-field' });\n } else if (target.family !== field.family) {\n dropped.push({ ref: field.ref, reason: 'wrong-family' });\n } else {\n const refused = input.refusal?.(target, value);\n if (refused) dropped.push({ ref: field.ref, reason: refused });\n else writes.push({ field: index, target, value });\n }\n });\n return { writes, dropped };\n}\n\n/** Whether a field read holds a value a write can set. */\nfunction holdsValue(field: FormFieldDTO): boolean {\n return field.valueEntry.kind === 'scalar' || field.valueEntry.kind === 'array';\n}\n\n/** A field's scripts as a create writes them; each left out is reported. */\nfunction fieldActionsOf(\n field: FormFieldDTO,\n mayScript: boolean,\n dropped: FormImportDrop[],\n): FieldActionsPatch {\n const actions: FieldActionsPatch = {};\n for (const [event, tree] of Object.entries(field.actions ?? {}) as [\n FieldScriptEvent,\n NonNullable<FormFieldDTO['actions']>[FieldScriptEvent],\n ][]) {\n if (!tree) continue;\n const script = fieldScriptOf(tree);\n const member = `actions.${event}`;\n if (!script) dropped.push({ ref: field.ref, field: member, reason: 'unsupported-action' });\n else if (!mayScript)\n dropped.push({ ref: field.ref, field: member, reason: 'script-not-allowed' });\n else actions[event] = script;\n }\n return actions;\n}\n\n/** A widget row as a create places it: on its mapped page, with its look and actions. */\nfunction placementOf(\n field: FormFieldDTO,\n row: WidgetAnnotation,\n mapPage: (page: PageRef) => PageRef,\n mayScript: boolean,\n dropped: FormImportDrop[],\n): WidgetPlacement {\n const actions: WidgetActionsPatch = {};\n for (const event of WIDGET_ACTION_EVENTS) {\n const tree = row.actions?.[event];\n if (!tree) continue;\n const write = actionWriteOf(tree);\n const drop = (reason: FormImportDropReason) =>\n dropped.push({ ref: field.ref, widget: row.ref, field: `actions.${event}`, reason });\n if (!write) drop('unsupported-action');\n else if (!mayScript && needsScriptRight(write)) drop('script-not-allowed');\n else actions[event] = mapPageRefs(write, mapPage);\n }\n const toggle =\n field.family === 'checkbox' || field.family === 'radio'\n ? field.widgets.find(\n (widget) => widget.ref && annotationKey(widget.ref) === annotationKey(row.ref),\n )\n : undefined;\n const look = {\n color: row.color,\n interiorColor: row.interiorColor,\n fontFamily: row.fontFamily,\n fontSize: row.fontSize,\n fontColor: row.fontColor,\n caption: field.family === 'pushbutton' ? row.caption : null,\n };\n return {\n page: mapPage(row.page),\n rect: row.rect,\n ...(row.rotation ? { rotation: row.rotation } : {}),\n strokeWidth: row.strokeWidth,\n borderStyle: row.borderStyle,\n textAlign: row.textAlign,\n // A new widget has none of these: only what the row has is written.\n ...Object.fromEntries(Object.entries(look).filter(([, value]) => value != null)),\n ...(toggle && 'exportValue' in toggle ? { exportValue: toggle.exportValue } : {}),\n ...(Object.keys(actions).length > 0 ? { actions } : {}),\n };\n}\n\nfunction flagsOf(row: WidgetAnnotation): WidgetFlags {\n return Object.fromEntries(WIDGET_FLAG_NAMES.map((name) => [name, row[name]])) as WidgetFlags;\n}\n\n/** The create a field row becomes, checked against the create schema. */\nfunction draftOf(\n field: FormFieldDTO,\n actions: FieldActionsPatch,\n widgets: WidgetPlacement[],\n index: number,\n): FormFieldDraft {\n const base = {\n name: field.name,\n readOnly: field.readOnly,\n required: field.required,\n noExport: field.noExport,\n ...(field.alternateName !== null ? { alternateName: field.alternateName } : {}),\n ...(field.mappingName !== null ? { mappingName: field.mappingName } : {}),\n // The group the field was in; the import decides whether it keeps it.\n ...(field.groupId !== null ? { groupId: field.groupId } : {}),\n ...(Object.keys(actions).length > 0 ? { actions } : {}),\n widgets,\n };\n const hasDefault = field.defaultValueEntry.kind !== 'none';\n const options = (list: readonly { label: string; value: string }[]) =>\n list.map(({ label, value }) => ({ label, value }));\n let draft: FormFieldDraft;\n switch (field.family) {\n case 'text':\n draft = {\n ...base,\n family: 'text',\n ...(hasDefault ? { defaultValue: field.defaultValue } : {}),\n ...(field.maxLength !== null ? { maxLength: field.maxLength } : {}),\n multiline: field.multiline,\n password: field.password,\n comb: field.comb,\n };\n break;\n case 'radio':\n draft = {\n ...base,\n family: 'radio',\n radiosInUnison: field.radiosInUnison,\n noToggleToOff: field.noToggleToOff,\n };\n break;\n case 'combobox':\n draft = {\n ...base,\n family: 'combobox',\n edit: field.edit,\n options: options(field.options),\n ...(hasDefault ? { defaultValue: field.defaultValue } : {}),\n };\n break;\n case 'listbox':\n draft = {\n ...base,\n family: 'listbox',\n multiSelect: field.multiSelect,\n options: options(field.options),\n ...(hasDefault ? { defaultValue: field.defaultValue } : {}),\n };\n break;\n case 'checkbox':\n case 'pushbutton':\n case 'signature':\n draft = { ...base, family: field.family };\n break;\n default:\n throw new EngineError(EngineErrorCode.InvalidArg, `import: field ${index} has no family`);\n }\n const checked = FormFieldDraftSchema.safeParse(draft);\n if (!checked.success) {\n const issue = checked.error.issues[0]!;\n const path = issue.path.join('.');\n throw new EngineError(\n EngineErrorCode.InvalidArg,\n `import: field ${index}${path ? ` member '${path}'` : ''}: ${issue.message}`,\n { details: { item: index, ...(path ? { field: path } : {}) } },\n );\n }\n return draft;\n}\n"],"mappings":";;;;;;;;;;;;AAwCA,SAAgB,sBACd,OACA,UAMI,CAAC,GACC;CACN,MAAM,cAAcA,eAAAA,cAAc,OAAO,MAAM,OAAO,CAAC;CACvD,MAAM,SAAS,QAAQ,UAAU,CAAC;CAOlC,MAAM,WALJ,eAAe,OAAO,SAAS,IAC1B,YAAY,YAAY,OAAqC,KAC5D,OAAO,YAAY,OAAO,KAAK,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,CACvD,IACAC,eAAAA,0BAAAA,CACiB,UAAU,KAAK;CACtC,IAAI,CAAC,QAAQ,SAAS,MAAM,aAAa,QAAQ,OAAO,GAAG,OAAO,MAAM,OAAO,EAAE,QAAQ;AAC3F;;;;;;;AAQA,SAAgB,sBACd,SACA,UACM;CACN,IAAI,QAAQ,YAAY,eAAe;CACvC,MAAM,SAAS;CACf,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQC,eAAAA,gBAAgB,QAAQ,QAAQ,CAAC,cAAc,GAAG;EAC3F,MAAM,QAAQ,OAAO;EACrB,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,KAAK,CAAC,CAAC,SAAS;EAC5D,MAAM,IAAIC,eAAAA,YACRC,eAAAA,gBAAgB,YAChB,QACI,GAAG,QAAQ,QAAQ,iBAAiB,KAAK,mFACzC,GAAG,QAAQ,QAAQ,iBAAiB,KAAK,uEAC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kc as WidgetFlags, Mg as PdfCoordinates, Mu as BundleImportTarget, Rl as AnnotationImportDrop, Tf as AnnotationReplyType, Vc as FormValuesImportDrop, Zg as FormFieldRef, bs as AnnotationDraft, ju as BundleImportPages, qs as DraftResolveOptions, uv as PageRef, vg as FormFieldFamily, vl as FormBundle, vo as FormFieldDraft, vs as Annotation, vu as AnnotationBundle, xs as AnnotationPatch } from "./AnnotationList-CkijRHet.cjs";
2
+ //#region src/annotation/checkWrite.d.ts
3
+ /**
4
+ * A prepared create's data checked against its kind's schema. The caller
5
+ * writes its own data, not the schema's output, so nothing is reshaped on its
6
+ * way in.
7
+ */
8
+ declare function assertAnnotationDraft(draft: AnnotationDraft<PdfCoordinates>, options?: {
9
+ /**
10
+ * Link fields the caller has taken out of the draft and links itself (a
11
+ * change set's `reply` and popup `parent`); they aren't checked here.
12
+ */
13
+ linked?: readonly string[];
14
+ }): void;
15
+ /**
16
+ * A prepared update's data (`pdfPrepareAnnotationPatch`) checked against the
17
+ * kind of `current`. A `readBack()` value still in it is a change, as
18
+ * preparation drops one sent back as it reads, so one a write can't make is
19
+ * refused; the rest is checked against the kind's update schema.
20
+ */
21
+ declare function assertAnnotationPatch(current: Annotation<PdfCoordinates>, prepared: AnnotationPatch<PdfCoordinates>): void;
22
+ /**
23
+ * The draft the engine writes for `draft`, in the file's coordinates:
24
+ * prepared (`pdfPrepareAnnotationDraft`), checked against its kind, and
25
+ * every field that follows from it stated (`pdfDeriveAnnotationDraft`). A
26
+ * viewer predicts the same without schema validation
27
+ * (`pdfPredictAnnotationDraft`).
28
+ *
29
+ * Throws `InvalidArg` for a draft the engine refuses. Pure: it reads nothing
30
+ * but its arguments.
31
+ */
32
+ declare function pdfResolveAnnotationDraft(draft: AnnotationDraft<PdfCoordinates>, options?: DraftResolveOptions): AnnotationDraft<PdfCoordinates>;
33
+ /**
34
+ * The patch the engine writes for `patch` on `current`, in the file's
35
+ * coordinates: prepared (`pdfPrepareAnnotationPatch`), checked against its
36
+ * kind (`assertAnnotationPatch`), and every field that follows from it
37
+ * stated (`pdfDeriveAnnotationPatch`). A viewer predicts the same without
38
+ * schema validation (`pdfPredictAnnotationPatch`).
39
+ *
40
+ * Throws `InvalidArg` for a patch the engine refuses. Pure: it reads nothing
41
+ * but its arguments.
42
+ */
43
+ declare function pdfResolveAnnotationPatch(current: Annotation<PdfCoordinates>, patch: AnnotationPatch<PdfCoordinates>, options?: ResolveOptions): AnnotationPatch<PdfCoordinates>;
44
+ //#endregion
45
+ //#region src/transfer/planAnnotationImport.d.ts
46
+ /** One annotation an import creates. */
47
+ interface PlannedAnnotation {
48
+ /** Its item in the bundle. */
49
+ readonly item: number;
50
+ /** The page it goes on. */
51
+ readonly page: PageRef;
52
+ /** What `create` writes: the item's data, its pages mapped, without its links and dropped fields. */
53
+ readonly draft: AnnotationDraft;
54
+ /** The annotation it replies to, by its place in `creates`. */
55
+ readonly replyTo?: {
56
+ readonly planned: number;
57
+ readonly type: AnnotationReplyType;
58
+ };
59
+ /** For a popup: the annotation it shows, by its place in `creates`. */
60
+ readonly parent?: number;
61
+ }
62
+ interface AnnotationImportPlan {
63
+ /** In bundle order. */
64
+ readonly creates: readonly PlannedAnnotation[];
65
+ readonly dropped: readonly AnnotationImportDrop[];
66
+ }
67
+ /**
68
+ * What an import of `bundle` into the `target` pages creates, and what it
69
+ * leaves out. Nothing here touches a document, so an import refuses before
70
+ * its first write:
71
+ *
72
+ * - `InvalidArg` when an item's data isn't valid for its kind, or when a
73
+ * page an item is on or points at maps to no target page (naming them);
74
+ * - `NotFound` when a page list maps to a page the target doesn't have.
75
+ *
76
+ * Unsupported items and unresolved relationships are left out in this order:
77
+ *
78
+ * 1. an item of an unsupported kind, and a form field's widget; a field
79
+ * marker leaves out only that field;
80
+ * 2. an item whose `reply.to` or `parent` is no item of the bundle on the
81
+ * same target page (`parent-missing`);
82
+ * 3. an item whose name is used on its target page, or by an earlier item
83
+ * going to the same page (`name-conflict`);
84
+ * 4. then, until nothing changes, an item whose `reply.to` or `parent` was
85
+ * left out (`parent-dropped`), so a whole branch goes together.
86
+ *
87
+ * `nameTaken(page, nm)` answers for the target page as it is before the import.
88
+ */
89
+ declare function planAnnotationImport(input: {
90
+ readonly bundle: Pick<AnnotationBundle, 'pages' | 'items'>;
91
+ readonly pages?: BundleImportPages;
92
+ readonly target: readonly BundleImportTarget[];
93
+ readonly nameTaken: (page: PageRef, nm: string) => boolean;
94
+ }): AnnotationImportPlan;
95
+ //#endregion
96
+ //#region src/transfer/planFormImport.d.ts
97
+ /** One field a design import creates. */
98
+ interface PlannedFormField {
99
+ /** Its row in the bundle. */
100
+ readonly field: number;
101
+ /** What `create` writes: the field's settings, scripts and widgets, their pages mapped. */
102
+ readonly draft: FormFieldDraft;
103
+ /** Each widget's row in the bundle, in `draft.widgets` order. */
104
+ readonly widgets: readonly number[];
105
+ /** Each widget's flags, in `draft.widgets` order. */
106
+ readonly flags: readonly WidgetFlags[];
107
+ /** The value it gets; absent when the import writes none. */
108
+ readonly value?: FormFieldValue;
109
+ }
110
+ interface FormImportPlan {
111
+ /** In bundle order. */
112
+ readonly creates: readonly PlannedFormField[];
113
+ /** The calculation order among the creates, by their place in `creates`, as the bundle has it. */
114
+ readonly calculationOrder: readonly number[];
115
+ readonly dropped: readonly FormImportDrop[];
116
+ }
117
+ /**
118
+ * What a design import of `bundle` into the `target` pages creates, and what
119
+ * it leaves out. Nothing here touches a document, so an import refuses
120
+ * before its first write:
121
+ *
122
+ * - `InvalidArg` when a field's data isn't valid for its family, or when a
123
+ * page a widget is on or points at maps to no target page;
124
+ * - `NotFound` when a page list maps to a page the target doesn't have.
125
+ *
126
+ * Left out, in bundle order: a field of an unknown family, a field whose
127
+ * name is taken (`nameTaken`, for the document as it is before the
128
+ * import), a widget whose field isn't in the bundle, and each action that
129
+ * is a script, a submit or a link when `mayScript` is false
130
+ * (`doc.forms.script`), or that a write can't make. Each field keeps every
131
+ * widget it has. With `values`, each field gets the value the bundle holds.
132
+ */
133
+ declare function planFormImport(input: {
134
+ readonly bundle: Pick<FormBundle, 'pages' | 'fields' | 'widgets' | 'calculationOrder'>;
135
+ readonly pages?: BundleImportPages;
136
+ readonly target: readonly BundleImportTarget[];
137
+ readonly nameTaken: (name: string) => boolean;
138
+ readonly mayScript: boolean;
139
+ readonly values: boolean;
140
+ }): FormImportPlan;
141
+ /** A field of the document a values import fills. */
142
+ interface FormValuesImportTarget {
143
+ readonly ref: FormFieldRef;
144
+ readonly name: string;
145
+ readonly family: FormFieldFamily;
146
+ }
147
+ /** One value a values import writes. */
148
+ interface PlannedValueWrite<T extends FormValuesImportTarget = FormValuesImportTarget> {
149
+ /** Its field's row in the bundle. */
150
+ readonly field: number;
151
+ /** The document's field of that name. */
152
+ readonly target: T;
153
+ readonly value: FormFieldValue;
154
+ }
155
+ /**
156
+ * What a values import of `bundle` writes into a form whose fields are
157
+ * `target`: each field the bundle holds a value for gets it, matched by full
158
+ * name. Left out, in bundle order: a field the document doesn't have
159
+ * (`no-field`), one of another family (`wrong-family`), and one `refusal`
160
+ * names a reason for: a value the field can't take, a field a signature
161
+ * locked, a field the session may not fill in. So everything is decided
162
+ * before the first write.
163
+ */
164
+ declare function planFormValuesImport<T extends FormValuesImportTarget>(input: {
165
+ readonly bundle: Pick<FormBundle, 'fields'>;
166
+ readonly target: readonly T[];
167
+ readonly refusal?: (target: T, value: FormFieldValue) => Extract<FormValuesImportDropReason, 'value-not-allowed' | 'locked' | 'fill-not-allowed'> | null;
168
+ }): {
169
+ readonly writes: readonly PlannedValueWrite<T>[];
170
+ readonly dropped: readonly FormValuesImportDrop[];
171
+ };
172
+ //#endregion
173
+ export { type AnnotationImportPlan, type FormImportPlan, type FormValuesImportTarget, type PlannedAnnotation, type PlannedFormField, type PlannedValueWrite, assertAnnotationDraft, assertAnnotationPatch, pdfResolveAnnotationDraft, pdfResolveAnnotationPatch, planAnnotationImport, planFormImport, planFormValuesImport };
174
+ //# sourceMappingURL=validation.d.cts.map
@@ -0,0 +1,174 @@
1
+ import { Aa as FormFieldValue, Hc as FormValuesImportDropReason, Ic as FormImportDrop, Js as ResolveOptions, Kc as WidgetFlags, Mg as PdfCoordinates, Mu as BundleImportTarget, Rl as AnnotationImportDrop, Tf as AnnotationReplyType, Vc as FormValuesImportDrop, Zg as FormFieldRef, bs as AnnotationDraft, ju as BundleImportPages, qs as DraftResolveOptions, uv as PageRef, vg as FormFieldFamily, vl as FormBundle, vo as FormFieldDraft, vs as Annotation, vu as AnnotationBundle, xs as AnnotationPatch } from "./AnnotationList-CkijRHet.js";
2
+ //#region src/annotation/checkWrite.d.ts
3
+ /**
4
+ * A prepared create's data checked against its kind's schema. The caller
5
+ * writes its own data, not the schema's output, so nothing is reshaped on its
6
+ * way in.
7
+ */
8
+ declare function assertAnnotationDraft(draft: AnnotationDraft<PdfCoordinates>, options?: {
9
+ /**
10
+ * Link fields the caller has taken out of the draft and links itself (a
11
+ * change set's `reply` and popup `parent`); they aren't checked here.
12
+ */
13
+ linked?: readonly string[];
14
+ }): void;
15
+ /**
16
+ * A prepared update's data (`pdfPrepareAnnotationPatch`) checked against the
17
+ * kind of `current`. A `readBack()` value still in it is a change, as
18
+ * preparation drops one sent back as it reads, so one a write can't make is
19
+ * refused; the rest is checked against the kind's update schema.
20
+ */
21
+ declare function assertAnnotationPatch(current: Annotation<PdfCoordinates>, prepared: AnnotationPatch<PdfCoordinates>): void;
22
+ /**
23
+ * The draft the engine writes for `draft`, in the file's coordinates:
24
+ * prepared (`pdfPrepareAnnotationDraft`), checked against its kind, and
25
+ * every field that follows from it stated (`pdfDeriveAnnotationDraft`). A
26
+ * viewer predicts the same without schema validation
27
+ * (`pdfPredictAnnotationDraft`).
28
+ *
29
+ * Throws `InvalidArg` for a draft the engine refuses. Pure: it reads nothing
30
+ * but its arguments.
31
+ */
32
+ declare function pdfResolveAnnotationDraft(draft: AnnotationDraft<PdfCoordinates>, options?: DraftResolveOptions): AnnotationDraft<PdfCoordinates>;
33
+ /**
34
+ * The patch the engine writes for `patch` on `current`, in the file's
35
+ * coordinates: prepared (`pdfPrepareAnnotationPatch`), checked against its
36
+ * kind (`assertAnnotationPatch`), and every field that follows from it
37
+ * stated (`pdfDeriveAnnotationPatch`). A viewer predicts the same without
38
+ * schema validation (`pdfPredictAnnotationPatch`).
39
+ *
40
+ * Throws `InvalidArg` for a patch the engine refuses. Pure: it reads nothing
41
+ * but its arguments.
42
+ */
43
+ declare function pdfResolveAnnotationPatch(current: Annotation<PdfCoordinates>, patch: AnnotationPatch<PdfCoordinates>, options?: ResolveOptions): AnnotationPatch<PdfCoordinates>;
44
+ //#endregion
45
+ //#region src/transfer/planAnnotationImport.d.ts
46
+ /** One annotation an import creates. */
47
+ interface PlannedAnnotation {
48
+ /** Its item in the bundle. */
49
+ readonly item: number;
50
+ /** The page it goes on. */
51
+ readonly page: PageRef;
52
+ /** What `create` writes: the item's data, its pages mapped, without its links and dropped fields. */
53
+ readonly draft: AnnotationDraft;
54
+ /** The annotation it replies to, by its place in `creates`. */
55
+ readonly replyTo?: {
56
+ readonly planned: number;
57
+ readonly type: AnnotationReplyType;
58
+ };
59
+ /** For a popup: the annotation it shows, by its place in `creates`. */
60
+ readonly parent?: number;
61
+ }
62
+ interface AnnotationImportPlan {
63
+ /** In bundle order. */
64
+ readonly creates: readonly PlannedAnnotation[];
65
+ readonly dropped: readonly AnnotationImportDrop[];
66
+ }
67
+ /**
68
+ * What an import of `bundle` into the `target` pages creates, and what it
69
+ * leaves out. Nothing here touches a document, so an import refuses before
70
+ * its first write:
71
+ *
72
+ * - `InvalidArg` when an item's data isn't valid for its kind, or when a
73
+ * page an item is on or points at maps to no target page (naming them);
74
+ * - `NotFound` when a page list maps to a page the target doesn't have.
75
+ *
76
+ * Unsupported items and unresolved relationships are left out in this order:
77
+ *
78
+ * 1. an item of an unsupported kind, and a form field's widget; a field
79
+ * marker leaves out only that field;
80
+ * 2. an item whose `reply.to` or `parent` is no item of the bundle on the
81
+ * same target page (`parent-missing`);
82
+ * 3. an item whose name is used on its target page, or by an earlier item
83
+ * going to the same page (`name-conflict`);
84
+ * 4. then, until nothing changes, an item whose `reply.to` or `parent` was
85
+ * left out (`parent-dropped`), so a whole branch goes together.
86
+ *
87
+ * `nameTaken(page, nm)` answers for the target page as it is before the import.
88
+ */
89
+ declare function planAnnotationImport(input: {
90
+ readonly bundle: Pick<AnnotationBundle, 'pages' | 'items'>;
91
+ readonly pages?: BundleImportPages;
92
+ readonly target: readonly BundleImportTarget[];
93
+ readonly nameTaken: (page: PageRef, nm: string) => boolean;
94
+ }): AnnotationImportPlan;
95
+ //#endregion
96
+ //#region src/transfer/planFormImport.d.ts
97
+ /** One field a design import creates. */
98
+ interface PlannedFormField {
99
+ /** Its row in the bundle. */
100
+ readonly field: number;
101
+ /** What `create` writes: the field's settings, scripts and widgets, their pages mapped. */
102
+ readonly draft: FormFieldDraft;
103
+ /** Each widget's row in the bundle, in `draft.widgets` order. */
104
+ readonly widgets: readonly number[];
105
+ /** Each widget's flags, in `draft.widgets` order. */
106
+ readonly flags: readonly WidgetFlags[];
107
+ /** The value it gets; absent when the import writes none. */
108
+ readonly value?: FormFieldValue;
109
+ }
110
+ interface FormImportPlan {
111
+ /** In bundle order. */
112
+ readonly creates: readonly PlannedFormField[];
113
+ /** The calculation order among the creates, by their place in `creates`, as the bundle has it. */
114
+ readonly calculationOrder: readonly number[];
115
+ readonly dropped: readonly FormImportDrop[];
116
+ }
117
+ /**
118
+ * What a design import of `bundle` into the `target` pages creates, and what
119
+ * it leaves out. Nothing here touches a document, so an import refuses
120
+ * before its first write:
121
+ *
122
+ * - `InvalidArg` when a field's data isn't valid for its family, or when a
123
+ * page a widget is on or points at maps to no target page;
124
+ * - `NotFound` when a page list maps to a page the target doesn't have.
125
+ *
126
+ * Left out, in bundle order: a field of an unknown family, a field whose
127
+ * name is taken (`nameTaken`, for the document as it is before the
128
+ * import), a widget whose field isn't in the bundle, and each action that
129
+ * is a script, a submit or a link when `mayScript` is false
130
+ * (`doc.forms.script`), or that a write can't make. Each field keeps every
131
+ * widget it has. With `values`, each field gets the value the bundle holds.
132
+ */
133
+ declare function planFormImport(input: {
134
+ readonly bundle: Pick<FormBundle, 'pages' | 'fields' | 'widgets' | 'calculationOrder'>;
135
+ readonly pages?: BundleImportPages;
136
+ readonly target: readonly BundleImportTarget[];
137
+ readonly nameTaken: (name: string) => boolean;
138
+ readonly mayScript: boolean;
139
+ readonly values: boolean;
140
+ }): FormImportPlan;
141
+ /** A field of the document a values import fills. */
142
+ interface FormValuesImportTarget {
143
+ readonly ref: FormFieldRef;
144
+ readonly name: string;
145
+ readonly family: FormFieldFamily;
146
+ }
147
+ /** One value a values import writes. */
148
+ interface PlannedValueWrite<T extends FormValuesImportTarget = FormValuesImportTarget> {
149
+ /** Its field's row in the bundle. */
150
+ readonly field: number;
151
+ /** The document's field of that name. */
152
+ readonly target: T;
153
+ readonly value: FormFieldValue;
154
+ }
155
+ /**
156
+ * What a values import of `bundle` writes into a form whose fields are
157
+ * `target`: each field the bundle holds a value for gets it, matched by full
158
+ * name. Left out, in bundle order: a field the document doesn't have
159
+ * (`no-field`), one of another family (`wrong-family`), and one `refusal`
160
+ * names a reason for: a value the field can't take, a field a signature
161
+ * locked, a field the session may not fill in. So everything is decided
162
+ * before the first write.
163
+ */
164
+ declare function planFormValuesImport<T extends FormValuesImportTarget>(input: {
165
+ readonly bundle: Pick<FormBundle, 'fields'>;
166
+ readonly target: readonly T[];
167
+ readonly refusal?: (target: T, value: FormFieldValue) => Extract<FormValuesImportDropReason, 'value-not-allowed' | 'locked' | 'fill-not-allowed'> | null;
168
+ }): {
169
+ readonly writes: readonly PlannedValueWrite<T>[];
170
+ readonly dropped: readonly FormValuesImportDrop[];
171
+ };
172
+ //#endregion
173
+ export { type AnnotationImportPlan, type FormImportPlan, type FormValuesImportTarget, type PlannedAnnotation, type PlannedFormField, type PlannedValueWrite, assertAnnotationDraft, assertAnnotationPatch, pdfResolveAnnotationDraft, pdfResolveAnnotationPatch, planAnnotationImport, planFormImport, planFormValuesImport };
174
+ //# sourceMappingURL=validation.d.ts.map