@poe-platform/safe-bash 0.1.782 → 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.
Files changed (116) hide show
  1. package/README.md +40 -0
  2. package/dist/office-package/zip-sync.d.ts +2 -0
  3. package/dist/office-package/zip-sync.js +111 -0
  4. package/dist/safe-bash/chunks/chunk-4FDQJUFW.js +3464 -0
  5. package/dist/safe-bash/chunks/csvkit-K55OYAQC.js +1564 -0
  6. package/dist/safe-bash/chunks/ffmpeg-BEFTQ6DZ.js +60 -0
  7. package/dist/safe-bash/chunks/gh-HQWOWLWE.js +41 -0
  8. package/dist/safe-bash/chunks/git-UFNPAOYZ.js +52 -0
  9. package/dist/safe-bash/chunks/imagemagick-53BMHH6D.js +134 -0
  10. package/dist/safe-bash/chunks/implementation-QUTAAYMT.js +105 -0
  11. package/dist/safe-bash/chunks/pdfimages-4OYI6FLG.js +73 -0
  12. package/dist/safe-bash/chunks/pdfinfo-I7U6TQPP.js +153 -0
  13. package/dist/safe-bash/chunks/pdftk-SUA6FMHI.js +79 -0
  14. package/dist/safe-bash/chunks/pdftoppm-4C5DGEWX.js +139 -0
  15. package/dist/safe-bash/chunks/pdftotext-Y4WI225Y.js +118 -0
  16. package/dist/safe-bash/chunks/qpdf-IORB4RV5.js +68 -0
  17. package/dist/safe-bash/chunks/sips-WHAMJFEU.js +77 -0
  18. package/dist/safe-bash/chunks/soffice-SYEK6WJS.js +89 -0
  19. package/dist/safe-bash/chunks/wkhtmltopdf-ZIICWJLF.js +85 -0
  20. package/dist/safe-bash/command-chunks/chunk-2LP3VMPA.js +58 -0
  21. package/dist/safe-bash/command-chunks/{chunk-CG4JSOK2.js → chunk-3HDIDEUJ.js} +1 -1
  22. package/dist/safe-bash/command-chunks/chunk-4DSJDVBM.js +2897 -0
  23. package/dist/safe-bash/command-chunks/{chunk-GBHSE6ZO.js → chunk-5GRLAARV.js} +1 -1
  24. package/dist/safe-bash/command-chunks/chunk-7OKDCM5U.js +112 -0
  25. package/dist/safe-bash/command-chunks/{chunk-FH3D75FC.js → chunk-ADCGH6A7.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-MTKXVRXL.js → chunk-DREUDEQG.js} +1 -1
  27. package/dist/safe-bash/command-chunks/{chunk-ADBFNLLK.js → chunk-FXYWQ6S4.js} +16 -14
  28. package/dist/safe-bash/command-chunks/{chunk-Y2KHC6TZ.js → chunk-IDKD76KR.js} +5 -3
  29. package/dist/safe-bash/command-chunks/{chunk-K6KBYLQC.js → chunk-JUDOV5MJ.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-3ZK5F23O.js → chunk-L3MLMXL4.js} +1 -1
  31. package/dist/safe-bash/command-chunks/{chunk-E5TEVROY.js → chunk-PFBJR2PY.js} +4 -4
  32. package/dist/safe-bash/command-chunks/{chunk-YGYOVXTO.js → chunk-UUR2S7AD.js} +9 -5
  33. package/dist/safe-bash/command-chunks/chunk-VIVYKW7Q.js +101 -0
  34. package/dist/safe-bash/command-chunks/{chunk-I5GLTNVH.js → chunk-X4P42NYK.js} +2 -27
  35. package/dist/safe-bash/command-chunks/{chunk-XF6TXYLD.js → chunk-Z57TV6TC.js} +4 -54
  36. package/dist/safe-bash/command-chunks/{chunk-QDPRSPHQ.js → chunk-Z64BW7CG.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-X3IVPNC3.js → chunk-Z7TYZG3A.js} +5 -3
  38. package/dist/safe-bash/command-chunks/{chunk-GZXLPWT5.js → chunk-ZF3ZVGQC.js} +259 -258
  39. package/dist/safe-bash/command-chunks/{pptx-ZL6L7KP2-QVZEYFUV.js → pptx-KY2OJWZW-76LBHCHD.js} +4 -3
  40. package/dist/safe-bash/commands/csvkit/index.d.ts +1 -8
  41. package/dist/safe-bash/commands/csvkit/index.js +5 -1639
  42. package/dist/safe-bash/commands/csvkit/sync.d.ts +9 -0
  43. package/dist/safe-bash/commands/csvkit/sync.js +1639 -0
  44. package/dist/safe-bash/commands/pandoc/implementation.d.ts +8 -0
  45. package/dist/safe-bash/commands/pandoc/implementation.js +92 -0
  46. package/dist/safe-bash/commands/pandoc/index.d.ts +2 -6
  47. package/dist/safe-bash/commands/pandoc/index.js +2 -90
  48. package/dist/safe-bash/core.browser.js +808 -6271
  49. package/dist/safe-bash/core.d.ts +17 -16
  50. package/dist/safe-bash/core.js +17 -16
  51. package/dist/safe-bash/lazy-gh.d.ts +10 -0
  52. package/dist/safe-bash/lazy-gh.js +30 -0
  53. package/dist/safe-bash/lazy-optional.d.ts +499 -0
  54. package/dist/safe-bash/lazy-optional.js +609 -0
  55. package/dist/safe-bash/plugins/composition.d.ts +1 -1
  56. package/dist/safe-bash/plugins/composition.js +1 -1
  57. package/dist/safe-bash/plugins/lazy-command.d.ts +9 -0
  58. package/dist/safe-bash/plugins/lazy-command.js +57 -0
  59. package/dist/safe-bash/shell/runtime.js +24 -25
  60. package/dist/safe-bash-command-csvkit/cli/lexical.d.ts +3 -0
  61. package/dist/safe-bash-command-csvkit/cli/parser.d.ts +1 -2
  62. package/dist/safe-bash-command-csvkit/codecs/python.js +3 -2
  63. package/dist/safe-bash-command-csvkit/codecs/utf8.js +2 -1
  64. package/dist/safe-bash-command-csvkit/index.js +453 -3270
  65. package/dist/safe-bash-command-csvkit/sync-support.d.ts +7 -0
  66. package/dist/safe-bash-command-csvkit/sync-support.js +31 -0
  67. package/dist/safe-bash-command-gh/index.js +25 -17
  68. package/dist/safe-bash-command-git/index.js +6 -10
  69. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  70. package/dist/safe-bash-command-pandoc/citeproc-filters.js +4 -2
  71. package/dist/safe-bash-command-pandoc/command.js +8 -6
  72. package/dist/safe-bash-command-pandoc/index.js +8 -6
  73. package/dist/safe-bash-command-pandoc/lua-filters.js +3 -2
  74. package/dist/safe-bash-command-pandoc/options.d.ts +5 -0
  75. package/dist/safe-bash-command-pandoc/options.js +93 -0
  76. package/dist/safe-bash-command-sips/index.js +2 -2
  77. package/dist/safe-bash-command-soffice/index.d.ts +1 -2
  78. package/dist/safe-bash-command-soffice/index.js +22 -18
  79. package/dist/safe-bash-command-ssconvert/commands.js +2 -2
  80. package/dist/safe-bash-command-ssconvert/core.js +2 -2
  81. package/dist/safe-bash-command-ssconvert/formats/csv.js +2 -2
  82. package/dist/safe-bash-command-ssconvert/formats/xls.js +3 -3
  83. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +3 -3
  84. package/dist/safe-bash-command-timeout/index.js +3 -3
  85. package/dist/safe-bash-command-yq/index.js +5 -5
  86. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  87. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  88. package/dist/safe-bash-compression-engine/files.js +7 -7
  89. package/dist/safe-bash-compression-engine/index.js +6 -6
  90. package/dist/safe-bash-compression-engine/operand.js +7 -7
  91. package/dist/safe-bash-compression-engine/stream.js +6 -6
  92. package/dist/safe-bash-compression-engine/zstd-decode.js +5 -5
  93. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  94. package/dist/safe-bash-contracts/escaping.js +9 -9
  95. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  96. package/dist/safe-bash-contracts/filesystem-output.js +10 -10
  97. package/dist/safe-bash-contracts/index.js +40 -40
  98. package/dist/safe-bash-io-engine/commands/search/requirements.js +4 -4
  99. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
  100. package/dist/safe-bash-io-engine/internal.d.ts +9 -0
  101. package/dist/safe-bash-io-engine/internal.js +3 -3
  102. package/dist/safe-bash-query-engine/index.js +6 -6
  103. package/dist/safe-bash-query-engine/interpreter.js +5 -5
  104. package/dist/safe-bash-query-engine/query-core.js +6 -6
  105. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +3 -3
  106. package/dist/safe-bash-regex-engine/index.js +2 -2
  107. package/dist/safe-bash-regex-engine/text/regex.js +2 -2
  108. package/dist/safe-bash-xml-engine/index.js +3 -3
  109. package/package.json +4 -4
  110. package/dist/safe-bash/command-chunks/{chunk-DC52GWRK.js → chunk-BUKYQBXO.js} +13 -13
  111. package/dist/safe-bash/command-chunks/{chunk-QJ3ONEBI.js → chunk-DEH3CMGL.js} +3 -3
  112. package/dist/safe-bash/command-chunks/{chunk-Y64PA6IA.js → chunk-KHZZ4V3L.js} +3 -3
  113. package/dist/safe-bash/command-chunks/{chunk-I7PKIGII.js → chunk-QIRUOY2W.js} +3 -3
  114. package/dist/safe-bash/command-chunks/{chunk-HQG2IBZL.js → chunk-TOSM3T3A.js} +6 -6
  115. package/dist/safe-bash/command-chunks/{chunk-F4IQCXZG.js → chunk-VBZMCL23.js} +4 -4
  116. package/dist/safe-bash/command-chunks/{chunk-J2NPH7DO.js → chunk-W2T7JWT3.js} +3 -3
@@ -0,0 +1,60 @@
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/ffmpeg/index.ts
9
+ init_platform();
10
+ import {
11
+ createFfmpegCommand as createRawFfmpegCommand,
12
+ createFfprobeCommand as createRawFfprobeCommand,
13
+ createFfmpegCommands as createRawFfmpegCommands,
14
+ evalSyncFfmpeg,
15
+ evalSyncFfprobe
16
+ } from "../../safe-bash-command-ffmpeg/index.js";
17
+ export * from "../../safe-bash-command-ffmpeg/index.js";
18
+ function createFfmpegCommand(options = {}) {
19
+ const def = createRawFfmpegCommand(options);
20
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
21
+ return def;
22
+ }
23
+ function createFfprobeCommand(options = {}) {
24
+ const def = createRawFfprobeCommand(options);
25
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
26
+ return def;
27
+ }
28
+ function createFfmpegCommands(options = {}) {
29
+ const pair = createRawFfmpegCommands(options);
30
+ for (let i = 0; i < pair.length; i++) internal_exports.builtInDirectContextExecutors.add(pair[i].execute);
31
+ return pair;
32
+ }
33
+ function ffmpegCommands(options = {}) {
34
+ const definitions = createFfmpegCommands(options);
35
+ return {
36
+ name: "ffmpeg-commands",
37
+ setup(host) {
38
+ if (!options.replace) {
39
+ for (const definition of definitions) {
40
+ if (host.commands.has(definition.name)) {
41
+ throw new Error(`Command already registered: ${definition.name}`);
42
+ }
43
+ }
44
+ }
45
+ for (const definition of definitions) {
46
+ host.commands.register(definition, { replace: options.replace ?? false });
47
+ }
48
+ }
49
+ };
50
+ }
51
+ internal_exports.syncCommandEvaluators.evalSyncFfmpeg = evalSyncFfmpeg;
52
+ internal_exports.syncCommandEvaluators.evalSyncFfprobe = evalSyncFfprobe;
53
+ export {
54
+ createFfmpegCommand,
55
+ createFfmpegCommands,
56
+ createFfprobeCommand,
57
+ evalSyncFfmpeg,
58
+ evalSyncFfprobe,
59
+ ffmpegCommands
60
+ };
@@ -0,0 +1,41 @@
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/gh/index.ts
9
+ init_platform();
10
+ import {
11
+ createGhCommand as createRawGhCommand,
12
+ createGhCommands as createRawGhCommands,
13
+ evalSyncGh
14
+ } from "../../safe-bash-command-gh/index.js";
15
+ export * from "../../safe-bash-command-gh/index.js";
16
+ function createGhCommand(options = {}) {
17
+ const def = createRawGhCommand(options);
18
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
19
+ return def;
20
+ }
21
+ function createGhCommands(options = {}) {
22
+ const defs = createRawGhCommands(options);
23
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
24
+ return defs;
25
+ }
26
+ function ghCommands(options = {}) {
27
+ const command = createGhCommand(options);
28
+ return {
29
+ name: "gh-commands",
30
+ setup(host) {
31
+ host.commands.register(command, { replace: options.replace ?? false });
32
+ }
33
+ };
34
+ }
35
+ internal_exports.syncCommandEvaluators.evalSyncGh = evalSyncGh;
36
+ export {
37
+ createGhCommand,
38
+ createGhCommands,
39
+ evalSyncGh,
40
+ ghCommands
41
+ };
@@ -0,0 +1,52 @@
1
+ import "./chunk-FJZNUUOQ.js";
2
+ import "./chunk-O6356Z27.js";
3
+ import "./chunk-T3VDYWKZ.js";
4
+ import {
5
+ internal_exports
6
+ } from "./chunk-GJWUEOT6.js";
7
+ import {
8
+ init_platform
9
+ } from "./chunk-Q45QCA4J.js";
10
+
11
+ // packages/safe-bash/src/commands/git/index.ts
12
+ init_platform();
13
+ import {
14
+ createGitCommand as createBaseGitCommand,
15
+ createGitCommands as createBaseGitCommands,
16
+ evalSyncGit
17
+ } from "../../safe-bash-command-git/index.js";
18
+ function isDefaultOptions(options) {
19
+ return options === void 0 || options.http === void 0 && options.wasmModule === void 0 && options.limits === void 0;
20
+ }
21
+ function createGitCommand(options = {}) {
22
+ const def = createBaseGitCommand(options);
23
+ if (isDefaultOptions(options)) {
24
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
25
+ }
26
+ return def;
27
+ }
28
+ function createGitCommands(options = {}) {
29
+ const defs = createBaseGitCommands(options);
30
+ if (isDefaultOptions(options)) {
31
+ for (const def of defs) internal_exports.builtInDirectContextExecutors.add(def.execute);
32
+ }
33
+ return defs;
34
+ }
35
+ function gitCommands(options = {}) {
36
+ const commands = createGitCommands(options);
37
+ return {
38
+ name: "git-commands",
39
+ setup(host) {
40
+ for (const command of commands) {
41
+ host.commands.register(command, { replace: options.replace ?? false });
42
+ }
43
+ }
44
+ };
45
+ }
46
+ internal_exports.syncCommandEvaluators.evalSyncGit = evalSyncGit;
47
+ export {
48
+ createGitCommand,
49
+ createGitCommands,
50
+ evalSyncGit,
51
+ gitCommands
52
+ };
@@ -0,0 +1,134 @@
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/imagemagick/index.ts
9
+ init_platform();
10
+ import {
11
+ createImagemagickCommands as createRawImagemagickCommands,
12
+ runIdentifyCliSync,
13
+ runConvertCliSync,
14
+ runMogrifyCliSync,
15
+ runCompositeCliSync,
16
+ runMontageCliSync,
17
+ runCompareCliSync,
18
+ runMagickCliSync
19
+ } from "../../safe-bash-command-imagemagick/index.js";
20
+ export * from "../../safe-bash-command-imagemagick/index.js";
21
+ function createImagemagickCommands(options = {}) {
22
+ const defs = createRawImagemagickCommands(options);
23
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
24
+ return defs;
25
+ }
26
+ function imagemagickPlugin(options = {}) {
27
+ const commands = createImagemagickCommands(options);
28
+ const replace = options.replace ?? false;
29
+ return {
30
+ name: "imagemagick",
31
+ setup(host) {
32
+ for (const command of commands) host.commands.register(command, { replace });
33
+ }
34
+ };
35
+ }
36
+ var imagemagickCommands = imagemagickPlugin;
37
+ var KNOWN_PREFIX_FORMATS = /* @__PURE__ */ new Set([
38
+ "png",
39
+ "png8",
40
+ "png24",
41
+ "png32",
42
+ "jpg",
43
+ "jpeg",
44
+ "gif",
45
+ "bmp",
46
+ "bmp2",
47
+ "bmp3",
48
+ "webp",
49
+ "tiff",
50
+ "tif",
51
+ "ppm",
52
+ "pgm",
53
+ "pbm",
54
+ "pnm",
55
+ "pam",
56
+ "svg",
57
+ "ico",
58
+ "cur",
59
+ "tga",
60
+ "hdr",
61
+ "exr",
62
+ "avif",
63
+ "heic",
64
+ "txt",
65
+ "info",
66
+ "json",
67
+ "null",
68
+ "histogram"
69
+ ]);
70
+ function evalSyncIdentify(cmdName, inBytes, opArgs, readFileSync, writeFileSync) {
71
+ try {
72
+ if (opArgs[0] === "-version" || opArgs[0] === "--version") {
73
+ return runIdentifyCliSync(opArgs, /* @__PURE__ */ new Map()).stdout;
74
+ }
75
+ const vfsFiles = /* @__PURE__ */ new Map();
76
+ if (inBytes !== void 0) vfsFiles.set("-", inBytes);
77
+ for (let i = 0; i < opArgs.length; i++) {
78
+ const token = opArgs[i];
79
+ if (token === "-" || token.endsWith(":-")) continue;
80
+ if (token.startsWith("-") || token.startsWith("+") || token === "(" || token === ")") continue;
81
+ let candidate = token.toLowerCase().startsWith("tile:") ? token.slice(5) : token;
82
+ const prefixMatch = /^([a-zA-Z0-9]+):(.*)$/.exec(candidate);
83
+ if (prefixMatch && KNOWN_PREFIX_FORMATS.has(prefixMatch[1].toLowerCase())) {
84
+ candidate = prefixMatch[2];
85
+ }
86
+ const bracketMatch = /^(.*)\[([^\]]+)\]$/.exec(candidate);
87
+ if (bracketMatch) {
88
+ candidate = bracketMatch[1];
89
+ }
90
+ if (!candidate) continue;
91
+ const b = readFileSync?.(candidate);
92
+ if (b) {
93
+ if (b.byteLength > 262144) return void 0;
94
+ vfsFiles.set(candidate, b);
95
+ }
96
+ }
97
+ const existingSnap = new Map(vfsFiles);
98
+ const res = cmdName === "identify" ? runIdentifyCliSync(opArgs, vfsFiles, inBytes) : cmdName === "magick" ? runMagickCliSync(opArgs, vfsFiles, inBytes) : cmdName === "convert" ? runConvertCliSync(opArgs, vfsFiles, inBytes) : cmdName === "mogrify" ? runMogrifyCliSync(opArgs, vfsFiles) : cmdName === "composite" ? runCompositeCliSync(opArgs, vfsFiles, inBytes) : cmdName === "montage" ? runMontageCliSync(opArgs, vfsFiles, inBytes) : cmdName === "compare" ? runCompareCliSync(opArgs, vfsFiles, inBytes) : void 0;
99
+ if (!res || res.exitCode !== 0 || res.stderr) return void 0;
100
+ let hasWrites = false;
101
+ for (const [key, val] of vfsFiles.entries()) {
102
+ if (existingSnap.get(key) !== val) {
103
+ hasWrites = true;
104
+ break;
105
+ }
106
+ }
107
+ if (hasWrites && !writeFileSync) return void 0;
108
+ let outText = res.stdout;
109
+ if (res.stdoutBytes) {
110
+ try {
111
+ outText = new TextDecoder("utf-8", { fatal: true }).decode(res.stdoutBytes);
112
+ } catch {
113
+ return void 0;
114
+ }
115
+ }
116
+ if (hasWrites && writeFileSync) {
117
+ for (const [key, val] of vfsFiles.entries()) {
118
+ if (existingSnap.get(key) !== val) {
119
+ if (!writeFileSync(key, val)) return void 0;
120
+ }
121
+ }
122
+ }
123
+ return outText;
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }
128
+ internal_exports.syncCommandEvaluators.evalSyncIdentify = evalSyncIdentify;
129
+ export {
130
+ createImagemagickCommands,
131
+ evalSyncIdentify,
132
+ imagemagickCommands,
133
+ imagemagickPlugin
134
+ };
@@ -0,0 +1,105 @@
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/pandoc/implementation.ts
9
+ init_platform();
10
+ import {
11
+ createPandocCommand as createRawPandocCommand,
12
+ createPandocCommands as createRawPandocCommands,
13
+ inspectFormats,
14
+ parseConversionArgs,
15
+ convertSync
16
+ } from "../../safe-bash-command-pandoc/index.js";
17
+ export * from "../../safe-bash-command-pandoc/index.js";
18
+ function createPandocCommand(options = {}, hasCommand) {
19
+ const def = createRawPandocCommand(options, hasCommand);
20
+ if (options.limits === void 0 && options.filters === void 0 && options.jsonFilterCommand === void 0 && options.citeproc === void 0) {
21
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
22
+ }
23
+ return def;
24
+ }
25
+ function createPandocCommands(options = {}) {
26
+ const defs = createRawPandocCommands(options);
27
+ if (options.limits === void 0 && options.filters === void 0 && options.jsonFilterCommand === void 0 && options.citeproc === void 0) {
28
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
29
+ }
30
+ return defs;
31
+ }
32
+ function pandocCommands(options = {}) {
33
+ let hasCommand;
34
+ const command = createPandocCommand(options, (name) => hasCommand?.(name) ?? false);
35
+ return {
36
+ name: "pandoc",
37
+ setup(host) {
38
+ hasCommand = (name) => host.commands.has(name);
39
+ host.commands.register(command, { replace: options.replace ?? false });
40
+ }
41
+ };
42
+ }
43
+ function evalSyncPandoc(inBytes, opArgs, readFileSync, writeFileSync) {
44
+ try {
45
+ if (opArgs.length > 0 && opArgs.every((a) => a === "--list-input-formats" || a === "--list-output-formats")) {
46
+ return inspectFormats(opArgs);
47
+ }
48
+ for (let i = 0; i < opArgs.length; i++) {
49
+ const a = opArgs[i];
50
+ if (a === "-d" || a === "--defaults" || a.startsWith("-d") || a.startsWith("--defaults=")) {
51
+ return void 0;
52
+ }
53
+ }
54
+ const signal = new AbortController().signal;
55
+ const parsed = parseConversionArgs(
56
+ opArgs,
57
+ {
58
+ cwd: "/",
59
+ ...inBytes === void 0 ? {} : { stdin: [inBytes] },
60
+ readFile: async () => new Uint8Array(0),
61
+ writeFile: async () => {
62
+ }
63
+ },
64
+ signal
65
+ );
66
+ const inputs = [];
67
+ if (!parsed.operands) {
68
+ if (inBytes === void 0 || inBytes.byteLength > 262144) return void 0;
69
+ inputs.push({ bytes: inBytes });
70
+ } else {
71
+ for (const op of parsed.operands) {
72
+ if (op.source === void 0) {
73
+ if (inBytes === void 0 || inBytes.byteLength > 262144) return void 0;
74
+ inputs.push({ bytes: inBytes });
75
+ } else {
76
+ if (parsed.destination && op.source === parsed.destination) return void 0;
77
+ const b = readFileSync?.(op.source);
78
+ if (!b || b.byteLength > 262144) return void 0;
79
+ inputs.push({ bytes: b, source: op.source, ...op.base === void 0 ? {} : { base: op.base } });
80
+ }
81
+ }
82
+ }
83
+ const serialized = convertSync(inputs, parsed.options);
84
+ if (!serialized) return void 0;
85
+ if (parsed.destination !== void 0) {
86
+ if (!writeFileSync) return void 0;
87
+ const outBytes = serialized.kind === "binary" ? serialized.bytes : new TextEncoder().encode(serialized.text);
88
+ if (!writeFileSync(parsed.destination, outBytes)) return void 0;
89
+ return "";
90
+ }
91
+ if (serialized.kind === "text") {
92
+ return serialized.text;
93
+ }
94
+ return new TextDecoder("utf-8", { fatal: true }).decode(serialized.bytes);
95
+ } catch {
96
+ return void 0;
97
+ }
98
+ }
99
+ internal_exports.syncCommandEvaluators.evalSyncPandoc = evalSyncPandoc;
100
+ export {
101
+ createPandocCommand,
102
+ createPandocCommands,
103
+ evalSyncPandoc,
104
+ pandocCommands
105
+ };
@@ -0,0 +1,73 @@
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/pdfimages/index.ts
9
+ init_platform();
10
+ import {
11
+ createPdfimagesCommand as createRawPdfimagesCommand,
12
+ createPdfimagesCommands as createRawPdfimagesCommands,
13
+ runPdfimagesCliSync
14
+ } from "../../safe-bash-command-pdfimages/index.js";
15
+ export * from "../../safe-bash-command-pdfimages/index.js";
16
+ function createPdfimagesCommand(options = {}) {
17
+ const def = createRawPdfimagesCommand(options);
18
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
19
+ return def;
20
+ }
21
+ function createPdfimagesCommands(options = {}) {
22
+ const defs = createRawPdfimagesCommands(options);
23
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
24
+ return defs;
25
+ }
26
+ function pdfimagesPlugin(options = {}) {
27
+ const command = createPdfimagesCommand(options);
28
+ const replace = options.replace ?? false;
29
+ return {
30
+ name: "pdfimages",
31
+ setup(host) {
32
+ host.commands.register(command, { replace });
33
+ }
34
+ };
35
+ }
36
+ var pdfimagesCommands = pdfimagesPlugin;
37
+ function evalSyncPdfimages(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 (a === "-f" || a === "-l" || a === "-upw" || a === "-opw") {
44
+ i++;
45
+ } else if (!a.startsWith("-") && a !== "-") {
46
+ const b = readFileSync?.(a);
47
+ if (b) {
48
+ if (b.byteLength > 262144) return void 0;
49
+ files.set(a, b);
50
+ }
51
+ }
52
+ }
53
+ const snap = new Map(files);
54
+ const res = runPdfimagesCliSync(opArgs, files);
55
+ if (res.exitCode !== 0 || res.stderr) return void 0;
56
+ for (const [k, v] of files.entries()) {
57
+ if (snap.get(k) !== v) {
58
+ if (!writeFileSync || !writeFileSync(k, v)) return void 0;
59
+ }
60
+ }
61
+ return res.stdout;
62
+ } catch {
63
+ return void 0;
64
+ }
65
+ }
66
+ internal_exports.syncCommandEvaluators.evalSyncPdfimages = evalSyncPdfimages;
67
+ export {
68
+ createPdfimagesCommand,
69
+ createPdfimagesCommands,
70
+ evalSyncPdfimages,
71
+ pdfimagesCommands,
72
+ pdfimagesPlugin
73
+ };
@@ -0,0 +1,153 @@
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/pdfinfo/index.ts
9
+ init_platform();
10
+ import {
11
+ createPdfinfoCommand as createRawPdfinfoCommand,
12
+ createPdfinfoCommands as createRawPdfinfoCommands,
13
+ createPdffontsCommand as createRawPdffontsCommand,
14
+ createPdfdetachCommand as createRawPdfdetachCommand,
15
+ createPdftocairoCommand as createRawPdftocairoCommand,
16
+ inspectPdfBytes,
17
+ runPdffontsCliSync,
18
+ runPdfdetachCliSync
19
+ } from "../../safe-bash-command-pdfinfo/index.js";
20
+ export * from "../../safe-bash-command-pdfinfo/index.js";
21
+ function createPdfinfoCommand(options = {}) {
22
+ const def = createRawPdfinfoCommand(options);
23
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
24
+ return def;
25
+ }
26
+ function createPdffontsCommand(options = {}) {
27
+ const def = createRawPdffontsCommand(options);
28
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
29
+ return def;
30
+ }
31
+ function createPdfdetachCommand(options = {}) {
32
+ const def = createRawPdfdetachCommand(options);
33
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
34
+ return def;
35
+ }
36
+ function createPdftocairoCommand(options = {}) {
37
+ const def = createRawPdftocairoCommand(options);
38
+ internal_exports.builtInDirectContextExecutors.add(def.execute);
39
+ return def;
40
+ }
41
+ function createPdfinfoCommands(options = {}) {
42
+ const defs = createRawPdfinfoCommands(options);
43
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
44
+ return defs;
45
+ }
46
+ function pdfinfoCommands(options = {}) {
47
+ const commands = createPdfinfoCommands(options);
48
+ const replace = options.replace ?? false;
49
+ return {
50
+ name: "pdfinfo",
51
+ setup(host) {
52
+ for (const command of commands) host.commands.register(command, { replace });
53
+ }
54
+ };
55
+ }
56
+ function evalSyncPdfinfo(inBytes, opArgs, readFileSync) {
57
+ try {
58
+ let inputFile;
59
+ let isHelpOrVer = false;
60
+ for (let i = 0; i < opArgs.length; i++) {
61
+ const a = opArgs[i];
62
+ if (a === "-listenc" || a === "-v" || a === "--version" || a === "-h" || a === "--help" || a === "-?") {
63
+ isHelpOrVer = true;
64
+ } else if (a === "-f" || a === "-l" || a === "-enc" || a === "-upw" || a === "-opw") {
65
+ i++;
66
+ } else if (a === "--") {
67
+ if (i + 1 < opArgs.length) inputFile = opArgs[i + 1];
68
+ break;
69
+ } else if (!a.startsWith("-") || a === "-") {
70
+ if (inputFile === void 0) inputFile = a;
71
+ }
72
+ }
73
+ if (isHelpOrVer) {
74
+ const res2 = inspectPdfBytes(new Uint8Array(0), opArgs);
75
+ if (res2.exitCode !== 0 || res2.stderr) return void 0;
76
+ return res2.stdout;
77
+ }
78
+ const target = inputFile ?? "-";
79
+ const pdfBytes = target === "-" ? inBytes : readFileSync?.(target);
80
+ if (!pdfBytes || pdfBytes.byteLength > 262144) return void 0;
81
+ const res = inspectPdfBytes(
82
+ pdfBytes,
83
+ opArgs,
84
+ target === "-" ? { isStdin: true, fileSize: 0 } : { fileSize: pdfBytes.byteLength }
85
+ );
86
+ if (res.exitCode !== 0 || res.stderr) return void 0;
87
+ return res.stdout;
88
+ } catch {
89
+ return void 0;
90
+ }
91
+ }
92
+ function evalSyncPdffonts(inBytes, opArgs, readFileSync) {
93
+ try {
94
+ const files = /* @__PURE__ */ new Map();
95
+ if (inBytes !== void 0) files.set("-", inBytes);
96
+ for (let i = 0; i < opArgs.length; i++) {
97
+ const a = opArgs[i];
98
+ if (a === "-f" || a === "-l" || a === "-upw" || a === "-opw") {
99
+ i++;
100
+ } else if (!a.startsWith("-") && a !== "-") {
101
+ const b = readFileSync?.(a);
102
+ if (!b || b.byteLength > 262144) return void 0;
103
+ files.set(a, b);
104
+ }
105
+ }
106
+ const res = runPdffontsCliSync(opArgs, files);
107
+ if (res.exitCode !== 0 || res.stderr) return void 0;
108
+ return res.stdout;
109
+ } catch {
110
+ return void 0;
111
+ }
112
+ }
113
+ function evalSyncPdfdetach(inBytes, opArgs, readFileSync, writeFileSync) {
114
+ try {
115
+ const files = /* @__PURE__ */ new Map();
116
+ if (inBytes !== void 0) files.set("-", inBytes);
117
+ for (let i = 0; i < opArgs.length; i++) {
118
+ const a = opArgs[i];
119
+ if (a === "-upw" || a === "-opw" || a === "-enc" || a === "-save" || a === "-savefile" || a === "-o") {
120
+ i++;
121
+ } else if (!a.startsWith("-") && a !== "-") {
122
+ const b = readFileSync?.(a);
123
+ if (!b || b.byteLength > 262144) return void 0;
124
+ files.set(a, b);
125
+ }
126
+ }
127
+ const snap = new Map(files);
128
+ const res = runPdfdetachCliSync(opArgs, files);
129
+ if (res.exitCode !== 0 || res.stderr) return void 0;
130
+ for (const [k, v] of files.entries()) {
131
+ if (snap.get(k) !== v) {
132
+ if (!writeFileSync || !writeFileSync(k, v)) return void 0;
133
+ }
134
+ }
135
+ return res.stdout;
136
+ } catch {
137
+ return void 0;
138
+ }
139
+ }
140
+ internal_exports.syncCommandEvaluators.evalSyncPdfinfo = evalSyncPdfinfo;
141
+ internal_exports.syncCommandEvaluators.evalSyncPdffonts = evalSyncPdffonts;
142
+ internal_exports.syncCommandEvaluators.evalSyncPdfdetach = evalSyncPdfdetach;
143
+ export {
144
+ createPdfdetachCommand,
145
+ createPdffontsCommand,
146
+ createPdfinfoCommand,
147
+ createPdfinfoCommands,
148
+ createPdftocairoCommand,
149
+ evalSyncPdfdetach,
150
+ evalSyncPdffonts,
151
+ evalSyncPdfinfo,
152
+ pdfinfoCommands
153
+ };
@@ -0,0 +1,79 @@
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/pdftk/index.ts
9
+ init_platform();
10
+ import {
11
+ createPdftkCommand as createRawPdftkCommand,
12
+ createPdftkCommands as createRawPdftkCommands,
13
+ runPdftkCliSync
14
+ } from "../../safe-bash-command-pdftk/index.js";
15
+ export * from "../../safe-bash-command-pdftk/index.js";
16
+ function isDefaultPdftkOptions(options) {
17
+ if (!options) return true;
18
+ const o = options;
19
+ return o.limits === void 0 && o.maxInputBytes === void 0 && o.maxOutputBytes === void 0;
20
+ }
21
+ function createPdftkCommand(options = {}) {
22
+ const def = createRawPdftkCommand(options);
23
+ if (isDefaultPdftkOptions(options)) internal_exports.builtInDirectContextExecutors.add(def.execute);
24
+ return def;
25
+ }
26
+ function createPdftkCommands(options = {}) {
27
+ const defs = createRawPdftkCommands(options);
28
+ if (isDefaultPdftkOptions(options)) {
29
+ for (let i = 0; i < defs.length; i++) internal_exports.builtInDirectContextExecutors.add(defs[i].execute);
30
+ }
31
+ return defs;
32
+ }
33
+ function pdftkPlugin(options = {}) {
34
+ const command = createPdftkCommand(options);
35
+ const replace = options.replace ?? false;
36
+ return {
37
+ name: "pdftk",
38
+ setup(host) {
39
+ host.commands.register(command, { replace });
40
+ }
41
+ };
42
+ }
43
+ var pdftkCommands = pdftkPlugin;
44
+ function evalSyncPdftk(inBytes, opArgs, readFileSync, writeFileSync) {
45
+ try {
46
+ const files = /* @__PURE__ */ new Map();
47
+ if (inBytes !== void 0) files.set("-", inBytes);
48
+ for (const token of opArgs) {
49
+ if (token.startsWith("-") && token !== "-") continue;
50
+ const eq = token.indexOf("=");
51
+ const filePath = eq > 0 ? token.slice(eq + 1) : token;
52
+ if (filePath === "-") continue;
53
+ const b = readFileSync?.(filePath);
54
+ if (b) {
55
+ if (b.byteLength > 262144) return void 0;
56
+ files.set(filePath, b);
57
+ }
58
+ }
59
+ const snap = new Map(files);
60
+ const res = runPdftkCliSync(opArgs, files);
61
+ if (res.exitCode !== 0 || res.stderr || res.stdoutBytes) return void 0;
62
+ for (const [k, v] of files.entries()) {
63
+ if (snap.get(k) !== v) {
64
+ if (!writeFileSync || !writeFileSync(k, v)) return void 0;
65
+ }
66
+ }
67
+ return res.stdout;
68
+ } catch {
69
+ return void 0;
70
+ }
71
+ }
72
+ internal_exports.syncCommandEvaluators.evalSyncPdftk = evalSyncPdftk;
73
+ export {
74
+ createPdftkCommand,
75
+ createPdftkCommands,
76
+ evalSyncPdftk,
77
+ pdftkCommands,
78
+ pdftkPlugin
79
+ };