sandboxedjs 0.1.39 → 0.1.40

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Shell, a as ShellIO, b as Session, V as Vfs, c as Cred, N as Node, d as Command, K as Kernel, R as RuntimeVolume, e as VolumeStat, f as VolumeStats, g as RuntimeHttpResponse, h as SpawnChild, i as SyncSpawn, j as RuntimePod, k as RuntimePackageInstaller, l as ChildSpawnConfig, m as ChildHandle, n as RuntimeProcess, E as ExecContext, O as OutputStream, C as Container, o as createContainer } from './container-BsPKqY9R.cjs';
2
- export { B as BufferSink, p as CPythonOptions, q as CallbackSink, r as CommandRegistry, s as ContainerFs, t as ContainerOptions, u as ContextInit, D as DirEntry, v as Env, w as ExecOptions, x as ExecResult, F as FileData, y as FileInput, z as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, A as KernelOptions, L as ListeningPort, M as MountEntry, P as NetInterface, Q as NetworkOptions, T as NetworkStack, U as NullInput, W as NullOutput, X as PYTHON_VERSION, Y as PasswdEntry, Z as Pipe, _ as Process, $ as ProcessKind, a0 as ProcessOptions, a1 as ProcessState, a2 as ProcessTable, a3 as PythonOptions, a4 as ROOT_CRED, a5 as ResolvedExecutable, a6 as RunOptions, a7 as RunResult, a8 as RuntimeProcessManager, a9 as RuntimeProcessResult, aa as SessionInit, ab as SessionResult, ac as SessionRunOptions, ad as ShellExit, ae as ShellInit, af as ShellOptions, ag as SpawnHandle, ah as Stats, ai as Stdio, aj as TeeOutput, ak as UserDatabase, al as Variables, am as VirtualNode, an as VirtualProvider, ao as WriteOptions, ap as applyChmod, aq as braceExpand, ar as captureStdio, as as configureCPython, at as configurePython, au as createChildProcessModule, av as createContext, aw as defineCommand, ax as expandWord, ay as expandWords, az as formatMode, aA as isCPythonAvailable, aB as isPythonAvailable, aC as makeCred, aD as octalMode, aE as parseUmask, aF as resetPidCounter, aG as shellQuote } from './container-BsPKqY9R.cjs';
1
+ import { S as Shell, a as ShellIO, b as Session, V as Vfs, c as Cred, N as Node, d as Command, K as Kernel, R as RuntimeVolume, e as VolumeStat, f as VolumeStats, g as RuntimeHttpResponse, h as SpawnChild, i as SyncSpawn, j as RuntimePod, k as RuntimePackageInstaller, l as ChildSpawnConfig, m as ChildHandle, n as RuntimeProcess, E as ExecContext, O as OutputStream, C as Container, o as createContainer } from './container-Bg_BuaAv.cjs';
2
+ export { B as BufferSink, p as CPythonOptions, q as CallbackSink, r as CommandRegistry, s as ContainerFs, t as ContainerOptions, u as ContextInit, D as DirEntry, v as Env, w as ExecOptions, x as ExecResult, F as FileData, y as FileInput, z as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, A as KernelOptions, L as ListeningPort, M as MountEntry, P as NetInterface, Q as NetworkOptions, T as NetworkStack, U as NullInput, W as NullOutput, X as PYTHON_VERSION, Y as PasswdEntry, Z as Pipe, _ as Process, $ as ProcessKind, a0 as ProcessOptions, a1 as ProcessState, a2 as ProcessTable, a3 as PythonOptions, a4 as ROOT_CRED, a5 as ResolvedExecutable, a6 as RunOptions, a7 as RunResult, a8 as RuntimeProcessManager, a9 as RuntimeProcessResult, aa as SessionInit, ab as SessionResult, ac as SessionRunOptions, ad as ShellExit, ae as ShellInit, af as ShellOptions, ag as SpawnHandle, ah as Stats, ai as Stdio, aj as TeeOutput, ak as UserDatabase, al as Variables, am as VirtualNode, an as VirtualProvider, ao as WriteOptions, ap as applyChmod, aq as braceExpand, ar as captureStdio, as as configureCPython, at as configurePython, au as createChildProcessModule, av as createContext, aw as defineCommand, ax as expandWord, ay as expandWords, az as formatMode, aA as isCPythonAvailable, aB as isPythonAvailable, aC as makeCred, aD as octalMode, aE as parseUmask, aF as resetPidCounter, aG as shellQuote } from './container-Bg_BuaAv.cjs';
3
3
  import EventEmitter from 'events/events.js';
4
4
  import streamModule from 'stream-browserify';
5
5
 
@@ -1427,6 +1427,25 @@ declare function syncChannelSupported(): boolean;
1427
1427
  * the response in an iframe with no origin at all.
1428
1428
  */
1429
1429
 
1430
+ /** A container-local server, named by port rather than by an address. */
1431
+ interface ContainerTarget {
1432
+ port: number;
1433
+ /** Path and query, so a deep link does not collapse to the root. */
1434
+ path: string;
1435
+ }
1436
+ /**
1437
+ * The container-local server a URL names, or null if it names anything else.
1438
+ *
1439
+ * A program inside the container prints the only address it can see —
1440
+ * `http://localhost:3000` — and that address is worse than useless once it
1441
+ * leaves: in the page it resolves to the *user's own machine*, where nothing
1442
+ * is listening, so a frame pointed at it fails with "refused to connect"
1443
+ * rather than failing visibly as a routing mistake.
1444
+ *
1445
+ * Exported separately from {@link Preview.resolve} because it is pure, and a
1446
+ * translation table is worth testing without a service worker in the way.
1447
+ */
1448
+ declare function containerTarget(value: string): ContainerTarget | null;
1430
1449
  interface PreviewOptions {
1431
1450
  /** Where the worker script lives; defaults to the copy shipped beside the bundle. */
1432
1451
  scriptUrl?: string | URL;
@@ -1436,6 +1455,20 @@ interface PreviewOptions {
1436
1455
  interface Preview {
1437
1456
  /** The URL an iframe should be pointed at to see `port`. */
1438
1457
  urlFor(port: number): string;
1458
+ /**
1459
+ * Translate an address printed inside the container into one the page can
1460
+ * load, or null when it names nothing this preview serves.
1461
+ *
1462
+ * This is {@link urlFor} keyed by URL instead of by port, and it exists
1463
+ * because that is the form these addresses actually arrive in: a build log,
1464
+ * a server's startup line, a model repeating one back. The path survives, so
1465
+ * `http://localhost:3000/about` lands on `/about`.
1466
+ *
1467
+ * Null covers both "not a container address" and "nothing is listening on
1468
+ * that port" — rewriting a URL to a dead port only trades one blank frame
1469
+ * for another, so the caller is told rather than handed a broken URL.
1470
+ */
1471
+ resolve(url: string): string | null;
1439
1472
  /** Stop answering requests and unregister the worker. */
1440
1473
  dispose(): Promise<void>;
1441
1474
  }
@@ -1483,4 +1516,4 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1483
1516
  * ```
1484
1517
  */
1485
1518
 
1486
- export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
1519
+ export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as Shell, a as ShellIO, b as Session, V as Vfs, c as Cred, N as Node, d as Command, K as Kernel, R as RuntimeVolume, e as VolumeStat, f as VolumeStats, g as RuntimeHttpResponse, h as SpawnChild, i as SyncSpawn, j as RuntimePod, k as RuntimePackageInstaller, l as ChildSpawnConfig, m as ChildHandle, n as RuntimeProcess, E as ExecContext, O as OutputStream, C as Container, o as createContainer } from './container-BsPKqY9R.js';
2
- export { B as BufferSink, p as CPythonOptions, q as CallbackSink, r as CommandRegistry, s as ContainerFs, t as ContainerOptions, u as ContextInit, D as DirEntry, v as Env, w as ExecOptions, x as ExecResult, F as FileData, y as FileInput, z as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, A as KernelOptions, L as ListeningPort, M as MountEntry, P as NetInterface, Q as NetworkOptions, T as NetworkStack, U as NullInput, W as NullOutput, X as PYTHON_VERSION, Y as PasswdEntry, Z as Pipe, _ as Process, $ as ProcessKind, a0 as ProcessOptions, a1 as ProcessState, a2 as ProcessTable, a3 as PythonOptions, a4 as ROOT_CRED, a5 as ResolvedExecutable, a6 as RunOptions, a7 as RunResult, a8 as RuntimeProcessManager, a9 as RuntimeProcessResult, aa as SessionInit, ab as SessionResult, ac as SessionRunOptions, ad as ShellExit, ae as ShellInit, af as ShellOptions, ag as SpawnHandle, ah as Stats, ai as Stdio, aj as TeeOutput, ak as UserDatabase, al as Variables, am as VirtualNode, an as VirtualProvider, ao as WriteOptions, ap as applyChmod, aq as braceExpand, ar as captureStdio, as as configureCPython, at as configurePython, au as createChildProcessModule, av as createContext, aw as defineCommand, ax as expandWord, ay as expandWords, az as formatMode, aA as isCPythonAvailable, aB as isPythonAvailable, aC as makeCred, aD as octalMode, aE as parseUmask, aF as resetPidCounter, aG as shellQuote } from './container-BsPKqY9R.js';
1
+ import { S as Shell, a as ShellIO, b as Session, V as Vfs, c as Cred, N as Node, d as Command, K as Kernel, R as RuntimeVolume, e as VolumeStat, f as VolumeStats, g as RuntimeHttpResponse, h as SpawnChild, i as SyncSpawn, j as RuntimePod, k as RuntimePackageInstaller, l as ChildSpawnConfig, m as ChildHandle, n as RuntimeProcess, E as ExecContext, O as OutputStream, C as Container, o as createContainer } from './container-Bg_BuaAv.js';
2
+ export { B as BufferSink, p as CPythonOptions, q as CallbackSink, r as CommandRegistry, s as ContainerFs, t as ContainerOptions, u as ContextInit, D as DirEntry, v as Env, w as ExecOptions, x as ExecResult, F as FileData, y as FileInput, z as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, A as KernelOptions, L as ListeningPort, M as MountEntry, P as NetInterface, Q as NetworkOptions, T as NetworkStack, U as NullInput, W as NullOutput, X as PYTHON_VERSION, Y as PasswdEntry, Z as Pipe, _ as Process, $ as ProcessKind, a0 as ProcessOptions, a1 as ProcessState, a2 as ProcessTable, a3 as PythonOptions, a4 as ROOT_CRED, a5 as ResolvedExecutable, a6 as RunOptions, a7 as RunResult, a8 as RuntimeProcessManager, a9 as RuntimeProcessResult, aa as SessionInit, ab as SessionResult, ac as SessionRunOptions, ad as ShellExit, ae as ShellInit, af as ShellOptions, ag as SpawnHandle, ah as Stats, ai as Stdio, aj as TeeOutput, ak as UserDatabase, al as Variables, am as VirtualNode, an as VirtualProvider, ao as WriteOptions, ap as applyChmod, aq as braceExpand, ar as captureStdio, as as configureCPython, at as configurePython, au as createChildProcessModule, av as createContext, aw as defineCommand, ax as expandWord, ay as expandWords, az as formatMode, aA as isCPythonAvailable, aB as isPythonAvailable, aC as makeCred, aD as octalMode, aE as parseUmask, aF as resetPidCounter, aG as shellQuote } from './container-Bg_BuaAv.js';
3
3
  import EventEmitter from 'events/events.js';
4
4
  import streamModule from 'stream-browserify';
5
5
 
@@ -1427,6 +1427,25 @@ declare function syncChannelSupported(): boolean;
1427
1427
  * the response in an iframe with no origin at all.
1428
1428
  */
1429
1429
 
1430
+ /** A container-local server, named by port rather than by an address. */
1431
+ interface ContainerTarget {
1432
+ port: number;
1433
+ /** Path and query, so a deep link does not collapse to the root. */
1434
+ path: string;
1435
+ }
1436
+ /**
1437
+ * The container-local server a URL names, or null if it names anything else.
1438
+ *
1439
+ * A program inside the container prints the only address it can see —
1440
+ * `http://localhost:3000` — and that address is worse than useless once it
1441
+ * leaves: in the page it resolves to the *user's own machine*, where nothing
1442
+ * is listening, so a frame pointed at it fails with "refused to connect"
1443
+ * rather than failing visibly as a routing mistake.
1444
+ *
1445
+ * Exported separately from {@link Preview.resolve} because it is pure, and a
1446
+ * translation table is worth testing without a service worker in the way.
1447
+ */
1448
+ declare function containerTarget(value: string): ContainerTarget | null;
1430
1449
  interface PreviewOptions {
1431
1450
  /** Where the worker script lives; defaults to the copy shipped beside the bundle. */
1432
1451
  scriptUrl?: string | URL;
@@ -1436,6 +1455,20 @@ interface PreviewOptions {
1436
1455
  interface Preview {
1437
1456
  /** The URL an iframe should be pointed at to see `port`. */
1438
1457
  urlFor(port: number): string;
1458
+ /**
1459
+ * Translate an address printed inside the container into one the page can
1460
+ * load, or null when it names nothing this preview serves.
1461
+ *
1462
+ * This is {@link urlFor} keyed by URL instead of by port, and it exists
1463
+ * because that is the form these addresses actually arrive in: a build log,
1464
+ * a server's startup line, a model repeating one back. The path survives, so
1465
+ * `http://localhost:3000/about` lands on `/about`.
1466
+ *
1467
+ * Null covers both "not a container address" and "nothing is listening on
1468
+ * that port" — rewriting a URL to a dead port only trades one blank frame
1469
+ * for another, so the caller is told rather than handed a broken URL.
1470
+ */
1471
+ resolve(url: string): string | null;
1439
1472
  /** Stop answering requests and unregister the worker. */
1440
1473
  dispose(): Promise<void>;
1441
1474
  }
@@ -1483,4 +1516,4 @@ declare function renderInto(box: Container, element: HTMLElement, options?: {
1483
1516
  * ```
1484
1517
  */
1485
1518
 
1486
- export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
1519
+ export { ArithError, ChildHandle, ChildSpawnConfig, type CleanInstallerOptions, CleanPackageInstaller, Command, CommonJsEngine, type CommonJsEngineOptions, type CommonJsModule, Container, type ContainerTarget, type CoreModulesOptions, Cred, ERRNO, type ErrnoCode, type EsmTransformResult, ExecContext, IncompleteInputError, type InstallOptions, KERNEL_NAME, KERNEL_RELEASE, Kernel, type LocalRuntimeOptions, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, OS_RELEASE, OutputStream, type Preview, type PreviewOptions, type RootfsOptions, type RunWasiOptions, RuntimePackageInstaller, RuntimePod, RuntimeProcess, RuntimeVolume, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellIO, Lexer as ShellLexer, ShellSyntaxError, SpawnChild, SysError, Terminal, type TerminalOptions, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, type WasiHostOptions, type WasiStdin, type WorkerRuntimeOptions, WorkerRuntimePod, allCommands, buildRootfs, builtinNames, containerTarget, createContainer, createCoreModules, createPreview, createContainer as default, evalArith, exitCodeForSignal, expandPrompt, extractNpmTarball, fnmatch, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isSysError, isWasmBinary, looksLikeEsm, normalizeSignal, parse as parseShell, path as posixPath, renderInto, runWasi, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
package/dist/index.js CHANGED
@@ -17296,7 +17296,8 @@ ${stdinPath === null ? "" : `(function () {
17296
17296
  }
17297
17297
  async function execute(ctx, invocation) {
17298
17298
  const { pod } = ctx.kernel;
17299
- const interactive = ctx.stdin.interactive || ctx.stdin.isTTY;
17299
+ const live = ctx.stdin.interactive || ctx.stdin.isTTY;
17300
+ const tty = ctx.stdin.isTTY;
17300
17301
  let exitCode = 0;
17301
17302
  try {
17302
17303
  const proc = await pod.spawn("node", [invocation.script], {
@@ -17308,7 +17309,8 @@ async function execute(ctx, invocation) {
17308
17309
  * program's stdin has to stay open and be fed as it arrives — and be
17309
17310
  * reported as a terminal, since that is what decides whether a CLI
17310
17311
  * prompts or takes its defaults. */
17311
- ...interactive ? { interactiveStdin: true, tty: true } : {}
17312
+ ...live ? { interactiveStdin: true } : {},
17313
+ ...tty ? { tty: true } : {}
17312
17314
  });
17313
17315
  proc.on("output", (chunk) => {
17314
17316
  try {
@@ -17326,7 +17328,7 @@ async function execute(ctx, invocation) {
17326
17328
  ctx.stdin.rawMode = enabled;
17327
17329
  });
17328
17330
  let forwarding = false;
17329
- if (interactive) {
17331
+ if (live) {
17330
17332
  forwarding = true;
17331
17333
  void (async () => {
17332
17334
  while (forwarding) {
@@ -21618,10 +21620,9 @@ var KernelChildProcess = class {
21618
21620
  started = false;
21619
21621
  cancelled = false;
21620
21622
  constructor(kernel, cred, config, pid) {
21621
- if (config.inheritStdio) {
21622
- this.stdin.isTTY = true;
21623
- this.stdin.interactive = true;
21624
- }
21623
+ this.stdin.interactive = true;
21624
+ if (config.inheritStdio) this.stdin.isTTY = true;
21625
+ if (config.stdinIgnored) this.stdin.end();
21625
21626
  this.stdin.onRawMode = (enabled) => this.emit("rawmode", enabled);
21626
21627
  this.kernel = kernel;
21627
21628
  this.cred = cred;
@@ -24217,13 +24218,19 @@ function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv
24217
24218
  const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
24218
24219
  return { file: shell, args: ["-c", command] };
24219
24220
  };
24221
+ const stdinIgnored = (options) => {
24222
+ const stdio = options.stdio;
24223
+ if (stdio === "ignore") return true;
24224
+ return Array.isArray(stdio) && stdio[0] === "ignore";
24225
+ };
24220
24226
  const start2 = (file3, args, options) => {
24221
24227
  const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
24222
24228
  const handle = spawnChild({
24223
24229
  command: resolved.file,
24224
24230
  args: resolved.args,
24225
24231
  cwd: options.cwd ?? defaultCwd(),
24226
- env: environmentFor(options)
24232
+ env: environmentFor(options),
24233
+ ...stdinIgnored(options) ? { stdinIgnored: true } : {}
24227
24234
  });
24228
24235
  return new ChildProcess(handle, resolved.file, resolved.args);
24229
24236
  };
@@ -27984,6 +27991,7 @@ var Container = class _Container {
27984
27991
  const stdout = new Pipe();
27985
27992
  const stderr = new Pipe();
27986
27993
  if (opts.tty) {
27994
+ stdin.isTTY = true;
27987
27995
  stdout.isTTY = true;
27988
27996
  stderr.isTTY = true;
27989
27997
  stdout.columns = opts.columns ?? 80;
@@ -28708,6 +28716,20 @@ function serveContainerOn(port, box) {
28708
28716
  };
28709
28717
  port.start?.();
28710
28718
  }
28719
+ var LOOPBACK_HOST = /^(?:localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[?::1\]?)$/i;
28720
+ function containerTarget(value) {
28721
+ let url;
28722
+ try {
28723
+ url = new URL(value.trim());
28724
+ } catch {
28725
+ return null;
28726
+ }
28727
+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;
28728
+ if (!LOOPBACK_HOST.test(url.hostname)) return null;
28729
+ const port = Number(url.port || (url.protocol === "https:" ? 443 : 80));
28730
+ if (!Number.isInteger(port) || port < 1 || port > 65535) return null;
28731
+ return { port, path: `${url.pathname}${url.search}` };
28732
+ }
28711
28733
  async function createPreview(box, options = {}) {
28712
28734
  if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) return null;
28713
28735
  const scriptUrl = options.scriptUrl ?? new URL("./service-worker.js?no-inline", import.meta.url);
@@ -28743,8 +28765,16 @@ async function createPreview(box, options = {}) {
28743
28765
  serveContainerOn(channel.port1, box);
28744
28766
  worker.postMessage({ type: "sandboxedjs:connect" }, [channel.port2]);
28745
28767
  const base2 = registration.scope.replace(/\/$/, "");
28768
+ const urlFor = (port) => `${base2}/__sbx__/${port}/`;
28746
28769
  return {
28747
- urlFor: (port) => `${base2}/__sbx__/${port}/`,
28770
+ urlFor,
28771
+ resolve: (value) => {
28772
+ const target = containerTarget(value);
28773
+ if (!target) return null;
28774
+ if (!box.net.listening().some((entry) => entry.port === target.port)) return null;
28775
+ const path = target.path.startsWith("/") ? target.path : `/${target.path}`;
28776
+ return `${urlFor(target.port).replace(/\/$/, "")}${path}`;
28777
+ },
28748
28778
  dispose: async () => {
28749
28779
  channel.port1.close();
28750
28780
  await registration.unregister();
@@ -28766,6 +28796,6 @@ async function renderInto(box, element, options = { port: 80 }) {
28766
28796
  // src/index.ts
28767
28797
  var src_default = createContainer;
28768
28798
 
28769
- export { ArithError, BufferSink, CallbackSink, CleanPackageInstaller, CommandRegistry, CommonJsEngine, Container, ContainerFs, ERRNO, FileInput, FileOutput, IncompleteInputError, KERNEL_NAME, KERNEL_RELEASE, Kernel, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, NetworkStack, NullInput, NullOutput, OS_RELEASE, PYTHON_VERSION, Pipe, Process, ProcessTable, ROOT_CRED, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellExit, Lexer as ShellLexer, ShellSyntaxError, Stats, SysError, TeeOutput, Terminal, UserDatabase, Variables, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, WorkerRuntimePod, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, configureCPython, configurePython, createChildProcessModule, createContainer, createContext, createCoreModules, createPreview, src_default as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, extractNpmTarball, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isCPythonAvailable, isPythonAvailable, isSysError, isWasmBinary, looksLikeEsm, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path_exports as posixPath, renderInto, resetPidCounter, runWasi, shellQuote, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
28799
+ export { ArithError, BufferSink, CallbackSink, CleanPackageInstaller, CommandRegistry, CommonJsEngine, Container, ContainerFs, ERRNO, FileInput, FileOutput, IncompleteInputError, KERNEL_NAME, KERNEL_RELEASE, Kernel, LocalRuntimePod, MemoryVolume, NODE_VERSION, NPM_VERSION, NetworkStack, NullInput, NullOutput, OS_RELEASE, PYTHON_VERSION, Pipe, Process, ProcessTable, ROOT_CRED, SIGNALS, SIGNAL_NAMES, Session, Shell, ShellExit, Lexer as ShellLexer, ShellSyntaxError, Stats, SysError, TeeOutput, Terminal, UserDatabase, Variables, Vfs, VirtualHttpRouter, VirtualHttpServer, VirtualIncomingMessage, VirtualServerResponse, WASM_ALIASES, WasiError, WasiExit, WasiHost, WorkerRuntimePod, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, configureCPython, configurePython, containerTarget, createChildProcessModule, createContainer, createContext, createCoreModules, createPreview, src_default as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, extractNpmTarball, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isCPythonAvailable, isPythonAvailable, isSysError, isWasmBinary, looksLikeEsm, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path_exports as posixPath, renderInto, resetPidCounter, runWasi, shellQuote, startRuntimeWorker, strerror, syncChannelSupported, transformEsm, unameInfo, wasi as wasiCommand };
28770
28800
  //# sourceMappingURL=index.js.map
28771
28801
  //# sourceMappingURL=index.js.map