@scelar/nodepod 1.0.1 → 1.0.2
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/__tests__/smoke.test.d.ts +1 -0
- package/dist/constants/cdn-urls.d.ts +12 -0
- package/dist/constants/config.d.ts +121 -0
- package/dist/cross-origin.d.ts +5 -0
- package/dist/engine-factory.d.ts +24 -0
- package/dist/engine-types.d.ts +40 -0
- package/dist/helpers/byte-encoding.d.ts +4 -0
- package/dist/helpers/digest.d.ts +1 -0
- package/dist/helpers/event-loop.d.ts +12 -0
- package/dist/helpers/wasm-cache.d.ts +6 -0
- package/dist/iframe-sandbox.d.ts +25 -0
- package/dist/index.d.ts +86 -0
- package/dist/isolation-helpers.d.ts +13 -0
- package/dist/memory-volume.d.ts +147 -0
- package/dist/module-transformer.d.ts +6 -0
- package/dist/packages/archive-extractor.d.ts +28 -0
- package/dist/packages/browser-bundler.d.ts +14 -0
- package/dist/packages/installer.d.ts +41 -0
- package/dist/packages/registry-client.d.ts +46 -0
- package/dist/packages/version-resolver.d.ts +37 -0
- package/dist/polyfills/assert.d.ts +54 -0
- package/dist/polyfills/async_hooks.d.ts +46 -0
- package/dist/polyfills/buffer.d.ts +111 -0
- package/dist/polyfills/child_process.d.ts +141 -0
- package/dist/polyfills/chokidar.d.ts +63 -0
- package/dist/polyfills/cluster.d.ts +55 -0
- package/dist/polyfills/console.d.ts +72 -0
- package/dist/polyfills/constants.d.ts +207 -0
- package/dist/polyfills/crypto.d.ts +189 -0
- package/dist/polyfills/dgram.d.ts +37 -0
- package/dist/polyfills/diagnostics_channel.d.ts +27 -0
- package/dist/polyfills/dns.d.ts +76 -0
- package/dist/polyfills/domain.d.ts +27 -0
- package/dist/polyfills/esbuild.d.ts +106 -0
- package/dist/polyfills/events.d.ts +39 -0
- package/dist/polyfills/fs.d.ts +274 -0
- package/dist/polyfills/fsevents.d.ts +62 -0
- package/dist/polyfills/http.d.ts +215 -0
- package/dist/polyfills/http2.d.ts +119 -0
- package/dist/polyfills/https.d.ts +24 -0
- package/dist/polyfills/inspector.d.ts +29 -0
- package/dist/polyfills/lightningcss.d.ts +70 -0
- package/dist/polyfills/module.d.ts +35 -0
- package/dist/polyfills/net.d.ts +91 -0
- package/dist/polyfills/os.d.ts +240 -0
- package/dist/polyfills/path.d.ts +95 -0
- package/dist/polyfills/perf_hooks.d.ts +48 -0
- package/dist/polyfills/process.d.ts +190 -0
- package/dist/polyfills/punycode.d.ts +21 -0
- package/dist/polyfills/querystring.d.ts +18 -0
- package/dist/polyfills/quic.d.ts +42 -0
- package/dist/polyfills/readdirp.d.ts +48 -0
- package/dist/polyfills/readline.d.ts +87 -0
- package/dist/polyfills/repl.d.ts +45 -0
- package/dist/polyfills/rollup.d.ts +37 -0
- package/dist/polyfills/sea.d.ts +11 -0
- package/dist/polyfills/sqlite.d.ts +30 -0
- package/dist/polyfills/stream.d.ts +160 -0
- package/dist/polyfills/string_decoder.d.ts +16 -0
- package/dist/polyfills/tailwindcss-oxide.d.ts +42 -0
- package/dist/polyfills/test.d.ts +60 -0
- package/dist/polyfills/timers.d.ts +23 -0
- package/dist/polyfills/tls.d.ts +61 -0
- package/dist/polyfills/trace_events.d.ts +22 -0
- package/dist/polyfills/tty.d.ts +38 -0
- package/dist/polyfills/url.d.ts +55 -0
- package/dist/polyfills/util.d.ts +135 -0
- package/dist/polyfills/v8.d.ts +97 -0
- package/dist/polyfills/vm.d.ts +66 -0
- package/dist/polyfills/volume-registry.d.ts +3 -0
- package/dist/polyfills/wasi.d.ts +16 -0
- package/dist/polyfills/worker_threads.d.ts +111 -0
- package/dist/polyfills/ws.d.ts +92 -0
- package/dist/polyfills/zlib.d.ts +278 -0
- package/dist/request-proxy.d.ts +63 -0
- package/dist/script-engine.d.ts +79 -0
- package/dist/sdk/nodepod-fs.d.ts +27 -0
- package/dist/sdk/nodepod-process.d.ts +28 -0
- package/dist/sdk/nodepod-terminal.d.ts +48 -0
- package/dist/sdk/nodepod.d.ts +39 -0
- package/dist/sdk/types.d.ts +53 -0
- package/dist/shell/commands/bun.d.ts +4 -0
- package/dist/shell/commands/directory.d.ts +2 -0
- package/dist/shell/commands/file-ops.d.ts +2 -0
- package/dist/shell/commands/git.d.ts +2 -0
- package/dist/shell/commands/node.d.ts +4 -0
- package/dist/shell/commands/npm.d.ts +3 -0
- package/dist/shell/commands/pm-types.d.ts +25 -0
- package/dist/shell/commands/pnpm.d.ts +3 -0
- package/dist/shell/commands/search.d.ts +2 -0
- package/dist/shell/commands/shell-env.d.ts +3 -0
- package/dist/shell/commands/text-processing.d.ts +2 -0
- package/dist/shell/commands/yarn.d.ts +3 -0
- package/dist/shell/shell-builtins.d.ts +2 -0
- package/dist/shell/shell-helpers.d.ts +28 -0
- package/dist/shell/shell-interpreter.d.ts +48 -0
- package/dist/shell/shell-parser.d.ts +6 -0
- package/dist/shell/shell-types.d.ts +48 -0
- package/dist/syntax-transforms.d.ts +3 -0
- package/dist/threading/engine-worker.d.ts +1 -0
- package/dist/threading/inline-worker.d.ts +2 -0
- package/dist/threading/offload-types.d.ts +87 -0
- package/dist/threading/offload-worker.d.ts +1 -0
- package/dist/threading/offload.d.ts +16 -0
- package/dist/threading/process-context.d.ts +40 -0
- package/dist/threading/process-handle.d.ts +42 -0
- package/dist/threading/process-manager.d.ts +52 -0
- package/dist/threading/process-worker-entry.d.ts +24 -0
- package/dist/threading/shared-vfs.d.ts +36 -0
- package/dist/threading/sync-channel.d.ts +21 -0
- package/dist/threading/task-queue.d.ts +15 -0
- package/dist/threading/vfs-bridge.d.ts +25 -0
- package/dist/threading/worker-pool.d.ts +38 -0
- package/dist/threading/worker-protocol.d.ts +264 -0
- package/dist/threading/worker-vfs.d.ts +34 -0
- package/dist/types/fs-streams.d.ts +122 -0
- package/dist/types/manifest.d.ts +17 -0
- package/dist/worker-sandbox.d.ts +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const PINNED_ESBUILD_WASM = "0.20.0";
|
|
2
|
+
export declare const PINNED_ROLLUP_BROWSER = "4.9.0";
|
|
3
|
+
export declare const PINNED_BROTLI_WASM = "3.0.1";
|
|
4
|
+
export declare const PINNED_LIGHTNINGCSS_WASM = "1.31.1";
|
|
5
|
+
export declare const CDN_ESBUILD_ESM = "https://esm.sh/esbuild-wasm@0.20.0";
|
|
6
|
+
export declare const CDN_ESBUILD_BINARY = "https://esm.sh/esbuild-wasm@0.20.0/esbuild.wasm";
|
|
7
|
+
export declare const CDN_ESBUILD_BROWSER = "https://esm.sh/esbuild-wasm@0.20.0/esm/browser.min.js";
|
|
8
|
+
export declare const CDN_ROLLUP_BROWSER = "https://esm.sh/@rollup/browser@4.9.0";
|
|
9
|
+
export declare const CDN_BROTLI_WASM = "https://esm.sh/brotli-wasm@3.0.1";
|
|
10
|
+
export declare const CDN_LIGHTNINGCSS_WASM = "https://esm.sh/lightningcss-wasm@1.31.1";
|
|
11
|
+
declare const _dynamicImport: (url: string) => Promise<any>;
|
|
12
|
+
export { _dynamicImport as cdnImport };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export declare const VERSIONS: {
|
|
2
|
+
readonly NODE: "v22.12.0";
|
|
3
|
+
readonly NODE_BARE: "22.12.0";
|
|
4
|
+
readonly NPM: "10.0.0";
|
|
5
|
+
readonly PNPM: "9.15.4";
|
|
6
|
+
readonly YARN: "4.6.0";
|
|
7
|
+
readonly BUN: "1.1.38";
|
|
8
|
+
readonly BUN_V: "v1.1.38";
|
|
9
|
+
readonly GIT: "2.43.0";
|
|
10
|
+
};
|
|
11
|
+
export declare const NODE_SUB_VERSIONS: {
|
|
12
|
+
readonly node: "22.12.0";
|
|
13
|
+
readonly v8: "11.3.244.8";
|
|
14
|
+
readonly uv: "1.44.2";
|
|
15
|
+
readonly modules: "115";
|
|
16
|
+
readonly openssl: "3.0.13";
|
|
17
|
+
readonly napi: "9";
|
|
18
|
+
readonly webcontainer: "1.0.0";
|
|
19
|
+
};
|
|
20
|
+
export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org";
|
|
21
|
+
export declare const NPM_REGISTRY_URL_SLASH = "https://registry.npmjs.org/";
|
|
22
|
+
export declare const PINNED_PAKO = "2.1.0";
|
|
23
|
+
export declare const CDN_PAKO = "https://esm.sh/pako@2.1.0";
|
|
24
|
+
export declare const RESOLVE_EXTENSIONS: readonly [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs", ".json"];
|
|
25
|
+
export declare const MAIN_FIELD_EXTENSIONS: readonly [".js", ".ts", ".tsx", ".mts", ".jsx", ".json", ".mjs", ".cjs"];
|
|
26
|
+
export declare const INDEX_FILES: readonly ["index.js", "index.ts", "index.tsx", "index.mjs", "index.cjs"];
|
|
27
|
+
export declare const IMPORTS_FIELD_EXTENSIONS: readonly [".js", ".ts", ".cjs", ".mjs", ".json"];
|
|
28
|
+
export declare const ESBUILD_LOADER_MAP: Record<string, string>;
|
|
29
|
+
export declare const MOCK_OS: {
|
|
30
|
+
readonly PLATFORM: "linux";
|
|
31
|
+
readonly ARCH: "x64";
|
|
32
|
+
readonly TYPE: "Linux";
|
|
33
|
+
readonly RELEASE: "5.10.0";
|
|
34
|
+
readonly VERSION: "#1 SMP";
|
|
35
|
+
readonly MACHINE: "x86_64";
|
|
36
|
+
readonly HOSTNAME: "localhost";
|
|
37
|
+
readonly HOMEDIR: "/home/user";
|
|
38
|
+
readonly TMPDIR: "/tmp";
|
|
39
|
+
readonly SHELL: "/bin/bash";
|
|
40
|
+
readonly USERNAME: "user";
|
|
41
|
+
readonly ENDIANNESS: "LE";
|
|
42
|
+
};
|
|
43
|
+
export declare const MOCK_IDS: {
|
|
44
|
+
readonly UID: 1000;
|
|
45
|
+
readonly GID: 1000;
|
|
46
|
+
};
|
|
47
|
+
export declare const MOCK_FS: {
|
|
48
|
+
readonly BLOCK_SIZE: 4096;
|
|
49
|
+
readonly BLOCK_CALC_SIZE: 512;
|
|
50
|
+
};
|
|
51
|
+
export declare const MOCK_CPU: {
|
|
52
|
+
readonly MODEL: "Virtual CPU";
|
|
53
|
+
readonly SPEED: 2400;
|
|
54
|
+
readonly COUNT: 2;
|
|
55
|
+
};
|
|
56
|
+
export declare const MOCK_MEMORY: {
|
|
57
|
+
readonly TOTAL: number;
|
|
58
|
+
readonly FREE: number;
|
|
59
|
+
readonly RSS: number;
|
|
60
|
+
readonly HEAP_TOTAL: number;
|
|
61
|
+
readonly HEAP_USED: number;
|
|
62
|
+
readonly EXTERNAL: number;
|
|
63
|
+
};
|
|
64
|
+
export declare const MOCK_LOADAVG: readonly [number, number, number];
|
|
65
|
+
export declare const DEFAULT_TERMINAL: {
|
|
66
|
+
readonly COLUMNS: 80;
|
|
67
|
+
readonly ROWS: 24;
|
|
68
|
+
readonly FONT_SIZE: 13;
|
|
69
|
+
};
|
|
70
|
+
export declare const MOCK_PROCESS: {
|
|
71
|
+
readonly PID: 1;
|
|
72
|
+
readonly PPID: 0;
|
|
73
|
+
readonly TITLE: "node";
|
|
74
|
+
readonly EXEC_PATH: "/usr/local/bin/node";
|
|
75
|
+
};
|
|
76
|
+
export declare const DEFAULT_ENV: {
|
|
77
|
+
readonly NODE_ENV: "development";
|
|
78
|
+
readonly PATH: "/usr/local/bin:/usr/bin:/bin";
|
|
79
|
+
readonly HOME: "/";
|
|
80
|
+
readonly SHELL: "/bin/sh";
|
|
81
|
+
readonly TERM: "xterm-256color";
|
|
82
|
+
readonly COLORTERM: "truecolor";
|
|
83
|
+
readonly REQUIRES_WASM: "true";
|
|
84
|
+
readonly npm_config_user_agent: "npm/10.0.0 node/v22.12.0 linux x64 workspaces/false";
|
|
85
|
+
readonly npm_execpath: "/usr/local/lib/node_modules/npm/bin/npm-cli.js";
|
|
86
|
+
readonly npm_node_execpath: "/usr/local/bin/node";
|
|
87
|
+
};
|
|
88
|
+
export declare const TIMEOUTS: {
|
|
89
|
+
readonly SYNC_OP: 120000;
|
|
90
|
+
readonly WAIT_LOOP_TICK: 200;
|
|
91
|
+
readonly SW_HEARTBEAT: 20000;
|
|
92
|
+
readonly WORKER_REAP_INTERVAL: 10000;
|
|
93
|
+
readonly WORKER_IDLE_TIMEOUT: 30000;
|
|
94
|
+
readonly WORKER_INIT_TIMEOUT: 30000;
|
|
95
|
+
readonly HTTP_KEEP_ALIVE: 5000;
|
|
96
|
+
readonly HTTP_HEADERS: 60000;
|
|
97
|
+
readonly HTTP_DISPATCH_SAFETY: 120000;
|
|
98
|
+
};
|
|
99
|
+
export declare const LIMITS: {
|
|
100
|
+
readonly MAX_RESOLVE_DEPTH: 50;
|
|
101
|
+
readonly MODULE_CACHE_MAX: 2000;
|
|
102
|
+
readonly MAX_WORKERS_CAP: 6;
|
|
103
|
+
};
|
|
104
|
+
export declare const PORT_RANGE: {
|
|
105
|
+
readonly BASE: 3000;
|
|
106
|
+
readonly RANGE: 1000;
|
|
107
|
+
};
|
|
108
|
+
export declare const DEFAULT_NODEPOD_CDN = "https://unpkg.com/@scelar/nodepod/dist/index.js";
|
|
109
|
+
export declare const MOCK_PID: {
|
|
110
|
+
readonly BASE: 1000;
|
|
111
|
+
readonly RANGE: 10000;
|
|
112
|
+
};
|
|
113
|
+
export declare const LS_BLOCK_SIZE = 512;
|
|
114
|
+
export declare const YES_REPEAT_COUNT = 100;
|
|
115
|
+
export declare const WS_OPCODE: {
|
|
116
|
+
readonly TEXT: 1;
|
|
117
|
+
readonly BINARY: 2;
|
|
118
|
+
readonly CLOSE: 8;
|
|
119
|
+
readonly PING: 9;
|
|
120
|
+
readonly PONG: 10;
|
|
121
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function setProxy(url: string | null): void;
|
|
2
|
+
export declare function getProxy(): string | null;
|
|
3
|
+
export declare function isProxyActive(): boolean;
|
|
4
|
+
export declare function proxiedFetch(url: string, init?: RequestInit): Promise<Response>;
|
|
5
|
+
export declare function resolveProxyUrl(url: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MemoryVolume } from './memory-volume';
|
|
2
|
+
import type { IScriptEngine, ExecutionOutcome, SpawnEngineConfig, EngineConfig } from './engine-types';
|
|
3
|
+
import { ProcessManager } from './threading/process-manager';
|
|
4
|
+
export declare function spawnEngine(vol: MemoryVolume, config?: SpawnEngineConfig): Promise<IScriptEngine>;
|
|
5
|
+
declare class ProcessWorkerAdapter implements IScriptEngine {
|
|
6
|
+
private _vol;
|
|
7
|
+
private _processManager;
|
|
8
|
+
private _vfsBridge;
|
|
9
|
+
private _cfg;
|
|
10
|
+
constructor(vol: MemoryVolume, cfg?: EngineConfig);
|
|
11
|
+
execute(code: string, filename?: string): Promise<ExecutionOutcome>;
|
|
12
|
+
runFile(filename: string): Promise<ExecutionOutcome>;
|
|
13
|
+
private _runInWorker;
|
|
14
|
+
clearCache(): void;
|
|
15
|
+
getVolume(): MemoryVolume;
|
|
16
|
+
getProcessManager(): ProcessManager;
|
|
17
|
+
teardown(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function spawnProcessWorkerEngine(vol: MemoryVolume, config?: EngineConfig): Promise<ProcessWorkerAdapter>;
|
|
20
|
+
export { ScriptEngine } from './script-engine';
|
|
21
|
+
export { WorkerSandbox } from './worker-sandbox';
|
|
22
|
+
export { IframeSandbox } from './iframe-sandbox';
|
|
23
|
+
export { ProcessWorkerAdapter };
|
|
24
|
+
export type { IScriptEngine, ExecutionOutcome, EngineConfig, SpawnEngineConfig, VolumeSnapshot } from './engine-types';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MemoryVolume } from './memory-volume';
|
|
2
|
+
export interface EngineConfig {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
env?: Record<string, string>;
|
|
5
|
+
onConsole?: (method: string, args: unknown[]) => void;
|
|
6
|
+
onStdout?: (data: string) => void;
|
|
7
|
+
onStderr?: (data: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface LoadedModule {
|
|
10
|
+
id: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
exports: unknown;
|
|
13
|
+
loaded: boolean;
|
|
14
|
+
children: LoadedModule[];
|
|
15
|
+
paths: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ExecutionOutcome {
|
|
18
|
+
exports: unknown;
|
|
19
|
+
module: LoadedModule;
|
|
20
|
+
}
|
|
21
|
+
export interface IScriptEngine {
|
|
22
|
+
execute(code: string, filename?: string): Promise<ExecutionOutcome>;
|
|
23
|
+
runFile(filename: string): Promise<ExecutionOutcome>;
|
|
24
|
+
clearCache(): void;
|
|
25
|
+
getVolume?(): MemoryVolume;
|
|
26
|
+
terminate?(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface SpawnEngineConfig extends EngineConfig {
|
|
29
|
+
sandboxUrl?: string;
|
|
30
|
+
allowUnsafeEval?: boolean;
|
|
31
|
+
useWorker?: boolean | 'auto';
|
|
32
|
+
}
|
|
33
|
+
export interface VolumeSnapshot {
|
|
34
|
+
entries: VolumeEntry[];
|
|
35
|
+
}
|
|
36
|
+
export interface VolumeEntry {
|
|
37
|
+
path: string;
|
|
38
|
+
kind: 'file' | 'directory';
|
|
39
|
+
data?: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function quickDigest(input: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProcessContext } from "../threading/process-context";
|
|
2
|
+
export declare function addDrainListener(cb: () => void): () => void;
|
|
3
|
+
export declare function notifyDrain(): void;
|
|
4
|
+
export declare function ref(): void;
|
|
5
|
+
export declare function unref(): void;
|
|
6
|
+
export declare function getRefCount(): number;
|
|
7
|
+
export declare function setRefCount(n: number): void;
|
|
8
|
+
export declare function resetRefCount(): void;
|
|
9
|
+
export declare function refCtx(ctx: ProcessContext): void;
|
|
10
|
+
export declare function unrefCtx(ctx: ProcessContext): void;
|
|
11
|
+
export declare function getRefCountCtx(ctx: ProcessContext): number;
|
|
12
|
+
export declare function addDrainListenerCtx(ctx: ProcessContext, cb: () => void): () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PRECOMPILE_THRESHOLD: number;
|
|
2
|
+
export declare function precompileWasm(bytes: Uint8Array | ArrayBuffer): void;
|
|
3
|
+
export declare function getCachedModule(bytes: BufferSource): WebAssembly.Module | null;
|
|
4
|
+
export declare function compileWasmInWorker(bytes: Uint8Array | ArrayBuffer): Promise<WebAssembly.Module>;
|
|
5
|
+
export declare function needsAsyncCompile(bytes: BufferSource): boolean;
|
|
6
|
+
export { PRECOMPILE_THRESHOLD };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MemoryVolume } from './memory-volume';
|
|
2
|
+
import type { IScriptEngine, ExecutionOutcome, EngineConfig } from './engine-types';
|
|
3
|
+
export declare class IframeSandbox implements IScriptEngine {
|
|
4
|
+
private frame;
|
|
5
|
+
private targetOrigin;
|
|
6
|
+
private vol;
|
|
7
|
+
private cfg;
|
|
8
|
+
private ready;
|
|
9
|
+
private pendingCalls;
|
|
10
|
+
private nextId;
|
|
11
|
+
private onFileChange;
|
|
12
|
+
private onFileDelete;
|
|
13
|
+
private onMessage;
|
|
14
|
+
constructor(sandboxUrl: string, vol: MemoryVolume, cfg?: EngineConfig);
|
|
15
|
+
private bindMessageHandler;
|
|
16
|
+
private awaitReady;
|
|
17
|
+
private sendInit;
|
|
18
|
+
private attachVolumeSync;
|
|
19
|
+
private dispatch;
|
|
20
|
+
execute(code: string, filename?: string): Promise<ExecutionOutcome>;
|
|
21
|
+
runFile(filename: string): Promise<ExecutionOutcome>;
|
|
22
|
+
clearCache(): void;
|
|
23
|
+
getVolume(): MemoryVolume;
|
|
24
|
+
terminate(): void;
|
|
25
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export { MemoryVolume } from "./memory-volume";
|
|
2
|
+
export type { VolumeNode, FileStat, FileWatchHandle, WatchCallback, WatchEventKind, SystemError, } from "./memory-volume";
|
|
3
|
+
export { ScriptEngine, executeCode } from "./script-engine";
|
|
4
|
+
export type { ModuleRecord, EngineOptions, ResolverFn } from "./script-engine";
|
|
5
|
+
export { spawnEngine, WorkerSandbox, IframeSandbox, spawnProcessWorkerEngine, ProcessWorkerAdapter } from "./engine-factory";
|
|
6
|
+
export type { IScriptEngine, ExecutionOutcome, SpawnEngineConfig, EngineConfig, VolumeSnapshot, } from "./engine-types";
|
|
7
|
+
export { generateSandboxDeployment, getSandboxPageHtml, getSandboxHostingConfig, SANDBOX_DEPLOYMENT_GUIDE, } from "./isolation-helpers";
|
|
8
|
+
export { buildFileSystemBridge } from "./polyfills/fs";
|
|
9
|
+
export type { FsBridge } from "./polyfills/fs";
|
|
10
|
+
export { buildProcessEnv } from "./polyfills/process";
|
|
11
|
+
export type { ProcessObject, ProcessEnvVars } from "./polyfills/process";
|
|
12
|
+
export * as path from "./polyfills/path";
|
|
13
|
+
export * as http from "./polyfills/http";
|
|
14
|
+
export * as net from "./polyfills/net";
|
|
15
|
+
export * as events from "./polyfills/events";
|
|
16
|
+
export * as stream from "./polyfills/stream";
|
|
17
|
+
export * as url from "./polyfills/url";
|
|
18
|
+
export * as querystring from "./polyfills/querystring";
|
|
19
|
+
export * as util from "./polyfills/util";
|
|
20
|
+
export * as npm from "./packages/installer";
|
|
21
|
+
export { DependencyInstaller, install } from "./packages/installer";
|
|
22
|
+
export { RequestProxy, getProxyInstance, resetProxy } from "./request-proxy";
|
|
23
|
+
export type { ProxyOptions, ServiceWorkerConfig } from "./request-proxy";
|
|
24
|
+
export * as chokidar from "./polyfills/chokidar";
|
|
25
|
+
export * as ws from "./polyfills/ws";
|
|
26
|
+
export * as fsevents from "./polyfills/fsevents";
|
|
27
|
+
export * as readdirp from "./polyfills/readdirp";
|
|
28
|
+
export * as module from "./polyfills/module";
|
|
29
|
+
export * as perf_hooks from "./polyfills/perf_hooks";
|
|
30
|
+
export * as worker_threads from "./polyfills/worker_threads";
|
|
31
|
+
export * as esbuild from "./polyfills/esbuild";
|
|
32
|
+
export * as rollup from "./polyfills/rollup";
|
|
33
|
+
export * as assert from "./polyfills/assert";
|
|
34
|
+
import { MemoryVolume } from "./memory-volume";
|
|
35
|
+
import { ScriptEngine, EngineOptions } from "./script-engine";
|
|
36
|
+
import { DependencyInstaller } from "./packages/installer";
|
|
37
|
+
import { RequestProxy } from "./request-proxy";
|
|
38
|
+
export interface CommandResult {
|
|
39
|
+
stdout: string;
|
|
40
|
+
stderr: string;
|
|
41
|
+
exitCode: number;
|
|
42
|
+
}
|
|
43
|
+
export interface CommandOptions {
|
|
44
|
+
cwd?: string;
|
|
45
|
+
onStdout?: (data: string) => void;
|
|
46
|
+
onStderr?: (data: string) => void;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}
|
|
49
|
+
export interface WorkspaceConfig extends EngineOptions {
|
|
50
|
+
baseUrl?: string;
|
|
51
|
+
onServerReady?: (port: number, url: string) => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function createWorkspace(config?: WorkspaceConfig): {
|
|
54
|
+
volume: MemoryVolume;
|
|
55
|
+
engine: ScriptEngine;
|
|
56
|
+
packages: DependencyInstaller;
|
|
57
|
+
proxy: RequestProxy;
|
|
58
|
+
execute: (code: string, filename?: string) => {
|
|
59
|
+
exports: unknown;
|
|
60
|
+
};
|
|
61
|
+
runFile: (filename: string) => {
|
|
62
|
+
exports: unknown;
|
|
63
|
+
};
|
|
64
|
+
run: (command: string, options?: CommandOptions) => Promise<CommandResult>;
|
|
65
|
+
sendInput: (data: string) => Promise<void>;
|
|
66
|
+
createREPL: () => {
|
|
67
|
+
eval: (code: string) => unknown;
|
|
68
|
+
};
|
|
69
|
+
on: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
70
|
+
};
|
|
71
|
+
export default createWorkspace;
|
|
72
|
+
export { Nodepod } from "./sdk/nodepod";
|
|
73
|
+
export { NodepodTerminal } from "./sdk/nodepod-terminal";
|
|
74
|
+
export { NodepodProcess } from "./sdk/nodepod-process";
|
|
75
|
+
export { NodepodFS } from "./sdk/nodepod-fs";
|
|
76
|
+
export type { NodepodOptions, TerminalOptions, TerminalTheme, StatResult, Snapshot, SpawnOptions, } from "./sdk/types";
|
|
77
|
+
export { ProcessManager } from "./threading/process-manager";
|
|
78
|
+
export { ProcessHandle } from "./threading/process-handle";
|
|
79
|
+
export type { ProcessState } from "./threading/process-handle";
|
|
80
|
+
export { VFSBridge } from "./threading/vfs-bridge";
|
|
81
|
+
export { WorkerVFS } from "./threading/worker-vfs";
|
|
82
|
+
export { SyncChannelController, SyncChannelWorker } from "./threading/sync-channel";
|
|
83
|
+
export { SharedVFSController, SharedVFSReader, isSharedArrayBufferAvailable } from "./threading/shared-vfs";
|
|
84
|
+
export { createProcessContext, getActiveContext, setActiveContext } from "./threading/process-context";
|
|
85
|
+
export type { ProcessContext, ProcessWriter, ProcessReader, OpenFileEntry } from "./threading/process-context";
|
|
86
|
+
export type { VFSBinarySnapshot, VFSSnapshotEntry, SpawnConfig, ProcessInfo, MainToWorkerMessage, WorkerToMainMessage, } from "./threading/worker-protocol";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SandboxPageConfig {
|
|
2
|
+
nodepodUrl?: string;
|
|
3
|
+
enableServiceWorker?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function getSandboxPageHtml(config?: SandboxPageConfig | string): string;
|
|
6
|
+
export declare function getSandboxHostingConfig(): object;
|
|
7
|
+
export interface GeneratedSandboxFiles {
|
|
8
|
+
'index.html': string;
|
|
9
|
+
'vercel.json': string;
|
|
10
|
+
'__sw__.js'?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function generateSandboxDeployment(config?: SandboxPageConfig | string): GeneratedSandboxFiles;
|
|
13
|
+
export declare const SANDBOX_DEPLOYMENT_GUIDE: string;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { VolumeSnapshot } from './engine-types';
|
|
2
|
+
export interface VolumeNode {
|
|
3
|
+
kind: 'file' | 'directory' | 'symlink';
|
|
4
|
+
content?: Uint8Array;
|
|
5
|
+
children?: Map<string, VolumeNode>;
|
|
6
|
+
target?: string;
|
|
7
|
+
modified: number;
|
|
8
|
+
}
|
|
9
|
+
type FileChangeHandler = (filePath: string, content: string) => void;
|
|
10
|
+
type FileDeleteHandler = (filePath: string) => void;
|
|
11
|
+
export interface FileStat {
|
|
12
|
+
isFile(): boolean;
|
|
13
|
+
isDirectory(): boolean;
|
|
14
|
+
isSymbolicLink(): boolean;
|
|
15
|
+
isBlockDevice(): boolean;
|
|
16
|
+
isCharacterDevice(): boolean;
|
|
17
|
+
isFIFO(): boolean;
|
|
18
|
+
isSocket(): boolean;
|
|
19
|
+
size: number;
|
|
20
|
+
mode: number;
|
|
21
|
+
mtime: Date;
|
|
22
|
+
atime: Date;
|
|
23
|
+
ctime: Date;
|
|
24
|
+
birthtime: Date;
|
|
25
|
+
mtimeMs: number;
|
|
26
|
+
atimeMs: number;
|
|
27
|
+
ctimeMs: number;
|
|
28
|
+
birthtimeMs: number;
|
|
29
|
+
nlink: number;
|
|
30
|
+
uid: number;
|
|
31
|
+
gid: number;
|
|
32
|
+
dev: number;
|
|
33
|
+
ino: number;
|
|
34
|
+
rdev: number;
|
|
35
|
+
blksize: number;
|
|
36
|
+
blocks: number;
|
|
37
|
+
atimeNs: bigint;
|
|
38
|
+
mtimeNs: bigint;
|
|
39
|
+
ctimeNs: bigint;
|
|
40
|
+
birthtimeNs: bigint;
|
|
41
|
+
}
|
|
42
|
+
export type WatchEventKind = 'change' | 'rename';
|
|
43
|
+
export type WatchCallback = (event: WatchEventKind, name: string | null) => void;
|
|
44
|
+
export interface FileWatchHandle {
|
|
45
|
+
close(): void;
|
|
46
|
+
ref(): this;
|
|
47
|
+
unref(): this;
|
|
48
|
+
on(event: string, listener: (...args: unknown[]) => void): this;
|
|
49
|
+
once(event: string, listener: (...args: unknown[]) => void): this;
|
|
50
|
+
removeListener(event: string, listener: (...args: unknown[]) => void): this;
|
|
51
|
+
off(event: string, listener: (...args: unknown[]) => void): this;
|
|
52
|
+
addListener(event: string, listener: (...args: unknown[]) => void): this;
|
|
53
|
+
removeAllListeners(event?: string): this;
|
|
54
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface SystemError extends Error {
|
|
57
|
+
code: string;
|
|
58
|
+
errno: number;
|
|
59
|
+
syscall: string;
|
|
60
|
+
path?: string;
|
|
61
|
+
}
|
|
62
|
+
export declare function makeSystemError(code: 'ENOENT' | 'ENOTDIR' | 'EISDIR' | 'EEXIST' | 'ENOTEMPTY', syscall: string, targetPath: string, detail?: string): SystemError;
|
|
63
|
+
export declare class MemoryVolume {
|
|
64
|
+
private tree;
|
|
65
|
+
private textEncoder;
|
|
66
|
+
private textDecoder;
|
|
67
|
+
private activeWatchers;
|
|
68
|
+
private subscribers;
|
|
69
|
+
constructor();
|
|
70
|
+
on(event: 'change', handler: FileChangeHandler): this;
|
|
71
|
+
on(event: 'delete', handler: FileDeleteHandler): this;
|
|
72
|
+
off(event: 'change', handler: FileChangeHandler): this;
|
|
73
|
+
off(event: 'delete', handler: FileDeleteHandler): this;
|
|
74
|
+
private broadcast;
|
|
75
|
+
toSnapshot(): VolumeSnapshot;
|
|
76
|
+
private collectEntries;
|
|
77
|
+
static fromBinarySnapshot(snapshot: {
|
|
78
|
+
manifest: Array<{
|
|
79
|
+
path: string;
|
|
80
|
+
offset: number;
|
|
81
|
+
length: number;
|
|
82
|
+
isDirectory: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
data: ArrayBuffer;
|
|
85
|
+
}): MemoryVolume;
|
|
86
|
+
static fromSnapshot(snapshot: VolumeSnapshot): MemoryVolume;
|
|
87
|
+
private normalize;
|
|
88
|
+
private segments;
|
|
89
|
+
private parentOf;
|
|
90
|
+
private nameOf;
|
|
91
|
+
private locateRaw;
|
|
92
|
+
private locate;
|
|
93
|
+
private ensureDir;
|
|
94
|
+
private writeInternal;
|
|
95
|
+
existsSync(p: string): boolean;
|
|
96
|
+
statSync(p: string): FileStat;
|
|
97
|
+
lstatSync(p: string): FileStat;
|
|
98
|
+
readFileSync(p: string): Uint8Array;
|
|
99
|
+
readFileSync(p: string, encoding: 'utf8' | 'utf-8'): string;
|
|
100
|
+
writeFileSync(p: string, data: string | Uint8Array): void;
|
|
101
|
+
mkdirSync(p: string, options?: {
|
|
102
|
+
recursive?: boolean;
|
|
103
|
+
}): void;
|
|
104
|
+
readdirSync(p: string): string[];
|
|
105
|
+
unlinkSync(p: string): void;
|
|
106
|
+
rmdirSync(p: string): void;
|
|
107
|
+
renameSync(from: string, to: string): void;
|
|
108
|
+
accessSync(p: string, _mode?: number): void;
|
|
109
|
+
copyFileSync(src: string, dest: string): void;
|
|
110
|
+
realpathSync(p: string): string;
|
|
111
|
+
symlinkSync(target: string, linkPath: string, _type?: string): void;
|
|
112
|
+
readlinkSync(p: string): string;
|
|
113
|
+
linkSync(existingPath: string, newPath: string): void;
|
|
114
|
+
chmodSync(_p: string, _mode: number): void;
|
|
115
|
+
chownSync(_p: string, _uid: number, _gid: number): void;
|
|
116
|
+
appendFileSync(p: string, data: string | Uint8Array): void;
|
|
117
|
+
truncateSync(p: string, len?: number): void;
|
|
118
|
+
readFile(p: string, optionsOrCb?: {
|
|
119
|
+
encoding?: string;
|
|
120
|
+
} | ((err: Error | null, data?: Uint8Array | string) => void), cb?: (err: Error | null, data?: Uint8Array | string) => void): void;
|
|
121
|
+
stat(p: string, cb?: (err: Error | null, stats?: FileStat) => void): void;
|
|
122
|
+
lstat(p: string, cb?: (err: Error | null, stats?: FileStat) => void): void;
|
|
123
|
+
readdir(p: string, optionsOrCb?: {
|
|
124
|
+
withFileTypes?: boolean;
|
|
125
|
+
} | ((err: Error | null, files?: string[]) => void), cb?: (err: Error | null, files?: string[]) => void): void;
|
|
126
|
+
realpath(p: string, cb?: (err: Error | null, resolved?: string) => void): void;
|
|
127
|
+
access(p: string, modeOrCb?: number | ((err: Error | null) => void), cb?: (err: Error | null) => void): void;
|
|
128
|
+
watch(target: string, optionsOrCb?: {
|
|
129
|
+
persistent?: boolean;
|
|
130
|
+
recursive?: boolean;
|
|
131
|
+
encoding?: string;
|
|
132
|
+
} | WatchCallback, cb?: WatchCallback): FileWatchHandle;
|
|
133
|
+
private triggerWatchers;
|
|
134
|
+
private globalChangeListeners;
|
|
135
|
+
onGlobalChange(cb: (path: string, event: string) => void): () => void;
|
|
136
|
+
private notifyGlobalListeners;
|
|
137
|
+
createReadStream(p: string): {
|
|
138
|
+
on: (event: string, cb: (...args: unknown[]) => void) => void;
|
|
139
|
+
pipe: (dest: unknown) => unknown;
|
|
140
|
+
};
|
|
141
|
+
createWriteStream(p: string): {
|
|
142
|
+
write: (data: string | Uint8Array) => boolean;
|
|
143
|
+
end: (data?: string | Uint8Array) => void;
|
|
144
|
+
on: (event: string, cb: (...args: unknown[]) => void) => void;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MemoryVolume } from "./memory-volume";
|
|
2
|
+
export declare function prepareTransformer(): Promise<void>;
|
|
3
|
+
export declare function isTransformerLoaded(): boolean;
|
|
4
|
+
export declare function convertFile(source: string, filePath: string): Promise<string>;
|
|
5
|
+
export declare function convertFileDirect(source: string, filePath: string): Promise<string>;
|
|
6
|
+
export declare function convertPackage(vol: MemoryVolume, packageDir: string, onProgress?: (msg: string) => void): Promise<number>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MemoryVolume } from "../memory-volume";
|
|
2
|
+
export interface ExtractionOptions {
|
|
3
|
+
stripComponents?: number;
|
|
4
|
+
filter?: (entryPath: string) => boolean;
|
|
5
|
+
onProgress?: (msg: string) => void;
|
|
6
|
+
}
|
|
7
|
+
type EntryKind = "file" | "directory" | "link" | "other";
|
|
8
|
+
interface ArchiveEntry {
|
|
9
|
+
filepath: string;
|
|
10
|
+
kind: EntryKind;
|
|
11
|
+
byteSize: number;
|
|
12
|
+
fileMode: number;
|
|
13
|
+
payload?: Uint8Array;
|
|
14
|
+
linkDestination?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function parseTarArchive(raw: Uint8Array): Generator<ArchiveEntry>;
|
|
17
|
+
export declare function inflateGzip(compressed: ArrayBuffer | Uint8Array): Uint8Array;
|
|
18
|
+
export declare function extractArchive(archiveBytes: ArrayBuffer | Uint8Array, vol: MemoryVolume, destDir: string, opts?: ExtractionOptions): string[];
|
|
19
|
+
export declare function downloadAndExtract(url: string, vol: MemoryVolume, destDir: string, opts?: ExtractionOptions): Promise<string[]>;
|
|
20
|
+
export declare function downloadAndExtractDirect(url: string, vol: MemoryVolume, destDir: string, opts?: ExtractionOptions): Promise<string[]>;
|
|
21
|
+
declare const _default: {
|
|
22
|
+
downloadAndExtract: typeof downloadAndExtract;
|
|
23
|
+
downloadAndExtractDirect: typeof downloadAndExtractDirect;
|
|
24
|
+
parseTarArchive: typeof parseTarArchive;
|
|
25
|
+
extractArchive: typeof extractArchive;
|
|
26
|
+
inflateGzip: typeof inflateGzip;
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MemoryVolume } from "../memory-volume";
|
|
2
|
+
export declare function invalidateBundleCache(): void;
|
|
3
|
+
export declare function attachVolume(vol: MemoryVolume): void;
|
|
4
|
+
export declare function setExternalPackages(packages: string[]): void;
|
|
5
|
+
export declare function bundleForBrowser(specifier: string): Promise<string>;
|
|
6
|
+
export declare class BrowserBundler {
|
|
7
|
+
private vol;
|
|
8
|
+
constructor(vol: MemoryVolume, options?: {
|
|
9
|
+
external?: string[];
|
|
10
|
+
});
|
|
11
|
+
bundle(specifier: string): Promise<string>;
|
|
12
|
+
clearCache(): void;
|
|
13
|
+
}
|
|
14
|
+
export default BrowserBundler;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MemoryVolume } from "../memory-volume";
|
|
2
|
+
import { RegistryConfig } from "./registry-client";
|
|
3
|
+
import { ResolvedDependency } from "./version-resolver";
|
|
4
|
+
export interface InstallFlags {
|
|
5
|
+
registry?: string;
|
|
6
|
+
persist?: boolean;
|
|
7
|
+
persistDev?: boolean;
|
|
8
|
+
withDevDeps?: boolean;
|
|
9
|
+
withOptionalDeps?: boolean;
|
|
10
|
+
onProgress?: (message: string) => void;
|
|
11
|
+
transformModules?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface InstallOutcome {
|
|
14
|
+
resolved: Map<string, ResolvedDependency>;
|
|
15
|
+
newPackages: string[];
|
|
16
|
+
}
|
|
17
|
+
declare function splitSpecifier(spec: string): {
|
|
18
|
+
name: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare class DependencyInstaller {
|
|
22
|
+
private vol;
|
|
23
|
+
private registryClient;
|
|
24
|
+
private workingDir;
|
|
25
|
+
constructor(vol: MemoryVolume, opts?: {
|
|
26
|
+
cwd?: string;
|
|
27
|
+
} & RegistryConfig);
|
|
28
|
+
install(packageName: string, version?: string, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
29
|
+
installFromManifest(manifestPath?: string, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
30
|
+
listInstalled(): Record<string, string>;
|
|
31
|
+
private materializePackages;
|
|
32
|
+
private createBinStubs;
|
|
33
|
+
private writeLockFile;
|
|
34
|
+
private patchManifest;
|
|
35
|
+
}
|
|
36
|
+
export declare function install(specifier: string, vol: MemoryVolume, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
37
|
+
export { RegistryClient } from "./registry-client";
|
|
38
|
+
export type { RegistryConfig, VersionDetail, PackageMetadata, } from "./registry-client";
|
|
39
|
+
export type { ResolvedDependency, ResolutionConfig } from "./version-resolver";
|
|
40
|
+
export type { ExtractionOptions } from "./archive-extractor";
|
|
41
|
+
export { splitSpecifier };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface VersionDetail {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
dependencies?: Record<string, string>;
|
|
5
|
+
devDependencies?: Record<string, string>;
|
|
6
|
+
peerDependencies?: Record<string, string>;
|
|
7
|
+
peerDependenciesMeta?: Record<string, {
|
|
8
|
+
optional?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
optionalDependencies?: Record<string, string>;
|
|
11
|
+
dist: {
|
|
12
|
+
tarball: string;
|
|
13
|
+
shasum: string;
|
|
14
|
+
integrity?: string;
|
|
15
|
+
};
|
|
16
|
+
main?: string;
|
|
17
|
+
module?: string;
|
|
18
|
+
exports?: Record<string, unknown>;
|
|
19
|
+
bin?: Record<string, string> | string;
|
|
20
|
+
}
|
|
21
|
+
export interface PackageMetadata {
|
|
22
|
+
name: string;
|
|
23
|
+
'dist-tags': {
|
|
24
|
+
latest: string;
|
|
25
|
+
[label: string]: string;
|
|
26
|
+
};
|
|
27
|
+
versions: Record<string, VersionDetail>;
|
|
28
|
+
time?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export interface RegistryConfig {
|
|
31
|
+
endpoint?: string;
|
|
32
|
+
metadataCache?: Map<string, PackageMetadata>;
|
|
33
|
+
}
|
|
34
|
+
export declare class RegistryClient {
|
|
35
|
+
private baseUrl;
|
|
36
|
+
private metadataStore;
|
|
37
|
+
constructor(config?: RegistryConfig);
|
|
38
|
+
fetchManifest(name: string): Promise<PackageMetadata>;
|
|
39
|
+
fetchVersion(name: string, version: string): Promise<VersionDetail>;
|
|
40
|
+
getLatestVersion(name: string): Promise<string>;
|
|
41
|
+
listVersions(name: string): Promise<string[]>;
|
|
42
|
+
getTarballUrl(name: string, version: string): Promise<string>;
|
|
43
|
+
downloadArchive(tarballUrl: string): Promise<ArrayBuffer>;
|
|
44
|
+
flushCache(): void;
|
|
45
|
+
}
|
|
46
|
+
export default RegistryClient;
|