@poe-platform/safe-bash 0.1.744 → 0.1.746

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 (70) hide show
  1. package/README.md +10 -1
  2. package/dist/image-ast/browser/sharp.d.ts +1 -1
  3. package/dist/image-ast/index.js +133 -35
  4. package/dist/image-ast/sharp.d.ts +1 -1
  5. package/dist/safe-bash/chunks/{chunk-2CO4WCMK.js → chunk-3ZNXN3XO.js} +434 -245
  6. package/dist/safe-bash/chunks/{chunk-2F7Q532M.js → chunk-4GK4FAT6.js} +3 -3
  7. package/dist/safe-bash/chunks/{chunk-WCNFCN2G.js → chunk-BS6QFRNX.js} +2 -2
  8. package/dist/safe-bash/chunks/{chunk-IZZ7KX4E.js → chunk-JCXAGOEK.js} +40 -3
  9. package/dist/safe-bash/chunks/{chunk-WN7FYUWU.js → chunk-MC2KZY3D.js} +26 -13
  10. package/dist/safe-bash/chunks/{chunk-I3DOFJSJ.js → chunk-MUWJPSGN.js} +2 -2
  11. package/dist/safe-bash/chunks/{chunk-7RP6WOWK.js → chunk-OF2PDE3W.js} +2 -2
  12. package/dist/safe-bash/chunks/{pdf-renderer-3TVUXNBT.js → pdf-renderer-4APIM7F7.js} +2 -2
  13. package/dist/safe-bash/chunks/{src-5VZS2ZKB.js → src-T2WAWJXF.js} +2 -2
  14. package/dist/safe-bash/command-chunks/{chunk-DRCPJVZF.js → chunk-44N2IRVP.js} +17 -5
  15. package/dist/safe-bash/command-chunks/{chunk-LYKC7WJB.js → chunk-6742OVAC.js} +37 -3
  16. package/dist/safe-bash/command-chunks/{chunk-BMBXSLVX.js → chunk-6QU5OLPJ.js} +2 -2
  17. package/dist/safe-bash/command-chunks/{chunk-YHANNN7I.js → chunk-S3BO2NJT.js} +7 -0
  18. package/dist/safe-bash/commands/basic.d.ts +2 -0
  19. package/dist/safe-bash/commands/basic.js +236 -9
  20. package/dist/safe-bash/commands/pr/index.browser.js +1 -1
  21. package/dist/safe-bash/commands/streams.js +9 -56
  22. package/dist/safe-bash/commands/table-text/index.js +5 -1
  23. package/dist/safe-bash/commands/text.js +13 -2
  24. package/dist/safe-bash/commands/time-env/shared.js +2 -2
  25. package/dist/safe-bash/commands/time-env/sleep.js +6 -4
  26. package/dist/safe-bash/commands/timeout/index.d.ts +7 -0
  27. package/dist/safe-bash/commands/timeout/index.js +52 -32
  28. package/dist/safe-bash/commands/timeout/scheduler.js +7 -6
  29. package/dist/safe-bash/core.browser.js +3475 -883
  30. package/dist/safe-bash/opt-in/commands/shuf/random.js +2 -3
  31. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +1 -2
  32. package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +1 -2
  33. package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +1 -8
  34. package/dist/safe-bash/playwright/adapter.d.ts +2 -0
  35. package/dist/safe-bash/playwright/capability-events.d.ts +7 -0
  36. package/dist/safe-bash/playwright/capability-events.js +11 -3
  37. package/dist/safe-bash/playwright/controller.d.ts +14 -0
  38. package/dist/safe-bash/playwright/controller.js +36 -8
  39. package/dist/safe-bash/playwright/index.d.ts +1 -0
  40. package/dist/safe-bash/playwright/index.js +1 -0
  41. package/dist/safe-bash/playwright/private-target-transport.d.ts +1 -0
  42. package/dist/safe-bash/playwright/private-target-transport.js +21 -21
  43. package/dist/safe-bash/shell/runtime.d.ts +34 -2
  44. package/dist/safe-bash/shell/runtime.js +4107 -947
  45. package/dist/safe-bash/shell/sync-jq-expression.d.ts +6 -0
  46. package/dist/safe-bash/shell/sync-jq-expression.js +46 -0
  47. package/dist/safe-bash-command-cal/index.js +32 -12
  48. package/dist/safe-bash-command-hostname/index.js +22 -7
  49. package/dist/safe-bash-command-id/index.js +28 -9
  50. package/dist/safe-bash-command-pandoc/command.js +1 -1
  51. package/dist/safe-bash-command-pandoc/index.js +1 -1
  52. package/dist/safe-bash-command-ssconvert/command.d.ts +2 -2
  53. package/dist/safe-bash-command-ssconvert/contracts.d.ts +4 -0
  54. package/dist/safe-bash-command-ssconvert/engine.d.ts +2 -2
  55. package/dist/safe-bash-command-ssconvert/index.js +421 -237
  56. package/dist/safe-bash-command-whoami/index.js +26 -12
  57. package/dist/safe-bash-command-wkhtmltopdf/index.js +24 -11
  58. package/dist/safe-bash-command-wkhtmltopdf/limits.d.ts +1 -1
  59. package/dist/safe-bash-command-wkhtmltopdf/resources.d.ts +1 -1
  60. package/dist/safe-bash-query-engine/index.js +3 -3
  61. package/dist/safe-bash-query-engine/interpreter.js +1 -1
  62. package/dist/safe-bash-query-engine/parser.js +1 -1
  63. package/dist/safe-bash-query-engine/query-core.js +3 -3
  64. package/dist/safe-playwright-cloudflare/browser-private-transport.js +8 -13
  65. package/dist/safe-playwright-cloudflare/browser-storage-control.js +13 -4
  66. package/dist/safe-playwright-cloudflare/browser-trace-archive.js +1 -1
  67. package/package.json +18 -14
  68. package/dist/image-ast/streams/node.d.ts +0 -10
  69. package/dist/image-ast/streams/node.js +0 -5
  70. package/dist/image-ast/streams/web.js +0 -94
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // packages/safe-bash-command-whoami/dist/index.js
6
6
  init_buffer();
7
+ import { isFsError } from "../safe-bash-contracts/errors.js";
7
8
  import { commandRuntimeIdentity, writeText } from "../safe-bash-contracts/index.js";
8
9
  function settings(options = {}) {
9
10
  const limits = {
@@ -31,19 +32,23 @@ Packaged by Safe-Bash (Sandbox VFS-ish/GNU runtime)
31
32
  async function resolvePasswdUser(context, euid, maxBytes) {
32
33
  try {
33
34
  const bytes = await context.fs.readFile("/etc/passwd", { signal: context.signal });
34
- if (bytes.byteLength <= maxBytes) {
35
- const text = new TextDecoder().decode(bytes);
36
- for (const line of text.split("\n")) {
37
- const trimmed = line.trim();
38
- if (!trimmed || trimmed.startsWith("#"))
39
- continue;
40
- const parts = trimmed.split(":");
41
- if (parts.length >= 3 && Number(parts[2]) === euid) {
42
- return parts[0];
43
- }
35
+ context.signal.throwIfAborted();
36
+ if (bytes.byteLength > maxBytes)
37
+ throw new RangeError("/etc/passwd exceeds size limit");
38
+ const text = new TextDecoder().decode(bytes);
39
+ for (const line of text.split("\n")) {
40
+ const trimmed = line.trim();
41
+ if (!trimmed || trimmed.startsWith("#"))
42
+ continue;
43
+ const parts = trimmed.split(":");
44
+ if (parts.length >= 3 && Number(parts[2]) === euid) {
45
+ return parts[0];
44
46
  }
45
47
  }
46
- } catch {
48
+ } catch (error) {
49
+ context.signal.throwIfAborted();
50
+ if (!isFsError(error, "ENOENT"))
51
+ throw error;
47
52
  }
48
53
  return void 0;
49
54
  }
@@ -96,7 +101,16 @@ function createWhoamiCommand(options = {}) {
96
101
  const euid = options.euid ?? options.uid ?? (rawEuid !== void 0 && /^\d+$/.test(rawEuid) ? Number(rawEuid) : void 0);
97
102
  let username;
98
103
  if (euid !== void 0) {
99
- username = await resolvePasswdUser(context, euid, limits.maxPasswdBytes);
104
+ try {
105
+ username = await resolvePasswdUser(context, euid, limits.maxPasswdBytes);
106
+ } catch (error) {
107
+ context.signal.throwIfAborted();
108
+ if (!(error instanceof RangeError))
109
+ throw error;
110
+ await writeText(context.stderr, `whoami: ${error.message}
111
+ `);
112
+ return { exitCode: 1 };
113
+ }
100
114
  if (!username) {
101
115
  if (euid === 0)
102
116
  username = "root";
@@ -4,6 +4,7 @@ import {
4
4
 
5
5
  // packages/safe-bash-command-wkhtmltopdf/dist/index.js
6
6
  init_buffer();
7
+ import { yieldTurn } from "../safe-bash-contracts/yield.js";
7
8
  import { commandRuntimeIdentity, getCommandArguments } from "../safe-bash-contracts/command.js";
8
9
  import { readBytes, writeBytes } from "../safe-bash-contracts/io.js";
9
10
  import { shellValueByteLength } from "../safe-bash-contracts/value.js";
@@ -51,10 +52,10 @@ var init_limits = __esm({
51
52
  this.options = options;
52
53
  this.checkCancellation();
53
54
  this.limits = {
54
- maxArguments: options.limits?.maxArguments,
55
- maxTextBytes: options.limits?.maxTextBytes,
56
- maxObjects: options.limits?.maxObjects,
57
- maxWork: options.limits?.maxWork
55
+ maxArguments: options.limits?.maxArguments ?? Infinity,
56
+ maxTextBytes: options.limits?.maxTextBytes ?? Infinity,
57
+ maxObjects: options.limits?.maxObjects ?? Infinity,
58
+ maxWork: options.limits?.maxWork ?? Infinity
58
59
  };
59
60
  for (const value of Object.values(this.limits)) {
60
61
  if (value !== Infinity && (!Number.isSafeInteger(value) || value < 1)) {
@@ -842,7 +843,13 @@ var init_outcome = __esm({
842
843
  }
843
844
  });
844
845
  async function withResources(options, run) {
845
- const limits = { ...options.limits };
846
+ const limits = {
847
+ maxInputBytes: options.limits?.maxInputBytes ?? Infinity,
848
+ maxDecodedBytes: options.limits?.maxDecodedBytes ?? Infinity,
849
+ maxRetainedBytes: options.limits?.maxRetainedBytes ?? Infinity,
850
+ maxWork: options.limits?.maxWork ?? Infinity,
851
+ maxResources: options.limits?.maxResources ?? Infinity
852
+ };
846
853
  for (const key of ["maxInputBytes", "maxDecodedBytes", "maxRetainedBytes", "maxWork", "maxResources"]) {
847
854
  if (limits[key] !== Infinity && (!Number.isSafeInteger(limits[key]) || limits[key] < 1)) {
848
855
  throw new WkhtmltopdfError("INVALID_VALUE", "Resource limits must be positive safe integers");
@@ -17290,7 +17297,7 @@ function extractLinks(html) {
17290
17297
  }
17291
17298
  return links;
17292
17299
  }
17293
- function parseHtmlDocument(rawHtml, replacements) {
17300
+ async function parseHtmlDocument(rawHtml, replacements, signal) {
17294
17301
  let html = rawHtml;
17295
17302
  for (const [key, value] of replacements) {
17296
17303
  if (key) html = html.split(key).join(value);
@@ -17302,7 +17309,10 @@ function parseHtmlDocument(rawHtml, replacements) {
17302
17309
  const tokenRegex = /<(h[1-6]|p|pre|ul|ol|dl|table|svg|hr|img|blockquote|div|section|article)\b([^>]*)>([\s\S]*?)<\/\1>|<(hr|img)\b([^>]*?)\/?>/gi;
17303
17310
  let lastIndex = 0;
17304
17311
  let match;
17312
+ let work = 0;
17305
17313
  while ((match = tokenRegex.exec(bodyHtml)) !== null) {
17314
+ signal.throwIfAborted();
17315
+ if (++work % 64 === 0) await yieldTurn(signal);
17306
17316
  const leadingText = stripTags(bodyHtml.slice(lastIndex, match.index));
17307
17317
  if (leadingText) {
17308
17318
  blocks.push({ kind: "paragraph", text: leadingText, links: extractLinks(bodyHtml.slice(lastIndex, match.index)) });
@@ -17432,7 +17442,7 @@ function parseHtmlDocument(rawHtml, replacements) {
17432
17442
  }
17433
17443
  } else {
17434
17444
  if (/<(h[1-6]|p|pre|ul|ol|dl|table|svg|hr|img|blockquote|div|section|article)\b/i.test(inner)) {
17435
- const nested = parseHtmlDocument(inner, []);
17445
+ const nested = await parseHtmlDocument(inner, [], signal);
17436
17446
  blocks.push(...nested.blocks);
17437
17447
  } else {
17438
17448
  const text = stripTags(inner);
@@ -17479,7 +17489,7 @@ function rgbColor(r, g, b, grayscale) {
17479
17489
  const lum = Math.round((0.299 * r + 0.587 * g + 0.114 * b) * 1e3) / 1e3;
17480
17490
  return { r: lum, g: lum, b: lum };
17481
17491
  }
17482
- function layoutObjectPages(blocks, box, settings) {
17492
+ async function layoutObjectPages(blocks, box, settings, signal) {
17483
17493
  const pages = [];
17484
17494
  let currentActions = [];
17485
17495
  const headerReserve = settings.header.left || settings.header.center || settings.header.right ? 24 : 0;
@@ -17498,7 +17508,10 @@ function layoutObjectPages(blocks, box, settings) {
17498
17508
  flushPage();
17499
17509
  }
17500
17510
  };
17511
+ let work = 0;
17501
17512
  for (const block of blocks) {
17513
+ signal.throwIfAborted();
17514
+ if (++work % 64 === 0) await yieldTurn(signal);
17502
17515
  if (block.kind === "pagebreak") {
17503
17516
  flushPage();
17504
17517
  continue;
@@ -17817,11 +17830,11 @@ function createPdfAstRenderer() {
17817
17830
  const obj = job.objects[i];
17818
17831
  const htmlBytes = inputs[i] ?? new Uint8Array(0);
17819
17832
  const htmlText = decoder3.decode(htmlBytes);
17820
- const parsed = parseHtmlDocument(htmlText, obj.settings.replacements);
17833
+ const parsed = await parseHtmlDocument(htmlText, obj.settings.replacements, signal);
17821
17834
  if (!inferredDocumentTitle && parsed.title) {
17822
17835
  inferredDocumentTitle = parsed.title;
17823
17836
  }
17824
- const pages = layoutObjectPages(parsed.blocks, box, obj.settings);
17837
+ const pages = await layoutObjectPages(parsed.blocks, box, obj.settings, signal);
17825
17838
  laidOutPerObject.push(pages);
17826
17839
  objectMeta.push({
17827
17840
  title: parsed.title || inferredDocumentTitle || "Document",
@@ -17853,7 +17866,7 @@ function createPdfAstRenderer() {
17853
17866
  producer: "@poe-code/pdf-ast"
17854
17867
  });
17855
17868
  for (const outPage of sequence.pages) {
17856
- signal.throwIfAborted();
17869
+ await yieldTurn(signal);
17857
17870
  const spec = laidOutPerObject[outPage.objectIndex][outPage.pageIndex];
17858
17871
  const meta = objectMeta[outPage.objectIndex];
17859
17872
  const page = doc.addPage({ width: box.width, height: box.height });
@@ -5,7 +5,7 @@ export interface ParseLimits {
5
5
  readonly maxWork: number;
6
6
  }
7
7
  export interface ParseOptions {
8
- readonly limits: ParseLimits;
8
+ readonly limits?: Partial<ParseLimits>;
9
9
  readonly signal?: AbortSignal;
10
10
  /** Deliberate safe CLI deviation from the unqualified ASCII-zero sentinel. */
11
11
  readonly endOfOptions?: boolean;
@@ -24,7 +24,7 @@ export interface ResourceLease {
24
24
  */
25
25
  export type ResourceOpen = (reference: string, signal: AbortSignal) => Promise<ResourceLease>;
26
26
  export interface ResourceOptions {
27
- readonly limits: ResourceLimits;
27
+ readonly limits?: Partial<ResourceLimits>;
28
28
  readonly signal: AbortSignal;
29
29
  readonly vfs?: ResourceOpen;
30
30
  readonly fonts?: ResourceOpen;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-BMBXSLVX.js";
5
- import "../safe-bash/command-chunks/chunk-YHANNN7I.js";
6
- import "../safe-bash/command-chunks/chunk-LYKC7WJB.js";
4
+ } from "../safe-bash/command-chunks/chunk-6QU5OLPJ.js";
5
+ import "../safe-bash/command-chunks/chunk-S3BO2NJT.js";
6
+ import "../safe-bash/command-chunks/chunk-6742OVAC.js";
7
7
  import "../safe-bash/command-chunks/chunk-TPDKSK66.js";
8
8
  import "../safe-bash/command-chunks/chunk-A7SJ2FC6.js";
9
9
  import "../safe-bash/command-chunks/chunk-XZ7QGZMG.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Interpreter
3
- } from "../safe-bash/command-chunks/chunk-LYKC7WJB.js";
3
+ } from "../safe-bash/command-chunks/chunk-6742OVAC.js";
4
4
  import "../safe-bash/command-chunks/chunk-TPDKSK66.js";
5
5
  import "../safe-bash/command-chunks/chunk-A7SJ2FC6.js";
6
6
  import "../safe-bash/command-chunks/chunk-XZ7QGZMG.js";
@@ -2,7 +2,7 @@ import {
2
2
  functions,
3
3
  moduleProgram,
4
4
  parse
5
- } from "../safe-bash/command-chunks/chunk-YHANNN7I.js";
5
+ } from "../safe-bash/command-chunks/chunk-S3BO2NJT.js";
6
6
  import "../safe-bash/command-chunks/chunk-OMJILKF3.js";
7
7
  import "../safe-bash/command-chunks/chunk-E4JIJFSF.js";
8
8
  import "../safe-bash/command-chunks/chunk-R2FMX7XC.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-BMBXSLVX.js";
5
- import "../safe-bash/command-chunks/chunk-YHANNN7I.js";
6
- import "../safe-bash/command-chunks/chunk-LYKC7WJB.js";
4
+ } from "../safe-bash/command-chunks/chunk-6QU5OLPJ.js";
5
+ import "../safe-bash/command-chunks/chunk-S3BO2NJT.js";
6
+ import "../safe-bash/command-chunks/chunk-6742OVAC.js";
7
7
  import "../safe-bash/command-chunks/chunk-TPDKSK66.js";
8
8
  import "../safe-bash/command-chunks/chunk-A7SJ2FC6.js";
9
9
  import "../safe-bash/command-chunks/chunk-XZ7QGZMG.js";
@@ -15,20 +15,14 @@ function protocolObject(data, maxBytes, maxGraphNodes, maxGraphDepth) {
15
15
  });
16
16
  }
17
17
  export function createBrowserPrivateTransport(options = {}) {
18
- const { maxClients = 8, ...guardOptions } = options;
19
- const maxTargets = options.maxPrivateTargets ?? 256;
18
+ const { maxClients = Infinity, ...guardOptions } = options;
19
+ const maxTargets = options.maxPrivateTargets ?? Infinity;
20
20
  const maxBytes = options.maxMessageBytes ?? Infinity;
21
- const creationTimeoutMs = options.creationTimeoutMs ?? 10000;
22
- for (const [name, value] of Object.entries({
23
- ...guardOptions,
24
- maxClients,
25
- maxTargets,
26
- ...(options.maxMessageBytes === undefined ? {} : { maxBytes }),
27
- creationTimeoutMs,
28
- })) {
29
- if (!Number.isSafeInteger(value) ||
21
+ const creationTimeoutMs = options.creationTimeoutMs ?? Infinity;
22
+ for (const [name, value] of Object.entries(options)) {
23
+ if (value !== undefined && value !== Infinity && (!Number.isSafeInteger(value) ||
30
24
  value <= 0 ||
31
- (name.endsWith("TimeoutMs") && value > 2147483647))
25
+ (name.endsWith("TimeoutMs") && value > 2147483647)))
32
26
  throw new TypeError(`Invalid private browser limit: ${name}`);
33
27
  }
34
28
  const clients = new Set();
@@ -258,7 +252,8 @@ export function createBrowserPrivateTransport(options = {}) {
258
252
  active: true,
259
253
  tokens: new Map(),
260
254
  destroyed: new Set(),
261
- deadline: AbortSignal.timeout(creationTimeoutMs),
255
+ deadline: Number.isFinite(creationTimeoutMs)
256
+ ? AbortSignal.timeout(creationTimeoutMs) : new AbortController().signal,
262
257
  expire: () => fail(new Error("Private target creation identity timed out")),
263
258
  };
264
259
  creation = entry;
@@ -75,6 +75,11 @@ export function createBrowserStorageControl(options) {
75
75
  let closing;
76
76
  let timer;
77
77
  let timedCommandId;
78
+ let clock = performance.now();
79
+ function now() {
80
+ clock = Math.max(clock, performance.now());
81
+ return clock;
82
+ }
78
83
  function scheduleDeadline() {
79
84
  if (!Number.isFinite(limits.commandTimeoutMs) || closed)
80
85
  return;
@@ -88,15 +93,19 @@ export function createBrowserStorageControl(options) {
88
93
  if (!first)
89
94
  return;
90
95
  const [id, command] = first;
91
- const remaining = limits.commandTimeoutMs - (performance.now() - command.started);
96
+ const previous = now();
97
+ const remaining = limits.commandTimeoutMs - (previous - command.started);
98
+ const step = Math.min(Math.max(0, remaining), 2147483647);
92
99
  timer = setTimeout(() => {
93
100
  timer = undefined;
94
101
  timedCommandId = undefined;
95
- if (performance.now() - command.started >= limits.commandTimeoutMs)
102
+ // Timer completion advances the logical clock even when workerd freezes performance.now().
103
+ clock = Math.max(now(), previous + step);
104
+ if (clock - command.started >= limits.commandTimeoutMs)
96
105
  expireCommand(id, command.method);
97
106
  // Long deadlines are chunked to avoid the native timer's signed-int overflow.
98
107
  scheduleDeadline();
99
- }, Math.min(Math.max(0, remaining), 2147483647));
108
+ }, step);
100
109
  }
101
110
  function notifyDetached(reason) {
102
111
  const event = {
@@ -251,7 +260,7 @@ export function createBrowserStorageControl(options) {
251
260
  bytes,
252
261
  sessionId,
253
262
  method,
254
- started: performance.now(),
263
+ started: now(),
255
264
  });
256
265
  pendingBytes += bytes;
257
266
  scheduleDeadline();
@@ -30,7 +30,7 @@ export async function writeTraceArchive(options) {
30
30
  const zipLimits = {
31
31
  maxArchiveBytes: limits.maxArchiveBytes, maxEntryBytes: limits.maxBytes,
32
32
  maxTotalBytes: limits.maxBytes, maxMembers: limits.maxFiles,
33
- maxPathBytes: 65535, maxDepth: 32, maxPaxBytes: 65535, maxTextBytes: 65535,
33
+ maxPathBytes: Infinity, maxDepth: Infinity, maxPaxBytes: Infinity, maxTextBytes: Infinity,
34
34
  chunkSize: 65536,
35
35
  };
36
36
  const entries = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.744",
3
+ "version": "0.1.746",
4
4
  "description": "Extensible virtual shell with pluggable filesystems and streaming commands",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -72,25 +72,31 @@
72
72
  },
73
73
  "./contracts": {
74
74
  "types": {
75
+ "workerd": "./dist/safe-bash/contracts/index.d.ts",
75
76
  "browser": "./dist/safe-bash/contracts/index.d.ts",
76
77
  "default": "./dist/safe-bash/contracts/node.d.ts"
77
78
  },
79
+ "workerd": "./dist/safe-bash/contracts/index.js",
78
80
  "browser": "./dist/safe-bash/contracts/index.js",
79
81
  "import": "./dist/safe-bash/contracts/node.js"
80
82
  },
81
83
  "./contracts/index": {
82
84
  "types": {
85
+ "workerd": "./dist/safe-bash/contracts/index.d.ts",
83
86
  "browser": "./dist/safe-bash/contracts/index.d.ts",
84
87
  "default": "./dist/safe-bash/contracts/node.d.ts"
85
88
  },
89
+ "workerd": "./dist/safe-bash/contracts/index.js",
86
90
  "browser": "./dist/safe-bash/contracts/index.js",
87
91
  "import": "./dist/safe-bash/contracts/node.js"
88
92
  },
89
93
  "./contracts/path": {
90
94
  "types": {
95
+ "workerd": "./dist/safe-bash/contracts/path.d.ts",
91
96
  "browser": "./dist/safe-bash/contracts/path.d.ts",
92
97
  "default": "./dist/safe-bash/contracts/node-path.d.ts"
93
98
  },
99
+ "workerd": "./dist/safe-bash/contracts/path.js",
94
100
  "browser": "./dist/safe-bash/contracts/path.js",
95
101
  "import": "./dist/safe-bash/contracts/node-path.js"
96
102
  },
@@ -100,9 +106,9 @@
100
106
  },
101
107
  "./commands/op": {
102
108
  "types": "./dist/safe-bash/commands/op/index.d.ts",
103
- "import": "./dist/safe-bash/commands/op/index.js",
104
109
  "workerd": "./dist/safe-bash/commands/op/index.browser.js",
105
- "browser": "./dist/safe-bash/commands/op/index.browser.js"
110
+ "browser": "./dist/safe-bash/commands/op/index.browser.js",
111
+ "import": "./dist/safe-bash/commands/op/index.js"
106
112
  },
107
113
  "./commands/network": {
108
114
  "types": {
@@ -278,6 +284,7 @@
278
284
  },
279
285
  "./node": {
280
286
  "types": "./dist/safe-bash/node.d.ts",
287
+ "workerd": null,
281
288
  "browser": null,
282
289
  "import": "./dist/safe-bash/node.js"
283
290
  },
@@ -313,6 +320,7 @@
313
320
  },
314
321
  "./commands/docx": {
315
322
  "types": "./dist/safe-bash/commands/docx/index.d.ts",
323
+ "workerd": "./dist/safe-bash/commands/docx/index.browser.js",
316
324
  "browser": "./dist/safe-bash/commands/docx/index.browser.js",
317
325
  "import": "./dist/safe-bash/commands/docx/index.js"
318
326
  },
@@ -322,21 +330,25 @@
322
330
  },
323
331
  "./commands/python": {
324
332
  "types": "./dist/safe-bash/commands/python/index.d.ts",
333
+ "workerd": "./dist/safe-bash/commands/python/index.browser.js",
325
334
  "browser": "./dist/safe-bash/commands/python/index.browser.js",
326
335
  "import": "./dist/safe-bash/commands/python/index.js"
327
336
  },
328
337
  "./commands/python/worker": {
329
338
  "types": "./dist/safe-bash/commands/python/worker.d.ts",
339
+ "workerd": "./dist/safe-bash/commands/python/worker.browser.js",
330
340
  "browser": "./dist/safe-bash/commands/python/worker.browser.js",
331
341
  "import": "./dist/safe-bash/commands/python/worker.js"
332
342
  },
333
343
  "./commands/python/node": {
334
344
  "types": "./dist/safe-bash/commands/python/node.d.ts",
345
+ "workerd": null,
335
346
  "browser": null,
336
347
  "import": "./dist/safe-bash/commands/python/node.js"
337
348
  },
338
349
  "./commands/python/docker": {
339
350
  "types": "./dist/safe-bash/commands/python/docker.d.ts",
351
+ "workerd": null,
340
352
  "browser": null,
341
353
  "import": "./dist/safe-bash/commands/python/docker.js"
342
354
  },
@@ -346,6 +358,7 @@
346
358
  },
347
359
  "./commands/playwright": {
348
360
  "types": "./dist/safe-bash/commands/playwright/index.d.ts",
361
+ "workerd": "./dist/safe-bash/commands/playwright/index.js",
349
362
  "browser": "./dist/safe-bash/commands/playwright/index.js",
350
363
  "import": "./dist/safe-bash/commands/playwright/index.js"
351
364
  },
@@ -407,6 +420,7 @@
407
420
  },
408
421
  "./playwright": {
409
422
  "types": "./dist/safe-bash/commands/playwright/index.d.ts",
423
+ "workerd": "./dist/safe-bash/commands/playwright/index.js",
410
424
  "browser": "./dist/safe-bash/commands/playwright/index.js",
411
425
  "import": "./dist/safe-bash/commands/playwright/index.js"
412
426
  },
@@ -631,7 +645,7 @@
631
645
  "access": "public"
632
646
  },
633
647
  "dependencies": {
634
- "@poe-platform/safe-fs": "0.1.744",
648
+ "@poe-platform/safe-fs": "0.1.746",
635
649
  "pdf-lib": "1.17.1",
636
650
  "@types/node": "^25.2.2",
637
651
  "pako": "3.0.1",
@@ -659,16 +673,6 @@
659
673
  "types": "./dist/safe-bash-command-git/runtime.d.ts",
660
674
  "workerd": "./dist/safe-bash-command-git/runtime.workerd.js",
661
675
  "default": "./dist/safe-bash-command-git/runtime.js"
662
- },
663
- "#image-ast-streams": {
664
- "types": {
665
- "workerd": "./dist/image-ast/browser/streams/web.d.ts",
666
- "browser": "./dist/image-ast/browser/streams/web.d.ts",
667
- "default": "./dist/image-ast/streams/node.d.ts"
668
- },
669
- "workerd": "./dist/image-ast/streams/web.js",
670
- "browser": "./dist/image-ast/streams/web.js",
671
- "default": "./dist/image-ast/streams/node.js"
672
676
  }
673
677
  },
674
678
  "peerDependencies": {
@@ -1,10 +0,0 @@
1
- import { Buffer } from "node:buffer";
2
- export { EventEmitter } from "node:events";
3
- export { Duplex } from "node:stream";
4
- export declare const outputBytes: {
5
- (array: import("node:buffer").WithImplicitCoercion<ArrayLike<number>>): Buffer<ArrayBuffer>;
6
- <TArrayBuffer extends import("node:buffer").WithImplicitCoercion<ArrayBufferLike>>(arrayBuffer: TArrayBuffer, byteOffset?: number, length?: number): Buffer<import("node:buffer").ImplicitArrayBuffer<TArrayBuffer>>;
7
- (string: import("node:buffer").WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
8
- (arrayOrString: import("node:buffer").WithImplicitCoercion<ArrayLike<number> | string>): Buffer<ArrayBuffer>;
9
- };
10
- export declare const isBuffer: (obj: any) => obj is Buffer;
@@ -1,5 +0,0 @@
1
- import { Buffer } from "node:buffer";
2
- export { EventEmitter } from "node:events";
3
- export { Duplex } from "node:stream";
4
- export const outputBytes = Buffer.from;
5
- export const isBuffer = Buffer.isBuffer;
@@ -1,94 +0,0 @@
1
- export const outputBytes = Uint8Array.from.bind(Uint8Array);
2
- export const isBuffer = (_input) => false;
3
- export class EventEmitter {
4
- listeners = new Map();
5
- on(event, listener) {
6
- let listeners = this.listeners.get(event);
7
- if (!listeners)
8
- this.listeners.set(event, listeners = new Set());
9
- listeners.add(listener);
10
- return this;
11
- }
12
- once(event, listener) {
13
- const once = (...args) => { this.removeListener(event, once); listener(...args); };
14
- return this.on(event, once);
15
- }
16
- removeListener(event, listener) {
17
- this.listeners.get(event)?.delete(listener);
18
- return this;
19
- }
20
- emit(event, ...args) {
21
- const listeners = [...this.listeners.get(event) ?? []];
22
- for (const listener of listeners)
23
- listener(...args);
24
- return listeners.length > 0;
25
- }
26
- }
27
- /** Browser Sharp streams use standard Web Streams for pressure and cancellation. */
28
- export class Duplex extends EventEmitter {
29
- readable;
30
- writable;
31
- writableFinished = false;
32
- controller;
33
- closed = false;
34
- constructor() {
35
- super();
36
- this.readable = new ReadableStream({
37
- start: controller => { this.controller = controller; },
38
- pull: () => { this._read(); },
39
- cancel: reason => { this.destroy(reason instanceof Error ? reason : undefined); },
40
- }, { highWaterMark: 0 });
41
- this.writable = new WritableStream({
42
- write: chunk => new Promise((resolve, reject) => {
43
- this._write(chunk, "utf8", error => {
44
- if (error) {
45
- this.destroy(error);
46
- reject(error);
47
- }
48
- else
49
- resolve();
50
- });
51
- }),
52
- close: () => { this.writableFinished = true; this.emit("finish"); },
53
- abort: reason => { this.destroy(reason instanceof Error ? reason : undefined); },
54
- });
55
- }
56
- _write(_chunk, _encoding, callback) {
57
- callback(new Error("Writable operation is not implemented"));
58
- }
59
- _read() { throw new Error("Readable operation is not implemented"); }
60
- push(chunk) {
61
- if (this.closed)
62
- return false;
63
- if (chunk === null) {
64
- this.closed = true;
65
- this.controller.close();
66
- }
67
- else
68
- this.controller.enqueue(new Uint8Array(chunk));
69
- return (this.controller.desiredSize ?? 0) > 0;
70
- }
71
- destroy(error) {
72
- if (!this.closed) {
73
- this.closed = true;
74
- this.controller.error(error ?? new Error("Stream cancelled"));
75
- this.emit("error", error ?? new Error("Stream cancelled"));
76
- }
77
- return this;
78
- }
79
- async *[Symbol.asyncIterator]() {
80
- const reader = this.readable.getReader();
81
- try {
82
- while (true) {
83
- const result = await reader.read();
84
- if (result.done)
85
- return;
86
- yield result.value;
87
- }
88
- }
89
- finally {
90
- await reader.cancel();
91
- reader.releaseLock();
92
- }
93
- }
94
- }