@poe-platform/safe-bash 0.1.539 → 0.1.540

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 (94) hide show
  1. package/dist/safe-bash/chunks/bz2-B2RXT4EX.js +4836 -0
  2. package/dist/safe-bash/chunks/bz2-B2RXT4EX.js.map +7 -0
  3. package/dist/safe-bash/chunks/{chunk-4NMFAR4Z.js → chunk-2KL6W6NB.js} +3 -629
  4. package/dist/safe-bash/chunks/{chunk-4NMFAR4Z.js.map → chunk-2KL6W6NB.js.map} +4 -4
  5. package/dist/safe-bash/chunks/{chunk-RDIJ6M2D.js → chunk-32GGX4AS.js} +6 -4
  6. package/dist/safe-bash/chunks/{chunk-RDIJ6M2D.js.map → chunk-32GGX4AS.js.map} +1 -1
  7. package/dist/safe-bash/chunks/{chunk-LUIEXTN5.js → chunk-DJHZJAB7.js} +6 -4
  8. package/dist/safe-bash/chunks/{chunk-LUIEXTN5.js.map → chunk-DJHZJAB7.js.map} +1 -1
  9. package/dist/safe-bash/chunks/{chunk-CI42NIWL.js → chunk-DPJWEGIX.js} +2 -2
  10. package/dist/safe-bash/chunks/{chunk-UL4TNDNV.js → chunk-EYJTLUBJ.js} +5 -3
  11. package/dist/safe-bash/chunks/{chunk-UL4TNDNV.js.map → chunk-EYJTLUBJ.js.map} +1 -1
  12. package/dist/safe-bash/chunks/chunk-GZKLXMBM.js +636 -0
  13. package/dist/safe-bash/chunks/chunk-GZKLXMBM.js.map +7 -0
  14. package/dist/safe-bash/chunks/{chunk-RVGX5DQT.js → chunk-IIWXPQB3.js} +15 -11
  15. package/dist/safe-bash/chunks/chunk-IIWXPQB3.js.map +7 -0
  16. package/dist/safe-bash/chunks/{chunk-R5ZK7V4W.js → chunk-J4CKSMJV.js} +7 -5
  17. package/dist/safe-bash/chunks/{chunk-R5ZK7V4W.js.map → chunk-J4CKSMJV.js.map} +1 -1
  18. package/dist/safe-bash/chunks/{chunk-GV76QENF.js → chunk-LRVRQIG5.js} +6 -4
  19. package/dist/safe-bash/chunks/{chunk-GV76QENF.js.map → chunk-LRVRQIG5.js.map} +1 -1
  20. package/dist/safe-bash/chunks/{chunk-ELK3CQTQ.js → chunk-LZUOZVGJ.js} +7 -5
  21. package/dist/safe-bash/chunks/{chunk-ELK3CQTQ.js.map → chunk-LZUOZVGJ.js.map} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-5X2TAR25.js → chunk-PPPN3OME.js} +6 -4
  23. package/dist/safe-bash/chunks/{chunk-5X2TAR25.js.map → chunk-PPPN3OME.js.map} +1 -1
  24. package/dist/safe-bash/chunks/{chunk-QWCD4HKE.js → chunk-QKQNBJOU.js} +9 -7
  25. package/dist/safe-bash/chunks/{chunk-QWCD4HKE.js.map → chunk-QKQNBJOU.js.map} +1 -1
  26. package/dist/safe-bash/chunks/{chunk-GZH6ILJC.js → chunk-UGMO7OO5.js} +7 -5
  27. package/dist/safe-bash/chunks/{chunk-GZH6ILJC.js.map → chunk-UGMO7OO5.js.map} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-67TENRTW.js → chunk-Z75O7XWR.js} +7 -5
  29. package/dist/safe-bash/chunks/{chunk-67TENRTW.js.map → chunk-Z75O7XWR.js.map} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-F4UILGOA.js → chunk-ZQEL7DYC.js} +8 -6
  31. package/dist/safe-bash/chunks/{chunk-F4UILGOA.js.map → chunk-ZQEL7DYC.js.map} +1 -1
  32. package/dist/safe-bash/chunks/xz-AVXFDXW4.js +6042 -0
  33. package/dist/safe-bash/chunks/xz-AVXFDXW4.js.map +7 -0
  34. package/dist/safe-bash/chunks/zstd-R6RPHJYO.js +27110 -0
  35. package/dist/safe-bash/chunks/zstd-R6RPHJYO.js.map +7 -0
  36. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +20 -0
  37. package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -0
  38. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +111 -0
  39. package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -0
  40. package/dist/safe-bash/commands/bytes/compression/codec-loader.d.ts +5 -0
  41. package/dist/safe-bash/commands/bytes/compression/codec-loader.d.ts.map +1 -0
  42. package/dist/safe-bash/commands/bytes/compression/codec-loader.js +89 -0
  43. package/dist/safe-bash/commands/bytes/compression/codec-loader.js.map +1 -0
  44. package/dist/safe-bash/commands/bytes/compression/files.d.ts +1 -1
  45. package/dist/safe-bash/commands/bytes/compression/files.d.ts.map +1 -1
  46. package/dist/safe-bash/commands/bytes/compression/files.js +15 -0
  47. package/dist/safe-bash/commands/bytes/compression/files.js.map +1 -1
  48. package/dist/safe-bash/commands/bytes/compression/index.js +3 -3
  49. package/dist/safe-bash/commands/bytes/compression/index.js.map +1 -1
  50. package/dist/safe-bash/commands/bytes/compression/native/LICENSES.txt +777 -0
  51. package/dist/safe-bash/commands/bytes/compression/native/generated/bz2.d.mts +3 -0
  52. package/dist/safe-bash/commands/bytes/compression/native/generated/bz2.mjs +2 -0
  53. package/dist/safe-bash/commands/bytes/compression/native/generated/xz.d.mts +3 -0
  54. package/dist/safe-bash/commands/bytes/compression/native/generated/xz.mjs +2 -0
  55. package/dist/safe-bash/commands/bytes/compression/native/generated/zstd.d.mts +3 -0
  56. package/dist/safe-bash/commands/bytes/compression/native/generated/zstd.mjs +2 -0
  57. package/dist/safe-bash/commands/bytes/compression/native/sources.json +246 -0
  58. package/dist/safe-bash/commands/bytes/compression/native/types.d.ts +17 -0
  59. package/dist/safe-bash/commands/bytes/compression/native/types.d.ts.map +1 -0
  60. package/dist/safe-bash/commands/bytes/compression/native/types.js +2 -0
  61. package/dist/safe-bash/commands/bytes/compression/native/types.js.map +1 -0
  62. package/dist/safe-bash/commands/bytes/compression/options.d.ts +27 -0
  63. package/dist/safe-bash/commands/bytes/compression/options.d.ts.map +1 -1
  64. package/dist/safe-bash/commands/bytes/compression/options.js +16 -3
  65. package/dist/safe-bash/commands/bytes/compression/options.js.map +1 -1
  66. package/dist/safe-bash/commands/bytes/compression/stream.d.ts.map +1 -1
  67. package/dist/safe-bash/commands/bytes/compression/stream.js +7 -4
  68. package/dist/safe-bash/commands/bytes/compression/stream.js.map +1 -1
  69. package/dist/safe-bash/commands/csplit/index.browser.js +6 -5
  70. package/dist/safe-bash/commands/factor/index.browser.js +4 -3
  71. package/dist/safe-bash/commands/getopt/index.browser.js +4 -3
  72. package/dist/safe-bash/commands/network/curl.js +1 -1
  73. package/dist/safe-bash/commands/network/curl.js.map +1 -1
  74. package/dist/safe-bash/commands/network/index.browser.js +7 -6
  75. package/dist/safe-bash/commands/network/output.d.ts.map +1 -1
  76. package/dist/safe-bash/commands/network/output.js +2 -2
  77. package/dist/safe-bash/commands/network/output.js.map +1 -1
  78. package/dist/safe-bash/commands/network/types.d.ts +4 -0
  79. package/dist/safe-bash/commands/network/types.d.ts.map +1 -1
  80. package/dist/safe-bash/commands/network/types.js.map +1 -1
  81. package/dist/safe-bash/commands/pr/index.browser.js +5 -4
  82. package/dist/safe-bash/commands/truncate.d.ts.map +1 -1
  83. package/dist/safe-bash/commands/truncate.js +14 -1
  84. package/dist/safe-bash/commands/truncate.js.map +1 -1
  85. package/dist/safe-bash/commands/tsort/index.browser.js +5 -4
  86. package/dist/safe-bash/commands/xml/index.browser.js +6 -5
  87. package/dist/safe-bash/commands/yq/index.browser.js +7 -6
  88. package/dist/safe-bash/contracts/filesystem.d.ts +1 -1
  89. package/dist/safe-bash/contracts/filesystem.d.ts.map +1 -1
  90. package/dist/safe-bash/core.browser.js +323 -97
  91. package/dist/safe-bash/core.browser.js.map +4 -4
  92. package/package.json +2 -2
  93. package/dist/safe-bash/chunks/chunk-RVGX5DQT.js.map +0 -7
  94. /package/dist/safe-bash/chunks/{chunk-CI42NIWL.js.map → chunk-DPJWEGIX.js.map} +0 -0
@@ -2,12 +2,12 @@ import {
2
2
  createGetoptCommand,
3
3
  createGetoptCommands,
4
4
  getoptCommands
5
- } from "./chunks/chunk-GV76QENF.js";
5
+ } from "./chunks/chunk-LRVRQIG5.js";
6
6
  import {
7
7
  createXmlCommands,
8
8
  defaultXmlQueryLimits,
9
9
  xmlCommands
10
- } from "./chunks/chunk-F4UILGOA.js";
10
+ } from "./chunks/chunk-ZQEL7DYC.js";
11
11
  import {
12
12
  Interpreter,
13
13
  createYqCommand,
@@ -18,7 +18,7 @@ import {
18
18
  rawValues,
19
19
  stringify,
20
20
  yqCommands
21
- } from "./chunks/chunk-QWCD4HKE.js";
21
+ } from "./chunks/chunk-QKQNBJOU.js";
22
22
  import {
23
23
  Budget,
24
24
  JqError,
@@ -31,7 +31,7 @@ import {
31
31
  resolveJqLimits,
32
32
  truth,
33
33
  wellFormed
34
- } from "./chunks/chunk-5X2TAR25.js";
34
+ } from "./chunks/chunk-PPPN3OME.js";
35
35
  import {
36
36
  CurlError,
37
37
  cloudflareWorkerNetworkLimits,
@@ -44,7 +44,7 @@ import {
44
44
  curlCommands,
45
45
  defaultNetworkLimits,
46
46
  networkCommands
47
- } from "./chunks/chunk-RVGX5DQT.js";
47
+ } from "./chunks/chunk-IIWXPQB3.js";
48
48
  import {
49
49
  RecordBuffer,
50
50
  UsageError,
@@ -76,7 +76,7 @@ import {
76
76
  textOutputRequirements,
77
77
  value,
78
78
  writeDiagnostic
79
- } from "./chunks/chunk-R5ZK7V4W.js";
79
+ } from "./chunks/chunk-J4CKSMJV.js";
80
80
  import {
81
81
  AvailableRecords,
82
82
  EreLedger,
@@ -96,22 +96,22 @@ import {
96
96
  exprMatchCeilings,
97
97
  matchEre,
98
98
  withRegexSession
99
- } from "./chunks/chunk-67TENRTW.js";
99
+ } from "./chunks/chunk-Z75O7XWR.js";
100
100
  import {
101
101
  bindFileOutputBudget,
102
102
  openFileOutput,
103
103
  writeFileOutput
104
- } from "./chunks/chunk-RDIJ6M2D.js";
104
+ } from "./chunks/chunk-32GGX4AS.js";
105
105
  import {
106
106
  createPrCommand,
107
107
  createPrCommands,
108
108
  prCommands
109
- } from "./chunks/chunk-GZH6ILJC.js";
109
+ } from "./chunks/chunk-UGMO7OO5.js";
110
110
  import {
111
111
  createTsortCommand,
112
112
  createTsortCommands,
113
113
  tsortCommands
114
- } from "./chunks/chunk-ELK3CQTQ.js";
114
+ } from "./chunks/chunk-LZUOZVGJ.js";
115
115
  import {
116
116
  basename,
117
117
  dirname,
@@ -121,15 +121,15 @@ import {
121
121
  relativePath,
122
122
  resolvePath,
123
123
  validatePath
124
- } from "./chunks/chunk-CI42NIWL.js";
124
+ } from "./chunks/chunk-DPJWEGIX.js";
125
125
  import {
126
126
  createFactorCommand,
127
127
  createFactorCommands,
128
128
  factorCommands
129
- } from "./chunks/chunk-LUIEXTN5.js";
129
+ } from "./chunks/chunk-DJHZJAB7.js";
130
130
  import {
131
131
  createOutputOperation
132
- } from "./chunks/chunk-UL4TNDNV.js";
132
+ } from "./chunks/chunk-EYJTLUBJ.js";
133
133
  import {
134
134
  CommandArgumentIdentityError,
135
135
  CommandRegistry,
@@ -142,8 +142,6 @@ import {
142
142
  createBytePipe,
143
143
  createCommandArguments,
144
144
  getCommandArguments,
145
- import_buffer,
146
- init_platform,
147
145
  isErrnoCode,
148
146
  isFsError,
149
147
  monotonicNow,
@@ -164,7 +162,11 @@ import {
164
162
  writeBytes,
165
163
  writeText,
166
164
  yieldTurn
167
- } from "./chunks/chunk-4NMFAR4Z.js";
165
+ } from "./chunks/chunk-GZKLXMBM.js";
166
+ import {
167
+ import_buffer,
168
+ init_platform
169
+ } from "./chunks/chunk-2KL6W6NB.js";
168
170
 
169
171
  // packages/safe-bash/src/core.browser.ts
170
172
  init_platform();
@@ -17253,6 +17255,87 @@ init_platform();
17253
17255
  // packages/safe-bash/src/commands/bytes/compression/files.ts
17254
17256
  init_platform();
17255
17257
 
17258
+ // packages/safe-bash/src/commands/bytes/compression/options.ts
17259
+ init_platform();
17260
+ var profiles = [
17261
+ { format: "gzip", names: ["gzip", "gunzip", "zcat"], suffix: ".gz", level: 6, keep: false },
17262
+ { format: "bzip2", names: ["bzip2", "bunzip2", "bzcat"], suffix: ".bz2", level: 9, keep: false },
17263
+ { format: "xz", names: ["xz", "unxz", "xzcat"], suffix: ".xz", level: 3, keep: false },
17264
+ { format: "zstd", names: ["zstd", "unzstd", "zstdcat"], suffix: ".zst", level: 3, keep: true }
17265
+ ];
17266
+ var aliases = {
17267
+ stdout: "c",
17268
+ "to-stdout": "c",
17269
+ decompress: "d",
17270
+ uncompress: "d",
17271
+ keep: "k",
17272
+ force: "f",
17273
+ test: "t",
17274
+ fast: "1",
17275
+ best: "9",
17276
+ "no-name": "n",
17277
+ help: "h"
17278
+ };
17279
+ function parseOptions(command7, args) {
17280
+ const profile2 = profiles.find((value2) => value2.names.some((name2) => name2 === command7));
17281
+ if (!profile2) throw new UsageError(`unknown compression command '${command7}'`);
17282
+ const result2 = {
17283
+ format: profile2.format,
17284
+ decompress: command7 !== profile2.names[0],
17285
+ stdout: command7 === profile2.names[2],
17286
+ keep: profile2.keep,
17287
+ force: false,
17288
+ test: false,
17289
+ help: false,
17290
+ level: profile2.level,
17291
+ operands: []
17292
+ };
17293
+ let ended = false;
17294
+ for (const argument2 of args) {
17295
+ if (ended || argument2 === "-" || !argument2.startsWith("-")) {
17296
+ result2.operands.push(argument2);
17297
+ continue;
17298
+ }
17299
+ if (argument2 === "--") {
17300
+ ended = true;
17301
+ continue;
17302
+ }
17303
+ const flags3 = argument2.startsWith("--") ? aliases[argument2.slice(2)] : argument2.slice(1);
17304
+ if (!flags3) throw new UsageError(`unrecognized option '${argument2}'`);
17305
+ for (const flag of flags3) {
17306
+ switch (flag) {
17307
+ case "c":
17308
+ result2.stdout = true;
17309
+ break;
17310
+ case "d":
17311
+ result2.decompress = true;
17312
+ break;
17313
+ case "k":
17314
+ result2.keep = true;
17315
+ break;
17316
+ case "f":
17317
+ result2.force = true;
17318
+ break;
17319
+ case "t":
17320
+ result2.test = true;
17321
+ result2.decompress = true;
17322
+ break;
17323
+ case "h":
17324
+ result2.help = true;
17325
+ break;
17326
+ case "n":
17327
+ if (profile2.format !== "gzip") throw new UsageError(`invalid option -- '${flag}'`);
17328
+ break;
17329
+ default:
17330
+ if (/^[1-9]$/u.test(flag)) result2.level = Number(flag);
17331
+ else throw new UsageError(`invalid option -- '${flag}'`);
17332
+ }
17333
+ }
17334
+ }
17335
+ if (!result2.operands.length) result2.operands.push("-");
17336
+ return result2;
17337
+ }
17338
+
17256
17339
  // packages/safe-bash/src/commands/bytes/compression/stream.ts
17257
17340
  init_platform();
17258
17341
 
@@ -20545,6 +20628,187 @@ async function* gunzipMembers(source2, parentSignal, force, warn) {
20545
20628
  }
20546
20629
  }
20547
20630
 
20631
+ // packages/safe-bash/src/commands/bytes/compression/bounded-codec.ts
20632
+ init_platform();
20633
+
20634
+ // packages/safe-bash/src/commands/bytes/compression/codec-loader.ts
20635
+ init_platform();
20636
+ function unavailable() {
20637
+ throw new Error("codec attempted an unavailable host operation");
20638
+ }
20639
+ var wasi = Object.freeze({
20640
+ fd_prestat_get: () => 8,
20641
+ fd_prestat_dir_name: unavailable,
20642
+ fd_write: unavailable,
20643
+ fd_read: unavailable,
20644
+ fd_close: unavailable,
20645
+ fd_seek: unavailable,
20646
+ fd_fdstat_get: unavailable,
20647
+ fd_fdstat_set_flags: unavailable,
20648
+ fd_filestat_get: unavailable,
20649
+ environ_get: unavailable,
20650
+ environ_sizes_get: unavailable,
20651
+ random_get: unavailable,
20652
+ clock_time_get: unavailable,
20653
+ proc_exit: unavailable
20654
+ });
20655
+ async function createCodec(options2, signal, factory) {
20656
+ signal.throwIfAborted();
20657
+ if (!Number.isInteger(options2.level) || options2.level < 1 || options2.level > 9) throw new RangeError("invalid codec level");
20658
+ if (!factory) {
20659
+ switch (options2.format) {
20660
+ case "bzip2":
20661
+ factory = (await import("./chunks/bz2-B2RXT4EX.js")).default;
20662
+ break;
20663
+ case "xz":
20664
+ factory = (await import("./chunks/xz-AVXFDXW4.js")).default;
20665
+ break;
20666
+ case "zstd":
20667
+ factory = (await import("./chunks/zstd-R6RPHJYO.js")).default;
20668
+ break;
20669
+ }
20670
+ }
20671
+ signal.throwIfAborted();
20672
+ const module = factory(wasi);
20673
+ let closed = false;
20674
+ const close = () => {
20675
+ if (!closed) {
20676
+ closed = true;
20677
+ module.bridge_destroy();
20678
+ }
20679
+ };
20680
+ try {
20681
+ module._initialize?.();
20682
+ const initialized = module.bridge_create(Number(options2.decompress), options2.level, 64 * 1024 * 1024, 23);
20683
+ signal.throwIfAborted();
20684
+ if (initialized !== 0) throw new PublicDiagnostic("codec initialization failed or memory limit exceeded");
20685
+ const inputPointer = module.bridge_input();
20686
+ const outputPointer = module.bridge_output();
20687
+ return {
20688
+ step(input3, output2, finish) {
20689
+ signal.throwIfAborted();
20690
+ if (closed) throw new Error("codec is closed");
20691
+ if (input3.length > 65536 || output2.length < 1 || output2.length > 65536) throw new RangeError("invalid codec buffer size");
20692
+ new Uint8Array(module.memory.buffer, inputPointer, input3.length).set(input3);
20693
+ const status2 = module.bridge_step(inputPointer, input3.length, outputPointer, output2.length, Number(finish));
20694
+ signal.throwIfAborted();
20695
+ if (status2 === -4) throw new PublicDiagnostic("unexpected end of file");
20696
+ if (status2 === -2 || status2 === -3) throw new PublicDiagnostic("invalid compressed data or codec memory limit exceeded");
20697
+ if (status2 !== 1 && status2 !== 2 && status2 !== 3) throw new Error(`invalid codec status ${status2}`);
20698
+ const consumed = module.bridge_consumed();
20699
+ const produced = module.bridge_produced();
20700
+ if (!Number.isSafeInteger(consumed) || consumed < 0 || consumed > input3.length || !Number.isSafeInteger(produced) || produced < 0 || produced > output2.length) throw new Error("invalid codec progress");
20701
+ output2.set(new Uint8Array(module.memory.buffer, outputPointer, produced));
20702
+ return { consumed, produced, status: status2 === 1 ? "end" : status2 === 3 ? "output" : "input" };
20703
+ },
20704
+ close
20705
+ };
20706
+ } catch (error) {
20707
+ try {
20708
+ close();
20709
+ } catch {
20710
+ }
20711
+ throw error;
20712
+ }
20713
+ }
20714
+
20715
+ // packages/safe-bash/src/commands/bytes/compression/bounded-codec.ts
20716
+ async function* boundedCodec(input3, options2, signal, create = createCodec) {
20717
+ signal.throwIfAborted();
20718
+ let stream;
20719
+ let current = new Uint8Array();
20720
+ let offset = 0;
20721
+ let eof = false;
20722
+ let needsInput = true;
20723
+ let ended = false;
20724
+ let calls = 0;
20725
+ let work = 0;
20726
+ let failed = false;
20727
+ let output2 = new Uint8Array(64 * 1024);
20728
+ try {
20729
+ stream = await create(options2, signal);
20730
+ for (; ; ) {
20731
+ signal.throwIfAborted();
20732
+ if ((needsInput || ended) && offset === current.length && !eof) {
20733
+ current = await input3.chunk() ?? new Uint8Array();
20734
+ offset = 0;
20735
+ eof = current.length === 0;
20736
+ signal.throwIfAborted();
20737
+ }
20738
+ if (ended) {
20739
+ if (options2.format === "xz") {
20740
+ let padding = 0;
20741
+ while (!eof) {
20742
+ while (offset < current.length && current[offset] === 0) {
20743
+ offset++;
20744
+ padding = (padding + 1) % 4;
20745
+ if (++work >= 64 * 1024) {
20746
+ await yieldTurn(signal);
20747
+ work = 0;
20748
+ calls = 0;
20749
+ }
20750
+ }
20751
+ if (offset < current.length) break;
20752
+ current = await input3.chunk() ?? new Uint8Array();
20753
+ offset = 0;
20754
+ eof = current.length === 0;
20755
+ signal.throwIfAborted();
20756
+ }
20757
+ if (padding) throw new PublicDiagnostic("invalid XZ stream padding");
20758
+ }
20759
+ if (eof) return;
20760
+ const previous = stream;
20761
+ stream = void 0;
20762
+ previous.close();
20763
+ stream = await create(options2, signal);
20764
+ signal.throwIfAborted();
20765
+ ended = false;
20766
+ }
20767
+ const bytes3 = current.subarray(offset, Math.min(current.length, offset + 64 * 1024));
20768
+ const result2 = stream.step(bytes3, output2, eof);
20769
+ signal.throwIfAborted();
20770
+ if (!Number.isSafeInteger(result2.consumed) || result2.consumed < 0 || result2.consumed > bytes3.length || !Number.isSafeInteger(result2.produced) || result2.produced < 0 || result2.produced > output2.length || !["input", "output", "end"].includes(result2.status)) {
20771
+ throw new Error("invalid codec progress");
20772
+ }
20773
+ offset += result2.consumed;
20774
+ if (!result2.consumed && !result2.produced && result2.status !== "end") {
20775
+ if (eof) throw new PublicDiagnostic("unexpected end of file");
20776
+ if (bytes3.length || result2.status !== "input") throw new Error("codec made no progress");
20777
+ }
20778
+ if (result2.produced) {
20779
+ yield output2.subarray(0, result2.produced);
20780
+ signal.throwIfAborted();
20781
+ output2 = new Uint8Array(64 * 1024);
20782
+ }
20783
+ signal.throwIfAborted();
20784
+ work += result2.consumed + result2.produced;
20785
+ if (++calls >= 64 || work >= 64 * 1024) {
20786
+ await yieldTurn(signal);
20787
+ calls = 0;
20788
+ work = 0;
20789
+ }
20790
+ if (result2.status === "end") {
20791
+ if (!options2.decompress) return;
20792
+ ended = true;
20793
+ }
20794
+ needsInput = result2.status !== "output";
20795
+ }
20796
+ } catch (error) {
20797
+ failed = true;
20798
+ options2.onFailure?.(error);
20799
+ throw error;
20800
+ } finally {
20801
+ if (failed) {
20802
+ try {
20803
+ stream?.close();
20804
+ } catch {
20805
+ }
20806
+ } else {
20807
+ stream?.close();
20808
+ }
20809
+ }
20810
+ }
20811
+
20548
20812
  // packages/safe-bash/src/commands/bytes/compression/stream.ts
20549
20813
  var chunkBytes = 64 * 1024;
20550
20814
  var stagingLimit = 256 * 1024 * 1024;
@@ -20618,11 +20882,11 @@ async function transform(source2, consume, options2, parentSignal, maxOutput = I
20618
20882
  };
20619
20883
  let prepared = split2(typeof source2 === "function" ? source2(signal) : source2, signal, fail4);
20620
20884
  let warned2 = false;
20621
- if (options2.decompress) prepared = gunzipMembers(prepared, signal, options2.force, () => {
20885
+ if (options2.format === "gzip" && options2.decompress) prepared = gunzipMembers(prepared, signal, options2.force, () => {
20622
20886
  warned2 = true;
20623
20887
  });
20624
- const reader = options2.decompress ? void 0 : new CodecReader(prepared, signal);
20625
- const transformed = reader ? codec(reader, { mode: "gzip", level: options2.level, onFailure: fail4 }, signal) : prepared;
20888
+ const reader = options2.format === "gzip" && options2.decompress ? void 0 : new CodecReader(prepared, signal);
20889
+ const transformed = options2.format !== "gzip" ? boundedCodec(reader, { format: options2.format, decompress: options2.decompress, level: options2.level, onFailure: fail4 }, signal) : reader ? codec(reader, { mode: "gzip", level: options2.level, onFailure: fail4 }, signal) : prepared;
20626
20890
  let consumed = false;
20627
20891
  const output2 = (async function* () {
20628
20892
  let size = 0;
@@ -20630,7 +20894,7 @@ async function transform(source2, consume, options2, parentSignal, maxOutput = I
20630
20894
  for await (const chunk of readBytes(transformed, signal)) {
20631
20895
  if (chunk.length > maxOutput - size) throw new FsError("EFBIG", { message: `staged output exceeds ${maxOutput} bytes` });
20632
20896
  let bytes3 = chunk;
20633
- if (!options2.decompress && size <= 9 && size + chunk.length > 9) {
20897
+ if (options2.format === "gzip" && !options2.decompress && size <= 9 && size + chunk.length > 9) {
20634
20898
  bytes3 = chunk.slice();
20635
20899
  bytes3[9 - size] = 255;
20636
20900
  }
@@ -20681,6 +20945,17 @@ async function existing(context2, path) {
20681
20945
  }
20682
20946
  }
20683
20947
  function outputPath(source2, options2) {
20948
+ if (options2.format !== "gzip") {
20949
+ const suffix2 = profiles.find((profile2) => profile2.format === options2.format).suffix;
20950
+ if (options2.decompress) {
20951
+ if (!source2.endsWith(suffix2)) throw new FsError("EINVAL", { path: source2, message: `unknown ${options2.format} suffix (use -c for stdout)` });
20952
+ const destination2 = source2.slice(0, -suffix2.length);
20953
+ if (destination2.endsWith("/")) throw new FsError("EINVAL", { path: source2, message: "empty output filename" });
20954
+ return destination2;
20955
+ }
20956
+ if (!options2.force && source2.endsWith(suffix2)) throw new FsError("EINVAL", { path: source2, message: `already has a ${options2.format} suffix (use -f to compress again)` });
20957
+ return source2 + suffix2;
20958
+ }
20684
20959
  if (options2.decompress) {
20685
20960
  if (/\.(?:tgz|taz)$/iu.test(source2)) return source2.slice(0, -4) + ".tar";
20686
20961
  const suffix2 = /(?:\.gz|\.z|-gz|-z|_z)$/iu.exec(source2);
@@ -20848,80 +21123,9 @@ async function writeFileOperand(context2, plan, options2) {
20848
21123
  return warned2;
20849
21124
  }
20850
21125
 
20851
- // packages/safe-bash/src/commands/bytes/compression/options.ts
20852
- init_platform();
20853
- var aliases = {
20854
- stdout: "c",
20855
- "to-stdout": "c",
20856
- decompress: "d",
20857
- uncompress: "d",
20858
- keep: "k",
20859
- force: "f",
20860
- test: "t",
20861
- fast: "1",
20862
- best: "9",
20863
- "no-name": "n",
20864
- help: "h"
20865
- };
20866
- function parseOptions(command7, args) {
20867
- const result2 = {
20868
- decompress: command7 !== "gzip",
20869
- stdout: command7 === "zcat",
20870
- keep: false,
20871
- force: false,
20872
- test: false,
20873
- help: false,
20874
- level: 6,
20875
- operands: []
20876
- };
20877
- let ended = false;
20878
- for (const argument2 of args) {
20879
- if (ended || argument2 === "-" || !argument2.startsWith("-")) {
20880
- result2.operands.push(argument2);
20881
- continue;
20882
- }
20883
- if (argument2 === "--") {
20884
- ended = true;
20885
- continue;
20886
- }
20887
- const flags3 = argument2.startsWith("--") ? aliases[argument2.slice(2)] : argument2.slice(1);
20888
- if (!flags3) throw new UsageError(`unrecognized option '${argument2}'`);
20889
- for (const flag of flags3) {
20890
- switch (flag) {
20891
- case "c":
20892
- result2.stdout = true;
20893
- break;
20894
- case "d":
20895
- result2.decompress = true;
20896
- break;
20897
- case "k":
20898
- result2.keep = true;
20899
- break;
20900
- case "f":
20901
- result2.force = true;
20902
- break;
20903
- case "t":
20904
- result2.test = true;
20905
- result2.decompress = true;
20906
- break;
20907
- case "h":
20908
- result2.help = true;
20909
- break;
20910
- case "n":
20911
- break;
20912
- default:
20913
- if (/^[1-9]$/u.test(flag)) result2.level = Number(flag);
20914
- else throw new UsageError(`invalid option -- '${flag}'`);
20915
- }
20916
- }
20917
- }
20918
- if (!result2.operands.length) result2.operands.push("-");
20919
- return result2;
20920
- }
20921
-
20922
21126
  // packages/safe-bash/src/commands/bytes/compression/index.ts
20923
21127
  function createCompressionCommands() {
20924
- return ["gzip", "gunzip", "zcat"].map((name2) => define(name2, async (context2) => {
21128
+ return profiles.flatMap((profile2) => profile2.names).map((name2) => define(name2, async (context2) => {
20925
21129
  const options2 = parseOptions(name2, context2.args);
20926
21130
  if (options2.help) {
20927
21131
  await output(context2, `Usage: ${name2} [OPTION]... [FILE]...
@@ -20931,8 +21135,9 @@ function createCompressionCommands() {
20931
21135
  -f, --force
20932
21136
  -t, --test
20933
21137
  -1..-9, --fast, --best
20934
- -n, --no-name (always enabled)
20935
- -h, --help
21138
+ ${options2.format === "gzip" ? "-n, --no-name (always enabled)\n" : `Default compression level: ${options2.level}; 64 MiB codec allocation cap.
21139
+ High presets may exceed the cap and fail explicitly.
21140
+ `}-h, --help
20936
21141
  No FILE or FILE '-' uses stdin; file output uses private VFS staging.
20937
21142
  `);
20938
21143
  return { exitCode: 0 };
@@ -24802,7 +25007,7 @@ function truncateCommand(options2 = {}) {
24802
25007
  const configured = settings(options2);
24803
25008
  const argumentLimit = Math.min(65536, configured.limits.maxArgumentBytes);
24804
25009
  const outputMaximum = Math.min(bufferLimit, configured.limits.maxOutputBytes);
24805
- return { name: "truncate", filesystemRequirements: [{ id: "resize", description: "Resize retained writable VFS entries", capabilities: ["retainedResize"], mutates: true }], async execute(context2) {
25010
+ return { name: "truncate", filesystemRequirements: [{ id: "resize", description: "Resize writable VFS entries through retained handles or atomic operations", capabilities: [], anyOf: [["retainedResize"], ["atomicResize"]], mutates: true }], async execute(context2) {
24806
25011
  context2.signal.throwIfAborted();
24807
25012
  const root = createOutputOperation({ signal: context2.signal, registerCleanup(cleanup) {
24808
25013
  let retirement;
@@ -24962,6 +25167,26 @@ ${error.usage ? "Try 'truncate --help' for more information.\n" : ""}`);
24962
25167
  if (readOnly === true) throw new FsError("EROFS");
24963
25168
  const retainedResize = capabilities.retainedResize;
24964
25169
  signal.throwIfAborted();
25170
+ if (retainedResize !== true && capabilities.atomicResize === true) {
25171
+ signal.throwIfAborted();
25172
+ const resize = filesystem.resizeFile;
25173
+ signal.throwIfAborted();
25174
+ if (typeof resize !== "function") throw new FsError("ENOTSUP");
25175
+ const operation2 = {
25176
+ size: settings17.size ?? reference,
25177
+ modifier: settings17.modifier,
25178
+ ...reference === void 0 ? {} : { referenceSize: reference },
25179
+ ioBlocks: settings17.blocks
25180
+ };
25181
+ await root.acquire((signal2) => Reflect.apply(resize, filesystem, [
25182
+ path,
25183
+ operation2,
25184
+ { create: !settings17.noCreate, mode: 438 & ~configured.umask, signal: signal2 }
25185
+ ]), () => {
25186
+ });
25187
+ signal.throwIfAborted();
25188
+ continue;
25189
+ }
24965
25190
  if (retainedResize !== true) throw new FsError("ENOTSUP");
24966
25191
  const openResizeFile = filesystem.openResizeFile;
24967
25192
  signal.throwIfAborted();
@@ -48969,7 +49194,7 @@ init_platform();
48969
49194
  // packages/safe-js/dist/browser/safe-fs.js
48970
49195
  init_platform();
48971
49196
 
48972
- // packages/safe-js/dist/browser/chunks/chunk-HG5OAL4N.js
49197
+ // packages/safe-js/dist/browser/chunks/chunk-BAO3TSWI.js
48973
49198
  init_platform();
48974
49199
  var platform = Object.freeze({
48975
49200
  errno(_code) {
@@ -50461,7 +50686,8 @@ var deviceCapabilities = Object.freeze({
50461
50686
  atomicRename: false,
50462
50687
  atomicRenameNoReplace: false,
50463
50688
  descriptorWriteStream: true,
50464
- retainedResize: true
50689
+ retainedResize: true,
50690
+ atomicResize: false
50465
50691
  });
50466
50692
  var syntheticStat = Object.freeze({
50467
50693
  type: "directory",