secure-exec 0.0.1 → 0.1.0-rc.1
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/LICENSE +191 -0
- package/README.md +7 -0
- package/dist/bridge/active-handles.d.ts +21 -0
- package/dist/bridge/active-handles.js +60 -0
- package/dist/bridge/child-process.d.ts +87 -0
- package/dist/bridge/child-process.js +523 -0
- package/dist/bridge/fs.d.ts +227 -0
- package/dist/bridge/fs.js +1572 -0
- package/dist/bridge/index.d.ts +10 -0
- package/dist/bridge/index.js +41 -0
- package/dist/bridge/module.d.ts +73 -0
- package/dist/bridge/module.js +329 -0
- package/dist/bridge/network.d.ts +208 -0
- package/dist/bridge/network.js +1117 -0
- package/dist/bridge/os.d.ts +13 -0
- package/dist/bridge/os.js +257 -0
- package/dist/bridge/polyfills.d.ts +2 -0
- package/dist/bridge/polyfills.js +12 -0
- package/dist/bridge/process.d.ts +64 -0
- package/dist/bridge/process.js +916 -0
- package/dist/bridge-loader.d.ts +1 -0
- package/dist/bridge-loader.js +2 -0
- package/dist/bridge-setup.d.ts +1 -0
- package/dist/bridge-setup.js +2 -0
- package/dist/bridge.js +10586 -0
- package/dist/browser/driver.d.ts +42 -0
- package/dist/browser/driver.js +263 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.js +4 -0
- package/dist/browser/worker.d.ts +1 -0
- package/dist/browser/worker.js +3 -0
- package/dist/browser-runtime.d.ts +6 -0
- package/dist/browser-runtime.js +4 -0
- package/dist/esm-compiler.d.ts +1 -0
- package/dist/esm-compiler.js +2 -0
- package/dist/execution.d.ts +1 -0
- package/dist/execution.js +2 -0
- package/dist/fs-helpers.d.ts +2 -0
- package/dist/fs-helpers.js +1 -0
- package/dist/generated/isolate-runtime.d.ts +19 -0
- package/dist/generated/isolate-runtime.js +21 -0
- package/dist/generated/polyfills.d.ts +82 -0
- package/dist/generated/polyfills.js +82 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +11 -0
- package/dist/isolate-runtime/apply-custom-global-policy.js +54 -0
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +44 -0
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +14 -0
- package/dist/isolate-runtime/bridge-attach.js +29 -0
- package/dist/isolate-runtime/bridge-initial-globals.js +78 -0
- package/dist/isolate-runtime/eval-script-result.js +8 -0
- package/dist/isolate-runtime/global-exposure-helpers.js +36 -0
- package/dist/isolate-runtime/init-commonjs-module-globals.js +28 -0
- package/dist/isolate-runtime/override-process-cwd.js +8 -0
- package/dist/isolate-runtime/override-process-env.js +8 -0
- package/dist/isolate-runtime/require-setup.js +606 -0
- package/dist/isolate-runtime/set-commonjs-file-globals.js +36 -0
- package/dist/isolate-runtime/set-stdin-data.js +10 -0
- package/dist/isolate-runtime/setup-dynamic-import.js +64 -0
- package/dist/isolate-runtime/setup-fs-facade.js +40 -0
- package/dist/isolate.d.ts +1 -0
- package/dist/isolate.js +2 -0
- package/dist/module-resolver.d.ts +1 -0
- package/dist/module-resolver.js +2 -0
- package/dist/node/bridge-setup.d.ts +1 -0
- package/dist/node/bridge-setup.js +2 -0
- package/dist/node/driver.d.ts +2 -0
- package/dist/node/driver.js +2 -0
- package/dist/node/esm-compiler.d.ts +1 -0
- package/dist/node/esm-compiler.js +2 -0
- package/dist/node/execution-driver.d.ts +2 -0
- package/dist/node/execution-driver.js +2 -0
- package/dist/node/execution-lifecycle.d.ts +1 -0
- package/dist/node/execution-lifecycle.js +2 -0
- package/dist/node/isolate-bootstrap.d.ts +2 -0
- package/dist/node/isolate-bootstrap.js +1 -0
- package/dist/node/module-access.d.ts +2 -0
- package/dist/node/module-access.js +2 -0
- package/dist/node/module-resolver.d.ts +1 -0
- package/dist/node/module-resolver.js +2 -0
- package/dist/package-bundler.d.ts +2 -0
- package/dist/package-bundler.js +1 -0
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +2 -0
- package/dist/python-runtime.d.ts +2 -0
- package/dist/python-runtime.js +2 -0
- package/dist/runtime-driver.d.ts +1 -0
- package/dist/runtime-driver.js +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.js +2 -0
- package/dist/shared/api-types.d.ts +1 -0
- package/dist/shared/api-types.js +1 -0
- package/dist/shared/bridge-contract.d.ts +2 -0
- package/dist/shared/bridge-contract.js +1 -0
- package/dist/shared/console-formatter.d.ts +2 -0
- package/dist/shared/console-formatter.js +1 -0
- package/dist/shared/errors.d.ts +2 -0
- package/dist/shared/errors.js +1 -0
- package/dist/shared/esm-utils.d.ts +1 -0
- package/dist/shared/esm-utils.js +2 -0
- package/dist/shared/global-exposure.d.ts +2 -0
- package/dist/shared/global-exposure.js +1 -0
- package/dist/shared/in-memory-fs.d.ts +1 -0
- package/dist/shared/in-memory-fs.js +2 -0
- package/dist/shared/permissions.d.ts +1 -0
- package/dist/shared/permissions.js +2 -0
- package/dist/shared/require-setup.d.ts +1 -0
- package/dist/shared/require-setup.js +2 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +51 -4
- package/index.js +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createCommandExecutorStub, createFsStub, createNetworkStub } from "../shared/permissions.js";
|
|
2
|
+
import type { CommandExecutor, NetworkAdapter, Permissions, SandboxDriver, VirtualFileSystem } from "../types.js";
|
|
3
|
+
export declare class OpfsFileSystem implements VirtualFileSystem {
|
|
4
|
+
private rootPromise;
|
|
5
|
+
constructor();
|
|
6
|
+
private getDirHandle;
|
|
7
|
+
private getFileHandle;
|
|
8
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
9
|
+
readTextFile(path: string): Promise<string>;
|
|
10
|
+
readDir(path: string): Promise<string[]>;
|
|
11
|
+
readDirWithTypes(path: string): Promise<Array<{
|
|
12
|
+
name: string;
|
|
13
|
+
isDirectory: boolean;
|
|
14
|
+
}>>;
|
|
15
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
16
|
+
createDir(path: string): Promise<void>;
|
|
17
|
+
mkdir(path: string): Promise<void>;
|
|
18
|
+
exists(path: string): Promise<boolean>;
|
|
19
|
+
stat(path: string): Promise<{
|
|
20
|
+
mode: number;
|
|
21
|
+
size: number;
|
|
22
|
+
isDirectory: boolean;
|
|
23
|
+
atimeMs: number;
|
|
24
|
+
mtimeMs: number;
|
|
25
|
+
ctimeMs: number;
|
|
26
|
+
birthtimeMs: number;
|
|
27
|
+
}>;
|
|
28
|
+
removeFile(path: string): Promise<void>;
|
|
29
|
+
removeDir(path: string): Promise<void>;
|
|
30
|
+
rename(_oldPath: string, _newPath: string): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export interface BrowserDriverOptions {
|
|
33
|
+
filesystem?: VirtualFileSystem;
|
|
34
|
+
networkAdapter?: NetworkAdapter;
|
|
35
|
+
commandExecutor?: CommandExecutor;
|
|
36
|
+
permissions?: Permissions;
|
|
37
|
+
useDefaultNetwork?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function createOpfsFileSystem(): Promise<VirtualFileSystem>;
|
|
40
|
+
export declare function createBrowserNetworkAdapter(): NetworkAdapter;
|
|
41
|
+
export declare function createBrowserDriver(options?: BrowserDriverOptions): Promise<SandboxDriver>;
|
|
42
|
+
export { createCommandExecutorStub, createFsStub, createNetworkStub, };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { createCommandExecutorStub, createFsStub, createNetworkStub, wrapCommandExecutor, wrapFileSystem, wrapNetworkAdapter, } from "../shared/permissions.js";
|
|
2
|
+
import { createInMemoryFileSystem } from "../shared/in-memory-fs.js";
|
|
3
|
+
import { createEnosysError } from "../shared/errors.js";
|
|
4
|
+
const S_IFREG = 0o100000;
|
|
5
|
+
const S_IFDIR = 0o040000;
|
|
6
|
+
function normalizePath(path) {
|
|
7
|
+
if (!path)
|
|
8
|
+
return "/";
|
|
9
|
+
let normalized = path.startsWith("/") ? path : `/${path}`;
|
|
10
|
+
normalized = normalized.replace(/\/+/g, "/");
|
|
11
|
+
if (normalized.length > 1 && normalized.endsWith("/")) {
|
|
12
|
+
normalized = normalized.slice(0, -1);
|
|
13
|
+
}
|
|
14
|
+
return normalized;
|
|
15
|
+
}
|
|
16
|
+
function splitPath(path) {
|
|
17
|
+
const normalized = normalizePath(path);
|
|
18
|
+
return normalized === "/" ? [] : normalized.slice(1).split("/");
|
|
19
|
+
}
|
|
20
|
+
function dirname(path) {
|
|
21
|
+
const parts = splitPath(path);
|
|
22
|
+
if (parts.length <= 1)
|
|
23
|
+
return "/";
|
|
24
|
+
return `/${parts.slice(0, -1).join("/")}`;
|
|
25
|
+
}
|
|
26
|
+
async function getRootHandle() {
|
|
27
|
+
if (!("storage" in navigator) || !("getDirectory" in navigator.storage)) {
|
|
28
|
+
throw createEnosysError("opfs");
|
|
29
|
+
}
|
|
30
|
+
return navigator.storage.getDirectory();
|
|
31
|
+
}
|
|
32
|
+
export class OpfsFileSystem {
|
|
33
|
+
rootPromise;
|
|
34
|
+
constructor() {
|
|
35
|
+
this.rootPromise = getRootHandle();
|
|
36
|
+
}
|
|
37
|
+
async getDirHandle(path, create = false) {
|
|
38
|
+
const root = await this.rootPromise;
|
|
39
|
+
const parts = splitPath(path);
|
|
40
|
+
let current = root;
|
|
41
|
+
for (const part of parts) {
|
|
42
|
+
current = await current.getDirectoryHandle(part, { create });
|
|
43
|
+
}
|
|
44
|
+
return current;
|
|
45
|
+
}
|
|
46
|
+
async getFileHandle(path, create = false) {
|
|
47
|
+
const normalized = normalizePath(path);
|
|
48
|
+
const parent = dirname(normalized);
|
|
49
|
+
const name = normalized.split("/").pop() || "";
|
|
50
|
+
const dir = await this.getDirHandle(parent, create);
|
|
51
|
+
return dir.getFileHandle(name, { create });
|
|
52
|
+
}
|
|
53
|
+
async readFile(path) {
|
|
54
|
+
const handle = await this.getFileHandle(path);
|
|
55
|
+
const file = await handle.getFile();
|
|
56
|
+
const buffer = await file.arrayBuffer();
|
|
57
|
+
return new Uint8Array(buffer);
|
|
58
|
+
}
|
|
59
|
+
async readTextFile(path) {
|
|
60
|
+
const handle = await this.getFileHandle(path);
|
|
61
|
+
const file = await handle.getFile();
|
|
62
|
+
return file.text();
|
|
63
|
+
}
|
|
64
|
+
async readDir(path) {
|
|
65
|
+
const dir = await this.getDirHandle(path);
|
|
66
|
+
const entries = [];
|
|
67
|
+
for await (const [name] of dir.entries()) {
|
|
68
|
+
entries.push(name);
|
|
69
|
+
}
|
|
70
|
+
return entries;
|
|
71
|
+
}
|
|
72
|
+
async readDirWithTypes(path) {
|
|
73
|
+
const dir = await this.getDirHandle(path);
|
|
74
|
+
const entries = [];
|
|
75
|
+
for await (const [name, handle] of dir.entries()) {
|
|
76
|
+
entries.push({
|
|
77
|
+
name,
|
|
78
|
+
isDirectory: handle.kind === "directory",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return entries;
|
|
82
|
+
}
|
|
83
|
+
async writeFile(path, content) {
|
|
84
|
+
const normalized = normalizePath(path);
|
|
85
|
+
await this.mkdir(dirname(normalized));
|
|
86
|
+
const handle = await this.getFileHandle(normalized, true);
|
|
87
|
+
const writable = await handle.createWritable();
|
|
88
|
+
if (typeof content === "string") {
|
|
89
|
+
await writable.write(content);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
await writable.write(content);
|
|
93
|
+
}
|
|
94
|
+
await writable.close();
|
|
95
|
+
}
|
|
96
|
+
async createDir(path) {
|
|
97
|
+
const normalized = normalizePath(path);
|
|
98
|
+
const parent = dirname(normalized);
|
|
99
|
+
await this.getDirHandle(parent, false);
|
|
100
|
+
await this.getDirHandle(normalized, true);
|
|
101
|
+
}
|
|
102
|
+
async mkdir(path) {
|
|
103
|
+
const parts = splitPath(path);
|
|
104
|
+
let current = "";
|
|
105
|
+
for (const part of parts) {
|
|
106
|
+
current += `/${part}`;
|
|
107
|
+
await this.getDirHandle(current, true);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async exists(path) {
|
|
111
|
+
try {
|
|
112
|
+
await this.getFileHandle(path);
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
try {
|
|
117
|
+
await this.getDirHandle(path);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async stat(path) {
|
|
126
|
+
try {
|
|
127
|
+
const handle = await this.getFileHandle(path);
|
|
128
|
+
const file = await handle.getFile();
|
|
129
|
+
return {
|
|
130
|
+
mode: S_IFREG | 0o644,
|
|
131
|
+
size: file.size,
|
|
132
|
+
isDirectory: false,
|
|
133
|
+
atimeMs: file.lastModified,
|
|
134
|
+
mtimeMs: file.lastModified,
|
|
135
|
+
ctimeMs: file.lastModified,
|
|
136
|
+
birthtimeMs: file.lastModified,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
const normalized = normalizePath(path);
|
|
141
|
+
try {
|
|
142
|
+
await this.getDirHandle(normalized);
|
|
143
|
+
const now = Date.now();
|
|
144
|
+
return {
|
|
145
|
+
mode: S_IFDIR | 0o755,
|
|
146
|
+
size: 4096,
|
|
147
|
+
isDirectory: true,
|
|
148
|
+
atimeMs: now,
|
|
149
|
+
mtimeMs: now,
|
|
150
|
+
ctimeMs: now,
|
|
151
|
+
birthtimeMs: now,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
throw new Error(`ENOENT: no such file or directory, stat '${normalized}'`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async removeFile(path) {
|
|
160
|
+
const normalized = normalizePath(path);
|
|
161
|
+
const parent = dirname(normalized);
|
|
162
|
+
const name = normalized.split("/").pop() || "";
|
|
163
|
+
const dir = await this.getDirHandle(parent);
|
|
164
|
+
await dir.removeEntry(name);
|
|
165
|
+
}
|
|
166
|
+
async removeDir(path) {
|
|
167
|
+
const normalized = normalizePath(path);
|
|
168
|
+
if (normalized === "/") {
|
|
169
|
+
throw new Error("EPERM: operation not permitted, rmdir '/'");
|
|
170
|
+
}
|
|
171
|
+
const parent = dirname(normalized);
|
|
172
|
+
const name = normalized.split("/").pop() || "";
|
|
173
|
+
const dir = await this.getDirHandle(parent);
|
|
174
|
+
await dir.removeEntry(name);
|
|
175
|
+
}
|
|
176
|
+
async rename(_oldPath, _newPath) {
|
|
177
|
+
throw createEnosysError("rename");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export async function createOpfsFileSystem() {
|
|
181
|
+
if (!("storage" in navigator) || typeof navigator.storage.getDirectory !== "function") {
|
|
182
|
+
return createInMemoryFileSystem();
|
|
183
|
+
}
|
|
184
|
+
return new OpfsFileSystem();
|
|
185
|
+
}
|
|
186
|
+
export function createBrowserNetworkAdapter() {
|
|
187
|
+
return {
|
|
188
|
+
async fetch(url, options) {
|
|
189
|
+
const response = await fetch(url, {
|
|
190
|
+
method: options?.method || "GET",
|
|
191
|
+
headers: options?.headers,
|
|
192
|
+
body: options?.body,
|
|
193
|
+
});
|
|
194
|
+
const headers = {};
|
|
195
|
+
response.headers.forEach((v, k) => {
|
|
196
|
+
headers[k] = v;
|
|
197
|
+
});
|
|
198
|
+
const contentType = response.headers.get("content-type") || "";
|
|
199
|
+
const isBinary = contentType.includes("octet-stream") ||
|
|
200
|
+
contentType.includes("gzip") ||
|
|
201
|
+
url.endsWith(".tgz");
|
|
202
|
+
let body;
|
|
203
|
+
if (isBinary) {
|
|
204
|
+
const buffer = await response.arrayBuffer();
|
|
205
|
+
body = btoa(String.fromCharCode(...new Uint8Array(buffer)));
|
|
206
|
+
headers["x-body-encoding"] = "base64";
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
body = await response.text();
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
ok: response.ok,
|
|
213
|
+
status: response.status,
|
|
214
|
+
statusText: response.statusText,
|
|
215
|
+
headers,
|
|
216
|
+
body,
|
|
217
|
+
url: response.url,
|
|
218
|
+
redirected: response.redirected,
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
async dnsLookup(_hostname) {
|
|
222
|
+
return { error: "DNS not supported in browser", code: "ENOSYS" };
|
|
223
|
+
},
|
|
224
|
+
async httpRequest(url, options) {
|
|
225
|
+
const response = await fetch(url, {
|
|
226
|
+
method: options?.method || "GET",
|
|
227
|
+
headers: options?.headers,
|
|
228
|
+
body: options?.body,
|
|
229
|
+
});
|
|
230
|
+
const headers = {};
|
|
231
|
+
response.headers.forEach((v, k) => {
|
|
232
|
+
headers[k] = v;
|
|
233
|
+
});
|
|
234
|
+
const body = await response.text();
|
|
235
|
+
return {
|
|
236
|
+
status: response.status,
|
|
237
|
+
statusText: response.statusText,
|
|
238
|
+
headers,
|
|
239
|
+
body,
|
|
240
|
+
url: response.url,
|
|
241
|
+
};
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export async function createBrowserDriver(options = {}) {
|
|
246
|
+
const permissions = options.permissions;
|
|
247
|
+
const filesystem = options.filesystem ?? (await createOpfsFileSystem());
|
|
248
|
+
const networkAdapter = options.networkAdapter
|
|
249
|
+
? wrapNetworkAdapter(options.networkAdapter, permissions)
|
|
250
|
+
: options.useDefaultNetwork
|
|
251
|
+
? wrapNetworkAdapter(createBrowserNetworkAdapter(), permissions)
|
|
252
|
+
: undefined;
|
|
253
|
+
const commandExecutor = options.commandExecutor
|
|
254
|
+
? wrapCommandExecutor(options.commandExecutor, permissions)
|
|
255
|
+
: undefined;
|
|
256
|
+
return {
|
|
257
|
+
filesystem: wrapFileSystem(filesystem, permissions),
|
|
258
|
+
network: networkAdapter,
|
|
259
|
+
commandExecutor,
|
|
260
|
+
permissions,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
export { createCommandExecutorStub, createFsStub, createNetworkStub, };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, } from "@secure-exec/browser";
|
|
2
|
+
export type { BrowserDriverOptions, BrowserRuntimeSystemOptions, } from "@secure-exec/browser";
|
|
3
|
+
export { createBrowserRuntimeDriverFactory, } from "@secure-exec/browser";
|
|
4
|
+
export type { BrowserRuntimeDriverFactoryOptions, } from "@secure-exec/browser";
|
|
5
|
+
export { createInMemoryFileSystem } from "@secure-exec/core";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Re-export browser driver factories from @secure-exec/browser.
|
|
2
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createOpfsFileSystem, } from "@secure-exec/browser";
|
|
3
|
+
export { createBrowserRuntimeDriverFactory, } from "@secure-exec/browser";
|
|
4
|
+
export { createInMemoryFileSystem } from "@secure-exec/core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@secure-exec/browser/internal/worker";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { NodeRuntime } from "@secure-exec/core";
|
|
2
|
+
export type { NodeRuntimeOptions } from "@secure-exec/core";
|
|
3
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createBrowserRuntimeDriverFactory, createOpfsFileSystem, } from "@secure-exec/browser";
|
|
4
|
+
export type { BrowserDriverOptions, BrowserRuntimeDriverFactoryOptions, BrowserRuntimeSystemOptions, } from "@secure-exec/browser";
|
|
5
|
+
export type { StdioChannel, StdioEvent, StdioHook, ExecOptions, ExecResult, OSConfig, PythonRunResult, ProcessConfig, RunResult, TimingMitigation, } from "@secure-exec/core";
|
|
6
|
+
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, } from "@secure-exec/core";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Browser-safe entrypoint for NodeRuntime + browser driver factories.
|
|
2
|
+
export { NodeRuntime } from "@secure-exec/core";
|
|
3
|
+
export { createBrowserDriver, createBrowserNetworkAdapter, createBrowserRuntimeDriverFactory, createOpfsFileSystem, } from "@secure-exec/browser";
|
|
4
|
+
export { allowAll, allowAllChildProcess, allowAllEnv, allowAllFs, allowAllNetwork, } from "@secure-exec/core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getStaticBuiltinWrapperSource, createBuiltinESMWrapper, getEmptyBuiltinESMWrapper, } from "@secure-exec/core";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { executeWithRuntime } from "@secure-exec/node/internal/execution";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { exists, stat, rename, readDirWithTypes, mkdir } from "@secure-exec/core";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const ISOLATE_RUNTIME_SOURCES: {
|
|
2
|
+
readonly applyCustomGlobalPolicy: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function hasOwnGlobal(name) {\n return Object.prototype.hasOwnProperty.call(globalThis, name);\n }\n function getGlobalValue(name) {\n return Reflect.get(globalThis, name);\n }\n\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/apply-custom-global-policy.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __globalPolicy = globalThis.__runtimeCustomGlobalPolicy ?? {};\n var __hardenedGlobals = Array.isArray(__globalPolicy.hardenedGlobals) ? __globalPolicy.hardenedGlobals : [];\n var __mutableGlobals = Array.isArray(__globalPolicy.mutableGlobals) ? __globalPolicy.mutableGlobals : [];\n for (const globalName of __hardenedGlobals) {\n if (hasOwnGlobal(globalName)) {\n __runtimeExposeCustomGlobal(globalName, getGlobalValue(globalName));\n }\n }\n for (const globalName of __mutableGlobals) {\n if (hasOwnGlobal(globalName)) {\n __runtimeExposeMutableGlobal(globalName, getGlobalValue(globalName));\n }\n }\n})();\n";
|
|
3
|
+
readonly applyTimingMitigationFreeze: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function setGlobalValue(name, value) {\n Reflect.set(globalThis, name, value);\n }\n\n // isolate-runtime/src/inject/apply-timing-mitigation-freeze.ts\n var __timingConfig = globalThis.__runtimeTimingMitigationConfig ?? {};\n var __frozenTimeMs = typeof __timingConfig.frozenTimeMs === \"number\" && Number.isFinite(__timingConfig.frozenTimeMs) ? __timingConfig.frozenTimeMs : Date.now();\n var __frozenDateNow = () => __frozenTimeMs;\n try {\n Object.defineProperty(Date, \"now\", {\n value: __frozenDateNow,\n configurable: true,\n writable: true\n });\n } catch {\n Date.now = __frozenDateNow;\n }\n var __frozenPerformanceNow = () => 0;\n var __performance = globalThis.performance;\n if (typeof __performance !== \"undefined\" && __performance !== null) {\n try {\n Object.defineProperty(__performance, \"now\", {\n value: __frozenPerformanceNow,\n configurable: true,\n writable: true\n });\n } catch {\n try {\n Object.assign(__performance, { now: __frozenPerformanceNow });\n } catch {\n }\n }\n } else {\n setGlobalValue(\"performance\", {\n now: __frozenPerformanceNow\n });\n }\n if (!Reflect.deleteProperty(globalThis, \"SharedArrayBuffer\")) {\n setGlobalValue(\"SharedArrayBuffer\", void 0);\n }\n})();\n";
|
|
4
|
+
readonly applyTimingMitigationOff: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function setGlobalValue(name, value) {\n Reflect.set(globalThis, name, value);\n }\n\n // isolate-runtime/src/inject/apply-timing-mitigation-off.ts\n if (typeof globalThis.performance === \"undefined\" || globalThis.performance === null) {\n setGlobalValue(\"performance\", {\n now: () => Date.now()\n });\n }\n})();\n";
|
|
5
|
+
readonly bridgeAttach: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/bridge-attach.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n if (typeof globalThis.bridge !== \"undefined\") {\n __runtimeExposeCustomGlobal(\"bridge\", globalThis.bridge);\n }\n})();\n";
|
|
6
|
+
readonly bridgeInitialGlobals: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/bridge-initial-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __bridgeSetupConfig = globalThis.__runtimeBridgeSetupConfig ?? {};\n var __initialCwd = typeof __bridgeSetupConfig.initialCwd === \"string\" ? __bridgeSetupConfig.initialCwd : \"/\";\n var __jsonPayloadLimitBytes = typeof __bridgeSetupConfig.jsonPayloadLimitBytes === \"number\" && Number.isFinite(__bridgeSetupConfig.jsonPayloadLimitBytes) ? Math.max(0, Math.floor(__bridgeSetupConfig.jsonPayloadLimitBytes)) : 4 * 1024 * 1024;\n var __payloadLimitErrorCode = typeof __bridgeSetupConfig.payloadLimitErrorCode === \"string\" && __bridgeSetupConfig.payloadLimitErrorCode.length > 0 ? __bridgeSetupConfig.payloadLimitErrorCode : \"ERR_SANDBOX_PAYLOAD_TOO_LARGE\";\n __runtimeExposeMutableGlobal(\"_moduleCache\", {});\n globalThis._moduleCache = globalThis._moduleCache ?? {};\n var __moduleCache = globalThis._moduleCache;\n if (__moduleCache) {\n __moduleCache[\"v8\"] = {\n getHeapStatistics: function() {\n return {\n total_heap_size: 67108864,\n total_heap_size_executable: 1048576,\n total_physical_size: 67108864,\n total_available_size: 67108864,\n used_heap_size: 52428800,\n heap_size_limit: 134217728,\n malloced_memory: 8192,\n peak_malloced_memory: 16384,\n does_zap_garbage: 0,\n number_of_native_contexts: 1,\n number_of_detached_contexts: 0,\n external_memory: 0\n };\n },\n getHeapSpaceStatistics: function() {\n return [];\n },\n getHeapCodeStatistics: function() {\n return {};\n },\n setFlagsFromString: function() {\n },\n serialize: function(value) {\n return Buffer.from(JSON.stringify(value));\n },\n deserialize: function(buffer) {\n const text = buffer.toString();\n if (Buffer.byteLength(text, \"utf8\") > __jsonPayloadLimitBytes) {\n throw new Error(\n __payloadLimitErrorCode + \": v8.deserialize exceeds \" + String(__jsonPayloadLimitBytes) + \" bytes\"\n );\n }\n return JSON.parse(text);\n },\n cachedDataVersionTag: function() {\n return 0;\n }\n };\n }\n __runtimeExposeMutableGlobal(\"_pendingModules\", {});\n __runtimeExposeMutableGlobal(\"_currentModule\", { dirname: __initialCwd });\n})();\n";
|
|
7
|
+
readonly evalScriptResult: "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/eval-script-result.ts\n var __runtimeIndirectEval = globalThis.eval;\n globalThis.__scriptResult__ = __runtimeIndirectEval(\n String(globalThis.__runtimeExecCode)\n );\n})();\n";
|
|
8
|
+
readonly globalExposureHelpers: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function ensureRuntimeExposureHelpers() {\n if (typeof globalThis.__runtimeExposeCustomGlobal !== \"function\") {\n defineRuntimeGlobalBinding(\n \"__runtimeExposeCustomGlobal\",\n createRuntimeGlobalExposer(false),\n false\n );\n }\n if (typeof globalThis.__runtimeExposeMutableGlobal !== \"function\") {\n defineRuntimeGlobalBinding(\n \"__runtimeExposeMutableGlobal\",\n createRuntimeGlobalExposer(true),\n false\n );\n }\n }\n\n // isolate-runtime/src/inject/global-exposure-helpers.ts\n ensureRuntimeExposureHelpers();\n})();\n";
|
|
9
|
+
readonly initCommonjsModuleGlobals: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/init-commonjs-module-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n __runtimeExposeMutableGlobal(\"module\", { exports: {} });\n __runtimeExposeMutableGlobal(\"exports\", globalThis.module.exports);\n})();\n";
|
|
10
|
+
readonly overrideProcessCwd: "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/override-process-cwd.ts\n var __cwd = globalThis.__runtimeProcessCwdOverride;\n if (typeof __cwd === \"string\") {\n process.cwd = () => __cwd;\n }\n})();\n";
|
|
11
|
+
readonly overrideProcessEnv: "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/override-process-env.ts\n var __envPatch = globalThis.__runtimeProcessEnvOverride;\n if (__envPatch && typeof __envPatch === \"object\") {\n Object.assign(process.env, __envPatch);\n }\n})();\n";
|
|
12
|
+
readonly requireSetup: "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/require-setup.ts\n var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === \"function\" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name2, value) {\n Object.defineProperty(globalThis, name2, {\n value,\n writable: false,\n configurable: false,\n enumerable: true\n });\n };\n if (typeof globalThis.AbortController === \"undefined\" || typeof globalThis.AbortSignal === \"undefined\") {\n class AbortSignal {\n constructor() {\n this.aborted = false;\n this.reason = void 0;\n this.onabort = null;\n this._listeners = [];\n }\n addEventListener(type, listener) {\n if (type !== \"abort\" || typeof listener !== \"function\") return;\n this._listeners.push(listener);\n }\n removeEventListener(type, listener) {\n if (type !== \"abort\" || typeof listener !== \"function\") return;\n const index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n }\n dispatchEvent(event) {\n if (!event || event.type !== \"abort\") return false;\n if (typeof this.onabort === \"function\") {\n try {\n this.onabort.call(this, event);\n } catch {\n }\n }\n const listeners = this._listeners.slice();\n for (const listener of listeners) {\n try {\n listener.call(this, event);\n } catch {\n }\n }\n return true;\n }\n }\n class AbortController {\n constructor() {\n this.signal = new AbortSignal();\n }\n abort(reason) {\n if (this.signal.aborted) return;\n this.signal.aborted = true;\n this.signal.reason = reason;\n this.signal.dispatchEvent({ type: \"abort\" });\n }\n }\n __requireExposeCustomGlobal(\"AbortSignal\", AbortSignal);\n __requireExposeCustomGlobal(\"AbortController\", AbortController);\n }\n if (typeof globalThis.structuredClone !== \"function\") {\n let structuredClonePolyfill = function(value) {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n if (value instanceof ArrayBuffer) {\n return value.slice(0);\n }\n if (ArrayBuffer.isView(value)) {\n if (value instanceof Uint8Array) {\n return new Uint8Array(value);\n }\n return new value.constructor(value);\n }\n return JSON.parse(JSON.stringify(value));\n };\n structuredClonePolyfill2 = structuredClonePolyfill;\n __requireExposeCustomGlobal(\"structuredClone\", structuredClonePolyfill);\n }\n var structuredClonePolyfill2;\n if (typeof globalThis.btoa !== \"function\") {\n __requireExposeCustomGlobal(\"btoa\", function btoa(input) {\n return Buffer.from(String(input), \"binary\").toString(\"base64\");\n });\n }\n if (typeof globalThis.atob !== \"function\") {\n __requireExposeCustomGlobal(\"atob\", function atob(input) {\n return Buffer.from(String(input), \"base64\").toString(\"binary\");\n });\n }\n function _dirname(p) {\n const lastSlash = p.lastIndexOf(\"/\");\n if (lastSlash === -1) return \".\";\n if (lastSlash === 0) return \"/\";\n return p.slice(0, lastSlash);\n }\n function _patchPolyfill(name2, result2) {\n if (typeof result2 !== \"object\" && typeof result2 !== \"function\" || result2 === null) {\n return result2;\n }\n if (name2 === \"buffer\") {\n const maxLength = typeof result2.kMaxLength === \"number\" ? result2.kMaxLength : 2147483647;\n const maxStringLength = typeof result2.kStringMaxLength === \"number\" ? result2.kStringMaxLength : 536870888;\n if (typeof result2.constants !== \"object\" || result2.constants === null) {\n result2.constants = {};\n }\n if (typeof result2.constants.MAX_LENGTH !== \"number\") {\n result2.constants.MAX_LENGTH = maxLength;\n }\n if (typeof result2.constants.MAX_STRING_LENGTH !== \"number\") {\n result2.constants.MAX_STRING_LENGTH = maxStringLength;\n }\n if (typeof result2.kMaxLength !== \"number\") {\n result2.kMaxLength = maxLength;\n }\n if (typeof result2.kStringMaxLength !== \"number\") {\n result2.kStringMaxLength = maxStringLength;\n }\n const BufferCtor = result2.Buffer;\n if ((typeof BufferCtor === \"function\" || typeof BufferCtor === \"object\") && BufferCtor !== null) {\n if (typeof BufferCtor.kMaxLength !== \"number\") {\n BufferCtor.kMaxLength = maxLength;\n }\n if (typeof BufferCtor.kStringMaxLength !== \"number\") {\n BufferCtor.kStringMaxLength = maxStringLength;\n }\n if (typeof BufferCtor.constants !== \"object\" || BufferCtor.constants === null) {\n BufferCtor.constants = result2.constants;\n }\n }\n return result2;\n }\n if (name2 === \"util\" && typeof result2.formatWithOptions === \"undefined\" && typeof result2.format === \"function\") {\n result2.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {\n return result2.format.apply(null, args);\n };\n return result2;\n }\n if (name2 === \"url\") {\n const OriginalURL = result2.URL;\n if (typeof OriginalURL !== \"function\" || OriginalURL._patched) {\n return result2;\n }\n const PatchedURL = function PatchedURL2(url, base) {\n if (typeof url === \"string\" && url.startsWith(\"file:\") && !url.startsWith(\"file://\") && base === void 0) {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n const cwd = process.cwd();\n if (cwd) {\n try {\n return new OriginalURL(url, \"file://\" + cwd + \"/\");\n } catch (e) {\n }\n }\n }\n }\n return base !== void 0 ? new OriginalURL(url, base) : new OriginalURL(url);\n };\n Object.keys(OriginalURL).forEach(function(key) {\n try {\n PatchedURL[key] = OriginalURL[key];\n } catch {\n }\n });\n Object.setPrototypeOf(PatchedURL, OriginalURL);\n PatchedURL.prototype = OriginalURL.prototype;\n PatchedURL._patched = true;\n const descriptor = Object.getOwnPropertyDescriptor(result2, \"URL\");\n if (descriptor && descriptor.configurable !== true && descriptor.writable !== true && typeof descriptor.set !== \"function\") {\n return result2;\n }\n try {\n result2.URL = PatchedURL;\n } catch {\n try {\n Object.defineProperty(result2, \"URL\", {\n value: PatchedURL,\n writable: true,\n configurable: true,\n enumerable: descriptor?.enumerable ?? true\n });\n } catch {\n }\n }\n return result2;\n }\n if (name2 === \"path\") {\n if (result2.win32 === null || result2.win32 === void 0) {\n result2.win32 = result2.posix || result2;\n }\n if (result2.posix === null || result2.posix === void 0) {\n result2.posix = result2;\n }\n const hasAbsoluteSegment = function(args) {\n return args.some(function(arg) {\n return typeof arg === \"string\" && arg.length > 0 && arg.charAt(0) === \"/\";\n });\n };\n const prependCwd = function(args) {\n if (hasAbsoluteSegment(args)) return;\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n const cwd = process.cwd();\n if (cwd && cwd.charAt(0) === \"/\") {\n args.unshift(cwd);\n }\n }\n };\n const originalResolve = result2.resolve;\n if (typeof originalResolve === \"function\" && !originalResolve._patchedForCwd) {\n const patchedResolve = function resolve2() {\n const args = Array.from(arguments);\n prependCwd(args);\n return originalResolve.apply(this, args);\n };\n patchedResolve._patchedForCwd = true;\n result2.resolve = patchedResolve;\n }\n if (result2.posix && typeof result2.posix.resolve === \"function\" && !result2.posix.resolve._patchedForCwd) {\n const originalPosixResolve = result2.posix.resolve;\n const patchedPosixResolve = function resolve2() {\n const args = Array.from(arguments);\n prependCwd(args);\n return originalPosixResolve.apply(this, args);\n };\n patchedPosixResolve._patchedForCwd = true;\n result2.posix.resolve = patchedPosixResolve;\n }\n }\n return result2;\n }\n var _deferredCoreModules = /* @__PURE__ */ new Set([\n \"net\",\n \"tls\",\n \"readline\",\n \"perf_hooks\",\n \"async_hooks\",\n \"worker_threads\"\n ]);\n var _unsupportedCoreModules = /* @__PURE__ */ new Set([\n \"dgram\",\n \"cluster\",\n \"wasi\",\n \"diagnostics_channel\",\n \"inspector\",\n \"repl\",\n \"trace_events\",\n \"domain\"\n ]);\n function _unsupportedApiError(moduleName2, apiName) {\n return new Error(moduleName2 + \".\" + apiName + \" is not supported in sandbox\");\n }\n function _createDeferredModuleStub(moduleName2) {\n const methodCache = {};\n let stub = null;\n stub = new Proxy({}, {\n get(_target, prop) {\n if (prop === \"__esModule\") return false;\n if (prop === \"default\") return stub;\n if (prop === Symbol.toStringTag) return \"Module\";\n if (prop === \"then\") return void 0;\n if (typeof prop !== \"string\") return void 0;\n if (!methodCache[prop]) {\n methodCache[prop] = function deferredApiStub() {\n throw _unsupportedApiError(moduleName2, prop);\n };\n }\n return methodCache[prop];\n }\n });\n return stub;\n }\n var __require = function require2(moduleName2) {\n return _requireFrom(moduleName2, _currentModule.dirname);\n };\n __requireExposeCustomGlobal(\"require\", __require);\n function _resolveFrom(moduleName2, fromDir2) {\n const resolved2 = _resolveModule.applySyncPromise(void 0, [moduleName2, fromDir2]);\n if (resolved2 === null) {\n const err = new Error(\"Cannot find module '\" + moduleName2 + \"'\");\n err.code = \"MODULE_NOT_FOUND\";\n throw err;\n }\n return resolved2;\n }\n globalThis.require.resolve = function resolve(moduleName2) {\n return _resolveFrom(moduleName2, _currentModule.dirname);\n };\n globalThis.require.cache = _moduleCache;\n function _debugRequire(phase, moduleName2, extra) {\n if (globalThis.__sandboxRequireDebug !== true) {\n return;\n }\n if (moduleName2 !== \"rivetkit\" && moduleName2 !== \"@rivetkit/traces\" && moduleName2 !== \"@rivetkit/on-change\" && moduleName2 !== \"async_hooks\" && !moduleName2.startsWith(\"rivetkit/\") && !moduleName2.startsWith(\"@rivetkit/\")) {\n return;\n }\n if (typeof console !== \"undefined\" && typeof console.log === \"function\") {\n console.log(\n \"[sandbox.require] \" + phase + \" \" + moduleName2 + (extra ? \" \" + extra : \"\")\n );\n }\n }\n function _requireFrom(moduleName, fromDir) {\n _debugRequire(\"start\", moduleName, fromDir);\n const name = moduleName.replace(/^node:/, \"\");\n let cacheKey = name;\n let resolved = null;\n const isRelative = name.startsWith(\"./\") || name.startsWith(\"../\");\n if (!isRelative && _moduleCache[name]) {\n _debugRequire(\"cache-hit\", name, name);\n return _moduleCache[name];\n }\n if (name === \"fs\") {\n if (_moduleCache[\"fs\"]) return _moduleCache[\"fs\"];\n const fsModule = globalThis.bridge?.fs || globalThis.bridge?.default || globalThis._fsModule || {};\n _moduleCache[\"fs\"] = fsModule;\n _debugRequire(\"loaded\", name, \"fs-special\");\n return fsModule;\n }\n if (name === \"fs/promises\") {\n if (_moduleCache[\"fs/promises\"]) return _moduleCache[\"fs/promises\"];\n const fsModule = _requireFrom(\"fs\", fromDir);\n _moduleCache[\"fs/promises\"] = fsModule.promises;\n _debugRequire(\"loaded\", name, \"fs-promises-special\");\n return fsModule.promises;\n }\n if (name === \"stream/promises\") {\n if (_moduleCache[\"stream/promises\"]) return _moduleCache[\"stream/promises\"];\n const streamModule = _requireFrom(\"stream\", fromDir);\n const promisesModule = {\n finished(stream, options) {\n return new Promise(function(resolve2, reject) {\n if (typeof streamModule.finished !== \"function\") {\n resolve2();\n return;\n }\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\n streamModule.finished(stream, options, function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n return;\n }\n streamModule.finished(stream, function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n });\n },\n pipeline() {\n const args = Array.prototype.slice.call(arguments);\n return new Promise(function(resolve2, reject) {\n if (typeof streamModule.pipeline !== \"function\") {\n reject(new Error(\"stream.pipeline is not supported in sandbox\"));\n return;\n }\n args.push(function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n streamModule.pipeline.apply(streamModule, args);\n });\n }\n };\n _moduleCache[\"stream/promises\"] = promisesModule;\n _debugRequire(\"loaded\", name, \"stream-promises-special\");\n return promisesModule;\n }\n if (name === \"child_process\") {\n if (_moduleCache[\"child_process\"]) return _moduleCache[\"child_process\"];\n _moduleCache[\"child_process\"] = _childProcessModule;\n _debugRequire(\"loaded\", name, \"child-process-special\");\n return _childProcessModule;\n }\n if (name === \"http\") {\n if (_moduleCache[\"http\"]) return _moduleCache[\"http\"];\n _moduleCache[\"http\"] = _httpModule;\n _debugRequire(\"loaded\", name, \"http-special\");\n return _httpModule;\n }\n if (name === \"https\") {\n if (_moduleCache[\"https\"]) return _moduleCache[\"https\"];\n _moduleCache[\"https\"] = _httpsModule;\n _debugRequire(\"loaded\", name, \"https-special\");\n return _httpsModule;\n }\n if (name === \"http2\") {\n if (_moduleCache[\"http2\"]) return _moduleCache[\"http2\"];\n _moduleCache[\"http2\"] = _http2Module;\n _debugRequire(\"loaded\", name, \"http2-special\");\n return _http2Module;\n }\n if (name === \"dns\") {\n if (_moduleCache[\"dns\"]) return _moduleCache[\"dns\"];\n _moduleCache[\"dns\"] = _dnsModule;\n _debugRequire(\"loaded\", name, \"dns-special\");\n return _dnsModule;\n }\n if (name === \"os\") {\n if (_moduleCache[\"os\"]) return _moduleCache[\"os\"];\n _moduleCache[\"os\"] = _osModule;\n _debugRequire(\"loaded\", name, \"os-special\");\n return _osModule;\n }\n if (name === \"module\") {\n if (_moduleCache[\"module\"]) return _moduleCache[\"module\"];\n _moduleCache[\"module\"] = _moduleModule;\n _debugRequire(\"loaded\", name, \"module-special\");\n return _moduleModule;\n }\n if (name === \"process\") {\n _debugRequire(\"loaded\", name, \"process-special\");\n return globalThis.process;\n }\n if (name === \"async_hooks\") {\n if (_moduleCache[\"async_hooks\"]) return _moduleCache[\"async_hooks\"];\n class AsyncLocalStorage {\n constructor() {\n this._store = void 0;\n }\n run(store, callback) {\n const previousStore = this._store;\n this._store = store;\n try {\n const args = Array.prototype.slice.call(arguments, 2);\n return callback.apply(void 0, args);\n } finally {\n this._store = previousStore;\n }\n }\n enterWith(store) {\n this._store = store;\n }\n getStore() {\n return this._store;\n }\n disable() {\n this._store = void 0;\n }\n exit(callback) {\n const previousStore = this._store;\n this._store = void 0;\n try {\n const args = Array.prototype.slice.call(arguments, 1);\n return callback.apply(void 0, args);\n } finally {\n this._store = previousStore;\n }\n }\n }\n class AsyncResource {\n constructor(type) {\n this.type = type;\n }\n runInAsyncScope(callback, thisArg) {\n const args = Array.prototype.slice.call(arguments, 2);\n return callback.apply(thisArg, args);\n }\n emitDestroy() {\n }\n }\n const asyncHooksModule = {\n AsyncLocalStorage,\n AsyncResource,\n createHook() {\n return {\n enable() {\n return this;\n },\n disable() {\n return this;\n }\n };\n },\n executionAsyncId() {\n return 1;\n },\n triggerAsyncId() {\n return 0;\n },\n executionAsyncResource() {\n return null;\n }\n };\n _moduleCache[\"async_hooks\"] = asyncHooksModule;\n _debugRequire(\"loaded\", name, \"async-hooks-special\");\n return asyncHooksModule;\n }\n if (_deferredCoreModules.has(name)) {\n if (_moduleCache[name]) return _moduleCache[name];\n const deferredStub = _createDeferredModuleStub(name);\n _moduleCache[name] = deferredStub;\n _debugRequire(\"loaded\", name, \"deferred-stub\");\n return deferredStub;\n }\n if (_unsupportedCoreModules.has(name)) {\n throw new Error(name + \" is not supported in sandbox\");\n }\n const polyfillCode = _loadPolyfill.applySyncPromise(void 0, [name]);\n if (polyfillCode !== null) {\n if (_moduleCache[name]) return _moduleCache[name];\n const moduleObj = { exports: {} };\n _pendingModules[name] = moduleObj;\n let result = eval(polyfillCode);\n result = _patchPolyfill(name, result);\n if (typeof result === \"object\" && result !== null) {\n Object.assign(moduleObj.exports, result);\n } else {\n moduleObj.exports = result;\n }\n _moduleCache[name] = moduleObj.exports;\n delete _pendingModules[name];\n _debugRequire(\"loaded\", name, \"polyfill\");\n return _moduleCache[name];\n }\n resolved = _resolveFrom(name, fromDir);\n cacheKey = resolved;\n if (_moduleCache[cacheKey]) {\n _debugRequire(\"cache-hit\", name, cacheKey);\n return _moduleCache[cacheKey];\n }\n if (_pendingModules[cacheKey]) {\n _debugRequire(\"pending-hit\", name, cacheKey);\n return _pendingModules[cacheKey].exports;\n }\n const source = _loadFile.applySyncPromise(void 0, [resolved]);\n if (source === null) {\n const err = new Error(\"Cannot find module '\" + resolved + \"'\");\n err.code = \"MODULE_NOT_FOUND\";\n throw err;\n }\n if (resolved.endsWith(\".json\")) {\n const parsed = JSON.parse(source);\n _moduleCache[cacheKey] = parsed;\n return parsed;\n }\n const normalizedSource = typeof source === \"string\" ? source.replace(/import\\.meta\\.url/g, \"__filename\").replace(/fileURLToPath\\(__filename\\)/g, \"__filename\").replace(/url\\.fileURLToPath\\(__filename\\)/g, \"__filename\").replace(/fileURLToPath\\.call\\(void 0, __filename\\)/g, \"__filename\") : source;\n const module = {\n exports: {},\n filename: resolved,\n dirname: _dirname(resolved),\n id: resolved,\n loaded: false\n };\n _pendingModules[cacheKey] = module;\n const prevModule = _currentModule;\n _currentModule = module;\n try {\n let wrapper;\n try {\n wrapper = new Function(\n \"exports\",\n \"require\",\n \"module\",\n \"__filename\",\n \"__dirname\",\n \"__dynamicImport\",\n normalizedSource + \"\\n//# sourceURL=\" + resolved\n );\n } catch (error) {\n const details = error && error.stack ? error.stack : String(error);\n throw new Error(\"failed to compile module \" + resolved + \": \" + details);\n }\n const moduleRequire = function(request) {\n return _requireFrom(request, module.dirname);\n };\n moduleRequire.resolve = function(request) {\n return _resolveFrom(request, module.dirname);\n };\n const moduleDynamicImport = function(specifier) {\n if (typeof globalThis.__dynamicImport === \"function\") {\n return globalThis.__dynamicImport(specifier, module.dirname);\n }\n return Promise.reject(new Error(\"Dynamic import is not initialized\"));\n };\n wrapper(\n module.exports,\n moduleRequire,\n module,\n resolved,\n module.dirname,\n moduleDynamicImport\n );\n module.loaded = true;\n } catch (error) {\n const details = error && error.stack ? error.stack : String(error);\n throw new Error(\"failed to execute module \" + resolved + \": \" + details);\n } finally {\n _currentModule = prevModule;\n }\n _moduleCache[cacheKey] = module.exports;\n delete _pendingModules[cacheKey];\n _debugRequire(\"loaded\", name, cacheKey);\n return module.exports;\n }\n __requireExposeCustomGlobal(\"_requireFrom\", _requireFrom);\n})();\n";
|
|
13
|
+
readonly setCommonjsFileGlobals: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/set-commonjs-file-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __commonJsFileConfig = globalThis.__runtimeCommonJsFileConfig ?? {};\n var __filePath = typeof __commonJsFileConfig.filePath === \"string\" ? __commonJsFileConfig.filePath : \"/<entry>.js\";\n var __dirname = typeof __commonJsFileConfig.dirname === \"string\" ? __commonJsFileConfig.dirname : \"/\";\n __runtimeExposeMutableGlobal(\"__filename\", __filePath);\n __runtimeExposeMutableGlobal(\"__dirname\", __dirname);\n var __currentModule = globalThis._currentModule;\n if (__currentModule) {\n __currentModule.dirname = __dirname;\n __currentModule.filename = __filePath;\n }\n})();\n";
|
|
14
|
+
readonly setStdinData: "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/set-stdin-data.ts\n if (typeof globalThis._stdinData !== \"undefined\") {\n globalThis._stdinData = globalThis.__runtimeStdinData;\n globalThis._stdinPosition = 0;\n globalThis._stdinEnded = false;\n globalThis._stdinFlowMode = false;\n }\n})();\n";
|
|
15
|
+
readonly setupDynamicImport: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function isObjectLike(value) {\n return value !== null && (typeof value === \"object\" || typeof value === \"function\");\n }\n\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/setup-dynamic-import.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __dynamicImportConfig = globalThis.__runtimeDynamicImportConfig ?? {};\n var __fallbackReferrer = typeof __dynamicImportConfig.referrerPath === \"string\" && __dynamicImportConfig.referrerPath.length > 0 ? __dynamicImportConfig.referrerPath : \"/\";\n var __dynamicImportHandler = async function(specifier, fromPath) {\n const request = String(specifier);\n const referrer = typeof fromPath === \"string\" && fromPath.length > 0 ? fromPath : __fallbackReferrer;\n const allowRequireFallback = request.endsWith(\".cjs\") || request.endsWith(\".json\");\n const namespace = await globalThis._dynamicImport.apply(\n void 0,\n [request, referrer],\n { result: { promise: true } }\n );\n if (namespace !== null) {\n return namespace;\n }\n if (!allowRequireFallback) {\n throw new Error(\"Cannot find module '\" + request + \"'\");\n }\n const runtimeRequire = globalThis.require;\n if (typeof runtimeRequire !== \"function\") {\n throw new Error(\"Cannot find module '\" + request + \"'\");\n }\n const mod = runtimeRequire(request);\n const namespaceFallback = { default: mod };\n if (isObjectLike(mod)) {\n for (const key of Object.keys(mod)) {\n if (!(key in namespaceFallback)) {\n namespaceFallback[key] = mod[key];\n }\n }\n }\n return namespaceFallback;\n };\n __runtimeExposeCustomGlobal(\"__dynamicImport\", __dynamicImportHandler);\n})();\n";
|
|
16
|
+
readonly setupFsFacade: "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/setup-fs-facade.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __fsFacade = {\n readFile: globalThis._fsReadFile,\n writeFile: globalThis._fsWriteFile,\n readFileBinary: globalThis._fsReadFileBinary,\n writeFileBinary: globalThis._fsWriteFileBinary,\n readDir: globalThis._fsReadDir,\n mkdir: globalThis._fsMkdir,\n rmdir: globalThis._fsRmdir,\n exists: globalThis._fsExists,\n stat: globalThis._fsStat,\n unlink: globalThis._fsUnlink,\n rename: globalThis._fsRename\n };\n __runtimeExposeCustomGlobal(\"_fs\", __fsFacade);\n})();\n";
|
|
17
|
+
};
|
|
18
|
+
export type IsolateRuntimeSourceId = keyof typeof ISOLATE_RUNTIME_SOURCES;
|
|
19
|
+
export declare function getIsolateRuntimeSource(id: IsolateRuntimeSourceId): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Auto-generated by scripts/build-isolate-runtime.mjs. Do not edit manually.
|
|
2
|
+
export const ISOLATE_RUNTIME_SOURCES = {
|
|
3
|
+
"applyCustomGlobalPolicy": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function hasOwnGlobal(name) {\n return Object.prototype.hasOwnProperty.call(globalThis, name);\n }\n function getGlobalValue(name) {\n return Reflect.get(globalThis, name);\n }\n\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/apply-custom-global-policy.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __globalPolicy = globalThis.__runtimeCustomGlobalPolicy ?? {};\n var __hardenedGlobals = Array.isArray(__globalPolicy.hardenedGlobals) ? __globalPolicy.hardenedGlobals : [];\n var __mutableGlobals = Array.isArray(__globalPolicy.mutableGlobals) ? __globalPolicy.mutableGlobals : [];\n for (const globalName of __hardenedGlobals) {\n if (hasOwnGlobal(globalName)) {\n __runtimeExposeCustomGlobal(globalName, getGlobalValue(globalName));\n }\n }\n for (const globalName of __mutableGlobals) {\n if (hasOwnGlobal(globalName)) {\n __runtimeExposeMutableGlobal(globalName, getGlobalValue(globalName));\n }\n }\n})();\n",
|
|
4
|
+
"applyTimingMitigationFreeze": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function setGlobalValue(name, value) {\n Reflect.set(globalThis, name, value);\n }\n\n // isolate-runtime/src/inject/apply-timing-mitigation-freeze.ts\n var __timingConfig = globalThis.__runtimeTimingMitigationConfig ?? {};\n var __frozenTimeMs = typeof __timingConfig.frozenTimeMs === \"number\" && Number.isFinite(__timingConfig.frozenTimeMs) ? __timingConfig.frozenTimeMs : Date.now();\n var __frozenDateNow = () => __frozenTimeMs;\n try {\n Object.defineProperty(Date, \"now\", {\n value: __frozenDateNow,\n configurable: true,\n writable: true\n });\n } catch {\n Date.now = __frozenDateNow;\n }\n var __frozenPerformanceNow = () => 0;\n var __performance = globalThis.performance;\n if (typeof __performance !== \"undefined\" && __performance !== null) {\n try {\n Object.defineProperty(__performance, \"now\", {\n value: __frozenPerformanceNow,\n configurable: true,\n writable: true\n });\n } catch {\n try {\n Object.assign(__performance, { now: __frozenPerformanceNow });\n } catch {\n }\n }\n } else {\n setGlobalValue(\"performance\", {\n now: __frozenPerformanceNow\n });\n }\n if (!Reflect.deleteProperty(globalThis, \"SharedArrayBuffer\")) {\n setGlobalValue(\"SharedArrayBuffer\", void 0);\n }\n})();\n",
|
|
5
|
+
"applyTimingMitigationOff": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function setGlobalValue(name, value) {\n Reflect.set(globalThis, name, value);\n }\n\n // isolate-runtime/src/inject/apply-timing-mitigation-off.ts\n if (typeof globalThis.performance === \"undefined\" || globalThis.performance === null) {\n setGlobalValue(\"performance\", {\n now: () => Date.now()\n });\n }\n})();\n",
|
|
6
|
+
"bridgeAttach": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/bridge-attach.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n if (typeof globalThis.bridge !== \"undefined\") {\n __runtimeExposeCustomGlobal(\"bridge\", globalThis.bridge);\n }\n})();\n",
|
|
7
|
+
"bridgeInitialGlobals": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/bridge-initial-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __bridgeSetupConfig = globalThis.__runtimeBridgeSetupConfig ?? {};\n var __initialCwd = typeof __bridgeSetupConfig.initialCwd === \"string\" ? __bridgeSetupConfig.initialCwd : \"/\";\n var __jsonPayloadLimitBytes = typeof __bridgeSetupConfig.jsonPayloadLimitBytes === \"number\" && Number.isFinite(__bridgeSetupConfig.jsonPayloadLimitBytes) ? Math.max(0, Math.floor(__bridgeSetupConfig.jsonPayloadLimitBytes)) : 4 * 1024 * 1024;\n var __payloadLimitErrorCode = typeof __bridgeSetupConfig.payloadLimitErrorCode === \"string\" && __bridgeSetupConfig.payloadLimitErrorCode.length > 0 ? __bridgeSetupConfig.payloadLimitErrorCode : \"ERR_SANDBOX_PAYLOAD_TOO_LARGE\";\n __runtimeExposeMutableGlobal(\"_moduleCache\", {});\n globalThis._moduleCache = globalThis._moduleCache ?? {};\n var __moduleCache = globalThis._moduleCache;\n if (__moduleCache) {\n __moduleCache[\"v8\"] = {\n getHeapStatistics: function() {\n return {\n total_heap_size: 67108864,\n total_heap_size_executable: 1048576,\n total_physical_size: 67108864,\n total_available_size: 67108864,\n used_heap_size: 52428800,\n heap_size_limit: 134217728,\n malloced_memory: 8192,\n peak_malloced_memory: 16384,\n does_zap_garbage: 0,\n number_of_native_contexts: 1,\n number_of_detached_contexts: 0,\n external_memory: 0\n };\n },\n getHeapSpaceStatistics: function() {\n return [];\n },\n getHeapCodeStatistics: function() {\n return {};\n },\n setFlagsFromString: function() {\n },\n serialize: function(value) {\n return Buffer.from(JSON.stringify(value));\n },\n deserialize: function(buffer) {\n const text = buffer.toString();\n if (Buffer.byteLength(text, \"utf8\") > __jsonPayloadLimitBytes) {\n throw new Error(\n __payloadLimitErrorCode + \": v8.deserialize exceeds \" + String(__jsonPayloadLimitBytes) + \" bytes\"\n );\n }\n return JSON.parse(text);\n },\n cachedDataVersionTag: function() {\n return 0;\n }\n };\n }\n __runtimeExposeMutableGlobal(\"_pendingModules\", {});\n __runtimeExposeMutableGlobal(\"_currentModule\", { dirname: __initialCwd });\n})();\n",
|
|
8
|
+
"evalScriptResult": "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/eval-script-result.ts\n var __runtimeIndirectEval = globalThis.eval;\n globalThis.__scriptResult__ = __runtimeIndirectEval(\n String(globalThis.__runtimeExecCode)\n );\n})();\n",
|
|
9
|
+
"globalExposureHelpers": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function ensureRuntimeExposureHelpers() {\n if (typeof globalThis.__runtimeExposeCustomGlobal !== \"function\") {\n defineRuntimeGlobalBinding(\n \"__runtimeExposeCustomGlobal\",\n createRuntimeGlobalExposer(false),\n false\n );\n }\n if (typeof globalThis.__runtimeExposeMutableGlobal !== \"function\") {\n defineRuntimeGlobalBinding(\n \"__runtimeExposeMutableGlobal\",\n createRuntimeGlobalExposer(true),\n false\n );\n }\n }\n\n // isolate-runtime/src/inject/global-exposure-helpers.ts\n ensureRuntimeExposureHelpers();\n})();\n",
|
|
10
|
+
"initCommonjsModuleGlobals": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/init-commonjs-module-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n __runtimeExposeMutableGlobal(\"module\", { exports: {} });\n __runtimeExposeMutableGlobal(\"exports\", globalThis.module.exports);\n})();\n",
|
|
11
|
+
"overrideProcessCwd": "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/override-process-cwd.ts\n var __cwd = globalThis.__runtimeProcessCwdOverride;\n if (typeof __cwd === \"string\") {\n process.cwd = () => __cwd;\n }\n})();\n",
|
|
12
|
+
"overrideProcessEnv": "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/override-process-env.ts\n var __envPatch = globalThis.__runtimeProcessEnvOverride;\n if (__envPatch && typeof __envPatch === \"object\") {\n Object.assign(process.env, __envPatch);\n }\n})();\n",
|
|
13
|
+
"requireSetup": "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/require-setup.ts\n var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === \"function\" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name2, value) {\n Object.defineProperty(globalThis, name2, {\n value,\n writable: false,\n configurable: false,\n enumerable: true\n });\n };\n if (typeof globalThis.AbortController === \"undefined\" || typeof globalThis.AbortSignal === \"undefined\") {\n class AbortSignal {\n constructor() {\n this.aborted = false;\n this.reason = void 0;\n this.onabort = null;\n this._listeners = [];\n }\n addEventListener(type, listener) {\n if (type !== \"abort\" || typeof listener !== \"function\") return;\n this._listeners.push(listener);\n }\n removeEventListener(type, listener) {\n if (type !== \"abort\" || typeof listener !== \"function\") return;\n const index = this._listeners.indexOf(listener);\n if (index !== -1) {\n this._listeners.splice(index, 1);\n }\n }\n dispatchEvent(event) {\n if (!event || event.type !== \"abort\") return false;\n if (typeof this.onabort === \"function\") {\n try {\n this.onabort.call(this, event);\n } catch {\n }\n }\n const listeners = this._listeners.slice();\n for (const listener of listeners) {\n try {\n listener.call(this, event);\n } catch {\n }\n }\n return true;\n }\n }\n class AbortController {\n constructor() {\n this.signal = new AbortSignal();\n }\n abort(reason) {\n if (this.signal.aborted) return;\n this.signal.aborted = true;\n this.signal.reason = reason;\n this.signal.dispatchEvent({ type: \"abort\" });\n }\n }\n __requireExposeCustomGlobal(\"AbortSignal\", AbortSignal);\n __requireExposeCustomGlobal(\"AbortController\", AbortController);\n }\n if (typeof globalThis.structuredClone !== \"function\") {\n let structuredClonePolyfill = function(value) {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n if (value instanceof ArrayBuffer) {\n return value.slice(0);\n }\n if (ArrayBuffer.isView(value)) {\n if (value instanceof Uint8Array) {\n return new Uint8Array(value);\n }\n return new value.constructor(value);\n }\n return JSON.parse(JSON.stringify(value));\n };\n structuredClonePolyfill2 = structuredClonePolyfill;\n __requireExposeCustomGlobal(\"structuredClone\", structuredClonePolyfill);\n }\n var structuredClonePolyfill2;\n if (typeof globalThis.btoa !== \"function\") {\n __requireExposeCustomGlobal(\"btoa\", function btoa(input) {\n return Buffer.from(String(input), \"binary\").toString(\"base64\");\n });\n }\n if (typeof globalThis.atob !== \"function\") {\n __requireExposeCustomGlobal(\"atob\", function atob(input) {\n return Buffer.from(String(input), \"base64\").toString(\"binary\");\n });\n }\n function _dirname(p) {\n const lastSlash = p.lastIndexOf(\"/\");\n if (lastSlash === -1) return \".\";\n if (lastSlash === 0) return \"/\";\n return p.slice(0, lastSlash);\n }\n function _patchPolyfill(name2, result2) {\n if (typeof result2 !== \"object\" && typeof result2 !== \"function\" || result2 === null) {\n return result2;\n }\n if (name2 === \"buffer\") {\n const maxLength = typeof result2.kMaxLength === \"number\" ? result2.kMaxLength : 2147483647;\n const maxStringLength = typeof result2.kStringMaxLength === \"number\" ? result2.kStringMaxLength : 536870888;\n if (typeof result2.constants !== \"object\" || result2.constants === null) {\n result2.constants = {};\n }\n if (typeof result2.constants.MAX_LENGTH !== \"number\") {\n result2.constants.MAX_LENGTH = maxLength;\n }\n if (typeof result2.constants.MAX_STRING_LENGTH !== \"number\") {\n result2.constants.MAX_STRING_LENGTH = maxStringLength;\n }\n if (typeof result2.kMaxLength !== \"number\") {\n result2.kMaxLength = maxLength;\n }\n if (typeof result2.kStringMaxLength !== \"number\") {\n result2.kStringMaxLength = maxStringLength;\n }\n const BufferCtor = result2.Buffer;\n if ((typeof BufferCtor === \"function\" || typeof BufferCtor === \"object\") && BufferCtor !== null) {\n if (typeof BufferCtor.kMaxLength !== \"number\") {\n BufferCtor.kMaxLength = maxLength;\n }\n if (typeof BufferCtor.kStringMaxLength !== \"number\") {\n BufferCtor.kStringMaxLength = maxStringLength;\n }\n if (typeof BufferCtor.constants !== \"object\" || BufferCtor.constants === null) {\n BufferCtor.constants = result2.constants;\n }\n }\n return result2;\n }\n if (name2 === \"util\" && typeof result2.formatWithOptions === \"undefined\" && typeof result2.format === \"function\") {\n result2.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {\n return result2.format.apply(null, args);\n };\n return result2;\n }\n if (name2 === \"url\") {\n const OriginalURL = result2.URL;\n if (typeof OriginalURL !== \"function\" || OriginalURL._patched) {\n return result2;\n }\n const PatchedURL = function PatchedURL2(url, base) {\n if (typeof url === \"string\" && url.startsWith(\"file:\") && !url.startsWith(\"file://\") && base === void 0) {\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n const cwd = process.cwd();\n if (cwd) {\n try {\n return new OriginalURL(url, \"file://\" + cwd + \"/\");\n } catch (e) {\n }\n }\n }\n }\n return base !== void 0 ? new OriginalURL(url, base) : new OriginalURL(url);\n };\n Object.keys(OriginalURL).forEach(function(key) {\n try {\n PatchedURL[key] = OriginalURL[key];\n } catch {\n }\n });\n Object.setPrototypeOf(PatchedURL, OriginalURL);\n PatchedURL.prototype = OriginalURL.prototype;\n PatchedURL._patched = true;\n const descriptor = Object.getOwnPropertyDescriptor(result2, \"URL\");\n if (descriptor && descriptor.configurable !== true && descriptor.writable !== true && typeof descriptor.set !== \"function\") {\n return result2;\n }\n try {\n result2.URL = PatchedURL;\n } catch {\n try {\n Object.defineProperty(result2, \"URL\", {\n value: PatchedURL,\n writable: true,\n configurable: true,\n enumerable: descriptor?.enumerable ?? true\n });\n } catch {\n }\n }\n return result2;\n }\n if (name2 === \"path\") {\n if (result2.win32 === null || result2.win32 === void 0) {\n result2.win32 = result2.posix || result2;\n }\n if (result2.posix === null || result2.posix === void 0) {\n result2.posix = result2;\n }\n const hasAbsoluteSegment = function(args) {\n return args.some(function(arg) {\n return typeof arg === \"string\" && arg.length > 0 && arg.charAt(0) === \"/\";\n });\n };\n const prependCwd = function(args) {\n if (hasAbsoluteSegment(args)) return;\n if (typeof process !== \"undefined\" && typeof process.cwd === \"function\") {\n const cwd = process.cwd();\n if (cwd && cwd.charAt(0) === \"/\") {\n args.unshift(cwd);\n }\n }\n };\n const originalResolve = result2.resolve;\n if (typeof originalResolve === \"function\" && !originalResolve._patchedForCwd) {\n const patchedResolve = function resolve2() {\n const args = Array.from(arguments);\n prependCwd(args);\n return originalResolve.apply(this, args);\n };\n patchedResolve._patchedForCwd = true;\n result2.resolve = patchedResolve;\n }\n if (result2.posix && typeof result2.posix.resolve === \"function\" && !result2.posix.resolve._patchedForCwd) {\n const originalPosixResolve = result2.posix.resolve;\n const patchedPosixResolve = function resolve2() {\n const args = Array.from(arguments);\n prependCwd(args);\n return originalPosixResolve.apply(this, args);\n };\n patchedPosixResolve._patchedForCwd = true;\n result2.posix.resolve = patchedPosixResolve;\n }\n }\n return result2;\n }\n var _deferredCoreModules = /* @__PURE__ */ new Set([\n \"net\",\n \"tls\",\n \"readline\",\n \"perf_hooks\",\n \"async_hooks\",\n \"worker_threads\"\n ]);\n var _unsupportedCoreModules = /* @__PURE__ */ new Set([\n \"dgram\",\n \"cluster\",\n \"wasi\",\n \"diagnostics_channel\",\n \"inspector\",\n \"repl\",\n \"trace_events\",\n \"domain\"\n ]);\n function _unsupportedApiError(moduleName2, apiName) {\n return new Error(moduleName2 + \".\" + apiName + \" is not supported in sandbox\");\n }\n function _createDeferredModuleStub(moduleName2) {\n const methodCache = {};\n let stub = null;\n stub = new Proxy({}, {\n get(_target, prop) {\n if (prop === \"__esModule\") return false;\n if (prop === \"default\") return stub;\n if (prop === Symbol.toStringTag) return \"Module\";\n if (prop === \"then\") return void 0;\n if (typeof prop !== \"string\") return void 0;\n if (!methodCache[prop]) {\n methodCache[prop] = function deferredApiStub() {\n throw _unsupportedApiError(moduleName2, prop);\n };\n }\n return methodCache[prop];\n }\n });\n return stub;\n }\n var __require = function require2(moduleName2) {\n return _requireFrom(moduleName2, _currentModule.dirname);\n };\n __requireExposeCustomGlobal(\"require\", __require);\n function _resolveFrom(moduleName2, fromDir2) {\n const resolved2 = _resolveModule.applySyncPromise(void 0, [moduleName2, fromDir2]);\n if (resolved2 === null) {\n const err = new Error(\"Cannot find module '\" + moduleName2 + \"'\");\n err.code = \"MODULE_NOT_FOUND\";\n throw err;\n }\n return resolved2;\n }\n globalThis.require.resolve = function resolve(moduleName2) {\n return _resolveFrom(moduleName2, _currentModule.dirname);\n };\n globalThis.require.cache = _moduleCache;\n function _debugRequire(phase, moduleName2, extra) {\n if (globalThis.__sandboxRequireDebug !== true) {\n return;\n }\n if (moduleName2 !== \"rivetkit\" && moduleName2 !== \"@rivetkit/traces\" && moduleName2 !== \"@rivetkit/on-change\" && moduleName2 !== \"async_hooks\" && !moduleName2.startsWith(\"rivetkit/\") && !moduleName2.startsWith(\"@rivetkit/\")) {\n return;\n }\n if (typeof console !== \"undefined\" && typeof console.log === \"function\") {\n console.log(\n \"[sandbox.require] \" + phase + \" \" + moduleName2 + (extra ? \" \" + extra : \"\")\n );\n }\n }\n function _requireFrom(moduleName, fromDir) {\n _debugRequire(\"start\", moduleName, fromDir);\n const name = moduleName.replace(/^node:/, \"\");\n let cacheKey = name;\n let resolved = null;\n const isRelative = name.startsWith(\"./\") || name.startsWith(\"../\");\n if (!isRelative && _moduleCache[name]) {\n _debugRequire(\"cache-hit\", name, name);\n return _moduleCache[name];\n }\n if (name === \"fs\") {\n if (_moduleCache[\"fs\"]) return _moduleCache[\"fs\"];\n const fsModule = globalThis.bridge?.fs || globalThis.bridge?.default || globalThis._fsModule || {};\n _moduleCache[\"fs\"] = fsModule;\n _debugRequire(\"loaded\", name, \"fs-special\");\n return fsModule;\n }\n if (name === \"fs/promises\") {\n if (_moduleCache[\"fs/promises\"]) return _moduleCache[\"fs/promises\"];\n const fsModule = _requireFrom(\"fs\", fromDir);\n _moduleCache[\"fs/promises\"] = fsModule.promises;\n _debugRequire(\"loaded\", name, \"fs-promises-special\");\n return fsModule.promises;\n }\n if (name === \"stream/promises\") {\n if (_moduleCache[\"stream/promises\"]) return _moduleCache[\"stream/promises\"];\n const streamModule = _requireFrom(\"stream\", fromDir);\n const promisesModule = {\n finished(stream, options) {\n return new Promise(function(resolve2, reject) {\n if (typeof streamModule.finished !== \"function\") {\n resolve2();\n return;\n }\n if (options && typeof options === \"object\" && !Array.isArray(options)) {\n streamModule.finished(stream, options, function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n return;\n }\n streamModule.finished(stream, function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n });\n },\n pipeline() {\n const args = Array.prototype.slice.call(arguments);\n return new Promise(function(resolve2, reject) {\n if (typeof streamModule.pipeline !== \"function\") {\n reject(new Error(\"stream.pipeline is not supported in sandbox\"));\n return;\n }\n args.push(function(error) {\n if (error) {\n reject(error);\n return;\n }\n resolve2();\n });\n streamModule.pipeline.apply(streamModule, args);\n });\n }\n };\n _moduleCache[\"stream/promises\"] = promisesModule;\n _debugRequire(\"loaded\", name, \"stream-promises-special\");\n return promisesModule;\n }\n if (name === \"child_process\") {\n if (_moduleCache[\"child_process\"]) return _moduleCache[\"child_process\"];\n _moduleCache[\"child_process\"] = _childProcessModule;\n _debugRequire(\"loaded\", name, \"child-process-special\");\n return _childProcessModule;\n }\n if (name === \"http\") {\n if (_moduleCache[\"http\"]) return _moduleCache[\"http\"];\n _moduleCache[\"http\"] = _httpModule;\n _debugRequire(\"loaded\", name, \"http-special\");\n return _httpModule;\n }\n if (name === \"https\") {\n if (_moduleCache[\"https\"]) return _moduleCache[\"https\"];\n _moduleCache[\"https\"] = _httpsModule;\n _debugRequire(\"loaded\", name, \"https-special\");\n return _httpsModule;\n }\n if (name === \"http2\") {\n if (_moduleCache[\"http2\"]) return _moduleCache[\"http2\"];\n _moduleCache[\"http2\"] = _http2Module;\n _debugRequire(\"loaded\", name, \"http2-special\");\n return _http2Module;\n }\n if (name === \"dns\") {\n if (_moduleCache[\"dns\"]) return _moduleCache[\"dns\"];\n _moduleCache[\"dns\"] = _dnsModule;\n _debugRequire(\"loaded\", name, \"dns-special\");\n return _dnsModule;\n }\n if (name === \"os\") {\n if (_moduleCache[\"os\"]) return _moduleCache[\"os\"];\n _moduleCache[\"os\"] = _osModule;\n _debugRequire(\"loaded\", name, \"os-special\");\n return _osModule;\n }\n if (name === \"module\") {\n if (_moduleCache[\"module\"]) return _moduleCache[\"module\"];\n _moduleCache[\"module\"] = _moduleModule;\n _debugRequire(\"loaded\", name, \"module-special\");\n return _moduleModule;\n }\n if (name === \"process\") {\n _debugRequire(\"loaded\", name, \"process-special\");\n return globalThis.process;\n }\n if (name === \"async_hooks\") {\n if (_moduleCache[\"async_hooks\"]) return _moduleCache[\"async_hooks\"];\n class AsyncLocalStorage {\n constructor() {\n this._store = void 0;\n }\n run(store, callback) {\n const previousStore = this._store;\n this._store = store;\n try {\n const args = Array.prototype.slice.call(arguments, 2);\n return callback.apply(void 0, args);\n } finally {\n this._store = previousStore;\n }\n }\n enterWith(store) {\n this._store = store;\n }\n getStore() {\n return this._store;\n }\n disable() {\n this._store = void 0;\n }\n exit(callback) {\n const previousStore = this._store;\n this._store = void 0;\n try {\n const args = Array.prototype.slice.call(arguments, 1);\n return callback.apply(void 0, args);\n } finally {\n this._store = previousStore;\n }\n }\n }\n class AsyncResource {\n constructor(type) {\n this.type = type;\n }\n runInAsyncScope(callback, thisArg) {\n const args = Array.prototype.slice.call(arguments, 2);\n return callback.apply(thisArg, args);\n }\n emitDestroy() {\n }\n }\n const asyncHooksModule = {\n AsyncLocalStorage,\n AsyncResource,\n createHook() {\n return {\n enable() {\n return this;\n },\n disable() {\n return this;\n }\n };\n },\n executionAsyncId() {\n return 1;\n },\n triggerAsyncId() {\n return 0;\n },\n executionAsyncResource() {\n return null;\n }\n };\n _moduleCache[\"async_hooks\"] = asyncHooksModule;\n _debugRequire(\"loaded\", name, \"async-hooks-special\");\n return asyncHooksModule;\n }\n if (_deferredCoreModules.has(name)) {\n if (_moduleCache[name]) return _moduleCache[name];\n const deferredStub = _createDeferredModuleStub(name);\n _moduleCache[name] = deferredStub;\n _debugRequire(\"loaded\", name, \"deferred-stub\");\n return deferredStub;\n }\n if (_unsupportedCoreModules.has(name)) {\n throw new Error(name + \" is not supported in sandbox\");\n }\n const polyfillCode = _loadPolyfill.applySyncPromise(void 0, [name]);\n if (polyfillCode !== null) {\n if (_moduleCache[name]) return _moduleCache[name];\n const moduleObj = { exports: {} };\n _pendingModules[name] = moduleObj;\n let result = eval(polyfillCode);\n result = _patchPolyfill(name, result);\n if (typeof result === \"object\" && result !== null) {\n Object.assign(moduleObj.exports, result);\n } else {\n moduleObj.exports = result;\n }\n _moduleCache[name] = moduleObj.exports;\n delete _pendingModules[name];\n _debugRequire(\"loaded\", name, \"polyfill\");\n return _moduleCache[name];\n }\n resolved = _resolveFrom(name, fromDir);\n cacheKey = resolved;\n if (_moduleCache[cacheKey]) {\n _debugRequire(\"cache-hit\", name, cacheKey);\n return _moduleCache[cacheKey];\n }\n if (_pendingModules[cacheKey]) {\n _debugRequire(\"pending-hit\", name, cacheKey);\n return _pendingModules[cacheKey].exports;\n }\n const source = _loadFile.applySyncPromise(void 0, [resolved]);\n if (source === null) {\n const err = new Error(\"Cannot find module '\" + resolved + \"'\");\n err.code = \"MODULE_NOT_FOUND\";\n throw err;\n }\n if (resolved.endsWith(\".json\")) {\n const parsed = JSON.parse(source);\n _moduleCache[cacheKey] = parsed;\n return parsed;\n }\n const normalizedSource = typeof source === \"string\" ? source.replace(/import\\.meta\\.url/g, \"__filename\").replace(/fileURLToPath\\(__filename\\)/g, \"__filename\").replace(/url\\.fileURLToPath\\(__filename\\)/g, \"__filename\").replace(/fileURLToPath\\.call\\(void 0, __filename\\)/g, \"__filename\") : source;\n const module = {\n exports: {},\n filename: resolved,\n dirname: _dirname(resolved),\n id: resolved,\n loaded: false\n };\n _pendingModules[cacheKey] = module;\n const prevModule = _currentModule;\n _currentModule = module;\n try {\n let wrapper;\n try {\n wrapper = new Function(\n \"exports\",\n \"require\",\n \"module\",\n \"__filename\",\n \"__dirname\",\n \"__dynamicImport\",\n normalizedSource + \"\\n//# sourceURL=\" + resolved\n );\n } catch (error) {\n const details = error && error.stack ? error.stack : String(error);\n throw new Error(\"failed to compile module \" + resolved + \": \" + details);\n }\n const moduleRequire = function(request) {\n return _requireFrom(request, module.dirname);\n };\n moduleRequire.resolve = function(request) {\n return _resolveFrom(request, module.dirname);\n };\n const moduleDynamicImport = function(specifier) {\n if (typeof globalThis.__dynamicImport === \"function\") {\n return globalThis.__dynamicImport(specifier, module.dirname);\n }\n return Promise.reject(new Error(\"Dynamic import is not initialized\"));\n };\n wrapper(\n module.exports,\n moduleRequire,\n module,\n resolved,\n module.dirname,\n moduleDynamicImport\n );\n module.loaded = true;\n } catch (error) {\n const details = error && error.stack ? error.stack : String(error);\n throw new Error(\"failed to execute module \" + resolved + \": \" + details);\n } finally {\n _currentModule = prevModule;\n }\n _moduleCache[cacheKey] = module.exports;\n delete _pendingModules[cacheKey];\n _debugRequire(\"loaded\", name, cacheKey);\n return module.exports;\n }\n __requireExposeCustomGlobal(\"_requireFrom\", _requireFrom);\n})();\n",
|
|
14
|
+
"setCommonjsFileGlobals": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeMutableGlobal() {\n if (typeof globalThis.__runtimeExposeMutableGlobal === \"function\") {\n return globalThis.__runtimeExposeMutableGlobal;\n }\n return createRuntimeGlobalExposer(true);\n }\n\n // isolate-runtime/src/inject/set-commonjs-file-globals.ts\n var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();\n var __commonJsFileConfig = globalThis.__runtimeCommonJsFileConfig ?? {};\n var __filePath = typeof __commonJsFileConfig.filePath === \"string\" ? __commonJsFileConfig.filePath : \"/<entry>.js\";\n var __dirname = typeof __commonJsFileConfig.dirname === \"string\" ? __commonJsFileConfig.dirname : \"/\";\n __runtimeExposeMutableGlobal(\"__filename\", __filePath);\n __runtimeExposeMutableGlobal(\"__dirname\", __dirname);\n var __currentModule = globalThis._currentModule;\n if (__currentModule) {\n __currentModule.dirname = __dirname;\n __currentModule.filename = __filePath;\n }\n})();\n",
|
|
15
|
+
"setStdinData": "\"use strict\";\n(() => {\n // isolate-runtime/src/inject/set-stdin-data.ts\n if (typeof globalThis._stdinData !== \"undefined\") {\n globalThis._stdinData = globalThis.__runtimeStdinData;\n globalThis._stdinPosition = 0;\n globalThis._stdinEnded = false;\n globalThis._stdinFlowMode = false;\n }\n})();\n",
|
|
16
|
+
"setupDynamicImport": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-access.ts\n function isObjectLike(value) {\n return value !== null && (typeof value === \"object\" || typeof value === \"function\");\n }\n\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/setup-dynamic-import.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __dynamicImportConfig = globalThis.__runtimeDynamicImportConfig ?? {};\n var __fallbackReferrer = typeof __dynamicImportConfig.referrerPath === \"string\" && __dynamicImportConfig.referrerPath.length > 0 ? __dynamicImportConfig.referrerPath : \"/\";\n var __dynamicImportHandler = async function(specifier, fromPath) {\n const request = String(specifier);\n const referrer = typeof fromPath === \"string\" && fromPath.length > 0 ? fromPath : __fallbackReferrer;\n const allowRequireFallback = request.endsWith(\".cjs\") || request.endsWith(\".json\");\n const namespace = await globalThis._dynamicImport.apply(\n void 0,\n [request, referrer],\n { result: { promise: true } }\n );\n if (namespace !== null) {\n return namespace;\n }\n if (!allowRequireFallback) {\n throw new Error(\"Cannot find module '\" + request + \"'\");\n }\n const runtimeRequire = globalThis.require;\n if (typeof runtimeRequire !== \"function\") {\n throw new Error(\"Cannot find module '\" + request + \"'\");\n }\n const mod = runtimeRequire(request);\n const namespaceFallback = { default: mod };\n if (isObjectLike(mod)) {\n for (const key of Object.keys(mod)) {\n if (!(key in namespaceFallback)) {\n namespaceFallback[key] = mod[key];\n }\n }\n }\n return namespaceFallback;\n };\n __runtimeExposeCustomGlobal(\"__dynamicImport\", __dynamicImportHandler);\n})();\n",
|
|
17
|
+
"setupFsFacade": "\"use strict\";\n(() => {\n // isolate-runtime/src/common/global-exposure.ts\n function defineRuntimeGlobalBinding(name, value, mutable) {\n Object.defineProperty(globalThis, name, {\n value,\n writable: mutable,\n configurable: mutable,\n enumerable: true\n });\n }\n function createRuntimeGlobalExposer(mutable) {\n return (name, value) => {\n defineRuntimeGlobalBinding(name, value, mutable);\n };\n }\n function getRuntimeExposeCustomGlobal() {\n if (typeof globalThis.__runtimeExposeCustomGlobal === \"function\") {\n return globalThis.__runtimeExposeCustomGlobal;\n }\n return createRuntimeGlobalExposer(false);\n }\n\n // isolate-runtime/src/inject/setup-fs-facade.ts\n var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();\n var __fsFacade = {\n readFile: globalThis._fsReadFile,\n writeFile: globalThis._fsWriteFile,\n readFileBinary: globalThis._fsReadFileBinary,\n writeFileBinary: globalThis._fsWriteFileBinary,\n readDir: globalThis._fsReadDir,\n mkdir: globalThis._fsMkdir,\n rmdir: globalThis._fsRmdir,\n exists: globalThis._fsExists,\n stat: globalThis._fsStat,\n unlink: globalThis._fsUnlink,\n rename: globalThis._fsRename\n };\n __runtimeExposeCustomGlobal(\"_fs\", __fsFacade);\n})();\n",
|
|
18
|
+
};
|
|
19
|
+
export function getIsolateRuntimeSource(id) {
|
|
20
|
+
return ISOLATE_RUNTIME_SOURCES[id];
|
|
21
|
+
}
|