@poe-platform/safe-bash 0.1.811 → 0.1.812
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/audio-ast/index.d.ts +1 -0
- package/dist/audio-ast/index.js +6 -1
- package/dist/audio-ast/vorbis.d.ts +14 -0
- package/dist/image-ast/index.js +1 -1
- package/dist/pdf-ast/cos/value-parser.d.ts +23 -2
- package/dist/pdf-ast/extract/retained-form-field-details.d.ts +20 -0
- package/dist/pdf-ast/extract/retained-form-fields.d.ts +17 -4
- package/dist/pdf-ast/index.d.ts +1 -0
- package/dist/pdf-ast/index.js +701 -336
- package/dist/pdf-ast/retained-document.d.ts +4 -0
- package/dist/safe-bash/audio-ast.browser.js +2 -1
- package/dist/safe-bash/command-chunks/{biff-3EFLKBAH-NYWZOYQS.js → biff-YKPDH35C-MVQIWNKV.js} +2309 -2277
- package/dist/safe-bash/command-chunks/{chunk-VU3EQF7F.js → chunk-2JSDKQ4J.js} +110 -31
- package/dist/safe-bash/command-chunks/{chunk-72C3TZ2U.js → chunk-3Q247UDJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-HARUYHH7.js → chunk-5HUICAWD.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2VCKUNDZ.js → chunk-B2C3UPJS.js} +27 -17
- package/dist/safe-bash/command-chunks/{chunk-5LI2DLNZ.js → chunk-CJQSAATC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZHRGYR7B.js → chunk-FDCIPJBQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5MB64DWR.js → chunk-HWQ2UHMT.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-5OO2P27R.js → chunk-NARD63DY.js} +98 -1
- package/dist/safe-bash/command-chunks/{chunk-Z5QOVRVH.js → chunk-SU26FZLJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DPR5CYQV.js → chunk-XITDDJFT.js} +2 -0
- package/dist/safe-bash/command-chunks/{chunk-YSY6R6AS.js → chunk-XVLWZTPY.js} +230 -28
- package/dist/safe-bash/command-chunks/{chunk-WH3TIOTS.js → chunk-ZEGNRZV2.js} +9 -2
- package/dist/safe-bash/command-chunks/{chunk-KL3OIBKB.js → chunk-ZEX53S5I.js} +1892 -1878
- package/dist/safe-bash/command-chunks/{command-engine-BEWABZ75.js → command-engine-BCUQGJJ4.js} +58 -21
- package/dist/safe-bash/command-chunks/{engine-AXXFTGCL-QBQNBI6K.js → engine-LAUEWYSQ-DQCEI5HE.js} +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +4 -4
- package/dist/safe-bash-command-apply-patch/index.js +4 -4
- package/dist/safe-bash-command-apply-patch/matcher.js +2 -2
- package/dist/safe-bash-command-apply-patch/parser.js +2 -2
- package/dist/safe-bash-command-apply-patch/shared.d.ts +2 -0
- package/dist/safe-bash-command-apply-patch/shared.js +1 -1
- package/dist/safe-bash-command-ffmpeg/index.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -2
- package/dist/safe-bash-command-ffprobe/media.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +1 -1
- package/dist/safe-bash-command-pandoc/index.js +1 -1
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-pdftk/index.js +35 -2
- package/dist/safe-bash-command-pptx/command-engine.d.ts +12 -3
- package/dist/safe-bash-command-pptx/engine.d.ts +2 -2
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-diff-engine/document.d.ts +2 -1
- package/dist/safe-bash-diff-engine/document.js +7 -4
- package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
- package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/index.js +9 -7
- package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
- package/dist/safe-bash-presentation-engine/retained-slide-publication.d.ts +24 -0
- package/dist/safe-bash-presentation-engine/slides.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/slides.js +6 -3
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +2 -2
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +46 -13
- package/dist/spreadsheet-format-xls/biff-metadata.d.ts +1 -0
- package/dist/spreadsheet-format-xls/biff-metadata.js +2 -2
- package/dist/spreadsheet-format-xls/biff-write-metadata.js +10 -1
- package/package.json +2 -2
package/dist/pdf-ast/index.js
CHANGED
|
@@ -28156,28 +28156,41 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
|
|
|
28156
28156
|
if (nodes >= maxNodes) throw new PdfError("E_LIMIT", "PDF value node limit exceeded");
|
|
28157
28157
|
nodes++;
|
|
28158
28158
|
};
|
|
28159
|
+
const residentDepth = 32;
|
|
28159
28160
|
const stack = [];
|
|
28160
|
-
|
|
28161
|
+
let current, depth = 0;
|
|
28162
|
+
const pathLength = (options.storedArrayPaths ?? []).reduce((length, path) => Math.max(length, path.length - 1), 0);
|
|
28163
|
+
function matchesStoredPath(parent) {
|
|
28161
28164
|
return options.storedArrayPaths?.some((path) => {
|
|
28162
|
-
const
|
|
28165
|
+
const length = parent.path.length + 1;
|
|
28163
28166
|
if (!path.length || path.length > length) return false;
|
|
28164
28167
|
for (let i = 0; i < path.length; i++) {
|
|
28165
28168
|
const at = length - path.length + i;
|
|
28166
|
-
|
|
28167
|
-
if (
|
|
28168
|
-
else {
|
|
28169
|
-
const parent = stack[at - prefix.length];
|
|
28170
|
-
if (parent.kind !== "dict") return false;
|
|
28171
|
-
key = parent.key?.decoded;
|
|
28172
|
-
}
|
|
28173
|
-
if (key === void 0 || path[i] !== "*" && path[i] !== key) return false;
|
|
28169
|
+
const key = at === parent.path.length ? parent.kind === "dict" ? parent.key?.decoded : void 0 : parent.path[at];
|
|
28170
|
+
if (key == null || path[i] !== "*" && path[i] !== key) return false;
|
|
28174
28171
|
}
|
|
28175
28172
|
return true;
|
|
28176
28173
|
}) ?? false;
|
|
28177
28174
|
}
|
|
28175
|
+
function ancestorPath(parent) {
|
|
28176
|
+
if (!pathLength) return [];
|
|
28177
|
+
return parent ? [...parent.path, parent.kind === "dict" ? parent.key?.decoded ?? null : null].slice(-pathLength) : options.arrayPathPrefix?.slice(-pathLength) ?? [];
|
|
28178
|
+
}
|
|
28179
|
+
function* push(container) {
|
|
28180
|
+
if (current) {
|
|
28181
|
+
if (options.containerStorage && depth > residentDepth) yield { kind: "container-push", container: current };
|
|
28182
|
+
else stack.push(current);
|
|
28183
|
+
}
|
|
28184
|
+
current = container;
|
|
28185
|
+
depth++;
|
|
28186
|
+
}
|
|
28187
|
+
function* pop() {
|
|
28188
|
+
depth--;
|
|
28189
|
+
current = options.containerStorage && depth > residentDepth ? yield { kind: "container-pop" } : stack.pop();
|
|
28190
|
+
}
|
|
28178
28191
|
while (true) {
|
|
28179
28192
|
if (++work % 16 === 0) yield;
|
|
28180
|
-
const parent =
|
|
28193
|
+
const parent = current;
|
|
28181
28194
|
lexer.setStringStorage?.(options.stringStorage && (parent?.kind === "dict" && parent.key && options.storedStringKeys?.includes(parent.key.decoded) || !parent && options.storeRootString) ? options.stringStorage : void 0);
|
|
28182
28195
|
const tok = yield "token";
|
|
28183
28196
|
if (!tok) {
|
|
@@ -28190,11 +28203,11 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
|
|
|
28190
28203
|
}
|
|
28191
28204
|
let node;
|
|
28192
28205
|
if (parent?.kind === "array" && tok.kind === "array-end") {
|
|
28193
|
-
|
|
28206
|
+
yield* pop();
|
|
28194
28207
|
node = { kind: "array", items: parent.items, ...parent.storedItems ? { storedItems: parent.storedItems } : {}, span: { start: parent.start, end: tok.span.end } };
|
|
28195
28208
|
} else if (parent?.kind === "dict" && !parent.key) {
|
|
28196
28209
|
if (tok.kind === "dict-end") {
|
|
28197
|
-
|
|
28210
|
+
yield* pop();
|
|
28198
28211
|
node = yield { kind: "dict", entries: parent.entries, span: { start: parent.start, end: tok.span.end } };
|
|
28199
28212
|
} else if (tok.kind === "name") {
|
|
28200
28213
|
charge();
|
|
@@ -28209,11 +28222,12 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
|
|
|
28209
28222
|
throw new PdfError("E_PARSE", `Missing value for dictionary key /${parent.key.decoded}`);
|
|
28210
28223
|
}
|
|
28211
28224
|
charge();
|
|
28212
|
-
if (
|
|
28225
|
+
if (depth > maxDepth) throw new PdfError("E_LIMIT", "PDF syntax nesting limit exceeded");
|
|
28213
28226
|
if (tok.kind === "array-start") {
|
|
28214
|
-
const backed = options.arrayStorage && (parent?.kind === "array" && parent.storedItems || parent?.kind === "dict" && (options.storedArrayKeys?.includes(parent.key.decoded) || matchesStoredPath()) || !parent && options.storeRootArray);
|
|
28215
|
-
|
|
28227
|
+
const backed = options.arrayStorage && (parent?.kind === "array" && parent.storedItems || parent?.kind === "dict" && (options.storedArrayKeys?.includes(parent.key.decoded) || matchesStoredPath(parent)) || !parent && options.storeRootArray);
|
|
28228
|
+
yield* push({
|
|
28216
28229
|
kind: "array",
|
|
28230
|
+
path: ancestorPath(parent),
|
|
28217
28231
|
start: tok.span.start,
|
|
28218
28232
|
items: [],
|
|
28219
28233
|
tail: -1,
|
|
@@ -28222,12 +28236,12 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
|
|
|
28222
28236
|
continue;
|
|
28223
28237
|
}
|
|
28224
28238
|
if (tok.kind === "dict-start") {
|
|
28225
|
-
|
|
28239
|
+
yield* push({ kind: "dict", path: ancestorPath(parent), start: tok.span.start, entries: [] });
|
|
28226
28240
|
continue;
|
|
28227
28241
|
}
|
|
28228
28242
|
node = yield* parseLeafFromToken(tok, lexer);
|
|
28229
28243
|
}
|
|
28230
|
-
const container =
|
|
28244
|
+
const container = current;
|
|
28231
28245
|
if (!container) return node;
|
|
28232
28246
|
if (container.kind === "array") {
|
|
28233
28247
|
if (container.storedItems) {
|
|
@@ -30819,7 +30833,7 @@ function* parseNodeFromLexerSteps(lexer, bytes, maxDepth, repair = false) {
|
|
|
30819
30833
|
yield;
|
|
30820
30834
|
step = work.next();
|
|
30821
30835
|
} else {
|
|
30822
|
-
if (step.value !== "token" && step.value.kind
|
|
30836
|
+
if (step.value !== "token" && step.value.kind !== "dict") throw new TypeError("Stored values require asynchronous parsing");
|
|
30823
30837
|
step = work.next(step.value === "token" ? lexer.nextToken() : parseDictionaryStream(step.value, lexer, bytes));
|
|
30824
30838
|
}
|
|
30825
30839
|
}
|
|
@@ -31514,7 +31528,7 @@ function* sampledVertices(size, domain, encode3, inputs, sampleCount) {
|
|
|
31514
31528
|
function* resolveNode(node, arrayKey) {
|
|
31515
31529
|
if (!node) return void 0;
|
|
31516
31530
|
const result = yield { kind: "resolve", node, ...arrayKey ? { arrayKey } : {} };
|
|
31517
|
-
if (typeof result === "number" || typeof result === "boolean" || result?.kind === "annotation-
|
|
31531
|
+
if (typeof result === "number" || typeof result === "boolean" || result?.kind === "annotation-frame") throw new TypeError("Expected a PDF annotation object");
|
|
31518
31532
|
return result;
|
|
31519
31533
|
}
|
|
31520
31534
|
function* resolveDict(node) {
|
|
@@ -31525,15 +31539,7 @@ function* resolveArray(node, arrayKey) {
|
|
|
31525
31539
|
const result = yield* resolveNode(node, arrayKey);
|
|
31526
31540
|
return result?.kind === "array" ? result : void 0;
|
|
31527
31541
|
}
|
|
31528
|
-
function*
|
|
31529
|
-
const cursor = new PdfArrayCursor(array);
|
|
31530
|
-
for (let step = yield* cursor.next(); !step.done; step = yield* cursor.next()) {
|
|
31531
|
-
const found = yield* visit(step.value);
|
|
31532
|
-
if (found !== void 0) return found;
|
|
31533
|
-
}
|
|
31534
|
-
return void 0;
|
|
31535
|
-
}
|
|
31536
|
-
function* extractPageAnnotationSteps(pageDict, root, maxDepth = Infinity) {
|
|
31542
|
+
function* extractPageAnnotationSteps(pageDict, root) {
|
|
31537
31543
|
const annotsArr = yield* resolveArray(dictGet(pageDict, "Annots"), "Annots");
|
|
31538
31544
|
if (!annotsArr) return;
|
|
31539
31545
|
function* resolveDestToPageNum(destNode, depth = 0) {
|
|
@@ -31565,35 +31571,8 @@ function* extractPageAnnotationSteps(pageDict, root, maxDepth = Infinity) {
|
|
|
31565
31571
|
}
|
|
31566
31572
|
const namesDict = yield* resolveDict(dictGet(catalog, "Names"));
|
|
31567
31573
|
const destsTree = namesDict ? dictGet(namesDict, "Dests") : void 0;
|
|
31568
|
-
const
|
|
31569
|
-
|
|
31570
|
-
if (!node) return void 0;
|
|
31571
|
-
if (depth2 > maxDepth) throw new PdfError("E_LIMIT", "PDF annotation name-tree depth limit exceeded");
|
|
31572
|
-
const identity = node.kind === "ref" ? `${node.objectNumber}:${node.generationNumber}` : node;
|
|
31573
|
-
if (active.has(identity)) return void 0;
|
|
31574
|
-
active.add(identity);
|
|
31575
|
-
try {
|
|
31576
|
-
const treeDict = yield* resolveDict(node);
|
|
31577
|
-
if (!treeDict) return void 0;
|
|
31578
|
-
const namesArr = yield* resolveArray(dictGet(treeDict, "Names"));
|
|
31579
|
-
if (namesArr) {
|
|
31580
|
-
for (let i = 0; i + 1 < namesArr.items.length; i += 2) {
|
|
31581
|
-
const kNode = yield* resolveNode(namesArr.items[i]);
|
|
31582
|
-
const kStr = kNode?.kind === "string" ? decodePdfString(kNode) : kNode?.kind === "name" ? kNode.decoded : "";
|
|
31583
|
-
if (kStr === destName) return namesArr.items[i + 1];
|
|
31584
|
-
}
|
|
31585
|
-
}
|
|
31586
|
-
const kidsArr = yield* resolveArray(dictGet(treeDict, "Kids"), "Kids");
|
|
31587
|
-
if (kidsArr) {
|
|
31588
|
-
const found = yield* visitChildren(kidsArr, (kid) => searchNameTree(kid, depth2 + 1));
|
|
31589
|
-
if (found) return found;
|
|
31590
|
-
}
|
|
31591
|
-
return void 0;
|
|
31592
|
-
} finally {
|
|
31593
|
-
active.delete(identity);
|
|
31594
|
-
}
|
|
31595
|
-
}
|
|
31596
|
-
const treeFound = yield* searchNameTree(destsTree);
|
|
31574
|
+
const treeFound = yield { kind: "named-destination", node: destsTree, name: destName };
|
|
31575
|
+
if (typeof treeFound === "number" || typeof treeFound === "boolean" || treeFound?.kind === "annotation-frame") throw new TypeError("Expected a named destination object");
|
|
31597
31576
|
if (treeFound) return yield* resolveDestToPageNum(treeFound, depth + 1);
|
|
31598
31577
|
}
|
|
31599
31578
|
}
|
|
@@ -31646,9 +31625,9 @@ function* annotationPageNumberSteps(root, reference, maxDepth = Infinity) {
|
|
|
31646
31625
|
while (true) {
|
|
31647
31626
|
if (!node) {
|
|
31648
31627
|
if (!cursor) {
|
|
31649
|
-
const frame = yield { kind: "pop-
|
|
31628
|
+
const frame = yield { kind: "pop-traversal-frame" };
|
|
31650
31629
|
if (frame === void 0) return void 0;
|
|
31651
|
-
if (typeof frame !== "object" || frame.kind !== "annotation-
|
|
31630
|
+
if (typeof frame !== "object" || frame.kind !== "annotation-frame") throw new TypeError("Expected an annotation page frame");
|
|
31652
31631
|
cursor = new PdfArrayCursor(frame.cursor.array, frame.cursor);
|
|
31653
31632
|
cursorDepth = frame.depth;
|
|
31654
31633
|
}
|
|
@@ -31670,7 +31649,7 @@ function* annotationPageNumberSteps(root, reference, maxDepth = Infinity) {
|
|
|
31670
31649
|
const type = yield* resolveNode(dictGet(dict, "Type"));
|
|
31671
31650
|
const kids = yield* resolveArray(dictGet(dict, "Kids"), "Kids");
|
|
31672
31651
|
if (kids && (type?.kind !== "name" || type.decoded !== "Page")) {
|
|
31673
|
-
if (cursor) yield { kind: "push-
|
|
31652
|
+
if (cursor) yield { kind: "push-traversal-frame", frame: { kind: "annotation-frame", cursor: cursor.snapshot(), depth: cursorDepth } };
|
|
31674
31653
|
cursor = new PdfArrayCursor(kids);
|
|
31675
31654
|
cursorDepth = depth + 1;
|
|
31676
31655
|
} else {
|
|
@@ -31679,6 +31658,54 @@ function* annotationPageNumberSteps(root, reference, maxDepth = Infinity) {
|
|
|
31679
31658
|
}
|
|
31680
31659
|
}
|
|
31681
31660
|
}
|
|
31661
|
+
function* annotationNameDestinationSteps(first, name, maxDepth = Infinity) {
|
|
31662
|
+
let node = first, depth = 0, cursor, cursorDepth = 0, identity;
|
|
31663
|
+
while (true) {
|
|
31664
|
+
if (!node) {
|
|
31665
|
+
if (!cursor) {
|
|
31666
|
+
const frame = yield { kind: "pop-traversal-frame" };
|
|
31667
|
+
if (frame === void 0) return void 0;
|
|
31668
|
+
if (typeof frame !== "object" || frame.kind !== "annotation-frame" || frame.identity === void 0) throw new TypeError("Expected an annotation name frame");
|
|
31669
|
+
cursor = new PdfArrayCursor(frame.cursor.array, frame.cursor);
|
|
31670
|
+
cursorDepth = frame.depth;
|
|
31671
|
+
identity = frame.identity;
|
|
31672
|
+
}
|
|
31673
|
+
const step = yield* cursor.next();
|
|
31674
|
+
if (step.done) {
|
|
31675
|
+
yield { kind: "leave-name-node", identity };
|
|
31676
|
+
cursor = void 0;
|
|
31677
|
+
continue;
|
|
31678
|
+
}
|
|
31679
|
+
node = step.value;
|
|
31680
|
+
depth = cursorDepth;
|
|
31681
|
+
if (!node) continue;
|
|
31682
|
+
}
|
|
31683
|
+
const current = node;
|
|
31684
|
+
node = void 0;
|
|
31685
|
+
if (depth > maxDepth) throw new PdfError("E_LIMIT", "PDF annotation name-tree depth limit exceeded");
|
|
31686
|
+
const entered = yield { kind: "enter-name-node", node: current };
|
|
31687
|
+
if (entered === void 0) continue;
|
|
31688
|
+
if (typeof entered !== "number") throw new TypeError("Expected an annotation node identity");
|
|
31689
|
+
const dict = yield* resolveDict(current);
|
|
31690
|
+
if (dict) {
|
|
31691
|
+
const names = yield* resolveArray(dictGet(dict, "Names"));
|
|
31692
|
+
if (names) for (let i = 0; i + 1 < names.items.length; i += 2) {
|
|
31693
|
+
const key = yield* resolveNode(names.items[i]);
|
|
31694
|
+
const decoded = key?.kind === "string" ? decodePdfString(key) : key?.kind === "name" ? key.decoded : "";
|
|
31695
|
+
if (decoded === name) return names.items[i + 1];
|
|
31696
|
+
}
|
|
31697
|
+
const kids = yield* resolveArray(dictGet(dict, "Kids"), "Kids");
|
|
31698
|
+
if (kids) {
|
|
31699
|
+
if (cursor) yield { kind: "push-traversal-frame", frame: { kind: "annotation-frame", cursor: cursor.snapshot(), depth: cursorDepth, identity } };
|
|
31700
|
+
cursor = new PdfArrayCursor(kids);
|
|
31701
|
+
cursorDepth = depth + 1;
|
|
31702
|
+
identity = entered;
|
|
31703
|
+
continue;
|
|
31704
|
+
}
|
|
31705
|
+
}
|
|
31706
|
+
yield { kind: "leave-name-node", identity: entered };
|
|
31707
|
+
}
|
|
31708
|
+
}
|
|
31682
31709
|
|
|
31683
31710
|
// packages/pdf-ast/src/fonts/stored-widths.ts
|
|
31684
31711
|
import { IntegerTable } from "@poe-platform/safe-fs/storage";
|
|
@@ -43943,10 +43970,10 @@ function extractPageAnnotations(cosDoc, pageDict) {
|
|
|
43943
43970
|
while (!step2.done) {
|
|
43944
43971
|
const request = step2.value;
|
|
43945
43972
|
if (request.kind === "resolve") step2 = work2.next(cosDoc.resolve(request.node));
|
|
43946
|
-
else if (request.kind === "push-
|
|
43973
|
+
else if (request.kind === "push-traversal-frame") {
|
|
43947
43974
|
frames.push(request.frame);
|
|
43948
43975
|
step2 = work2.next();
|
|
43949
|
-
} else if (request.kind === "pop-
|
|
43976
|
+
} else if (request.kind === "pop-traversal-frame") step2 = work2.next(frames.pop());
|
|
43950
43977
|
else if (request.kind === "visit-page") {
|
|
43951
43978
|
const number = request.reference.objectNumber, added = !visited.has(number);
|
|
43952
43979
|
visited.add(number);
|
|
@@ -43955,6 +43982,36 @@ function extractPageAnnotations(cosDoc, pageDict) {
|
|
|
43955
43982
|
}
|
|
43956
43983
|
return step2.value;
|
|
43957
43984
|
}
|
|
43985
|
+
function namedDestination(node, name) {
|
|
43986
|
+
const identities = /* @__PURE__ */ new Map(), active = /* @__PURE__ */ new Set(), frames = [];
|
|
43987
|
+
const work2 = annotationNameDestinationSteps(node, name);
|
|
43988
|
+
let step2 = work2.next();
|
|
43989
|
+
while (!step2.done) {
|
|
43990
|
+
const request = step2.value;
|
|
43991
|
+
if (request.kind === "resolve") step2 = work2.next(cosDoc.resolve(request.node));
|
|
43992
|
+
else if (request.kind === "push-traversal-frame") {
|
|
43993
|
+
frames.push(request.frame);
|
|
43994
|
+
step2 = work2.next();
|
|
43995
|
+
} else if (request.kind === "pop-traversal-frame") step2 = work2.next(frames.pop());
|
|
43996
|
+
else if (request.kind === "enter-name-node") {
|
|
43997
|
+
const node2 = request.node, key = node2.kind === "ref" ? `${node2.objectNumber}:${node2.generationNumber}` : node2;
|
|
43998
|
+
let id = identities.get(key);
|
|
43999
|
+
if (id === void 0) {
|
|
44000
|
+
id = identities.size;
|
|
44001
|
+
identities.set(key, id);
|
|
44002
|
+
}
|
|
44003
|
+
if (active.has(id)) step2 = work2.next();
|
|
44004
|
+
else {
|
|
44005
|
+
active.add(id);
|
|
44006
|
+
step2 = work2.next(id);
|
|
44007
|
+
}
|
|
44008
|
+
} else if (request.kind === "leave-name-node") {
|
|
44009
|
+
active.delete(request.identity);
|
|
44010
|
+
step2 = work2.next();
|
|
44011
|
+
} else throw new TypeError("Unexpected annotation name lookup request");
|
|
44012
|
+
}
|
|
44013
|
+
return step2.value;
|
|
44014
|
+
}
|
|
43958
44015
|
const output = [];
|
|
43959
44016
|
const work = extractPageAnnotationSteps(pageDict, cosDoc.rootRef);
|
|
43960
44017
|
let step = work.next();
|
|
@@ -43965,6 +44022,7 @@ function extractPageAnnotations(cosDoc, pageDict) {
|
|
|
43965
44022
|
step = work.next();
|
|
43966
44023
|
} else if (request.kind === "resolve") step = work.next(cosDoc.resolve(request.node));
|
|
43967
44024
|
else if (request.kind === "page-number") step = work.next(pageNumber(request.reference));
|
|
44025
|
+
else if (request.kind === "named-destination") step = work.next(namedDestination(request.node, request.name));
|
|
43968
44026
|
else throw new TypeError("Unexpected annotation request");
|
|
43969
44027
|
}
|
|
43970
44028
|
return output;
|
|
@@ -48156,6 +48214,7 @@ async function resolveStreamLength(entry, options) {
|
|
|
48156
48214
|
async function readValue(lexer, depth, nodes, options) {
|
|
48157
48215
|
const { signal } = options;
|
|
48158
48216
|
const work = parseValueSteps(lexer, depth, options.recovery === "repair", nodes, options);
|
|
48217
|
+
const containers = options.containerStorage ? new StoredMetadataStack(options.containerStorage, signal) : void 0;
|
|
48159
48218
|
let value;
|
|
48160
48219
|
let turns = 0;
|
|
48161
48220
|
try {
|
|
@@ -48172,6 +48231,16 @@ async function readValue(lexer, depth, nodes, options) {
|
|
|
48172
48231
|
throw error;
|
|
48173
48232
|
}
|
|
48174
48233
|
step = work.next(position);
|
|
48234
|
+
} else if (request && request !== "token" && (request.kind === "container-push" || request.kind === "container-pop")) {
|
|
48235
|
+
let container;
|
|
48236
|
+
try {
|
|
48237
|
+
if (request.kind === "container-push") await containers.push(request.container);
|
|
48238
|
+
else container = await containers.pop();
|
|
48239
|
+
} catch (error) {
|
|
48240
|
+
options.onBackingError?.(error);
|
|
48241
|
+
throw error;
|
|
48242
|
+
}
|
|
48243
|
+
step = work.next(container);
|
|
48175
48244
|
} else step = request === void 0 ? work.next() : work.next(request === "token" ? await lexer.nextToken() : request);
|
|
48176
48245
|
if (++turns % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
48177
48246
|
}
|
|
@@ -57082,8 +57151,124 @@ function resolveDestinationPageIndex(doc, destOrActionNode) {
|
|
|
57082
57151
|
return void 0;
|
|
57083
57152
|
}
|
|
57084
57153
|
|
|
57085
|
-
// packages/pdf-ast/src/
|
|
57086
|
-
|
|
57154
|
+
// packages/pdf-ast/src/cos/name-index.ts
|
|
57155
|
+
var PdfNameIndex = class {
|
|
57156
|
+
constructor(storage, maximum10 = Infinity, signal) {
|
|
57157
|
+
this.storage = storage;
|
|
57158
|
+
this.maximum = maximum10;
|
|
57159
|
+
this.signal = signal;
|
|
57160
|
+
const limit10 = typeof maximum10 === "function" ? maximum10() : maximum10;
|
|
57161
|
+
if (limit10 !== Infinity && (!Number.isSafeInteger(limit10) || limit10 < 0)) throw new RangeError("Invalid name staging limit");
|
|
57162
|
+
}
|
|
57163
|
+
storage;
|
|
57164
|
+
maximum;
|
|
57165
|
+
signal;
|
|
57166
|
+
tail = /* @__PURE__ */ new Map();
|
|
57167
|
+
hot = /* @__PURE__ */ new Map();
|
|
57168
|
+
levels = [];
|
|
57169
|
+
nextNode = 2;
|
|
57170
|
+
nextName = 0;
|
|
57171
|
+
closed = false;
|
|
57172
|
+
get stagedBytes() {
|
|
57173
|
+
return this.levels.reduce((sum, index2) => sum + (index2?.size ?? 0) * 32, 0);
|
|
57174
|
+
}
|
|
57175
|
+
async get(edge) {
|
|
57176
|
+
if (this.tail.has(edge)) return this.tail.get(edge);
|
|
57177
|
+
if (this.hot.has(edge)) return this.hot.get(edge);
|
|
57178
|
+
for (const level of this.levels) {
|
|
57179
|
+
const entry = await level?.get(edge, this.signal);
|
|
57180
|
+
if (entry) {
|
|
57181
|
+
if (this.hot.size < 256) this.hot.set(edge, entry.offset);
|
|
57182
|
+
return entry.offset;
|
|
57183
|
+
}
|
|
57184
|
+
}
|
|
57185
|
+
return void 0;
|
|
57186
|
+
}
|
|
57187
|
+
async insert(edge, node) {
|
|
57188
|
+
this.tail.set(edge, node);
|
|
57189
|
+
if (this.hot.size < 256) this.hot.set(edge, node);
|
|
57190
|
+
if (this.tail.size < 64) return;
|
|
57191
|
+
let level = 0;
|
|
57192
|
+
while (this.levels[level]) level++;
|
|
57193
|
+
const inputs = this.levels.slice(0, level);
|
|
57194
|
+
const tail = this.tail;
|
|
57195
|
+
const signal = this.signal;
|
|
57196
|
+
async function* rows() {
|
|
57197
|
+
for (const [objectNumber, offset] of tail) yield { objectNumber, offset, type: "uncompressed" };
|
|
57198
|
+
for (const index2 of inputs) yield* index2.entries(signal);
|
|
57199
|
+
}
|
|
57200
|
+
const limit10 = typeof this.maximum === "function" ? this.maximum() : this.maximum;
|
|
57201
|
+
const remaining = Math.min(limit10, Number.MAX_SAFE_INTEGER) - this.stagedBytes;
|
|
57202
|
+
if (remaining < 0) throw new PdfError("E_LIMIT", "PDF name staging byte limit exceeded");
|
|
57203
|
+
const combined = await PdfObjectIndex.build(rows(), this.storage, {
|
|
57204
|
+
runEntries: 64,
|
|
57205
|
+
chunkBytes: 2048,
|
|
57206
|
+
cacheBytes: 2048,
|
|
57207
|
+
maxStagingBytes: remaining,
|
|
57208
|
+
...signal ? { signal } : {}
|
|
57209
|
+
});
|
|
57210
|
+
try {
|
|
57211
|
+
for (let i = 0; i < level; i++) {
|
|
57212
|
+
await this.levels[i].close();
|
|
57213
|
+
this.levels[i] = void 0;
|
|
57214
|
+
}
|
|
57215
|
+
this.levels[level] = combined;
|
|
57216
|
+
this.tail.clear();
|
|
57217
|
+
} catch (error) {
|
|
57218
|
+
try {
|
|
57219
|
+
await combined.close();
|
|
57220
|
+
} catch {
|
|
57221
|
+
}
|
|
57222
|
+
throw error;
|
|
57223
|
+
}
|
|
57224
|
+
}
|
|
57225
|
+
async intern(value) {
|
|
57226
|
+
if (this.closed) throw new PdfError("E_CAPABILITY", "PDF name index is closed");
|
|
57227
|
+
this.signal?.throwIfAborted();
|
|
57228
|
+
let node = 1, newPath = false;
|
|
57229
|
+
const units = typeof value === "string" ? (function* () {
|
|
57230
|
+
for (let i = 0; i < value.length; i++) yield value.charCodeAt(i);
|
|
57231
|
+
})() : value;
|
|
57232
|
+
let work = 0;
|
|
57233
|
+
for await (const code of units) {
|
|
57234
|
+
this.signal?.throwIfAborted();
|
|
57235
|
+
if (!Number.isInteger(code) || code < 0 || code > 65535) throw new RangeError("Invalid PDF name code unit");
|
|
57236
|
+
if (++work % 512 === 0) {
|
|
57237
|
+
await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
57238
|
+
this.signal?.throwIfAborted();
|
|
57239
|
+
}
|
|
57240
|
+
for (const unit of [code & 255, code >>> 8]) {
|
|
57241
|
+
const edge = node * 257 + unit + 1;
|
|
57242
|
+
let child = newPath ? void 0 : await this.get(edge);
|
|
57243
|
+
if (child === void 0) {
|
|
57244
|
+
if (this.nextNode > Math.floor(Number.MAX_SAFE_INTEGER / 257) - 1) throw new PdfError("E_LIMIT", "PDF name index address limit exceeded");
|
|
57245
|
+
child = this.nextNode++;
|
|
57246
|
+
await this.insert(edge, child);
|
|
57247
|
+
newPath = true;
|
|
57248
|
+
}
|
|
57249
|
+
node = child;
|
|
57250
|
+
}
|
|
57251
|
+
}
|
|
57252
|
+
const terminal = node * 257;
|
|
57253
|
+
const existing = newPath ? void 0 : await this.get(terminal);
|
|
57254
|
+
if (existing !== void 0) return { index: existing, added: false };
|
|
57255
|
+
const index2 = this.nextName++;
|
|
57256
|
+
await this.insert(terminal, index2);
|
|
57257
|
+
return { index: index2, added: true };
|
|
57258
|
+
}
|
|
57259
|
+
async close() {
|
|
57260
|
+
if (this.closed) return;
|
|
57261
|
+
this.closed = true;
|
|
57262
|
+
const results = await Promise.allSettled(this.levels.map((index2) => index2?.close()));
|
|
57263
|
+
this.tail.clear();
|
|
57264
|
+
this.hot.clear();
|
|
57265
|
+
this.levels.length = 0;
|
|
57266
|
+
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
57267
|
+
}
|
|
57268
|
+
};
|
|
57269
|
+
|
|
57270
|
+
// packages/pdf-ast/src/extract/retained-form-fields.ts
|
|
57271
|
+
import { IntegerTable as IntegerTable4, PagedStorage as PagedStorage6 } from "@poe-platform/safe-fs/storage";
|
|
57087
57272
|
|
|
57088
57273
|
// packages/pdf-ast/src/cos/mutable-object-store.ts
|
|
57089
57274
|
import { IntegerTable as IntegerTable3, PagedStorage as PagedStorage5 } from "@poe-platform/safe-fs/storage";
|
|
@@ -57613,6 +57798,290 @@ var PdfMutableObjectStore = class {
|
|
|
57613
57798
|
}
|
|
57614
57799
|
};
|
|
57615
57800
|
|
|
57801
|
+
// packages/pdf-ast/src/extract/retained-form-fields.ts
|
|
57802
|
+
async function inheritedRetainedFieldEntry(document2, storage, dict, key, options) {
|
|
57803
|
+
const seen = new PdfReferenceSet(storage, options.maxStagingBytes, options.signal);
|
|
57804
|
+
let current = dict, depth = 0, failed = false;
|
|
57805
|
+
try {
|
|
57806
|
+
while (current) {
|
|
57807
|
+
options.signal?.throwIfAborted();
|
|
57808
|
+
if (++depth > (options.maxDepth ?? document2.depthLimit)) throw new PdfError("E_LIMIT", "PDF form field depth limit exceeded");
|
|
57809
|
+
if (depth % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
57810
|
+
const value = dictGet(current, key);
|
|
57811
|
+
if (value !== void 0) return (await document2.lookup(value))?.value;
|
|
57812
|
+
const parent = dictGet(current, "Parent");
|
|
57813
|
+
if (parent?.kind === "ref" && !await seen.add(parent.objectNumber)) return;
|
|
57814
|
+
const found = await document2.lookup(parent);
|
|
57815
|
+
current = !found?.stream && found?.value.kind === "dict" ? found.value : void 0;
|
|
57816
|
+
}
|
|
57817
|
+
} catch (error) {
|
|
57818
|
+
failed = true;
|
|
57819
|
+
throw error;
|
|
57820
|
+
} finally {
|
|
57821
|
+
await seen.close().catch((error) => {
|
|
57822
|
+
if (!failed) throw error;
|
|
57823
|
+
});
|
|
57824
|
+
}
|
|
57825
|
+
}
|
|
57826
|
+
async function* walkRetainedFieldEntries(document2, storage, options = {}) {
|
|
57827
|
+
const signal = options.signal ?? new AbortController().signal, maxDepth = options.maxDepth ?? document2.depthLimit;
|
|
57828
|
+
signal.throwIfAborted();
|
|
57829
|
+
const frames = new PdfMutableObjectStore(storage, { signal, ...options.maxStagingBytes === void 0 ? {} : { maxStagingBytes: options.maxStagingBytes } });
|
|
57830
|
+
const backing = new PagedStorage6({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new IntegerTable4(backing, 64);
|
|
57831
|
+
let pending = 0, work = 0, failed = false;
|
|
57832
|
+
async function checkpoint(depth = 0) {
|
|
57833
|
+
signal.throwIfAborted();
|
|
57834
|
+
if (depth > maxDepth) throw new PdfError("E_LIMIT", "PDF form field depth limit exceeded");
|
|
57835
|
+
if (++work % 64 === 0) await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
57836
|
+
signal.throwIfAborted();
|
|
57837
|
+
}
|
|
57838
|
+
async function resolve2(node) {
|
|
57839
|
+
const found = await document2.lookup(node);
|
|
57840
|
+
return found?.stream ? void 0 : found?.value;
|
|
57841
|
+
}
|
|
57842
|
+
async function push(node, prefix, ft, depth, flags = 0, justification = 0, maxLength) {
|
|
57843
|
+
await frames.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray([node, cosString(prefix), cosString(ft), cosNumber(depth), cosNumber(flags), cosNumber(justification), maxLength === void 0 ? cosNull() : cosNumber(maxLength)]) });
|
|
57844
|
+
}
|
|
57845
|
+
try {
|
|
57846
|
+
const root = await resolve2(document2.crossReference.rootRef), form = root?.kind === "dict" ? await resolve2(dictGet(root, "AcroForm")) : void 0;
|
|
57847
|
+
const fields2 = form?.kind === "dict" ? await resolve2(dictGet(form, "Fields")) : void 0;
|
|
57848
|
+
if (fields2?.kind !== "array") return;
|
|
57849
|
+
for (let i = fields2.items.length - 1; i >= 0; i--) {
|
|
57850
|
+
await checkpoint();
|
|
57851
|
+
await push(fields2.items[i], "", "", 0);
|
|
57852
|
+
}
|
|
57853
|
+
while (pending) {
|
|
57854
|
+
const frame = (await frames.get(pending--)).value;
|
|
57855
|
+
if (frame.kind !== "array") throw new PdfError("E_PARSE", "Invalid form traversal frame");
|
|
57856
|
+
const [node, prefixNode, ftNode, depthNode, flagsNode, qNode, maxNode] = frame.items;
|
|
57857
|
+
if (frame.items.length === 1 && node?.kind === "number") {
|
|
57858
|
+
await active.set(BigInt(node.value), 0n);
|
|
57859
|
+
continue;
|
|
57860
|
+
}
|
|
57861
|
+
if (!node || prefixNode?.kind !== "string" || ftNode?.kind !== "string" || depthNode?.kind !== "number") throw new PdfError("E_PARSE", "Invalid form traversal frame");
|
|
57862
|
+
await checkpoint(depthNode.value);
|
|
57863
|
+
if (node.kind === "ref") {
|
|
57864
|
+
if (await active.get(BigInt(node.objectNumber)) === 1n) continue;
|
|
57865
|
+
await active.set(BigInt(node.objectNumber), 1n);
|
|
57866
|
+
await frames.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray([cosNumber(node.objectNumber)]) });
|
|
57867
|
+
}
|
|
57868
|
+
const dict = await resolve2(node);
|
|
57869
|
+
if (dict?.kind !== "dict") continue;
|
|
57870
|
+
const named = await resolve2(dictGet(dict, "T")), ownFt = await resolve2(dictGet(dict, "FT"));
|
|
57871
|
+
const partial = named?.kind === "string" ? decodePdfString(named) : named?.kind === "name" ? named.decoded : "", prefix = decodePdfString(prefixNode);
|
|
57872
|
+
const name = prefix && partial ? `${prefix}.${partial}` : partial || prefix, ft = ownFt?.kind === "name" ? ownFt.decoded : decodePdfString(ftNode);
|
|
57873
|
+
const ownFlags = await resolve2(dictGet(dict, "Ff")), ownQ = await resolve2(dictGet(dict, "Q")), ownMax = await resolve2(dictGet(dict, "MaxLen"));
|
|
57874
|
+
const flags = ownFlags?.kind === "number" ? ownFlags.value : flagsNode?.kind === "number" ? flagsNode.value : 0;
|
|
57875
|
+
const justification = ownQ?.kind === "number" ? ownQ.value : qNode?.kind === "number" ? qNode.value : 0;
|
|
57876
|
+
const maxLength = ownMax?.kind === "number" ? ownMax.value : maxNode?.kind === "number" ? maxNode.value : void 0;
|
|
57877
|
+
const kids = await resolve2(dictGet(dict, "Kids"));
|
|
57878
|
+
if (kids?.kind === "array" && kids.items.length) {
|
|
57879
|
+
let namedKids = false;
|
|
57880
|
+
for (const kid of kids.items) {
|
|
57881
|
+
await checkpoint();
|
|
57882
|
+
const value = await resolve2(kid);
|
|
57883
|
+
if (value?.kind === "dict" && dictGet(value, "T")) {
|
|
57884
|
+
namedKids = true;
|
|
57885
|
+
break;
|
|
57886
|
+
}
|
|
57887
|
+
}
|
|
57888
|
+
if (namedKids || !ft || !name) {
|
|
57889
|
+
for (let i = kids.items.length - 1; i >= 0; i--) {
|
|
57890
|
+
await checkpoint();
|
|
57891
|
+
await push(kids.items[i], name, ft, depthNode.value + 1, flags, justification, maxLength);
|
|
57892
|
+
}
|
|
57893
|
+
continue;
|
|
57894
|
+
}
|
|
57895
|
+
}
|
|
57896
|
+
if (!name) continue;
|
|
57897
|
+
yield { name, dict, ft, flags, justification, maxLength };
|
|
57898
|
+
}
|
|
57899
|
+
} catch (error) {
|
|
57900
|
+
failed = true;
|
|
57901
|
+
throw error;
|
|
57902
|
+
} finally {
|
|
57903
|
+
const results = await Promise.allSettled([frames.close(), backing.close()]);
|
|
57904
|
+
if (!failed) {
|
|
57905
|
+
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
57906
|
+
}
|
|
57907
|
+
}
|
|
57908
|
+
}
|
|
57909
|
+
async function* walkRetainedFormFields(document2, storage, options = {}) {
|
|
57910
|
+
let work = 0;
|
|
57911
|
+
async function resolve2(node) {
|
|
57912
|
+
if (++work % 64 === 0) await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
57913
|
+
const found = await document2.lookup(node);
|
|
57914
|
+
return found?.stream ? void 0 : found?.value;
|
|
57915
|
+
}
|
|
57916
|
+
for await (const { name, dict, ft } of walkRetainedFieldEntries(document2, storage, options)) {
|
|
57917
|
+
const value = await inheritedRetainedFieldEntry(document2, storage, dict, "V", options);
|
|
57918
|
+
if (ft === "Btn") {
|
|
57919
|
+
yield { name, type: "checkbox", value: value?.kind === "name" ? value.decoded !== "Off" : value?.kind === "boolean" ? value.value : false };
|
|
57920
|
+
continue;
|
|
57921
|
+
}
|
|
57922
|
+
let text = value?.kind === "string" ? decodePdfString(value) : value?.kind === "name" ? value.decoded : "";
|
|
57923
|
+
if (value?.kind === "array") {
|
|
57924
|
+
let first = true;
|
|
57925
|
+
for (const item of value.items) {
|
|
57926
|
+
options.signal?.throwIfAborted();
|
|
57927
|
+
const found = await resolve2(item);
|
|
57928
|
+
if (found?.kind === "string" || found?.kind === "name") {
|
|
57929
|
+
text += `${first ? "" : ", "}${found.kind === "string" ? decodePdfString(found) : found.decoded}`;
|
|
57930
|
+
first = false;
|
|
57931
|
+
}
|
|
57932
|
+
}
|
|
57933
|
+
}
|
|
57934
|
+
yield { name, type: ft === "Tx" ? "text" : ft === "Ch" ? "choice" : "unknown", value: text };
|
|
57935
|
+
}
|
|
57936
|
+
}
|
|
57937
|
+
|
|
57938
|
+
// packages/pdf-ast/src/extract/retained-form-field-details.ts
|
|
57939
|
+
async function* walkRetainedFormFieldDetails(document2, storage, options = {}) {
|
|
57940
|
+
let work = 0;
|
|
57941
|
+
async function checkpoint() {
|
|
57942
|
+
options.signal?.throwIfAborted();
|
|
57943
|
+
if (++work % 64 === 0) await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
57944
|
+
options.signal?.throwIfAborted();
|
|
57945
|
+
}
|
|
57946
|
+
async function resolve2(node) {
|
|
57947
|
+
await checkpoint();
|
|
57948
|
+
const found = await document2.lookup(node);
|
|
57949
|
+
return found?.stream ? void 0 : found?.value;
|
|
57950
|
+
}
|
|
57951
|
+
const text = (node) => node?.kind === "string" ? decodePdfString(node) : node?.kind === "name" ? node.decoded : void 0;
|
|
57952
|
+
for await (const entry of walkRetainedFieldEntries(document2, storage, options)) {
|
|
57953
|
+
let owned2 = function(producer) {
|
|
57954
|
+
async function* visit() {
|
|
57955
|
+
assertActive();
|
|
57956
|
+
readers.add(reader);
|
|
57957
|
+
try {
|
|
57958
|
+
for await (const value2 of producer()) {
|
|
57959
|
+
assertActive();
|
|
57960
|
+
yield value2;
|
|
57961
|
+
}
|
|
57962
|
+
} finally {
|
|
57963
|
+
readers.delete(reader);
|
|
57964
|
+
}
|
|
57965
|
+
}
|
|
57966
|
+
const reader = visit();
|
|
57967
|
+
return reader;
|
|
57968
|
+
};
|
|
57969
|
+
var owned = owned2;
|
|
57970
|
+
const { dict, ft } = entry;
|
|
57971
|
+
let active = true;
|
|
57972
|
+
const readers = /* @__PURE__ */ new Set();
|
|
57973
|
+
const assertActive = () => {
|
|
57974
|
+
options.signal?.throwIfAborted();
|
|
57975
|
+
if (!active) throw new PdfError("E_CAPABILITY", "Retained form field is no longer active");
|
|
57976
|
+
};
|
|
57977
|
+
async function* stateOptions() {
|
|
57978
|
+
const seen = new PdfNameIndex(storage, options.maxStagingBytes, options.signal);
|
|
57979
|
+
let count = 0, failed2 = false;
|
|
57980
|
+
async function* unique(value2) {
|
|
57981
|
+
assertActive();
|
|
57982
|
+
if (value2 && (await seen.intern(value2)).added) {
|
|
57983
|
+
count++;
|
|
57984
|
+
yield value2;
|
|
57985
|
+
}
|
|
57986
|
+
}
|
|
57987
|
+
async function* appearances(field2) {
|
|
57988
|
+
const appearance = await resolve2(dictGet(field2, "AP"));
|
|
57989
|
+
const normal = appearance?.kind === "dict" ? await resolve2(dictGet(appearance, "N")) : void 0;
|
|
57990
|
+
if (normal?.kind === "dict") for (const pair of normal.entries) {
|
|
57991
|
+
await checkpoint();
|
|
57992
|
+
yield* unique(pair.key.decoded);
|
|
57993
|
+
}
|
|
57994
|
+
}
|
|
57995
|
+
try {
|
|
57996
|
+
if (ft === "Btn") {
|
|
57997
|
+
yield* unique("Off");
|
|
57998
|
+
yield* appearances(dict);
|
|
57999
|
+
const kids = await resolve2(dictGet(dict, "Kids"));
|
|
58000
|
+
if (kids?.kind === "array") for (const kid of kids.items) {
|
|
58001
|
+
const field2 = await resolve2(kid);
|
|
58002
|
+
if (field2?.kind === "dict") yield* appearances(field2);
|
|
58003
|
+
}
|
|
58004
|
+
if (count === 1) yield* unique("Yes");
|
|
58005
|
+
}
|
|
58006
|
+
const choices = await inheritedRetainedFieldEntry(document2, storage, dict, "Opt", options);
|
|
58007
|
+
if (choices?.kind === "array") for (const item of choices.items) {
|
|
58008
|
+
let value2 = await resolve2(item);
|
|
58009
|
+
if (value2?.kind === "array" && value2.items.length) value2 = await resolve2(value2.items[value2.items.length - 1]);
|
|
58010
|
+
yield* unique(text(value2));
|
|
58011
|
+
}
|
|
58012
|
+
} catch (error) {
|
|
58013
|
+
failed2 = true;
|
|
58014
|
+
throw error;
|
|
58015
|
+
} finally {
|
|
58016
|
+
await seen.close().catch((error) => {
|
|
58017
|
+
if (!failed2) throw error;
|
|
58018
|
+
});
|
|
58019
|
+
}
|
|
58020
|
+
}
|
|
58021
|
+
const value = await inheritedRetainedFieldEntry(document2, storage, dict, "V", options);
|
|
58022
|
+
const defaultValue = text(await inheritedRetainedFieldEntry(document2, storage, dict, "DV", options));
|
|
58023
|
+
const altName = text(await inheritedRetainedFieldEntry(document2, storage, dict, "TU", options));
|
|
58024
|
+
const checked = ft === "Btn" ? value?.kind === "name" ? value.decoded !== "Off" : value?.kind === "boolean" ? value.value : false : void 0;
|
|
58025
|
+
let stateValue;
|
|
58026
|
+
if (ft === "Btn") {
|
|
58027
|
+
stateValue = value?.kind === "name" ? value.decoded : checked ? "Yes" : "Off";
|
|
58028
|
+
if (checked && value?.kind !== "name") {
|
|
58029
|
+
for await (const option of stateOptions()) if (option !== "Off") {
|
|
58030
|
+
stateValue = option;
|
|
58031
|
+
break;
|
|
58032
|
+
}
|
|
58033
|
+
}
|
|
58034
|
+
}
|
|
58035
|
+
async function* values() {
|
|
58036
|
+
if (stateValue !== void 0) {
|
|
58037
|
+
yield stateValue;
|
|
58038
|
+
return;
|
|
58039
|
+
}
|
|
58040
|
+
if (value?.kind !== "array") {
|
|
58041
|
+
yield text(value) ?? "";
|
|
58042
|
+
return;
|
|
58043
|
+
}
|
|
58044
|
+
let any = false;
|
|
58045
|
+
for (const item of value.items) {
|
|
58046
|
+
const selected = text(await resolve2(item));
|
|
58047
|
+
if (selected !== void 0) {
|
|
58048
|
+
any = true;
|
|
58049
|
+
yield selected;
|
|
58050
|
+
}
|
|
58051
|
+
}
|
|
58052
|
+
if (!any) yield "";
|
|
58053
|
+
}
|
|
58054
|
+
let failed = false;
|
|
58055
|
+
try {
|
|
58056
|
+
yield {
|
|
58057
|
+
name: entry.name,
|
|
58058
|
+
type: ft === "Btn" ? "checkbox" : ft === "Ch" ? "choice" : ft === "Tx" ? "text" : "unknown",
|
|
58059
|
+
flags: entry.flags,
|
|
58060
|
+
justification: entry.justification === 1 ? "Centered" : entry.justification === 2 ? "Right" : "Left",
|
|
58061
|
+
maxLength: entry.maxLength,
|
|
58062
|
+
altName,
|
|
58063
|
+
defaultValue,
|
|
58064
|
+
checked,
|
|
58065
|
+
stateValue,
|
|
58066
|
+
values: () => owned2(values),
|
|
58067
|
+
options: () => owned2(stateOptions)
|
|
58068
|
+
};
|
|
58069
|
+
} catch (error) {
|
|
58070
|
+
failed = true;
|
|
58071
|
+
throw error;
|
|
58072
|
+
} finally {
|
|
58073
|
+
active = false;
|
|
58074
|
+
const results = await Promise.allSettled([...readers].map((reader) => reader.return()));
|
|
58075
|
+
if (!failed) {
|
|
58076
|
+
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
58077
|
+
}
|
|
58078
|
+
}
|
|
58079
|
+
}
|
|
58080
|
+
}
|
|
58081
|
+
|
|
58082
|
+
// packages/pdf-ast/src/retained-document.ts
|
|
58083
|
+
import { IntegerTable as IntegerTable5, PagedStorage as PagedStorage8 } from "@poe-platform/safe-fs/storage";
|
|
58084
|
+
|
|
57616
58085
|
// packages/pdf-ast/src/edit/retained-merge-outlines.ts
|
|
57617
58086
|
var PdfMergeOutlines = class {
|
|
57618
58087
|
constructor(storage, signal, maxDepth = Infinity) {
|
|
@@ -57820,127 +58289,6 @@ async function* walkRetainedPageLabels(document2, storage, options = {}) {
|
|
|
57820
58289
|
}
|
|
57821
58290
|
}
|
|
57822
58291
|
|
|
57823
|
-
// packages/pdf-ast/src/extract/retained-form-fields.ts
|
|
57824
|
-
import { IntegerTable as IntegerTable4, PagedStorage as PagedStorage6 } from "@poe-platform/safe-fs/storage";
|
|
57825
|
-
async function* walkRetainedFormFields(document2, storage, options = {}) {
|
|
57826
|
-
const signal = options.signal ?? new AbortController().signal, maxDepth = options.maxDepth ?? document2.depthLimit;
|
|
57827
|
-
signal.throwIfAborted();
|
|
57828
|
-
const frames = new PdfMutableObjectStore(storage, { signal, ...options.maxStagingBytes === void 0 ? {} : { maxStagingBytes: options.maxStagingBytes } });
|
|
57829
|
-
const backing = new PagedStorage6({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new IntegerTable4(backing, 64);
|
|
57830
|
-
let pending = 0, work = 0, failed = false;
|
|
57831
|
-
async function checkpoint(depth = 0) {
|
|
57832
|
-
signal.throwIfAborted();
|
|
57833
|
-
if (depth > maxDepth) throw new PdfError("E_LIMIT", "PDF form field depth limit exceeded");
|
|
57834
|
-
if (++work % 64 === 0) await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
57835
|
-
signal.throwIfAborted();
|
|
57836
|
-
}
|
|
57837
|
-
async function resolve2(node) {
|
|
57838
|
-
const found = await document2.lookup(node);
|
|
57839
|
-
return found?.stream ? void 0 : found?.value;
|
|
57840
|
-
}
|
|
57841
|
-
async function push(node, prefix, ft, depth) {
|
|
57842
|
-
await frames.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray([node, cosString(prefix), cosString(ft), cosNumber(depth)]) });
|
|
57843
|
-
}
|
|
57844
|
-
async function inheritedValue(dict) {
|
|
57845
|
-
const seen = new PdfReferenceSet(storage, options.maxStagingBytes, signal);
|
|
57846
|
-
let current = dict, depth = 0, failed2 = false;
|
|
57847
|
-
try {
|
|
57848
|
-
while (current) {
|
|
57849
|
-
await checkpoint(++depth);
|
|
57850
|
-
const value = dictGet(current, "V");
|
|
57851
|
-
if (value !== void 0) return await resolve2(value);
|
|
57852
|
-
const parent = dictGet(current, "Parent");
|
|
57853
|
-
if (parent?.kind === "ref" && !await seen.add(parent.objectNumber)) return;
|
|
57854
|
-
const found = await resolve2(parent);
|
|
57855
|
-
current = found?.kind === "dict" ? found : void 0;
|
|
57856
|
-
}
|
|
57857
|
-
} catch (error) {
|
|
57858
|
-
failed2 = true;
|
|
57859
|
-
throw error;
|
|
57860
|
-
} finally {
|
|
57861
|
-
await seen.close().catch((error) => {
|
|
57862
|
-
if (!failed2) throw error;
|
|
57863
|
-
});
|
|
57864
|
-
}
|
|
57865
|
-
}
|
|
57866
|
-
try {
|
|
57867
|
-
const root = await resolve2(document2.crossReference.rootRef), form = root?.kind === "dict" ? await resolve2(dictGet(root, "AcroForm")) : void 0;
|
|
57868
|
-
const fields2 = form?.kind === "dict" ? await resolve2(dictGet(form, "Fields")) : void 0;
|
|
57869
|
-
if (fields2?.kind !== "array") return;
|
|
57870
|
-
for (let i = fields2.items.length - 1; i >= 0; i--) {
|
|
57871
|
-
await checkpoint();
|
|
57872
|
-
await push(fields2.items[i], "", "", 0);
|
|
57873
|
-
}
|
|
57874
|
-
while (pending) {
|
|
57875
|
-
const frame = (await frames.get(pending--)).value;
|
|
57876
|
-
if (frame.kind !== "array") throw new PdfError("E_PARSE", "Invalid form traversal frame");
|
|
57877
|
-
const [node, prefixNode, ftNode, depthNode] = frame.items;
|
|
57878
|
-
if (frame.items.length === 1 && node?.kind === "number") {
|
|
57879
|
-
await active.set(BigInt(node.value), 0n);
|
|
57880
|
-
continue;
|
|
57881
|
-
}
|
|
57882
|
-
if (!node || prefixNode?.kind !== "string" || ftNode?.kind !== "string" || depthNode?.kind !== "number") throw new PdfError("E_PARSE", "Invalid form traversal frame");
|
|
57883
|
-
await checkpoint(depthNode.value);
|
|
57884
|
-
if (node.kind === "ref") {
|
|
57885
|
-
if (await active.get(BigInt(node.objectNumber)) === 1n) continue;
|
|
57886
|
-
await active.set(BigInt(node.objectNumber), 1n);
|
|
57887
|
-
await frames.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray([cosNumber(node.objectNumber)]) });
|
|
57888
|
-
}
|
|
57889
|
-
const dict = await resolve2(node);
|
|
57890
|
-
if (dict?.kind !== "dict") continue;
|
|
57891
|
-
const named = await resolve2(dictGet(dict, "T")), ownFt = await resolve2(dictGet(dict, "FT"));
|
|
57892
|
-
const partial = named?.kind === "string" ? decodePdfString(named) : named?.kind === "name" ? named.decoded : "", prefix = decodePdfString(prefixNode);
|
|
57893
|
-
const name = prefix && partial ? `${prefix}.${partial}` : partial || prefix, ft = ownFt?.kind === "name" ? ownFt.decoded : decodePdfString(ftNode);
|
|
57894
|
-
const kids = await resolve2(dictGet(dict, "Kids"));
|
|
57895
|
-
if (kids?.kind === "array" && kids.items.length) {
|
|
57896
|
-
let namedKids = false;
|
|
57897
|
-
for (const kid of kids.items) {
|
|
57898
|
-
await checkpoint();
|
|
57899
|
-
const value2 = await resolve2(kid);
|
|
57900
|
-
if (value2?.kind === "dict" && dictGet(value2, "T")) {
|
|
57901
|
-
namedKids = true;
|
|
57902
|
-
break;
|
|
57903
|
-
}
|
|
57904
|
-
}
|
|
57905
|
-
if (namedKids || !ft || !name) {
|
|
57906
|
-
for (let i = kids.items.length - 1; i >= 0; i--) {
|
|
57907
|
-
await checkpoint();
|
|
57908
|
-
await push(kids.items[i], name, ft, depthNode.value + 1);
|
|
57909
|
-
}
|
|
57910
|
-
continue;
|
|
57911
|
-
}
|
|
57912
|
-
}
|
|
57913
|
-
if (!name) continue;
|
|
57914
|
-
const value = await inheritedValue(dict);
|
|
57915
|
-
if (ft === "Btn") {
|
|
57916
|
-
yield { name, type: "checkbox", value: value?.kind === "name" ? value.decoded !== "Off" : value?.kind === "boolean" ? value.value : false };
|
|
57917
|
-
continue;
|
|
57918
|
-
}
|
|
57919
|
-
let text = value?.kind === "string" ? decodePdfString(value) : value?.kind === "name" ? value.decoded : "";
|
|
57920
|
-
if (value?.kind === "array") {
|
|
57921
|
-
let first = true;
|
|
57922
|
-
for (const item of value.items) {
|
|
57923
|
-
await checkpoint();
|
|
57924
|
-
const found = await resolve2(item);
|
|
57925
|
-
if (found?.kind === "string" || found?.kind === "name") {
|
|
57926
|
-
text += `${first ? "" : ", "}${found.kind === "string" ? decodePdfString(found) : found.decoded}`;
|
|
57927
|
-
first = false;
|
|
57928
|
-
}
|
|
57929
|
-
}
|
|
57930
|
-
}
|
|
57931
|
-
yield { name, type: ft === "Tx" ? "text" : ft === "Ch" ? "choice" : "unknown", value: text };
|
|
57932
|
-
}
|
|
57933
|
-
} catch (error) {
|
|
57934
|
-
failed = true;
|
|
57935
|
-
throw error;
|
|
57936
|
-
} finally {
|
|
57937
|
-
const results = await Promise.allSettled([frames.close(), backing.close()]);
|
|
57938
|
-
if (!failed) {
|
|
57939
|
-
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
57940
|
-
}
|
|
57941
|
-
}
|
|
57942
|
-
}
|
|
57943
|
-
|
|
57944
58292
|
// packages/pdf-ast/src/cos/stored-object-reader.ts
|
|
57945
58293
|
async function openStoredPdfObjectReader(store, storage, options) {
|
|
57946
58294
|
let maximum10 = 0, closed = false;
|
|
@@ -58712,124 +59060,6 @@ async function prepareRetainedPageContent(document2, page2, pageResources, stora
|
|
|
58712
59060
|
|
|
58713
59061
|
// packages/pdf-ast/src/staged-outputs.ts
|
|
58714
59062
|
import { listenForAbort as listenForAbort3 } from "@poe-platform/safe-fs/contracts";
|
|
58715
|
-
|
|
58716
|
-
// packages/pdf-ast/src/cos/name-index.ts
|
|
58717
|
-
var PdfNameIndex = class {
|
|
58718
|
-
constructor(storage, maximum10 = Infinity, signal) {
|
|
58719
|
-
this.storage = storage;
|
|
58720
|
-
this.maximum = maximum10;
|
|
58721
|
-
this.signal = signal;
|
|
58722
|
-
const limit10 = typeof maximum10 === "function" ? maximum10() : maximum10;
|
|
58723
|
-
if (limit10 !== Infinity && (!Number.isSafeInteger(limit10) || limit10 < 0)) throw new RangeError("Invalid name staging limit");
|
|
58724
|
-
}
|
|
58725
|
-
storage;
|
|
58726
|
-
maximum;
|
|
58727
|
-
signal;
|
|
58728
|
-
tail = /* @__PURE__ */ new Map();
|
|
58729
|
-
hot = /* @__PURE__ */ new Map();
|
|
58730
|
-
levels = [];
|
|
58731
|
-
nextNode = 2;
|
|
58732
|
-
nextName = 0;
|
|
58733
|
-
closed = false;
|
|
58734
|
-
get stagedBytes() {
|
|
58735
|
-
return this.levels.reduce((sum, index2) => sum + (index2?.size ?? 0) * 32, 0);
|
|
58736
|
-
}
|
|
58737
|
-
async get(edge) {
|
|
58738
|
-
if (this.tail.has(edge)) return this.tail.get(edge);
|
|
58739
|
-
if (this.hot.has(edge)) return this.hot.get(edge);
|
|
58740
|
-
for (const level of this.levels) {
|
|
58741
|
-
const entry = await level?.get(edge, this.signal);
|
|
58742
|
-
if (entry) {
|
|
58743
|
-
if (this.hot.size < 256) this.hot.set(edge, entry.offset);
|
|
58744
|
-
return entry.offset;
|
|
58745
|
-
}
|
|
58746
|
-
}
|
|
58747
|
-
return void 0;
|
|
58748
|
-
}
|
|
58749
|
-
async insert(edge, node) {
|
|
58750
|
-
this.tail.set(edge, node);
|
|
58751
|
-
if (this.hot.size < 256) this.hot.set(edge, node);
|
|
58752
|
-
if (this.tail.size < 64) return;
|
|
58753
|
-
let level = 0;
|
|
58754
|
-
while (this.levels[level]) level++;
|
|
58755
|
-
const inputs = this.levels.slice(0, level);
|
|
58756
|
-
const tail = this.tail;
|
|
58757
|
-
const signal = this.signal;
|
|
58758
|
-
async function* rows() {
|
|
58759
|
-
for (const [objectNumber, offset] of tail) yield { objectNumber, offset, type: "uncompressed" };
|
|
58760
|
-
for (const index2 of inputs) yield* index2.entries(signal);
|
|
58761
|
-
}
|
|
58762
|
-
const limit10 = typeof this.maximum === "function" ? this.maximum() : this.maximum;
|
|
58763
|
-
const remaining = Math.min(limit10, Number.MAX_SAFE_INTEGER) - this.stagedBytes;
|
|
58764
|
-
if (remaining < 0) throw new PdfError("E_LIMIT", "PDF name staging byte limit exceeded");
|
|
58765
|
-
const combined = await PdfObjectIndex.build(rows(), this.storage, {
|
|
58766
|
-
runEntries: 64,
|
|
58767
|
-
chunkBytes: 2048,
|
|
58768
|
-
cacheBytes: 2048,
|
|
58769
|
-
maxStagingBytes: remaining,
|
|
58770
|
-
...signal ? { signal } : {}
|
|
58771
|
-
});
|
|
58772
|
-
try {
|
|
58773
|
-
for (let i = 0; i < level; i++) {
|
|
58774
|
-
await this.levels[i].close();
|
|
58775
|
-
this.levels[i] = void 0;
|
|
58776
|
-
}
|
|
58777
|
-
this.levels[level] = combined;
|
|
58778
|
-
this.tail.clear();
|
|
58779
|
-
} catch (error) {
|
|
58780
|
-
try {
|
|
58781
|
-
await combined.close();
|
|
58782
|
-
} catch {
|
|
58783
|
-
}
|
|
58784
|
-
throw error;
|
|
58785
|
-
}
|
|
58786
|
-
}
|
|
58787
|
-
async intern(value) {
|
|
58788
|
-
if (this.closed) throw new PdfError("E_CAPABILITY", "PDF name index is closed");
|
|
58789
|
-
this.signal?.throwIfAborted();
|
|
58790
|
-
let node = 1, newPath = false;
|
|
58791
|
-
const units = typeof value === "string" ? (function* () {
|
|
58792
|
-
for (let i = 0; i < value.length; i++) yield value.charCodeAt(i);
|
|
58793
|
-
})() : value;
|
|
58794
|
-
let work = 0;
|
|
58795
|
-
for await (const code of units) {
|
|
58796
|
-
this.signal?.throwIfAborted();
|
|
58797
|
-
if (!Number.isInteger(code) || code < 0 || code > 65535) throw new RangeError("Invalid PDF name code unit");
|
|
58798
|
-
if (++work % 512 === 0) {
|
|
58799
|
-
await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
58800
|
-
this.signal?.throwIfAborted();
|
|
58801
|
-
}
|
|
58802
|
-
for (const unit of [code & 255, code >>> 8]) {
|
|
58803
|
-
const edge = node * 257 + unit + 1;
|
|
58804
|
-
let child = newPath ? void 0 : await this.get(edge);
|
|
58805
|
-
if (child === void 0) {
|
|
58806
|
-
if (this.nextNode > Math.floor(Number.MAX_SAFE_INTEGER / 257) - 1) throw new PdfError("E_LIMIT", "PDF name index address limit exceeded");
|
|
58807
|
-
child = this.nextNode++;
|
|
58808
|
-
await this.insert(edge, child);
|
|
58809
|
-
newPath = true;
|
|
58810
|
-
}
|
|
58811
|
-
node = child;
|
|
58812
|
-
}
|
|
58813
|
-
}
|
|
58814
|
-
const terminal = node * 257;
|
|
58815
|
-
const existing = newPath ? void 0 : await this.get(terminal);
|
|
58816
|
-
if (existing !== void 0) return { index: existing, added: false };
|
|
58817
|
-
const index2 = this.nextName++;
|
|
58818
|
-
await this.insert(terminal, index2);
|
|
58819
|
-
return { index: index2, added: true };
|
|
58820
|
-
}
|
|
58821
|
-
async close() {
|
|
58822
|
-
if (this.closed) return;
|
|
58823
|
-
this.closed = true;
|
|
58824
|
-
const results = await Promise.allSettled(this.levels.map((index2) => index2?.close()));
|
|
58825
|
-
this.tail.clear();
|
|
58826
|
-
this.hot.clear();
|
|
58827
|
-
this.levels.length = 0;
|
|
58828
|
-
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
58829
|
-
}
|
|
58830
|
-
};
|
|
58831
|
-
|
|
58832
|
-
// packages/pdf-ast/src/staged-outputs.ts
|
|
58833
59063
|
function maximum7(value, fallback) {
|
|
58834
59064
|
const result = value ?? fallback;
|
|
58835
59065
|
if (result !== Infinity && (!Number.isSafeInteger(result) || result < 0)) throw new RangeError("Invalid PDF output limit");
|
|
@@ -60032,10 +60262,10 @@ var PdfRetainedDocument = class _PdfRetainedDocument {
|
|
|
60032
60262
|
step = work.next(resolved?.stream && resolved.value.kind === "dict" ? { kind: "stream", dict: resolved.value, rawBytes: new Uint8Array() } : resolved?.value);
|
|
60033
60263
|
} else if (request.kind === "array-item") {
|
|
60034
60264
|
step = work.next(await this.readArrayItem(request.items, request.position));
|
|
60035
|
-
} else if (request.kind === "push-
|
|
60265
|
+
} else if (request.kind === "push-traversal-frame") {
|
|
60036
60266
|
await frames.push(request.frame);
|
|
60037
60267
|
step = work.next();
|
|
60038
|
-
} else if (request.kind === "pop-
|
|
60268
|
+
} else if (request.kind === "pop-traversal-frame") step = work.next(await frames.pop());
|
|
60039
60269
|
else if (request.kind === "visit-page") step = work.next(await visited.add(request.reference.objectNumber));
|
|
60040
60270
|
else throw new TypeError("Unexpected annotation page lookup request");
|
|
60041
60271
|
}
|
|
@@ -60050,6 +60280,123 @@ var PdfRetainedDocument = class _PdfRetainedDocument {
|
|
|
60050
60280
|
});
|
|
60051
60281
|
}
|
|
60052
60282
|
}
|
|
60283
|
+
/** Resolve a named annotation destination with caller-backed path state. */
|
|
60284
|
+
async annotationNamedDestination(node, name) {
|
|
60285
|
+
this.assertOpen();
|
|
60286
|
+
const storage = new PdfStagingStorage(this.storage, this.options.maxTraversalStagingBytes);
|
|
60287
|
+
let names;
|
|
60288
|
+
const flags = this.options.valueArrays?.arrayStorage;
|
|
60289
|
+
const pending = [];
|
|
60290
|
+
const signal = this.options.signal;
|
|
60291
|
+
async function initialize() {
|
|
60292
|
+
while (pending.length) {
|
|
60293
|
+
const { at, length } = pending.shift();
|
|
60294
|
+
signal?.throwIfAborted();
|
|
60295
|
+
await flags.write(at, new Uint8Array(length), signal ? { signal } : void 0);
|
|
60296
|
+
signal?.throwIfAborted();
|
|
60297
|
+
}
|
|
60298
|
+
}
|
|
60299
|
+
const indexStorage = flags ? {
|
|
60300
|
+
allocate(length) {
|
|
60301
|
+
const at = flags.allocate(length);
|
|
60302
|
+
pending.push({ at, length });
|
|
60303
|
+
return at;
|
|
60304
|
+
},
|
|
60305
|
+
async read(at, length) {
|
|
60306
|
+
await initialize();
|
|
60307
|
+
signal?.throwIfAborted();
|
|
60308
|
+
const bytes = await flags.read(at, length, signal ? { signal } : void 0);
|
|
60309
|
+
signal?.throwIfAborted();
|
|
60310
|
+
return bytes.slice();
|
|
60311
|
+
},
|
|
60312
|
+
async write(at, bytes) {
|
|
60313
|
+
await initialize();
|
|
60314
|
+
signal?.throwIfAborted();
|
|
60315
|
+
await flags.write(at, bytes, signal ? { signal } : void 0);
|
|
60316
|
+
signal?.throwIfAborted();
|
|
60317
|
+
}
|
|
60318
|
+
} : void 0;
|
|
60319
|
+
const references = indexStorage ? new IntegerTable5(indexStorage, 64) : void 0;
|
|
60320
|
+
const unusualReferences = indexStorage ? new IntegerTable5(indexStorage, 64) : void 0;
|
|
60321
|
+
const backing = this.options.valueArrays?.storedArrayKeys?.includes("Kids") ? flags : void 0;
|
|
60322
|
+
const frames = backing ? new StoredMetadataStack(backing, this.options.signal) : [];
|
|
60323
|
+
const buffered = /* @__PURE__ */ new Map(), active = /* @__PURE__ */ new Set();
|
|
60324
|
+
const direct = /* @__PURE__ */ new WeakMap();
|
|
60325
|
+
let failed = false;
|
|
60326
|
+
const work = annotationNameDestinationSteps(node, name, this.depthLimit);
|
|
60327
|
+
try {
|
|
60328
|
+
let step = work.next(), turns = 0;
|
|
60329
|
+
while (!step.done) {
|
|
60330
|
+
if (++turns % 256 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
60331
|
+
this.assertOpen();
|
|
60332
|
+
const request = step.value;
|
|
60333
|
+
let result;
|
|
60334
|
+
if (request.kind === "resolve") {
|
|
60335
|
+
const resolved = await this.lookup(request.node, void 0, request.arrayKey ? [request.arrayKey] : void 0);
|
|
60336
|
+
result = resolved?.stream && resolved.value.kind === "dict" ? { kind: "stream", dict: resolved.value, rawBytes: new Uint8Array() } : resolved?.value;
|
|
60337
|
+
} else if (request.kind === "array-item") result = await this.readArrayItem(request.items, request.position);
|
|
60338
|
+
else if (request.kind === "push-traversal-frame") await frames.push(request.frame);
|
|
60339
|
+
else if (request.kind === "pop-traversal-frame") result = await frames.pop();
|
|
60340
|
+
else if (request.kind === "enter-name-node") {
|
|
60341
|
+
const node2 = request.node;
|
|
60342
|
+
if (!flags) {
|
|
60343
|
+
const key = node2.kind === "ref" ? `${node2.objectNumber}:${node2.generationNumber}` : node2;
|
|
60344
|
+
let id2 = buffered.get(key);
|
|
60345
|
+
if (id2 === void 0) {
|
|
60346
|
+
id2 = buffered.size;
|
|
60347
|
+
buffered.set(key, id2);
|
|
60348
|
+
}
|
|
60349
|
+
if (!active.has(id2)) {
|
|
60350
|
+
active.add(id2);
|
|
60351
|
+
result = id2;
|
|
60352
|
+
}
|
|
60353
|
+
step = work.next(result);
|
|
60354
|
+
continue;
|
|
60355
|
+
}
|
|
60356
|
+
let id = node2.kind === "ref" ? void 0 : direct.get(node2);
|
|
60357
|
+
if (node2.kind === "ref") {
|
|
60358
|
+
const packed = Number.isSafeInteger(node2.objectNumber) && node2.objectNumber >= 0 && node2.objectNumber <= 281474976710655 && Number.isInteger(node2.generationNumber) && node2.generationNumber >= 0 && node2.generationNumber <= 65535;
|
|
60359
|
+
let key;
|
|
60360
|
+
const table = packed ? references : unusualReferences;
|
|
60361
|
+
if (packed) key = BigInt(node2.objectNumber) << 16n | BigInt(node2.generationNumber);
|
|
60362
|
+
else {
|
|
60363
|
+
names ??= new PdfNameIndex(storage, Infinity, this.options.signal);
|
|
60364
|
+
key = BigInt((await names.intern(`${node2.objectNumber}:${node2.generationNumber}`)).index);
|
|
60365
|
+
}
|
|
60366
|
+
const found = await table.get(key);
|
|
60367
|
+
if (found !== void 0) id = Number(found);
|
|
60368
|
+
else {
|
|
60369
|
+
id = flags.allocate(1);
|
|
60370
|
+
await flags.write(id, Uint8Array.of(0), signal ? { signal } : void 0);
|
|
60371
|
+
await table.set(key, BigInt(id));
|
|
60372
|
+
}
|
|
60373
|
+
} else if (id === void 0) {
|
|
60374
|
+
id = flags.allocate(1);
|
|
60375
|
+
await flags.write(id, Uint8Array.of(0), signal ? { signal } : void 0);
|
|
60376
|
+
direct.set(node2, id);
|
|
60377
|
+
}
|
|
60378
|
+
if ((await flags.read(id, 1, signal ? { signal } : void 0))[0] === 0) {
|
|
60379
|
+
await flags.write(id, Uint8Array.of(1), signal ? { signal } : void 0);
|
|
60380
|
+
result = id;
|
|
60381
|
+
}
|
|
60382
|
+
} else if (request.kind === "leave-name-node") {
|
|
60383
|
+
if (flags) await flags.write(request.identity, Uint8Array.of(0), signal ? { signal } : void 0);
|
|
60384
|
+
else active.delete(request.identity);
|
|
60385
|
+
} else throw new TypeError("Unexpected annotation name lookup request");
|
|
60386
|
+
step = work.next(result);
|
|
60387
|
+
}
|
|
60388
|
+
return step.value;
|
|
60389
|
+
} catch (error) {
|
|
60390
|
+
failed = true;
|
|
60391
|
+
throw error;
|
|
60392
|
+
} finally {
|
|
60393
|
+
work.return(void 0);
|
|
60394
|
+
const results = await Promise.allSettled([names?.close()]);
|
|
60395
|
+
if (!failed) {
|
|
60396
|
+
for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
|
|
60397
|
+
}
|
|
60398
|
+
}
|
|
60399
|
+
}
|
|
60053
60400
|
pages() {
|
|
60054
60401
|
async function* visit(doc) {
|
|
60055
60402
|
doc.assertOpen();
|
|
@@ -60259,6 +60606,23 @@ var PdfRetainedDocument = class _PdfRetainedDocument {
|
|
|
60259
60606
|
const work = visit(this);
|
|
60260
60607
|
return work;
|
|
60261
60608
|
}
|
|
60609
|
+
formFieldDetails() {
|
|
60610
|
+
async function* visit(doc) {
|
|
60611
|
+
doc.assertOpen();
|
|
60612
|
+
doc.walks.add(work);
|
|
60613
|
+
try {
|
|
60614
|
+
yield* walkRetainedFormFieldDetails(doc, doc.storage, {
|
|
60615
|
+
maxDepth: doc.depthLimit,
|
|
60616
|
+
...doc.options.maxTraversalStagingBytes === void 0 ? {} : { maxStagingBytes: doc.options.maxTraversalStagingBytes },
|
|
60617
|
+
...doc.options.signal ? { signal: doc.options.signal } : {}
|
|
60618
|
+
});
|
|
60619
|
+
} finally {
|
|
60620
|
+
doc.walks.delete(work);
|
|
60621
|
+
}
|
|
60622
|
+
}
|
|
60623
|
+
const work = visit(this);
|
|
60624
|
+
return work;
|
|
60625
|
+
}
|
|
60262
60626
|
attachments() {
|
|
60263
60627
|
async function* visit(doc) {
|
|
60264
60628
|
doc.assertOpen();
|
|
@@ -60458,7 +60822,7 @@ var PdfRetainedPage = class {
|
|
|
60458
60822
|
/** Pull one annotation at a time. Destination page lookup uses the document's
|
|
60459
60823
|
* caller-backed traversal index, without retaining a document-wide page map. */
|
|
60460
60824
|
async *annotations() {
|
|
60461
|
-
const work = extractPageAnnotationSteps(this.dict, this.document.crossReference.rootRef
|
|
60825
|
+
const work = extractPageAnnotationSteps(this.dict, this.document.crossReference.rootRef);
|
|
60462
60826
|
try {
|
|
60463
60827
|
let step = work.next(), turns = 0;
|
|
60464
60828
|
while (!step.done) {
|
|
@@ -60472,6 +60836,7 @@ var PdfRetainedPage = class {
|
|
|
60472
60836
|
} else if (request.kind === "array-item") {
|
|
60473
60837
|
result = await this.document.readArrayItem(request.items, request.position);
|
|
60474
60838
|
} else if (request.kind === "page-number") result = await this.document.annotationPageNumber(request.reference);
|
|
60839
|
+
else if (request.kind === "named-destination") result = await this.document.annotationNamedDestination(request.node, request.name);
|
|
60475
60840
|
else throw new TypeError("Unexpected annotation request");
|
|
60476
60841
|
step = work.next(result);
|
|
60477
60842
|
}
|
|
@@ -60901,7 +61266,7 @@ var PdfMergeAttachments = class {
|
|
|
60901
61266
|
};
|
|
60902
61267
|
|
|
60903
61268
|
// packages/pdf-ast/src/edit/retained-page-copy.ts
|
|
60904
|
-
import { IntegerTable as
|
|
61269
|
+
import { IntegerTable as IntegerTable6, PagedStorage as PagedStorage10 } from "@poe-platform/safe-fs/storage";
|
|
60905
61270
|
async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions, singleOptions = {}) {
|
|
60906
61271
|
const single = "pages" in input;
|
|
60907
61272
|
const storage = single ? storageOrOptions : indicesOrStorage;
|
|
@@ -60915,7 +61280,7 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
|
|
|
60915
61280
|
const attachments = options.includeAttachments ? new PdfMergeAttachments(storage, signal) : void 0;
|
|
60916
61281
|
const labels = options.includePageLabels ? new PdfMergeLabels(storage, signal, maximumDepth) : void 0;
|
|
60917
61282
|
const outlines = options.includeOutlines ? new PdfMergeOutlines(storage, signal, maximumDepth) : void 0;
|
|
60918
|
-
const pageReferences = outlines ? new
|
|
61283
|
+
const pageReferences = outlines ? new IntegerTable6(lists, 64) : void 0;
|
|
60919
61284
|
const catalog = cosDict({ Type: cosName("Catalog"), Pages: cosRef(2) });
|
|
60920
61285
|
const pages = { first: 0, last: 0, count: 0 }, formFields = { first: 0, last: 0, count: 0 };
|
|
60921
61286
|
let mayLinearize = false;
|
|
@@ -60965,7 +61330,7 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
|
|
|
60965
61330
|
async function append(document2, pageIndices, resourceState) {
|
|
60966
61331
|
const backing = new PagedStorage10({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
|
|
60967
61332
|
const sourcePages = new PdfMutableObjectStore(storage, { maxRecursionDepth: maximumDepth, signal });
|
|
60968
|
-
const memo = new
|
|
61333
|
+
const memo = new IntegerTable6(backing, 64), wanted = new IntegerTable6(backing, 64), sourceReferences = new IntegerTable6(backing, 64);
|
|
60969
61334
|
let firstSelection = 0, lastSelection = 0, sourceFailed = false;
|
|
60970
61335
|
async function* selections() {
|
|
60971
61336
|
let position = firstSelection;
|
|
@@ -61173,7 +61538,7 @@ async function createRetainedPageCopy(input, indicesOrStorage, storageOrOptions,
|
|
|
61173
61538
|
}
|
|
61174
61539
|
if (fields2?.kind === "array" && acro?.kind === "dict") {
|
|
61175
61540
|
let addedFields = false;
|
|
61176
|
-
const rootNumbers = new
|
|
61541
|
+
const rootNumbers = new IntegerTable6(backing, 64);
|
|
61177
61542
|
for (const field2 of fields2.items) {
|
|
61178
61543
|
if (!await hasCloned(field2)) continue;
|
|
61179
61544
|
const cloned = await clone(field2);
|
|
@@ -61380,10 +61745,10 @@ async function* retainedCosObjects(document2, storage, options = {}) {
|
|
|
61380
61745
|
}
|
|
61381
61746
|
|
|
61382
61747
|
// packages/pdf-ast/src/cos/retained-object-streams.ts
|
|
61383
|
-
import { IntegerTable as
|
|
61748
|
+
import { IntegerTable as IntegerTable7, PagedStorage as PagedStorage11 } from "@poe-platform/safe-fs/storage";
|
|
61384
61749
|
async function* serializeRetainedObjectStreams(store, storage, options, objects, fallback) {
|
|
61385
61750
|
const signal = options.signal ?? new AbortController().signal;
|
|
61386
|
-
const backing = new PagedStorage11({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), packed = new
|
|
61751
|
+
const backing = new PagedStorage11({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), packed = new IntegerTable7(backing);
|
|
61387
61752
|
let count = 0, highest = 0, failed = false, compressed;
|
|
61388
61753
|
try {
|
|
61389
61754
|
for await (const identity of store.identities()) {
|
|
@@ -61654,7 +62019,7 @@ async function* saveRetainedDocumentChunks(document2, storage, options = {}) {
|
|
|
61654
62019
|
}
|
|
61655
62020
|
|
|
61656
62021
|
// packages/pdf-ast/src/edit/retained-form-appearances.ts
|
|
61657
|
-
import { IntegerTable as
|
|
62022
|
+
import { IntegerTable as IntegerTable8, PagedStorage as PagedStorage13 } from "@poe-platform/safe-fs/storage";
|
|
61658
62023
|
|
|
61659
62024
|
// packages/pdf-ast/src/edit/form-appearance-chunks.ts
|
|
61660
62025
|
function* serializeFormAppearanceChunks(text, options) {
|
|
@@ -61742,7 +62107,7 @@ function* operators(text, options) {
|
|
|
61742
62107
|
// packages/pdf-ast/src/edit/retained-form-appearances.ts
|
|
61743
62108
|
async function generateRetainedFormAppearances(document2, store, storage, signal) {
|
|
61744
62109
|
if (!document2.crossReference.rootRef) return;
|
|
61745
|
-
const backing = new PagedStorage13({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new
|
|
62110
|
+
const backing = new PagedStorage13({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new IntegerTable8(backing);
|
|
61746
62111
|
let head = -1, failed = false, work = 0;
|
|
61747
62112
|
let defaultAppearance;
|
|
61748
62113
|
async function checkpoint(depth = 0) {
|
|
@@ -61949,17 +62314,17 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
|
|
|
61949
62314
|
}
|
|
61950
62315
|
|
|
61951
62316
|
// packages/pdf-ast/src/edit/retained-flatten-annotations.ts
|
|
61952
|
-
import { IntegerTable as
|
|
62317
|
+
import { IntegerTable as IntegerTable10, PagedStorage as PagedStorage17 } from "@poe-platform/safe-fs/storage";
|
|
61953
62318
|
|
|
61954
62319
|
// packages/pdf-ast/src/edit/retained-content-edit.ts
|
|
61955
|
-
import { IntegerTable as
|
|
62320
|
+
import { IntegerTable as IntegerTable9, PagedStorage as PagedStorage14 } from "@poe-platform/safe-fs/storage";
|
|
61956
62321
|
var RetainedContentEditor = class _RetainedContentEditor {
|
|
61957
62322
|
constructor(store, storage, signal) {
|
|
61958
62323
|
this.store = store;
|
|
61959
62324
|
this.storage = storage;
|
|
61960
62325
|
this.signal = signal;
|
|
61961
62326
|
this.backing = new PagedStorage14({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
|
|
61962
|
-
this.counts = new
|
|
62327
|
+
this.counts = new IntegerTable9(this.backing);
|
|
61963
62328
|
this.identities = new PdfNameIndex(storage, Infinity, signal);
|
|
61964
62329
|
}
|
|
61965
62330
|
store;
|
|
@@ -62274,7 +62639,7 @@ async function flattenRetainedAnnotations(document2, store, storage, mode, signa
|
|
|
62274
62639
|
}
|
|
62275
62640
|
if (normal?.stream && normal.reference && normal.value.kind === "dict") {
|
|
62276
62641
|
let content = await PdfFileSource.fromStream(storage.fs, storage.directory, document2.objects.decodeStream(normal.reference.objectNumber, normal.reference.generationNumber), { signal });
|
|
62277
|
-
const backing = new PagedStorage17({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), renames = new
|
|
62642
|
+
const backing = new PagedStorage17({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), renames = new IntegerTable10(backing), names = new PdfNameIndex(storage, Infinity, signal);
|
|
62278
62643
|
let appearanceFailed = false, count = 0;
|
|
62279
62644
|
try {
|
|
62280
62645
|
if (content.size) {
|
|
@@ -62393,7 +62758,7 @@ q ${scaleX} 0 0 ${scaleY} ${tx} ${ty} cm${matSuffix}
|
|
|
62393
62758
|
}
|
|
62394
62759
|
|
|
62395
62760
|
// packages/pdf-ast/src/edit/retained-stamps.ts
|
|
62396
|
-
import { IntegerTable as
|
|
62761
|
+
import { IntegerTable as IntegerTable11, PagedStorage as PagedStorage18 } from "@poe-platform/safe-fs/storage";
|
|
62397
62762
|
async function stampRetainedPages(document2, store, storage, getPage, stamps, signal) {
|
|
62398
62763
|
const editor = await RetainedContentEditor.open(store, storage, signal);
|
|
62399
62764
|
let counter = 1, failed = false, work = 0;
|
|
@@ -62404,7 +62769,7 @@ async function stampRetainedPages(document2, store, storage, getPage, stamps, si
|
|
|
62404
62769
|
try {
|
|
62405
62770
|
for await (const stamp of stamps) {
|
|
62406
62771
|
const source = await editRetainedDocument(stamp.source, storage, { signal });
|
|
62407
|
-
const backing = new PagedStorage18({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), memo = new
|
|
62772
|
+
const backing = new PagedStorage18({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), memo = new IntegerTable11(backing);
|
|
62408
62773
|
let stampFailed = false;
|
|
62409
62774
|
async function clone(node, depth = 0) {
|
|
62410
62775
|
await checkpoint();
|
|
@@ -62669,7 +63034,7 @@ async function externalizeRetainedInlineImages(document2, store, storage, option
|
|
|
62669
63034
|
}
|
|
62670
63035
|
|
|
62671
63036
|
// packages/pdf-ast/src/edit/retained-resource-pruning.ts
|
|
62672
|
-
import { IntegerTable as
|
|
63037
|
+
import { IntegerTable as IntegerTable12, PagedStorage as PagedStorage20 } from "@poe-platform/safe-fs/storage";
|
|
62673
63038
|
async function collectNames(input, names, found, signal) {
|
|
62674
63039
|
const iterator = input[Symbol.asyncIterator](), pending = [];
|
|
62675
63040
|
let chunk = new Uint8Array(), at = 0, ended = false, changed = false, work = 0, failed = false;
|
|
@@ -62751,7 +63116,7 @@ async function pruneRetainedResources(document2, store, storage, signal) {
|
|
|
62751
63116
|
return { ...found2, value: same(page2.reference) ? page2.dict : same(resources?.reference) ? resources.value : found2.value };
|
|
62752
63117
|
}
|
|
62753
63118
|
const names = new PdfNameIndex(storage, Infinity, signal), visitedNames = new PdfNameIndex(storage, Infinity, signal);
|
|
62754
|
-
const backing = new PagedStorage20({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), found = new
|
|
63119
|
+
const backing = new PagedStorage20({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), found = new IntegerTable12(backing);
|
|
62755
63120
|
let failed = false;
|
|
62756
63121
|
try {
|
|
62757
63122
|
const referenced = async (name) => await found.get(BigInt((await names.intern(name)).index)) !== void 0;
|
|
@@ -62881,7 +63246,7 @@ async function flattenRetainedRotations(document2, store, storage, signal) {
|
|
|
62881
63246
|
}
|
|
62882
63247
|
|
|
62883
63248
|
// packages/pdf-ast/src/edit/retained-attachment-edits.ts
|
|
62884
|
-
import { IntegerTable as
|
|
63249
|
+
import { IntegerTable as IntegerTable13, PagedStorage as PagedStorage21 } from "@poe-platform/safe-fs/storage";
|
|
62885
63250
|
var PdfDuplicateAttachment = class extends PdfError {
|
|
62886
63251
|
constructor(key) {
|
|
62887
63252
|
super("E_CAPABILITY", `Duplicate attachment key: ${key}`);
|
|
@@ -62892,7 +63257,7 @@ var PdfDuplicateAttachment = class extends PdfError {
|
|
|
62892
63257
|
async function editRetainedAttachments(document2, target, storage, remove, additions, signal, preserveTree = false) {
|
|
62893
63258
|
const pairs = new PdfMutableObjectStore(storage, { signal });
|
|
62894
63259
|
const names = new PdfNameIndex(storage, Infinity, signal), removed = new PdfNameIndex(storage, Infinity, signal);
|
|
62895
|
-
const backing = new PagedStorage21({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), first = new
|
|
63260
|
+
const backing = new PagedStorage21({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), first = new IntegerTable13(backing), removals = new IntegerTable13(backing);
|
|
62896
63261
|
let failed = false, count = 0, work = 0;
|
|
62897
63262
|
async function checkpoint() {
|
|
62898
63263
|
signal.throwIfAborted();
|
|
@@ -63309,10 +63674,10 @@ async function* copyRetainedAttachments(document2, storage, options = {}) {
|
|
|
63309
63674
|
}
|
|
63310
63675
|
|
|
63311
63676
|
// packages/pdf-ast/src/cos/retained-object-order.ts
|
|
63312
|
-
import { IntegerTable as
|
|
63677
|
+
import { IntegerTable as IntegerTable14, PagedStorage as PagedStorage23 } from "@poe-platform/safe-fs/storage";
|
|
63313
63678
|
async function* retainedObjectOrder(document2, source, storage, signal) {
|
|
63314
63679
|
const backing = new PagedStorage23({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
|
|
63315
|
-
const seen = new
|
|
63680
|
+
const seen = new IntegerTable14(backing), streams = new IntegerTable14(backing);
|
|
63316
63681
|
let failed = false, work = 0;
|
|
63317
63682
|
async function candidate(number) {
|
|
63318
63683
|
signal.throwIfAborted();
|
|
@@ -63326,7 +63691,7 @@ async function* retainedObjectOrder(document2, source, storage, signal) {
|
|
|
63326
63691
|
try {
|
|
63327
63692
|
if (document2.crossReference.revisionCount) {
|
|
63328
63693
|
for (const kind of ["uncompressed", "compressed"]) {
|
|
63329
|
-
const revisions = new
|
|
63694
|
+
const revisions = new IntegerTable14(backing);
|
|
63330
63695
|
let offset = document2.crossReference.xrefOffset;
|
|
63331
63696
|
while (offset !== void 0 && await revisions.get(BigInt(offset)) === void 0) {
|
|
63332
63697
|
await revisions.set(BigInt(offset), 1n);
|
|
@@ -63448,14 +63813,14 @@ async function* encryptRetainedPdfChunks(source, storage, options = {}) {
|
|
|
63448
63813
|
}
|
|
63449
63814
|
|
|
63450
63815
|
// packages/pdf-ast/src/cos/qpdf-json-values.ts
|
|
63451
|
-
import { IntegerTable as
|
|
63816
|
+
import { IntegerTable as IntegerTable15, PagedStorage as PagedStorage24 } from "@poe-platform/safe-fs/storage";
|
|
63452
63817
|
var QpdfJsonValues = class _QpdfJsonValues {
|
|
63453
63818
|
constructor(tree, storage, signal) {
|
|
63454
63819
|
this.tree = tree;
|
|
63455
63820
|
this.signal = signal;
|
|
63456
63821
|
this.scratch = new PagedStorage24({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
|
|
63457
|
-
this.first = new
|
|
63458
|
-
this.next = new
|
|
63822
|
+
this.first = new IntegerTable15(this.scratch, 64);
|
|
63823
|
+
this.next = new IntegerTable15(this.scratch, 64);
|
|
63459
63824
|
}
|
|
63460
63825
|
tree;
|
|
63461
63826
|
signal;
|
|
@@ -63553,7 +63918,7 @@ var QpdfJsonValues = class _QpdfJsonValues {
|
|
|
63553
63918
|
await this.cooperate();
|
|
63554
63919
|
const header2 = await this.tree.describe(position);
|
|
63555
63920
|
if (header2.kind === "object") {
|
|
63556
|
-
const hashes = new
|
|
63921
|
+
const hashes = new IntegerTable15(this.scratch, 64);
|
|
63557
63922
|
let head = 0, tail = 0;
|
|
63558
63923
|
for await (const { key } of order.entries(position)) {
|
|
63559
63924
|
let hash2 = 0;
|
|
@@ -63846,7 +64211,7 @@ var QpdfJsonValues = class _QpdfJsonValues {
|
|
|
63846
64211
|
};
|
|
63847
64212
|
|
|
63848
64213
|
// packages/pdf-ast/src/cos/qpdf-json-document.ts
|
|
63849
|
-
import { IntegerTable as
|
|
64214
|
+
import { IntegerTable as IntegerTable16, PagedStorage as PagedStorage25 } from "@poe-platform/safe-fs/storage";
|
|
63850
64215
|
var QpdfJsonDocument = class _QpdfJsonDocument {
|
|
63851
64216
|
constructor(storage, options = {}) {
|
|
63852
64217
|
this.storage = storage;
|
|
@@ -63856,9 +64221,9 @@ var QpdfJsonDocument = class _QpdfJsonDocument {
|
|
|
63856
64221
|
{ fs: storage.fs, cwd: storage.directory, env: {}, signal: this.signal },
|
|
63857
64222
|
4
|
|
63858
64223
|
);
|
|
63859
|
-
this.positions = new
|
|
63860
|
-
this.order = new
|
|
63861
|
-
this.catalogs = new
|
|
64224
|
+
this.positions = new IntegerTable16(this.backing, 64);
|
|
64225
|
+
this.order = new IntegerTable16(this.backing, 64);
|
|
64226
|
+
this.catalogs = new IntegerTable16(this.backing, 64);
|
|
63862
64227
|
}
|
|
63863
64228
|
storage;
|
|
63864
64229
|
rootRef;
|