sandboxedjs 0.2.6 → 0.2.7

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.
package/dist/index.js CHANGED
@@ -605,32 +605,32 @@ var init_variables = __esm({
605
605
  return this.find(name) !== void 0;
606
606
  }
607
607
  get(name) {
608
- const found = this.find(name);
609
- if (!found) return void 0;
610
- if (found.entry.array) return found.entry.array[0] ?? "";
611
- return found.entry.value;
608
+ const found2 = this.find(name);
609
+ if (!found2) return void 0;
610
+ if (found2.entry.array) return found2.entry.array[0] ?? "";
611
+ return found2.entry.value;
612
612
  }
613
613
  entry(name) {
614
614
  return this.find(name)?.entry;
615
615
  }
616
616
  getArray(name) {
617
- const found = this.find(name);
618
- if (!found) return void 0;
619
- return found.entry.array ?? [found.entry.value];
617
+ const found2 = this.find(name);
618
+ if (!found2) return void 0;
619
+ return found2.entry.array ?? [found2.entry.value];
620
620
  }
621
621
  isArray(name) {
622
622
  return this.find(name)?.entry.array !== void 0;
623
623
  }
624
624
  set(name, value, attrs = {}) {
625
- const found = this.find(name);
626
- if (found?.entry.readonly) throw new ReadonlyVariableError(name);
625
+ const found2 = this.find(name);
626
+ if (found2?.entry.readonly) throw new ReadonlyVariableError(name);
627
627
  let next = value;
628
- if (found?.entry.upper || attrs.upper) next = next.toUpperCase();
629
- if (found?.entry.lower || attrs.lower) next = next.toLowerCase();
630
- if (found) {
631
- found.entry.value = next;
632
- delete found.entry.array;
633
- Object.assign(found.entry, attrs);
628
+ if (found2?.entry.upper || attrs.upper) next = next.toUpperCase();
629
+ if (found2?.entry.lower || attrs.lower) next = next.toLowerCase();
630
+ if (found2) {
631
+ found2.entry.value = next;
632
+ delete found2.entry.array;
633
+ Object.assign(found2.entry, attrs);
634
634
  } else {
635
635
  this.scopes[this.scopes.length - 1].set(name, { value: next, ...attrs });
636
636
  }
@@ -640,28 +640,28 @@ var init_variables = __esm({
640
640
  this.scopes[this.scopes.length - 1].set(name, { value, ...attrs });
641
641
  }
642
642
  setArray(name, values, attrs = {}) {
643
- const found = this.find(name);
644
- if (found?.entry.readonly) throw new ReadonlyVariableError(name);
645
- if (found) {
646
- found.entry.array = values.slice();
647
- found.entry.value = values[0] ?? "";
648
- Object.assign(found.entry, attrs);
643
+ const found2 = this.find(name);
644
+ if (found2?.entry.readonly) throw new ReadonlyVariableError(name);
645
+ if (found2) {
646
+ found2.entry.array = values.slice();
647
+ found2.entry.value = values[0] ?? "";
648
+ Object.assign(found2.entry, attrs);
649
649
  } else {
650
650
  this.scopes[this.scopes.length - 1].set(name, { value: values[0] ?? "", array: values.slice(), ...attrs });
651
651
  }
652
652
  }
653
653
  setIndex(name, index, value) {
654
- const found = this.find(name);
655
- if (found?.entry.readonly) throw new ReadonlyVariableError(name);
656
- const arr = found?.entry.array ?? (found ? [found.entry.value] : []);
654
+ const found2 = this.find(name);
655
+ if (found2?.entry.readonly) throw new ReadonlyVariableError(name);
656
+ const arr = found2?.entry.array ?? (found2 ? [found2.entry.value] : []);
657
657
  while (arr.length < index) arr.push("");
658
658
  arr[index] = value;
659
659
  this.setArray(name, arr);
660
660
  }
661
661
  append(name, value) {
662
- const found = this.find(name);
663
- if (found?.entry.array) {
664
- this.setArray(name, [...found.entry.array, value]);
662
+ const found2 = this.find(name);
663
+ if (found2?.entry.array) {
664
+ this.setArray(name, [...found2.entry.array, value]);
665
665
  return;
666
666
  }
667
667
  this.set(name, (this.get(name) ?? "") + value);
@@ -678,13 +678,13 @@ var init_variables = __esm({
678
678
  return false;
679
679
  }
680
680
  export(name, exported = true) {
681
- const found = this.find(name);
682
- if (found) found.entry.exported = exported;
681
+ const found2 = this.find(name);
682
+ if (found2) found2.entry.exported = exported;
683
683
  else this.scopes[this.scopes.length - 1].set(name, { value: "", exported });
684
684
  }
685
685
  markReadonly(name) {
686
- const found = this.find(name);
687
- if (found) found.entry.readonly = true;
686
+ const found2 = this.find(name);
687
+ if (found2) found2.entry.readonly = true;
688
688
  else this.scopes[this.scopes.length - 1].set(name, { value: "", readonly: true });
689
689
  }
690
690
  names() {
@@ -2930,8 +2930,8 @@ async function builtinSource({ shell, argv, io }) {
2930
2930
  }
2931
2931
  let path = resolve(shell.cwd, target);
2932
2932
  if (!target.includes("/")) {
2933
- const found = shell.kernel.which(target, shell.cwd, shell.vars.environment(), shell.cred);
2934
- if (found) path = found;
2933
+ const found2 = shell.kernel.which(target, shell.cwd, shell.vars.environment(), shell.cred);
2934
+ if (found2) path = found2;
2935
2935
  }
2936
2936
  let text2;
2937
2937
  try {
@@ -3565,32 +3565,32 @@ function builtinType({ shell, argv, io }) {
3565
3565
  const names = args.filter((a) => !a.startsWith("-"));
3566
3566
  let status = 0;
3567
3567
  for (const name of names) {
3568
- const found = [];
3568
+ const found2 = [];
3569
3569
  if (shell.aliases.has(name)) {
3570
- if (typeOnly) found.push("alias");
3571
- else if (!pathOnly) found.push(`${name} is aliased to \`${shell.aliases.get(name)}'`);
3570
+ if (typeOnly) found2.push("alias");
3571
+ else if (!pathOnly) found2.push(`${name} is aliased to \`${shell.aliases.get(name)}'`);
3572
3572
  }
3573
3573
  if (shell.functions.has(name)) {
3574
- if (typeOnly) found.push("function");
3575
- else if (!pathOnly) found.push(`${name} is a function`);
3574
+ if (typeOnly) found2.push("function");
3575
+ else if (!pathOnly) found2.push(`${name} is a function`);
3576
3576
  }
3577
3577
  if (isBuiltinName(name)) {
3578
- if (typeOnly) found.push("builtin");
3579
- else if (!pathOnly) found.push(`${name} is a shell builtin`);
3578
+ if (typeOnly) found2.push("builtin");
3579
+ else if (!pathOnly) found2.push(`${name} is a shell builtin`);
3580
3580
  }
3581
3581
  const path = shell.kernel.which(name, shell.cwd, shell.vars.environment(), shell.cred);
3582
3582
  if (path) {
3583
- if (typeOnly) found.push("file");
3584
- else if (pathOnly) found.push(path);
3585
- else found.push(`${name} is ${path}`);
3583
+ if (typeOnly) found2.push("file");
3584
+ else if (pathOnly) found2.push(path);
3585
+ else found2.push(`${name} is ${path}`);
3586
3586
  }
3587
- if (found.length === 0) {
3587
+ if (found2.length === 0) {
3588
3588
  if (!pathOnly && !typeOnly) io.stderr.write(`type: ${name}: not found
3589
3589
  `);
3590
3590
  status = 1;
3591
3591
  continue;
3592
3592
  }
3593
- for (const line of all ? found : [found[0]]) io.stdout.write(line + "\n");
3593
+ for (const line of all ? found2 : [found2[0]]) io.stdout.write(line + "\n");
3594
3594
  }
3595
3595
  return status;
3596
3596
  }
@@ -5947,9 +5947,9 @@ function parseArgs(argv, specs, opts = {}) {
5947
5947
  const resolveLong = (name) => {
5948
5948
  const exact = byLong.get(name);
5949
5949
  if (exact) return exact;
5950
- const candidates = [...byLong.keys()].filter((k) => k.startsWith(name));
5951
- if (candidates.length === 1) return byLong.get(candidates[0]);
5952
- if (candidates.length > 1) throw new UsageError(`option '--${name}' is ambiguous`);
5950
+ const candidates2 = [...byLong.keys()].filter((k) => k.startsWith(name));
5951
+ if (candidates2.length === 1) return byLong.get(candidates2[0]);
5952
+ if (candidates2.length > 1) throw new UsageError(`option '--${name}' is ambiguous`);
5953
5953
  return void 0;
5954
5954
  };
5955
5955
  for (; i < argv.length; i++) {
@@ -6468,19 +6468,19 @@ var WasiHost = class {
6468
6468
  }
6469
6469
  // ── descriptors ──────────────────────────────────────────────────────────
6470
6470
  get(fd) {
6471
- const found = this.fds.get(fd);
6472
- if (!found) throw new WasiError(WASI_EBADF);
6473
- return found;
6471
+ const found2 = this.fds.get(fd);
6472
+ if (!found2) throw new WasiError(WASI_EBADF);
6473
+ return found2;
6474
6474
  }
6475
6475
  dir(fd) {
6476
- const found = this.get(fd);
6477
- if (found.kind !== "dir") throw new WasiError(WASI_ENOTDIR);
6478
- return found;
6476
+ const found2 = this.get(fd);
6477
+ if (found2.kind !== "dir") throw new WasiError(WASI_ENOTDIR);
6478
+ return found2;
6479
6479
  }
6480
6480
  file(fd) {
6481
- const found = this.get(fd);
6482
- if (found.kind !== "file") throw new WasiError(WASI_EBADF);
6483
- return found;
6481
+ const found2 = this.get(fd);
6482
+ if (found2.kind !== "file") throw new WasiError(WASI_EBADF);
6483
+ return found2;
6484
6484
  }
6485
6485
  /**
6486
6486
  * Resolve a guest path against a directory descriptor.
@@ -7425,13 +7425,13 @@ var Kernel = class {
7425
7425
  * Find `name` the way `execvp` does. Returns null when nothing matches.
7426
7426
  */
7427
7427
  resolveExecutable(name, cwd, env2, cred = ROOT_CRED) {
7428
- const candidates = [];
7428
+ const candidates2 = [];
7429
7429
  if (name.includes("/")) {
7430
- candidates.push(resolve(cwd, name));
7430
+ candidates2.push(resolve(cwd, name));
7431
7431
  } else {
7432
- for (const dir3 of this.pathDirs(env2)) candidates.push(join(dir3, name));
7432
+ for (const dir3 of this.pathDirs(env2)) candidates2.push(join(dir3, name));
7433
7433
  }
7434
- for (const candidate of candidates) {
7434
+ for (const candidate of candidates2) {
7435
7435
  let real;
7436
7436
  try {
7437
7437
  real = this.vfs.realpath(candidate, cred);
@@ -8407,10 +8407,50 @@ function isBrowser() {
8407
8407
  }
8408
8408
  function browserBlocked(hostname, message) {
8409
8409
  return new Error(
8410
- `${message} \u2014 the request to ${hostname} was blocked by the browser. A page can only read a response from a host that sends CORS headers, and most APIs send none. Give the container a proxy that makes the request for it \u2014 network: { proxy }, and \`npx sandboxedjs-egress\` is one \u2014 or run the container on a server.`
8410
+ `${message} \u2014 the request to ${hostname} was blocked by the browser. A page can only read a response from a host that sends CORS headers, and most APIs send none. The container looks for a proxy to make the request for it and found none: mount \`handleEgressRequest\` from "sandboxedjs/egress" at /__sandboxedjs__/egress on this origin, or run \`npx sandboxedjs-egress\`, and it is used without further configuration (network: { proxy } names one somewhere else) \u2014 or run the container on a server.`
8411
8411
  );
8412
8412
  }
8413
8413
 
8414
+ // src/net/discover-egress.ts
8415
+ var EGRESS_PATH = "/__sandboxedjs__/egress";
8416
+ var EGRESS_MARKER = { sandboxedjs: "egress", protocol: 1 };
8417
+ var CLI_PORT = 4181;
8418
+ var found = null;
8419
+ var PROBE_TIMEOUT_MS = 1500;
8420
+ async function isEgress(url, fetchImpl) {
8421
+ const control = new AbortController();
8422
+ const timer = setTimeout(() => control.abort(), PROBE_TIMEOUT_MS);
8423
+ try {
8424
+ const answer = await fetchImpl(url, { method: "GET", signal: control.signal });
8425
+ if (!answer.ok) return false;
8426
+ const payload = await answer.json();
8427
+ return payload?.sandboxedjs === EGRESS_MARKER.sandboxedjs;
8428
+ } catch {
8429
+ return false;
8430
+ } finally {
8431
+ clearTimeout(timer);
8432
+ }
8433
+ }
8434
+ function candidates() {
8435
+ const origin = globalThis.location?.origin;
8436
+ const list = [];
8437
+ if (origin && /^https?:/.test(origin)) list.push(`${origin}${EGRESS_PATH}`);
8438
+ list.push(`http://127.0.0.1:${CLI_PORT}/`);
8439
+ return list;
8440
+ }
8441
+ async function discoverEgress(fetchImpl = fetch) {
8442
+ if (!isBrowser()) return null;
8443
+ if (!found) {
8444
+ found = (async () => {
8445
+ for (const candidate of candidates()) {
8446
+ if (await isEgress(candidate, fetchImpl)) return candidate;
8447
+ }
8448
+ return null;
8449
+ })();
8450
+ }
8451
+ return await found;
8452
+ }
8453
+
8414
8454
  // src/net/policy.ts
8415
8455
  function isLoopbackHostname(hostname) {
8416
8456
  const host2 = hostname.replace(/^\[|\]$/g, "").toLowerCase();
@@ -8453,7 +8493,8 @@ function policedFetch(policy, fetchImpl) {
8453
8493
  if (!outboundAllowed(policy, url)) {
8454
8494
  throw Object.assign(new TypeError("fetch failed"), { cause: outboundBlockedError(url) });
8455
8495
  }
8456
- if (policy.proxy) return await fetchThroughProxy(policy.proxy, fetchImpl, input, init);
8496
+ const proxy = policy.proxy ?? await discoverEgress(fetchImpl);
8497
+ if (proxy) return await fetchThroughProxy(proxy, fetchImpl, input, init);
8457
8498
  try {
8458
8499
  return await fetchImpl(input, init);
8459
8500
  } catch (error) {
@@ -8989,7 +9030,7 @@ var Lexer = class _Lexer {
8989
9030
  const quoted = /['"\\]/.test(rawTag);
8990
9031
  const tag2 = rawTag.replace(/['"\\]/g, "");
8991
9032
  const lines = [];
8992
- let found = false;
9033
+ let found2 = false;
8993
9034
  while (this.pos < this.src.length) {
8994
9035
  let eol = this.src.indexOf("\n", this.pos);
8995
9036
  if (eol < 0) eol = this.src.length;
@@ -8997,13 +9038,13 @@ var Lexer = class _Lexer {
8997
9038
  this.pos = eol + 1;
8998
9039
  const compare = stripTabs ? rawLine.replace(/^\t+/, "") : rawLine;
8999
9040
  if (compare === tag2) {
9000
- found = true;
9041
+ found2 = true;
9001
9042
  break;
9002
9043
  }
9003
9044
  lines.push(stripTabs ? rawLine.replace(/^\t+/, "") : rawLine);
9004
9045
  if (eol >= this.src.length) break;
9005
9046
  }
9006
- if (!found) {
9047
+ if (!found2) {
9007
9048
  throw new IncompleteInputError(`here-document delimited by end-of-file (wanted \`${tag2}')`, opToken.pos);
9008
9049
  }
9009
9050
  opToken.heredoc = { tag: tag2, stripTabs, quoted, body: lines.length ? lines.join("\n") + "\n" : "" };
@@ -14458,8 +14499,8 @@ var Interpreter = class {
14458
14499
  for (let i = this.locals.length - 1; i >= 0; i--) {
14459
14500
  const scope = this.locals[i];
14460
14501
  if (scope.has(name)) {
14461
- const found = scope.get(name);
14462
- return found instanceof Map ? Value.uninitialized : found;
14502
+ const found2 = scope.get(name);
14503
+ return found2 instanceof Map ? Value.uninitialized : found2;
14463
14504
  }
14464
14505
  }
14465
14506
  if (name === "NF") {
@@ -14491,8 +14532,8 @@ var Interpreter = class {
14491
14532
  for (let i = this.locals.length - 1; i >= 0; i--) {
14492
14533
  const scope = this.locals[i];
14493
14534
  if (scope.has(name)) {
14494
- const found = scope.get(name);
14495
- if (found instanceof Map) return found;
14535
+ const found2 = scope.get(name);
14536
+ if (found2 instanceof Map) return found2;
14496
14537
  const created = /* @__PURE__ */ new Map();
14497
14538
  scope.set(name, created);
14498
14539
  return created;
@@ -17570,7 +17611,7 @@ async function performRequest(ctx, url, init) {
17570
17611
  `outbound network access to ${url.hostname} is disabled for this container (enable with network: { allowOutbound: true })`
17571
17612
  );
17572
17613
  }
17573
- const proxy = ctx.kernel.net.proxy;
17614
+ const proxy = ctx.kernel.net.proxy ?? await discoverEgress();
17574
17615
  if (proxy) {
17575
17616
  const result = await proxyExchange(proxy, {
17576
17617
  url: url.toString(),
@@ -18541,14 +18582,14 @@ var apropos = defineCommand({
18541
18582
  return 1;
18542
18583
  }
18543
18584
  const patterns = ctx.args.map((a) => new RegExp(a, "i"));
18544
- let found = 0;
18585
+ let found2 = 0;
18545
18586
  for (const command of ctx.kernel.commands.all()) {
18546
18587
  const haystack = `${command.name} ${command.summary ?? ""}`;
18547
18588
  if (!patterns.some((p) => p.test(haystack))) continue;
18548
- found++;
18589
+ found2++;
18549
18590
  ctx.line(`${command.name} (1)${" ".repeat(Math.max(1, 16 - command.name.length))}- ${command.summary ?? ""}`);
18550
18591
  }
18551
- if (found === 0) {
18592
+ if (found2 === 0) {
18552
18593
  ctx.line(`${ctx.args.join(" ")}: nothing appropriate.`);
18553
18594
  return 1;
18554
18595
  }
@@ -19572,8 +19613,8 @@ ${prelude}${preloadRequires(preloads)}${source}
19572
19613
  }
19573
19614
  function resolveScript(ctx, operand) {
19574
19615
  const base2 = ctx.path(operand);
19575
- const candidates = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.json`];
19576
- for (const candidate of candidates) {
19616
+ const candidates2 = [base2, `${base2}.js`, `${base2}.mjs`, `${base2}.cjs`, `${base2}.json`];
19617
+ for (const candidate of candidates2) {
19577
19618
  try {
19578
19619
  const st = ctx.vfs.stat(candidate, { cred: ctx.cred });
19579
19620
  if (st.isFile()) return ctx.vfs.realpath(candidate, ctx.cred);
@@ -21040,7 +21081,7 @@ var wheels_default = {
21040
21081
 
21041
21082
  // package.json
21042
21083
  var package_default = {
21043
- version: "0.2.6"};
21084
+ version: "0.2.7"};
21044
21085
 
21045
21086
  // src/python/extension-abi.ts
21046
21087
  var EXTENSION_ABI = {
@@ -23912,7 +23953,7 @@ function explain(name, constraints, chosenVersion, available2 = []) {
23912
23953
  return lines;
23913
23954
  }
23914
23955
  async function fetchCandidates(client, name, allowSourceBuilds, prebuilt, rejected = { versions: /* @__PURE__ */ new Set(), sourceAvailable: false }) {
23915
- const candidates = [];
23956
+ const candidates2 = [];
23916
23957
  if (prebuilt) assertIndexUsable(prebuilt);
23917
23958
  for (const wheel of prebuilt?.wheels ?? []) {
23918
23959
  if (normalize2(wheel.name) !== normalize2(name)) continue;
@@ -23921,7 +23962,7 @@ async function fetchCandidates(client, name, allowSourceBuilds, prebuilt, reject
23921
23962
  `${wheel.filename} in the wheel index was built for ABI ${wheel.abiId}, but this runtime implements ${EXTENSION_ABI.abiId}; rebuild it`
23922
23963
  );
23923
23964
  }
23924
- candidates.push({
23965
+ candidates2.push({
23925
23966
  name: normalize2(wheel.name),
23926
23967
  version: wheel.version,
23927
23968
  kind: "sbx-wasm",
@@ -23932,13 +23973,13 @@ async function fetchCandidates(client, name, allowSourceBuilds, prebuilt, reject
23932
23973
  indexedRequires: wheel.requires
23933
23974
  });
23934
23975
  }
23935
- candidates.push(...builtinCandidates(normalize2(name)));
23936
- if (isBuiltinOnly(normalize2(name))) return candidates;
23976
+ candidates2.push(...builtinCandidates(normalize2(name)));
23977
+ if (isBuiltinOnly(normalize2(name))) return candidates2;
23937
23978
  let index;
23938
23979
  try {
23939
23980
  index = await client.json(`https://pypi.org/pypi/${name}/json`, { timeoutMs: 3e4 });
23940
23981
  } catch (error) {
23941
- if (candidates.length > 0) return candidates;
23982
+ if (candidates2.length > 0) return candidates2;
23942
23983
  throw error;
23943
23984
  }
23944
23985
  for (const [version, files] of Object.entries(index.releases ?? {})) {
@@ -23951,7 +23992,7 @@ async function fetchCandidates(client, name, allowSourceBuilds, prebuilt, reject
23951
23992
  rejected.versions.add(version);
23952
23993
  continue;
23953
23994
  }
23954
- candidates.push({
23995
+ candidates2.push({
23955
23996
  name: normalize2(name),
23956
23997
  version,
23957
23998
  kind,
@@ -23962,7 +24003,7 @@ async function fetchCandidates(client, name, allowSourceBuilds, prebuilt, reject
23962
24003
  });
23963
24004
  }
23964
24005
  }
23965
- return candidates;
24006
+ return candidates2;
23966
24007
  }
23967
24008
  function newest(versions) {
23968
24009
  return versions.reduce((a, b) => compareVersions(b, a, ">") ? b : a);
@@ -24259,17 +24300,17 @@ function createProcessService(ctx) {
24259
24300
  return proc.pid;
24260
24301
  },
24261
24302
  async wait(pid, options) {
24262
- const candidates = pid > 0 ? [children.get(pid)].filter((p) => p !== void 0) : [...children.values()];
24263
- if (candidates.length === 0) throw new PosixError(Errno.ECHILD);
24303
+ const candidates2 = pid > 0 ? [children.get(pid)].filter((p) => p !== void 0) : [...children.values()];
24304
+ if (candidates2.length === 0) throw new PosixError(Errno.ECHILD);
24264
24305
  const reap = (proc) => {
24265
24306
  children.delete(proc.pid);
24266
24307
  return { pid: proc.pid, status: waitStatus(proc) };
24267
24308
  };
24268
- const done = candidates.find(exited);
24309
+ const done = candidates2.find(exited);
24269
24310
  if (done) return reap(done);
24270
24311
  if (options & WNOHANG) return { pid: 0, status: 0 };
24271
- await Promise.race(candidates.map((proc) => proc.wait()));
24272
- const finished = candidates.find(exited);
24312
+ await Promise.race(candidates2.map((proc) => proc.wait()));
24313
+ const finished = candidates2.find(exited);
24273
24314
  if (!finished) throw new PosixError(Errno.ECHILD);
24274
24315
  return reap(finished);
24275
24316
  },
@@ -26497,9 +26538,9 @@ function resolveVersion(metadata, range) {
26497
26538
  const tag2 = metadata["dist-tags"]?.[range];
26498
26539
  if (tag2) return tag2;
26499
26540
  if (valid(range) && metadata.versions[range]) return range;
26500
- const found = maxSatisfying(Object.keys(metadata.versions), range === "latest" ? "*" : range, { includePrerelease: false });
26501
- if (!found) throw new Error(`No matching version found for ${metadata.name}@${range}`);
26502
- return found;
26541
+ const found2 = maxSatisfying(Object.keys(metadata.versions), range === "latest" ? "*" : range, { includePrerelease: false });
26542
+ if (!found2) throw new Error(`No matching version found for ${metadata.name}@${range}`);
26543
+ return found2;
26503
26544
  }
26504
26545
  function verifyIntegrity(data, integrity, shasum, identity) {
26505
26546
  if (integrity) {
@@ -26961,23 +27002,23 @@ var npm = defineCommand({
26961
27002
  case "uninstall":
26962
27003
  case "remove":
26963
27004
  case "rm": {
26964
- const found = readManifest(ctx, root);
27005
+ const found2 = readManifest(ctx, root);
26965
27006
  for (const name of rest.filter((a) => !a.startsWith("-"))) {
26966
27007
  const target = join(root, "node_modules", name);
26967
27008
  if (ctx.vfs.lexists(target)) ctx.vfs.rmrf(target, ctx.cred);
26968
- if (found) {
26969
- delete found.manifest.dependencies?.[name];
26970
- delete found.manifest.devDependencies?.[name];
27009
+ if (found2) {
27010
+ delete found2.manifest.dependencies?.[name];
27011
+ delete found2.manifest.devDependencies?.[name];
26971
27012
  }
26972
27013
  ctx.line(`removed ${name}`);
26973
27014
  }
26974
- if (found) writeManifest(ctx, found.path, found.manifest);
27015
+ if (found2) writeManifest(ctx, found2.path, found2.manifest);
26975
27016
  return 0;
26976
27017
  }
26977
27018
  case "ls":
26978
27019
  case "list": {
26979
- const found = readManifest(ctx, root);
26980
- ctx.line(`${found?.manifest.name ?? basename(root)}@${found?.manifest.version ?? "1.0.0"} ${root}`);
27020
+ const found2 = readManifest(ctx, root);
27021
+ ctx.line(`${found2?.manifest.name ?? basename(root)}@${found2?.manifest.version ?? "1.0.0"} ${root}`);
26981
27022
  const modules = join(root, "node_modules");
26982
27023
  if (!ctx.vfs.lexists(modules)) return 0;
26983
27024
  const names = ctx.vfs.readdir(modules, ctx.cred).filter((n) => !n.startsWith("."));
@@ -26999,29 +27040,29 @@ var npm = defineCommand({
26999
27040
  case "build": {
27000
27041
  const scriptName = subcommand === "run" || subcommand === "run-script" ? rest[0] : subcommand;
27001
27042
  const scriptArgs = subcommand === "run" || subcommand === "run-script" ? rest.slice(1) : rest;
27002
- const found = readManifest(ctx, root);
27003
- if (!found) return ctx.fail("could not read package.json", 1);
27043
+ const found2 = readManifest(ctx, root);
27044
+ if (!found2) return ctx.fail("could not read package.json", 1);
27004
27045
  if (scriptName === void 0) {
27005
- ctx.line("Lifecycle scripts included in " + (found.manifest.name ?? "app") + ":");
27006
- for (const [name, body] of Object.entries(found.manifest.scripts ?? {})) {
27046
+ ctx.line("Lifecycle scripts included in " + (found2.manifest.name ?? "app") + ":");
27047
+ for (const [name, body] of Object.entries(found2.manifest.scripts ?? {})) {
27007
27048
  ctx.line(` ${name}`);
27008
27049
  ctx.line(` ${body}`);
27009
27050
  }
27010
27051
  return 0;
27011
27052
  }
27012
- const script = found.manifest.scripts?.[scriptName];
27053
+ const script = found2.manifest.scripts?.[scriptName];
27013
27054
  if (script === void 0) {
27014
- if (scriptName === "start" && found.manifest.main) {
27015
- return await runScript(ctx, root, `node ${found.manifest.main}`, scriptArgs, found.manifest);
27055
+ if (scriptName === "start" && found2.manifest.main) {
27056
+ return await runScript(ctx, root, `node ${found2.manifest.main}`, scriptArgs, found2.manifest);
27016
27057
  }
27017
27058
  ctx.warn(`Missing script: "${scriptName}"`);
27018
27059
  return 1;
27019
27060
  }
27020
27061
  ctx.line("");
27021
- ctx.line(`> ${found.manifest.name ?? "app"}@${found.manifest.version ?? "1.0.0"} ${scriptName}`);
27062
+ ctx.line(`> ${found2.manifest.name ?? "app"}@${found2.manifest.version ?? "1.0.0"} ${scriptName}`);
27022
27063
  ctx.line(`> ${script}`);
27023
27064
  ctx.line("");
27024
- return await runScript(ctx, root, script, scriptArgs, found.manifest);
27065
+ return await runScript(ctx, root, script, scriptArgs, found2.manifest);
27025
27066
  }
27026
27067
  case "exec":
27027
27068
  return await runScript(ctx, root, rest.join(" "), [], readManifest(ctx, root)?.manifest ?? {});
@@ -29457,23 +29498,23 @@ var CommonJsEngine = class {
29457
29498
  const builtin = this.builtin(specifier);
29458
29499
  if (builtin.found) return specifier;
29459
29500
  if (specifier.startsWith("#")) {
29460
- const found = this.resolveImports(specifier, importer, kind);
29461
- if (found) return found;
29501
+ const found2 = this.resolveImports(specifier, importer, kind);
29502
+ if (found2) return found2;
29462
29503
  throw this.moduleNotFound(specifier, importer);
29463
29504
  }
29464
29505
  const baseDir = dirname(importer);
29465
29506
  if (specifier.startsWith("/") || specifier.startsWith("./") || specifier.startsWith("../")) {
29466
29507
  const resolved = specifier.startsWith("/") ? clean(specifier) : resolve(baseDir, specifier);
29467
- const found = this.resolvePath(resolved, kind);
29468
- if (found) return found;
29508
+ const found2 = this.resolvePath(resolved, kind);
29509
+ if (found2) return found2;
29469
29510
  } else {
29470
29511
  const aliased = this.aliasFor(specifier);
29471
29512
  if (aliased) {
29472
29513
  const substituted = this.resolvePackage(aliased, baseDir, kind);
29473
29514
  if (substituted) return substituted;
29474
29515
  }
29475
- const found = this.resolvePackage(specifier, baseDir, kind);
29476
- if (found) return found;
29516
+ const found2 = this.resolvePackage(specifier, baseDir, kind);
29517
+ if (found2) return found2;
29477
29518
  }
29478
29519
  throw this.moduleNotFound(specifier, importer);
29479
29520
  }
@@ -29639,8 +29680,8 @@ ${code}
29639
29680
  continue;
29640
29681
  }
29641
29682
  for (const target of targets ?? []) {
29642
- const found = this.resolvePath(resolve(root, target), kind);
29643
- if (found) return found;
29683
+ const found2 = this.resolvePath(resolve(root, target), kind);
29684
+ if (found2) return found2;
29644
29685
  }
29645
29686
  }
29646
29687
  return null;
@@ -29649,8 +29690,8 @@ ${code}
29649
29690
  for (const field of ENTRY_FIELDS[kind]) {
29650
29691
  const value = manifest?.[field];
29651
29692
  if (typeof value === "string") {
29652
- const found = this.resolvePath(resolve(root, value), kind);
29653
- if (found) return found;
29693
+ const found2 = this.resolvePath(resolve(root, value), kind);
29694
+ if (found2) return found2;
29654
29695
  }
29655
29696
  }
29656
29697
  return this.resolveIndex(root);
@@ -29673,8 +29714,8 @@ ${code}
29673
29714
  continue;
29674
29715
  }
29675
29716
  for (const target of targets ?? []) {
29676
- const found = target.startsWith(".") ? this.resolvePath(resolve(root, target), kind) : this.resolvePackage(target, root, kind);
29677
- if (found) return found;
29717
+ const found2 = target.startsWith(".") ? this.resolvePath(resolve(root, target), kind) : this.resolvePackage(target, root, kind);
29718
+ if (found2) return found2;
29678
29719
  }
29679
29720
  }
29680
29721
  return null;
@@ -36308,12 +36349,12 @@ async function loadNodeRolldownMemfsBinding() {
36308
36349
  function resolveWorkerPath(node2) {
36309
36350
  const { dirname: dirname3, existsSync, fileURLToPath: fileURLToPath2, join: join3 } = node2;
36310
36351
  const here = dirname3(fileURLToPath2(import.meta.url));
36311
- const candidates = [
36352
+ const candidates2 = [
36312
36353
  join3(here, WORKER_FILE),
36313
36354
  /* src/tools → dist, for a checkout that has been built. */
36314
36355
  join3(here, "..", "..", "dist", WORKER_FILE)
36315
36356
  ];
36316
- return candidates.find((candidate) => existsSync(candidate)) ?? null;
36357
+ return candidates2.find((candidate) => existsSync(candidate)) ?? null;
36317
36358
  }
36318
36359
  function resolveSubpath(node2, require2, packageName, subpath) {
36319
36360
  const { dirname: dirname3, join: join3, pathToFileURL: pathToFileURL2, readFileSync } = node2;
@@ -38667,17 +38708,17 @@ var Terminal = class {
38667
38708
  const match2 = /(\S*)$/.exec(left);
38668
38709
  const word = match2?.[1] ?? "";
38669
38710
  const isFirstWord = left.slice(0, left.length - word.length).trim() === "";
38670
- const candidates = isFirstWord && !word.includes("/") ? this.completeCommand(word) : this.completePath(word);
38671
- if (candidates.length === 0) return;
38672
- if (candidates.length === 1) {
38673
- const completion = candidates[0];
38711
+ const candidates2 = isFirstWord && !word.includes("/") ? this.completeCommand(word) : this.completePath(word);
38712
+ if (candidates2.length === 0) return;
38713
+ if (candidates2.length === 1) {
38714
+ const completion = candidates2[0];
38674
38715
  const suffix = completion.slice(word.length);
38675
38716
  this.buffer = this.buffer.slice(0, this.cursor) + suffix + this.buffer.slice(this.cursor);
38676
38717
  this.cursor += suffix.length;
38677
38718
  this.redraw();
38678
38719
  return;
38679
38720
  }
38680
- const common = longestCommonPrefix(candidates);
38721
+ const common = longestCommonPrefix(candidates2);
38681
38722
  if (common.length > word.length) {
38682
38723
  const suffix = common.slice(word.length);
38683
38724
  this.buffer = this.buffer.slice(0, this.cursor) + suffix + this.buffer.slice(this.cursor);
@@ -38685,7 +38726,7 @@ var Terminal = class {
38685
38726
  this.redraw();
38686
38727
  return;
38687
38728
  }
38688
- this.write("\r\n" + formatColumns(candidates, this.columns) + "\r\n");
38729
+ this.write("\r\n" + formatColumns(candidates2, this.columns) + "\r\n");
38689
38730
  this.redraw();
38690
38731
  }
38691
38732
  completeCommand(word) {