@poe-platform/safe-bash 0.1.788 → 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-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-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-YNT4ZJHW.js → chunk-AT6ZSOE6.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-KSIGF4AG.js → chunk-BK4CMEE6.js} +1 -1
- 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-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-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-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-query-engine/index.js +4 -4
- package/dist/safe-bash-query-engine/interpreter.js +2 -2
- package/dist/safe-bash-query-engine/query-core.js +4 -4
- package/package.json +2 -2
- 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-RTOJNFFL.js → chunk-BJ6DGYJA.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DEH3CMGL.js → chunk-QJ3ONEBI.js} +3 -3
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
|
|
20
20
|
// packages/safe-bash-command-sips/dist/index.js
|
|
21
21
|
init_buffer();
|
|
22
|
+
import { yieldTurn, drainCooperativeSteps as drainSteps } from "../safe-bash-contracts/yield.js";
|
|
23
|
+
import { InputByteBudget } from "../safe-bash-contracts/io.js";
|
|
22
24
|
import { writeFileOutput } from "../safe-bash-contracts/filesystem-output-budget.js";
|
|
23
25
|
import {
|
|
24
26
|
commandRuntimeIdentity,
|
|
@@ -185,10 +187,8 @@ function applySipsOddCanvasCropOrPad(image, curW, curH, dstW, dstH, padColorInpu
|
|
|
185
187
|
}
|
|
186
188
|
return decodeImage(out, { raw: { width: dstW, height: dstH, channels: ch } });
|
|
187
189
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
function runSipsCliSync(argv, files) {
|
|
190
|
+
function* runSipsCliSteps(argv, files, signal) {
|
|
191
|
+
let cooperativeWork = 63;
|
|
192
192
|
if (argv.length === 0) {
|
|
193
193
|
return {
|
|
194
194
|
exitCode: 1,
|
|
@@ -211,6 +211,8 @@ function runSipsCliSync(argv, files) {
|
|
|
211
211
|
const actions = [];
|
|
212
212
|
const inputPaths = [];
|
|
213
213
|
for (let i = 0; i < argv.length; i++) {
|
|
214
|
+
if (++cooperativeWork % 64 === 0)
|
|
215
|
+
yield;
|
|
214
216
|
const arg = argv[i];
|
|
215
217
|
if (arg === "-h" || arg === "--help") {
|
|
216
218
|
return {
|
|
@@ -406,10 +408,7 @@ function runSipsCliSync(argv, files) {
|
|
|
406
408
|
const outLines = [];
|
|
407
409
|
const errLines = [];
|
|
408
410
|
let exitCode = 0;
|
|
409
|
-
const lastCropPadIdx = actions.reduce(
|
|
410
|
-
(acc, act, idx) => act.kind === "crop" || act.kind === "pad" ? idx : acc,
|
|
411
|
-
-1
|
|
412
|
-
);
|
|
411
|
+
const lastCropPadIdx = actions.reduce((acc, act, idx) => act.kind === "crop" || act.kind === "pad" ? idx : acc, -1);
|
|
413
412
|
const hasResampleW = actions.some((act) => act.kind === "resampleW");
|
|
414
413
|
const filteredActions = actions.filter((act, idx) => {
|
|
415
414
|
if ((act.kind === "crop" || act.kind === "pad") && idx !== lastCropPadIdx) {
|
|
@@ -443,6 +442,7 @@ function runSipsCliSync(argv, files) {
|
|
|
443
442
|
];
|
|
444
443
|
}
|
|
445
444
|
for (const inPath of inputPaths) {
|
|
445
|
+
yield;
|
|
446
446
|
const inBytes = files.get(inPath);
|
|
447
447
|
if (!inBytes) {
|
|
448
448
|
errLines.push(`Error: ${inPath}: file does not exist`);
|
|
@@ -452,6 +452,8 @@ function runSipsCliSync(argv, files) {
|
|
|
452
452
|
try {
|
|
453
453
|
const mergedProps = new Map(SIPS_BUFFER_PROPS.get(inBytes) ?? SIPS_CONTENT_PROPS.get(imageFingerprint(inBytes)) ?? []);
|
|
454
454
|
for (const [k, v] of customSetProps) {
|
|
455
|
+
if (++cooperativeWork % 64 === 0)
|
|
456
|
+
yield;
|
|
455
457
|
mergedProps.set(k, v);
|
|
456
458
|
}
|
|
457
459
|
let meta = readImageMetadata(inBytes);
|
|
@@ -464,6 +466,7 @@ function runSipsCliSync(argv, files) {
|
|
|
464
466
|
let image = decodeImage(inBytes);
|
|
465
467
|
let resizeInput;
|
|
466
468
|
for (const act of effectiveActions) {
|
|
469
|
+
yield;
|
|
467
470
|
if (act.kind === "rotate") {
|
|
468
471
|
const rotated = encodeImage(rotateImage(image, act.degrees, parseColor(effectivePadColor)), {}).data;
|
|
469
472
|
image = decodeImage(rotated);
|
|
@@ -501,14 +504,7 @@ function runSipsCliSync(argv, files) {
|
|
|
501
504
|
curH = nh;
|
|
502
505
|
} else if (act.kind === "crop") {
|
|
503
506
|
if (cropOffsetX === void 0 && cropOffsetY === void 0 && ((act.width - curW) % 2 !== 0 || (act.height - curH) % 2 !== 0)) {
|
|
504
|
-
image = applySipsOddCanvasCropOrPad(
|
|
505
|
-
image,
|
|
506
|
-
curW,
|
|
507
|
-
curH,
|
|
508
|
-
act.width,
|
|
509
|
-
act.height,
|
|
510
|
-
effectivePadColor
|
|
511
|
-
);
|
|
507
|
+
image = applySipsOddCanvasCropOrPad(image, curW, curH, act.width, act.height, effectivePadColor);
|
|
512
508
|
curW = act.width;
|
|
513
509
|
curH = act.height;
|
|
514
510
|
resizeInput = void 0;
|
|
@@ -573,14 +569,7 @@ function runSipsCliSync(argv, files) {
|
|
|
573
569
|
resizeInput = void 0;
|
|
574
570
|
} else if (act.kind === "pad") {
|
|
575
571
|
if ((act.width - curW) % 2 !== 0 || (act.height - curH) % 2 !== 0) {
|
|
576
|
-
image = applySipsOddCanvasCropOrPad(
|
|
577
|
-
image,
|
|
578
|
-
curW,
|
|
579
|
-
curH,
|
|
580
|
-
act.width,
|
|
581
|
-
act.height,
|
|
582
|
-
effectivePadColor
|
|
583
|
-
);
|
|
572
|
+
image = applySipsOddCanvasCropOrPad(image, curW, curH, act.width, act.height, effectivePadColor);
|
|
584
573
|
curW = act.width;
|
|
585
574
|
curH = act.height;
|
|
586
575
|
resizeInput = void 0;
|
|
@@ -640,6 +629,8 @@ function runSipsCliSync(argv, files) {
|
|
|
640
629
|
const normTarget = outTarget.endsWith("/") ? outTarget.slice(0, -1) : outTarget;
|
|
641
630
|
let isExistingDir = false;
|
|
642
631
|
for (const k of files.keys()) {
|
|
632
|
+
if (++cooperativeWork % 64 === 0)
|
|
633
|
+
yield;
|
|
643
634
|
if (k.startsWith(`${normTarget}/`)) {
|
|
644
635
|
isExistingDir = true;
|
|
645
636
|
break;
|
|
@@ -699,23 +690,27 @@ function runSipsCliSync(argv, files) {
|
|
|
699
690
|
` <key>path</key>
|
|
700
691
|
<string>${escapeXml(inPath)}</string>`
|
|
701
692
|
].join("\n");
|
|
702
|
-
outLines.push(
|
|
703
|
-
`<?xml version="1.0" encoding="UTF-8"?>
|
|
693
|
+
outLines.push(`<?xml version="1.0" encoding="UTF-8"?>
|
|
704
694
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
705
695
|
<plist version="1.0">
|
|
706
696
|
<dict>
|
|
707
697
|
${xmlEntries}
|
|
708
698
|
</dict>
|
|
709
|
-
</plist>`
|
|
710
|
-
);
|
|
699
|
+
</plist>`);
|
|
711
700
|
} else {
|
|
712
701
|
const expandedKeys = [];
|
|
713
702
|
for (const k of getProperties) {
|
|
714
|
-
if (
|
|
715
|
-
|
|
703
|
+
if (++cooperativeWork % 64 === 0)
|
|
704
|
+
yield;
|
|
705
|
+
if (k === "all")
|
|
706
|
+
expandedKeys.push(...ALL_SIPS_KEYS);
|
|
707
|
+
else
|
|
708
|
+
expandedKeys.push(k);
|
|
716
709
|
}
|
|
717
710
|
const propLines = [inPath];
|
|
718
711
|
for (const k of expandedKeys) {
|
|
712
|
+
if (++cooperativeWork % 64 === 0)
|
|
713
|
+
yield;
|
|
719
714
|
const val = formatSipsPropertyValue(meta, k, mergedProps, inPath);
|
|
720
715
|
if (val !== void 0) {
|
|
721
716
|
propLines.push(singleLine ? `${k}: ${val}` : ` ${k}: ${val}`);
|
|
@@ -741,6 +736,17 @@ ${xmlEntries}
|
|
|
741
736
|
stderr: errLines.length > 0 ? errLines.join("\n") + "\n" : ""
|
|
742
737
|
};
|
|
743
738
|
}
|
|
739
|
+
async function runSipsCli(argv, files, signal) {
|
|
740
|
+
return drainSteps(runSipsCliSteps(argv, files, signal), signal);
|
|
741
|
+
}
|
|
742
|
+
function runSipsCliSync(argv, files, signal) {
|
|
743
|
+
const steps = runSipsCliSteps(argv, files, signal);
|
|
744
|
+
let next = steps.next();
|
|
745
|
+
while (!next.done) {
|
|
746
|
+
next = steps.next();
|
|
747
|
+
}
|
|
748
|
+
return next.value;
|
|
749
|
+
}
|
|
744
750
|
function formatIdentifyCustom(fmt, filePath, meta, byteSize) {
|
|
745
751
|
const lastSlash = filePath.lastIndexOf("/");
|
|
746
752
|
const dirName = lastSlash > 0 ? filePath.slice(0, lastSlash) : lastSlash === 0 ? "/" : ".";
|
|
@@ -929,11 +935,14 @@ function formatIdentifyCustom(fmt, filePath, meta, byteSize) {
|
|
|
929
935
|
}
|
|
930
936
|
return out;
|
|
931
937
|
}
|
|
932
|
-
|
|
938
|
+
function* runIdentifyCliSteps(argv, files, signal) {
|
|
939
|
+
let cooperativeWork = 63;
|
|
933
940
|
let customFormat;
|
|
934
941
|
let verbose = false;
|
|
935
942
|
const inputPaths = [];
|
|
936
943
|
for (let i = 0; i < argv.length; i++) {
|
|
944
|
+
if (++cooperativeWork % 64 === 0)
|
|
945
|
+
yield;
|
|
937
946
|
const arg = argv[i];
|
|
938
947
|
if (arg === "-h" || arg === "-help" || arg === "--help") {
|
|
939
948
|
return {
|
|
@@ -965,6 +974,7 @@ async function runIdentifyCli(argv, files) {
|
|
|
965
974
|
const errParts = [];
|
|
966
975
|
let exitCode = 0;
|
|
967
976
|
for (const inPath of inputPaths) {
|
|
977
|
+
yield;
|
|
968
978
|
const bracketMatch = /^(.*)\[(\d+)\]$/.exec(inPath);
|
|
969
979
|
const baseInPath = bracketMatch ? bracketMatch[1] : inPath;
|
|
970
980
|
const pageIdx = bracketMatch ? parseInt(bracketMatch[2], 10) : void 0;
|
|
@@ -984,8 +994,7 @@ async function runIdentifyCli(argv, files) {
|
|
|
984
994
|
outParts.push(formatIdentifyCustom(customFormat, baseInPath, meta, bytes.byteLength));
|
|
985
995
|
} else if (verbose) {
|
|
986
996
|
const stats = computeImageStats(decodeImage(bytes, inputOptions));
|
|
987
|
-
outParts.push(
|
|
988
|
-
`Image: ${inPath}
|
|
997
|
+
outParts.push(`Image: ${inPath}
|
|
989
998
|
Format: ${meta.format.toUpperCase()}
|
|
990
999
|
Geometry: ${meta.width}x${meta.height}+0+0
|
|
991
1000
|
Resolution: ${meta.density}x${meta.density}
|
|
@@ -995,13 +1004,10 @@ async function runIdentifyCli(argv, files) {
|
|
|
995
1004
|
Alpha: ${meta.hasAlpha ? "True" : "False"}
|
|
996
1005
|
Filesize: ${bytes.byteLength}B
|
|
997
1006
|
Entropy: ${stats.entropy.toFixed(4)}
|
|
998
|
-
`
|
|
999
|
-
);
|
|
1007
|
+
`);
|
|
1000
1008
|
} else {
|
|
1001
|
-
outParts.push(
|
|
1002
|
-
|
|
1003
|
-
`
|
|
1004
|
-
);
|
|
1009
|
+
outParts.push(`${inPath} ${meta.format.toUpperCase()} ${meta.width}x${meta.height} ${meta.width}x${meta.height}+0+0 ${bitDepth}-bit ${spaceLabel} ${bytes.byteLength}B 0.000u 0:00.000
|
|
1010
|
+
`);
|
|
1005
1011
|
}
|
|
1006
1012
|
} catch (err) {
|
|
1007
1013
|
errParts.push(`identify: improper image header '${inPath}': ${err.message}
|
|
@@ -1015,7 +1021,11 @@ async function runIdentifyCli(argv, files) {
|
|
|
1015
1021
|
stderr: errParts.join("")
|
|
1016
1022
|
};
|
|
1017
1023
|
}
|
|
1024
|
+
async function runIdentifyCli(argv, files, signal) {
|
|
1025
|
+
return drainSteps(runIdentifyCliSteps(argv, files, signal), signal);
|
|
1026
|
+
}
|
|
1018
1027
|
async function executeVfsImageTool(context, runner) {
|
|
1028
|
+
let cooperativeWork = 63;
|
|
1019
1029
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
1020
1030
|
} });
|
|
1021
1031
|
try {
|
|
@@ -1025,6 +1035,7 @@ async function executeVfsImageTool(context, runner) {
|
|
|
1025
1035
|
const resolveVfsPath = (p) => p.startsWith("/") ? p : `${context.cwd === "/" ? "" : context.cwd}/${p}`;
|
|
1026
1036
|
const normalizedArgv = [...argv];
|
|
1027
1037
|
for (let i = 0; i < normalizedArgv.length; i++) {
|
|
1038
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
1028
1039
|
const token = normalizedArgv[i];
|
|
1029
1040
|
if (token === "-o" || token === "--out") {
|
|
1030
1041
|
const next = normalizedArgv[i + 1];
|
|
@@ -1050,8 +1061,9 @@ async function executeVfsImageTool(context, runner) {
|
|
|
1050
1061
|
} catch {
|
|
1051
1062
|
}
|
|
1052
1063
|
}
|
|
1064
|
+
context.inputBudget?.check(0);
|
|
1053
1065
|
const existingSnap = new Map(vfsFiles);
|
|
1054
|
-
const res = await runner(normalizedArgv, vfsFiles);
|
|
1066
|
+
const res = await runner(normalizedArgv, vfsFiles, invocation.signal);
|
|
1055
1067
|
if (res.stderr) {
|
|
1056
1068
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
1057
1069
|
}
|
|
@@ -1060,6 +1072,7 @@ async function executeVfsImageTool(context, runner) {
|
|
|
1060
1072
|
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
1061
1073
|
}
|
|
1062
1074
|
for (const [key, val] of vfsFiles.entries()) {
|
|
1075
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
1063
1076
|
if (existingSnap.get(key) !== val) {
|
|
1064
1077
|
const abs = resolveVfsPath(key);
|
|
1065
1078
|
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
@@ -1075,24 +1088,30 @@ async function executeVfsImageTool(context, runner) {
|
|
|
1075
1088
|
await invocation.close();
|
|
1076
1089
|
}
|
|
1077
1090
|
}
|
|
1078
|
-
function createSipsCommand(
|
|
1091
|
+
function createSipsCommand(options = {}) {
|
|
1092
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
1079
1093
|
return Object.freeze({
|
|
1080
1094
|
name: "sips",
|
|
1081
1095
|
runtimeIdentity: commandRuntimeIdentity,
|
|
1082
1096
|
description: "Scriptable image processing system powered by @poe-code/image-ast",
|
|
1083
1097
|
execute(context) {
|
|
1084
|
-
return
|
|
1098
|
+
return new InputByteBudget(maxInputBytes).run(context, async (context2) => {
|
|
1099
|
+
return executeVfsImageTool(context2, runSipsCli);
|
|
1100
|
+
});
|
|
1085
1101
|
}
|
|
1086
1102
|
});
|
|
1087
1103
|
}
|
|
1088
1104
|
var sipsCommand = createSipsCommand();
|
|
1089
|
-
function createIdentifyCommand(
|
|
1105
|
+
function createIdentifyCommand(options = {}) {
|
|
1106
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
1090
1107
|
return Object.freeze({
|
|
1091
1108
|
name: "identify",
|
|
1092
1109
|
runtimeIdentity: commandRuntimeIdentity,
|
|
1093
1110
|
description: "Inspect image format, dimensions, and metadata via @poe-code/image-ast",
|
|
1094
1111
|
execute(context) {
|
|
1095
|
-
return
|
|
1112
|
+
return new InputByteBudget(maxInputBytes).run(context, async (context2) => {
|
|
1113
|
+
return executeVfsImageTool(context2, runIdentifyCli);
|
|
1114
|
+
});
|
|
1096
1115
|
}
|
|
1097
1116
|
});
|
|
1098
1117
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
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 SofficeLimits {
|
|
4
|
+
readonly maxInputBytes: number;
|
|
5
|
+
readonly maxOutputBytes: number;
|
|
6
|
+
readonly maxArgumentBytes: number;
|
|
7
|
+
}
|
|
3
8
|
export interface SofficeCommandOptions {
|
|
9
|
+
readonly limits?: Partial<SofficeLimits>;
|
|
4
10
|
readonly replace?: boolean;
|
|
5
11
|
}
|
|
6
12
|
export interface SofficeCliResult {
|
|
@@ -13,12 +19,12 @@ export declare function runSofficeCliSync(argv: readonly string[], files: Map<st
|
|
|
13
19
|
export declare function runSofficeCli(argv: readonly string[], files: Map<string, Uint8Array>, cwd?: string, options?: {
|
|
14
20
|
readonly signal?: AbortSignal;
|
|
15
21
|
}): Promise<SofficeCliResult>;
|
|
16
|
-
export declare function soffice(context: CommandContext): Promise<{
|
|
22
|
+
export declare function soffice(context: CommandContext, options?: SofficeCommandOptions): Promise<{
|
|
17
23
|
exitCode: number;
|
|
18
24
|
}>;
|
|
19
|
-
export declare function createSofficeCommand(
|
|
25
|
+
export declare function createSofficeCommand(options?: SofficeCommandOptions): CommandDefinition;
|
|
20
26
|
export declare const sofficeCommand: CommandDefinition;
|
|
21
|
-
export declare function createLibreofficeCommand(
|
|
27
|
+
export declare function createLibreofficeCommand(options?: SofficeCommandOptions): CommandDefinition;
|
|
22
28
|
export declare const libreofficeCommand: CommandDefinition;
|
|
23
29
|
export declare function sofficeCommands(options?: SofficeCommandsOptions): VirtualShellPlugin;
|
|
24
30
|
export type SofficeCommandsOptions = SofficeCommandOptions;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
xlsxFormat
|
|
3
|
+
} from "../safe-bash/command-chunks/chunk-Z64BW7CG.js";
|
|
1
4
|
import {
|
|
2
5
|
csvFormat
|
|
3
6
|
} from "../safe-bash/command-chunks/chunk-KHZZ4V3L.js";
|
|
@@ -13,15 +16,12 @@ import "../safe-bash/command-chunks/chunk-CE6Z2ULX.js";
|
|
|
13
16
|
import "../safe-bash/command-chunks/chunk-444OTXM7.js";
|
|
14
17
|
import "../safe-bash/command-chunks/chunk-OZSWW23M.js";
|
|
15
18
|
import "../safe-bash/command-chunks/chunk-TT2DMDBY.js";
|
|
16
|
-
import {
|
|
17
|
-
xlsxFormat
|
|
18
|
-
} from "../safe-bash/command-chunks/chunk-Z64BW7CG.js";
|
|
19
|
-
import "../safe-bash/command-chunks/chunk-KOM3FNCE.js";
|
|
20
19
|
import "../safe-bash/command-chunks/chunk-VBZMCL23.js";
|
|
21
20
|
import "../safe-bash/command-chunks/chunk-J7UMKBRK.js";
|
|
22
21
|
import "../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
|
|
23
22
|
import "../safe-bash/command-chunks/chunk-FLMLM7Y4.js";
|
|
24
23
|
import "../safe-bash/command-chunks/chunk-RID3B5RE.js";
|
|
24
|
+
import "../safe-bash/command-chunks/chunk-KOM3FNCE.js";
|
|
25
25
|
import "../safe-bash/command-chunks/chunk-WKPOGTZY.js";
|
|
26
26
|
import "../safe-bash/command-chunks/chunk-MED2BOOW.js";
|
|
27
27
|
import "../safe-bash/command-chunks/chunk-FDNCPZQS.js";
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
|
|
38
38
|
// packages/safe-bash-command-soffice/dist/index.js
|
|
39
39
|
init_buffer();
|
|
40
|
+
import { yieldTurn } from "../safe-bash-contracts/yield.js";
|
|
40
41
|
import { resolvePath } from "@poe-platform/safe-fs/core";
|
|
41
42
|
|
|
42
43
|
// packages/safe-bash-command-soffice/dist/spreadsheet.js
|
|
@@ -202,6 +203,14 @@ function readZipArchiveEntries(zipBytes) {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
// packages/safe-bash-command-soffice/dist/index.js
|
|
206
|
+
function resolveLimits(options) {
|
|
207
|
+
const limits = { maxInputBytes: Infinity, maxOutputBytes: Infinity, maxArgumentBytes: Infinity, ...options.limits };
|
|
208
|
+
for (const [name, value] of Object.entries(limits)) {
|
|
209
|
+
if (value !== Infinity && (!Number.isSafeInteger(value) || value < 0))
|
|
210
|
+
throw new RangeError(`${name} limit must be a nonnegative safe integer or Infinity`);
|
|
211
|
+
}
|
|
212
|
+
return limits;
|
|
213
|
+
}
|
|
205
214
|
function unescapeXml(str) {
|
|
206
215
|
return str.replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCodePoint(Number.parseInt(hex, 16))).replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number.parseInt(dec, 10))).replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
207
216
|
}
|
|
@@ -325,7 +334,7 @@ function parsePptxSlides(zipBytes) {
|
|
|
325
334
|
}
|
|
326
335
|
return slides;
|
|
327
336
|
}
|
|
328
|
-
function renderBlocksToPdf(blocks, title = "Document") {
|
|
337
|
+
function* renderBlocksToPdf(blocks, title = "Document") {
|
|
329
338
|
const doc = PdfDocument.create();
|
|
330
339
|
doc.setTitle(title);
|
|
331
340
|
doc.setCreator("LibreOffice 24.8 (@poe-code/pdf-ast)");
|
|
@@ -337,7 +346,10 @@ function renderBlocksToPdf(blocks, title = "Document") {
|
|
|
337
346
|
y = 720;
|
|
338
347
|
}
|
|
339
348
|
};
|
|
349
|
+
let work = 0;
|
|
340
350
|
for (const block of blocks) {
|
|
351
|
+
if (++work % 32 === 0)
|
|
352
|
+
yield void 0;
|
|
341
353
|
if (block.kind === "heading") {
|
|
342
354
|
ensureSpace(32);
|
|
343
355
|
page.drawText(block.text ?? "", {
|
|
@@ -363,7 +375,10 @@ function renderBlocksToPdf(blocks, title = "Document") {
|
|
|
363
375
|
const tableWidth = 504;
|
|
364
376
|
const colWidth = tableWidth / colCount;
|
|
365
377
|
const rowHeight = 22;
|
|
366
|
-
block.rows.
|
|
378
|
+
for (let rIdx = 0; rIdx < block.rows.length; rIdx++) {
|
|
379
|
+
if (++work % 32 === 0)
|
|
380
|
+
yield void 0;
|
|
381
|
+
const row = block.rows[rIdx];
|
|
367
382
|
ensureSpace(rowHeight + 6);
|
|
368
383
|
const rowTop = y;
|
|
369
384
|
const rowBottom = y - rowHeight;
|
|
@@ -407,7 +422,7 @@ function renderBlocksToPdf(blocks, title = "Document") {
|
|
|
407
422
|
});
|
|
408
423
|
});
|
|
409
424
|
y -= rowHeight;
|
|
410
|
-
}
|
|
425
|
+
}
|
|
411
426
|
y -= 14;
|
|
412
427
|
}
|
|
413
428
|
}
|
|
@@ -660,6 +675,8 @@ function* runSofficeSteps(argv, files, cwd, signal) {
|
|
|
660
675
|
if (catMode && !convertSpec && inputs.length > 0) {
|
|
661
676
|
const chunks = [];
|
|
662
677
|
for (const inputPath of inputs) {
|
|
678
|
+
yield void 0;
|
|
679
|
+
signal.throwIfAborted();
|
|
663
680
|
const bytes = files.get(inputPath) ?? files.get(resolvePath(cwd, inputPath));
|
|
664
681
|
if (!bytes) {
|
|
665
682
|
return { exitCode: 1, stdout: "", stderr: `Error: source file could not be loaded: ${inputPath}
|
|
@@ -695,6 +712,8 @@ function* runSofficeSteps(argv, files, cwd, signal) {
|
|
|
695
712
|
const targetExt = (targetExtRaw ?? "pdf").toLowerCase();
|
|
696
713
|
let stdout = "";
|
|
697
714
|
for (const inputPath of inputs) {
|
|
715
|
+
yield void 0;
|
|
716
|
+
signal.throwIfAborted();
|
|
698
717
|
const inputBytes = files.get(inputPath) ?? files.get(resolvePath(cwd, inputPath));
|
|
699
718
|
if (!inputBytes) {
|
|
700
719
|
return {
|
|
@@ -716,7 +735,7 @@ function* runSofficeSteps(argv, files, cwd, signal) {
|
|
|
716
735
|
} else if ([".docx", ".odt", ".ods", ".odp", ".rtf"].some((ext) => lowerIn.endsWith(ext))) {
|
|
717
736
|
const blocks = lowerIn.endsWith(".docx") ? parseDocxBlocks(inputBytes) : [".odt", ".ods", ".odp"].some((ext) => lowerIn.endsWith(ext)) ? parseOdtBlocks(inputBytes) : parseRtfBlocks(inputBytes);
|
|
718
737
|
if (targetExt === "pdf") {
|
|
719
|
-
outBytes = renderBlocksToPdf(blocks, stem);
|
|
738
|
+
outBytes = yield* renderBlocksToPdf(blocks, stem);
|
|
720
739
|
} else if (targetExt === "html") {
|
|
721
740
|
outBytes = renderBlocksToHtml(blocks, stem);
|
|
722
741
|
} else if (targetExt === "docx") {
|
|
@@ -734,7 +753,7 @@ function* runSofficeSteps(argv, files, cwd, signal) {
|
|
|
734
753
|
} else if (targetExt === "html") {
|
|
735
754
|
outBytes = renderBlocksToHtml([{ kind: "table", rows }], stem);
|
|
736
755
|
} else if (targetExt === "pdf") {
|
|
737
|
-
outBytes = renderBlocksToPdf([{ kind: "table", rows }], stem);
|
|
756
|
+
outBytes = yield* renderBlocksToPdf([{ kind: "table", rows }], stem);
|
|
738
757
|
} else {
|
|
739
758
|
outBytes = new TextEncoder().encode(rows.map((row) => row.join(" ")).join("\n") + "\n");
|
|
740
759
|
}
|
|
@@ -789,7 +808,7 @@ ${s.bullets.join("\n")}`).join("\n\n");
|
|
|
789
808
|
const rawText = new TextDecoder().decode(inputBytes);
|
|
790
809
|
const lines = rawText.split(/\r?\n/).filter((l) => l.trim().length > 0);
|
|
791
810
|
const blocks = lines.map((l) => l.startsWith("# ") ? { kind: "heading", text: l.slice(2).trim() } : { kind: "paragraph", text: l });
|
|
792
|
-
outBytes = targetExt === "pdf" ? renderBlocksToPdf(blocks, stem) : targetExt === "docx" ? buildDocxFromBlocks(blocks) : targetExt === "html" ? renderBlocksToHtml(blocks, stem) : inputBytes;
|
|
811
|
+
outBytes = targetExt === "pdf" ? yield* renderBlocksToPdf(blocks, stem) : targetExt === "docx" ? buildDocxFromBlocks(blocks) : targetExt === "html" ? renderBlocksToHtml(blocks, stem) : inputBytes;
|
|
793
812
|
}
|
|
794
813
|
if (targetExt === "pdf" && filterOpts && filterOpts.trim().startsWith("{")) {
|
|
795
814
|
try {
|
|
@@ -841,7 +860,9 @@ ${s.bullets.join("\n")}`).join("\n\n");
|
|
|
841
860
|
}
|
|
842
861
|
function runSofficeCliSync(argv, files, cwd = "/") {
|
|
843
862
|
const steps = runSofficeSteps(argv, files, cwd, new AbortController().signal);
|
|
844
|
-
|
|
863
|
+
let step = steps.next();
|
|
864
|
+
while (!step.done && step.value === void 0)
|
|
865
|
+
step = steps.next();
|
|
845
866
|
if (step.done)
|
|
846
867
|
return step.value;
|
|
847
868
|
const result = { exitCode: 1, stdout: "", stderr: "Error: this spreadsheet conversion requires the asynchronous runSofficeCli API\n" };
|
|
@@ -852,23 +873,39 @@ async function runSofficeCli(argv, files, cwd = "/", options = {}) {
|
|
|
852
873
|
const signal = options.signal ?? new AbortController().signal;
|
|
853
874
|
signal.throwIfAborted();
|
|
854
875
|
const steps = runSofficeSteps(argv, files, cwd, signal);
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
876
|
+
try {
|
|
877
|
+
let step = steps.next();
|
|
878
|
+
while (!step.done) {
|
|
879
|
+
try {
|
|
880
|
+
await yieldTurn(signal);
|
|
881
|
+
signal.throwIfAborted();
|
|
882
|
+
step = steps.next(step.value ? await step.value() : void 0);
|
|
883
|
+
} catch (error) {
|
|
884
|
+
step = steps.throw(error);
|
|
885
|
+
}
|
|
861
886
|
}
|
|
887
|
+
signal.throwIfAborted();
|
|
888
|
+
return step.value;
|
|
889
|
+
} finally {
|
|
890
|
+
steps.return({ exitCode: 1, stdout: "", stderr: "" });
|
|
862
891
|
}
|
|
863
|
-
signal.throwIfAborted();
|
|
864
|
-
return step.value;
|
|
865
892
|
}
|
|
866
|
-
async function soffice(context) {
|
|
893
|
+
async function soffice(context, options = {}) {
|
|
894
|
+
const limits = resolveLimits(options);
|
|
895
|
+
let outputBytes = 0;
|
|
896
|
+
const chargeOutput = (bytes) => {
|
|
897
|
+
outputBytes += bytes;
|
|
898
|
+
if (outputBytes > limits.maxOutputBytes)
|
|
899
|
+
throw new RangeError("Output byte limit exceeded");
|
|
900
|
+
};
|
|
867
901
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
868
902
|
} });
|
|
869
903
|
try {
|
|
870
904
|
const carrier = getCommandArguments(context);
|
|
871
905
|
const argv = [...carrier.args];
|
|
906
|
+
const argumentBytes = argv.reduce((total, arg) => total + new TextEncoder().encode(arg).byteLength + 1, 0);
|
|
907
|
+
if (argumentBytes > limits.maxArgumentBytes)
|
|
908
|
+
throw new RangeError("Argument byte limit exceeded");
|
|
872
909
|
const vfsFiles = /* @__PURE__ */ new Map();
|
|
873
910
|
const parsed = parseSofficeArguments(argv, context.cwd);
|
|
874
911
|
let inputBytes = 0;
|
|
@@ -885,6 +922,8 @@ async function soffice(context) {
|
|
|
885
922
|
}
|
|
886
923
|
inputBytes += bytes.byteLength;
|
|
887
924
|
context.inputBudget?.check(inputBytes);
|
|
925
|
+
if (inputBytes > limits.maxInputBytes)
|
|
926
|
+
throw new RangeError("Input byte limit exceeded");
|
|
888
927
|
vfsFiles.set(abs, bytes);
|
|
889
928
|
}
|
|
890
929
|
const existingSnap = new Map(vfsFiles);
|
|
@@ -893,11 +932,13 @@ async function soffice(context) {
|
|
|
893
932
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
894
933
|
}
|
|
895
934
|
if (res.stdout) {
|
|
935
|
+
chargeOutput(new TextEncoder().encode(res.stdout).byteLength);
|
|
896
936
|
const stdout = invocation.child(context.stdout);
|
|
897
937
|
await writeBytes(stdout.output, new TextEncoder().encode(res.stdout), invocation.signal);
|
|
898
938
|
}
|
|
899
939
|
for (const [fileKey, fileBytes] of vfsFiles.entries()) {
|
|
900
940
|
if (existingSnap.get(fileKey) !== fileBytes) {
|
|
941
|
+
chargeOutput(fileBytes.byteLength);
|
|
901
942
|
const abs = resolvePath(context.cwd, fileKey);
|
|
902
943
|
const parentDir = abs.slice(0, abs.lastIndexOf("/")) || "/";
|
|
903
944
|
try {
|
|
@@ -912,24 +953,24 @@ async function soffice(context) {
|
|
|
912
953
|
await invocation.close();
|
|
913
954
|
}
|
|
914
955
|
}
|
|
915
|
-
function createSofficeCommand(
|
|
956
|
+
function createSofficeCommand(options = {}) {
|
|
916
957
|
return Object.freeze({
|
|
917
958
|
name: "soffice",
|
|
918
959
|
runtimeIdentity: commandRuntimeIdentity,
|
|
919
960
|
description: "Headless document/spreadsheet/presentation to PDF and CSV converter via @poe-code/pdf-ast",
|
|
920
961
|
execute(context) {
|
|
921
|
-
return soffice(context);
|
|
962
|
+
return soffice(context, options);
|
|
922
963
|
}
|
|
923
964
|
});
|
|
924
965
|
}
|
|
925
966
|
var sofficeCommand = createSofficeCommand();
|
|
926
|
-
function createLibreofficeCommand(
|
|
967
|
+
function createLibreofficeCommand(options = {}) {
|
|
927
968
|
return Object.freeze({
|
|
928
969
|
name: "libreoffice",
|
|
929
970
|
runtimeIdentity: commandRuntimeIdentity,
|
|
930
971
|
description: "Headless LibreOffice document/spreadsheet/presentation to PDF converter via @poe-code/pdf-ast",
|
|
931
972
|
execute(context) {
|
|
932
|
-
return soffice(context);
|
|
973
|
+
return soffice(context, options);
|
|
933
974
|
}
|
|
934
975
|
});
|
|
935
976
|
}
|
|
@@ -149,6 +149,10 @@ export declare function toSqlString(v: SqlValue): string;
|
|
|
149
149
|
export declare function isTruthy(v: SqlValue): boolean;
|
|
150
150
|
export declare function matchGlob(str: string, pattern: string): boolean;
|
|
151
151
|
export declare class SqliteDatabase {
|
|
152
|
+
private readonly maxRows;
|
|
153
|
+
constructor(maxRows?: number);
|
|
154
|
+
private checkRowCount;
|
|
155
|
+
executeStatementAsync(sql: string, signal: AbortSignal): Promise<QueryResultSet | null>;
|
|
152
156
|
tables: Map<string, TableDef>;
|
|
153
157
|
indexes: Map<string, IndexDef>;
|
|
154
158
|
views: Map<string, ViewDef>;
|
|
@@ -172,14 +176,18 @@ export declare class SqliteDatabase {
|
|
|
172
176
|
private captureSnapshot;
|
|
173
177
|
private restoreSnapshot;
|
|
174
178
|
loadFromBytes(bytes: Uint8Array): void;
|
|
179
|
+
private loadFromBytesSteps;
|
|
175
180
|
serializeToBytes(): Uint8Array;
|
|
181
|
+
private serializeToBytesSteps;
|
|
176
182
|
findTable(name: string): TableDef | undefined;
|
|
177
183
|
findView(name: string): ViewDef | undefined;
|
|
178
184
|
exec(sql: string, positionalParams?: SqlValue[]): QueryResultSet[];
|
|
185
|
+
private execSteps;
|
|
179
186
|
executeStatement(rawSql: string, positionalParams?: SqlValue[], cteScope?: Map<string, {
|
|
180
187
|
columns: string[];
|
|
181
188
|
rows: SqlValue[][];
|
|
182
189
|
}>): QueryResultSet | null;
|
|
190
|
+
private executeStatementSteps;
|
|
183
191
|
private executePragma;
|
|
184
192
|
private executeCreate;
|
|
185
193
|
private parseColumnDefTokens;
|
|
@@ -220,6 +228,7 @@ export declare class SqliteDatabase {
|
|
|
220
228
|
columns: string[];
|
|
221
229
|
rows: SqlValue[][];
|
|
222
230
|
}>): SqlValue;
|
|
231
|
+
private evalExprSteps;
|
|
223
232
|
private applyUnary;
|
|
224
233
|
private applyBinary;
|
|
225
234
|
private applyCast;
|
|
@@ -6,6 +6,7 @@ export interface Sqlite3Limits {
|
|
|
6
6
|
readonly maxRows: number;
|
|
7
7
|
}
|
|
8
8
|
export interface SqliteEngineInstance {
|
|
9
|
+
executeStatementAsync?(sql: string, signal: AbortSignal): Promise<QueryResultSet | null>;
|
|
9
10
|
executeStatement?(sql: string, positionalParams?: SqlValue[]): Promise<QueryResultSet | null> | QueryResultSet | null;
|
|
10
11
|
exec?(sql: string, positionalParams?: SqlValue[]): Promise<QueryResultSet[]> | QueryResultSet[];
|
|
11
12
|
loadFromBytes?(bytes: Uint8Array): Promise<void> | void;
|