@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
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type CommandDefinition } from "../safe-bash-contracts/command.js";
|
|
2
2
|
import type { VirtualShellPlugin } from "../safe-bash-contracts/plugin.js";
|
|
3
3
|
import { PdfDocument } from "../pdf-ast/index.js";
|
|
4
|
+
export interface PdftkLimits {
|
|
5
|
+
readonly maxInputBytes: number;
|
|
6
|
+
}
|
|
4
7
|
export interface PdftkCommandOptions {
|
|
8
|
+
readonly limits?: Partial<PdftkLimits>;
|
|
5
9
|
readonly replace?: boolean;
|
|
6
10
|
}
|
|
7
11
|
export interface PdftkCliResult {
|
|
@@ -20,9 +24,9 @@ export interface ExpandedPageSelection {
|
|
|
20
24
|
readonly rotation?: RotationSpec | undefined;
|
|
21
25
|
}
|
|
22
26
|
export declare function parsePdftkRangeToken(token: string, handles: ReadonlyMap<string, PdfDocument>, defaultHandle: string): ExpandedPageSelection[];
|
|
23
|
-
export declare function runPdftkCli(argv: readonly string[], files: Map<string, Uint8Array
|
|
24
|
-
export declare function runPdftkCliSync(argv: readonly string[], files: Map<string, Uint8Array
|
|
25
|
-
export declare function createPdftkCommand(
|
|
27
|
+
export declare function runPdftkCli(argv: readonly string[], files: Map<string, Uint8Array>, signal?: AbortSignal): Promise<PdftkCliResult>;
|
|
28
|
+
export declare function runPdftkCliSync(argv: readonly string[], files: Map<string, Uint8Array>, signal?: AbortSignal): PdftkCliResult;
|
|
29
|
+
export declare function createPdftkCommand(options?: PdftkCommandOptions): CommandDefinition;
|
|
26
30
|
export declare const pdftkCommand: CommandDefinition;
|
|
27
31
|
export declare function pdftkPlugin(options?: PdftkCommandsOptions): VirtualShellPlugin;
|
|
28
32
|
export declare const pdftkCommands: typeof pdftkPlugin;
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// packages/safe-bash-command-pdftk/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,
|
|
@@ -45660,10 +45662,8 @@ function normalizeQuarterTurn(degrees) {
|
|
|
45660
45662
|
if (mod === 90 || mod === 180 || mod === 270) return mod;
|
|
45661
45663
|
return 0;
|
|
45662
45664
|
}
|
|
45663
|
-
|
|
45664
|
-
|
|
45665
|
-
}
|
|
45666
|
-
function runPdftkCliSync(argv, files) {
|
|
45665
|
+
function* runPdftkCliSteps(argv, files, signal) {
|
|
45666
|
+
let cooperativeWork = 63;
|
|
45667
45667
|
if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
|
|
45668
45668
|
return {
|
|
45669
45669
|
exitCode: 0,
|
|
@@ -45677,13 +45677,20 @@ function runPdftkCliSync(argv, files) {
|
|
|
45677
45677
|
const inputPasswords = /* @__PURE__ */ new Map();
|
|
45678
45678
|
let defaultInputPassword = "";
|
|
45679
45679
|
for (let p = 0; p < argv.length; p++) {
|
|
45680
|
+
if (++cooperativeWork % 64 === 0)
|
|
45681
|
+
yield;
|
|
45680
45682
|
if (argv[p]?.toLowerCase() === "input_pw") {
|
|
45681
45683
|
for (let q = p + 1; q < argv.length; q++) {
|
|
45684
|
+
if (++cooperativeWork % 64 === 0)
|
|
45685
|
+
yield;
|
|
45682
45686
|
const tok = argv[q];
|
|
45683
|
-
if (PDFTK_OPERATIONS.has(tok.toLowerCase()))
|
|
45687
|
+
if (PDFTK_OPERATIONS.has(tok.toLowerCase()))
|
|
45688
|
+
break;
|
|
45684
45689
|
const eq = tok.indexOf("=");
|
|
45685
|
-
if (eq > 0)
|
|
45686
|
-
|
|
45690
|
+
if (eq > 0)
|
|
45691
|
+
inputPasswords.set(tok.slice(0, eq), tok.slice(eq + 1));
|
|
45692
|
+
else
|
|
45693
|
+
defaultInputPassword = tok;
|
|
45687
45694
|
}
|
|
45688
45695
|
}
|
|
45689
45696
|
}
|
|
@@ -45692,8 +45699,11 @@ function runPdftkCliSync(argv, files) {
|
|
|
45692
45699
|
let idx = 0;
|
|
45693
45700
|
let autoHandleCharCode = 65;
|
|
45694
45701
|
while (idx < argv.length) {
|
|
45702
|
+
if (++cooperativeWork % 64 === 0)
|
|
45703
|
+
yield;
|
|
45695
45704
|
const token = argv[idx];
|
|
45696
|
-
if (PDFTK_OPERATIONS.has(token.toLowerCase()) || token.toLowerCase() === "input_pw")
|
|
45705
|
+
if (PDFTK_OPERATIONS.has(token.toLowerCase()) || token.toLowerCase() === "input_pw")
|
|
45706
|
+
break;
|
|
45697
45707
|
idx++;
|
|
45698
45708
|
let handleName = "";
|
|
45699
45709
|
let filePath = token;
|
|
@@ -45718,15 +45728,20 @@ function runPdftkCliSync(argv, files) {
|
|
|
45718
45728
|
` };
|
|
45719
45729
|
}
|
|
45720
45730
|
handles.set(handleName, doc);
|
|
45721
|
-
if (!handles.has(""))
|
|
45731
|
+
if (!handles.has(""))
|
|
45732
|
+
handles.set("", doc);
|
|
45722
45733
|
orderedDocs.push({ handle: handleName, doc });
|
|
45723
45734
|
}
|
|
45724
45735
|
if (orderedDocs.length === 0) {
|
|
45725
45736
|
return { exitCode: 1, stdout: "", stderr: "Error: No input PDF files specified.\n" };
|
|
45726
45737
|
}
|
|
45727
45738
|
while (idx < argv.length && argv[idx]?.toLowerCase() === "input_pw") {
|
|
45739
|
+
if (++cooperativeWork % 64 === 0)
|
|
45740
|
+
yield;
|
|
45728
45741
|
idx++;
|
|
45729
45742
|
while (idx < argv.length && !PDFTK_OPERATIONS.has(argv[idx].toLowerCase())) {
|
|
45743
|
+
if (++cooperativeWork % 64 === 0)
|
|
45744
|
+
yield;
|
|
45730
45745
|
idx++;
|
|
45731
45746
|
}
|
|
45732
45747
|
}
|
|
@@ -45763,6 +45778,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45763
45778
|
"allfeatures"
|
|
45764
45779
|
]);
|
|
45765
45780
|
while (idx < argv.length) {
|
|
45781
|
+
if (++cooperativeWork % 64 === 0)
|
|
45782
|
+
yield;
|
|
45766
45783
|
const tok = argv[idx++];
|
|
45767
45784
|
const lower = tok.toLowerCase();
|
|
45768
45785
|
if (lower === "output") {
|
|
@@ -45777,6 +45794,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45777
45794
|
ownerPassword = argv[idx++];
|
|
45778
45795
|
} else if (lower === "allow") {
|
|
45779
45796
|
while (idx < argv.length && ALLOW_KEYWORDS.has(argv[idx].toLowerCase())) {
|
|
45797
|
+
if (++cooperativeWork % 64 === 0)
|
|
45798
|
+
yield;
|
|
45780
45799
|
allowPermissions.add(argv[idx++].toLowerCase());
|
|
45781
45800
|
}
|
|
45782
45801
|
} else if (lower === "keep_first_id") {
|
|
@@ -45825,6 +45844,7 @@ function runPdftkCliSync(argv, files) {
|
|
|
45825
45844
|
if (operation === "burst") {
|
|
45826
45845
|
const pattern = outputTarget ?? "pg_%04d.pdf";
|
|
45827
45846
|
for (let p = 1; p <= primaryDoc.pageCount; p++) {
|
|
45847
|
+
yield;
|
|
45828
45848
|
const singleDoc = PdfDocument.create();
|
|
45829
45849
|
copyPrimaryMetadata(primaryDoc, singleDoc);
|
|
45830
45850
|
singleDoc.copyPagesFrom(primaryDoc, [p - 1]);
|
|
@@ -45833,7 +45853,10 @@ function runPdftkCliSync(argv, files) {
|
|
|
45833
45853
|
}
|
|
45834
45854
|
if (uncompressStreams || compressStreams) {
|
|
45835
45855
|
for (const obj of singleDoc.cos.objects.values()) {
|
|
45836
|
-
if (
|
|
45856
|
+
if (++cooperativeWork % 64 === 0)
|
|
45857
|
+
yield;
|
|
45858
|
+
if (obj.value.kind !== "stream")
|
|
45859
|
+
continue;
|
|
45837
45860
|
const raw = singleDoc.cos.decodeStream(obj.value);
|
|
45838
45861
|
dictDelete(obj.value.dict, "Filter");
|
|
45839
45862
|
dictDelete(obj.value.dict, "DecodeParms");
|
|
@@ -45879,6 +45902,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45879
45902
|
const filesToAttach = [];
|
|
45880
45903
|
let toPageSpec;
|
|
45881
45904
|
for (let k = 0; k < opArgs.length; k++) {
|
|
45905
|
+
if (++cooperativeWork % 64 === 0)
|
|
45906
|
+
yield;
|
|
45882
45907
|
if (opArgs[k]?.toLowerCase() === "to_page") {
|
|
45883
45908
|
toPageSpec = opArgs[++k];
|
|
45884
45909
|
continue;
|
|
@@ -45895,6 +45920,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45895
45920
|
}
|
|
45896
45921
|
const fieldValues = parseFormDataBytes(dataBytes);
|
|
45897
45922
|
for (const [k, v] of fieldValues.entries()) {
|
|
45923
|
+
if (++cooperativeWork % 64 === 0)
|
|
45924
|
+
yield;
|
|
45898
45925
|
setDocumentFormField(resultDoc.cos, k, v);
|
|
45899
45926
|
}
|
|
45900
45927
|
if (shouldFlatten) {
|
|
@@ -45908,7 +45935,10 @@ function runPdftkCliSync(argv, files) {
|
|
|
45908
45935
|
const selections = [];
|
|
45909
45936
|
if (opArgs.length === 0) {
|
|
45910
45937
|
for (const item of orderedDocs) {
|
|
45938
|
+
if (++cooperativeWork % 64 === 0)
|
|
45939
|
+
yield;
|
|
45911
45940
|
for (let p = 1; p <= item.doc.pageCount; p++) {
|
|
45941
|
+
yield;
|
|
45912
45942
|
selections.push({ handle: item.handle, pageNumber: p });
|
|
45913
45943
|
}
|
|
45914
45944
|
}
|
|
@@ -45916,12 +45946,19 @@ function runPdftkCliSync(argv, files) {
|
|
|
45916
45946
|
const groups = opArgs.map((arg) => parsePdftkRangeToken(arg, handles, primaryHandle));
|
|
45917
45947
|
const maxLen = Math.max(0, ...groups.map((g) => g.length));
|
|
45918
45948
|
for (let k = 0; k < maxLen; k++) {
|
|
45949
|
+
if (++cooperativeWork % 64 === 0)
|
|
45950
|
+
yield;
|
|
45919
45951
|
for (const g of groups) {
|
|
45920
|
-
if (
|
|
45952
|
+
if (++cooperativeWork % 64 === 0)
|
|
45953
|
+
yield;
|
|
45954
|
+
if (k < g.length)
|
|
45955
|
+
selections.push(g[k]);
|
|
45921
45956
|
}
|
|
45922
45957
|
}
|
|
45923
45958
|
} else {
|
|
45924
45959
|
for (const arg of opArgs) {
|
|
45960
|
+
if (++cooperativeWork % 64 === 0)
|
|
45961
|
+
yield;
|
|
45925
45962
|
selections.push(...parsePdftkRangeToken(arg, handles, primaryHandle));
|
|
45926
45963
|
}
|
|
45927
45964
|
}
|
|
@@ -45941,6 +45978,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45941
45978
|
};
|
|
45942
45979
|
const remappedBookmarks = [];
|
|
45943
45980
|
for (let sIdx = 0; sIdx < selections.length; sIdx++) {
|
|
45981
|
+
if (++cooperativeWork % 64 === 0)
|
|
45982
|
+
yield;
|
|
45944
45983
|
const sel = selections[sIdx];
|
|
45945
45984
|
const srcDoc = handles.get(sel.handle) ?? primaryDoc;
|
|
45946
45985
|
const [copied] = resultDoc.copyPagesFrom(srcDoc, [sel.pageNumber - 1]);
|
|
@@ -45950,6 +45989,8 @@ function runPdftkCliSync(argv, files) {
|
|
|
45950
45989
|
copied.setRotation(normalizeQuarterTurn(rawRot));
|
|
45951
45990
|
}
|
|
45952
45991
|
for (const bm of getDocBookmarks(srcDoc)) {
|
|
45992
|
+
if (++cooperativeWork % 64 === 0)
|
|
45993
|
+
yield;
|
|
45953
45994
|
if (bm.pageNumber === sel.pageNumber) {
|
|
45954
45995
|
remappedBookmarks.push({
|
|
45955
45996
|
title: bm.title,
|
|
@@ -45962,11 +46003,15 @@ function runPdftkCliSync(argv, files) {
|
|
|
45962
46003
|
setDocumentBookmarks(resultDoc, remappedBookmarks);
|
|
45963
46004
|
const usedDocs = /* @__PURE__ */ new Set();
|
|
45964
46005
|
for (const sel of selections) {
|
|
46006
|
+
if (++cooperativeWork % 64 === 0)
|
|
46007
|
+
yield;
|
|
45965
46008
|
const d = handles.get(sel.handle) ?? primaryDoc;
|
|
45966
46009
|
usedDocs.add(d);
|
|
45967
46010
|
}
|
|
45968
46011
|
const unpackedMap = /* @__PURE__ */ new Map();
|
|
45969
46012
|
for (const d of usedDocs) {
|
|
46013
|
+
if (++cooperativeWork % 64 === 0)
|
|
46014
|
+
yield;
|
|
45970
46015
|
unpackFilesFromDocument(d, ".", unpackedMap);
|
|
45971
46016
|
}
|
|
45972
46017
|
if (unpackedMap.size > 0) {
|
|
@@ -45978,11 +46023,17 @@ function runPdftkCliSync(argv, files) {
|
|
|
45978
46023
|
} else if (operation === "rotate") {
|
|
45979
46024
|
const rotByPage = /* @__PURE__ */ new Map();
|
|
45980
46025
|
for (const arg of opArgs) {
|
|
46026
|
+
if (++cooperativeWork % 64 === 0)
|
|
46027
|
+
yield;
|
|
45981
46028
|
for (const sel of parsePdftkRangeToken(arg, handles, primaryHandle)) {
|
|
45982
|
-
if (
|
|
46029
|
+
if (++cooperativeWork % 64 === 0)
|
|
46030
|
+
yield;
|
|
46031
|
+
if (sel.rotation)
|
|
46032
|
+
rotByPage.set(sel.pageNumber, sel.rotation);
|
|
45983
46033
|
}
|
|
45984
46034
|
}
|
|
45985
46035
|
for (let p = 1; p <= resultDoc.pageCount; p++) {
|
|
46036
|
+
yield;
|
|
45986
46037
|
const spec = rotByPage.get(p);
|
|
45987
46038
|
if (spec) {
|
|
45988
46039
|
const page = resultDoc.getPage(p - 1);
|
|
@@ -45998,12 +46049,7 @@ function runPdftkCliSync(argv, files) {
|
|
|
45998
46049
|
` };
|
|
45999
46050
|
}
|
|
46000
46051
|
const overlayDoc = PdfDocument.load(overlayBytes);
|
|
46001
|
-
applyOverlayToDocument(
|
|
46002
|
-
resultDoc,
|
|
46003
|
-
overlayDoc,
|
|
46004
|
-
operation.includes("background") ? "background" : "stamp",
|
|
46005
|
-
operation.startsWith("multi")
|
|
46006
|
-
);
|
|
46052
|
+
applyOverlayToDocument(resultDoc, overlayDoc, operation.includes("background") ? "background" : "stamp", operation.startsWith("multi"));
|
|
46007
46053
|
if (shouldFlatten) {
|
|
46008
46054
|
flattenDocumentFormFields(resultDoc.cos);
|
|
46009
46055
|
}
|
|
@@ -46015,15 +46061,19 @@ function runPdftkCliSync(argv, files) {
|
|
|
46015
46061
|
if (dropXfa) {
|
|
46016
46062
|
const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
|
|
46017
46063
|
const acroForm = root ? resultDoc.cos.resolveDict(dictGet(root, "AcroForm")) : void 0;
|
|
46018
|
-
if (acroForm)
|
|
46064
|
+
if (acroForm)
|
|
46065
|
+
dictDelete(acroForm, "XFA");
|
|
46019
46066
|
}
|
|
46020
46067
|
if (dropXmp) {
|
|
46021
46068
|
const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
|
|
46022
|
-
if (root)
|
|
46069
|
+
if (root)
|
|
46070
|
+
dictDelete(root, "Metadata");
|
|
46023
46071
|
}
|
|
46024
46072
|
if (replacementFont && operation === "fill_form") {
|
|
46025
46073
|
const cleanFontName = replacementFont.startsWith("/") ? replacementFont.slice(1) : replacementFont;
|
|
46026
46074
|
for (const obj of resultDoc.cos.objects.values()) {
|
|
46075
|
+
if (++cooperativeWork % 64 === 0)
|
|
46076
|
+
yield;
|
|
46027
46077
|
if (obj.value.kind === "dict") {
|
|
46028
46078
|
const stNode = dictGet(obj.value, "Subtype");
|
|
46029
46079
|
const bfNode = dictGet(obj.value, "BaseFont");
|
|
@@ -46064,7 +46114,10 @@ function runPdftkCliSync(argv, files) {
|
|
|
46064
46114
|
}
|
|
46065
46115
|
if (uncompressStreams || compressStreams) {
|
|
46066
46116
|
for (const obj of resultDoc.cos.objects.values()) {
|
|
46067
|
-
if (
|
|
46117
|
+
if (++cooperativeWork % 64 === 0)
|
|
46118
|
+
yield;
|
|
46119
|
+
if (obj.value.kind !== "stream")
|
|
46120
|
+
continue;
|
|
46068
46121
|
const raw = resultDoc.cos.decodeStream(obj.value);
|
|
46069
46122
|
dictDelete(obj.value.dict, "Filter");
|
|
46070
46123
|
dictDelete(obj.value.dict, "DecodeParms");
|
|
@@ -46079,34 +46132,44 @@ function runPdftkCliSync(argv, files) {
|
|
|
46079
46132
|
}
|
|
46080
46133
|
const hasAllow = allowPermissions.size > 0;
|
|
46081
46134
|
const allAllowed = allowPermissions.has("allfeatures");
|
|
46082
|
-
const savedBytes = resultDoc.save(
|
|
46083
|
-
|
|
46084
|
-
|
|
46085
|
-
|
|
46086
|
-
|
|
46087
|
-
|
|
46088
|
-
|
|
46089
|
-
|
|
46090
|
-
|
|
46091
|
-
|
|
46092
|
-
|
|
46093
|
-
|
|
46094
|
-
|
|
46095
|
-
|
|
46096
|
-
|
|
46097
|
-
|
|
46098
|
-
|
|
46099
|
-
|
|
46100
|
-
|
|
46101
|
-
} : {}
|
|
46102
|
-
);
|
|
46135
|
+
const savedBytes = resultDoc.save(userPassword || ownerPassword ? {
|
|
46136
|
+
encrypt: {
|
|
46137
|
+
userPassword: userPassword ?? "",
|
|
46138
|
+
ownerPassword: ownerPassword ?? userPassword ?? "owner",
|
|
46139
|
+
revision: 6,
|
|
46140
|
+
...hasAllow ? {
|
|
46141
|
+
permissions: {
|
|
46142
|
+
print: allAllowed || allowPermissions.has("printing") || allowPermissions.has("degradedprinting"),
|
|
46143
|
+
modify: allAllowed || allowPermissions.has("modifycontents"),
|
|
46144
|
+
copy: allAllowed || allowPermissions.has("copycontents"),
|
|
46145
|
+
addNotes: allAllowed || allowPermissions.has("modifyannotations"),
|
|
46146
|
+
fillForms: allAllowed || allowPermissions.has("fillin") || allowPermissions.has("modifyannotations"),
|
|
46147
|
+
extractAccessibility: allAllowed || allowPermissions.has("screenreaders"),
|
|
46148
|
+
assemble: allAllowed || allowPermissions.has("assembly") || allowPermissions.has("modifycontents"),
|
|
46149
|
+
printHighRes: allAllowed || allowPermissions.has("printing")
|
|
46150
|
+
}
|
|
46151
|
+
} : {}
|
|
46152
|
+
}
|
|
46153
|
+
} : {});
|
|
46103
46154
|
if (!outputTarget || outputTarget === "-") {
|
|
46104
46155
|
return { exitCode: 0, stdout: "", stderr: "", stdoutBytes: savedBytes };
|
|
46105
46156
|
}
|
|
46106
46157
|
files.set(outputTarget, savedBytes);
|
|
46107
46158
|
return { exitCode: 0, stdout: "", stderr: "" };
|
|
46108
46159
|
}
|
|
46160
|
+
async function runPdftkCli(argv, files, signal) {
|
|
46161
|
+
return drainSteps(runPdftkCliSteps(argv, files, signal), signal);
|
|
46162
|
+
}
|
|
46163
|
+
function runPdftkCliSync(argv, files, signal) {
|
|
46164
|
+
const steps = runPdftkCliSteps(argv, files, signal);
|
|
46165
|
+
let next = steps.next();
|
|
46166
|
+
while (!next.done) {
|
|
46167
|
+
next = steps.next();
|
|
46168
|
+
}
|
|
46169
|
+
return next.value;
|
|
46170
|
+
}
|
|
46109
46171
|
async function executePdftk(context) {
|
|
46172
|
+
let cooperativeWork = 63;
|
|
46110
46173
|
const invocation = createOutputOperation(context, { write: async () => {
|
|
46111
46174
|
} });
|
|
46112
46175
|
try {
|
|
@@ -46125,6 +46188,7 @@ async function executePdftk(context) {
|
|
|
46125
46188
|
const chunks = [];
|
|
46126
46189
|
let total = 0;
|
|
46127
46190
|
for await (const chunk of readBytes(context.stdin, invocation.signal)) {
|
|
46191
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
46128
46192
|
chunks.push(chunk);
|
|
46129
46193
|
total += chunk.byteLength;
|
|
46130
46194
|
chargeBytes(chunk.byteLength);
|
|
@@ -46132,12 +46196,14 @@ async function executePdftk(context) {
|
|
|
46132
46196
|
const buf = new Uint8Array(total);
|
|
46133
46197
|
let off = 0;
|
|
46134
46198
|
for (const c of chunks) {
|
|
46199
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
46135
46200
|
buf.set(c, off);
|
|
46136
46201
|
off += c.byteLength;
|
|
46137
46202
|
}
|
|
46138
46203
|
vfsFiles.set("-", buf);
|
|
46139
46204
|
}
|
|
46140
46205
|
for (const token of argv) {
|
|
46206
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
46141
46207
|
if (token.startsWith("-") && token !== "-") continue;
|
|
46142
46208
|
const eqIdx = token.indexOf("=");
|
|
46143
46209
|
const filePath = eqIdx > 0 ? token.slice(eqIdx + 1) : token;
|
|
@@ -46149,8 +46215,9 @@ async function executePdftk(context) {
|
|
|
46149
46215
|
} catch {
|
|
46150
46216
|
}
|
|
46151
46217
|
}
|
|
46218
|
+
context.inputBudget?.check(0);
|
|
46152
46219
|
const existingSnap = new Map(vfsFiles);
|
|
46153
|
-
const res = await runPdftkCli(argv, vfsFiles);
|
|
46220
|
+
const res = await runPdftkCli(argv, vfsFiles, invocation.signal);
|
|
46154
46221
|
if (res.stderr) {
|
|
46155
46222
|
await writeBytes(context.stderr, new TextEncoder().encode(res.stderr), invocation.signal);
|
|
46156
46223
|
}
|
|
@@ -46165,6 +46232,7 @@ async function executePdftk(context) {
|
|
|
46165
46232
|
await writeBytes(stdout.output, outBytes, invocation.signal);
|
|
46166
46233
|
}
|
|
46167
46234
|
for (const [key, val] of vfsFiles.entries()) {
|
|
46235
|
+
if (++cooperativeWork % 64 === 0) await yieldTurn(context.signal);
|
|
46168
46236
|
if (key !== "-" && existingSnap.get(key) !== val) {
|
|
46169
46237
|
chargeBytes(val.byteLength);
|
|
46170
46238
|
const abs = resolveVfsPath(key);
|
|
@@ -46181,13 +46249,14 @@ async function executePdftk(context) {
|
|
|
46181
46249
|
await invocation.close();
|
|
46182
46250
|
}
|
|
46183
46251
|
}
|
|
46184
|
-
function createPdftkCommand(
|
|
46252
|
+
function createPdftkCommand(options = {}) {
|
|
46253
|
+
const maxInputBytes = InputByteBudget.limit(options.limits?.maxInputBytes);
|
|
46185
46254
|
return Object.freeze({
|
|
46186
46255
|
name: "pdftk",
|
|
46187
46256
|
runtimeIdentity: commandRuntimeIdentity,
|
|
46188
46257
|
description: "Manipulate PDF documents, fill/flatten AcroForms, and assemble pages via @poe-code/pdf-ast",
|
|
46189
46258
|
execute(context) {
|
|
46190
|
-
return
|
|
46259
|
+
return new InputByteBudget(maxInputBytes).run(context, executePdftk);
|
|
46191
46260
|
}
|
|
46192
46261
|
});
|
|
46193
46262
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type CommandDefinition } from "../safe-bash-contracts/command.js";
|
|
2
2
|
import type { VirtualShellPlugin } from "../safe-bash-contracts/plugin.js";
|
|
3
|
+
export interface PdftoppmLimits {
|
|
4
|
+
readonly maxInputBytes: number;
|
|
5
|
+
}
|
|
3
6
|
export interface PdftoppmCommandOptions {
|
|
7
|
+
readonly limits?: Partial<PdftoppmLimits>;
|
|
4
8
|
readonly replace?: boolean;
|
|
5
9
|
}
|
|
6
10
|
export interface PdftoppmCliResult {
|
|
@@ -9,21 +13,25 @@ export interface PdftoppmCliResult {
|
|
|
9
13
|
readonly stderr: string;
|
|
10
14
|
readonly stdoutBytes?: Uint8Array | undefined;
|
|
11
15
|
}
|
|
12
|
-
export declare function runPdftoppmCliSync(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
13
|
-
readonly onAllocateBytes?: (bytes: number) => void;
|
|
14
|
-
}): PdftoppmCliResult;
|
|
15
16
|
export declare function runPdftoppmCli(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
17
|
+
readonly signal?: AbortSignal;
|
|
16
18
|
readonly onAllocateBytes?: (bytes: number) => void;
|
|
17
19
|
}): Promise<PdftoppmCliResult>;
|
|
18
|
-
export declare function
|
|
19
|
-
|
|
20
|
-
export declare function runPdftocairoCliSync(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
20
|
+
export declare function runPdftoppmCliSync(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
21
|
+
readonly signal?: AbortSignal;
|
|
21
22
|
readonly onAllocateBytes?: (bytes: number) => void;
|
|
22
23
|
}): PdftoppmCliResult;
|
|
24
|
+
export declare function createPdftoppmCommand(options?: PdftoppmCommandOptions): CommandDefinition;
|
|
25
|
+
export declare const pdftoppmCommand: CommandDefinition;
|
|
23
26
|
export declare function runPdftocairoCli(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
27
|
+
readonly signal?: AbortSignal;
|
|
24
28
|
readonly onAllocateBytes?: (bytes: number) => void;
|
|
25
29
|
}): Promise<PdftoppmCliResult>;
|
|
26
|
-
export declare function
|
|
30
|
+
export declare function runPdftocairoCliSync(argv: readonly string[], files: Map<string, Uint8Array>, options?: {
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
readonly onAllocateBytes?: (bytes: number) => void;
|
|
33
|
+
}): PdftoppmCliResult;
|
|
34
|
+
export declare function createPdftocairoCommand(options?: PdftoppmCommandOptions): CommandDefinition;
|
|
27
35
|
export declare const pdftocairoCommand: CommandDefinition;
|
|
28
36
|
export declare function pdftoppmPlugin(options?: PdftoppmCommandsOptions): VirtualShellPlugin;
|
|
29
37
|
export declare const pdftoppmCommands: typeof pdftoppmPlugin;
|