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

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 (58) hide show
  1. package/dist/{AbortError-DHqPBnYc.js → AbortError-DwuHPK_I.js} +2 -2
  2. package/dist/{AbortError-DHqPBnYc.js.map → AbortError-DwuHPK_I.js.map} +1 -1
  3. package/dist/{AbortError-Cq2igpZ6.cjs → AbortError-P0RU0Mgg.cjs} +4 -4
  4. package/dist/{AbortError-Cq2igpZ6.cjs.map → AbortError-P0RU0Mgg.cjs.map} +1 -1
  5. package/dist/{AnnotationListSnapshot-D3mFut1e.d.cts → AnnotationListSnapshot-D9R5n2Kf.d.cts} +237 -7
  6. package/dist/{AnnotationListSnapshot-D3mFut1e.d.ts → AnnotationListSnapshot-D9R5n2Kf.d.ts} +237 -7
  7. package/dist/{DocumentSecurityService-ClTZc0zO.d.cts → DocumentSecurityService-CIx1MT0T.d.cts} +2 -2
  8. package/dist/{DocumentSecurityService-_JRjqvoI.d.ts → DocumentSecurityService-Ca6EK3-3.d.ts} +2 -2
  9. package/dist/{Engine-Bx0NOfmd.d.cts → Engine-EWWHhEIi.d.ts} +17 -4
  10. package/dist/{Engine-DxtpCYcP.d.ts → Engine-FNaAEjfb.d.cts} +17 -4
  11. package/dist/conformance.cjs +382 -95
  12. package/dist/conformance.cjs.map +1 -1
  13. package/dist/conformance.d.cts +7 -3
  14. package/dist/conformance.d.ts +7 -3
  15. package/dist/conformance.js +302 -16
  16. package/dist/conformance.js.map +1 -1
  17. package/dist/derive-BbsDk_Kz.cjs +880 -0
  18. package/dist/derive-BbsDk_Kz.cjs.map +1 -0
  19. package/dist/derive-DAFJolWu.js +647 -0
  20. package/dist/derive-DAFJolWu.js.map +1 -0
  21. package/dist/{PageInsertBlankInput-cHq9-i-z.js → format-Bbphf4zR.js} +59 -2
  22. package/dist/format-Bbphf4zR.js.map +1 -0
  23. package/dist/{PageInsertBlankInput-CqXBmFhN.cjs → format-D_epWlob.cjs} +70 -1
  24. package/dist/format-D_epWlob.cjs.map +1 -0
  25. package/dist/index.cjs +127 -107
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +4 -4
  29. package/dist/runtime.cjs +137 -117
  30. package/dist/runtime.cjs.map +1 -1
  31. package/dist/runtime.d.cts +29 -5
  32. package/dist/runtime.d.ts +29 -5
  33. package/dist/runtime.js +5 -5
  34. package/dist/{schemas-BLARNCgx.js → schemas-CFQGvWiu.js} +134 -4
  35. package/dist/schemas-CFQGvWiu.js.map +1 -0
  36. package/dist/{schemas-DIqFMmrC.cjs → schemas-D0g6tKa9.cjs} +250 -24
  37. package/dist/schemas-D0g6tKa9.cjs.map +1 -0
  38. package/dist/{builders-Bqm8yTpi.cjs → viewport-BWeNHZmb.cjs} +71 -132
  39. package/dist/viewport-BWeNHZmb.cjs.map +1 -0
  40. package/dist/{builders-Dqo2X-dt.js → viewport-CvMcadfQ.js} +39 -88
  41. package/dist/viewport-CvMcadfQ.js.map +1 -0
  42. package/dist/wire.cjs +25 -2
  43. package/dist/wire.cjs.map +1 -1
  44. package/dist/wire.d.cts +2739 -8
  45. package/dist/wire.d.ts +2739 -8
  46. package/dist/wire.js +10 -3
  47. package/dist/wire.js.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/PageInsertBlankInput-CqXBmFhN.cjs.map +0 -1
  50. package/dist/PageInsertBlankInput-cHq9-i-z.js.map +0 -1
  51. package/dist/builders-Bqm8yTpi.cjs.map +0 -1
  52. package/dist/builders-Dqo2X-dt.js.map +0 -1
  53. package/dist/fold-2V29cxCV.cjs +0 -447
  54. package/dist/fold-2V29cxCV.cjs.map +0 -1
  55. package/dist/fold-CdEJTBTn.js +0 -334
  56. package/dist/fold-CdEJTBTn.js.map +0 -1
  57. package/dist/schemas-BLARNCgx.js.map +0 -1
  58. package/dist/schemas-DIqFMmrC.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { i as EngineError, n as foldText, r as toOriginalRange, s as _defineProperty, u as isRotatedGeometryRun } from "./fold-CdEJTBTn.js";
2
- import { f as EngineErrorCode } from "./PageInsertBlankInput-cHq9-i-z.js";
1
+ import { A as isRotatedGeometryRun, C as refKey, D as _defineProperty, S as classifyRelation, b as toOriginalRange, w as EngineError, y as foldText } from "./derive-DAFJolWu.js";
2
+ import { m as EngineErrorCode } from "./format-Bbphf4zR.js";
3
3
  import { _ as levelAllows, h as deriveProtection, v as levelFromPermission, x as minLevel, y as lockCovers } from "./resolver-inAVzsWt.js";
4
4
  //#region src/dto/PdfAction.ts
5
5
  /**
@@ -373,85 +373,6 @@ async function normalizeAnnotationPatch(patch) {
373
373
  }
374
374
  }
375
375
  //#endregion
376
- //#region src/annotation/relationships.ts
377
- /**
378
- * Classify one annotation by its relationship edge alone. Mirrors the
379
- * spec's "practical parser rule": no `/IRT` is top-level; `/RT /Group` is
380
- * a grouped subordinate; anything else with an `/IRT` is a reply (the
381
- * engine has already normalized a missing `/RT` to `'reply'`).
382
- */
383
- function classifyRelation(a) {
384
- if (!a.inReplyTo) return "top-level";
385
- return a.replyType === "group" ? "grouped-subordinate" : "reply";
386
- }
387
- /**
388
- * Stable string key for an {@link AnnotationRef}, used to match a child's
389
- * `inReplyTo` against a candidate parent's `ref`. Both sides are produced
390
- * by the engine with the same identity precedence (objectNumber, then nm,
391
- * then index), so equal keys mean "same annotation".
392
- */
393
- function refKey(ref) {
394
- switch (ref.kind) {
395
- case "objectNumber": return `obj:${ref.pageObjectNumber}:${ref.annotObjectNumber}`;
396
- case "nm": return `nm:${ref.pageObjectNumber}:${ref.nm}`;
397
- case "index": return `idx:${ref.pageObjectNumber}:${ref.index}`;
398
- }
399
- }
400
- /**
401
- * Compose a flat annotation list (one page, or a whole document via
402
- * `listRawAll()` flattened) into {@link AnnotationThread}s in primary
403
- * order.
404
- *
405
- * Rules (ISO 32000 §12.5.6.2 + the spec's UI rule):
406
- * - Annotations with no `/IRT` become thread primaries, in input order.
407
- * - A `/RT /Group` child is attached to its primary's `groupedParts`.
408
- * - A `/RT /R` (or default) child is attached to its primary's `replies`.
409
- * - A child whose parent is not in the input set is treated as an
410
- * orphan primary (defensive — e.g. a partial/filtered page slice).
411
- *
412
- * Limitations (v1, matches the legacy stack): threading is one level deep
413
- * — a reply-to-a-reply is keyed to its direct parent, so it only appears
414
- * nested if that direct parent is itself a primary. Callers that want a
415
- * sidebar of "most annotations, not widgets/popups" should pre-filter the
416
- * input; this helper is intentionally unopinionated about eligibility.
417
- */
418
- function buildThreads(annotations) {
419
- const byKey = /* @__PURE__ */ new Map();
420
- for (const a of annotations) {
421
- byKey.set(refKey(a.ref), a);
422
- if (a.nm && a.nm.length > 0) byKey.set(`nm:${a.ref.pageObjectNumber}:${a.nm}`, a);
423
- }
424
- const threads = [];
425
- const threadByPrimaryKey = /* @__PURE__ */ new Map();
426
- const primaryThread = (primary) => {
427
- const key = refKey(primary.ref);
428
- let thread = threadByPrimaryKey.get(key);
429
- if (!thread) {
430
- thread = {
431
- primary,
432
- groupedParts: [],
433
- replies: []
434
- };
435
- threadByPrimaryKey.set(key, thread);
436
- threads.push(thread);
437
- }
438
- return thread;
439
- };
440
- for (const a of annotations) if (!a.inReplyTo) primaryThread(a);
441
- for (const a of annotations) {
442
- if (!a.inReplyTo) continue;
443
- const parent = byKey.get(refKey(a.inReplyTo));
444
- if (!parent || parent.inReplyTo) {
445
- primaryThread(a);
446
- continue;
447
- }
448
- const thread = primaryThread(parent);
449
- if (a.replyType === "group") thread.groupedParts.push(a);
450
- else thread.replies.push(a);
451
- }
452
- return threads;
453
- }
454
- //#endregion
455
376
  //#region src/annotation/comments.ts
456
377
  /** Subtypes that never participate in comment threads. `unsupported`
457
378
  * covers `/Popup` dictionaries (raw code 16) and unreadable foreign
@@ -803,15 +724,22 @@ function appearanceImpactOf(current, patch) {
803
724
  const cur = current;
804
725
  const pat = patch;
805
726
  const subtype = patch.subtype;
727
+ const caption = pat.caption === void 0 ? cur.caption : pat.caption;
728
+ const contentsPainted = CONTENTS_PAINTED.has(subtype) || [
729
+ "line",
730
+ "polygon",
731
+ "polyline"
732
+ ].includes(subtype) && !!caption?.enabled;
806
733
  const touched = [];
807
734
  for (const [key, value] of Object.entries(pat)) {
808
735
  if (value === void 0 || INERT_KEYS.has(key)) continue;
809
- if (key === "contents" && !CONTENTS_PAINTED.has(subtype)) continue;
736
+ if (key === "contents" && !contentsPainted) continue;
810
737
  if (key === "rotation" && ADVISORY_ROTATION.has(subtype)) continue;
811
738
  if (!semanticEqual(value, cur[key])) touched.push(key);
812
739
  }
813
740
  if (touched.length === 0) return "inert";
814
- const geometryKeys = TRANSLATABLE_GEOMETRY[subtype];
741
+ const baseGeometryKeys = TRANSLATABLE_GEOMETRY[subtype];
742
+ const geometryKeys = baseGeometryKeys && (subtype === "polygon" || subtype === "polyline") && cur.caption?.center ? [...baseGeometryKeys, "caption"] : baseGeometryKeys;
815
743
  if (!geometryKeys) return "regenerate";
816
744
  if (!touched.every((k) => geometryKeys.includes(k))) return "regenerate";
817
745
  return isRigidTranslation(cur, pat, subtype, geometryKeys) ? "translation" : "regenerate";
@@ -2208,7 +2136,8 @@ var EdgeResolver = class {
2208
2136
  function foldOptionsFor(query) {
2209
2137
  return {
2210
2138
  keepCase: !!query.matchCase,
2211
- keepMarks: !!query.matchDiacritics
2139
+ keepMarks: !!query.matchDiacritics,
2140
+ dropWhitespace: !!query.ignoreWhitespace
2212
2141
  };
2213
2142
  }
2214
2143
  const WORD_UNIT = /[\p{L}\p{N}_]/u;
@@ -2226,6 +2155,17 @@ function wordAt(text, index) {
2226
2155
  return WORD_UNIT.test(String.fromCodePoint(text.codePointAt(index)));
2227
2156
  }
2228
2157
  /**
2158
+ * Whether the folded hit at `at` sits on word boundaries. Checked on the
2159
+ * folded plane, except under `ignoreWhitespace`: dropping whitespace glues
2160
+ * neighbouring words together ("i n v o i c e 42" folds to "invoice42"), so there the
2161
+ * boundaries are read off the ORIGINAL text around the mapped range.
2162
+ */
2163
+ function isWholeWordHit(haystack, at, needleLength, query) {
2164
+ if (!query.ignoreWhitespace) return !wordBefore(haystack.folded, at) && !wordAt(haystack.folded, at + needleLength);
2165
+ const { start, length } = toOriginalRange(haystack, at, needleLength);
2166
+ return !wordBefore(haystack.original, start) && !wordAt(haystack.original, start + length);
2167
+ }
2168
+ /**
2229
2169
  * All non-overlapping literal matches, in original code-unit space.
2230
2170
  * `haystack` must have been folded with `foldOptionsFor(query)`.
2231
2171
  */
@@ -2237,7 +2177,7 @@ function matchLiteral(haystack, query) {
2237
2177
  while (from <= haystack.folded.length - needle.length) {
2238
2178
  const at = haystack.folded.indexOf(needle, from);
2239
2179
  if (at < 0) break;
2240
- if (query.wholeWord && (wordBefore(haystack.folded, at) || wordAt(haystack.folded, at + needle.length))) {
2180
+ if (query.wholeWord && !isWholeWordHit(haystack, at, needle.length, query)) {
2241
2181
  from = at + 1;
2242
2182
  continue;
2243
2183
  }
@@ -2338,6 +2278,11 @@ function validateSearchQuery(query) {
2338
2278
  issue: "diacritics-with-regex",
2339
2279
  message: "Diacritic-sensitive matching is not available for regex patterns (regex runs on the raw text plane)."
2340
2280
  };
2281
+ if (query.ignoreWhitespace) return {
2282
+ ok: false,
2283
+ issue: "ignore-whitespace-with-regex",
2284
+ message: "Whitespace-insensitive matching is not available for regex patterns (regex runs on the raw text plane; use \\s* in the pattern)."
2285
+ };
2341
2286
  return validateSearchRegex(query.text);
2342
2287
  }
2343
2288
  /**
@@ -2921,7 +2866,7 @@ function fnv1a64(input) {
2921
2866
  * untouched (their raw form IS the query).
2922
2867
  */
2923
2868
  function canonicalSearchQuery(query) {
2924
- if (query.regex || query.matchCase || query.matchDiacritics) return query;
2869
+ if (query.regex || query.matchCase || query.matchDiacritics || query.ignoreWhitespace) return query;
2925
2870
  const canonical = { text: foldText(query.text).folded };
2926
2871
  if (query.wholeWord) canonical.wholeWord = true;
2927
2872
  return canonical;
@@ -3116,6 +3061,12 @@ function materializePdfPermissions(b) {
3116
3061
  return [...out];
3117
3062
  }
3118
3063
  //#endregion
3119
- export { buildCommentThreads as $, USAGE_INCOMPLETE as A, changedKeys as B, validateSearchRegex as C, wordBefore as D, wordAt as E, assessmentOf as F, stableStringify as G, parsePdfValue as H, combine as I, appearanceImpactOf as J, decodeFieldRefKey as K, conclude as L, evaluateStep as M, restrictionsOf as N, DEFAULT_EDGE_RESOLVER_BUDGET as O, sameEffectiveValue as P, shiftsExistingAnnotationIndices as Q, primaryFinding as R, validateSearchQuery as S, matchLiteral as T, pdfValueEquals as U, dictEntries as V, refsOf as W, changesAnnotationList as X, semanticEqual as Y, invalidatesWeakIndexRefs as Z, SEARCH_SNIPPET_CONTEXT as _, richTextPlainText as _t, PDF_BITS as a, normalizeAnnotationPatch as at, SEARCH_REGEX_MAX_LENGTH as b, decodeSubmitFormFlags as bt, searchContentEpoch as c, resolveBinarySource as ct, buildPageTextLayout as d, knownWeakAnnotationState as dt, isStateAnnotation as et, expandTextRangeToLine as f, revisionTokensEqual as ft, textSegmentsForRange as g, richTextParagraphsFromPlainText as gt, textGlyphQuad as h, isValidPageObjectNumber as ht, pdfPermissions as i, normalizeAnnotationDraft as it, restrictionsFor as j, EdgeResolver as k, searchRectsForRange as l, NO_ANNOTATION_FLAGS as lt, textGlyphAt as m, encodeStableIdKey as mt, collab as n, classifyRelation as nt, decodePdfBits as o, normalizeAttachmentFileSource as ot, expandTextRangeToWord as p, decodeStableIdKey as pt, encodeFieldRefKey as q, materializePdfPermissions as r, refKey as rt, canonicalSearchQuery as s, sniffBinaryMetadata as st, caps as t, buildThreads as tt, searchSegmentsForRange as u, UNKNOWN_WEAK_ANNOTATION_STATE as ut, buildSnippet as v, DEFAULT_PDF_SAVE_MODE as vt, foldOptionsFor as w, matchRegex as x, matchPageText as y, createPageImageHandle as yt, worstVerdict as z };
3064
+ //#region src/measure/viewport.ts
3065
+ /** Last containing viewport wins. A foreign measure still wins; never guess a fallback. */
3066
+ function viewportForPoint(viewports, point) {
3067
+ return [...viewports].reverse().find(({ bbox: b }) => point.x >= b.left && point.x <= b.right && point.y >= b.bottom && point.y <= b.top);
3068
+ }
3069
+ //#endregion
3070
+ export { shiftsExistingAnnotationIndices as $, EdgeResolver as A, worstVerdict as B, validateSearchQuery as C, wordAt as D, matchLiteral as E, sameEffectiveValue as F, refsOf as G, dictEntries as H, assessmentOf as I, encodeFieldRefKey as J, stableStringify as K, combine as L, restrictionsFor as M, evaluateStep as N, wordBefore as O, restrictionsOf as P, invalidatesWeakIndexRefs as Q, conclude as R, matchRegex as S, foldOptionsFor as T, parsePdfValue as U, changedKeys as V, pdfValueEquals as W, semanticEqual as X, appearanceImpactOf as Y, changesAnnotationList as Z, textSegmentsForRange as _, createPageImageHandle as _t, pdfPermissions as a, sniffBinaryMetadata as at, matchPageText as b, canonicalSearchQuery as c, UNKNOWN_WEAK_ANNOTATION_STATE as ct, searchSegmentsForRange as d, decodeStableIdKey as dt, buildCommentThreads as et, buildPageTextLayout as f, encodeStableIdKey as ft, textGlyphQuad as g, DEFAULT_PDF_SAVE_MODE as gt, textGlyphAt as h, richTextPlainText as ht, materializePdfPermissions as i, normalizeAttachmentFileSource as it, USAGE_INCOMPLETE as j, DEFAULT_EDGE_RESOLVER_BUDGET as k, searchContentEpoch as l, knownWeakAnnotationState as lt, expandTextRangeToWord as m, richTextParagraphsFromPlainText as mt, caps as n, normalizeAnnotationDraft as nt, PDF_BITS as o, resolveBinarySource as ot, expandTextRangeToLine as p, isValidPageObjectNumber as pt, decodeFieldRefKey as q, collab as r, normalizeAnnotationPatch as rt, decodePdfBits as s, NO_ANNOTATION_FLAGS as st, viewportForPoint as t, isStateAnnotation as tt, searchRectsForRange as u, revisionTokensEqual as ut, SEARCH_SNIPPET_CONTEXT as v, decodeSubmitFormFlags as vt, validateSearchRegex as w, SEARCH_REGEX_MAX_LENGTH as x, buildSnippet as y, primaryFinding as z };
3120
3071
 
3121
- //# sourceMappingURL=builders-Dqo2X-dt.js.map
3072
+ //# sourceMappingURL=viewport-CvMcadfQ.js.map