@poe-platform/safe-bash 0.1.757 → 0.1.758

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 (55) hide show
  1. package/dist/image-ast/index.browser.js +72 -19
  2. package/dist/image-ast/index.js +72 -19
  3. package/dist/pdf-ast/ast.d.ts +3 -0
  4. package/dist/pdf-ast/index.js +88 -36
  5. package/dist/safe-bash/command-chunks/{chunk-F3J5ZLKF.js → chunk-522TDVLS.js} +1 -1
  6. package/dist/safe-bash/command-chunks/{chunk-VFS2MDAB.js → chunk-6YLD37NH.js} +2 -2
  7. package/dist/safe-bash/command-chunks/{chunk-YI3GKJ7Q.js → chunk-766IWMTB.js} +2 -2
  8. package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
  9. package/dist/safe-bash/command-chunks/{chunk-S4MLIYSN.js → chunk-J2NPH7DO.js} +4 -0
  10. package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-L2C5TIII.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-TCAGGM44.js} +72 -19
  12. package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-XYCWDGOG.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
  14. package/dist/safe-bash-command-column/column.js +3 -3
  15. package/dist/safe-bash-command-column/index.js +3 -3
  16. package/dist/safe-bash-command-column/layout.js +2 -2
  17. package/dist/safe-bash-command-factor/command.js +2 -2
  18. package/dist/safe-bash-command-factor/index.js +2 -2
  19. package/dist/safe-bash-command-ffmpeg/index.js +5923 -5893
  20. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  21. package/dist/safe-bash-command-pandoc/command.js +3 -3
  22. package/dist/safe-bash-command-pandoc/index.js +3 -3
  23. package/dist/safe-bash-command-pdfimages/index.js +72 -19
  24. package/dist/safe-bash-command-pdfinfo/index.js +88 -36
  25. package/dist/safe-bash-command-pdftk/index.js +72 -19
  26. package/dist/safe-bash-command-pdftoppm/index.js +88 -36
  27. package/dist/safe-bash-command-pdftotext/index.js +72 -19
  28. package/dist/safe-bash-command-qpdf/index.js +72 -19
  29. package/dist/safe-bash-command-sips/index.js +2 -2
  30. package/dist/safe-bash-command-soffice/index.js +2 -2
  31. package/dist/safe-bash-command-ssconvert/command-bindings.d.ts +18 -0
  32. package/dist/safe-bash-command-ssconvert/command.d.ts +5 -14
  33. package/dist/safe-bash-command-ssconvert/commands.d.ts +6 -0
  34. package/dist/safe-bash-command-ssconvert/commands.js +871 -0
  35. package/dist/safe-bash-command-ssconvert/core.js +1 -1
  36. package/dist/safe-bash-command-ssconvert/index.js +269 -209
  37. package/dist/safe-bash-command-wkhtmltopdf/index.js +72 -19
  38. package/dist/safe-bash-command-yq/index.js +4 -4
  39. package/dist/safe-bash-compression-engine/files.js +2 -2
  40. package/dist/safe-bash-compression-engine/operand.js +4 -4
  41. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  42. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  43. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  44. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  45. package/dist/safe-bash-markdown-engine/index.js +7 -7
  46. package/dist/safe-bash-query-engine/index.js +5 -5
  47. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  48. package/dist/safe-bash-query-engine/query-core.js +5 -5
  49. package/package.json +6 -2
  50. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +16 -0
  51. package/dist/safe-bash/command-chunks/{chunk-OQVIJMBY.js → chunk-7HINP7ZK.js} +4 -4
  52. package/dist/safe-bash/command-chunks/{chunk-XAYEDOV5.js → chunk-CG4JSOK2.js} +3 -3
  53. package/dist/safe-bash/command-chunks/{chunk-YIK4ZYQ4.js → chunk-DC52GWRK.js} +9 -9
  54. package/dist/safe-bash/command-chunks/{chunk-TOTZFBDT.js → chunk-TKACIO4X.js} +4 -4
  55. package/dist/safe-bash/command-chunks/{chunk-VTWKS4RM.js → chunk-WF2LSKMI.js} +3 -3
@@ -0,0 +1,871 @@
1
+ import {
2
+ FileWriteError,
3
+ compareServiceIds,
4
+ createEngine,
5
+ createResourceIO,
6
+ defaultSsconvertLimits,
7
+ imageFormats,
8
+ ioFailure
9
+ } from "../safe-bash/command-chunks/chunk-J2NPH7DO.js";
10
+ import {
11
+ resourceUri
12
+ } from "../safe-bash/command-chunks/chunk-CE6Z2ULX.js";
13
+ import "../safe-bash/command-chunks/chunk-OZSWW23M.js";
14
+ import "../safe-bash/command-chunks/chunk-444OTXM7.js";
15
+ import "../safe-bash/command-chunks/chunk-TT2DMDBY.js";
16
+ import {
17
+ snapshotRuntimeFunctions
18
+ } from "../safe-bash/command-chunks/chunk-WKPOGTZY.js";
19
+ import "../safe-bash/command-chunks/chunk-MED2BOOW.js";
20
+ import {
21
+ SsconvertError,
22
+ isSsconvertError
23
+ } from "../safe-bash/command-chunks/chunk-FDNCPZQS.js";
24
+ import {
25
+ init_buffer
26
+ } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
27
+
28
+ // packages/safe-bash-command-ssconvert/dist/commands.js
29
+ init_buffer();
30
+
31
+ // packages/safe-bash-command-ssconvert/dist/command-bindings.js
32
+ init_buffer();
33
+
34
+ // packages/safe-bash-command-ssconvert/dist/formulas/runtime-functions.js
35
+ init_buffer();
36
+
37
+ // packages/safe-bash-command-ssconvert/dist/codecs/format-provider.js
38
+ init_buffer();
39
+
40
+ // packages/spreadsheet-engine/src/codecs/format-provider.ts
41
+ init_buffer();
42
+ function snapshotFormats(formats) {
43
+ return Object.freeze(formats.map((provider) => Object.freeze({
44
+ ...provider,
45
+ services: Object.freeze(provider.services.map((service) => Object.freeze({
46
+ ...service,
47
+ extensions: Object.freeze([...service.extensions]),
48
+ ...service.filenameSuffixes === void 0 ? {} : { filenameSuffixes: Object.freeze([...service.filenameSuffixes]) },
49
+ ...service.mimeTypes === void 0 ? {} : { mimeTypes: Object.freeze([...service.mimeTypes]) },
50
+ ...service.exporterOptionKeys === void 0 ? {} : { exporterOptionKeys: Object.freeze([...service.exporterOptionKeys]) },
51
+ ...service.exportOptionRules === void 0 ? {} : { exportOptionRules: Object.freeze(Object.fromEntries(
52
+ Object.entries(service.exportOptionRules).map(([key, rule]) => [key, Object.freeze({
53
+ ...rule,
54
+ ...rule.kind === "enum" ? { values: Object.freeze([...rule.values]) } : {}
55
+ })])
56
+ )) }
57
+ })))
58
+ })));
59
+ }
60
+
61
+ // packages/safe-bash-command-ssconvert/dist/io/index.js
62
+ init_buffer();
63
+
64
+ // packages/safe-bash-command-ssconvert/dist/io/publication.js
65
+ init_buffer();
66
+
67
+ // packages/spreadsheet-engine/src/io/publication.ts
68
+ init_buffer();
69
+ function createVfsOutput(fs, writeBytes, retainCleanup) {
70
+ let serial = 0;
71
+ return async (filename, context) => {
72
+ const signal = context.signal;
73
+ const options = { signal };
74
+ const uri = resourceUri(filename, context.environment.cwd ?? context.environment.env.PWD ?? "/");
75
+ let path = filename;
76
+ let temporary;
77
+ let finalized = false;
78
+ let aborting;
79
+ let closed = false;
80
+ let releaseAcquisition;
81
+ const acquiring = new Promise((resolve) => {
82
+ releaseAcquisition = resolve;
83
+ });
84
+ const check = () => {
85
+ signal.throwIfAborted();
86
+ if (closed) throw new SsconvertError("invalid-request", "ssconvert file output is closed");
87
+ };
88
+ const abort = (remove = (path2) => fs.unlink(path2)) => {
89
+ closed = true;
90
+ return aborting ??= (async () => {
91
+ await acquiring;
92
+ if (finalized || temporary === void 0) return;
93
+ const path2 = temporary;
94
+ temporary = void 0;
95
+ await remove(path2);
96
+ })();
97
+ };
98
+ try {
99
+ context.own(retainCleanup ? retainCleanup(abort) : abort);
100
+ check();
101
+ let mode = 438 & ~(context.environment.umask ?? 18);
102
+ const visited = /* @__PURE__ */ new Set();
103
+ for (let links = 0; ; links++) {
104
+ check();
105
+ if (links > (context.limits.outputSymlinks ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert output symlink limit exceeded");
106
+ let stat;
107
+ try {
108
+ stat = await fs.lstat(path, options);
109
+ } catch (error) {
110
+ signal.throwIfAborted();
111
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") break;
112
+ ioFailure(error, uri, "write", path);
113
+ }
114
+ check();
115
+ if (stat.type === "symlink") {
116
+ const identity = resourceUri(path, context.environment.cwd ?? context.environment.env.PWD ?? "/");
117
+ if (visited.has(identity)) throw new FileWriteError(uri, `${path}: Symlink cycle`);
118
+ visited.add(identity);
119
+ if (!fs.readlink) throw new SsconvertError("capability-denied", "Filesystem readlink capability is required for output aliases");
120
+ const target = await fs.readlink(path, options);
121
+ check();
122
+ const dirname2 = path.slice(0, path.lastIndexOf("/") + 1);
123
+ path = target.startsWith("/") ? target : dirname2 + target;
124
+ continue;
125
+ }
126
+ if (stat.type !== "file") throw new FileWriteError(uri, `${path}: Is not a regular file`);
127
+ try {
128
+ await fs.access(path, 2, options);
129
+ } catch (error) {
130
+ signal.throwIfAborted();
131
+ ioFailure(error, uri, "write", path);
132
+ }
133
+ check();
134
+ mode = stat.mode & 4095;
135
+ break;
136
+ }
137
+ check();
138
+ const capabilities = await fs.capabilitiesFor?.(path, options) ?? fs.capabilities;
139
+ check();
140
+ if (!capabilities.exclusiveCreate || !capabilities.atomicRename || !capabilities.permissions || !fs.unlink || !fs.chmod)
141
+ throw new SsconvertError("capability-denied", "Filesystem exclusive creation, atomic rename, unlink and permissions capabilities are required for ssconvert file publication");
142
+ const dirname = path.slice(0, path.lastIndexOf("/") + 1);
143
+ const random = context.random?.next() ?? 0;
144
+ if (!Number.isFinite(random) || random < 0 || random >= 1) throw new SsconvertError("invalid-request", "Invalid ssconvert random value");
145
+ for (let attempt = 0; ; attempt++) {
146
+ check();
147
+ if (attempt >= Math.max(1, context.limits.operations)) throw new SsconvertError("resource-limit", "ssconvert temporary file collision limit exceeded");
148
+ const suffix = ((Math.floor(random * 2176782336) + serial++) % 2176782336).toString(36).toUpperCase().padStart(6, "0");
149
+ const candidate = `${dirname}.gsf-save-${suffix}`;
150
+ try {
151
+ await fs.writeFile(candidate, new Uint8Array(), { ...options, flag: "wx", mode: 384 });
152
+ } catch (error) {
153
+ signal.throwIfAborted();
154
+ if (error && typeof error === "object" && "code" in error && error.code === "EEXIST") continue;
155
+ ioFailure(error, uri, "write", candidate);
156
+ }
157
+ temporary = candidate;
158
+ check();
159
+ break;
160
+ }
161
+ return {
162
+ abort,
163
+ async write(bytes) {
164
+ check();
165
+ if (finalized || !temporary) throw new SsconvertError("invalid-request", "ssconvert file output is closed");
166
+ try {
167
+ await writeBytes(temporary, bytes, signal);
168
+ } catch (error) {
169
+ signal.throwIfAborted();
170
+ await abort();
171
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOSPC") {
172
+ await context.diagnostic?.({ code: "close-error", severity: "error", message: " ==> Failed to close file: No space left on device" });
173
+ throw new SsconvertError("io", "E Failed to close file: No space left on device");
174
+ }
175
+ throw error;
176
+ }
177
+ },
178
+ async close() {
179
+ check();
180
+ if (finalized || !temporary) throw new SsconvertError("invalid-request", "ssconvert file output is closed");
181
+ finalized = true;
182
+ try {
183
+ await fs.rename(temporary, path, options);
184
+ } catch (error) {
185
+ signal.throwIfAborted();
186
+ if (error && typeof error === "object" && "code" in error && error.code === "EACCES") {
187
+ await context.diagnostic?.({ code: "publication-error", severity: "error", message: " ==> Permission denied" });
188
+ throw new SsconvertError("io", "E Permission denied");
189
+ }
190
+ throw error;
191
+ }
192
+ temporary = void 0;
193
+ try {
194
+ await fs.chmod(path, mode, options);
195
+ } catch (error) {
196
+ signal.throwIfAborted();
197
+ if (error && typeof error === "object" && "code" in error && error.code === "EACCES") return;
198
+ throw error;
199
+ }
200
+ }
201
+ };
202
+ } finally {
203
+ releaseAcquisition();
204
+ }
205
+ };
206
+ }
207
+
208
+ // packages/safe-bash-command-ssconvert/dist/io/cwd.js
209
+ init_buffer();
210
+
211
+ // packages/spreadsheet-engine/src/io/cwd.ts
212
+ init_buffer();
213
+ function snapshotDirectory(value) {
214
+ const { type, identityScope, dev, ino, opaqueIdentity } = value;
215
+ return { type, identityScope, dev, ino, opaqueIdentity };
216
+ }
217
+ async function resolveVfsCwd(cwd, pwd, filesystem, signal) {
218
+ signal.throwIfAborted();
219
+ if (!cwd.startsWith("/") || cwd.includes("\0")) throw new TypeError("ssconvert cwd must be an absolute VFS path");
220
+ if (!pwd?.startsWith("/") || pwd.includes("\0") || pwd === cwd || !filesystem.stat) return cwd;
221
+ const stat = filesystem.stat.bind(filesystem);
222
+ try {
223
+ const actual = snapshotDirectory(await stat(cwd, { signal }));
224
+ signal.throwIfAborted();
225
+ if (actual.type !== "directory" || !(typeof actual.identityScope === "object" && actual.identityScope !== null || typeof actual.identityScope === "symbol")) return cwd;
226
+ const alias = snapshotDirectory(await stat(pwd, { signal }));
227
+ signal.throwIfAborted();
228
+ if (alias.type !== "directory" || actual.identityScope !== alias.identityScope) return cwd;
229
+ const numeric = (value) => Number.isSafeInteger(value.dev) && value.dev >= 0 && Number.isSafeInteger(value.ino) && value.ino >= 0;
230
+ if (numeric(actual) && numeric(alias)) return actual.dev === alias.dev && actual.ino === alias.ino ? pwd : cwd;
231
+ if (typeof actual.opaqueIdentity === "string" && actual.opaqueIdentity.length > 0 && actual.opaqueIdentity.length <= 4096 && actual.opaqueIdentity === alias.opaqueIdentity) return pwd;
232
+ } catch {
233
+ signal.throwIfAborted();
234
+ }
235
+ return cwd;
236
+ }
237
+
238
+ // packages/safe-bash-command-ssconvert/dist/cli.js
239
+ init_buffer();
240
+
241
+ // packages/safe-bash-command-ssconvert/dist/contracts.js
242
+ init_buffer();
243
+
244
+ // packages/safe-bash-command-ssconvert/dist/cli/parser.js
245
+ init_buffer();
246
+
247
+ // packages/safe-bash-command-ssconvert/dist/cli/reference.js
248
+ init_buffer();
249
+ var referenceText = Object.freeze({
250
+ "help": "Usage:\n ssconvert [OPTION?] INFILE [OUTFILE]\n\nHelp Options:\n -h, --help Show help options\n --help-all Show all help options\n --help-libspreadsheet Show Gnumeric Options\n --help-gtk Show GTK+ Options\n\nApplication Options:\n --version Display program version\n -v, --verbose Be somewhat more verbose during conversion\n -E, --import-encoding=ENCODING Optionally specify an encoding for imported content\n -I, --import-type=ID Optionally specify which importer to use\n --list-importers List the available importers\n -M, --merge-to=file Merge listed files (all same format) to make this file\n -T, --export-type=ID Optionally specify which exporter to use\n -O, --export-options=string Detailed instructions for the chosen exporter\n --list-exporters List the available exporters\n -S, --export-file-per-sheet Export a file for each sheet if the exporter only supports one sheet at a time\n --export-graphs Export graphs\n --list-image-formats List the available image formats\n --set Change the contents of a cell before writing --set A12=2\n --recalc Recalculate all cells before writing the result\n --display=DISPLAY X display to use\n\n",
251
+ "help-all": "Usage:\n ssconvert [OPTION?] INFILE [OUTFILE]\n\nHelp Options:\n -h, --help Show help options\n --help-all Show all help options\n --help-libspreadsheet Show Gnumeric Options\n --help-gtk Show GTK+ Options\n\nGnumeric Options\n --libspreadsheet-version Display Gnumeric's version\n -L, --lib-dir=DIR Set the root library directory\n -D, --data-dir=DIR Adjust the root data directory\n\nGTK+ Options\n --class=CLASS Program class as used by the window manager\n --name=NAME Program name as used by the window manager\n --gtk-module=MODULES Load additional GTK+ modules\n --g-fatal-warnings Make all warnings fatal\n\nApplication Options:\n --version Display program version\n -v, --verbose Be somewhat more verbose during conversion\n -E, --import-encoding=ENCODING Optionally specify an encoding for imported content\n -I, --import-type=ID Optionally specify which importer to use\n --list-importers List the available importers\n -M, --merge-to=file Merge listed files (all same format) to make this file\n -T, --export-type=ID Optionally specify which exporter to use\n -O, --export-options=string Detailed instructions for the chosen exporter\n --list-exporters List the available exporters\n -S, --export-file-per-sheet Export a file for each sheet if the exporter only supports one sheet at a time\n --export-graphs Export graphs\n --list-image-formats List the available image formats\n --set Change the contents of a cell before writing --set A12=2\n --recalc Recalculate all cells before writing the result\n --display=DISPLAY X display to use\n\n",
252
+ "help-libspreadsheet": "Usage:\n ssconvert [OPTION?] INFILE [OUTFILE]\n\nGnumeric Options\n --libspreadsheet-version Display Gnumeric's version\n -L, --lib-dir=DIR Set the root library directory\n -D, --data-dir=DIR Adjust the root data directory\n\n",
253
+ "help-gtk": "Usage:\n ssconvert [OPTION?] INFILE [OUTFILE]\n\nGTK+ Options\n --class=CLASS Program class as used by the window manager\n --name=NAME Program name as used by the window manager\n --display=DISPLAY X display to use\n --gtk-module=MODULES Load additional GTK+ modules\n --g-fatal-warnings Make all warnings fatal\n\n",
254
+ "version": "ssconvert version '1.12.61'\ndatadir := '/opt/ssconvert-reference/share/gnumeric/1.12.61'\nlibdir := '/opt/ssconvert-reference/lib/gnumeric/1.12.61'\n",
255
+ "libspreadsheet-version": "gnumeric version '1.12.61'\ndatadir := '/opt/ssconvert-reference/share/gnumeric/1.12.61'\nlibdir := '/opt/ssconvert-reference/lib/gnumeric/1.12.61'\n"
256
+ });
257
+
258
+ // packages/safe-bash-command-ssconvert/dist/cli/parser.js
259
+ var scalarNames = {
260
+ L: "lib-dir",
261
+ D: "data-dir",
262
+ "lib-dir": "lib-dir",
263
+ "data-dir": "data-dir",
264
+ display: "display",
265
+ class: "class",
266
+ name: "name",
267
+ "gtk-module": "gtk-module",
268
+ E: "import-encoding",
269
+ I: "import-type",
270
+ M: "merge-to",
271
+ T: "export-type",
272
+ O: "export-options",
273
+ "import-encoding": "import-encoding",
274
+ "import-type": "import-type",
275
+ "merge-to": "merge-to",
276
+ "export-type": "export-type",
277
+ "export-options": "export-options",
278
+ resize: "resize",
279
+ clipboard: "clipboard",
280
+ "export-range": "export-range"
281
+ };
282
+ var flagNames = {
283
+ "g-fatal-warnings": "g-fatal-warnings",
284
+ v: "verbose",
285
+ S: "export-file-per-sheet",
286
+ verbose: "verbose",
287
+ "export-file-per-sheet": "export-file-per-sheet",
288
+ "list-importers": "list-importers",
289
+ "list-exporters": "list-exporters",
290
+ "list-image-formats": "list-image-formats",
291
+ "export-graphs": "export-graphs",
292
+ recalc: "recalc",
293
+ solve: "solve",
294
+ version: "version"
295
+ };
296
+ var inheritedGroups = [
297
+ { name: "libspreadsheet", entries: {
298
+ version: "library-version",
299
+ "lib-dir": "lib-dir",
300
+ "data-dir": "data-dir"
301
+ } },
302
+ { name: "gtk", entries: {
303
+ display: "display",
304
+ class: "class",
305
+ name: "name",
306
+ "gtk-module": "gtk-module",
307
+ "g-fatal-warnings": "g-fatal-warnings"
308
+ } }
309
+ ];
310
+ var arrayNames = /* @__PURE__ */ new Set(["set", "goal-seek", "tool-test"]);
311
+ var terminal = (stderr, exitCode = 1, stdout = "") => ({
312
+ kind: "terminal",
313
+ exitCode,
314
+ stdout,
315
+ stderr
316
+ });
317
+ var parserError = (message) => terminal(`${message}
318
+ Run 'ssconvert --help' to see a full list of available command line options.
319
+ `);
320
+ function parseCommand(supplied, profile) {
321
+ const encoder = new TextEncoder();
322
+ const decoder = new TextDecoder("utf8", { ignoreBOM: true });
323
+ const byteMode = supplied.some((argument) => typeof argument !== "string");
324
+ const bytes = supplied.map((argument) => typeof argument === "string" ? encoder.encode(argument) : new Uint8Array(argument));
325
+ const argv = bytes.map((argument) => Array.from(argument, (byte) => String.fromCharCode(byte)).join(""));
326
+ const operandBytes = [];
327
+ const unknown = (index) => {
328
+ const option = bytes[index];
329
+ if (profile?.listingEncoding !== "utf8") {
330
+ let message;
331
+ try {
332
+ const text = new TextDecoder("utf8", { fatal: true, ignoreBOM: true }).decode(option);
333
+ message = "Unknown option " + Array.from(text, (character) => character.codePointAt(0) < 128 ? character : "?").join("");
334
+ } catch {
335
+ message = "[Invalid UTF-8] Unknown option " + Array.from(option, (byte) => byte >= 32 && byte < 127 || byte === 9 || byte === 10 ? String.fromCharCode(byte) : `\\x${byte.toString(16).padStart(2, "0")}`).join("");
336
+ }
337
+ const result = parserError(message);
338
+ return { ...result, stderrBytes: encoder.encode(result.stderr) };
339
+ }
340
+ const prefix = encoder.encode("Unknown option ");
341
+ const suffix = encoder.encode("\nRun 'ssconvert --help' to see a full list of available command line options.\n");
342
+ const raw = new Uint8Array(prefix.length + option.length + suffix.length);
343
+ raw.set(prefix);
344
+ raw.set(option, prefix.length);
345
+ raw.set(suffix, prefix.length + option.length);
346
+ return { kind: "terminal", exitCode: 1, stdout: "", stderr: decoder.decode(raw), stderrBytes: raw };
347
+ };
348
+ const operands = [], scalars = {}, scalarBytes = {}, arrays = {}, flags = /* @__PURE__ */ new Set();
349
+ let options = true;
350
+ for (let index = 0; index < argv.length; index++) {
351
+ const argument = argv[index];
352
+ if (argument.includes("\0"))
353
+ return parserError("Arguments must not contain NUL");
354
+ if (options && argument === "--") {
355
+ options = false;
356
+ if (argv.slice(index + 1).some((remaining) => remaining.startsWith("-"))) {
357
+ operands.push(argument);
358
+ operandBytes.push(bytes[index]);
359
+ }
360
+ continue;
361
+ }
362
+ if (!options || !argument.startsWith("-") || argument === "-") {
363
+ operands.push(decoder.decode(bytes[index]));
364
+ operandBytes.push(bytes[index]);
365
+ continue;
366
+ }
367
+ const long = argument.startsWith("--");
368
+ const raw = argument.slice(long ? 2 : 1);
369
+ let consumed = false;
370
+ for (const entry of long ? [raw] : raw) {
371
+ if (long && ["help", "help-all", "help-libspreadsheet", "help-gtk"].includes(entry) || !long && (entry === "?" || entry === "h")) {
372
+ const group = long ? entry : "help";
373
+ const captured = group === "help" ? profile?.help : profile?.groups?.[group];
374
+ if (captured !== void 0)
375
+ return terminal("", 0, captured);
376
+ if (group !== "help" && profile?.help !== void 0)
377
+ return terminal(`Unsupported ssconvert feature: --${group} (missing locale help capture; virtual runtime parity blocker)
378
+ `);
379
+ return terminal("", 0, referenceText[group]);
380
+ }
381
+ const equals = long ? entry.indexOf("=") : -1;
382
+ let name = equals < 0 ? entry : entry.slice(0, equals);
383
+ let inherited;
384
+ if (long && !Object.hasOwn(scalarNames, name) && !Object.hasOwn(flagNames, name) && !arrayNames.has(name)) {
385
+ const dash = name.indexOf("-");
386
+ if (dash > 0) {
387
+ const prefix = name.slice(0, dash), option = name.slice(dash + 1);
388
+ for (const group of inheritedGroups) {
389
+ if (group.name.startsWith(prefix) && Object.hasOwn(group.entries, option)) {
390
+ inherited = group.entries[option];
391
+ name = option;
392
+ break;
393
+ }
394
+ }
395
+ }
396
+ }
397
+ const scalar = (long ? name.length > 1 : name.length === 1) && Object.hasOwn(scalarNames, name) ? scalarNames[name] : void 0;
398
+ const flag = inherited === "library-version" ? inherited : (long ? name.length > 1 : name.length === 1) && Object.hasOwn(flagNames, name) ? flagNames[name] : void 0;
399
+ if (scalar || long && arrayNames.has(name)) {
400
+ const optionName = `${long ? "--" : "-"}${name}`;
401
+ if (!long && consumed)
402
+ return parserError(`Error parsing option ${optionName}`);
403
+ const value = equals < 0 ? argv[index + 1] : entry.slice(equals + 1);
404
+ if (value === void 0)
405
+ return parserError(`Missing argument for ${optionName}`);
406
+ if (value.includes("\0"))
407
+ return parserError("Arguments must not contain NUL");
408
+ const valueBytes = equals < 0 ? bytes[index + 1] : bytes[index].subarray(2 + equals + 1);
409
+ if (scalar !== "lib-dir" && scalar !== "data-dir" && profile?.argumentEncoding !== "utf8" && valueBytes.some((byte) => byte >= 128))
410
+ return parserError("Invalid byte sequence in conversion input");
411
+ let decoded;
412
+ if (scalar === "lib-dir" || scalar === "data-dir") {
413
+ scalarBytes[scalar] = new Uint8Array(valueBytes);
414
+ decoded = decoder.decode(valueBytes);
415
+ } else {
416
+ try {
417
+ decoded = new TextDecoder("utf8", { fatal: true, ignoreBOM: true }).decode(valueBytes);
418
+ } catch {
419
+ return parserError("Invalid byte sequence in conversion input");
420
+ }
421
+ }
422
+ if (equals < 0)
423
+ consumed = true;
424
+ if (scalar === "gtk-module") {
425
+ if (decoded !== "")
426
+ (arrays[scalar] ??= []).push(decoded);
427
+ } else if (scalar)
428
+ scalars[scalar] = decoded;
429
+ else
430
+ (arrays[name] ??= []).push(decoded);
431
+ } else if (flag)
432
+ flags.add(flag);
433
+ else
434
+ return unknown(index);
435
+ }
436
+ if (consumed)
437
+ index++;
438
+ }
439
+ if (flags.has("library-version"))
440
+ return terminal("", 0, profile?.libraryVersion ?? (profile?.configurationRoots ? `gnumeric version '1.12.61'
441
+ datadir := '${profile.configurationRoots.dataDir}'
442
+ libdir := '${profile.configurationRoots.libDir}'
443
+ ` : referenceText["libspreadsheet-version"]));
444
+ if (arrays["gtk-module"] !== void 0)
445
+ return terminal("Unsupported ssconvert feature: --gtk-module (virtual runtime parity blocker)\n");
446
+ if (flags.has("version"))
447
+ return terminal("", 0, profile?.version ?? (profile?.configurationRoots ? `ssconvert version '1.12.61'
448
+ datadir := '${profile.configurationRoots.dataDir}'
449
+ libdir := '${profile.configurationRoots.libDir}'
450
+ ` : referenceText.version));
451
+ for (const name of ["display", "class", "name", "g-fatal-warnings"])
452
+ if (scalars[name] !== void 0 || flags.has(name))
453
+ return terminal(`Unsupported ssconvert feature: --${name} (virtual runtime parity blocker)
454
+ `);
455
+ if (flags.has("export-file-per-sheet") && scalars["merge-to"] !== void 0)
456
+ return terminal("--export-file-per-sheet and --merge-to are incompatible\n");
457
+ if (flags.has("export-graphs"))
458
+ flags.add("export-file-per-sheet");
459
+ const action = flags.has("list-exporters") ? "list-exporters" : flags.has("list-importers") ? "list-importers" : flags.has("list-image-formats") ? "list-image-formats" : scalars.clipboard !== void 0 ? "clipboard" : scalars["merge-to"] !== void 0 ? "merge" : "convert";
460
+ if (!action.startsWith("list-") && (action === "merge" ? operands.length < 2 : action === "clipboard" ? operands.length !== 2 || scalars["export-range"] === void 0 : operands.length < 1 || operands.length > 2))
461
+ return terminal("Usage: ssconvert [OPTION...] INFILE [OUTFILE]\n");
462
+ return Object.freeze({
463
+ kind: "operation",
464
+ action,
465
+ operands: Object.freeze(operands),
466
+ ...byteMode ? { operandBytes: Object.freeze(operandBytes) } : {},
467
+ scalars: Object.freeze(scalars),
468
+ ...Object.keys(scalarBytes).length === 0 ? {} : { scalarBytes: Object.freeze(scalarBytes) },
469
+ arrays: Object.freeze(Object.fromEntries(Object.entries(arrays).map(([key, values]) => [key, Object.freeze(values)]))),
470
+ flags: Object.freeze([...flags])
471
+ });
472
+ }
473
+
474
+ // packages/safe-bash-command-ssconvert/dist/codecs/ordering.js
475
+ init_buffer();
476
+
477
+ // packages/safe-bash-command-ssconvert/dist/rendering/images/formats.js
478
+ init_buffer();
479
+
480
+ // packages/safe-bash-command-ssconvert/dist/cli.js
481
+ async function runCommand(argv, engine, operation, profile) {
482
+ operation.signal.throwIfAborted();
483
+ let argumentBytes = 0;
484
+ try {
485
+ const maximum = engine.limits.argumentBytes ?? Infinity;
486
+ if (argv.length > maximum)
487
+ throw new SsconvertError("resource-limit", "ssconvert arguments limit exceeded");
488
+ for (const argument of argv) {
489
+ if (typeof argument === "string") {
490
+ if (argument.length > maximum - argumentBytes)
491
+ throw new SsconvertError("resource-limit", "ssconvert argument bytes limit exceeded");
492
+ for (const character of argument) {
493
+ const code = character.codePointAt(0);
494
+ argumentBytes += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
495
+ if (argumentBytes > maximum)
496
+ throw new SsconvertError("resource-limit", "ssconvert argument bytes limit exceeded");
497
+ }
498
+ } else
499
+ argumentBytes += argument.byteLength;
500
+ if (argumentBytes > maximum)
501
+ throw new SsconvertError("resource-limit", "ssconvert argument bytes limit exceeded");
502
+ }
503
+ } catch (error) {
504
+ if (!isSsconvertError(error))
505
+ throw error;
506
+ await operation.stderr.write(new TextEncoder().encode(`${error.message}
507
+ `));
508
+ operation.signal.throwIfAborted();
509
+ return { exitCode: error.exitCode };
510
+ }
511
+ const parsed = parseCommand(argv, profile);
512
+ const encoder = new TextEncoder();
513
+ let stderrFailed = false;
514
+ async function report(bytes) {
515
+ operation.signal.throwIfAborted();
516
+ try {
517
+ await operation.stderr.write(bytes);
518
+ } catch (error) {
519
+ stderrFailed = true;
520
+ throw error;
521
+ }
522
+ operation.signal.throwIfAborted();
523
+ }
524
+ let outputBytes = 0;
525
+ function encodeOutput(text) {
526
+ for (const character of text) {
527
+ const code = character.codePointAt(0);
528
+ outputBytes += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
529
+ if (outputBytes > (engine.limits.commandOutputBytes ?? Infinity))
530
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
531
+ }
532
+ return encoder.encode(text);
533
+ }
534
+ try {
535
+ if (parsed.kind === "terminal") {
536
+ if (parsed.stdout)
537
+ await operation.stdout.write(encodeOutput(parsed.stdout));
538
+ if (parsed.stderr) {
539
+ if (parsed.stderrBytes) {
540
+ if (parsed.stderrBytes.byteLength > (engine.limits.commandOutputBytes ?? Infinity) - outputBytes)
541
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
542
+ outputBytes += parsed.stderrBytes.byteLength;
543
+ await report(parsed.stderrBytes);
544
+ } else
545
+ await report(encodeOutput(parsed.stderr));
546
+ }
547
+ operation.signal.throwIfAborted();
548
+ return { exitCode: parsed.exitCode };
549
+ }
550
+ if (parsed.action === "list-importers" || parsed.action === "list-exporters" || parsed.action === "list-image-formats") {
551
+ let textLength2 = function(text, ascii2) {
552
+ let length = 0;
553
+ for (const character of text) {
554
+ const code = character.codePointAt(0);
555
+ length += ascii2 || code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
556
+ if (length > maximum)
557
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
558
+ }
559
+ return length;
560
+ };
561
+ var textLength = textLength2;
562
+ const services = parsed.action === "list-image-formats" ? imageFormats : [...engine.listServices(parsed.action === "list-importers" ? "read" : "write")].filter((service) => !service.interactiveOnly).sort(compareServiceIds);
563
+ const maximum = engine.limits.commandOutputBytes ?? Infinity;
564
+ if (services.length > maximum)
565
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
566
+ const widths = services.map((service) => textLength2(service.id, false));
567
+ const width = widths.reduce((max, length) => Math.max(max, length), 0);
568
+ const ascii = profile?.listingEncoding !== "utf8";
569
+ let total = 2 + Math.max(0, width - 2) + " | Description\n".length;
570
+ if (total > maximum)
571
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
572
+ for (let index = 0; index < services.length; index++) {
573
+ const service = services[index];
574
+ const length = textLength2(service.id, ascii) + Math.max(0, width - widths[index]) + 3 + textLength2(service.description, ascii) + 1;
575
+ if (length > maximum - total)
576
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
577
+ total += length;
578
+ }
579
+ await report(encodeOutput(`ID${" ".repeat(Math.max(0, width - 2))} | Description
580
+ `));
581
+ for (let index = 0; index < services.length; index++) {
582
+ operation.signal.throwIfAborted();
583
+ const service = services[index];
584
+ const padding = Math.max(0, width - widths[index]);
585
+ const length = textLength2(service.id, ascii) + padding + 3 + textLength2(service.description, ascii) + 1;
586
+ if (length > maximum - outputBytes)
587
+ throw new SsconvertError("resource-limit", "ssconvert output bytes limit exceeded");
588
+ const line = `${service.id}${" ".repeat(padding)} | ${service.description}
589
+ `;
590
+ const display = ascii ? Array.from(line, (character) => character.codePointAt(0) < 128 ? character : "?").join("") : line;
591
+ await report(encodeOutput(display));
592
+ }
593
+ operation.signal.throwIfAborted();
594
+ return { exitCode: 0 };
595
+ }
596
+ if (parsed.action !== "convert" && parsed.action !== "merge" && parsed.action !== "clipboard")
597
+ throw new SsconvertError("unsupported-feature", `Unsupported ssconvert feature: ${parsed.action}`);
598
+ for (const name of Object.keys(parsed.arrays).filter((name2) => name2 !== "set" && name2 !== "goal-seek" && name2 !== "tool-test"))
599
+ throw new SsconvertError("unsupported-feature", `Unsupported ssconvert feature: --${name}`);
600
+ if (parsed.operandBytes) {
601
+ const filenameDecoder = new TextDecoder("utf8", { fatal: true, ignoreBOM: true });
602
+ for (const bytes of parsed.operandBytes) {
603
+ try {
604
+ filenameDecoder.decode(bytes);
605
+ } catch {
606
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: non-UTF-8 resource name");
607
+ }
608
+ }
609
+ }
610
+ const output = parsed.action === "merge" ? parsed.scalars["merge-to"] : parsed.operands[1];
611
+ const request = {
612
+ input: { kind: "resource", uri: parsed.operands[0] },
613
+ ...output === void 0 ? {} : { destination: output === "fd://1" && parsed.scalars["export-type"] !== void 0 ? { kind: "stream", sink: operation.stdout } : { kind: "resource", uri: output } },
614
+ ...parsed.scalars["import-type"] === void 0 ? {} : { importType: parsed.scalars["import-type"] },
615
+ ...parsed.scalars["import-encoding"] === void 0 ? {} : { importEncoding: parsed.scalars["import-encoding"] },
616
+ ...parsed.scalars["export-type"] === void 0 ? {} : { exportType: parsed.scalars["export-type"] },
617
+ ...parsed.scalars["export-options"] === void 0 ? {} : { exportOptions: [parsed.scalars["export-options"]] },
618
+ recalc: parsed.flags.includes("recalc"),
619
+ solve: parsed.flags.includes("solve"),
620
+ verbose: parsed.flags.includes("verbose"),
621
+ perSheet: parsed.flags.includes("export-file-per-sheet"),
622
+ graphs: parsed.flags.includes("export-graphs"),
623
+ ...parsed.scalars.clipboard === void 0 ? {} : { clipboard: parsed.scalars.clipboard },
624
+ ...parsed.arrays.set === void 0 ? {} : { updateExpressions: parsed.arrays.set },
625
+ ...parsed.arrays["goal-seek"] === void 0 ? {} : { goalSeekExpressions: parsed.arrays["goal-seek"] },
626
+ ...parsed.arrays["tool-test"] === void 0 ? {} : { toolTest: parsed.arrays["tool-test"] },
627
+ ...parsed.scalars.resize === void 0 ? {} : { resizeExpression: parsed.scalars.resize },
628
+ ...parsed.scalars["export-range"] === void 0 ? {} : { exportRangeExpression: parsed.scalars["export-range"] }
629
+ };
630
+ const emitted = /* @__PURE__ */ new Set();
631
+ const diagnosticOperation = {
632
+ ...operation,
633
+ async diagnostic(diagnostic) {
634
+ operation.signal.throwIfAborted();
635
+ await report(diagnostic.bytes ?? encoder.encode(`${diagnostic.message}
636
+ `));
637
+ emitted.add(diagnostic);
638
+ operation.signal.throwIfAborted();
639
+ }
640
+ };
641
+ const result = parsed.action === "merge" ? await engine.merge({
642
+ ...request,
643
+ inputs: parsed.operands.map((uri) => ({ kind: "resource", uri }))
644
+ }, diagnosticOperation) : await engine.convert(request, diagnosticOperation);
645
+ for (const diagnostic of result.diagnostics) {
646
+ if (emitted.has(diagnostic))
647
+ continue;
648
+ operation.signal.throwIfAborted();
649
+ await report(diagnostic.bytes ?? encoder.encode(`${diagnostic.message}
650
+ `));
651
+ }
652
+ operation.signal.throwIfAborted();
653
+ return result;
654
+ } catch (error) {
655
+ operation.signal.throwIfAborted();
656
+ if (stderrFailed)
657
+ throw error;
658
+ if (!isSsconvertError(error))
659
+ throw error;
660
+ await report(encoder.encode(`${error.message}
661
+ `));
662
+ operation.signal.throwIfAborted();
663
+ return { exitCode: error.exitCode };
664
+ }
665
+ }
666
+
667
+ // packages/safe-bash-command-ssconvert/dist/command-bindings.js
668
+ import { retainFileSystemCleanup } from "@poe-platform/safe-fs/core";
669
+ import { createOutputOperation, getCommandArguments } from "../safe-bash-contracts/index.js";
670
+ import { builtInDirectContextExecutors } from "../safe-bash-contracts/runtime-control.js";
671
+ import { shellValueByteLength } from "../safe-bash-contracts/value.js";
672
+ import { writeFileOutput } from "../safe-bash-contracts/filesystem-output.js";
673
+ function createCommandBindings(createEngine2, compatibilityDefaults = false) {
674
+ function createSsconvertCommand2(options = {}) {
675
+ const configured = { ...options };
676
+ if (configured.replace !== void 0 && typeof configured.replace !== "boolean")
677
+ throw new TypeError("ssconvert replace must be boolean");
678
+ const binding = {
679
+ ...configured,
680
+ ...configured.io === void 0 ? {} : { io: Object.freeze({
681
+ ...configured.io.descriptors === void 0 ? {} : { descriptors: Object.freeze(Object.fromEntries(Object.entries(configured.io.descriptors).map(([key, descriptor]) => [key, Object.freeze({ ...descriptor })]))) },
682
+ ...configured.io.adapters === void 0 ? {} : { adapters: Object.freeze({ ...configured.io.adapters }) },
683
+ ...configured.io.transport === void 0 ? {} : { transport: Object.freeze({
684
+ authorize: configured.io.transport.authorize.bind(configured.io.transport),
685
+ request: configured.io.transport.request.bind(configured.io.transport),
686
+ redirects: configured.io.transport.redirects
687
+ }) }
688
+ }) },
689
+ ...configured.runtimeFunctions === void 0 ? {} : { runtimeFunctions: snapshotRuntimeFunctions(configured.runtimeFunctions) },
690
+ ...configured.profile === void 0 ? {} : { profile: Object.freeze({
691
+ ...configured.profile,
692
+ ...configured.profile.groups === void 0 ? {} : { groups: Object.freeze({ ...configured.profile.groups }) },
693
+ ...configured.profile.configurationRoots === void 0 ? {} : {
694
+ configurationRoots: Object.freeze({ ...configured.profile.configurationRoots })
695
+ }
696
+ }) },
697
+ codecs: Object.freeze([...configured.codecs ?? []]),
698
+ ...configured.formats === void 0 ? {} : { formats: snapshotFormats(configured.formats) },
699
+ limits: Object.freeze({ ...defaultSsconvertLimits, ...configured.limits }),
700
+ environment: Object.freeze({
701
+ locale: "C",
702
+ timezone: "UTC",
703
+ ...configured.environment,
704
+ env: Object.freeze({ ...configured.environment?.env })
705
+ })
706
+ };
707
+ const command = {
708
+ name: "ssconvert",
709
+ description: "Explicitly bound TypeScript spreadsheet conversion engine",
710
+ async execute(context) {
711
+ context.signal.throwIfAborted();
712
+ const owner = createOutputOperation(context, { async write() {
713
+ } });
714
+ const inputBytes = Math.min(binding.limits.inputBytes, context.inputBudget?.maxBytes ?? Infinity);
715
+ let stdout;
716
+ const standardOutput = { async write(bytes) {
717
+ stdout ??= owner.child(context.stdout);
718
+ await stdout.output.write(bytes);
719
+ } };
720
+ let stderr;
721
+ const standardError = { async write(bytes) {
722
+ stderr ??= owner.child(context.stderr);
723
+ await stderr.output.write(bytes);
724
+ } };
725
+ const openOutput = createVfsOutput(context.fs, async (path, bytes, signal) => {
726
+ await owner.acquire(() => writeFileOutput(context, bytes, async (data) => {
727
+ const capabilities = await context.fs.capabilitiesFor?.(path, { signal }) ?? context.fs.capabilities;
728
+ signal.throwIfAborted();
729
+ if (context.fs.writeStream && capabilities.streamingWrite !== false)
730
+ await context.fs.writeStream(path, (async function* () {
731
+ yield data;
732
+ })(), { signal });
733
+ else
734
+ await context.fs.writeFile(path, data, { signal });
735
+ }), () => {
736
+ });
737
+ }, (cleanup) => retainFileSystemCleanup(context.fs, (view) => cleanup((path) => view.rm(path)), { maxOperations: 1 }));
738
+ let engine;
739
+ try {
740
+ const cwd = await owner.acquire(() => resolveVfsCwd(context.cwd, context.env.PWD, context.fs, owner.signal), () => {
741
+ });
742
+ engine = createEngine2({
743
+ ...binding,
744
+ environment: {
745
+ ...binding.environment,
746
+ cwd,
747
+ env: Object.freeze({ ...context.env })
748
+ },
749
+ limits: { ...binding.limits, inputBytes },
750
+ filesystem: createResourceIO({
751
+ ...binding.io,
752
+ cwd,
753
+ descriptors: {
754
+ ...binding.io?.descriptors,
755
+ 0: { source: context.stdin },
756
+ 1: { sink: standardOutput }
757
+ },
758
+ filesystem: {
759
+ openOutput,
760
+ async read(uri, signal) {
761
+ try {
762
+ const capabilities = await context.fs.capabilitiesFor?.(uri, { signal }) ?? context.fs.capabilities;
763
+ signal.throwIfAborted();
764
+ if (context.fs.readStream && capabilities.streamingRead !== false)
765
+ return context.fs.readStream(uri, { signal });
766
+ const bytes = await owner.acquire(() => context.fs.readFile(uri, {
767
+ signal,
768
+ ...inputBytes === Infinity ? {} : { maxBytes: inputBytes }
769
+ }), () => {
770
+ });
771
+ context.inputBudget?.check(bytes.byteLength);
772
+ return [bytes];
773
+ } catch (error) {
774
+ signal.throwIfAborted();
775
+ throw error;
776
+ }
777
+ },
778
+ async write(uri, bytes, signal) {
779
+ try {
780
+ await owner.acquire(() => writeFileOutput(context, bytes, async (data) => {
781
+ const capabilities = await context.fs.capabilitiesFor?.(uri, { signal }) ?? context.fs.capabilities;
782
+ signal.throwIfAborted();
783
+ if (context.fs.writeStream && capabilities.streamingWrite !== false)
784
+ await context.fs.writeStream(uri, (async function* () {
785
+ yield data;
786
+ })(), { signal });
787
+ else
788
+ await context.fs.writeFile(uri, data, { signal });
789
+ }), () => {
790
+ });
791
+ } catch (error) {
792
+ signal.throwIfAborted();
793
+ throw error;
794
+ }
795
+ }
796
+ }
797
+ })
798
+ });
799
+ const maximumArguments = binding.limits.argumentBytes ?? Infinity;
800
+ const values = context.argumentValues?.values ?? context.args;
801
+ let argumentBytes = 0;
802
+ let refusal;
803
+ if (values.length > maximumArguments)
804
+ refusal = "ssconvert arguments limit exceeded";
805
+ for (const value of values) {
806
+ if (refusal)
807
+ break;
808
+ if (typeof value === "string" && value.length > maximumArguments - argumentBytes) {
809
+ refusal = "ssconvert argument bytes limit exceeded";
810
+ break;
811
+ }
812
+ argumentBytes += shellValueByteLength(value);
813
+ if (argumentBytes > maximumArguments)
814
+ refusal = "ssconvert argument bytes limit exceeded";
815
+ }
816
+ if (refusal) {
817
+ await standardError.write(new TextEncoder().encode(`${refusal}
818
+ `));
819
+ owner.signal.throwIfAborted();
820
+ return { exitCode: 1 };
821
+ }
822
+ const carrier = getCommandArguments(context);
823
+ return await runCommand(carrier.args.map((_, index) => carrier.bytes(index)), engine, {
824
+ signal: owner.signal,
825
+ ...context.stdinIsDefault === void 0 ? {} : { stdinIsDefault: context.stdinIsDefault },
826
+ stdout: standardOutput,
827
+ stderr: standardError,
828
+ registerCleanup: (cleanup) => owner.registerCleanup(cleanup)
829
+ }, binding.profile);
830
+ } finally {
831
+ try {
832
+ await engine?.dispose();
833
+ } finally {
834
+ await owner.close();
835
+ }
836
+ }
837
+ }
838
+ };
839
+ if (compatibilityDefaults && Object.entries(configured).every(([key, value]) => key === "replace" || value === void 0)) {
840
+ builtInDirectContextExecutors.add(command.execute);
841
+ }
842
+ return command;
843
+ }
844
+ function ssconvertCommands2(options = {}) {
845
+ const commands = createSsconvertCommands2(options), replace = options.replace ?? false;
846
+ return {
847
+ name: "ssconvert-commands",
848
+ setup(host) {
849
+ if (!replace && commands.some((command) => host.commands.has(command.name)))
850
+ throw new Error("Command already registered: ssconvert");
851
+ for (const command of commands)
852
+ host.commands.register(command, { replace });
853
+ }
854
+ };
855
+ }
856
+ function createSsconvertCommands2(options = {}) {
857
+ return Object.freeze([createSsconvertCommand2(options)]);
858
+ }
859
+ return { createSsconvertCommand: createSsconvertCommand2, createSsconvertCommands: createSsconvertCommands2, ssconvertCommands: ssconvertCommands2 };
860
+ }
861
+
862
+ // packages/safe-bash-command-ssconvert/dist/commands.js
863
+ var bindings = createCommandBindings(createEngine);
864
+ var createSsconvertCommand = bindings.createSsconvertCommand;
865
+ var createSsconvertCommands = bindings.createSsconvertCommands;
866
+ var ssconvertCommands = bindings.ssconvertCommands;
867
+ export {
868
+ createSsconvertCommand,
869
+ createSsconvertCommands,
870
+ ssconvertCommands
871
+ };