@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,8 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// packages/safe-bash-command-pdftoppm/dist/index.js
|
|
6
6
|
init_buffer();
|
|
7
|
+
import { yieldTurn, drainCooperativeSteps as drainSteps } from "../safe-bash-contracts/yield.js";
|
|
8
|
+
import { InputByteBudget } from "../safe-bash-contracts/io.js";
|
|
7
9
|
import { writeFileOutput } from "../safe-bash-contracts/filesystem-output-budget.js";
|
|
8
10
|
import {
|
|
9
11
|
commandRuntimeIdentity,
|
|
@@ -44595,7 +44597,8 @@ function extractPdftoppmPositionals(argv) {
|
|
|
44595
44597
|
}
|
|
44596
44598
|
return pos;
|
|
44597
44599
|
}
|
|
44598
|
-
function
|
|
44600
|
+
function* runPdftoppmCliSteps(argv, files, options = {}) {
|
|
44601
|
+
let cooperativeWork = 63;
|
|
44599
44602
|
let format = "ppm";
|
|
44600
44603
|
let explicitContainer;
|
|
44601
44604
|
let colorMode = "rgb";
|
|
@@ -44631,6 +44634,8 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44631
44634
|
let password = "";
|
|
44632
44635
|
const positionals = [];
|
|
44633
44636
|
for (let i = 0; i < argv.length; i++) {
|
|
44637
|
+
if (++cooperativeWork % 64 === 0)
|
|
44638
|
+
yield;
|
|
44634
44639
|
const arg = argv[i];
|
|
44635
44640
|
if (arg === "-v" || arg === "--version") {
|
|
44636
44641
|
return { exitCode: 0, stdout: "pdftoppm version 24.08.0\n", stderr: "" };
|
|
@@ -44674,6 +44679,8 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44674
44679
|
else if (arg === "-jpegopt") {
|
|
44675
44680
|
const optStr = argv[++i] ?? "";
|
|
44676
44681
|
for (const part of optStr.split(",")) {
|
|
44682
|
+
if (++cooperativeWork % 64 === 0)
|
|
44683
|
+
yield;
|
|
44677
44684
|
const eqIdx = part.indexOf("=");
|
|
44678
44685
|
if (eqIdx > 0 && part.slice(0, eqIdx).trim().toLowerCase() === "quality") {
|
|
44679
44686
|
const qVal = Number(part.slice(eqIdx + 1).trim());
|
|
@@ -44795,8 +44802,11 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44795
44802
|
const outChunks = [];
|
|
44796
44803
|
const progressLines = [];
|
|
44797
44804
|
for (let p = firstPage; p <= endPage; p++) {
|
|
44798
|
-
|
|
44799
|
-
if (
|
|
44805
|
+
yield;
|
|
44806
|
+
if (oddOnly && p % 2 === 0)
|
|
44807
|
+
continue;
|
|
44808
|
+
if (evenOnly && p % 2 === 1)
|
|
44809
|
+
continue;
|
|
44800
44810
|
const page = doc.getPage(p - 1);
|
|
44801
44811
|
const displayList = page.evaluateDisplayList({ hideAnnotations });
|
|
44802
44812
|
const box = useCropBox ? getDisplayListCropBox(displayList) : [0, 0, displayList.width, displayList.height];
|
|
@@ -44813,11 +44823,13 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44813
44823
|
} else {
|
|
44814
44824
|
if (scaleToX > 0) {
|
|
44815
44825
|
effDpiX = scaleToX * 72 / Math.max(ptW, 1);
|
|
44816
|
-
if (scaleToY < 0)
|
|
44826
|
+
if (scaleToY < 0)
|
|
44827
|
+
effDpiY = effDpiX;
|
|
44817
44828
|
}
|
|
44818
44829
|
if (scaleToY > 0) {
|
|
44819
44830
|
effDpiY = scaleToY * 72 / Math.max(ptH, 1);
|
|
44820
|
-
if (scaleToX < 0)
|
|
44831
|
+
if (scaleToX < 0)
|
|
44832
|
+
effDpiX = effDpiY;
|
|
44821
44833
|
}
|
|
44822
44834
|
}
|
|
44823
44835
|
const cropRect = hasCrop ? { x: cropX, y: cropY, width: cropW, height: cropH } : void 0;
|
|
@@ -44847,6 +44859,8 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44847
44859
|
options.onAllocateBytes?.(bitmap.width * bitmap.height * 4);
|
|
44848
44860
|
if (colorMode !== "rgb" && (format === "png" || format === "tif" || format === "jpg")) {
|
|
44849
44861
|
for (let px = 0; px < bitmap.data.length; px += 4) {
|
|
44862
|
+
if (++cooperativeWork % 65536 === 0)
|
|
44863
|
+
yield;
|
|
44850
44864
|
const r = bitmap.data[px];
|
|
44851
44865
|
const g = bitmap.data[px + 1];
|
|
44852
44866
|
const b = bitmap.data[px + 2];
|
|
@@ -44857,12 +44871,18 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44857
44871
|
bitmap.data[px + 2] = v;
|
|
44858
44872
|
}
|
|
44859
44873
|
}
|
|
44860
|
-
if (format === "png")
|
|
44861
|
-
|
|
44862
|
-
else if (format === "
|
|
44863
|
-
|
|
44864
|
-
else if (format === "
|
|
44865
|
-
|
|
44874
|
+
if (format === "png")
|
|
44875
|
+
renderedBytes = encodePng(bitmap);
|
|
44876
|
+
else if (format === "tif")
|
|
44877
|
+
renderedBytes = encodeTiff(bitmap, effDpiX, tiffCompression);
|
|
44878
|
+
else if (format === "jpg")
|
|
44879
|
+
renderedBytes = encodeJpeg(bitmap, jpegQuality);
|
|
44880
|
+
else if (format === "pgm")
|
|
44881
|
+
renderedBytes = encodePgm(bitmap);
|
|
44882
|
+
else if (format === "pbm")
|
|
44883
|
+
renderedBytes = encodePbm(bitmap);
|
|
44884
|
+
else
|
|
44885
|
+
renderedBytes = encodePpm(bitmap);
|
|
44866
44886
|
}
|
|
44867
44887
|
options.onAllocateBytes?.(renderedBytes.byteLength);
|
|
44868
44888
|
if (!prefix || prefix === "-") {
|
|
@@ -44872,17 +44892,15 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44872
44892
|
}
|
|
44873
44893
|
} else {
|
|
44874
44894
|
const effectivePageNo = setPageNo !== void 0 ? setPageNo + (p - firstPage) : p;
|
|
44875
|
-
const pageSuffix = String(effectivePageNo).padStart(
|
|
44876
|
-
Math.max(padWidth, String(effectivePageNo).length),
|
|
44877
|
-
"0"
|
|
44878
|
-
);
|
|
44895
|
+
const pageSuffix = String(effectivePageNo).padStart(Math.max(padWidth, String(effectivePageNo).length), "0");
|
|
44879
44896
|
const fileName = singleFile && !forceNum ? `${prefix}.${ext}` : `${prefix}${sep}${pageSuffix}.${ext}`;
|
|
44880
44897
|
files.set(fileName, renderedBytes);
|
|
44881
44898
|
if (progress && !quiet) {
|
|
44882
44899
|
progressLines.push(`${p} ${endPage} ${fileName}`);
|
|
44883
44900
|
}
|
|
44884
44901
|
}
|
|
44885
|
-
if (singleFile)
|
|
44902
|
+
if (singleFile)
|
|
44903
|
+
break;
|
|
44886
44904
|
}
|
|
44887
44905
|
const stderrText = progressLines.length > 0 ? progressLines.join("\n") + "\n" : "";
|
|
44888
44906
|
if (outChunks.length > 0) {
|
|
@@ -44890,6 +44908,8 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44890
44908
|
const merged = new Uint8Array(totalLen);
|
|
44891
44909
|
let off = 0;
|
|
44892
44910
|
for (const c of outChunks) {
|
|
44911
|
+
if (++cooperativeWork % 64 === 0)
|
|
44912
|
+
yield;
|
|
44893
44913
|
merged.set(c, off);
|
|
44894
44914
|
off += c.byteLength;
|
|
44895
44915
|
}
|
|
@@ -44898,9 +44918,18 @@ function runPdftoppmCliSync(argv, files, options = {}) {
|
|
|
44898
44918
|
return { exitCode: 0, stdout: "", stderr: stderrText };
|
|
44899
44919
|
}
|
|
44900
44920
|
async function runPdftoppmCli(argv, files, options = {}) {
|
|
44901
|
-
return
|
|
44921
|
+
return drainSteps(runPdftoppmCliSteps(argv, files, options), options.signal);
|
|
44922
|
+
}
|
|
44923
|
+
function runPdftoppmCliSync(argv, files, options = {}) {
|
|
44924
|
+
const steps = runPdftoppmCliSteps(argv, files, options);
|
|
44925
|
+
let next = steps.next();
|
|
44926
|
+
while (!next.done) {
|
|
44927
|
+
next = steps.next();
|
|
44928
|
+
}
|
|
44929
|
+
return next.value;
|
|
44902
44930
|
}
|
|
44903
44931
|
async function executePdftoppm(context) {
|
|
44932
|
+
let cooperativeWork = 63;
|
|
44904
44933
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
44905
44934
|
} });
|
|
44906
44935
|
try {
|
|
@@ -44921,6 +44950,7 @@ async function executePdftoppm(context) {
|
|
|
44921
44950
|
const chunks = [];
|
|
44922
44951
|
let total = 0;
|
|
44923
44952
|
for await (const chunk of readBytes(context.stdin, invocation.signal)) {
|
|
44953
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44924
44954
|
chunks.push(chunk);
|
|
44925
44955
|
total += chunk.byteLength;
|
|
44926
44956
|
chargeBytes(chunk.byteLength);
|
|
@@ -44929,6 +44959,7 @@ async function executePdftoppm(context) {
|
|
|
44929
44959
|
const buf = new Uint8Array(total);
|
|
44930
44960
|
let off = 0;
|
|
44931
44961
|
for (const c of chunks) {
|
|
44962
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44932
44963
|
buf.set(c, off);
|
|
44933
44964
|
off += c.byteLength;
|
|
44934
44965
|
}
|
|
@@ -44936,6 +44967,7 @@ async function executePdftoppm(context) {
|
|
|
44936
44967
|
}
|
|
44937
44968
|
}
|
|
44938
44969
|
for (const token of positionals) {
|
|
44970
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44939
44971
|
if (token === "-") continue;
|
|
44940
44972
|
try {
|
|
44941
44973
|
const bytes = await context.fs.readFile(resolveVfsPath(token), { signal: invocation.signal });
|
|
@@ -44944,8 +44976,9 @@ async function executePdftoppm(context) {
|
|
|
44944
44976
|
} catch {
|
|
44945
44977
|
}
|
|
44946
44978
|
}
|
|
44979
|
+
context.inputBudget?.check(0);
|
|
44947
44980
|
const existingSnap = new Map(vfsFiles);
|
|
44948
|
-
const res = await runPdftoppmCli(argv, vfsFiles, { onAllocateBytes: chargeBytes });
|
|
44981
|
+
const res = await runPdftoppmCli(argv, vfsFiles, { onAllocateBytes: chargeBytes, signal: invocation.signal });
|
|
44949
44982
|
if (res.stderr) {
|
|
44950
44983
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
44951
44984
|
}
|
|
@@ -44957,6 +44990,7 @@ async function executePdftoppm(context) {
|
|
|
44957
44990
|
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
44958
44991
|
}
|
|
44959
44992
|
for (const [key, val] of vfsFiles.entries()) {
|
|
44993
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
44960
44994
|
if (key !== "-" && existingSnap.get(key) !== val) {
|
|
44961
44995
|
const abs = resolveVfsPath(key);
|
|
44962
44996
|
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
@@ -44972,13 +45006,14 @@ async function executePdftoppm(context) {
|
|
|
44972
45006
|
await invocation.close();
|
|
44973
45007
|
}
|
|
44974
45008
|
}
|
|
44975
|
-
function createPdftoppmCommand(
|
|
45009
|
+
function createPdftoppmCommand(options = {}) {
|
|
45010
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
44976
45011
|
return Object.freeze({
|
|
44977
45012
|
name: "pdftoppm",
|
|
44978
45013
|
runtimeIdentity: commandRuntimeIdentity,
|
|
44979
45014
|
description: "Render PDF pages to PNG, PPM, PGM, PBM, or SVG via @poe-code/pdf-ast",
|
|
44980
45015
|
execute(context) {
|
|
44981
|
-
return
|
|
45016
|
+
return new InputByteBudget(maxInputBytes).run(context, executePdftoppm);
|
|
44982
45017
|
}
|
|
44983
45018
|
});
|
|
44984
45019
|
}
|
|
@@ -45014,7 +45049,8 @@ function extractPdftocairoPositionals(argv) {
|
|
|
45014
45049
|
}
|
|
45015
45050
|
return pos;
|
|
45016
45051
|
}
|
|
45017
|
-
function
|
|
45052
|
+
function* runPdftocairoCliSteps(argv, files, options = {}) {
|
|
45053
|
+
let cooperativeWork = 63;
|
|
45018
45054
|
let format = "png";
|
|
45019
45055
|
let grayMode = false;
|
|
45020
45056
|
let monoMode = false;
|
|
@@ -45035,6 +45071,8 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45035
45071
|
const forwardedArgs = [];
|
|
45036
45072
|
const positionals = [];
|
|
45037
45073
|
for (let i = 0; i < argv.length; i++) {
|
|
45074
|
+
if (++cooperativeWork % 64 === 0)
|
|
45075
|
+
yield;
|
|
45038
45076
|
const arg = argv[i];
|
|
45039
45077
|
if (arg === "-v" || arg === "--version") {
|
|
45040
45078
|
return { exitCode: 0, stdout: "pdftocairo version 24.08.0\n", stderr: "" };
|
|
@@ -45115,8 +45153,10 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45115
45153
|
} else if (VALUE_FLAGS.has(arg)) {
|
|
45116
45154
|
const val = argv[++i] ?? "";
|
|
45117
45155
|
forwardedArgs.push(arg, val);
|
|
45118
|
-
if (arg === "-f")
|
|
45119
|
-
|
|
45156
|
+
if (arg === "-f")
|
|
45157
|
+
firstPage = Math.max(1, Number.parseInt(val, 10) || 1);
|
|
45158
|
+
else if (arg === "-l")
|
|
45159
|
+
lastPage = Math.max(0, Number.parseInt(val, 10) || 0);
|
|
45120
45160
|
else if (arg === "-x") {
|
|
45121
45161
|
cropX = Math.max(0, Number.parseInt(val, 10) || 0);
|
|
45122
45162
|
hasCrop = true;
|
|
@@ -45138,8 +45178,10 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45138
45178
|
password = val;
|
|
45139
45179
|
}
|
|
45140
45180
|
} else if (arg.startsWith("-") && arg !== "-") {
|
|
45141
|
-
if (arg === "-o")
|
|
45142
|
-
|
|
45181
|
+
if (arg === "-o")
|
|
45182
|
+
oddOnly = true;
|
|
45183
|
+
if (arg === "-e")
|
|
45184
|
+
evenOnly = true;
|
|
45143
45185
|
forwardedArgs.push(arg);
|
|
45144
45186
|
} else {
|
|
45145
45187
|
positionals.push(arg);
|
|
@@ -45153,7 +45195,7 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45153
45195
|
if (format === "svg") {
|
|
45154
45196
|
const rawOut = positionals[1] ?? (inputPath === "-" ? "-" : `${inputStem}.svg`);
|
|
45155
45197
|
const rootForSvg = rawOut.toLowerCase().endsWith(".svg") ? rawOut.slice(0, -4) : rawOut;
|
|
45156
|
-
return
|
|
45198
|
+
return yield* runPdftoppmCliSteps(["-svg", "-singlefile", ...forwardedArgs, inputPath, rootForSvg], files, options);
|
|
45157
45199
|
}
|
|
45158
45200
|
if (format === "pdf" || format === "ps" || format === "eps") {
|
|
45159
45201
|
const pdfBytes = files.get(inputPath);
|
|
@@ -45180,8 +45222,11 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45180
45222
|
}
|
|
45181
45223
|
const selectedIndices = [];
|
|
45182
45224
|
for (let p = firstPage; p <= endPage; p++) {
|
|
45183
|
-
|
|
45184
|
-
if (
|
|
45225
|
+
yield;
|
|
45226
|
+
if (oddOnly && p % 2 === 0)
|
|
45227
|
+
continue;
|
|
45228
|
+
if (evenOnly && p % 2 !== 0)
|
|
45229
|
+
continue;
|
|
45185
45230
|
selectedIndices.push(p - 1);
|
|
45186
45231
|
}
|
|
45187
45232
|
const rawOut = positionals[1] ?? (inputPath === "-" ? "-" : `${inputStem}.${format}`);
|
|
@@ -45189,29 +45234,29 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45189
45234
|
if (format === "pdf") {
|
|
45190
45235
|
const outDoc = PdfDocument.create();
|
|
45191
45236
|
const srcMeta = doc.getMetadata();
|
|
45192
|
-
if (srcMeta.title)
|
|
45193
|
-
|
|
45194
|
-
if (srcMeta.
|
|
45195
|
-
|
|
45196
|
-
if (srcMeta.
|
|
45197
|
-
|
|
45237
|
+
if (srcMeta.title)
|
|
45238
|
+
outDoc.setTitle(srcMeta.title);
|
|
45239
|
+
if (srcMeta.author)
|
|
45240
|
+
outDoc.setAuthor(srcMeta.author);
|
|
45241
|
+
if (srcMeta.subject)
|
|
45242
|
+
outDoc.setSubject(srcMeta.subject);
|
|
45243
|
+
if (srcMeta.keywords)
|
|
45244
|
+
outDoc.setKeywords(srcMeta.keywords);
|
|
45245
|
+
if (srcMeta.creator)
|
|
45246
|
+
outDoc.setCreator(srcMeta.creator);
|
|
45247
|
+
if (srcMeta.producer)
|
|
45248
|
+
outDoc.setProducer(srcMeta.producer);
|
|
45198
45249
|
const hasPaper = !origPageSizes && paperW > 0 && paperH > 0;
|
|
45199
45250
|
for (const idx of selectedIndices) {
|
|
45251
|
+
if (++cooperativeWork % 64 === 0)
|
|
45252
|
+
yield;
|
|
45200
45253
|
const [copied] = outDoc.copyPagesFrom(doc, [idx]);
|
|
45201
45254
|
if (copied && (hasCrop || hasPaper)) {
|
|
45202
45255
|
const origSize = copied.getSize();
|
|
45203
45256
|
const effW = hasPaper ? paperW : cropW > 0 ? cropW : Math.max(1, origSize.width - cropX);
|
|
45204
45257
|
const effH = hasPaper ? paperH : cropH > 0 ? cropH : Math.max(1, origSize.height - cropY);
|
|
45205
|
-
dictSet(
|
|
45206
|
-
|
|
45207
|
-
"MediaBox",
|
|
45208
|
-
cosArray([cosNumber(0), cosNumber(0), cosNumber(effW), cosNumber(effH)])
|
|
45209
|
-
);
|
|
45210
|
-
dictSet(
|
|
45211
|
-
copied.pageDict,
|
|
45212
|
-
"CropBox",
|
|
45213
|
-
cosArray([cosNumber(0), cosNumber(0), cosNumber(effW), cosNumber(effH)])
|
|
45214
|
-
);
|
|
45258
|
+
dictSet(copied.pageDict, "MediaBox", cosArray([cosNumber(0), cosNumber(0), cosNumber(effW), cosNumber(effH)]));
|
|
45259
|
+
dictSet(copied.pageDict, "CropBox", cosArray([cosNumber(0), cosNumber(0), cosNumber(effW), cosNumber(effH)]));
|
|
45215
45260
|
}
|
|
45216
45261
|
}
|
|
45217
45262
|
const outBytes = outDoc.save();
|
|
@@ -45233,12 +45278,18 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45233
45278
|
"%%EndComments"
|
|
45234
45279
|
];
|
|
45235
45280
|
for (let s = 0; s < selectedIndices.length; s++) {
|
|
45281
|
+
if (++cooperativeWork % 64 === 0)
|
|
45282
|
+
yield;
|
|
45236
45283
|
const page = doc.getPage(selectedIndices[s]);
|
|
45237
45284
|
psLines.push(`%%Page: ${s + 1} ${s + 1}`);
|
|
45238
45285
|
psLines.push("/Helvetica findfont 12 scalefont setfont");
|
|
45239
45286
|
const extracted = page.extractPage();
|
|
45240
45287
|
for (const block of extracted.blocks) {
|
|
45288
|
+
if (++cooperativeWork % 64 === 0)
|
|
45289
|
+
yield;
|
|
45241
45290
|
for (const line of block.lines) {
|
|
45291
|
+
if (++cooperativeWork % 64 === 0)
|
|
45292
|
+
yield;
|
|
45242
45293
|
const escaped = line.text.replaceAll("\\", "\\\\").replaceAll("(", "\\(").replaceAll(")", "\\)");
|
|
45243
45294
|
psLines.push(`${Math.round(line.bbox[0])} ${Math.round(line.bbox[1])} moveto (${escaped}) show`);
|
|
45244
45295
|
}
|
|
@@ -45255,7 +45306,7 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45255
45306
|
}
|
|
45256
45307
|
const snapBefore = new Map(files);
|
|
45257
45308
|
const rasterPositionals = positionals.length === 1 && inputPath !== "-" ? [inputPath, inputStem] : positionals;
|
|
45258
|
-
const res =
|
|
45309
|
+
const res = yield* runPdftoppmCliSteps([...forwardedArgs, ...rasterPositionals], files, options);
|
|
45259
45310
|
if (res.exitCode !== 0 || !grayMode && !monoMode) {
|
|
45260
45311
|
return res;
|
|
45261
45312
|
}
|
|
@@ -45269,6 +45320,8 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45269
45320
|
}
|
|
45270
45321
|
};
|
|
45271
45322
|
for (const [k, v] of files.entries()) {
|
|
45323
|
+
if (++cooperativeWork % 64 === 0)
|
|
45324
|
+
yield;
|
|
45272
45325
|
if (snapBefore.get(k) !== v && k.endsWith(".png")) {
|
|
45273
45326
|
const decoded = decodePng(v);
|
|
45274
45327
|
convertRgbaInPlace(decoded.data);
|
|
@@ -45278,83 +45331,100 @@ function runPdftocairoCliSync(argv, files, options = {}) {
|
|
|
45278
45331
|
return res;
|
|
45279
45332
|
}
|
|
45280
45333
|
async function runPdftocairoCli(argv, files, options = {}) {
|
|
45281
|
-
return
|
|
45334
|
+
return drainSteps(runPdftocairoCliSteps(argv, files, options), options.signal);
|
|
45282
45335
|
}
|
|
45283
|
-
function
|
|
45336
|
+
function runPdftocairoCliSync(argv, files, options = {}) {
|
|
45337
|
+
const steps = runPdftocairoCliSteps(argv, files, options);
|
|
45338
|
+
let next = steps.next();
|
|
45339
|
+
while (!next.done) {
|
|
45340
|
+
next = steps.next();
|
|
45341
|
+
}
|
|
45342
|
+
return next.value;
|
|
45343
|
+
}
|
|
45344
|
+
function createPdftocairoCommand(options = {}) {
|
|
45345
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
45284
45346
|
return Object.freeze({
|
|
45285
45347
|
name: "pdftocairo",
|
|
45286
45348
|
runtimeIdentity: commandRuntimeIdentity,
|
|
45287
45349
|
description: "Render PDF pages to PNG, JPEG, TIFF, PDF, PS, EPS, or SVG via @poe-code/pdf-ast",
|
|
45288
45350
|
async execute(context) {
|
|
45289
|
-
|
|
45290
|
-
|
|
45291
|
-
|
|
45292
|
-
|
|
45293
|
-
|
|
45294
|
-
|
|
45295
|
-
|
|
45296
|
-
|
|
45297
|
-
|
|
45298
|
-
|
|
45299
|
-
|
|
45300
|
-
|
|
45301
|
-
|
|
45302
|
-
|
|
45303
|
-
|
|
45304
|
-
|
|
45305
|
-
const
|
|
45306
|
-
|
|
45307
|
-
|
|
45308
|
-
|
|
45309
|
-
|
|
45310
|
-
|
|
45311
|
-
|
|
45312
|
-
|
|
45313
|
-
|
|
45314
|
-
|
|
45315
|
-
|
|
45316
|
-
buf
|
|
45317
|
-
off
|
|
45351
|
+
return new InputByteBudget(maxInputBytes).run(context, async (context2) => {
|
|
45352
|
+
let cooperativeWork = 63;
|
|
45353
|
+
const invocation = createOutputOperation(context2, { write: async () => {
|
|
45354
|
+
} });
|
|
45355
|
+
try {
|
|
45356
|
+
const carrier = getCommandArguments(context2);
|
|
45357
|
+
const argv = [...carrier.args];
|
|
45358
|
+
const vfsFiles = /* @__PURE__ */ new Map();
|
|
45359
|
+
const resolveVfsPath = (p) => p.startsWith("/") ? p : `${context2.cwd === "/" ? "" : context2.cwd}/${p}`;
|
|
45360
|
+
let accountedBytes = 0;
|
|
45361
|
+
const chargeBytes = (delta) => {
|
|
45362
|
+
if (delta > 0) {
|
|
45363
|
+
accountedBytes += delta;
|
|
45364
|
+
context2.inputBudget?.check(accountedBytes);
|
|
45365
|
+
}
|
|
45366
|
+
};
|
|
45367
|
+
const positionals = extractPdftocairoPositionals(argv);
|
|
45368
|
+
if (positionals.length === 0 || positionals[0] === "-") {
|
|
45369
|
+
const chunks = [];
|
|
45370
|
+
let total = 0;
|
|
45371
|
+
for await (const chunk of readBytes(context2.stdin, invocation.signal)) {
|
|
45372
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context2.signal);
|
|
45373
|
+
chunks.push(chunk);
|
|
45374
|
+
total += chunk.byteLength;
|
|
45375
|
+
chargeBytes(chunk.byteLength);
|
|
45376
|
+
}
|
|
45377
|
+
if (total > 0) {
|
|
45378
|
+
const buf = new Uint8Array(total);
|
|
45379
|
+
let off = 0;
|
|
45380
|
+
for (const c of chunks) {
|
|
45381
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context2.signal);
|
|
45382
|
+
buf.set(c, off);
|
|
45383
|
+
off += c.byteLength;
|
|
45384
|
+
}
|
|
45385
|
+
vfsFiles.set("-", buf);
|
|
45318
45386
|
}
|
|
45319
|
-
vfsFiles.set("-", buf);
|
|
45320
45387
|
}
|
|
45321
|
-
|
|
45322
|
-
|
|
45323
|
-
|
|
45324
|
-
try {
|
|
45325
|
-
const bytes = await context.fs.readFile(resolveVfsPath(token), { signal: invocation.signal });
|
|
45326
|
-
chargeBytes(bytes.byteLength);
|
|
45327
|
-
vfsFiles.set(token, bytes);
|
|
45328
|
-
} catch {
|
|
45329
|
-
}
|
|
45330
|
-
}
|
|
45331
|
-
const existingSnap = new Map(vfsFiles);
|
|
45332
|
-
const res = await runPdftocairoCli(argv, vfsFiles, { onAllocateBytes: chargeBytes });
|
|
45333
|
-
if (res.stderr) {
|
|
45334
|
-
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
45335
|
-
}
|
|
45336
|
-
if (res.stdoutBytes) {
|
|
45337
|
-
const stdout = invocation.child(context.stdout);
|
|
45338
|
-
await writeBytes(stdout.output, res.stdoutBytes, invocation.signal);
|
|
45339
|
-
} else if (res.stdout) {
|
|
45340
|
-
const stdout = invocation.child(context.stdout);
|
|
45341
|
-
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
45342
|
-
}
|
|
45343
|
-
for (const [key, val] of vfsFiles.entries()) {
|
|
45344
|
-
if (key !== "-" && existingSnap.get(key) !== val) {
|
|
45345
|
-
const abs = resolveVfsPath(key);
|
|
45346
|
-
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
45388
|
+
for (const token of positionals) {
|
|
45389
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context2.signal);
|
|
45390
|
+
if (token === "-") continue;
|
|
45347
45391
|
try {
|
|
45348
|
-
await
|
|
45392
|
+
const bytes = await context2.fs.readFile(resolveVfsPath(token), { signal: invocation.signal });
|
|
45393
|
+
chargeBytes(bytes.byteLength);
|
|
45394
|
+
vfsFiles.set(token, bytes);
|
|
45349
45395
|
} catch {
|
|
45350
45396
|
}
|
|
45351
|
-
await writeFileOutput(context, val, (data) => context.fs.writeFile(abs, data, { signal: invocation.signal }));
|
|
45352
45397
|
}
|
|
45398
|
+
context2.inputBudget?.check(0);
|
|
45399
|
+
const existingSnap = new Map(vfsFiles);
|
|
45400
|
+
const res = await runPdftocairoCli(argv, vfsFiles, { onAllocateBytes: chargeBytes, signal: invocation.signal });
|
|
45401
|
+
if (res.stderr) {
|
|
45402
|
+
await writeBytes(context2.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
45403
|
+
}
|
|
45404
|
+
if (res.stdoutBytes) {
|
|
45405
|
+
const stdout = invocation.child(context2.stdout);
|
|
45406
|
+
await writeBytes(stdout.output, res.stdoutBytes, invocation.signal);
|
|
45407
|
+
} else if (res.stdout) {
|
|
45408
|
+
const stdout = invocation.child(context2.stdout);
|
|
45409
|
+
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
45410
|
+
}
|
|
45411
|
+
for (const [key, val] of vfsFiles.entries()) {
|
|
45412
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context2.signal);
|
|
45413
|
+
if (key !== "-" && existingSnap.get(key) !== val) {
|
|
45414
|
+
const abs = resolveVfsPath(key);
|
|
45415
|
+
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
45416
|
+
try {
|
|
45417
|
+
await context2.fs.mkdir(parentDir, { recursive: true, signal: invocation.signal });
|
|
45418
|
+
} catch {
|
|
45419
|
+
}
|
|
45420
|
+
await writeFileOutput(context2, val, (data) => context2.fs.writeFile(abs, data, { signal: invocation.signal }));
|
|
45421
|
+
}
|
|
45422
|
+
}
|
|
45423
|
+
return { exitCode: res.exitCode };
|
|
45424
|
+
} finally {
|
|
45425
|
+
await invocation.close();
|
|
45353
45426
|
}
|
|
45354
|
-
|
|
45355
|
-
} finally {
|
|
45356
|
-
await invocation.close();
|
|
45357
|
-
}
|
|
45427
|
+
});
|
|
45358
45428
|
}
|
|
45359
45429
|
});
|
|
45360
45430
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type CommandContext, type CommandDefinition } from "../safe-bash-contracts/command.js";
|
|
2
2
|
import type { VirtualShellPlugin } from "../safe-bash-contracts/plugin.js";
|
|
3
|
+
export interface PdftotextLimits {
|
|
4
|
+
readonly maxInputBytes: number;
|
|
5
|
+
}
|
|
3
6
|
export interface PdftotextCommandOptions {
|
|
7
|
+
readonly limits?: Partial<PdftotextLimits>;
|
|
4
8
|
readonly replace?: boolean;
|
|
5
9
|
}
|
|
6
10
|
export interface PdftotextCliResult {
|
|
@@ -10,18 +14,18 @@ export interface PdftotextCliResult {
|
|
|
10
14
|
readonly outputPath: string;
|
|
11
15
|
}
|
|
12
16
|
export declare function extractPdfToTextBytes(bytes: Uint8Array, argv?: readonly string[]): PdftotextCliResult;
|
|
13
|
-
export declare function runPdftotextCli(argv: readonly string[], files: ReadonlyMap<string, Uint8Array>, stdinBytes?: Uint8Array): Promise<PdftotextCliResult>;
|
|
17
|
+
export declare function runPdftotextCli(argv: readonly string[], files: ReadonlyMap<string, Uint8Array>, stdinBytes?: Uint8Array, signal?: AbortSignal): Promise<PdftotextCliResult>;
|
|
14
18
|
export declare function pdftotext(context: CommandContext): Promise<{
|
|
15
19
|
exitCode: number;
|
|
16
20
|
}>;
|
|
17
|
-
export declare function createPdftotextCommand(
|
|
21
|
+
export declare function createPdftotextCommand(options?: PdftotextCommandOptions): CommandDefinition;
|
|
18
22
|
export declare const pdftotextCommand: CommandDefinition;
|
|
19
|
-
export declare function runPdftohtmlCli(argv: readonly string[], files: Map<string, Uint8Array
|
|
23
|
+
export declare function runPdftohtmlCli(argv: readonly string[], files: Map<string, Uint8Array>, signal?: AbortSignal): Promise<{
|
|
20
24
|
exitCode: number;
|
|
21
25
|
stdout: string;
|
|
22
26
|
stderr: string;
|
|
23
27
|
}>;
|
|
24
|
-
export declare function runPdftohtmlCliSync(argv: readonly string[], files: Map<string, Uint8Array
|
|
28
|
+
export declare function runPdftohtmlCliSync(argv: readonly string[], files: Map<string, Uint8Array>, signal?: AbortSignal): {
|
|
25
29
|
exitCode: number;
|
|
26
30
|
stdout: string;
|
|
27
31
|
stderr: string;
|
|
@@ -29,7 +33,7 @@ export declare function runPdftohtmlCliSync(argv: readonly string[], files: Map<
|
|
|
29
33
|
export declare function pdftohtml(context: CommandContext): Promise<{
|
|
30
34
|
exitCode: number;
|
|
31
35
|
}>;
|
|
32
|
-
export declare function createPdftohtmlCommand(
|
|
36
|
+
export declare function createPdftohtmlCommand(options?: PdftotextCommandOptions): CommandDefinition;
|
|
33
37
|
export declare const pdftohtmlCommand: CommandDefinition;
|
|
34
38
|
export declare function pdftotextCommands(options?: PdftotextCommandsOptions): VirtualShellPlugin;
|
|
35
39
|
export type PdftotextCommandsOptions = PdftotextCommandOptions;
|