sandboxedjs 0.1.39 → 0.1.41
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/README.md +44 -0
- package/dist/agent.d.cts +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/{container-BsPKqY9R.d.cts → container-CZn9USBQ.d.cts} +22 -0
- package/dist/{container-BsPKqY9R.d.ts → container-CZn9USBQ.d.ts} +22 -0
- package/dist/index.cjs +74 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -3
- package/dist/index.d.ts +36 -3
- package/dist/index.js +74 -11
- package/dist/index.js.map +1 -1
- package/dist/worker-entry.js +7 -1
- package/dist/worker-entry.js.map +1 -1
- package/package.json +1 -1
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-
|
|
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-
|
|
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-CZn9USBQ.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-CZn9USBQ.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-
|
|
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-
|
|
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-CZn9USBQ.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-CZn9USBQ.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
|
@@ -4751,6 +4751,8 @@ init_path();
|
|
|
4751
4751
|
init_errno();
|
|
4752
4752
|
var encoder2 = new TextEncoder();
|
|
4753
4753
|
var decoder2 = new TextDecoder();
|
|
4754
|
+
var CR = 13;
|
|
4755
|
+
var LF = 10;
|
|
4754
4756
|
function toBytes(data) {
|
|
4755
4757
|
return typeof data === "string" ? encoder2.encode(data) : data;
|
|
4756
4758
|
}
|
|
@@ -4783,6 +4785,21 @@ var Pipe = class _Pipe {
|
|
|
4783
4785
|
* every character appears twice.
|
|
4784
4786
|
*/
|
|
4785
4787
|
raw = false;
|
|
4788
|
+
/**
|
|
4789
|
+
* Translate carriage returns on the way in, the way `ICRNL` does.
|
|
4790
|
+
*
|
|
4791
|
+
* A terminal sends CR when Enter is pressed — xterm and every browser
|
|
4792
|
+
* terminal emulator do — while everything that reads a line looks for LF.
|
|
4793
|
+
* A real tty reconciles the two in its line discipline, which is on by
|
|
4794
|
+
* default; without it `read name` waits forever on input the user already
|
|
4795
|
+
* typed, and the only visible symptom is a hang.
|
|
4796
|
+
*
|
|
4797
|
+
* Deliberately opt-in rather than implied by `isTTY`, because stdout is a
|
|
4798
|
+
* tty too and a bare CR there is how every progress bar and menu redraw
|
|
4799
|
+
* returns to the start of the line. Translating those would corrupt exactly
|
|
4800
|
+
* the output this runtime exists to render faithfully.
|
|
4801
|
+
*/
|
|
4802
|
+
icrnl = false;
|
|
4786
4803
|
onRawMode;
|
|
4787
4804
|
get rawMode() {
|
|
4788
4805
|
return this.raw;
|
|
@@ -4805,7 +4822,7 @@ var Pipe = class _Pipe {
|
|
|
4805
4822
|
write(data) {
|
|
4806
4823
|
if (this.readerClosed) throw new SysError("EPIPE", "write");
|
|
4807
4824
|
if (this.writerClosed) return;
|
|
4808
|
-
const bytes2 = toBytes(data);
|
|
4825
|
+
const bytes2 = this.icrnl && !this.raw ? translateCarriageReturns(toBytes(data)) : toBytes(data);
|
|
4809
4826
|
if (bytes2.length === 0) return;
|
|
4810
4827
|
this.chunks.push(bytes2);
|
|
4811
4828
|
this.buffered += bytes2.length;
|
|
@@ -4898,6 +4915,21 @@ var Pipe = class _Pipe {
|
|
|
4898
4915
|
return p;
|
|
4899
4916
|
}
|
|
4900
4917
|
};
|
|
4918
|
+
function translateCarriageReturns(bytes2) {
|
|
4919
|
+
if (!bytes2.includes(CR)) return bytes2;
|
|
4920
|
+
const out = new Uint8Array(bytes2.length);
|
|
4921
|
+
let length = 0;
|
|
4922
|
+
for (let index = 0; index < bytes2.length; index += 1) {
|
|
4923
|
+
const byte = bytes2[index];
|
|
4924
|
+
if (byte === CR) {
|
|
4925
|
+
out[length++] = LF;
|
|
4926
|
+
if (bytes2[index + 1] === LF) index += 1;
|
|
4927
|
+
} else {
|
|
4928
|
+
out[length++] = byte;
|
|
4929
|
+
}
|
|
4930
|
+
}
|
|
4931
|
+
return out.subarray(0, length);
|
|
4932
|
+
}
|
|
4901
4933
|
var NullOutput = class {
|
|
4902
4934
|
closed = false;
|
|
4903
4935
|
isTTY = false;
|
|
@@ -17296,7 +17328,8 @@ ${stdinPath === null ? "" : `(function () {
|
|
|
17296
17328
|
}
|
|
17297
17329
|
async function execute(ctx, invocation) {
|
|
17298
17330
|
const { pod } = ctx.kernel;
|
|
17299
|
-
const
|
|
17331
|
+
const live = ctx.stdin.interactive || ctx.stdin.isTTY;
|
|
17332
|
+
const tty = ctx.stdin.isTTY;
|
|
17300
17333
|
let exitCode = 0;
|
|
17301
17334
|
try {
|
|
17302
17335
|
const proc = await pod.spawn("node", [invocation.script], {
|
|
@@ -17308,7 +17341,8 @@ async function execute(ctx, invocation) {
|
|
|
17308
17341
|
* program's stdin has to stay open and be fed as it arrives — and be
|
|
17309
17342
|
* reported as a terminal, since that is what decides whether a CLI
|
|
17310
17343
|
* prompts or takes its defaults. */
|
|
17311
|
-
...
|
|
17344
|
+
...live ? { interactiveStdin: true } : {},
|
|
17345
|
+
...tty ? { tty: true } : {}
|
|
17312
17346
|
});
|
|
17313
17347
|
proc.on("output", (chunk) => {
|
|
17314
17348
|
try {
|
|
@@ -17326,7 +17360,7 @@ async function execute(ctx, invocation) {
|
|
|
17326
17360
|
ctx.stdin.rawMode = enabled;
|
|
17327
17361
|
});
|
|
17328
17362
|
let forwarding = false;
|
|
17329
|
-
if (
|
|
17363
|
+
if (live) {
|
|
17330
17364
|
forwarding = true;
|
|
17331
17365
|
void (async () => {
|
|
17332
17366
|
while (forwarding) {
|
|
@@ -21618,10 +21652,9 @@ var KernelChildProcess = class {
|
|
|
21618
21652
|
started = false;
|
|
21619
21653
|
cancelled = false;
|
|
21620
21654
|
constructor(kernel, cred, config, pid) {
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
|
|
21624
|
-
}
|
|
21655
|
+
this.stdin.interactive = true;
|
|
21656
|
+
if (config.inheritStdio) this.stdin.isTTY = true;
|
|
21657
|
+
if (config.stdinIgnored) this.stdin.end();
|
|
21625
21658
|
this.stdin.onRawMode = (enabled) => this.emit("rawmode", enabled);
|
|
21626
21659
|
this.kernel = kernel;
|
|
21627
21660
|
this.cred = cred;
|
|
@@ -24217,13 +24250,19 @@ function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv
|
|
|
24217
24250
|
const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
|
|
24218
24251
|
return { file: shell, args: ["-c", command] };
|
|
24219
24252
|
};
|
|
24253
|
+
const stdinIgnored = (options) => {
|
|
24254
|
+
const stdio = options.stdio;
|
|
24255
|
+
if (stdio === "ignore") return true;
|
|
24256
|
+
return Array.isArray(stdio) && stdio[0] === "ignore";
|
|
24257
|
+
};
|
|
24220
24258
|
const start2 = (file3, args, options) => {
|
|
24221
24259
|
const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
|
|
24222
24260
|
const handle = spawnChild({
|
|
24223
24261
|
command: resolved.file,
|
|
24224
24262
|
args: resolved.args,
|
|
24225
24263
|
cwd: options.cwd ?? defaultCwd(),
|
|
24226
|
-
env: environmentFor(options)
|
|
24264
|
+
env: environmentFor(options),
|
|
24265
|
+
...stdinIgnored(options) ? { stdinIgnored: true } : {}
|
|
24227
24266
|
});
|
|
24228
24267
|
return new ChildProcess(handle, resolved.file, resolved.args);
|
|
24229
24268
|
};
|
|
@@ -27984,6 +28023,8 @@ var Container = class _Container {
|
|
|
27984
28023
|
const stdout = new Pipe();
|
|
27985
28024
|
const stderr = new Pipe();
|
|
27986
28025
|
if (opts.tty) {
|
|
28026
|
+
stdin.isTTY = true;
|
|
28027
|
+
stdin.icrnl = true;
|
|
27987
28028
|
stdout.isTTY = true;
|
|
27988
28029
|
stderr.isTTY = true;
|
|
27989
28030
|
stdout.columns = opts.columns ?? 80;
|
|
@@ -28708,6 +28749,20 @@ function serveContainerOn(port, box) {
|
|
|
28708
28749
|
};
|
|
28709
28750
|
port.start?.();
|
|
28710
28751
|
}
|
|
28752
|
+
var LOOPBACK_HOST = /^(?:localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|\[?::1\]?)$/i;
|
|
28753
|
+
function containerTarget(value) {
|
|
28754
|
+
let url;
|
|
28755
|
+
try {
|
|
28756
|
+
url = new URL(value.trim());
|
|
28757
|
+
} catch {
|
|
28758
|
+
return null;
|
|
28759
|
+
}
|
|
28760
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
28761
|
+
if (!LOOPBACK_HOST.test(url.hostname)) return null;
|
|
28762
|
+
const port = Number(url.port || (url.protocol === "https:" ? 443 : 80));
|
|
28763
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) return null;
|
|
28764
|
+
return { port, path: `${url.pathname}${url.search}` };
|
|
28765
|
+
}
|
|
28711
28766
|
async function createPreview(box, options = {}) {
|
|
28712
28767
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) return null;
|
|
28713
28768
|
const scriptUrl = options.scriptUrl ?? new URL("./service-worker.js?no-inline", import.meta.url);
|
|
@@ -28743,8 +28798,16 @@ async function createPreview(box, options = {}) {
|
|
|
28743
28798
|
serveContainerOn(channel.port1, box);
|
|
28744
28799
|
worker.postMessage({ type: "sandboxedjs:connect" }, [channel.port2]);
|
|
28745
28800
|
const base2 = registration.scope.replace(/\/$/, "");
|
|
28801
|
+
const urlFor = (port) => `${base2}/__sbx__/${port}/`;
|
|
28746
28802
|
return {
|
|
28747
|
-
urlFor
|
|
28803
|
+
urlFor,
|
|
28804
|
+
resolve: (value) => {
|
|
28805
|
+
const target = containerTarget(value);
|
|
28806
|
+
if (!target) return null;
|
|
28807
|
+
if (!box.net.listening().some((entry) => entry.port === target.port)) return null;
|
|
28808
|
+
const path = target.path.startsWith("/") ? target.path : `/${target.path}`;
|
|
28809
|
+
return `${urlFor(target.port).replace(/\/$/, "")}${path}`;
|
|
28810
|
+
},
|
|
28748
28811
|
dispose: async () => {
|
|
28749
28812
|
channel.port1.close();
|
|
28750
28813
|
await registration.unregister();
|
|
@@ -28766,6 +28829,6 @@ async function renderInto(box, element, options = { port: 80 }) {
|
|
|
28766
28829
|
// src/index.ts
|
|
28767
28830
|
var src_default = createContainer;
|
|
28768
28831
|
|
|
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 };
|
|
28832
|
+
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
28833
|
//# sourceMappingURL=index.js.map
|
|
28771
28834
|
//# sourceMappingURL=index.js.map
|