@poe-platform/safe-bash 0.1.781 → 0.1.783
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 +40 -0
- package/dist/office-package/zip-sync.d.ts +2 -0
- package/dist/office-package/zip-sync.js +111 -0
- package/dist/safe-bash/chunks/chunk-4FDQJUFW.js +3464 -0
- package/dist/safe-bash/chunks/csvkit-K55OYAQC.js +1564 -0
- package/dist/safe-bash/chunks/ffmpeg-BEFTQ6DZ.js +60 -0
- package/dist/safe-bash/chunks/gh-HQWOWLWE.js +41 -0
- package/dist/safe-bash/chunks/git-UFNPAOYZ.js +52 -0
- package/dist/safe-bash/chunks/imagemagick-53BMHH6D.js +134 -0
- package/dist/safe-bash/chunks/implementation-QUTAAYMT.js +105 -0
- package/dist/safe-bash/chunks/pdfimages-4OYI6FLG.js +73 -0
- package/dist/safe-bash/chunks/pdfinfo-I7U6TQPP.js +153 -0
- package/dist/safe-bash/chunks/pdftk-SUA6FMHI.js +79 -0
- package/dist/safe-bash/chunks/pdftoppm-4C5DGEWX.js +139 -0
- package/dist/safe-bash/chunks/pdftotext-Y4WI225Y.js +118 -0
- package/dist/safe-bash/chunks/qpdf-IORB4RV5.js +68 -0
- package/dist/safe-bash/chunks/sips-WHAMJFEU.js +77 -0
- package/dist/safe-bash/chunks/soffice-SYEK6WJS.js +89 -0
- package/dist/safe-bash/chunks/wkhtmltopdf-ZIICWJLF.js +85 -0
- package/dist/safe-bash/command-chunks/chunk-2LP3VMPA.js +58 -0
- package/dist/safe-bash/command-chunks/{chunk-CG4JSOK2.js → chunk-3HDIDEUJ.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-4DSJDVBM.js +2897 -0
- package/dist/safe-bash/command-chunks/{chunk-GBHSE6ZO.js → chunk-5GRLAARV.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-7OKDCM5U.js +112 -0
- package/dist/safe-bash/command-chunks/{chunk-FH3D75FC.js → chunk-ADCGH6A7.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-MTKXVRXL.js → chunk-DREUDEQG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ADBFNLLK.js → chunk-FXYWQ6S4.js} +16 -14
- package/dist/safe-bash/command-chunks/{chunk-Y2KHC6TZ.js → chunk-IDKD76KR.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-K6KBYLQC.js → chunk-JUDOV5MJ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3ZK5F23O.js → chunk-L3MLMXL4.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-E5TEVROY.js → chunk-PFBJR2PY.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-YGYOVXTO.js → chunk-UUR2S7AD.js} +9 -5
- package/dist/safe-bash/command-chunks/chunk-VIVYKW7Q.js +101 -0
- package/dist/safe-bash/command-chunks/{chunk-I5GLTNVH.js → chunk-X4P42NYK.js} +2 -27
- package/dist/safe-bash/command-chunks/{chunk-XF6TXYLD.js → chunk-Z57TV6TC.js} +4 -54
- package/dist/safe-bash/command-chunks/{chunk-QDPRSPHQ.js → chunk-Z64BW7CG.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-X3IVPNC3.js → chunk-Z7TYZG3A.js} +5 -3
- package/dist/safe-bash/command-chunks/{chunk-GZXLPWT5.js → chunk-ZF3ZVGQC.js} +259 -258
- package/dist/safe-bash/command-chunks/{pptx-ZL6L7KP2-QVZEYFUV.js → pptx-KY2OJWZW-76LBHCHD.js} +4 -3
- package/dist/safe-bash/commands/csvkit/index.d.ts +1 -8
- package/dist/safe-bash/commands/csvkit/index.js +5 -1639
- package/dist/safe-bash/commands/csvkit/sync.d.ts +9 -0
- package/dist/safe-bash/commands/csvkit/sync.js +1639 -0
- package/dist/safe-bash/commands/pandoc/implementation.d.ts +8 -0
- package/dist/safe-bash/commands/pandoc/implementation.js +92 -0
- package/dist/safe-bash/commands/pandoc/index.d.ts +2 -6
- package/dist/safe-bash/commands/pandoc/index.js +2 -90
- package/dist/safe-bash/core.browser.js +808 -6271
- package/dist/safe-bash/core.d.ts +17 -16
- package/dist/safe-bash/core.js +17 -16
- package/dist/safe-bash/lazy-gh.d.ts +10 -0
- package/dist/safe-bash/lazy-gh.js +30 -0
- package/dist/safe-bash/lazy-optional.d.ts +499 -0
- package/dist/safe-bash/lazy-optional.js +609 -0
- package/dist/safe-bash/plugins/composition.d.ts +1 -1
- package/dist/safe-bash/plugins/composition.js +1 -1
- package/dist/safe-bash/plugins/lazy-command.d.ts +9 -0
- package/dist/safe-bash/plugins/lazy-command.js +57 -0
- package/dist/safe-bash/shell/runtime.js +24 -25
- package/dist/safe-bash-command-csvkit/cli/lexical.d.ts +3 -0
- package/dist/safe-bash-command-csvkit/cli/parser.d.ts +1 -2
- package/dist/safe-bash-command-csvkit/codecs/python.js +3 -2
- package/dist/safe-bash-command-csvkit/codecs/utf8.js +2 -1
- package/dist/safe-bash-command-csvkit/index.js +453 -3270
- package/dist/safe-bash-command-csvkit/sync-support.d.ts +7 -0
- package/dist/safe-bash-command-csvkit/sync-support.js +31 -0
- package/dist/safe-bash-command-gh/index.js +25 -17
- package/dist/safe-bash-command-git/index.js +6 -10
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-pandoc/citeproc-filters.js +4 -2
- package/dist/safe-bash-command-pandoc/command.js +8 -6
- package/dist/safe-bash-command-pandoc/index.js +8 -6
- package/dist/safe-bash-command-pandoc/lua-filters.js +3 -2
- package/dist/safe-bash-command-pandoc/options.d.ts +5 -0
- package/dist/safe-bash-command-pandoc/options.js +93 -0
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.d.ts +1 -2
- package/dist/safe-bash-command-soffice/index.js +22 -18
- package/dist/safe-bash-command-ssconvert/commands.js +2 -2
- package/dist/safe-bash-command-ssconvert/core.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/csv.js +2 -2
- package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
- package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
- package/dist/safe-bash-command-timeout/index.js +3 -3
- package/dist/safe-bash-command-yq/index.js +5 -5
- 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 +7 -7
- package/dist/safe-bash-compression-engine/index.js +6 -6
- package/dist/safe-bash-compression-engine/operand.js +7 -7
- package/dist/safe-bash-compression-engine/stream.js +6 -6
- package/dist/safe-bash-compression-engine/zstd-decode.js +5 -5
- 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 +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +10 -10
- package/dist/safe-bash-contracts/index.js +40 -40
- package/dist/safe-bash-io-engine/commands/search/requirements.js +4 -4
- package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
- package/dist/safe-bash-io-engine/internal.d.ts +9 -0
- package/dist/safe-bash-io-engine/internal.js +3 -3
- package/dist/safe-bash-query-engine/index.js +6 -6
- package/dist/safe-bash-query-engine/interpreter.js +5 -5
- package/dist/safe-bash-query-engine/query-core.js +6 -6
- package/dist/safe-bash-regex-engine/execution/bounded-provider.js +3 -3
- package/dist/safe-bash-regex-engine/index.js +2 -2
- package/dist/safe-bash-regex-engine/text/regex.js +2 -2
- package/dist/safe-bash-xml-engine/index.js +3 -3
- package/package.json +4 -4
- package/dist/safe-bash/command-chunks/{chunk-DC52GWRK.js → chunk-BUKYQBXO.js} +13 -13
- package/dist/safe-bash/command-chunks/{chunk-QJ3ONEBI.js → chunk-DEH3CMGL.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-Y64PA6IA.js → chunk-KHZZ4V3L.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-I7PKIGII.js → chunk-QIRUOY2W.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HQG2IBZL.js → chunk-TOSM3T3A.js} +6 -6
- package/dist/safe-bash/command-chunks/{chunk-F4IQCXZG.js → chunk-VBZMCL23.js} +4 -4
- package/dist/safe-bash/command-chunks/{chunk-J2NPH7DO.js → chunk-W2T7JWT3.js} +3 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/pdftoppm/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createPdftoppmCommand as createRawPdftoppmCommand,
|
|
12
|
+
createPdftocairoCommand as createRawPdftocairoCommand,
|
|
13
|
+
createPdftoppmCommands as createRawPdftoppmCommands,
|
|
14
|
+
runPdftoppmCliSync,
|
|
15
|
+
runPdftocairoCliSync
|
|
16
|
+
} from "../../safe-bash-command-pdftoppm/index.js";
|
|
17
|
+
export * from "../../safe-bash-command-pdftoppm/index.js";
|
|
18
|
+
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
19
|
+
function createPdftoppmCommand(options = {}) {
|
|
20
|
+
const def = createRawPdftoppmCommand(options);
|
|
21
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
22
|
+
return def;
|
|
23
|
+
}
|
|
24
|
+
function createPdftocairoCommand(options = {}) {
|
|
25
|
+
const def = createRawPdftocairoCommand(options);
|
|
26
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
27
|
+
return def;
|
|
28
|
+
}
|
|
29
|
+
function createPdftoppmCommands(options = {}) {
|
|
30
|
+
const defs = createRawPdftoppmCommands(options);
|
|
31
|
+
for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
|
|
32
|
+
return defs;
|
|
33
|
+
}
|
|
34
|
+
function pdftoppmCommands(options = {}) {
|
|
35
|
+
const commands = createPdftoppmCommands(options);
|
|
36
|
+
const replace = options.replace ?? false;
|
|
37
|
+
return {
|
|
38
|
+
name: "pdftoppm",
|
|
39
|
+
setup(host) {
|
|
40
|
+
for (const command of commands) host.commands.register(command, { replace });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var pdftoppmPlugin = pdftoppmCommands;
|
|
45
|
+
function evalSyncPdftoppm(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
46
|
+
try {
|
|
47
|
+
const files = /* @__PURE__ */ new Map();
|
|
48
|
+
if (inBytes !== void 0) files.set("-", inBytes);
|
|
49
|
+
const positionals = [];
|
|
50
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
51
|
+
const a = opArgs[i];
|
|
52
|
+
if (a === "-v" || a === "--version" || a === "-h" || a === "-help" || a === "--help" || a === "-?") {
|
|
53
|
+
const res2 = runPdftoppmCliSync(opArgs, files);
|
|
54
|
+
return res2.exitCode === 0 && !res2.stderr ? res2.stdout : void 0;
|
|
55
|
+
}
|
|
56
|
+
if (a === "-r" || a === "-rx" || a === "-ry" || a === "-scale-to" || a === "-scale-to-x" || a === "-scale-to-y" || a === "-f" || a === "-l" || a === "-x" || a === "-y" || a === "-W" || a === "-H" || a === "-sz" || a === "-sep" || a === "-setpageno" || a === "-defaultgray" || a === "-defaultrgb" || a === "-defaultcmyk" || a === "-upw" || a === "-opw" || a === "-tiffcompression" || a === "-aa" || a === "-aaVector" || a === "-thinlinemode" || a === "-freetype" || a === "-jpegopt") {
|
|
57
|
+
i++;
|
|
58
|
+
} else if (!a.startsWith("-") || a === "-") {
|
|
59
|
+
positionals.push(a);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const input = positionals[0] ?? "-";
|
|
63
|
+
if (input !== "-") {
|
|
64
|
+
const b = readFileSync?.(input);
|
|
65
|
+
if (!b || b.byteLength > 262144) return void 0;
|
|
66
|
+
files.set(input, b);
|
|
67
|
+
} else if (!files.has("-")) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
const snap = new Map(files);
|
|
71
|
+
const res = runPdftoppmCliSync(opArgs, files);
|
|
72
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
73
|
+
for (const [k, v] of files.entries()) {
|
|
74
|
+
if (snap.get(k) !== v) {
|
|
75
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (res.stdoutBytes) {
|
|
79
|
+
if (res.stdoutBytes.includes(0)) return void 0;
|
|
80
|
+
return utf8Decoder.decode(res.stdoutBytes);
|
|
81
|
+
}
|
|
82
|
+
return res.stdout;
|
|
83
|
+
} catch {
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function evalSyncPdftocairo(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
88
|
+
try {
|
|
89
|
+
const files = /* @__PURE__ */ new Map();
|
|
90
|
+
if (inBytes !== void 0) files.set("-", inBytes);
|
|
91
|
+
const positionals = [];
|
|
92
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
93
|
+
const a = opArgs[i];
|
|
94
|
+
if (a === "-v" || a === "--version" || a === "-h" || a === "-help" || a === "--help" || a === "-?") {
|
|
95
|
+
const res2 = runPdftocairoCliSync(opArgs, files);
|
|
96
|
+
return res2.exitCode === 0 && !res2.stderr ? res2.stdout : void 0;
|
|
97
|
+
}
|
|
98
|
+
if (a === "-r" || a === "-rx" || a === "-ry" || a === "-scale-to" || a === "-scale-to-x" || a === "-scale-to-y" || a === "-f" || a === "-l" || a === "-x" || a === "-y" || a === "-W" || a === "-H" || a === "-sz" || a === "-sep" || a === "-setpageno" || a === "-defaultgray" || a === "-defaultrgb" || a === "-defaultcmyk" || a === "-upw" || a === "-opw" || a === "-tiffcompression" || a === "-aa" || a === "-aaVector" || a === "-thinlinemode" || a === "-freetype" || a === "-jpegopt" || a === "-antialias" || a === "-icc" || a === "-paper" || a === "-paperw" || a === "-paperh") {
|
|
99
|
+
i++;
|
|
100
|
+
} else if (!a.startsWith("-") || a === "-") {
|
|
101
|
+
positionals.push(a);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const input = positionals[0] ?? "-";
|
|
105
|
+
if (input !== "-") {
|
|
106
|
+
const b = readFileSync?.(input);
|
|
107
|
+
if (!b || b.byteLength > 262144) return void 0;
|
|
108
|
+
files.set(input, b);
|
|
109
|
+
} else if (!files.has("-")) {
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
const snap = new Map(files);
|
|
113
|
+
const res = runPdftocairoCliSync(opArgs, files);
|
|
114
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
115
|
+
for (const [k, v] of files.entries()) {
|
|
116
|
+
if (snap.get(k) !== v) {
|
|
117
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (res.stdoutBytes) {
|
|
121
|
+
if (res.stdoutBytes.includes(0)) return void 0;
|
|
122
|
+
return utf8Decoder.decode(res.stdoutBytes);
|
|
123
|
+
}
|
|
124
|
+
return res.stdout;
|
|
125
|
+
} catch {
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
internal_exports.syncCommandEvaluators.evalSyncPdftoppm = evalSyncPdftoppm;
|
|
130
|
+
internal_exports.syncCommandEvaluators.evalSyncPdftocairo = evalSyncPdftocairo;
|
|
131
|
+
export {
|
|
132
|
+
createPdftocairoCommand,
|
|
133
|
+
createPdftoppmCommand,
|
|
134
|
+
createPdftoppmCommands,
|
|
135
|
+
evalSyncPdftocairo,
|
|
136
|
+
evalSyncPdftoppm,
|
|
137
|
+
pdftoppmCommands,
|
|
138
|
+
pdftoppmPlugin
|
|
139
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/pdftotext/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createPdftotextCommand as createRawPdftotextCommand,
|
|
12
|
+
createPdftotextCommands as createRawPdftotextCommands,
|
|
13
|
+
extractPdfToTextBytes,
|
|
14
|
+
runPdftohtmlCliSync
|
|
15
|
+
} from "../../safe-bash-command-pdftotext/index.js";
|
|
16
|
+
export * from "../../safe-bash-command-pdftotext/index.js";
|
|
17
|
+
function isDefaultPdftotextOptions(options) {
|
|
18
|
+
if (!options) return true;
|
|
19
|
+
const o = options;
|
|
20
|
+
return o.limits === void 0 && o.maxInputBytes === void 0 && o.maxOutputBytes === void 0;
|
|
21
|
+
}
|
|
22
|
+
function createPdftotextCommand(options = {}) {
|
|
23
|
+
const def = createRawPdftotextCommand(options);
|
|
24
|
+
if (isDefaultPdftotextOptions(options)) internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
function createPdftotextCommands(options = {}) {
|
|
28
|
+
const defs = createRawPdftotextCommands(options);
|
|
29
|
+
if (isDefaultPdftotextOptions(options)) {
|
|
30
|
+
for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
|
|
31
|
+
}
|
|
32
|
+
return defs;
|
|
33
|
+
}
|
|
34
|
+
function pdftotextCommands(options = {}) {
|
|
35
|
+
const commands = createPdftotextCommands(options);
|
|
36
|
+
const replace = options.replace ?? false;
|
|
37
|
+
return {
|
|
38
|
+
name: "pdftotext",
|
|
39
|
+
setup(host) {
|
|
40
|
+
for (const command of commands) host.commands.register(command, { replace });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var pdfTxtEncoder = new TextEncoder();
|
|
45
|
+
function evalSyncPdftotext(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
46
|
+
try {
|
|
47
|
+
const positionals = [];
|
|
48
|
+
let isHelpOrVer = false;
|
|
49
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
50
|
+
const a = opArgs[i];
|
|
51
|
+
if (a === "-listenc" || a === "-v" || a === "--version" || a === "-h" || a === "--help" || a === "-?") {
|
|
52
|
+
isHelpOrVer = true;
|
|
53
|
+
} else if (a === "-f" || a === "-l" || a === "-r" || a === "-x" || a === "-y" || a === "-W" || a === "-H" || a === "-fixed" || a === "-enc" || a === "-eol" || a === "-opw" || a === "-upw") {
|
|
54
|
+
i++;
|
|
55
|
+
} else if (a === "--") {
|
|
56
|
+
positionals.push(...opArgs.slice(i + 1));
|
|
57
|
+
break;
|
|
58
|
+
} else if (!a.startsWith("-") || a === "-") {
|
|
59
|
+
positionals.push(a);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (isHelpOrVer) {
|
|
63
|
+
const res2 = extractPdfToTextBytes(new Uint8Array(0), opArgs);
|
|
64
|
+
if (res2.exitCode !== 0 || res2.stderr) return void 0;
|
|
65
|
+
return res2.output;
|
|
66
|
+
}
|
|
67
|
+
const target = positionals[0] ?? "-";
|
|
68
|
+
const pdfBytes = target === "-" ? inBytes : readFileSync?.(target);
|
|
69
|
+
if (!pdfBytes || pdfBytes.byteLength > 262144) return void 0;
|
|
70
|
+
const res = extractPdfToTextBytes(pdfBytes, opArgs);
|
|
71
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
72
|
+
if (res.outputPath !== "-") {
|
|
73
|
+
if (!res.outputPath || !writeFileSync || !writeFileSync(res.outputPath, pdfTxtEncoder.encode(res.output))) return void 0;
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
return res.output;
|
|
77
|
+
} catch {
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function evalSyncPdftohtml(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
82
|
+
try {
|
|
83
|
+
const files = /* @__PURE__ */ new Map();
|
|
84
|
+
if (inBytes !== void 0) files.set("-", inBytes);
|
|
85
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
86
|
+
const a = opArgs[i];
|
|
87
|
+
if (["-f", "-l", "-zoom", "-fmt", "-enc", "-upw", "-opw"].includes(a)) {
|
|
88
|
+
i++;
|
|
89
|
+
} else if (!a.startsWith("-") && a !== "-") {
|
|
90
|
+
const b = readFileSync?.(a);
|
|
91
|
+
if (b) {
|
|
92
|
+
if (b.byteLength > 262144) return void 0;
|
|
93
|
+
files.set(a, b);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const snap = new Map(files);
|
|
98
|
+
const res = runPdftohtmlCliSync(opArgs, files);
|
|
99
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
100
|
+
for (const [k, v] of files.entries()) {
|
|
101
|
+
if (snap.get(k) !== v) {
|
|
102
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return res.stdout;
|
|
106
|
+
} catch {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
internal_exports.syncCommandEvaluators.evalSyncPdftotext = evalSyncPdftotext;
|
|
111
|
+
internal_exports.syncCommandEvaluators.evalSyncPdftohtml = evalSyncPdftohtml;
|
|
112
|
+
export {
|
|
113
|
+
createPdftotextCommand,
|
|
114
|
+
createPdftotextCommands,
|
|
115
|
+
evalSyncPdftohtml,
|
|
116
|
+
evalSyncPdftotext,
|
|
117
|
+
pdftotextCommands
|
|
118
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/qpdf/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createQpdfCommand as createRawQpdfCommand,
|
|
12
|
+
createQpdfCommands as createRawQpdfCommands,
|
|
13
|
+
runQpdfCliSync
|
|
14
|
+
} from "../../safe-bash-command-qpdf/index.js";
|
|
15
|
+
export * from "../../safe-bash-command-qpdf/index.js";
|
|
16
|
+
function createQpdfCommand(options = {}) {
|
|
17
|
+
const def = createRawQpdfCommand(options);
|
|
18
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
19
|
+
return def;
|
|
20
|
+
}
|
|
21
|
+
function createQpdfCommands(options = {}) {
|
|
22
|
+
const defs = createRawQpdfCommands(options);
|
|
23
|
+
for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
|
|
24
|
+
return defs;
|
|
25
|
+
}
|
|
26
|
+
function qpdfCommands(options = {}) {
|
|
27
|
+
const commands = createQpdfCommands(options);
|
|
28
|
+
const replace = options.replace ?? false;
|
|
29
|
+
return {
|
|
30
|
+
name: "qpdf",
|
|
31
|
+
setup(host) {
|
|
32
|
+
for (const command of commands) host.commands.register(command, { replace });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function evalSyncQpdf(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
37
|
+
try {
|
|
38
|
+
const files = /* @__PURE__ */ new Map();
|
|
39
|
+
if (inBytes !== void 0) files.set("-", inBytes);
|
|
40
|
+
for (const token of opArgs) {
|
|
41
|
+
if (token.startsWith("-") && token !== "-") continue;
|
|
42
|
+
if (token === "--") continue;
|
|
43
|
+
const b = readFileSync?.(token);
|
|
44
|
+
if (b) {
|
|
45
|
+
if (b.byteLength > 262144) return void 0;
|
|
46
|
+
files.set(token, b);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const snap = new Map(files);
|
|
50
|
+
const res = runQpdfCliSync(opArgs, files);
|
|
51
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
52
|
+
for (const [k, v] of files.entries()) {
|
|
53
|
+
if (snap.get(k) !== v) {
|
|
54
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return res.stdout;
|
|
58
|
+
} catch {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
internal_exports.syncCommandEvaluators.evalSyncQpdf = evalSyncQpdf;
|
|
63
|
+
export {
|
|
64
|
+
createQpdfCommand,
|
|
65
|
+
createQpdfCommands,
|
|
66
|
+
evalSyncQpdf,
|
|
67
|
+
qpdfCommands
|
|
68
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/sips/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createSipsCommand as createRawSipsCommand,
|
|
12
|
+
createSipsCommands as createRawSipsCommands,
|
|
13
|
+
runSipsCliSync
|
|
14
|
+
} from "../../safe-bash-command-sips/index.js";
|
|
15
|
+
export * from "../../safe-bash-command-sips/index.js";
|
|
16
|
+
function createSipsCommand(options = {}) {
|
|
17
|
+
const def = createRawSipsCommand(options);
|
|
18
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
19
|
+
return def;
|
|
20
|
+
}
|
|
21
|
+
function createSipsCommands(options = {}) {
|
|
22
|
+
const defs = createRawSipsCommands(options);
|
|
23
|
+
for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
|
|
24
|
+
return defs;
|
|
25
|
+
}
|
|
26
|
+
function sipsPlugin(options = {}) {
|
|
27
|
+
const command = createSipsCommand(options);
|
|
28
|
+
const replace = options.replace ?? false;
|
|
29
|
+
return {
|
|
30
|
+
name: "sips",
|
|
31
|
+
setup(host) {
|
|
32
|
+
host.commands.register(command, { replace });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var sipsCommands = sipsPlugin;
|
|
37
|
+
function evalSyncSips(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
38
|
+
try {
|
|
39
|
+
const files = /* @__PURE__ */ new Map();
|
|
40
|
+
if (inBytes !== void 0) files.set("-", inBytes);
|
|
41
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
42
|
+
const a = opArgs[i];
|
|
43
|
+
if (["-g", "--getProperty", "-s", "--setProperty", "-d", "--deleteProperty", "-r", "--rotate", "-f", "--flip", "-c", "--cropToHeightWidth", "-Z", "--resampleHeightWidthMax", "-z", "--resampleHeightWidth", "--resampleWidth", "--resampleHeight", "-p", "--padToHeightWidth", "--padColor", "-o", "--out"].includes(a)) {
|
|
44
|
+
if (a === "-s" || a === "--setProperty" || a === "-c" || a === "--cropToHeightWidth" || a === "-z" || a === "--resampleHeightWidth" || a === "-p" || a === "--padToHeightWidth") {
|
|
45
|
+
i += 2;
|
|
46
|
+
} else {
|
|
47
|
+
i += 1;
|
|
48
|
+
}
|
|
49
|
+
} else if (!a.startsWith("-") && a !== "-") {
|
|
50
|
+
const b = readFileSync?.(a);
|
|
51
|
+
if (b) {
|
|
52
|
+
if (b.byteLength > 262144) return void 0;
|
|
53
|
+
files.set(a, b);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const snap = new Map(files);
|
|
58
|
+
const res = runSipsCliSync(opArgs, files);
|
|
59
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
60
|
+
for (const [k, v] of files.entries()) {
|
|
61
|
+
if (snap.get(k) !== v) {
|
|
62
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return res.stdout;
|
|
66
|
+
} catch {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
internal_exports.syncCommandEvaluators.evalSyncSips = evalSyncSips;
|
|
71
|
+
export {
|
|
72
|
+
createSipsCommand,
|
|
73
|
+
createSipsCommands,
|
|
74
|
+
evalSyncSips,
|
|
75
|
+
sipsCommands,
|
|
76
|
+
sipsPlugin
|
|
77
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/soffice/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createSofficeCommand as createRawSofficeCommand,
|
|
12
|
+
createLibreofficeCommand as createRawLibreofficeCommand,
|
|
13
|
+
createSofficeCommands as createRawSofficeCommands,
|
|
14
|
+
runSofficeCliSync
|
|
15
|
+
} from "../../safe-bash-command-soffice/index.js";
|
|
16
|
+
export * from "../../safe-bash-command-soffice/index.js";
|
|
17
|
+
function createSofficeCommand(options = {}) {
|
|
18
|
+
const def = createRawSofficeCommand(options);
|
|
19
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
20
|
+
return def;
|
|
21
|
+
}
|
|
22
|
+
function createLibreofficeCommand(options = {}) {
|
|
23
|
+
const def = createRawLibreofficeCommand(options);
|
|
24
|
+
internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
function createSofficeCommands(options = {}) {
|
|
28
|
+
const defs = createRawSofficeCommands(options);
|
|
29
|
+
for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
|
|
30
|
+
return defs;
|
|
31
|
+
}
|
|
32
|
+
function sofficeCommands(options = {}) {
|
|
33
|
+
const commands = createSofficeCommands(options);
|
|
34
|
+
const replace = options.replace ?? false;
|
|
35
|
+
return {
|
|
36
|
+
name: "soffice",
|
|
37
|
+
setup(host) {
|
|
38
|
+
for (const command of commands) host.commands.register(command, { replace });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function evalSyncSoffice(opArgs, readFileSync, writeFileSync) {
|
|
43
|
+
try {
|
|
44
|
+
let hasHelpOrVer = false;
|
|
45
|
+
let hasCat = false;
|
|
46
|
+
let hasConvertTo = false;
|
|
47
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
48
|
+
const a = opArgs[i];
|
|
49
|
+
if (a === "--version" || a === "--help" || a === "-h") hasHelpOrVer = true;
|
|
50
|
+
else if (a === "--cat" || a === "-cat") hasCat = true;
|
|
51
|
+
else if (a === "--convert-to" || a.startsWith("--convert-to=")) hasConvertTo = true;
|
|
52
|
+
}
|
|
53
|
+
if (!hasHelpOrVer && !hasCat && !hasConvertTo) return void 0;
|
|
54
|
+
const files = /* @__PURE__ */ new Map();
|
|
55
|
+
if (!hasHelpOrVer) {
|
|
56
|
+
for (let i = 0; i < opArgs.length; i++) {
|
|
57
|
+
const a = opArgs[i];
|
|
58
|
+
if (a === "--convert-to" || a === "-convert-to" || a === "--outdir" || a === "-outdir" || a === "-o") {
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (a.startsWith("-")) continue;
|
|
63
|
+
const b = readFileSync?.(a);
|
|
64
|
+
if (!b || b.byteLength > 262144) return void 0;
|
|
65
|
+
files.set(a, b);
|
|
66
|
+
if (a.startsWith("/")) files.set(a, b);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const snap = new Map(files);
|
|
70
|
+
const res = runSofficeCliSync(opArgs, files);
|
|
71
|
+
if (res.exitCode !== 0 || res.stderr) return void 0;
|
|
72
|
+
for (const [k, v] of files.entries()) {
|
|
73
|
+
if (snap.get(k) !== v) {
|
|
74
|
+
if (!writeFileSync || !writeFileSync(k, v)) return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return res.stdout;
|
|
78
|
+
} catch {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
internal_exports.syncCommandEvaluators.evalSyncSoffice = evalSyncSoffice;
|
|
83
|
+
export {
|
|
84
|
+
createLibreofficeCommand,
|
|
85
|
+
createSofficeCommand,
|
|
86
|
+
createSofficeCommands,
|
|
87
|
+
evalSyncSoffice,
|
|
88
|
+
sofficeCommands
|
|
89
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
internal_exports
|
|
3
|
+
} from "./chunk-GJWUEOT6.js";
|
|
4
|
+
import {
|
|
5
|
+
init_platform
|
|
6
|
+
} from "./chunk-Q45QCA4J.js";
|
|
7
|
+
|
|
8
|
+
// packages/safe-bash/src/commands/wkhtmltopdf/index.ts
|
|
9
|
+
init_platform();
|
|
10
|
+
import {
|
|
11
|
+
createPdfAstWkhtmltopdfCommand,
|
|
12
|
+
informationText,
|
|
13
|
+
parseInvocation,
|
|
14
|
+
renderPdfAstSync,
|
|
15
|
+
wkhtmltopdfLimits
|
|
16
|
+
} from "../../safe-bash-command-wkhtmltopdf/index.js";
|
|
17
|
+
export * from "../../safe-bash-command-wkhtmltopdf/index.js";
|
|
18
|
+
function isDefaultWkhtmltopdfOptions(options) {
|
|
19
|
+
if (!options) return true;
|
|
20
|
+
return options.limits === void 0 && options.renderer === void 0;
|
|
21
|
+
}
|
|
22
|
+
function createWkhtmltopdfCommand(options = {}) {
|
|
23
|
+
const def = createPdfAstWkhtmltopdfCommand(options);
|
|
24
|
+
if (isDefaultWkhtmltopdfOptions(options)) internal_exports.builtInDirectContextExecutors.add(def.execute);
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
function createWkhtmltopdfCommands(options = {}) {
|
|
28
|
+
return [createWkhtmltopdfCommand(options)];
|
|
29
|
+
}
|
|
30
|
+
function wkhtmltopdfCommands(options = {}) {
|
|
31
|
+
const command = createWkhtmltopdfCommand(options);
|
|
32
|
+
return {
|
|
33
|
+
name: "wkhtmltopdf",
|
|
34
|
+
setup(host) {
|
|
35
|
+
host.commands.register(command, { replace: options.replace ?? false });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function evalSyncWkhtmltopdf(inBytes, opArgs, readFileSync, writeFileSync) {
|
|
40
|
+
if (opArgs.length === 0) return void 0;
|
|
41
|
+
try {
|
|
42
|
+
const signal = new AbortController().signal;
|
|
43
|
+
const initial = parseInvocation(opArgs, { endOfOptions: true, signal });
|
|
44
|
+
if (initial.mode === "information") {
|
|
45
|
+
return informationText(initial.global.action);
|
|
46
|
+
}
|
|
47
|
+
if (initial.mode === "conversion") {
|
|
48
|
+
const inputs = [];
|
|
49
|
+
for (const obj of initial.objects) {
|
|
50
|
+
if (obj.input === null) return void 0;
|
|
51
|
+
if (obj.input === "-") {
|
|
52
|
+
if (inBytes === void 0 || inBytes.byteLength > 262144) return void 0;
|
|
53
|
+
inputs.push(inBytes);
|
|
54
|
+
} else {
|
|
55
|
+
if (initial.output !== "-" && obj.input === initial.output) return void 0;
|
|
56
|
+
const b = readFileSync?.(obj.input);
|
|
57
|
+
if (!b || b.byteLength > 262144) return void 0;
|
|
58
|
+
inputs.push(b);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const pdfBytes = renderPdfAstSync({
|
|
62
|
+
job: initial,
|
|
63
|
+
inputs,
|
|
64
|
+
signal,
|
|
65
|
+
limits: wkhtmltopdfLimits
|
|
66
|
+
});
|
|
67
|
+
if (initial.output === "-") {
|
|
68
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(pdfBytes);
|
|
69
|
+
}
|
|
70
|
+
if (!writeFileSync || !initial.output) return void 0;
|
|
71
|
+
if (!writeFileSync(initial.output, pdfBytes)) return void 0;
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
} catch {
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
internal_exports.syncCommandEvaluators.evalSyncWkhtmltopdf = evalSyncWkhtmltopdf;
|
|
80
|
+
export {
|
|
81
|
+
createWkhtmltopdfCommand,
|
|
82
|
+
createWkhtmltopdfCommands,
|
|
83
|
+
evalSyncWkhtmltopdf,
|
|
84
|
+
wkhtmltopdfCommands
|
|
85
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_buffer
|
|
3
|
+
} from "./chunk-HX3SHTCE.js";
|
|
4
|
+
|
|
5
|
+
// packages/safe-bash-command-csvkit/dist/errors.js
|
|
6
|
+
init_buffer();
|
|
7
|
+
var CsvkitDiagnostic = class extends Error {
|
|
8
|
+
status;
|
|
9
|
+
constructor(message, status = 1) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.status = status;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var CsvkitBlocked = class extends CsvkitDiagnostic {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(`csvkit: unsupported or unqualified: ${message}`, 78);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var CsvkitOutputBudgetError = class extends CsvkitBlocked {
|
|
20
|
+
constructor() {
|
|
21
|
+
super("output byte budget exceeded");
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var CsvkitWorkBudgetError = class extends CsvkitBlocked {
|
|
25
|
+
constructor() {
|
|
26
|
+
super("work budget exceeded");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var CsvkitCleanupError = class extends AggregateError {
|
|
30
|
+
constructor(errors, message) {
|
|
31
|
+
super(errors, message);
|
|
32
|
+
this.name = "CsvkitCleanupError";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// packages/safe-bash-command-csvkit/dist/diagnostics/exception.js
|
|
37
|
+
init_buffer();
|
|
38
|
+
var PythonException = class extends CsvkitDiagnostic {
|
|
39
|
+
exceptionClass;
|
|
40
|
+
detail;
|
|
41
|
+
traceback;
|
|
42
|
+
constructor(exceptionClass, detail, traceback) {
|
|
43
|
+
super(detail);
|
|
44
|
+
this.exceptionClass = exceptionClass;
|
|
45
|
+
this.detail = detail;
|
|
46
|
+
this.traceback = traceback;
|
|
47
|
+
this.name = exceptionClass;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
CsvkitDiagnostic,
|
|
53
|
+
CsvkitBlocked,
|
|
54
|
+
CsvkitOutputBudgetError,
|
|
55
|
+
CsvkitWorkBudgetError,
|
|
56
|
+
CsvkitCleanupError,
|
|
57
|
+
PythonException
|
|
58
|
+
};
|