@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.
- package/dist/{AbortError-DHqPBnYc.js → AbortError-DwuHPK_I.js} +2 -2
- package/dist/{AbortError-DHqPBnYc.js.map → AbortError-DwuHPK_I.js.map} +1 -1
- package/dist/{AbortError-Cq2igpZ6.cjs → AbortError-P0RU0Mgg.cjs} +4 -4
- package/dist/{AbortError-Cq2igpZ6.cjs.map → AbortError-P0RU0Mgg.cjs.map} +1 -1
- package/dist/{AnnotationListSnapshot-D3mFut1e.d.cts → AnnotationListSnapshot-D9R5n2Kf.d.cts} +237 -7
- package/dist/{AnnotationListSnapshot-D3mFut1e.d.ts → AnnotationListSnapshot-D9R5n2Kf.d.ts} +237 -7
- package/dist/{DocumentSecurityService-ClTZc0zO.d.cts → DocumentSecurityService-CIx1MT0T.d.cts} +2 -2
- package/dist/{DocumentSecurityService-_JRjqvoI.d.ts → DocumentSecurityService-Ca6EK3-3.d.ts} +2 -2
- package/dist/{Engine-Bx0NOfmd.d.cts → Engine-EWWHhEIi.d.ts} +17 -4
- package/dist/{Engine-DxtpCYcP.d.ts → Engine-FNaAEjfb.d.cts} +17 -4
- package/dist/conformance.cjs +382 -95
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +7 -3
- package/dist/conformance.d.ts +7 -3
- package/dist/conformance.js +302 -16
- package/dist/conformance.js.map +1 -1
- package/dist/derive-BbsDk_Kz.cjs +880 -0
- package/dist/derive-BbsDk_Kz.cjs.map +1 -0
- package/dist/derive-DAFJolWu.js +647 -0
- package/dist/derive-DAFJolWu.js.map +1 -0
- package/dist/{PageInsertBlankInput-cHq9-i-z.js → format-Bbphf4zR.js} +59 -2
- package/dist/format-Bbphf4zR.js.map +1 -0
- package/dist/{PageInsertBlankInput-CqXBmFhN.cjs → format-D_epWlob.cjs} +70 -1
- package/dist/format-D_epWlob.cjs.map +1 -0
- package/dist/index.cjs +127 -107
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/runtime.cjs +137 -117
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +29 -5
- package/dist/runtime.d.ts +29 -5
- package/dist/runtime.js +5 -5
- package/dist/{schemas-BLARNCgx.js → schemas-CFQGvWiu.js} +134 -4
- package/dist/schemas-CFQGvWiu.js.map +1 -0
- package/dist/{schemas-DIqFMmrC.cjs → schemas-D0g6tKa9.cjs} +250 -24
- package/dist/schemas-D0g6tKa9.cjs.map +1 -0
- package/dist/{builders-Bqm8yTpi.cjs → viewport-BWeNHZmb.cjs} +71 -132
- package/dist/viewport-BWeNHZmb.cjs.map +1 -0
- package/dist/{builders-Dqo2X-dt.js → viewport-CvMcadfQ.js} +39 -88
- package/dist/viewport-CvMcadfQ.js.map +1 -0
- package/dist/wire.cjs +25 -2
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +2739 -8
- package/dist/wire.d.ts +2739 -8
- package/dist/wire.js +10 -3
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/PageInsertBlankInput-CqXBmFhN.cjs.map +0 -1
- package/dist/PageInsertBlankInput-cHq9-i-z.js.map +0 -1
- package/dist/builders-Bqm8yTpi.cjs.map +0 -1
- package/dist/builders-Dqo2X-dt.js.map +0 -1
- package/dist/fold-2V29cxCV.cjs +0 -447
- package/dist/fold-2V29cxCV.cjs.map +0 -1
- package/dist/fold-CdEJTBTn.js +0 -334
- package/dist/fold-CdEJTBTn.js.map +0 -1
- package/dist/schemas-BLARNCgx.js.map +0 -1
- package/dist/schemas-DIqFMmrC.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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" && !
|
|
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
|
|
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 && (
|
|
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
|
-
|
|
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=
|
|
3072
|
+
//# sourceMappingURL=viewport-CvMcadfQ.js.map
|