@poe-platform/safe-bash 0.1.57 → 0.1.59

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 (42) hide show
  1. package/dist/safe-bash/browser.js +20 -8
  2. package/dist/safe-bash/browser.js.map +2 -2
  3. package/dist/safe-bash/commands/bytes/checksums/index.d.ts +2 -1
  4. package/dist/safe-bash/commands/bytes/checksums/index.d.ts.map +1 -1
  5. package/dist/safe-bash/commands/bytes/checksums/index.js +12 -7
  6. package/dist/safe-bash/commands/bytes/checksums/index.js.map +1 -1
  7. package/dist/safe-bash/commands/bytes/encoding/base.d.ts +1 -1
  8. package/dist/safe-bash/commands/bytes/encoding/base.d.ts.map +1 -1
  9. package/dist/safe-bash/commands/bytes/encoding/base.js +7 -7
  10. package/dist/safe-bash/commands/bytes/encoding/base.js.map +1 -1
  11. package/dist/safe-bash/commands/bytes/encoding/index.d.ts +2 -1
  12. package/dist/safe-bash/commands/bytes/encoding/index.d.ts.map +1 -1
  13. package/dist/safe-bash/commands/bytes/encoding/index.js +4 -2
  14. package/dist/safe-bash/commands/bytes/encoding/index.js.map +1 -1
  15. package/dist/safe-bash/commands/bytes/encoding/od.d.ts +1 -1
  16. package/dist/safe-bash/commands/bytes/encoding/od.d.ts.map +1 -1
  17. package/dist/safe-bash/commands/bytes/encoding/od.js +2 -2
  18. package/dist/safe-bash/commands/bytes/encoding/od.js.map +1 -1
  19. package/dist/safe-bash/commands/bytes/encoding/shared.d.ts +1 -1
  20. package/dist/safe-bash/commands/bytes/encoding/shared.d.ts.map +1 -1
  21. package/dist/safe-bash/commands/bytes/encoding/shared.js +6 -4
  22. package/dist/safe-bash/commands/bytes/encoding/shared.js.map +1 -1
  23. package/dist/safe-bash/commands/bytes/encoding/xxd.d.ts +1 -1
  24. package/dist/safe-bash/commands/bytes/encoding/xxd.d.ts.map +1 -1
  25. package/dist/safe-bash/commands/bytes/encoding/xxd.js +8 -8
  26. package/dist/safe-bash/commands/bytes/encoding/xxd.js.map +1 -1
  27. package/dist/safe-bash/commands/bytes/index.d.ts +7 -1
  28. package/dist/safe-bash/commands/bytes/index.d.ts.map +1 -1
  29. package/dist/safe-bash/commands/bytes/index.js +3 -3
  30. package/dist/safe-bash/commands/bytes/index.js.map +1 -1
  31. package/dist/safe-bash/commands/bytes/input-budget.d.ts +18 -0
  32. package/dist/safe-bash/commands/bytes/input-budget.d.ts.map +1 -0
  33. package/dist/safe-bash/commands/bytes/input-budget.js +35 -0
  34. package/dist/safe-bash/commands/bytes/input-budget.js.map +1 -0
  35. package/dist/safe-bash/plugins/index.d.ts +2 -0
  36. package/dist/safe-bash/plugins/index.d.ts.map +1 -1
  37. package/dist/safe-bash/plugins/index.js +1 -1
  38. package/dist/safe-bash/plugins/index.js.map +1 -1
  39. package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
  40. package/dist/safe-bash/shell/runtime.js +27 -8
  41. package/dist/safe-bash/shell/runtime.js.map +1 -1
  42. package/package.json +2 -2
@@ -10197,6 +10197,13 @@ function activeIO(io) {
10197
10197
  ...error?.closed && error.output === io.stderr ? { stderr: closedSink } : {}
10198
10198
  };
10199
10199
  }
10200
+ function appendOutputBytes(current, chunk) {
10201
+ const length = current.length + chunk.length;
10202
+ const bytes2 = current.buffer.byteLength - current.byteOffset >= length ? new Uint8Array(current.buffer, current.byteOffset, length) : new Uint8Array(Math.max(length, current.length * 2, 64));
10203
+ if (bytes2.buffer !== current.buffer) bytes2.set(current);
10204
+ bytes2.set(chunk, current.length);
10205
+ return bytes2.subarray(0, length);
10206
+ }
10200
10207
  var Flow = class extends Error {
10201
10208
  constructor(kind, status, levels = 1) {
10202
10209
  super(kind);
@@ -12167,22 +12174,27 @@ var Runtime = class _Runtime {
12167
12174
  return this.fileOperation(path, async () => {
12168
12175
  if (closed) throw new Error("Output descriptor is closed");
12169
12176
  const current = file.data;
12170
- if (append) {
12171
- await this.fs.appendFile(path, copy2, options2);
12172
- if (current) {
12173
- const bytes2 = new Uint8Array(current.length + copy2.length);
12174
- bytes2.set(current);
12175
- bytes2.set(copy2, current.length);
12176
- file.data = bytes2;
12177
+ let atEOF = false;
12178
+ if (!append && current && offset === current.length && capabilities.append === true && capabilities.stat !== false) {
12179
+ try {
12180
+ atEOF = (await interruptible(this.fs.stat(path, options2), this.signal)).size === offset;
12181
+ } catch {
12182
+ this.signal.throwIfAborted();
12177
12183
  }
12184
+ this.signal.throwIfAborted();
12185
+ }
12186
+ if (append || atEOF) {
12187
+ const bytes2 = current ? appendOutputBytes(current, copy2) : void 0;
12188
+ await this.fs.appendFile(path, copy2, options2);
12189
+ file.data = bytes2;
12178
12190
  } else {
12179
12191
  const bytes2 = new Uint8Array(Math.max(current?.length ?? 0, offset + copy2.length));
12180
12192
  if (current) bytes2.set(current);
12181
12193
  bytes2.set(copy2, offset);
12182
12194
  await this.fs.writeFile(path, bytes2, options2);
12183
12195
  file.data = bytes2;
12184
- offset += copy2.length;
12185
12196
  }
12197
+ if (!append) offset += copy2.length;
12186
12198
  });
12187
12199
  } };
12188
12200
  };