sandboxedjs 0.1.47 → 0.1.49

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,8 @@
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, o as RuntimeSocketPeer, p as RuntimeConnection, E as ExecContext, O as OutputStream, C as Container, q as createContainer } from './container-DyRF-bY0.cjs';
2
- export { B as BufferSink, r as CPythonOptions, s as CallbackSink, t as CommandRegistry, u as ContainerFs, v as ContainerOptions, w as ContextInit, D as DirEntry, x as Env, y as ExecOptions, z as ExecResult, F as FileData, A as FileInput, G as FileOutput, H as GroupEntry, I as HttpResponse, J as InputStream, L as Job, M as KernelOptions, P as ListeningPort, Q as MountEntry, T as NetInterface, U as NetworkOptions, W as NetworkStack, X as NullInput, Y as NullOutput, Z as PYTHON_VERSION, _ as PasswdEntry, $ as Pipe, a0 as Process, a1 as ProcessKind, a2 as ProcessOptions, a3 as ProcessState, a4 as ProcessTable, a5 as PythonOptions, a6 as ROOT_CRED, a7 as ResolvedExecutable, a8 as RunOptions, a9 as RunResult, aa as RuntimeProcessManager, ab as RuntimeProcessResult, ac as SessionInit, ad as SessionResult, ae as SessionRunOptions, af as ShellExit, ag as ShellInit, ah as ShellOptions, ai as SpawnHandle, aj as Stats, ak as Stdio, al as TeeOutput, am as UserDatabase, an as Variables, ao as VirtualNode, ap as VirtualProvider, aq as WriteOptions, ar as applyChmod, as as braceExpand, at as captureStdio, au as configureCPython, av as configurePython, aw as createChildProcessModule, ax as createContext, ay as defineCommand, az as expandWord, aA as expandWords, aB as formatMode, aC as isCPythonAvailable, aD as isPythonAvailable, aE as makeCred, aF as octalMode, aG as parseUmask, aH as resetPidCounter, aI as shellQuote } from './container-DyRF-bY0.cjs';
1
+ import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, d as createContainer } from './container-Dg8NwBc7.cjs';
2
+ export { B as BufferSink, e as CPythonOptions, f as CallbackSink, g as CommandRegistry, h as ContainerFs, i as ContainerOptions, j as ContextInit, k as Env, l as ExecOptions, m as ExecResult, F as FileData, n as FileInput, o as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, p as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, q as MANIFEST_SCHEMA_VERSION, r as MountEntry, s as NetInterface, t as NetworkOptions, u as NetworkStack, v as NullInput, w as NullOutput, P as PYTHON_VERSION, x as PasswdEntry, y as Pipe, z as Process, A as ProcessKind, D as ProcessOptions, Q as ProcessState, R as ProcessTable, T as PythonCapabilities, U as PythonOptions, V as PythonProfile, W as PythonRuntimeManifest, X as ResolvedExecutable, Y as RunOptions, Z as RunResult, _ as SessionInit, $ as SessionResult, a0 as SessionRunOptions, a1 as ShellExit, a2 as ShellInit, a3 as ShellOptions, a4 as SpawnHandle, a5 as Stdio, a6 as TeeOutput, a7 as UserDatabase, a8 as Variables, a9 as braceExpand, aa as captureStdio, ab as configureCPython, ac as configurePython, ad as createContext, ae as defineCommand, af as expandWord, ag as expandWords, ah as isCPythonAvailable, ai as isPythonAvailable, aj as resetPidCounter, ak as shellQuote, al as validateManifest } from './container-Dg8NwBc7.cjs';
3
+ import { V as Vfs, C as Cred, R as RuntimeVolume, a as RuntimeHttpResponse, S as SpawnChild, b as SyncSpawn, c as VolumeStat, d as VolumeStats, e as RuntimePod, f as RuntimePackageInstaller, g as ChildSpawnConfig, h as ChildHandle, i as RuntimeProcess, j as RuntimeSocketPeer, k as RuntimeConnection } from './vfs-DzEcPbMY.cjs';
4
+ export { D as DirEntry, l as ROOT_CRED, m as RuntimeProcessManager, n as RuntimeProcessResult, o as Stats, p as VirtualNode, q as VirtualProvider, W as WriteOptions, r as applyChmod, s as createChildProcessModule, t as formatMode, u as makeCred, v as octalMode, w as parseUmask } from './vfs-DzEcPbMY.cjs';
5
+ import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-DCzGZFJb.cjs';
3
6
  import EventEmitter from 'events/events.js';
4
7
  import streamModule from 'stream-browserify';
5
8
 
@@ -419,69 +422,6 @@ declare const NODE_VERSION = "v22.12.0";
419
422
 
420
423
  declare const NPM_VERSION = "10.9.0";
421
424
 
422
- type NodeKind = "file" | "directory" | "symlink";
423
- interface MemoryVolumeSnapshotEntry {
424
- path: string;
425
- ino: number;
426
- kind: NodeKind;
427
- mode: number;
428
- uid: number;
429
- gid: number;
430
- nlink: number;
431
- data: number[];
432
- target: string;
433
- atimeMs: number;
434
- mtimeMs: number;
435
- ctimeMs: number;
436
- birthtimeMs: number;
437
- }
438
- /** Browser-safe, synchronous in-memory filesystem used by the new runtime. */
439
- declare class MemoryVolume implements RuntimeVolume {
440
- private readonly entries;
441
- private nextIno;
442
- constructor();
443
- readFileSync(path: string): Uint8Array;
444
- writeFileSync(path: string, data: string | Uint8Array): void;
445
- appendFileSync(path: string, data: string | Uint8Array): void;
446
- readdirSync(path: string): string[];
447
- lstatSync(path: string): VolumeStat;
448
- readlinkSync(path: string): string;
449
- mkdirSync(path: string, options?: {
450
- mode?: number;
451
- }): void;
452
- rmdirSync(path: string): void;
453
- unlinkSync(path: string): void;
454
- renameSync(from: string, to: string): void;
455
- symlinkSync(target: string, path: string): void;
456
- linkSync(existing: string, path: string): void;
457
- truncateSync(path: string, length?: number): void;
458
- chmodSync(path: string, mode: number): void;
459
- lchmodSync(path: string, mode: number): void;
460
- chownSync(path: string, uid: number, gid: number): void;
461
- lchownSync(path: string, uid: number, gid: number): void;
462
- utimesSync(path: string, atime: Date, mtime: Date): void;
463
- getStats(): VolumeStats;
464
- snapshot(): MemoryVolumeSnapshotEntry[];
465
- restore(snapshot: MemoryVolumeSnapshotEntry[]): void;
466
- /** Serializable representation used by RuntimePod snapshots. */
467
- export(): Array<{
468
- path: string;
469
- kind: NodeKind;
470
- mode: number;
471
- uid: number;
472
- gid: number;
473
- data?: number[];
474
- target?: string;
475
- }>;
476
- private setMode;
477
- private setOwner;
478
- private key;
479
- private required;
480
- private requireParent;
481
- private inode;
482
- private touchChanged;
483
- }
484
-
485
425
  /**
486
426
  * How a specifier was requested. Node resolves the same package differently
487
427
  * for the two, and a dual package depends on that: `is-promise` exports a
@@ -993,6 +933,10 @@ declare class MirroringVolume implements RuntimeVolume {
993
933
  readFileSync(path: string): Uint8Array;
994
934
  readdirSync(path: string): string[];
995
935
  lstatSync(path: string): VolumeStat;
936
+ /** The mirror's copy of a file, if it has one and we are allowed to look. */
937
+ private fromMirror;
938
+ /** The mirror's entries for a directory, for merging into a listing. */
939
+ private mirrorNames;
996
940
  readlinkSync(path: string): string;
997
941
  getStats(): VolumeStats;
998
942
  writeFileSync(path: string, data: string | Uint8Array): void;
@@ -1002,7 +946,35 @@ declare class MirroringVolume implements RuntimeVolume {
1002
946
  }): void;
1003
947
  rmdirSync(path: string): void;
1004
948
  unlinkSync(path: string): void;
949
+ /**
950
+ * Rename, carrying anything the mirrored engine put there.
951
+ *
952
+ * This is the operation the dependency optimizer is built on, and the one
953
+ * that used to destroy its output. Vite bundles into a temporary directory
954
+ * and renames it into place when it is complete — but only half of that
955
+ * directory is ever on this volume. Vite writes `_metadata.json` and
956
+ * `package.json` through here; Rolldown writes the actual bundles through
957
+ * WASI into the mirror. Renaming moved the half that was here and then
958
+ * `sync(from)` deleted the half that was not, because from this side the
959
+ * source directory had simply gone.
960
+ *
961
+ * What survived was a `deps` directory holding metadata that described five
962
+ * optimized dependencies and contained none of them — which Vite reports, on
963
+ * the failed read, as `504 Outdated Optimize Dep`. Nothing in that message is
964
+ * true, and following it leads to hashes rather than to a missing file.
965
+ *
966
+ * So the mirror's side of the move is collected first, and lands here as
967
+ * part of the rename.
968
+ */
1005
969
  renameSync(from: string, to: string): void;
970
+ /**
971
+ * Copy whatever the mirror holds under `from` into this volume under `to`.
972
+ *
973
+ * Deliberately not filtered the way {@link absorb} is: this walks one
974
+ * directory that is being renamed, not the whole project, so the subtree is
975
+ * small and `node_modules` is exactly where the interesting case lives.
976
+ */
977
+ private collect;
1006
978
  symlinkSync(target: string, path: string): void;
1007
979
  linkSync(existing: string, path: string): void;
1008
980
  truncateSync(path: string, length?: number): void;
@@ -1059,6 +1031,21 @@ declare class LocalRuntimePod implements RuntimePod {
1059
1031
  readonly proxy: {
1060
1032
  activePorts: (_instanceId?: string) => number[];
1061
1033
  };
1034
+ /**
1035
+ * Bind a port to a server that is not a JavaScript one.
1036
+ *
1037
+ * The request is flattened to bytes and headers before it crosses the
1038
+ * boundary, because the far side is a different language and a Node stream
1039
+ * object cannot go there. What comes back is a complete response; streaming
1040
+ * is a later protocol, and pretending to stream over a buffered path would
1041
+ * only move the surprise.
1042
+ */
1043
+ serveExternal(port: number, owner: string, handler: (request: {
1044
+ method: string;
1045
+ path: string;
1046
+ headers: Record<string, string>;
1047
+ body: Uint8Array;
1048
+ }) => Promise<RuntimeHttpResponse>): () => void;
1062
1049
  /**
1063
1050
  * Mutable on purpose: a container replaces `spawn` so that children resolve
1064
1051
  * against the kernel's PATH. Left alone, it runs `node` and reports anything
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
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, o as RuntimeSocketPeer, p as RuntimeConnection, E as ExecContext, O as OutputStream, C as Container, q as createContainer } from './container-DyRF-bY0.js';
2
- export { B as BufferSink, r as CPythonOptions, s as CallbackSink, t as CommandRegistry, u as ContainerFs, v as ContainerOptions, w as ContextInit, D as DirEntry, x as Env, y as ExecOptions, z as ExecResult, F as FileData, A as FileInput, G as FileOutput, H as GroupEntry, I as HttpResponse, J as InputStream, L as Job, M as KernelOptions, P as ListeningPort, Q as MountEntry, T as NetInterface, U as NetworkOptions, W as NetworkStack, X as NullInput, Y as NullOutput, Z as PYTHON_VERSION, _ as PasswdEntry, $ as Pipe, a0 as Process, a1 as ProcessKind, a2 as ProcessOptions, a3 as ProcessState, a4 as ProcessTable, a5 as PythonOptions, a6 as ROOT_CRED, a7 as ResolvedExecutable, a8 as RunOptions, a9 as RunResult, aa as RuntimeProcessManager, ab as RuntimeProcessResult, ac as SessionInit, ad as SessionResult, ae as SessionRunOptions, af as ShellExit, ag as ShellInit, ah as ShellOptions, ai as SpawnHandle, aj as Stats, ak as Stdio, al as TeeOutput, am as UserDatabase, an as Variables, ao as VirtualNode, ap as VirtualProvider, aq as WriteOptions, ar as applyChmod, as as braceExpand, at as captureStdio, au as configureCPython, av as configurePython, aw as createChildProcessModule, ax as createContext, ay as defineCommand, az as expandWord, aA as expandWords, aB as formatMode, aC as isCPythonAvailable, aD as isPythonAvailable, aE as makeCred, aF as octalMode, aG as parseUmask, aH as resetPidCounter, aI as shellQuote } from './container-DyRF-bY0.js';
1
+ import { S as Shell, a as ShellIO, b as Session, N as Node, c as Command, K as Kernel, E as ExecContext, O as OutputStream, C as Container, d as createContainer } from './container-DBMPLbUu.js';
2
+ export { B as BufferSink, e as CPythonOptions, f as CallbackSink, g as CommandRegistry, h as ContainerFs, i as ContainerOptions, j as ContextInit, k as Env, l as ExecOptions, m as ExecResult, F as FileData, n as FileInput, o as FileOutput, G as GroupEntry, H as HttpResponse, I as InputStream, J as Job, p as KernelOptions, L as ListeningPort, M as MANIFEST_FORMAT, q as MANIFEST_SCHEMA_VERSION, r as MountEntry, s as NetInterface, t as NetworkOptions, u as NetworkStack, v as NullInput, w as NullOutput, P as PYTHON_VERSION, x as PasswdEntry, y as Pipe, z as Process, A as ProcessKind, D as ProcessOptions, Q as ProcessState, R as ProcessTable, T as PythonCapabilities, U as PythonOptions, V as PythonProfile, W as PythonRuntimeManifest, X as ResolvedExecutable, Y as RunOptions, Z as RunResult, _ as SessionInit, $ as SessionResult, a0 as SessionRunOptions, a1 as ShellExit, a2 as ShellInit, a3 as ShellOptions, a4 as SpawnHandle, a5 as Stdio, a6 as TeeOutput, a7 as UserDatabase, a8 as Variables, a9 as braceExpand, aa as captureStdio, ab as configureCPython, ac as configurePython, ad as createContext, ae as defineCommand, af as expandWord, ag as expandWords, ah as isCPythonAvailable, ai as isPythonAvailable, aj as resetPidCounter, ak as shellQuote, al as validateManifest } from './container-DBMPLbUu.js';
3
+ import { V as Vfs, C as Cred, R as RuntimeVolume, a as RuntimeHttpResponse, S as SpawnChild, b as SyncSpawn, c as VolumeStat, d as VolumeStats, e as RuntimePod, f as RuntimePackageInstaller, g as ChildSpawnConfig, h as ChildHandle, i as RuntimeProcess, j as RuntimeSocketPeer, k as RuntimeConnection } from './vfs-DzEcPbMY.js';
4
+ export { D as DirEntry, l as ROOT_CRED, m as RuntimeProcessManager, n as RuntimeProcessResult, o as Stats, p as VirtualNode, q as VirtualProvider, W as WriteOptions, r as applyChmod, s as createChildProcessModule, t as formatMode, u as makeCred, v as octalMode, w as parseUmask } from './vfs-DzEcPbMY.js';
5
+ import { M as MemoryVolume, a as MemoryVolumeSnapshotEntry } from './memory-volume-CTOXNJ6n.js';
3
6
  import EventEmitter from 'events/events.js';
4
7
  import streamModule from 'stream-browserify';
5
8
 
@@ -419,69 +422,6 @@ declare const NODE_VERSION = "v22.12.0";
419
422
 
420
423
  declare const NPM_VERSION = "10.9.0";
421
424
 
422
- type NodeKind = "file" | "directory" | "symlink";
423
- interface MemoryVolumeSnapshotEntry {
424
- path: string;
425
- ino: number;
426
- kind: NodeKind;
427
- mode: number;
428
- uid: number;
429
- gid: number;
430
- nlink: number;
431
- data: number[];
432
- target: string;
433
- atimeMs: number;
434
- mtimeMs: number;
435
- ctimeMs: number;
436
- birthtimeMs: number;
437
- }
438
- /** Browser-safe, synchronous in-memory filesystem used by the new runtime. */
439
- declare class MemoryVolume implements RuntimeVolume {
440
- private readonly entries;
441
- private nextIno;
442
- constructor();
443
- readFileSync(path: string): Uint8Array;
444
- writeFileSync(path: string, data: string | Uint8Array): void;
445
- appendFileSync(path: string, data: string | Uint8Array): void;
446
- readdirSync(path: string): string[];
447
- lstatSync(path: string): VolumeStat;
448
- readlinkSync(path: string): string;
449
- mkdirSync(path: string, options?: {
450
- mode?: number;
451
- }): void;
452
- rmdirSync(path: string): void;
453
- unlinkSync(path: string): void;
454
- renameSync(from: string, to: string): void;
455
- symlinkSync(target: string, path: string): void;
456
- linkSync(existing: string, path: string): void;
457
- truncateSync(path: string, length?: number): void;
458
- chmodSync(path: string, mode: number): void;
459
- lchmodSync(path: string, mode: number): void;
460
- chownSync(path: string, uid: number, gid: number): void;
461
- lchownSync(path: string, uid: number, gid: number): void;
462
- utimesSync(path: string, atime: Date, mtime: Date): void;
463
- getStats(): VolumeStats;
464
- snapshot(): MemoryVolumeSnapshotEntry[];
465
- restore(snapshot: MemoryVolumeSnapshotEntry[]): void;
466
- /** Serializable representation used by RuntimePod snapshots. */
467
- export(): Array<{
468
- path: string;
469
- kind: NodeKind;
470
- mode: number;
471
- uid: number;
472
- gid: number;
473
- data?: number[];
474
- target?: string;
475
- }>;
476
- private setMode;
477
- private setOwner;
478
- private key;
479
- private required;
480
- private requireParent;
481
- private inode;
482
- private touchChanged;
483
- }
484
-
485
425
  /**
486
426
  * How a specifier was requested. Node resolves the same package differently
487
427
  * for the two, and a dual package depends on that: `is-promise` exports a
@@ -993,6 +933,10 @@ declare class MirroringVolume implements RuntimeVolume {
993
933
  readFileSync(path: string): Uint8Array;
994
934
  readdirSync(path: string): string[];
995
935
  lstatSync(path: string): VolumeStat;
936
+ /** The mirror's copy of a file, if it has one and we are allowed to look. */
937
+ private fromMirror;
938
+ /** The mirror's entries for a directory, for merging into a listing. */
939
+ private mirrorNames;
996
940
  readlinkSync(path: string): string;
997
941
  getStats(): VolumeStats;
998
942
  writeFileSync(path: string, data: string | Uint8Array): void;
@@ -1002,7 +946,35 @@ declare class MirroringVolume implements RuntimeVolume {
1002
946
  }): void;
1003
947
  rmdirSync(path: string): void;
1004
948
  unlinkSync(path: string): void;
949
+ /**
950
+ * Rename, carrying anything the mirrored engine put there.
951
+ *
952
+ * This is the operation the dependency optimizer is built on, and the one
953
+ * that used to destroy its output. Vite bundles into a temporary directory
954
+ * and renames it into place when it is complete — but only half of that
955
+ * directory is ever on this volume. Vite writes `_metadata.json` and
956
+ * `package.json` through here; Rolldown writes the actual bundles through
957
+ * WASI into the mirror. Renaming moved the half that was here and then
958
+ * `sync(from)` deleted the half that was not, because from this side the
959
+ * source directory had simply gone.
960
+ *
961
+ * What survived was a `deps` directory holding metadata that described five
962
+ * optimized dependencies and contained none of them — which Vite reports, on
963
+ * the failed read, as `504 Outdated Optimize Dep`. Nothing in that message is
964
+ * true, and following it leads to hashes rather than to a missing file.
965
+ *
966
+ * So the mirror's side of the move is collected first, and lands here as
967
+ * part of the rename.
968
+ */
1005
969
  renameSync(from: string, to: string): void;
970
+ /**
971
+ * Copy whatever the mirror holds under `from` into this volume under `to`.
972
+ *
973
+ * Deliberately not filtered the way {@link absorb} is: this walks one
974
+ * directory that is being renamed, not the whole project, so the subtree is
975
+ * small and `node_modules` is exactly where the interesting case lives.
976
+ */
977
+ private collect;
1006
978
  symlinkSync(target: string, path: string): void;
1007
979
  linkSync(existing: string, path: string): void;
1008
980
  truncateSync(path: string, length?: number): void;
@@ -1059,6 +1031,21 @@ declare class LocalRuntimePod implements RuntimePod {
1059
1031
  readonly proxy: {
1060
1032
  activePorts: (_instanceId?: string) => number[];
1061
1033
  };
1034
+ /**
1035
+ * Bind a port to a server that is not a JavaScript one.
1036
+ *
1037
+ * The request is flattened to bytes and headers before it crosses the
1038
+ * boundary, because the far side is a different language and a Node stream
1039
+ * object cannot go there. What comes back is a complete response; streaming
1040
+ * is a later protocol, and pretending to stream over a buffered path would
1041
+ * only move the surprise.
1042
+ */
1043
+ serveExternal(port: number, owner: string, handler: (request: {
1044
+ method: string;
1045
+ path: string;
1046
+ headers: Record<string, string>;
1047
+ body: Uint8Array;
1048
+ }) => Promise<RuntimeHttpResponse>): () => void;
1062
1049
  /**
1063
1050
  * Mutable on purpose: a container replaces `spawn` so that children resolve
1064
1051
  * against the kernel's PATH. Left alone, it runs `node` and reports anything