@volter/world-runtime 3.0.52 → 3.0.54

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.
@@ -21,7 +21,7 @@ import { isIP } from 'node:net';
21
21
  import { allocatePort } from "./tcp-port.js";
22
22
  import { constants as osConstants, hostname as osHostname } from 'node:os';
23
23
  import { accessSync, appendFileSync, chmodSync, closeSync, constants as fsConstants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, writeSync, existsSync, fchmodSync, ftruncateSync } from 'node:fs';
24
- import { basename, dirname, join, relative, resolve, sep } from 'node:path';
24
+ import { basename, delimiter, dirname, join, relative, resolve, sep } from 'node:path';
25
25
  import { packFacts } from "./pack-facts.js";
26
26
  import { assertOwnedRealPath, ownedPath } from "./owned-path.js";
27
27
  import { isEnvironmentName } from "./schema.js";
@@ -3040,7 +3040,7 @@ function sleep(ms) {
3040
3040
  return new Promise((resolveWait) => setTimeout(resolveWait, ms));
3041
3041
  }
3042
3042
  function commandExists(command) {
3043
- // Pass the live env so PATH reflects the current process (some runtimes snapshot env otherwise).
3043
+ // Read the current process's PATH rather than an import-time environment snapshot.
3044
3044
  return OWN_COMMANDS[command] !== undefined || onPath(command);
3045
3045
  }
3046
3046
  /** Built-in lifecycle names belong to the executing runtime. PATH may contain another
@@ -3056,22 +3056,25 @@ export function ownCommand(command) {
3056
3056
  ? ['--experimental-transform-types', '--no-warnings'] : [];
3057
3057
  return [process.execPath, ...loader, script, ...args];
3058
3058
  }
3059
- /** A command answers when it names an executable: a path is checked as a file (what `which` does with a path),
3060
- * never by spawning `which`. `ownCommand` hands this the running executable's own path (process.execPath), and a
3061
- * process layer without synchronous spawn (a browser tab's, where spawnSync is ENOSYS) answered "not found on PATH"
3062
- * for the very node running the World: the managed infrastructure never started there. A bare name is still looked
3063
- * up on PATH. */
3059
+ /** Read executable availability without launching a utility. Browser guests can
3060
+ * run an installed lifecycle command while synchronous `which` is ENOSYS. */
3064
3061
  function onPath(command) {
3065
- if (command.includes(sep) || command.includes('/')) {
3062
+ const executable = (path) => {
3066
3063
  try {
3067
- accessSync(command, fsConstants.X_OK);
3068
- return statSync(command).isFile();
3064
+ accessSync(path, fsConstants.X_OK);
3065
+ return statSync(path).isFile();
3069
3066
  }
3070
3067
  catch {
3071
3068
  return false;
3072
3069
  }
3073
- }
3074
- return spawnSync('which', [command], { windowsHide: true, stdio: 'ignore', env: process.env }).status === 0;
3070
+ };
3071
+ if (command.includes(sep) || command.includes('/'))
3072
+ return executable(command);
3073
+ if (!command || process.env.PATH === undefined)
3074
+ return false;
3075
+ const extensions = process.platform === 'win32'
3076
+ ? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)] : [''];
3077
+ return process.env.PATH.split(delimiter).some(directory => extensions.some(extension => executable(join(directory || '.', `${command}${extension}`))));
3075
3078
  }
3076
3079
  function resolveWithPublicDns(hostname) {
3077
3080
  const result = spawnSync('dig', ['+short', '@1.1.1.1', hostname, 'A'], { windowsHide: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/world-runtime",
3
- "version": "3.0.52",
3
+ "version": "3.0.54",
4
4
  "description": "World configs for twins: boot named local runtimes, allocate ports, generate world.env/instance.json, and run apps against fake-key twin worlds.",
5
5
  "keywords": [
6
6
  "twin",
@@ -69,14 +69,14 @@
69
69
  "node": ">=22.3"
70
70
  },
71
71
  "peerDependencies": {
72
- "@volter/world-core": "3.0.52",
73
- "@volter/world-console": "3.0.47"
72
+ "@volter/world-core": "3.0.54",
73
+ "@volter/world-console": "3.0.49"
74
74
  },
75
75
  "dependencies": {
76
76
  "@electric-sql/pglite": "0.5.8",
77
77
  "@electric-sql/pglite-pgvector": "0.0.9",
78
78
  "@volter/world-access": "3.0.1",
79
- "@volter/world-core": "3.0.52",
79
+ "@volter/world-core": "3.0.54",
80
80
  "mongodb": "~6.20.0",
81
81
  "pg-gateway": "0.3.0-beta.4",
82
82
  "smol-toml": "^1.8.0",
package/src/runtime.ts CHANGED
@@ -23,7 +23,7 @@ import { isIP } from 'node:net';
23
23
  import { allocatePort } from './tcp-port.ts';
24
24
  import { constants as osConstants, hostname as osHostname } from 'node:os';
25
25
  import { accessSync, appendFileSync, chmodSync, closeSync, constants as fsConstants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, writeSync, existsSync, fchmodSync, ftruncateSync } from 'node:fs';
26
- import { basename, dirname, join, relative, resolve, sep } from 'node:path';
26
+ import { basename, delimiter, dirname, join, relative, resolve, sep } from 'node:path';
27
27
  import { packFacts } from './pack-facts.ts';
28
28
  import { assertOwnedRealPath, ownedPath } from './owned-path.ts';
29
29
  import { isEnvironmentName } from './schema.ts';
@@ -2856,7 +2856,7 @@ function sleep(ms: number): Promise<void> {
2856
2856
  }
2857
2857
 
2858
2858
  function commandExists(command: string): boolean {
2859
- // Pass the live env so PATH reflects the current process (some runtimes snapshot env otherwise).
2859
+ // Read the current process's PATH rather than an import-time environment snapshot.
2860
2860
  return OWN_COMMANDS[command] !== undefined || onPath(command);
2861
2861
  }
2862
2862
 
@@ -2873,16 +2873,18 @@ export function ownCommand(command: string[]): string[] {
2873
2873
  return [process.execPath, ...loader, script, ...args];
2874
2874
  }
2875
2875
 
2876
- /** A command answers when it names an executable: a path is checked as a file (what `which` does with a path),
2877
- * never by spawning `which`. `ownCommand` hands this the running executable's own path (process.execPath), and a
2878
- * process layer without synchronous spawn (a browser tab's, where spawnSync is ENOSYS) answered "not found on PATH"
2879
- * for the very node running the World: the managed infrastructure never started there. A bare name is still looked
2880
- * up on PATH. */
2876
+ /** Read executable availability without launching a utility. Browser guests can
2877
+ * run an installed lifecycle command while synchronous `which` is ENOSYS. */
2881
2878
  function onPath(command: string): boolean {
2882
- if (command.includes(sep) || command.includes('/')) {
2883
- try { accessSync(command, fsConstants.X_OK); return statSync(command).isFile(); } catch { return false; }
2884
- }
2885
- return spawnSync('which', [command], { windowsHide: true, stdio: 'ignore', env: process.env }).status === 0;
2879
+ const executable = (path: string): boolean => {
2880
+ try { accessSync(path, fsConstants.X_OK); return statSync(path).isFile(); } catch { return false; }
2881
+ };
2882
+ if (command.includes(sep) || command.includes('/')) return executable(command);
2883
+ if (!command || process.env.PATH === undefined) return false;
2884
+ const extensions = process.platform === 'win32'
2885
+ ? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean)] : [''];
2886
+ return process.env.PATH.split(delimiter).some(directory =>
2887
+ extensions.some(extension => executable(join(directory || '.', `${command}${extension}`))));
2886
2888
  }
2887
2889
 
2888
2890
  function resolveWithPublicDns(hostname: string): string | undefined {