@scelar/nodepod 1.0.3 → 1.0.5
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/__sw__.js +642 -642
- package/dist/{child_process-hmVqFcF7.cjs → child_process-B9qsOKHs.cjs} +7434 -7434
- package/dist/child_process-B9qsOKHs.cjs.map +1 -0
- package/dist/{child_process-D6oDN2MX.js → child_process-PY34i_6n.js} +8233 -8233
- package/dist/child_process-PY34i_6n.js.map +1 -0
- package/dist/{index-BO1i013L.cjs → index-CyhVjVJU.cjs} +38383 -37240
- package/dist/index-CyhVjVJU.cjs.map +1 -0
- package/dist/index-D8Hn2kWU.js +36455 -0
- package/dist/index-D8Hn2kWU.js.map +1 -0
- package/dist/index.cjs +67 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +88 -86
- package/dist/index.mjs +61 -59
- package/dist/memory-handler.d.ts +57 -0
- package/dist/memory-volume.d.ts +157 -147
- package/dist/packages/installer.d.ts +44 -41
- package/dist/persistence/idb-cache.d.ts +7 -0
- package/dist/polyfills/wasi.d.ts +45 -4
- package/dist/script-engine.d.ts +84 -81
- package/dist/sdk/nodepod-process.d.ts +29 -28
- package/dist/sdk/nodepod.d.ts +59 -39
- package/dist/sdk/types.d.ts +64 -53
- package/dist/threading/process-manager.d.ts +1 -1
- package/dist/threading/worker-protocol.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +194 -192
- package/src/memory-handler.ts +168 -0
- package/src/memory-volume.ts +78 -8
- package/src/packages/installer.ts +49 -1
- package/src/packages/version-resolver.ts +421 -411
- package/src/persistence/idb-cache.ts +107 -0
- package/src/polyfills/child_process.ts +2288 -2288
- package/src/polyfills/events.ts +6 -2
- package/src/polyfills/fs.ts +2888 -2888
- package/src/polyfills/http.ts +1450 -1449
- package/src/polyfills/process.ts +27 -1
- package/src/polyfills/stream.ts +1621 -1620
- package/src/polyfills/wasi.ts +1306 -44
- package/src/polyfills/zlib.ts +881 -881
- package/src/request-proxy.ts +716 -716
- package/src/script-engine.ts +444 -118
- package/src/sdk/nodepod-process.ts +94 -86
- package/src/sdk/nodepod.ts +571 -509
- package/src/sdk/types.ts +82 -70
- package/src/syntax-transforms.ts +2 -2
- package/src/threading/offload-worker.ts +383 -383
- package/src/threading/offload.ts +271 -271
- package/src/threading/process-manager.ts +967 -956
- package/src/threading/process-worker-entry.ts +858 -854
- package/src/threading/worker-protocol.ts +358 -358
- package/dist/child_process-D6oDN2MX.js.map +0 -1
- package/dist/child_process-hmVqFcF7.cjs.map +0 -1
- package/dist/index-Ale2oba_.js +0 -35412
- package/dist/index-Ale2oba_.js.map +0 -1
- package/dist/index-BO1i013L.cjs.map +0 -1
package/dist/memory-volume.d.ts
CHANGED
|
@@ -1,147 +1,157 @@
|
|
|
1
|
-
import type { VolumeSnapshot } from './engine-types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export type
|
|
44
|
-
export
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
export declare
|
|
64
|
-
|
|
65
|
-
private
|
|
66
|
-
private
|
|
67
|
-
private
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
private
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
import type { VolumeSnapshot } from './engine-types';
|
|
2
|
+
import type { MemoryHandler } from './memory-handler';
|
|
3
|
+
export interface VolumeNode {
|
|
4
|
+
kind: 'file' | 'directory' | 'symlink';
|
|
5
|
+
content?: Uint8Array;
|
|
6
|
+
children?: Map<string, VolumeNode>;
|
|
7
|
+
target?: string;
|
|
8
|
+
modified: number;
|
|
9
|
+
}
|
|
10
|
+
type FileChangeHandler = (filePath: string, content: string) => void;
|
|
11
|
+
type FileDeleteHandler = (filePath: string) => void;
|
|
12
|
+
export interface FileStat {
|
|
13
|
+
isFile(): boolean;
|
|
14
|
+
isDirectory(): boolean;
|
|
15
|
+
isSymbolicLink(): boolean;
|
|
16
|
+
isBlockDevice(): boolean;
|
|
17
|
+
isCharacterDevice(): boolean;
|
|
18
|
+
isFIFO(): boolean;
|
|
19
|
+
isSocket(): boolean;
|
|
20
|
+
size: number;
|
|
21
|
+
mode: number;
|
|
22
|
+
mtime: Date;
|
|
23
|
+
atime: Date;
|
|
24
|
+
ctime: Date;
|
|
25
|
+
birthtime: Date;
|
|
26
|
+
mtimeMs: number;
|
|
27
|
+
atimeMs: number;
|
|
28
|
+
ctimeMs: number;
|
|
29
|
+
birthtimeMs: number;
|
|
30
|
+
nlink: number;
|
|
31
|
+
uid: number;
|
|
32
|
+
gid: number;
|
|
33
|
+
dev: number;
|
|
34
|
+
ino: number;
|
|
35
|
+
rdev: number;
|
|
36
|
+
blksize: number;
|
|
37
|
+
blocks: number;
|
|
38
|
+
atimeNs: bigint;
|
|
39
|
+
mtimeNs: bigint;
|
|
40
|
+
ctimeNs: bigint;
|
|
41
|
+
birthtimeNs: bigint;
|
|
42
|
+
}
|
|
43
|
+
export type WatchEventKind = 'change' | 'rename';
|
|
44
|
+
export type WatchCallback = (event: WatchEventKind, name: string | null) => void;
|
|
45
|
+
export interface FileWatchHandle {
|
|
46
|
+
close(): void;
|
|
47
|
+
ref(): this;
|
|
48
|
+
unref(): this;
|
|
49
|
+
on(event: string, listener: (...args: unknown[]) => void): this;
|
|
50
|
+
once(event: string, listener: (...args: unknown[]) => void): this;
|
|
51
|
+
removeListener(event: string, listener: (...args: unknown[]) => void): this;
|
|
52
|
+
off(event: string, listener: (...args: unknown[]) => void): this;
|
|
53
|
+
addListener(event: string, listener: (...args: unknown[]) => void): this;
|
|
54
|
+
removeAllListeners(event?: string): this;
|
|
55
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface SystemError extends Error {
|
|
58
|
+
code: string;
|
|
59
|
+
errno: number;
|
|
60
|
+
syscall: string;
|
|
61
|
+
path?: string;
|
|
62
|
+
}
|
|
63
|
+
export declare function makeSystemError(code: 'ENOENT' | 'ENOTDIR' | 'EISDIR' | 'EEXIST' | 'ENOTEMPTY', syscall: string, targetPath: string, detail?: string): SystemError;
|
|
64
|
+
export declare class MemoryVolume {
|
|
65
|
+
private tree;
|
|
66
|
+
private textEncoder;
|
|
67
|
+
private textDecoder;
|
|
68
|
+
private activeWatchers;
|
|
69
|
+
private subscribers;
|
|
70
|
+
private _handler;
|
|
71
|
+
constructor(handler?: MemoryHandler | null);
|
|
72
|
+
on(event: 'change', handler: FileChangeHandler): this;
|
|
73
|
+
on(event: 'delete', handler: FileDeleteHandler): this;
|
|
74
|
+
off(event: 'change', handler: FileChangeHandler): this;
|
|
75
|
+
off(event: 'delete', handler: FileDeleteHandler): this;
|
|
76
|
+
private broadcast;
|
|
77
|
+
getStats(): {
|
|
78
|
+
fileCount: number;
|
|
79
|
+
totalBytes: number;
|
|
80
|
+
dirCount: number;
|
|
81
|
+
watcherCount: number;
|
|
82
|
+
};
|
|
83
|
+
/** Clean up all watchers, subscribers, and global listeners. */
|
|
84
|
+
dispose(): void;
|
|
85
|
+
toSnapshot(excludePrefixes?: string[], excludeDirNames?: Set<string>): VolumeSnapshot;
|
|
86
|
+
private collectEntries;
|
|
87
|
+
static fromBinarySnapshot(snapshot: {
|
|
88
|
+
manifest: Array<{
|
|
89
|
+
path: string;
|
|
90
|
+
offset: number;
|
|
91
|
+
length: number;
|
|
92
|
+
isDirectory: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
data: ArrayBuffer;
|
|
95
|
+
}): MemoryVolume;
|
|
96
|
+
static fromSnapshot(snapshot: VolumeSnapshot): MemoryVolume;
|
|
97
|
+
private normalize;
|
|
98
|
+
private segments;
|
|
99
|
+
private parentOf;
|
|
100
|
+
private nameOf;
|
|
101
|
+
private locateRaw;
|
|
102
|
+
private locate;
|
|
103
|
+
private ensureDir;
|
|
104
|
+
private writeInternal;
|
|
105
|
+
existsSync(p: string): boolean;
|
|
106
|
+
statSync(p: string): FileStat;
|
|
107
|
+
lstatSync(p: string): FileStat;
|
|
108
|
+
readFileSync(p: string): Uint8Array;
|
|
109
|
+
readFileSync(p: string, encoding: 'utf8' | 'utf-8'): string;
|
|
110
|
+
writeFileSync(p: string, data: string | Uint8Array): void;
|
|
111
|
+
mkdirSync(p: string, options?: {
|
|
112
|
+
recursive?: boolean;
|
|
113
|
+
}): void;
|
|
114
|
+
readdirSync(p: string): string[];
|
|
115
|
+
unlinkSync(p: string): void;
|
|
116
|
+
rmdirSync(p: string): void;
|
|
117
|
+
renameSync(from: string, to: string): void;
|
|
118
|
+
accessSync(p: string, _mode?: number): void;
|
|
119
|
+
copyFileSync(src: string, dest: string): void;
|
|
120
|
+
realpathSync(p: string): string;
|
|
121
|
+
symlinkSync(target: string, linkPath: string, _type?: string): void;
|
|
122
|
+
readlinkSync(p: string): string;
|
|
123
|
+
linkSync(existingPath: string, newPath: string): void;
|
|
124
|
+
chmodSync(_p: string, _mode: number): void;
|
|
125
|
+
chownSync(_p: string, _uid: number, _gid: number): void;
|
|
126
|
+
appendFileSync(p: string, data: string | Uint8Array): void;
|
|
127
|
+
truncateSync(p: string, len?: number): void;
|
|
128
|
+
readFile(p: string, optionsOrCb?: {
|
|
129
|
+
encoding?: string;
|
|
130
|
+
} | ((err: Error | null, data?: Uint8Array | string) => void), cb?: (err: Error | null, data?: Uint8Array | string) => void): void;
|
|
131
|
+
stat(p: string, cb?: (err: Error | null, stats?: FileStat) => void): void;
|
|
132
|
+
lstat(p: string, cb?: (err: Error | null, stats?: FileStat) => void): void;
|
|
133
|
+
readdir(p: string, optionsOrCb?: {
|
|
134
|
+
withFileTypes?: boolean;
|
|
135
|
+
} | ((err: Error | null, files?: string[]) => void), cb?: (err: Error | null, files?: string[]) => void): void;
|
|
136
|
+
realpath(p: string, cb?: (err: Error | null, resolved?: string) => void): void;
|
|
137
|
+
access(p: string, modeOrCb?: number | ((err: Error | null) => void), cb?: (err: Error | null) => void): void;
|
|
138
|
+
watch(target: string, optionsOrCb?: {
|
|
139
|
+
persistent?: boolean;
|
|
140
|
+
recursive?: boolean;
|
|
141
|
+
encoding?: string;
|
|
142
|
+
} | WatchCallback, cb?: WatchCallback): FileWatchHandle;
|
|
143
|
+
private triggerWatchers;
|
|
144
|
+
private globalChangeListeners;
|
|
145
|
+
onGlobalChange(cb: (path: string, event: string) => void): () => void;
|
|
146
|
+
private notifyGlobalListeners;
|
|
147
|
+
createReadStream(p: string): {
|
|
148
|
+
on: (event: string, cb: (...args: unknown[]) => void) => void;
|
|
149
|
+
pipe: (dest: unknown) => unknown;
|
|
150
|
+
};
|
|
151
|
+
createWriteStream(p: string): {
|
|
152
|
+
write: (data: string | Uint8Array) => boolean;
|
|
153
|
+
end: (data?: string | Uint8Array) => void;
|
|
154
|
+
on: (event: string, cb: (...args: unknown[]) => void) => void;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export {};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { MemoryVolume } from "../memory-volume";
|
|
2
|
-
import { RegistryConfig } from "./registry-client";
|
|
3
|
-
import { ResolvedDependency } from "./version-resolver";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export {
|
|
1
|
+
import { MemoryVolume } from "../memory-volume";
|
|
2
|
+
import { RegistryConfig } from "./registry-client";
|
|
3
|
+
import { ResolvedDependency } from "./version-resolver";
|
|
4
|
+
import type { IDBSnapshotCache } from "../persistence/idb-cache";
|
|
5
|
+
export interface InstallFlags {
|
|
6
|
+
registry?: string;
|
|
7
|
+
persist?: boolean;
|
|
8
|
+
persistDev?: boolean;
|
|
9
|
+
withDevDeps?: boolean;
|
|
10
|
+
withOptionalDeps?: boolean;
|
|
11
|
+
onProgress?: (message: string) => void;
|
|
12
|
+
transformModules?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface InstallOutcome {
|
|
15
|
+
resolved: Map<string, ResolvedDependency>;
|
|
16
|
+
newPackages: string[];
|
|
17
|
+
}
|
|
18
|
+
declare function splitSpecifier(spec: string): {
|
|
19
|
+
name: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
};
|
|
22
|
+
export declare class DependencyInstaller {
|
|
23
|
+
private vol;
|
|
24
|
+
private registryClient;
|
|
25
|
+
private workingDir;
|
|
26
|
+
private _snapshotCache;
|
|
27
|
+
constructor(vol: MemoryVolume, opts?: {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
snapshotCache?: IDBSnapshotCache | null;
|
|
30
|
+
} & RegistryConfig);
|
|
31
|
+
install(packageName: string, version?: string, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
32
|
+
installFromManifest(manifestPath?: string, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
33
|
+
listInstalled(): Record<string, string>;
|
|
34
|
+
private materializePackages;
|
|
35
|
+
private createBinStubs;
|
|
36
|
+
private writeLockFile;
|
|
37
|
+
private patchManifest;
|
|
38
|
+
}
|
|
39
|
+
export declare function install(specifier: string, vol: MemoryVolume, flags?: InstallFlags): Promise<InstallOutcome>;
|
|
40
|
+
export { RegistryClient } from "./registry-client";
|
|
41
|
+
export type { RegistryConfig, VersionDetail, PackageMetadata, } from "./registry-client";
|
|
42
|
+
export type { ResolvedDependency, ResolutionConfig } from "./version-resolver";
|
|
43
|
+
export type { ExtractionOptions } from "./archive-extractor";
|
|
44
|
+
export { splitSpecifier };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VolumeSnapshot } from '../engine-types';
|
|
2
|
+
export interface IDBSnapshotCache {
|
|
3
|
+
get(packageJsonHash: string): Promise<VolumeSnapshot | null>;
|
|
4
|
+
set(packageJsonHash: string, snapshot: VolumeSnapshot): Promise<void>;
|
|
5
|
+
close(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function openSnapshotCache(): Promise<IDBSnapshotCache | null>;
|
package/dist/polyfills/wasi.d.ts
CHANGED
|
@@ -1,12 +1,53 @@
|
|
|
1
|
+
interface WasiFileStat {
|
|
2
|
+
isFile(): boolean;
|
|
3
|
+
isDirectory(): boolean;
|
|
4
|
+
isSymbolicLink(): boolean;
|
|
5
|
+
size: number;
|
|
6
|
+
mtimeMs: number;
|
|
7
|
+
atimeMs: number;
|
|
8
|
+
ctimeMs: number;
|
|
9
|
+
ino?: number;
|
|
10
|
+
nlink?: number;
|
|
11
|
+
}
|
|
12
|
+
interface WasiFS {
|
|
13
|
+
readFileSync(p: string): Uint8Array;
|
|
14
|
+
writeFileSync(p: string, data: string | Uint8Array): void;
|
|
15
|
+
mkdirSync(p: string, options?: {
|
|
16
|
+
recursive?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
statSync(p: string): WasiFileStat;
|
|
19
|
+
readdirSync(p: string): string[];
|
|
20
|
+
unlinkSync(p: string): void;
|
|
21
|
+
rmdirSync(p: string): void;
|
|
22
|
+
renameSync(from: string, to: string): void;
|
|
23
|
+
existsSync(p: string): boolean;
|
|
24
|
+
symlinkSync?(target: string, linkPath: string): void;
|
|
25
|
+
readlinkSync?(p: string): string;
|
|
26
|
+
}
|
|
27
|
+
export declare class ExitStatus extends Error {
|
|
28
|
+
readonly code: number;
|
|
29
|
+
constructor(code: number);
|
|
30
|
+
}
|
|
31
|
+
export interface WASIOptions {
|
|
32
|
+
version?: "preview1" | "unstable";
|
|
33
|
+
args?: string[];
|
|
34
|
+
env?: Record<string, string>;
|
|
35
|
+
preopens?: Record<string, string>;
|
|
36
|
+
returnOnExit?: boolean;
|
|
37
|
+
stdin?: number;
|
|
38
|
+
stdout?: number;
|
|
39
|
+
stderr?: number;
|
|
40
|
+
fs?: WasiFS;
|
|
41
|
+
}
|
|
1
42
|
export interface WASI {
|
|
2
43
|
readonly wasiImport: Record<string, Function>;
|
|
3
|
-
start(
|
|
4
|
-
initialize(
|
|
44
|
+
start(instance: object): number;
|
|
45
|
+
initialize(instance: object): void;
|
|
5
46
|
getImportObject(): Record<string, Record<string, Function>>;
|
|
6
47
|
}
|
|
7
48
|
interface WASIConstructor {
|
|
8
|
-
new (
|
|
9
|
-
(this: any,
|
|
49
|
+
new (options?: WASIOptions): WASI;
|
|
50
|
+
(this: any, options?: WASIOptions): void;
|
|
10
51
|
prototype: any;
|
|
11
52
|
}
|
|
12
53
|
export declare const WASI: WASIConstructor;
|
package/dist/script-engine.d.ts
CHANGED
|
@@ -1,81 +1,84 @@
|
|
|
1
|
-
import { MemoryVolume } from "./memory-volume";
|
|
2
|
-
import type { ExecutionOutcome } from "./engine-types";
|
|
3
|
-
import { ProcessObject } from "./polyfills/process";
|
|
4
|
-
export declare function setChildProcessPolyfill(mod: any): void;
|
|
5
|
-
export interface ModuleRecord {
|
|
6
|
-
id: string;
|
|
7
|
-
filename: string;
|
|
8
|
-
exports: unknown;
|
|
9
|
-
loaded: boolean;
|
|
10
|
-
children: ModuleRecord[];
|
|
11
|
-
paths: string[];
|
|
12
|
-
parent: ModuleRecord | null;
|
|
13
|
-
}
|
|
14
|
-
export interface EngineOptions {
|
|
15
|
-
cwd?: string;
|
|
16
|
-
env?: Record<string, string>;
|
|
17
|
-
onConsole?: (method: string, args: unknown[]) => void;
|
|
18
|
-
onStdout?: (data: string) => void;
|
|
19
|
-
onStderr?: (data: string) => void;
|
|
20
|
-
workerThreadsOverride?: {
|
|
21
|
-
isMainThread: boolean;
|
|
22
|
-
parentPort: unknown;
|
|
23
|
-
workerData: unknown;
|
|
24
|
-
threadId: number;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import { MemoryVolume } from "./memory-volume";
|
|
2
|
+
import type { ExecutionOutcome } from "./engine-types";
|
|
3
|
+
import { ProcessObject } from "./polyfills/process";
|
|
4
|
+
export declare function setChildProcessPolyfill(mod: any): void;
|
|
5
|
+
export interface ModuleRecord {
|
|
6
|
+
id: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
exports: unknown;
|
|
9
|
+
loaded: boolean;
|
|
10
|
+
children: ModuleRecord[];
|
|
11
|
+
paths: string[];
|
|
12
|
+
parent: ModuleRecord | null;
|
|
13
|
+
}
|
|
14
|
+
export interface EngineOptions {
|
|
15
|
+
cwd?: string;
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
onConsole?: (method: string, args: unknown[]) => void;
|
|
18
|
+
onStdout?: (data: string) => void;
|
|
19
|
+
onStderr?: (data: string) => void;
|
|
20
|
+
workerThreadsOverride?: {
|
|
21
|
+
isMainThread: boolean;
|
|
22
|
+
parentPort: unknown;
|
|
23
|
+
workerData: unknown;
|
|
24
|
+
threadId: number;
|
|
25
|
+
};
|
|
26
|
+
handler?: import('./memory-handler').MemoryHandler;
|
|
27
|
+
}
|
|
28
|
+
export interface ResolverFn {
|
|
29
|
+
(id: string): unknown;
|
|
30
|
+
resolve: (id: string, options?: {
|
|
31
|
+
paths?: string[];
|
|
32
|
+
}) => string;
|
|
33
|
+
cache: Record<string, ModuleRecord>;
|
|
34
|
+
extensions: Record<string, unknown>;
|
|
35
|
+
main: ModuleRecord | null;
|
|
36
|
+
_ownerRecord?: ModuleRecord;
|
|
37
|
+
}
|
|
38
|
+
export declare class ScriptEngine {
|
|
39
|
+
private vol;
|
|
40
|
+
private fsBridge;
|
|
41
|
+
private proc;
|
|
42
|
+
private moduleRegistry;
|
|
43
|
+
private opts;
|
|
44
|
+
private transformCache;
|
|
45
|
+
constructor(vol: MemoryVolume, opts?: EngineOptions);
|
|
46
|
+
private patchTextDecoder;
|
|
47
|
+
private patchStackTraceApi;
|
|
48
|
+
execute(code: string, filename?: string): {
|
|
49
|
+
exports: unknown;
|
|
50
|
+
module: ModuleRecord;
|
|
51
|
+
};
|
|
52
|
+
executeSync: (code: string, filename?: string) => {
|
|
53
|
+
exports: unknown;
|
|
54
|
+
module: ModuleRecord;
|
|
55
|
+
};
|
|
56
|
+
executeAsync(code: string, filename?: string): Promise<ExecutionOutcome>;
|
|
57
|
+
runFile(filename: string): {
|
|
58
|
+
exports: unknown;
|
|
59
|
+
module: ModuleRecord;
|
|
60
|
+
};
|
|
61
|
+
runFileSync: (filename: string) => {
|
|
62
|
+
exports: unknown;
|
|
63
|
+
module: ModuleRecord;
|
|
64
|
+
};
|
|
65
|
+
runFileTLA(filename: string): Promise<{
|
|
66
|
+
exports: unknown;
|
|
67
|
+
module: ModuleRecord;
|
|
68
|
+
}>;
|
|
69
|
+
runFileAsync(filename: string): Promise<ExecutionOutcome>;
|
|
70
|
+
clearCache(): void;
|
|
71
|
+
/** Evict one node_modules entry when module cache exceeds soft limit. */
|
|
72
|
+
private _trimModuleCache;
|
|
73
|
+
getVolume(): MemoryVolume;
|
|
74
|
+
getProcess(): ProcessObject;
|
|
75
|
+
createREPL(): {
|
|
76
|
+
eval: (code: string) => unknown;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare function executeCode(code: string, vol: MemoryVolume, opts?: EngineOptions): {
|
|
80
|
+
exports: unknown;
|
|
81
|
+
module: ModuleRecord;
|
|
82
|
+
};
|
|
83
|
+
export type { IScriptEngine, ExecutionOutcome, EngineConfig, } from "./engine-types";
|
|
84
|
+
export default ScriptEngine;
|