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,606 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/inject/require-setup.ts
|
|
4
|
+
var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === "function" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name2, value) {
|
|
5
|
+
Object.defineProperty(globalThis, name2, {
|
|
6
|
+
value,
|
|
7
|
+
writable: false,
|
|
8
|
+
configurable: false,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
if (typeof globalThis.AbortController === "undefined" || typeof globalThis.AbortSignal === "undefined") {
|
|
13
|
+
class AbortSignal {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.aborted = false;
|
|
16
|
+
this.reason = void 0;
|
|
17
|
+
this.onabort = null;
|
|
18
|
+
this._listeners = [];
|
|
19
|
+
}
|
|
20
|
+
addEventListener(type, listener) {
|
|
21
|
+
if (type !== "abort" || typeof listener !== "function") return;
|
|
22
|
+
this._listeners.push(listener);
|
|
23
|
+
}
|
|
24
|
+
removeEventListener(type, listener) {
|
|
25
|
+
if (type !== "abort" || typeof listener !== "function") return;
|
|
26
|
+
const index = this._listeners.indexOf(listener);
|
|
27
|
+
if (index !== -1) {
|
|
28
|
+
this._listeners.splice(index, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
dispatchEvent(event) {
|
|
32
|
+
if (!event || event.type !== "abort") return false;
|
|
33
|
+
if (typeof this.onabort === "function") {
|
|
34
|
+
try {
|
|
35
|
+
this.onabort.call(this, event);
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const listeners = this._listeners.slice();
|
|
40
|
+
for (const listener of listeners) {
|
|
41
|
+
try {
|
|
42
|
+
listener.call(this, event);
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class AbortController {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.signal = new AbortSignal();
|
|
52
|
+
}
|
|
53
|
+
abort(reason) {
|
|
54
|
+
if (this.signal.aborted) return;
|
|
55
|
+
this.signal.aborted = true;
|
|
56
|
+
this.signal.reason = reason;
|
|
57
|
+
this.signal.dispatchEvent({ type: "abort" });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
__requireExposeCustomGlobal("AbortSignal", AbortSignal);
|
|
61
|
+
__requireExposeCustomGlobal("AbortController", AbortController);
|
|
62
|
+
}
|
|
63
|
+
if (typeof globalThis.structuredClone !== "function") {
|
|
64
|
+
let structuredClonePolyfill = function(value) {
|
|
65
|
+
if (value === null || typeof value !== "object") {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
if (value instanceof ArrayBuffer) {
|
|
69
|
+
return value.slice(0);
|
|
70
|
+
}
|
|
71
|
+
if (ArrayBuffer.isView(value)) {
|
|
72
|
+
if (value instanceof Uint8Array) {
|
|
73
|
+
return new Uint8Array(value);
|
|
74
|
+
}
|
|
75
|
+
return new value.constructor(value);
|
|
76
|
+
}
|
|
77
|
+
return JSON.parse(JSON.stringify(value));
|
|
78
|
+
};
|
|
79
|
+
structuredClonePolyfill2 = structuredClonePolyfill;
|
|
80
|
+
__requireExposeCustomGlobal("structuredClone", structuredClonePolyfill);
|
|
81
|
+
}
|
|
82
|
+
var structuredClonePolyfill2;
|
|
83
|
+
if (typeof globalThis.btoa !== "function") {
|
|
84
|
+
__requireExposeCustomGlobal("btoa", function btoa(input) {
|
|
85
|
+
return Buffer.from(String(input), "binary").toString("base64");
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (typeof globalThis.atob !== "function") {
|
|
89
|
+
__requireExposeCustomGlobal("atob", function atob(input) {
|
|
90
|
+
return Buffer.from(String(input), "base64").toString("binary");
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function _dirname(p) {
|
|
94
|
+
const lastSlash = p.lastIndexOf("/");
|
|
95
|
+
if (lastSlash === -1) return ".";
|
|
96
|
+
if (lastSlash === 0) return "/";
|
|
97
|
+
return p.slice(0, lastSlash);
|
|
98
|
+
}
|
|
99
|
+
function _patchPolyfill(name2, result2) {
|
|
100
|
+
if (typeof result2 !== "object" && typeof result2 !== "function" || result2 === null) {
|
|
101
|
+
return result2;
|
|
102
|
+
}
|
|
103
|
+
if (name2 === "buffer") {
|
|
104
|
+
const maxLength = typeof result2.kMaxLength === "number" ? result2.kMaxLength : 2147483647;
|
|
105
|
+
const maxStringLength = typeof result2.kStringMaxLength === "number" ? result2.kStringMaxLength : 536870888;
|
|
106
|
+
if (typeof result2.constants !== "object" || result2.constants === null) {
|
|
107
|
+
result2.constants = {};
|
|
108
|
+
}
|
|
109
|
+
if (typeof result2.constants.MAX_LENGTH !== "number") {
|
|
110
|
+
result2.constants.MAX_LENGTH = maxLength;
|
|
111
|
+
}
|
|
112
|
+
if (typeof result2.constants.MAX_STRING_LENGTH !== "number") {
|
|
113
|
+
result2.constants.MAX_STRING_LENGTH = maxStringLength;
|
|
114
|
+
}
|
|
115
|
+
if (typeof result2.kMaxLength !== "number") {
|
|
116
|
+
result2.kMaxLength = maxLength;
|
|
117
|
+
}
|
|
118
|
+
if (typeof result2.kStringMaxLength !== "number") {
|
|
119
|
+
result2.kStringMaxLength = maxStringLength;
|
|
120
|
+
}
|
|
121
|
+
const BufferCtor = result2.Buffer;
|
|
122
|
+
if ((typeof BufferCtor === "function" || typeof BufferCtor === "object") && BufferCtor !== null) {
|
|
123
|
+
if (typeof BufferCtor.kMaxLength !== "number") {
|
|
124
|
+
BufferCtor.kMaxLength = maxLength;
|
|
125
|
+
}
|
|
126
|
+
if (typeof BufferCtor.kStringMaxLength !== "number") {
|
|
127
|
+
BufferCtor.kStringMaxLength = maxStringLength;
|
|
128
|
+
}
|
|
129
|
+
if (typeof BufferCtor.constants !== "object" || BufferCtor.constants === null) {
|
|
130
|
+
BufferCtor.constants = result2.constants;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return result2;
|
|
134
|
+
}
|
|
135
|
+
if (name2 === "util" && typeof result2.formatWithOptions === "undefined" && typeof result2.format === "function") {
|
|
136
|
+
result2.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {
|
|
137
|
+
return result2.format.apply(null, args);
|
|
138
|
+
};
|
|
139
|
+
return result2;
|
|
140
|
+
}
|
|
141
|
+
if (name2 === "url") {
|
|
142
|
+
const OriginalURL = result2.URL;
|
|
143
|
+
if (typeof OriginalURL !== "function" || OriginalURL._patched) {
|
|
144
|
+
return result2;
|
|
145
|
+
}
|
|
146
|
+
const PatchedURL = function PatchedURL2(url, base) {
|
|
147
|
+
if (typeof url === "string" && url.startsWith("file:") && !url.startsWith("file://") && base === void 0) {
|
|
148
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
149
|
+
const cwd = process.cwd();
|
|
150
|
+
if (cwd) {
|
|
151
|
+
try {
|
|
152
|
+
return new OriginalURL(url, "file://" + cwd + "/");
|
|
153
|
+
} catch (e) {
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return base !== void 0 ? new OriginalURL(url, base) : new OriginalURL(url);
|
|
159
|
+
};
|
|
160
|
+
Object.keys(OriginalURL).forEach(function(key) {
|
|
161
|
+
try {
|
|
162
|
+
PatchedURL[key] = OriginalURL[key];
|
|
163
|
+
} catch {
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
Object.setPrototypeOf(PatchedURL, OriginalURL);
|
|
167
|
+
PatchedURL.prototype = OriginalURL.prototype;
|
|
168
|
+
PatchedURL._patched = true;
|
|
169
|
+
const descriptor = Object.getOwnPropertyDescriptor(result2, "URL");
|
|
170
|
+
if (descriptor && descriptor.configurable !== true && descriptor.writable !== true && typeof descriptor.set !== "function") {
|
|
171
|
+
return result2;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
result2.URL = PatchedURL;
|
|
175
|
+
} catch {
|
|
176
|
+
try {
|
|
177
|
+
Object.defineProperty(result2, "URL", {
|
|
178
|
+
value: PatchedURL,
|
|
179
|
+
writable: true,
|
|
180
|
+
configurable: true,
|
|
181
|
+
enumerable: descriptor?.enumerable ?? true
|
|
182
|
+
});
|
|
183
|
+
} catch {
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return result2;
|
|
187
|
+
}
|
|
188
|
+
if (name2 === "path") {
|
|
189
|
+
if (result2.win32 === null || result2.win32 === void 0) {
|
|
190
|
+
result2.win32 = result2.posix || result2;
|
|
191
|
+
}
|
|
192
|
+
if (result2.posix === null || result2.posix === void 0) {
|
|
193
|
+
result2.posix = result2;
|
|
194
|
+
}
|
|
195
|
+
const hasAbsoluteSegment = function(args) {
|
|
196
|
+
return args.some(function(arg) {
|
|
197
|
+
return typeof arg === "string" && arg.length > 0 && arg.charAt(0) === "/";
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
const prependCwd = function(args) {
|
|
201
|
+
if (hasAbsoluteSegment(args)) return;
|
|
202
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
203
|
+
const cwd = process.cwd();
|
|
204
|
+
if (cwd && cwd.charAt(0) === "/") {
|
|
205
|
+
args.unshift(cwd);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const originalResolve = result2.resolve;
|
|
210
|
+
if (typeof originalResolve === "function" && !originalResolve._patchedForCwd) {
|
|
211
|
+
const patchedResolve = function resolve2() {
|
|
212
|
+
const args = Array.from(arguments);
|
|
213
|
+
prependCwd(args);
|
|
214
|
+
return originalResolve.apply(this, args);
|
|
215
|
+
};
|
|
216
|
+
patchedResolve._patchedForCwd = true;
|
|
217
|
+
result2.resolve = patchedResolve;
|
|
218
|
+
}
|
|
219
|
+
if (result2.posix && typeof result2.posix.resolve === "function" && !result2.posix.resolve._patchedForCwd) {
|
|
220
|
+
const originalPosixResolve = result2.posix.resolve;
|
|
221
|
+
const patchedPosixResolve = function resolve2() {
|
|
222
|
+
const args = Array.from(arguments);
|
|
223
|
+
prependCwd(args);
|
|
224
|
+
return originalPosixResolve.apply(this, args);
|
|
225
|
+
};
|
|
226
|
+
patchedPosixResolve._patchedForCwd = true;
|
|
227
|
+
result2.posix.resolve = patchedPosixResolve;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return result2;
|
|
231
|
+
}
|
|
232
|
+
var _deferredCoreModules = /* @__PURE__ */ new Set([
|
|
233
|
+
"net",
|
|
234
|
+
"tls",
|
|
235
|
+
"readline",
|
|
236
|
+
"perf_hooks",
|
|
237
|
+
"async_hooks",
|
|
238
|
+
"worker_threads"
|
|
239
|
+
]);
|
|
240
|
+
var _unsupportedCoreModules = /* @__PURE__ */ new Set([
|
|
241
|
+
"dgram",
|
|
242
|
+
"cluster",
|
|
243
|
+
"wasi",
|
|
244
|
+
"diagnostics_channel",
|
|
245
|
+
"inspector",
|
|
246
|
+
"repl",
|
|
247
|
+
"trace_events",
|
|
248
|
+
"domain"
|
|
249
|
+
]);
|
|
250
|
+
function _unsupportedApiError(moduleName2, apiName) {
|
|
251
|
+
return new Error(moduleName2 + "." + apiName + " is not supported in sandbox");
|
|
252
|
+
}
|
|
253
|
+
function _createDeferredModuleStub(moduleName2) {
|
|
254
|
+
const methodCache = {};
|
|
255
|
+
let stub = null;
|
|
256
|
+
stub = new Proxy({}, {
|
|
257
|
+
get(_target, prop) {
|
|
258
|
+
if (prop === "__esModule") return false;
|
|
259
|
+
if (prop === "default") return stub;
|
|
260
|
+
if (prop === Symbol.toStringTag) return "Module";
|
|
261
|
+
if (prop === "then") return void 0;
|
|
262
|
+
if (typeof prop !== "string") return void 0;
|
|
263
|
+
if (!methodCache[prop]) {
|
|
264
|
+
methodCache[prop] = function deferredApiStub() {
|
|
265
|
+
throw _unsupportedApiError(moduleName2, prop);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
return methodCache[prop];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
return stub;
|
|
272
|
+
}
|
|
273
|
+
var __require = function require2(moduleName2) {
|
|
274
|
+
return _requireFrom(moduleName2, _currentModule.dirname);
|
|
275
|
+
};
|
|
276
|
+
__requireExposeCustomGlobal("require", __require);
|
|
277
|
+
function _resolveFrom(moduleName2, fromDir2) {
|
|
278
|
+
const resolved2 = _resolveModule.applySyncPromise(void 0, [moduleName2, fromDir2]);
|
|
279
|
+
if (resolved2 === null) {
|
|
280
|
+
const err = new Error("Cannot find module '" + moduleName2 + "'");
|
|
281
|
+
err.code = "MODULE_NOT_FOUND";
|
|
282
|
+
throw err;
|
|
283
|
+
}
|
|
284
|
+
return resolved2;
|
|
285
|
+
}
|
|
286
|
+
globalThis.require.resolve = function resolve(moduleName2) {
|
|
287
|
+
return _resolveFrom(moduleName2, _currentModule.dirname);
|
|
288
|
+
};
|
|
289
|
+
globalThis.require.cache = _moduleCache;
|
|
290
|
+
function _debugRequire(phase, moduleName2, extra) {
|
|
291
|
+
if (globalThis.__sandboxRequireDebug !== true) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (moduleName2 !== "rivetkit" && moduleName2 !== "@rivetkit/traces" && moduleName2 !== "@rivetkit/on-change" && moduleName2 !== "async_hooks" && !moduleName2.startsWith("rivetkit/") && !moduleName2.startsWith("@rivetkit/")) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (typeof console !== "undefined" && typeof console.log === "function") {
|
|
298
|
+
console.log(
|
|
299
|
+
"[sandbox.require] " + phase + " " + moduleName2 + (extra ? " " + extra : "")
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function _requireFrom(moduleName, fromDir) {
|
|
304
|
+
_debugRequire("start", moduleName, fromDir);
|
|
305
|
+
const name = moduleName.replace(/^node:/, "");
|
|
306
|
+
let cacheKey = name;
|
|
307
|
+
let resolved = null;
|
|
308
|
+
const isRelative = name.startsWith("./") || name.startsWith("../");
|
|
309
|
+
if (!isRelative && _moduleCache[name]) {
|
|
310
|
+
_debugRequire("cache-hit", name, name);
|
|
311
|
+
return _moduleCache[name];
|
|
312
|
+
}
|
|
313
|
+
if (name === "fs") {
|
|
314
|
+
if (_moduleCache["fs"]) return _moduleCache["fs"];
|
|
315
|
+
const fsModule = globalThis.bridge?.fs || globalThis.bridge?.default || globalThis._fsModule || {};
|
|
316
|
+
_moduleCache["fs"] = fsModule;
|
|
317
|
+
_debugRequire("loaded", name, "fs-special");
|
|
318
|
+
return fsModule;
|
|
319
|
+
}
|
|
320
|
+
if (name === "fs/promises") {
|
|
321
|
+
if (_moduleCache["fs/promises"]) return _moduleCache["fs/promises"];
|
|
322
|
+
const fsModule = _requireFrom("fs", fromDir);
|
|
323
|
+
_moduleCache["fs/promises"] = fsModule.promises;
|
|
324
|
+
_debugRequire("loaded", name, "fs-promises-special");
|
|
325
|
+
return fsModule.promises;
|
|
326
|
+
}
|
|
327
|
+
if (name === "stream/promises") {
|
|
328
|
+
if (_moduleCache["stream/promises"]) return _moduleCache["stream/promises"];
|
|
329
|
+
const streamModule = _requireFrom("stream", fromDir);
|
|
330
|
+
const promisesModule = {
|
|
331
|
+
finished(stream, options) {
|
|
332
|
+
return new Promise(function(resolve2, reject) {
|
|
333
|
+
if (typeof streamModule.finished !== "function") {
|
|
334
|
+
resolve2();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (options && typeof options === "object" && !Array.isArray(options)) {
|
|
338
|
+
streamModule.finished(stream, options, function(error) {
|
|
339
|
+
if (error) {
|
|
340
|
+
reject(error);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
resolve2();
|
|
344
|
+
});
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
streamModule.finished(stream, function(error) {
|
|
348
|
+
if (error) {
|
|
349
|
+
reject(error);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
resolve2();
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
},
|
|
356
|
+
pipeline() {
|
|
357
|
+
const args = Array.prototype.slice.call(arguments);
|
|
358
|
+
return new Promise(function(resolve2, reject) {
|
|
359
|
+
if (typeof streamModule.pipeline !== "function") {
|
|
360
|
+
reject(new Error("stream.pipeline is not supported in sandbox"));
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
args.push(function(error) {
|
|
364
|
+
if (error) {
|
|
365
|
+
reject(error);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
resolve2();
|
|
369
|
+
});
|
|
370
|
+
streamModule.pipeline.apply(streamModule, args);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
_moduleCache["stream/promises"] = promisesModule;
|
|
375
|
+
_debugRequire("loaded", name, "stream-promises-special");
|
|
376
|
+
return promisesModule;
|
|
377
|
+
}
|
|
378
|
+
if (name === "child_process") {
|
|
379
|
+
if (_moduleCache["child_process"]) return _moduleCache["child_process"];
|
|
380
|
+
_moduleCache["child_process"] = _childProcessModule;
|
|
381
|
+
_debugRequire("loaded", name, "child-process-special");
|
|
382
|
+
return _childProcessModule;
|
|
383
|
+
}
|
|
384
|
+
if (name === "http") {
|
|
385
|
+
if (_moduleCache["http"]) return _moduleCache["http"];
|
|
386
|
+
_moduleCache["http"] = _httpModule;
|
|
387
|
+
_debugRequire("loaded", name, "http-special");
|
|
388
|
+
return _httpModule;
|
|
389
|
+
}
|
|
390
|
+
if (name === "https") {
|
|
391
|
+
if (_moduleCache["https"]) return _moduleCache["https"];
|
|
392
|
+
_moduleCache["https"] = _httpsModule;
|
|
393
|
+
_debugRequire("loaded", name, "https-special");
|
|
394
|
+
return _httpsModule;
|
|
395
|
+
}
|
|
396
|
+
if (name === "http2") {
|
|
397
|
+
if (_moduleCache["http2"]) return _moduleCache["http2"];
|
|
398
|
+
_moduleCache["http2"] = _http2Module;
|
|
399
|
+
_debugRequire("loaded", name, "http2-special");
|
|
400
|
+
return _http2Module;
|
|
401
|
+
}
|
|
402
|
+
if (name === "dns") {
|
|
403
|
+
if (_moduleCache["dns"]) return _moduleCache["dns"];
|
|
404
|
+
_moduleCache["dns"] = _dnsModule;
|
|
405
|
+
_debugRequire("loaded", name, "dns-special");
|
|
406
|
+
return _dnsModule;
|
|
407
|
+
}
|
|
408
|
+
if (name === "os") {
|
|
409
|
+
if (_moduleCache["os"]) return _moduleCache["os"];
|
|
410
|
+
_moduleCache["os"] = _osModule;
|
|
411
|
+
_debugRequire("loaded", name, "os-special");
|
|
412
|
+
return _osModule;
|
|
413
|
+
}
|
|
414
|
+
if (name === "module") {
|
|
415
|
+
if (_moduleCache["module"]) return _moduleCache["module"];
|
|
416
|
+
_moduleCache["module"] = _moduleModule;
|
|
417
|
+
_debugRequire("loaded", name, "module-special");
|
|
418
|
+
return _moduleModule;
|
|
419
|
+
}
|
|
420
|
+
if (name === "process") {
|
|
421
|
+
_debugRequire("loaded", name, "process-special");
|
|
422
|
+
return globalThis.process;
|
|
423
|
+
}
|
|
424
|
+
if (name === "async_hooks") {
|
|
425
|
+
if (_moduleCache["async_hooks"]) return _moduleCache["async_hooks"];
|
|
426
|
+
class AsyncLocalStorage {
|
|
427
|
+
constructor() {
|
|
428
|
+
this._store = void 0;
|
|
429
|
+
}
|
|
430
|
+
run(store, callback) {
|
|
431
|
+
const previousStore = this._store;
|
|
432
|
+
this._store = store;
|
|
433
|
+
try {
|
|
434
|
+
const args = Array.prototype.slice.call(arguments, 2);
|
|
435
|
+
return callback.apply(void 0, args);
|
|
436
|
+
} finally {
|
|
437
|
+
this._store = previousStore;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
enterWith(store) {
|
|
441
|
+
this._store = store;
|
|
442
|
+
}
|
|
443
|
+
getStore() {
|
|
444
|
+
return this._store;
|
|
445
|
+
}
|
|
446
|
+
disable() {
|
|
447
|
+
this._store = void 0;
|
|
448
|
+
}
|
|
449
|
+
exit(callback) {
|
|
450
|
+
const previousStore = this._store;
|
|
451
|
+
this._store = void 0;
|
|
452
|
+
try {
|
|
453
|
+
const args = Array.prototype.slice.call(arguments, 1);
|
|
454
|
+
return callback.apply(void 0, args);
|
|
455
|
+
} finally {
|
|
456
|
+
this._store = previousStore;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
class AsyncResource {
|
|
461
|
+
constructor(type) {
|
|
462
|
+
this.type = type;
|
|
463
|
+
}
|
|
464
|
+
runInAsyncScope(callback, thisArg) {
|
|
465
|
+
const args = Array.prototype.slice.call(arguments, 2);
|
|
466
|
+
return callback.apply(thisArg, args);
|
|
467
|
+
}
|
|
468
|
+
emitDestroy() {
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
const asyncHooksModule = {
|
|
472
|
+
AsyncLocalStorage,
|
|
473
|
+
AsyncResource,
|
|
474
|
+
createHook() {
|
|
475
|
+
return {
|
|
476
|
+
enable() {
|
|
477
|
+
return this;
|
|
478
|
+
},
|
|
479
|
+
disable() {
|
|
480
|
+
return this;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
},
|
|
484
|
+
executionAsyncId() {
|
|
485
|
+
return 1;
|
|
486
|
+
},
|
|
487
|
+
triggerAsyncId() {
|
|
488
|
+
return 0;
|
|
489
|
+
},
|
|
490
|
+
executionAsyncResource() {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
_moduleCache["async_hooks"] = asyncHooksModule;
|
|
495
|
+
_debugRequire("loaded", name, "async-hooks-special");
|
|
496
|
+
return asyncHooksModule;
|
|
497
|
+
}
|
|
498
|
+
if (_deferredCoreModules.has(name)) {
|
|
499
|
+
if (_moduleCache[name]) return _moduleCache[name];
|
|
500
|
+
const deferredStub = _createDeferredModuleStub(name);
|
|
501
|
+
_moduleCache[name] = deferredStub;
|
|
502
|
+
_debugRequire("loaded", name, "deferred-stub");
|
|
503
|
+
return deferredStub;
|
|
504
|
+
}
|
|
505
|
+
if (_unsupportedCoreModules.has(name)) {
|
|
506
|
+
throw new Error(name + " is not supported in sandbox");
|
|
507
|
+
}
|
|
508
|
+
const polyfillCode = _loadPolyfill.applySyncPromise(void 0, [name]);
|
|
509
|
+
if (polyfillCode !== null) {
|
|
510
|
+
if (_moduleCache[name]) return _moduleCache[name];
|
|
511
|
+
const moduleObj = { exports: {} };
|
|
512
|
+
_pendingModules[name] = moduleObj;
|
|
513
|
+
let result = eval(polyfillCode);
|
|
514
|
+
result = _patchPolyfill(name, result);
|
|
515
|
+
if (typeof result === "object" && result !== null) {
|
|
516
|
+
Object.assign(moduleObj.exports, result);
|
|
517
|
+
} else {
|
|
518
|
+
moduleObj.exports = result;
|
|
519
|
+
}
|
|
520
|
+
_moduleCache[name] = moduleObj.exports;
|
|
521
|
+
delete _pendingModules[name];
|
|
522
|
+
_debugRequire("loaded", name, "polyfill");
|
|
523
|
+
return _moduleCache[name];
|
|
524
|
+
}
|
|
525
|
+
resolved = _resolveFrom(name, fromDir);
|
|
526
|
+
cacheKey = resolved;
|
|
527
|
+
if (_moduleCache[cacheKey]) {
|
|
528
|
+
_debugRequire("cache-hit", name, cacheKey);
|
|
529
|
+
return _moduleCache[cacheKey];
|
|
530
|
+
}
|
|
531
|
+
if (_pendingModules[cacheKey]) {
|
|
532
|
+
_debugRequire("pending-hit", name, cacheKey);
|
|
533
|
+
return _pendingModules[cacheKey].exports;
|
|
534
|
+
}
|
|
535
|
+
const source = _loadFile.applySyncPromise(void 0, [resolved]);
|
|
536
|
+
if (source === null) {
|
|
537
|
+
const err = new Error("Cannot find module '" + resolved + "'");
|
|
538
|
+
err.code = "MODULE_NOT_FOUND";
|
|
539
|
+
throw err;
|
|
540
|
+
}
|
|
541
|
+
if (resolved.endsWith(".json")) {
|
|
542
|
+
const parsed = JSON.parse(source);
|
|
543
|
+
_moduleCache[cacheKey] = parsed;
|
|
544
|
+
return parsed;
|
|
545
|
+
}
|
|
546
|
+
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;
|
|
547
|
+
const module = {
|
|
548
|
+
exports: {},
|
|
549
|
+
filename: resolved,
|
|
550
|
+
dirname: _dirname(resolved),
|
|
551
|
+
id: resolved,
|
|
552
|
+
loaded: false
|
|
553
|
+
};
|
|
554
|
+
_pendingModules[cacheKey] = module;
|
|
555
|
+
const prevModule = _currentModule;
|
|
556
|
+
_currentModule = module;
|
|
557
|
+
try {
|
|
558
|
+
let wrapper;
|
|
559
|
+
try {
|
|
560
|
+
wrapper = new Function(
|
|
561
|
+
"exports",
|
|
562
|
+
"require",
|
|
563
|
+
"module",
|
|
564
|
+
"__filename",
|
|
565
|
+
"__dirname",
|
|
566
|
+
"__dynamicImport",
|
|
567
|
+
normalizedSource + "\n//# sourceURL=" + resolved
|
|
568
|
+
);
|
|
569
|
+
} catch (error) {
|
|
570
|
+
const details = error && error.stack ? error.stack : String(error);
|
|
571
|
+
throw new Error("failed to compile module " + resolved + ": " + details);
|
|
572
|
+
}
|
|
573
|
+
const moduleRequire = function(request) {
|
|
574
|
+
return _requireFrom(request, module.dirname);
|
|
575
|
+
};
|
|
576
|
+
moduleRequire.resolve = function(request) {
|
|
577
|
+
return _resolveFrom(request, module.dirname);
|
|
578
|
+
};
|
|
579
|
+
const moduleDynamicImport = function(specifier) {
|
|
580
|
+
if (typeof globalThis.__dynamicImport === "function") {
|
|
581
|
+
return globalThis.__dynamicImport(specifier, module.dirname);
|
|
582
|
+
}
|
|
583
|
+
return Promise.reject(new Error("Dynamic import is not initialized"));
|
|
584
|
+
};
|
|
585
|
+
wrapper(
|
|
586
|
+
module.exports,
|
|
587
|
+
moduleRequire,
|
|
588
|
+
module,
|
|
589
|
+
resolved,
|
|
590
|
+
module.dirname,
|
|
591
|
+
moduleDynamicImport
|
|
592
|
+
);
|
|
593
|
+
module.loaded = true;
|
|
594
|
+
} catch (error) {
|
|
595
|
+
const details = error && error.stack ? error.stack : String(error);
|
|
596
|
+
throw new Error("failed to execute module " + resolved + ": " + details);
|
|
597
|
+
} finally {
|
|
598
|
+
_currentModule = prevModule;
|
|
599
|
+
}
|
|
600
|
+
_moduleCache[cacheKey] = module.exports;
|
|
601
|
+
delete _pendingModules[cacheKey];
|
|
602
|
+
_debugRequire("loaded", name, cacheKey);
|
|
603
|
+
return module.exports;
|
|
604
|
+
}
|
|
605
|
+
__requireExposeCustomGlobal("_requireFrom", _requireFrom);
|
|
606
|
+
})();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/common/global-exposure.ts
|
|
4
|
+
function defineRuntimeGlobalBinding(name, value, mutable) {
|
|
5
|
+
Object.defineProperty(globalThis, name, {
|
|
6
|
+
value,
|
|
7
|
+
writable: mutable,
|
|
8
|
+
configurable: mutable,
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function createRuntimeGlobalExposer(mutable) {
|
|
13
|
+
return (name, value) => {
|
|
14
|
+
defineRuntimeGlobalBinding(name, value, mutable);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getRuntimeExposeMutableGlobal() {
|
|
18
|
+
if (typeof globalThis.__runtimeExposeMutableGlobal === "function") {
|
|
19
|
+
return globalThis.__runtimeExposeMutableGlobal;
|
|
20
|
+
}
|
|
21
|
+
return createRuntimeGlobalExposer(true);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// isolate-runtime/src/inject/set-commonjs-file-globals.ts
|
|
25
|
+
var __runtimeExposeMutableGlobal = getRuntimeExposeMutableGlobal();
|
|
26
|
+
var __commonJsFileConfig = globalThis.__runtimeCommonJsFileConfig ?? {};
|
|
27
|
+
var __filePath = typeof __commonJsFileConfig.filePath === "string" ? __commonJsFileConfig.filePath : "/<entry>.js";
|
|
28
|
+
var __dirname = typeof __commonJsFileConfig.dirname === "string" ? __commonJsFileConfig.dirname : "/";
|
|
29
|
+
__runtimeExposeMutableGlobal("__filename", __filePath);
|
|
30
|
+
__runtimeExposeMutableGlobal("__dirname", __dirname);
|
|
31
|
+
var __currentModule = globalThis._currentModule;
|
|
32
|
+
if (__currentModule) {
|
|
33
|
+
__currentModule.dirname = __dirname;
|
|
34
|
+
__currentModule.filename = __filePath;
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
// isolate-runtime/src/inject/set-stdin-data.ts
|
|
4
|
+
if (typeof globalThis._stdinData !== "undefined") {
|
|
5
|
+
globalThis._stdinData = globalThis.__runtimeStdinData;
|
|
6
|
+
globalThis._stdinPosition = 0;
|
|
7
|
+
globalThis._stdinEnded = false;
|
|
8
|
+
globalThis._stdinFlowMode = false;
|
|
9
|
+
}
|
|
10
|
+
})();
|