@poe-platform/safe-bash 0.1.787 → 0.1.789
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/README.md +1 -1
- package/dist/safe-bash/chunks/{chunk-WHURJBET.js → chunk-2MUJ7RLZ.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-PYTLIUST.js → chunk-CTUHLNJM.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Z3HX3ZBA.js → chunk-D4PHJK4T.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-O6356Z27.js → chunk-H7MMJS26.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-Q3E6C3DX.js → chunk-KHJGUF2W.js} +14 -0
- package/dist/safe-bash/chunks/{chunk-FJZNUUOQ.js → chunk-VUVKC6HV.js} +1 -1
- package/dist/safe-bash/chunks/{chunk-ZMYVCRAF.js → chunk-X5ZCECM6.js} +2 -2
- package/dist/safe-bash/chunks/{git-UFNPAOYZ.js → git-HO7WDPHZ.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-PFBJR2PY.js → chunk-2KRKKW5S.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4DSJDVBM.js → chunk-32F3RBUW.js} +10 -749
- package/dist/safe-bash/command-chunks/{chunk-WVWWRMFD.js → chunk-3KROFHBT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-L3MLMXL4.js → chunk-3ZK5F23O.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-4QX6XCDD.js → chunk-4RNIZ3RT.js} +79 -0
- package/dist/safe-bash/command-chunks/{chunk-IFUNAM4D.js → chunk-5L62A5RO.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-D7TADAYG.js → chunk-64LG3EVJ.js} +17 -0
- package/dist/safe-bash/command-chunks/{chunk-JUDOV5MJ.js → chunk-6F7QJMJ3.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-IJ3FXP4Q.js → chunk-A3ZX6SCY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-DREUDEQG.js → chunk-AT6ZSOE6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-BUKYQBXO.js → chunk-BJ6DGYJA.js} +12 -12
- package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-NSEUBSOD.js → chunk-CXMOCPPH.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-XGMWWUHV.js → chunk-CZ5DAK4K.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z57TV6TC.js → chunk-EZ2DTOLI.js} +4 -2
- package/dist/safe-bash/command-chunks/{chunk-ADCGH6A7.js → chunk-FH3D75FC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-WYJTWJZ5.js → chunk-G3G6W5ZE.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3HDIDEUJ.js → chunk-GF54KE2M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3JS4FOLB.js → chunk-HETU7MYN.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-Z7TYZG3A.js → chunk-IHHTTQX6.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-INDIFLBW.js → chunk-JTAGNROA.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-Z47EO74H.js → chunk-MYKK3Q5G.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GZOUGVVV.js → chunk-OYZ534IK.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-PGEYORBZ.js +25 -0
- package/dist/safe-bash/command-chunks/chunk-QM4UZF3C.js +753 -0
- package/dist/safe-bash/command-chunks/{chunk-TOSM3T3A.js → chunk-UJOO6DKY.js} +20 -9
- package/dist/safe-bash/command-chunks/{chunk-TFZEYNMX.js → chunk-VQLFJCG7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-BIXN77VL.js → chunk-VUG324ER.js} +10 -0
- package/dist/safe-bash/command-chunks/{chunk-2LP3VMPA.js → chunk-WFDW4XXD.js} +1 -17
- package/dist/safe-bash/command-chunks/chunk-WR37IS4O.js +318 -0
- package/dist/safe-bash/command-chunks/{chunk-Y5IHIAY3.js → chunk-XNHSCU6I.js} +7 -3
- package/dist/safe-bash/commands/basic.js +148 -48
- package/dist/safe-bash/commands/bytes/compression/index.js +5 -6
- package/dist/safe-bash/commands/cmp.d.ts +2 -3
- package/dist/safe-bash/commands/cmp.js +2 -689
- package/dist/safe-bash/commands/docx/index.browser.js +3 -46
- package/dist/safe-bash/commands/docx/index.d.ts +2 -24
- package/dist/safe-bash/commands/docx/index.js +2 -41
- package/dist/safe-bash/commands/docx/io.d.ts +1 -14
- package/dist/safe-bash/commands/docx/io.js +1 -15
- package/dist/safe-bash/commands/llm/index.browser.js +3 -3
- package/dist/safe-bash/commands/network/index.browser.js +3 -3
- package/dist/safe-bash/commands/node/index.browser.js +3 -3
- package/dist/safe-bash/commands/pptx/index.d.ts +2 -28
- package/dist/safe-bash/commands/pptx/index.js +2 -152
- package/dist/safe-bash/commands/printf-float.d.ts +1 -0
- package/dist/safe-bash/commands/printf-float.js +48 -38
- package/dist/safe-bash/commands/printf-format.js +9 -6
- package/dist/safe-bash/commands/printf-quote.d.ts +3 -0
- package/dist/safe-bash/commands/printf-quote.js +62 -0
- package/dist/safe-bash/commands/printf-wide.d.ts +5 -0
- package/dist/safe-bash/commands/printf-wide.js +41 -0
- package/dist/safe-bash/commands/python/index.browser.js +2 -2
- package/dist/safe-bash/commands/truncate.d.ts +2 -3
- package/dist/safe-bash/commands/truncate.js +2 -686
- package/dist/safe-bash/contracts/diagnostics.d.ts +2 -0
- package/dist/safe-bash/contracts/diagnostics.js +2 -0
- package/dist/safe-bash/contracts/runtime-control.d.ts +2 -0
- package/dist/safe-bash/contracts/runtime-control.js +2 -0
- package/dist/safe-bash/core.browser.d.ts +1 -1
- package/dist/safe-bash/core.browser.js +2651 -4871
- package/dist/safe-bash/core.d.ts +10 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -2
- package/dist/safe-bash/opt-in/commands/cmp/index.js +776 -79
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +0 -12
- package/dist/safe-bash/opt-in/commands/cmp/options.js +0 -153
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +8 -3
- package/dist/safe-bash/opt-in/commands/truncate/index.js +790 -272
- package/dist/safe-bash/opt-in/commands/truncate/sync.d.ts +1 -0
- package/dist/safe-bash/opt-in/commands/truncate/sync.js +60 -0
- package/dist/safe-bash/optional-host.browser.js +9 -1
- package/dist/safe-bash/optional-host.d.ts +3 -1
- package/dist/safe-bash/optional-host.js +3 -1
- package/dist/safe-bash/shell/runtime.js +10 -6
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +14 -2
- package/dist/safe-bash-command-bzip2/index.js +2 -1
- package/dist/safe-bash-command-cmp/index.d.ts +10 -0
- package/dist/safe-bash-command-cmp/index.js +796 -0
- package/dist/safe-bash-command-cmp/options.d.ts +12 -0
- package/dist/safe-bash-command-cmp/options.js +42 -0
- package/dist/safe-bash-command-csvcut/index.js +11 -8
- package/dist/safe-bash-command-csvgrep/index.js +35 -7
- package/dist/safe-bash-command-csvkit/codecs/python.js +4 -3
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +3 -2
- package/dist/safe-bash-command-csvkit/index.js +80 -324
- package/dist/safe-bash-command-csvkit/python-regex.d.ts +5 -0
- package/dist/safe-bash-command-csvkit/python-regex.js +14 -0
- package/dist/safe-bash-command-csvkit/runtime.d.ts +1 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +4 -2
- package/dist/safe-bash-command-diff3/index.js +3 -0
- package/dist/safe-bash-command-docx/LICENSE +21 -0
- package/dist/safe-bash-command-docx/index.d.ts +30 -0
- package/dist/safe-bash-command-docx/index.js +67 -0
- package/dist/safe-bash-command-docx/io.d.ts +14 -0
- package/dist/safe-bash-command-docx/io.js +26 -0
- package/dist/safe-bash-command-envsubst/index.js +34 -3
- package/dist/safe-bash-command-exiftool/index.js +3 -0
- package/dist/safe-bash-command-ffmpeg/index.js +1102 -1088
- package/dist/safe-bash-command-fold/family.js +1 -1
- package/dist/safe-bash-command-fold/index.js +1 -1
- package/dist/safe-bash-command-htmlq/index.js +5 -0
- package/dist/safe-bash-command-imagemagick/index.d.ts +25 -21
- package/dist/safe-bash-command-imagemagick/index.js +669 -271
- package/dist/safe-bash-command-mmdc/index.js +48 -10
- package/dist/safe-bash-command-mmdc/svg.d.ts +1 -0
- package/dist/safe-bash-command-op/index.js +19 -14
- 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-pdfimages/index.d.ts +7 -1
- package/dist/safe-bash-command-pdfimages/index.js +63 -33
- package/dist/safe-bash-command-pdfinfo/index.d.ts +24 -20
- package/dist/safe-bash-command-pdfinfo/index.js +370 -161
- package/dist/safe-bash-command-pdftk/index.d.ts +7 -3
- package/dist/safe-bash-command-pdftk/index.js +114 -45
- package/dist/safe-bash-command-pdftoppm/index.d.ts +15 -7
- package/dist/safe-bash-command-pdftoppm/index.js +179 -109
- package/dist/safe-bash-command-pdftotext/index.d.ts +9 -5
- package/dist/safe-bash-command-pdftotext/index.js +90 -27
- package/dist/safe-bash-command-pptx/LICENSE +21 -0
- package/dist/safe-bash-command-pptx/index.d.ts +33 -0
- package/dist/safe-bash-command-pptx/index.js +168 -0
- package/dist/safe-bash-command-qpdf/index.d.ts +9 -3
- package/dist/safe-bash-command-qpdf/index.js +80 -29
- package/dist/safe-bash-command-sha512sum/index.js +12 -475
- package/dist/safe-bash-command-sips/index.d.ts +9 -5
- package/dist/safe-bash-command-sips/index.js +63 -44
- package/dist/safe-bash-command-soffice/index.d.ts +9 -3
- package/dist/safe-bash-command-soffice/index.js +65 -24
- package/dist/safe-bash-command-sqlite3/engine.d.ts +9 -0
- package/dist/safe-bash-command-sqlite3/index.d.ts +1 -0
- package/dist/safe-bash-command-sqlite3/index.js +851 -352
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-truncate/index.d.ts +8 -3
- package/dist/safe-bash-command-truncate/index.js +790 -272
- package/dist/safe-bash-command-truncate/sync.d.ts +1 -0
- package/dist/safe-bash-command-truncate/sync.js +60 -0
- package/dist/safe-bash-command-wkhtmltopdf/index.js +92 -38
- package/dist/safe-bash-command-wkhtmltopdf/pdf-renderer.d.ts +1 -1
- package/dist/safe-bash-command-xxd/index.js +78 -20
- package/dist/safe-bash-command-xz/command.d.ts +4 -0
- package/dist/safe-bash-command-xz/index.d.ts +1 -1
- package/dist/safe-bash-command-xz/index.js +1 -1
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/command.js +3 -3
- package/dist/safe-bash-contracts/diagnostics.js +3 -3
- package/dist/safe-bash-contracts/escaping.js +9 -9
- package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
- package/dist/safe-bash-contracts/filesystem-output.js +8 -8
- package/dist/safe-bash-contracts/index.js +21 -19
- package/dist/safe-bash-contracts/io.d.ts +12 -0
- package/dist/safe-bash-contracts/io.js +4 -1
- package/dist/safe-bash-contracts/output.js +3 -2
- package/dist/safe-bash-contracts/runtime-control.js +2 -2
- package/dist/safe-bash-contracts/signals.js +1 -1
- package/dist/safe-bash-contracts/yield.d.ts +1 -0
- package/dist/safe-bash-contracts/yield.js +3 -1
- package/dist/safe-bash-csv-engine/index.d.ts +10 -1
- package/dist/safe-bash-csv-engine/index.js +78 -6
- package/dist/safe-bash-io-engine/commands/search/requirements.js +3 -3
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +3 -3
- package/dist/safe-bash-io-engine/gnu-information.js +1 -1
- package/dist/safe-bash-io-engine/internal.d.ts +1 -1
- package/dist/safe-bash-io-engine/internal.js +2 -2
- package/dist/safe-bash-mcp/index.browser.d.ts +875 -0
- package/dist/safe-bash-mcp/index.browser.js +8740 -0
- package/dist/safe-bash-mcp/index.js +32 -31
- package/dist/safe-bash-query-engine/capture.js +3 -3
- package/dist/safe-bash-query-engine/delpaths.js +3 -3
- package/dist/safe-bash-query-engine/formats.js +2 -2
- package/dist/safe-bash-query-engine/index.js +12 -12
- package/dist/safe-bash-query-engine/indices.js +3 -3
- package/dist/safe-bash-query-engine/input.js +1 -1
- package/dist/safe-bash-query-engine/interpreter.js +10 -10
- package/dist/safe-bash-query-engine/query-core.js +12 -12
- package/dist/safe-bash-query-engine/regex.js +3 -3
- package/dist/safe-bash-query-engine/splits.js +4 -4
- package/dist/safe-bash-query-engine/values.js +2 -2
- package/package.json +9 -3
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +0 -95
- package/dist/safe-bash/opt-in/commands/cmp/io.js +0 -218
- package/dist/safe-bash/command-chunks/{chunk-FXYWQ6S4.js → chunk-2VTMZTV3.js} +0 -0
- package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// packages/safe-bash-command-qpdf/dist/index.js
|
|
6
6
|
init_buffer();
|
|
7
|
+
import { yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
7
8
|
import { writeFileOutput } from "../safe-bash-contracts/filesystem-output-budget.js";
|
|
8
9
|
import {
|
|
9
10
|
commandRuntimeIdentity,
|
|
@@ -43993,6 +43994,13 @@ function replacePdfNameToken(content, oldName, newName) {
|
|
|
43993
43994
|
}
|
|
43994
43995
|
return out;
|
|
43995
43996
|
}
|
|
43997
|
+
function resolveLimits(options) {
|
|
43998
|
+
const limits = { maxInputBytes: Infinity, maxOutputBytes: Infinity, maxArgumentBytes: Infinity, ...options.limits };
|
|
43999
|
+
for (const [name, value] of Object.entries(limits)) {
|
|
44000
|
+
if (value !== Infinity && (!Number.isSafeInteger(value) || value < 0)) throw new RangeError(`${name} limit must be a nonnegative safe integer or Infinity`);
|
|
44001
|
+
}
|
|
44002
|
+
return limits;
|
|
44003
|
+
}
|
|
43996
44004
|
function parseSingleTokenPageNumber(tok, totalPages) {
|
|
43997
44005
|
const trimmed = tok.trim();
|
|
43998
44006
|
if (trimmed === "z") return totalPages;
|
|
@@ -44417,13 +44425,25 @@ function collectNumberTreeDicts(doc, treeDict, visited = /* @__PURE__ */ new Set
|
|
|
44417
44425
|
}
|
|
44418
44426
|
return out;
|
|
44419
44427
|
}
|
|
44420
|
-
async function runQpdfCli(argv, files, readStdin) {
|
|
44428
|
+
async function runQpdfCli(argv, files, readStdin, signal) {
|
|
44429
|
+
signal?.throwIfAborted();
|
|
44421
44430
|
const parsed = parseQpdfArguments(argv);
|
|
44422
44431
|
if (parsed.result) return parsed.result;
|
|
44423
44432
|
const { inputFile, pageSpecs, stampSpecs, addAttachmentSpecs, copyAttachmentsSpecs, updateFromJsonFiles } = parsed.options;
|
|
44424
44433
|
const usesStdin = inputFile === "-" || updateFromJsonFiles.includes("-") || [...pageSpecs, ...stampSpecs, ...addAttachmentSpecs, ...copyAttachmentsSpecs].some((spec) => spec.file === "-");
|
|
44425
44434
|
if (readStdin && usesStdin) await readStdin();
|
|
44426
|
-
|
|
44435
|
+
const steps = executeQpdfCli(parsed.options, files);
|
|
44436
|
+
try {
|
|
44437
|
+
let step = steps.next();
|
|
44438
|
+
while (!step.done) {
|
|
44439
|
+
await yieldTurn(signal);
|
|
44440
|
+
signal?.throwIfAborted();
|
|
44441
|
+
step = steps.next();
|
|
44442
|
+
}
|
|
44443
|
+
return step.value;
|
|
44444
|
+
} finally {
|
|
44445
|
+
steps.return({ exitCode: 2, stdout: "", stderr: "" });
|
|
44446
|
+
}
|
|
44427
44447
|
}
|
|
44428
44448
|
function parseQpdfArguments(argv) {
|
|
44429
44449
|
let check = false;
|
|
@@ -44845,9 +44865,12 @@ function parseQpdfArguments(argv) {
|
|
|
44845
44865
|
function runQpdfCliSync(argv, files) {
|
|
44846
44866
|
const parsed = parseQpdfArguments(argv);
|
|
44847
44867
|
if (parsed.result) return parsed.result;
|
|
44848
|
-
|
|
44868
|
+
const steps = executeQpdfCli(parsed.options, files);
|
|
44869
|
+
let step = steps.next();
|
|
44870
|
+
while (!step.done) step = steps.next();
|
|
44871
|
+
return step.value;
|
|
44849
44872
|
}
|
|
44850
|
-
function executeQpdfCli(options, files) {
|
|
44873
|
+
function* executeQpdfCli(options, files) {
|
|
44851
44874
|
const {
|
|
44852
44875
|
check,
|
|
44853
44876
|
showNpages,
|
|
@@ -45316,6 +45339,7 @@ extract for accessibility: ${enc.permissions.copy ? "allowed" : "not allowed"}
|
|
|
45316
45339
|
}
|
|
45317
45340
|
const loadedSpecs = [];
|
|
45318
45341
|
for (const spec of pageSpecs) {
|
|
45342
|
+
yield;
|
|
45319
45343
|
const srcBytes = loadBytes(spec.file);
|
|
45320
45344
|
if (!srcBytes) {
|
|
45321
45345
|
return { exitCode: 2, stdout: "", stderr: `qpdf: cannot open ${spec.file}
|
|
@@ -45352,6 +45376,7 @@ extract for accessibility: ${enc.permissions.copy ? "allowed" : "not allowed"}
|
|
|
45352
45376
|
for (const rot of rotateSpecs) {
|
|
45353
45377
|
const pageNums = parseQpdfPageRange(rot.range, workingDoc.getPageCount());
|
|
45354
45378
|
for (const pNum of pageNums) {
|
|
45379
|
+
yield;
|
|
45355
45380
|
const page = workingDoc.getPage(pNum - 1);
|
|
45356
45381
|
if (rot.relative) {
|
|
45357
45382
|
const current = page.getRotation();
|
|
@@ -45508,6 +45533,7 @@ ${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
|
|
|
45508
45533
|
if (flattenRotation) {
|
|
45509
45534
|
const enc = new TextEncoder();
|
|
45510
45535
|
for (const page of workingDoc.getPages()) {
|
|
45536
|
+
yield;
|
|
45511
45537
|
const rot = page.getRotation();
|
|
45512
45538
|
if (rot === 90 || rot === 180 || rot === 270) {
|
|
45513
45539
|
const { width: W, height: H } = page.getSize();
|
|
@@ -45576,6 +45602,7 @@ ${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
|
|
|
45576
45602
|
if (flattenAnnotations !== false) {
|
|
45577
45603
|
const enc = new TextEncoder();
|
|
45578
45604
|
for (const page of workingDoc.getPages()) {
|
|
45605
|
+
yield;
|
|
45579
45606
|
const annotsNode = workingDoc.cos.resolve(dictGet(page.dict, "Annots"));
|
|
45580
45607
|
const annotsArr = asArray(annotsNode);
|
|
45581
45608
|
if (!annotsArr) continue;
|
|
@@ -45754,6 +45781,7 @@ Q
|
|
|
45754
45781
|
};
|
|
45755
45782
|
let extCounter = 1;
|
|
45756
45783
|
for (const page of workingDoc.getPages()) {
|
|
45784
|
+
yield;
|
|
45757
45785
|
let modified = false;
|
|
45758
45786
|
const pageRes = page.getResourcesDict();
|
|
45759
45787
|
let xobjSub = asDict(workingDoc.cos.resolve(dictGet(pageRes, "XObject")));
|
|
@@ -45839,6 +45867,7 @@ Q
|
|
|
45839
45867
|
"Properties"
|
|
45840
45868
|
];
|
|
45841
45869
|
for (const page of workingDoc.getPages()) {
|
|
45870
|
+
yield;
|
|
45842
45871
|
const refNames = /* @__PURE__ */ new Set();
|
|
45843
45872
|
collectPdfNamesFromBytes(page.getRawContentStream(), refNames);
|
|
45844
45873
|
const annotsArr = asArray(workingDoc.cos.resolve(dictGet(page.dict, "Annots")));
|
|
@@ -45957,6 +45986,7 @@ Q
|
|
|
45957
45986
|
}
|
|
45958
45987
|
}
|
|
45959
45988
|
for (const copySpec of copyAttachmentsSpecs) {
|
|
45989
|
+
yield;
|
|
45960
45990
|
const srcBytes = loadBytes(copySpec.file);
|
|
45961
45991
|
if (!srcBytes) {
|
|
45962
45992
|
return { exitCode: 2, stdout: "", stderr: `qpdf: cannot open ${copySpec.file}
|
|
@@ -46092,6 +46122,7 @@ Q
|
|
|
46092
46122
|
namesArr = asArray(dictGet(efTree, "Names"));
|
|
46093
46123
|
}
|
|
46094
46124
|
for (const addSpec of addAttachmentSpecs) {
|
|
46125
|
+
yield;
|
|
46095
46126
|
const attBytes = loadBytes(addSpec.file);
|
|
46096
46127
|
if (!attBytes) {
|
|
46097
46128
|
return { exitCode: 2, stdout: "", stderr: `qpdf: cannot open attachment ${addSpec.file}
|
|
@@ -46190,6 +46221,7 @@ Q
|
|
|
46190
46221
|
return replaced ? out : void 0;
|
|
46191
46222
|
};
|
|
46192
46223
|
for (let startIdx = 0; startIdx < total; startIdx += splitPagesGroup) {
|
|
46224
|
+
yield;
|
|
46193
46225
|
const endIdx = Math.min(total - 1, startIdx + splitPagesGroup - 1);
|
|
46194
46226
|
const subDoc = PdfDocument.create();
|
|
46195
46227
|
if (wMeta.title) subDoc.setTitle(wMeta.title);
|
|
@@ -46237,12 +46269,20 @@ Q
|
|
|
46237
46269
|
files.set(finalTarget, outBytes);
|
|
46238
46270
|
return { exitCode: repairedWarning && !warningExit0 ? 3 : 0, stdout: "", stderr: "" };
|
|
46239
46271
|
}
|
|
46240
|
-
async function qpdf(context) {
|
|
46272
|
+
async function qpdf(context, options = {}) {
|
|
46273
|
+
const limits = resolveLimits(options);
|
|
46274
|
+
let outputBytes = 0;
|
|
46275
|
+
const chargeOutput = (bytes) => {
|
|
46276
|
+
outputBytes += bytes;
|
|
46277
|
+
if (outputBytes > limits.maxOutputBytes) throw new RangeError("Output byte limit exceeded");
|
|
46278
|
+
};
|
|
46241
46279
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
46242
46280
|
} });
|
|
46243
46281
|
try {
|
|
46244
46282
|
const carrier = getCommandArguments(context);
|
|
46245
46283
|
const argv = [...carrier.args];
|
|
46284
|
+
const argumentBytes = argv.reduce((total, arg) => total + new TextEncoder().encode(arg).byteLength + 1, 0);
|
|
46285
|
+
if (argumentBytes > limits.maxArgumentBytes) throw new RangeError("Argument byte limit exceeded");
|
|
46246
46286
|
const vfsFiles = /* @__PURE__ */ new Map();
|
|
46247
46287
|
const resolveVfsPath = (p) => p.startsWith("/") ? p : `${context.cwd === "/" ? "" : context.cwd}/${p}`;
|
|
46248
46288
|
let accountedBytes = 0;
|
|
@@ -46250,6 +46290,7 @@ async function qpdf(context) {
|
|
|
46250
46290
|
if (delta > 0) {
|
|
46251
46291
|
accountedBytes += delta;
|
|
46252
46292
|
context.inputBudget?.check(accountedBytes);
|
|
46293
|
+
if (accountedBytes > limits.maxInputBytes) throw new RangeError("Input byte limit exceeded");
|
|
46253
46294
|
}
|
|
46254
46295
|
};
|
|
46255
46296
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -46270,39 +46311,49 @@ async function qpdf(context) {
|
|
|
46270
46311
|
i += args.length - 1;
|
|
46271
46312
|
}
|
|
46272
46313
|
for (const token of argv) {
|
|
46314
|
+
await yieldTurn(invocation.signal);
|
|
46315
|
+
invocation.signal.throwIfAborted();
|
|
46273
46316
|
let candidate = token;
|
|
46274
|
-
if (token.startsWith("--overlay=") || token.startsWith("--underlay=") || token.startsWith("--update-from-json=")) {
|
|
46317
|
+
if (token.startsWith("--overlay=") || token.startsWith("--underlay=") || token.startsWith("--add-attachment=") || token.startsWith("--copy-attachments-from=") || token.startsWith("--update-from-json=")) {
|
|
46275
46318
|
candidate = token.slice(token.indexOf("=") + 1);
|
|
46276
46319
|
} else if (token.startsWith("-") || token === "--" || token === ".") {
|
|
46277
46320
|
continue;
|
|
46278
46321
|
}
|
|
46279
46322
|
const abs = resolveVfsPath(candidate);
|
|
46323
|
+
let bytes;
|
|
46280
46324
|
try {
|
|
46281
|
-
|
|
46282
|
-
chargeBytes(bytes.byteLength);
|
|
46283
|
-
vfsFiles.set(candidate, bytes);
|
|
46325
|
+
bytes = await context.fs.readFile(abs, { signal: invocation.signal });
|
|
46284
46326
|
} catch {
|
|
46327
|
+
invocation.signal.throwIfAborted();
|
|
46328
|
+
continue;
|
|
46285
46329
|
}
|
|
46330
|
+
chargeBytes(bytes.byteLength);
|
|
46331
|
+
vfsFiles.set(candidate, bytes);
|
|
46286
46332
|
}
|
|
46287
46333
|
if (argv.includes("--json-input") || argv.some((t) => t.startsWith("--update-from-json="))) {
|
|
46288
46334
|
for (const fileBytes of [...vfsFiles.values()]) {
|
|
46335
|
+
let parsed;
|
|
46289
46336
|
try {
|
|
46290
|
-
|
|
46291
|
-
const objs = Array.isArray(parsed.qpdf) && typeof parsed.qpdf[1] === "object" ? parsed.qpdf[1] : typeof parsed.objects === "object" && parsed.objects !== null ? parsed.objects : void 0;
|
|
46292
|
-
if (!objs) continue;
|
|
46293
|
-
for (const entry of Object.values(objs)) {
|
|
46294
|
-
if (typeof entry === "object" && entry !== null && "stream" in entry) {
|
|
46295
|
-
const st = entry.stream;
|
|
46296
|
-
if (st && typeof st.datafile === "string" && !vfsFiles.has(st.datafile)) {
|
|
46297
|
-
const dfBytes = await context.fs.readFile(resolveVfsPath(st.datafile), {
|
|
46298
|
-
signal: invocation.signal
|
|
46299
|
-
});
|
|
46300
|
-
chargeBytes(dfBytes.byteLength);
|
|
46301
|
-
vfsFiles.set(st.datafile, dfBytes);
|
|
46302
|
-
}
|
|
46303
|
-
}
|
|
46304
|
-
}
|
|
46337
|
+
parsed = JSON.parse(new TextDecoder().decode(fileBytes));
|
|
46305
46338
|
} catch {
|
|
46339
|
+
continue;
|
|
46340
|
+
}
|
|
46341
|
+
if (!parsed || typeof parsed !== "object") continue;
|
|
46342
|
+
const objs = Array.isArray(parsed.qpdf) && typeof parsed.qpdf[1] === "object" ? parsed.qpdf[1] : typeof parsed.objects === "object" && parsed.objects !== null ? parsed.objects : void 0;
|
|
46343
|
+
if (!objs) continue;
|
|
46344
|
+
for (const entry of Object.values(objs)) {
|
|
46345
|
+
if (typeof entry !== "object" || entry === null || !("stream" in entry)) continue;
|
|
46346
|
+
const stream = entry.stream;
|
|
46347
|
+
if (!stream || typeof stream.datafile !== "string" || vfsFiles.has(stream.datafile)) continue;
|
|
46348
|
+
let bytes;
|
|
46349
|
+
try {
|
|
46350
|
+
bytes = await context.fs.readFile(resolveVfsPath(stream.datafile), { signal: invocation.signal });
|
|
46351
|
+
} catch {
|
|
46352
|
+
invocation.signal.throwIfAborted();
|
|
46353
|
+
continue;
|
|
46354
|
+
}
|
|
46355
|
+
chargeBytes(bytes.byteLength);
|
|
46356
|
+
vfsFiles.set(stream.datafile, bytes);
|
|
46306
46357
|
}
|
|
46307
46358
|
}
|
|
46308
46359
|
}
|
|
@@ -46323,19 +46374,19 @@ async function qpdf(context) {
|
|
|
46323
46374
|
}
|
|
46324
46375
|
vfsFiles.set("-", bytes);
|
|
46325
46376
|
existingSnap.set("-", bytes);
|
|
46326
|
-
});
|
|
46377
|
+
}, invocation.signal);
|
|
46327
46378
|
if (res.stderr) {
|
|
46328
46379
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
46329
46380
|
}
|
|
46330
46381
|
if (res.stdout) {
|
|
46331
46382
|
const outBytes = new TextEncoder().encode(res.stdout);
|
|
46332
|
-
|
|
46383
|
+
chargeOutput(outBytes.byteLength);
|
|
46333
46384
|
const stdout = invocation.child(context.stdout);
|
|
46334
46385
|
await writeBytes(stdout.output, outBytes, invocation.signal);
|
|
46335
46386
|
}
|
|
46336
46387
|
for (const [fileKey, fileBytes] of vfsFiles.entries()) {
|
|
46337
46388
|
if (existingSnap.get(fileKey) !== fileBytes) {
|
|
46338
|
-
|
|
46389
|
+
chargeOutput(fileBytes.byteLength);
|
|
46339
46390
|
if (fileKey === "-") {
|
|
46340
46391
|
const stdout = invocation.child(context.stdout);
|
|
46341
46392
|
await writeBytes(stdout.output, fileBytes, invocation.signal);
|
|
@@ -46350,13 +46401,13 @@ async function qpdf(context) {
|
|
|
46350
46401
|
await invocation.close();
|
|
46351
46402
|
}
|
|
46352
46403
|
}
|
|
46353
|
-
function createQpdfCommand(
|
|
46404
|
+
function createQpdfCommand(options = {}) {
|
|
46354
46405
|
return Object.freeze({
|
|
46355
46406
|
name: "qpdf",
|
|
46356
46407
|
runtimeIdentity: commandRuntimeIdentity,
|
|
46357
46408
|
description: "Structural PDF inspection, encryption, page selection, and transformation via @poe-code/pdf-ast",
|
|
46358
46409
|
execute(context) {
|
|
46359
|
-
return qpdf(context);
|
|
46410
|
+
return qpdf(context, options);
|
|
46360
46411
|
}
|
|
46361
46412
|
});
|
|
46362
46413
|
}
|