sandboxedjs 0.1.80 → 0.1.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.cts +2 -2
- package/dist/agent.d.ts +2 -2
- package/dist/{container-LwAV9JTH.d.cts → container-B14Q03ng.d.cts} +1 -1
- package/dist/{container-CUB12Moo.d.ts → container-DtVUncWL.d.ts} +1 -1
- package/dist/{contracts-C2_dTgk3.d.cts → contracts-DNkSvBCM.d.cts} +19 -2
- package/dist/{contracts-C2_dTgk3.d.ts → contracts-DNkSvBCM.d.ts} +19 -2
- package/dist/index.cjs +709 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +709 -64
- package/dist/index.js.map +1 -1
- package/dist/{memory-volume-CG56p660.d.ts → memory-volume-D4FLjyEU.d.ts} +1 -1
- package/dist/{memory-volume-DqEWFo7t.d.cts → memory-volume-n-LY8Vdv.d.cts} +1 -1
- package/dist/python-abi.d.cts +3 -3
- package/dist/python-abi.d.ts +3 -3
- package/dist/worker-entry.js +714 -63
- package/dist/worker-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var timersModule = require('timers-browserify');
|
|
|
21
21
|
var legacyUrl = require('url/url.js');
|
|
22
22
|
var legacy$1 = require('@noble/hashes/legacy');
|
|
23
23
|
var hmac = require('@noble/hashes/hmac');
|
|
24
|
+
var pbkdf2 = require('@noble/hashes/pbkdf2');
|
|
24
25
|
|
|
25
26
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
26
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -20237,7 +20238,7 @@ var wheels_default = {
|
|
|
20237
20238
|
|
|
20238
20239
|
// package.json
|
|
20239
20240
|
var package_default = {
|
|
20240
|
-
version: "0.1.
|
|
20241
|
+
version: "0.1.83"};
|
|
20241
20242
|
|
|
20242
20243
|
// src/python/config.ts
|
|
20243
20244
|
function runtimeModuleUrl() {
|
|
@@ -25215,7 +25216,21 @@ function makeNpmAlias(name, path) {
|
|
|
25215
25216
|
exec: ["exec", ...rest],
|
|
25216
25217
|
list: ["ls", ...rest],
|
|
25217
25218
|
why: ["ls", ...rest],
|
|
25218
|
-
dlx: ["exec", ...rest]
|
|
25219
|
+
dlx: ["exec", ...rest],
|
|
25220
|
+
/* Verbs of the package manager itself, never script names. Tools ask
|
|
25221
|
+
* them in passing — Next resolves its download registry with
|
|
25222
|
+
* `yarn config get registry` whenever yarn is on PATH — and running
|
|
25223
|
+
* them as scripts failed with "could not read package.json". */
|
|
25224
|
+
config: ["config", ...rest],
|
|
25225
|
+
cache: ["cache", ...rest],
|
|
25226
|
+
root: ["root", ...rest],
|
|
25227
|
+
prefix: ["prefix", ...rest],
|
|
25228
|
+
ping: ["ping", ...rest],
|
|
25229
|
+
whoami: ["whoami", ...rest],
|
|
25230
|
+
init: ["init", ...rest],
|
|
25231
|
+
create: ["create", ...rest],
|
|
25232
|
+
uninstall: ["uninstall", ...rest],
|
|
25233
|
+
rm: ["uninstall", ...rest]
|
|
25219
25234
|
};
|
|
25220
25235
|
if (subcommand === void 0) return npm.run({ ...ctx, args: ["install"], argv: [name, "install"] });
|
|
25221
25236
|
if (subcommand === "-v" || subcommand === "--version") {
|
|
@@ -25827,6 +25842,49 @@ var CommonJsEngine = class {
|
|
|
25827
25842
|
this.globals = { ...options.globals };
|
|
25828
25843
|
this.aliases = { ...options.aliases };
|
|
25829
25844
|
this.overrides = { ...options.overrides };
|
|
25845
|
+
const engine = this;
|
|
25846
|
+
this.moduleApi = function Module(id = "", parent = null) {
|
|
25847
|
+
Object.assign(this, { id, filename: id, exports: {}, loaded: false, parent, children: [] });
|
|
25848
|
+
};
|
|
25849
|
+
Object.assign(this.moduleApi, this.builtins.module);
|
|
25850
|
+
this.moduleApi.Module = this.moduleApi;
|
|
25851
|
+
this.moduleApi._extensions = {
|
|
25852
|
+
".js": (module, filename) => this.evaluate(module, this.readText(filename)),
|
|
25853
|
+
".json": (module, filename) => {
|
|
25854
|
+
module.exports = JSON.parse(this.readText(filename));
|
|
25855
|
+
},
|
|
25856
|
+
".node": (_module, filename) => {
|
|
25857
|
+
throw dlopenFailed(filename);
|
|
25858
|
+
}
|
|
25859
|
+
};
|
|
25860
|
+
this.moduleApi._cache = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
25861
|
+
get: (_target, key) => typeof key === "string" ? this.cache.get(key) : void 0,
|
|
25862
|
+
set: (_target, key, value) => {
|
|
25863
|
+
this.cache.set(String(key), value);
|
|
25864
|
+
return true;
|
|
25865
|
+
},
|
|
25866
|
+
deleteProperty: (_target, key) => this.cache.delete(String(key)),
|
|
25867
|
+
ownKeys: () => [...this.cache.keys()],
|
|
25868
|
+
getOwnPropertyDescriptor: (_target, key) => this.cache.has(String(key)) ? { enumerable: true, configurable: true, writable: true, value: this.cache.get(String(key)) } : void 0
|
|
25869
|
+
});
|
|
25870
|
+
this.moduleApi._resolveFilename = (request, parent) => this.resolve(request, parent?.filename || join(this.cwd, "__entry__.js"));
|
|
25871
|
+
this.moduleApi.prototype.require = function(request) {
|
|
25872
|
+
const filename = engine.moduleApi._resolveFilename(request, this);
|
|
25873
|
+
const builtin = engine.builtin(filename, this);
|
|
25874
|
+
if (builtin.found) return builtin.value;
|
|
25875
|
+
const target = engine.load(filename, this, false);
|
|
25876
|
+
if (target.pending) throw requireOfAsyncModule(request);
|
|
25877
|
+
return target.exports;
|
|
25878
|
+
};
|
|
25879
|
+
this.moduleApi.prototype._compile = function(source, filename) {
|
|
25880
|
+
this.filename = filename;
|
|
25881
|
+
engine.evaluate(this, source);
|
|
25882
|
+
};
|
|
25883
|
+
this.moduleApi.createRequire = (filename) => {
|
|
25884
|
+
const path = String(filename).startsWith("file:") ? pathFromFileUrl(String(filename)) : String(filename);
|
|
25885
|
+
if (!path.startsWith("/")) throw new TypeError("createRequire requires an absolute path or file URL");
|
|
25886
|
+
return this.makeRequire(Object.assign(new this.moduleApi(path), { filename: path }));
|
|
25887
|
+
};
|
|
25830
25888
|
}
|
|
25831
25889
|
volume;
|
|
25832
25890
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -25839,6 +25897,7 @@ var CommonJsEngine = class {
|
|
|
25839
25897
|
/** `package.json` per directory; resolution reads them constantly. */
|
|
25840
25898
|
manifests = /* @__PURE__ */ new Map();
|
|
25841
25899
|
evaluationDepth = 0;
|
|
25900
|
+
moduleApi;
|
|
25842
25901
|
/**
|
|
25843
25902
|
* Is a module body running synchronously right now?
|
|
25844
25903
|
*
|
|
@@ -25875,7 +25934,7 @@ var CommonJsEngine = class {
|
|
|
25875
25934
|
specifier = pathFromFileUrl(specifier);
|
|
25876
25935
|
}
|
|
25877
25936
|
const builtin = this.builtin(specifier);
|
|
25878
|
-
if (builtin.found) return specifier
|
|
25937
|
+
if (builtin.found) return specifier;
|
|
25879
25938
|
if (specifier.startsWith("#")) {
|
|
25880
25939
|
const found = this.resolveImports(specifier, importer, kind);
|
|
25881
25940
|
if (found) return found;
|
|
@@ -25908,17 +25967,14 @@ var CommonJsEngine = class {
|
|
|
25908
25967
|
parent,
|
|
25909
25968
|
children: []
|
|
25910
25969
|
};
|
|
25970
|
+
Object.setPrototypeOf(module, this.moduleApi.prototype);
|
|
25911
25971
|
this.cache.set(filename, module);
|
|
25912
25972
|
parent?.children.push(module);
|
|
25913
25973
|
if (isMain) this.main = module;
|
|
25914
25974
|
try {
|
|
25915
|
-
|
|
25916
|
-
|
|
25917
|
-
|
|
25918
|
-
module.exports = JSON.parse(this.readText(filename));
|
|
25919
|
-
} else {
|
|
25920
|
-
this.evaluate(module, this.readText(filename));
|
|
25921
|
-
}
|
|
25975
|
+
const extension = extname(filename);
|
|
25976
|
+
const loader = this.moduleApi._extensions[extension] ?? this.moduleApi._extensions[".js"];
|
|
25977
|
+
loader(module, filename);
|
|
25922
25978
|
module.loaded = true;
|
|
25923
25979
|
return module;
|
|
25924
25980
|
} catch (error) {
|
|
@@ -25971,15 +26027,12 @@ ${code}
|
|
|
25971
26027
|
/** The `require` a module sees, complete with `resolve`, `cache` and `main`. */
|
|
25972
26028
|
makeRequire(module) {
|
|
25973
26029
|
const localRequire = ((specifier) => {
|
|
25974
|
-
|
|
25975
|
-
if (builtin.found) return builtin.value;
|
|
25976
|
-
const target = this.load(this.resolve(specifier, module.filename, "require"), module, false);
|
|
25977
|
-
if (target.pending) throw requireOfAsyncModule(specifier);
|
|
25978
|
-
return target.exports;
|
|
26030
|
+
return this.moduleApi.prototype.require.call(module, specifier);
|
|
25979
26031
|
});
|
|
25980
|
-
localRequire.resolve = (specifier) => this.
|
|
26032
|
+
localRequire.resolve = (specifier) => this.moduleApi._resolveFilename(specifier, module);
|
|
25981
26033
|
Object.defineProperty(localRequire, "main", { get: () => this.main });
|
|
25982
|
-
localRequire.cache =
|
|
26034
|
+
localRequire.cache = this.moduleApi._cache;
|
|
26035
|
+
localRequire.extensions = this.moduleApi._extensions;
|
|
25983
26036
|
return localRequire;
|
|
25984
26037
|
}
|
|
25985
26038
|
/**
|
|
@@ -26154,12 +26207,7 @@ ${code}
|
|
|
26154
26207
|
if (prefixOnly || !Object.prototype.hasOwnProperty.call(this.builtins, name)) {
|
|
26155
26208
|
return Object.prototype.hasOwnProperty.call(this.overrides, specifier) ? { found: true, value: this.overrides[specifier] } : { found: false, value: void 0 };
|
|
26156
26209
|
}
|
|
26157
|
-
if (name === "module"
|
|
26158
|
-
return {
|
|
26159
|
-
found: true,
|
|
26160
|
-
value: { ...this.builtins.module, createRequire: () => this.makeRequire(importer) }
|
|
26161
|
-
};
|
|
26162
|
-
}
|
|
26210
|
+
if (name === "module") return { found: true, value: this.moduleApi };
|
|
26163
26211
|
return { found: true, value: this.builtins[name] };
|
|
26164
26212
|
}
|
|
26165
26213
|
exists(path) {
|
|
@@ -26267,6 +26315,108 @@ function splitSpecifier(specifier) {
|
|
|
26267
26315
|
return { name: parts.slice(0, size).join("/"), subpath: parts.slice(size).join("/") };
|
|
26268
26316
|
}
|
|
26269
26317
|
|
|
26318
|
+
// src/node/diagnostics-channel.ts
|
|
26319
|
+
function createDiagnosticsChannel() {
|
|
26320
|
+
const channels2 = /* @__PURE__ */ new Map();
|
|
26321
|
+
class Channel {
|
|
26322
|
+
constructor(name) {
|
|
26323
|
+
this.name = name;
|
|
26324
|
+
}
|
|
26325
|
+
name;
|
|
26326
|
+
listeners = /* @__PURE__ */ new Set();
|
|
26327
|
+
get hasSubscribers() {
|
|
26328
|
+
return this.listeners.size > 0;
|
|
26329
|
+
}
|
|
26330
|
+
subscribe(fn) {
|
|
26331
|
+
if (typeof fn !== "function") throw new TypeError("subscriber must be a function");
|
|
26332
|
+
this.listeners.add(fn);
|
|
26333
|
+
}
|
|
26334
|
+
unsubscribe(fn) {
|
|
26335
|
+
return this.listeners.delete(fn);
|
|
26336
|
+
}
|
|
26337
|
+
publish(message) {
|
|
26338
|
+
for (const fn of [...this.listeners]) {
|
|
26339
|
+
try {
|
|
26340
|
+
fn(message, this.name);
|
|
26341
|
+
} catch (error) {
|
|
26342
|
+
queueMicrotask(() => {
|
|
26343
|
+
throw error;
|
|
26344
|
+
});
|
|
26345
|
+
}
|
|
26346
|
+
}
|
|
26347
|
+
}
|
|
26348
|
+
}
|
|
26349
|
+
const channel = (name) => {
|
|
26350
|
+
if (typeof name !== "string" && typeof name !== "symbol") throw new TypeError("channel name must be a string or symbol");
|
|
26351
|
+
let result = channels2.get(name);
|
|
26352
|
+
if (!result) {
|
|
26353
|
+
result = new Channel(name);
|
|
26354
|
+
channels2.set(name, result);
|
|
26355
|
+
}
|
|
26356
|
+
return result;
|
|
26357
|
+
};
|
|
26358
|
+
return {
|
|
26359
|
+
Channel,
|
|
26360
|
+
channel,
|
|
26361
|
+
hasSubscribers: (name) => channels2.get(name)?.hasSubscribers ?? false,
|
|
26362
|
+
subscribe: (name, fn) => channel(name).subscribe(fn),
|
|
26363
|
+
unsubscribe: (name, fn) => channels2.get(name)?.unsubscribe(fn) ?? false
|
|
26364
|
+
};
|
|
26365
|
+
}
|
|
26366
|
+
|
|
26367
|
+
// src/node/ipc-channel.ts
|
|
26368
|
+
var IPC_CHANNEL_ENV = "SANDBOXEDJS_IPC_CHANNEL";
|
|
26369
|
+
var channels = /* @__PURE__ */ new Map();
|
|
26370
|
+
var closedChannels = /* @__PURE__ */ new Set();
|
|
26371
|
+
function newIpcChannelId() {
|
|
26372
|
+
const random = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : Math.random().toString(36).slice(2);
|
|
26373
|
+
return `ipc-${random}`;
|
|
26374
|
+
}
|
|
26375
|
+
var hostIpcTransport = {
|
|
26376
|
+
attach(id, side, onMessage, onDisconnect) {
|
|
26377
|
+
let channel = channels.get(id);
|
|
26378
|
+
if (!channel && !closedChannels.has(id)) {
|
|
26379
|
+
channel = { parent: { backlog: [] }, child: { backlog: [] }, closed: false };
|
|
26380
|
+
channels.set(id, channel);
|
|
26381
|
+
}
|
|
26382
|
+
if (!channel || channel.closed) {
|
|
26383
|
+
queueMicrotask(onDisconnect);
|
|
26384
|
+
return { send: () => {
|
|
26385
|
+
}, disconnect: () => {
|
|
26386
|
+
} };
|
|
26387
|
+
}
|
|
26388
|
+
const own = channel[side];
|
|
26389
|
+
const other = channel[side === "parent" ? "child" : "parent"];
|
|
26390
|
+
own.deliver = onMessage;
|
|
26391
|
+
own.disconnected = onDisconnect;
|
|
26392
|
+
for (const message of own.backlog.splice(0)) queueMicrotask(() => onMessage(message));
|
|
26393
|
+
return {
|
|
26394
|
+
send(message) {
|
|
26395
|
+
if (channel.closed) return;
|
|
26396
|
+
const copy = message === void 0 ? void 0 : JSON.parse(JSON.stringify(message));
|
|
26397
|
+
if (other.deliver) {
|
|
26398
|
+
const deliver = other.deliver;
|
|
26399
|
+
setTimeout(() => {
|
|
26400
|
+
if (!channel.closed) deliver(copy);
|
|
26401
|
+
}, 0);
|
|
26402
|
+
} else {
|
|
26403
|
+
other.backlog.push(copy);
|
|
26404
|
+
}
|
|
26405
|
+
},
|
|
26406
|
+
disconnect() {
|
|
26407
|
+
if (channel.closed) return;
|
|
26408
|
+
channel.closed = true;
|
|
26409
|
+
channels.delete(id);
|
|
26410
|
+
closedChannels.add(id);
|
|
26411
|
+
for (const end of [channel.parent, channel.child]) {
|
|
26412
|
+
const notify = end.disconnected;
|
|
26413
|
+
if (notify) setTimeout(notify, 0);
|
|
26414
|
+
}
|
|
26415
|
+
}
|
|
26416
|
+
};
|
|
26417
|
+
}
|
|
26418
|
+
};
|
|
26419
|
+
|
|
26270
26420
|
// src/node/readable-from.ts
|
|
26271
26421
|
function createReadableFrom(Readable) {
|
|
26272
26422
|
return function from(source, options = {}) {
|
|
@@ -26316,6 +26466,132 @@ function installReadableFrom(streamModule5) {
|
|
|
26316
26466
|
streamModule5.Readable.from = createReadableFrom(streamModule5.Readable);
|
|
26317
26467
|
}
|
|
26318
26468
|
|
|
26469
|
+
// src/node/parse-args.ts
|
|
26470
|
+
function argError(code, message) {
|
|
26471
|
+
return Object.assign(new TypeError(message), { code });
|
|
26472
|
+
}
|
|
26473
|
+
function parseArgs2(config2 = {}) {
|
|
26474
|
+
const args = config2.args ?? globalThis.process?.argv?.slice(2) ?? [];
|
|
26475
|
+
const options = config2.options ?? {};
|
|
26476
|
+
const strict = config2.strict ?? true;
|
|
26477
|
+
const allowPositionals = config2.allowPositionals ?? !strict;
|
|
26478
|
+
const allowNegative = config2.allowNegative ?? false;
|
|
26479
|
+
const byShort = /* @__PURE__ */ new Map();
|
|
26480
|
+
for (const [name, option] of Object.entries(options)) {
|
|
26481
|
+
if (option.type !== "string" && option.type !== "boolean") {
|
|
26482
|
+
throw argError("ERR_INVALID_ARG_VALUE", `The property 'options.${name}.type' must be one of: 'string', 'boolean'`);
|
|
26483
|
+
}
|
|
26484
|
+
if (option.short !== void 0) {
|
|
26485
|
+
if (option.short.length !== 1) {
|
|
26486
|
+
throw argError("ERR_INVALID_ARG_VALUE", `The property 'options.${name}.short' must be a single character`);
|
|
26487
|
+
}
|
|
26488
|
+
byShort.set(option.short, name);
|
|
26489
|
+
}
|
|
26490
|
+
}
|
|
26491
|
+
const tokens = [];
|
|
26492
|
+
const takesValue = (name) => options[name]?.type === "string";
|
|
26493
|
+
for (let index = 0; index < args.length; index++) {
|
|
26494
|
+
const arg = args[index];
|
|
26495
|
+
if (arg === "--") {
|
|
26496
|
+
tokens.push({ kind: "option-terminator", index });
|
|
26497
|
+
for (let rest = index + 1; rest < args.length; rest++) tokens.push({ kind: "positional", index: rest, value: args[rest] });
|
|
26498
|
+
break;
|
|
26499
|
+
}
|
|
26500
|
+
if (arg.startsWith("--") && arg.length > 2) {
|
|
26501
|
+
const equals = arg.indexOf("=");
|
|
26502
|
+
if (equals !== -1) {
|
|
26503
|
+
tokens.push({ kind: "option", name: arg.slice(2, equals), rawName: arg.slice(0, equals), index, value: arg.slice(equals + 1), inlineValue: true });
|
|
26504
|
+
continue;
|
|
26505
|
+
}
|
|
26506
|
+
const name = arg.slice(2);
|
|
26507
|
+
if (takesValue(name) && index + 1 < args.length) {
|
|
26508
|
+
tokens.push({ kind: "option", name, rawName: arg, index, value: args[index + 1], inlineValue: false });
|
|
26509
|
+
index++;
|
|
26510
|
+
} else {
|
|
26511
|
+
tokens.push({ kind: "option", name, rawName: arg, index, value: void 0, inlineValue: void 0 });
|
|
26512
|
+
}
|
|
26513
|
+
continue;
|
|
26514
|
+
}
|
|
26515
|
+
if (arg.startsWith("-") && arg.length > 1) {
|
|
26516
|
+
for (let at = 1; at < arg.length; at++) {
|
|
26517
|
+
const short = arg[at];
|
|
26518
|
+
const name = byShort.get(short) ?? short;
|
|
26519
|
+
if (takesValue(name)) {
|
|
26520
|
+
if (at + 1 < arg.length) {
|
|
26521
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: arg.slice(at + 1), inlineValue: true });
|
|
26522
|
+
} else if (index + 1 < args.length) {
|
|
26523
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: args[index + 1], inlineValue: false });
|
|
26524
|
+
index++;
|
|
26525
|
+
} else {
|
|
26526
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: void 0, inlineValue: void 0 });
|
|
26527
|
+
}
|
|
26528
|
+
break;
|
|
26529
|
+
}
|
|
26530
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: void 0, inlineValue: void 0 });
|
|
26531
|
+
}
|
|
26532
|
+
continue;
|
|
26533
|
+
}
|
|
26534
|
+
tokens.push({ kind: "positional", index, value: arg });
|
|
26535
|
+
}
|
|
26536
|
+
const values = /* @__PURE__ */ Object.create(null);
|
|
26537
|
+
const positionals = [];
|
|
26538
|
+
const store = (name, value) => {
|
|
26539
|
+
if (options[name]?.multiple) {
|
|
26540
|
+
const list = values[name] ?? [];
|
|
26541
|
+
list.push(value);
|
|
26542
|
+
values[name] = list;
|
|
26543
|
+
} else {
|
|
26544
|
+
values[name] = value;
|
|
26545
|
+
}
|
|
26546
|
+
};
|
|
26547
|
+
for (const token of tokens) {
|
|
26548
|
+
if (token.kind === "option-terminator") continue;
|
|
26549
|
+
if (token.kind === "positional") {
|
|
26550
|
+
if (!allowPositionals) {
|
|
26551
|
+
throw argError("ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL", `Unexpected argument '${token.value}'. This command does not take positional arguments`);
|
|
26552
|
+
}
|
|
26553
|
+
positionals.push(token.value);
|
|
26554
|
+
continue;
|
|
26555
|
+
}
|
|
26556
|
+
let name = token.name;
|
|
26557
|
+
let negated = false;
|
|
26558
|
+
if (allowNegative && name.startsWith("no-") && token.rawName.startsWith("--") && options[name.slice(3)]?.type === "boolean") {
|
|
26559
|
+
name = name.slice(3);
|
|
26560
|
+
negated = true;
|
|
26561
|
+
}
|
|
26562
|
+
const option = options[name];
|
|
26563
|
+
if (!option) {
|
|
26564
|
+
if (strict) {
|
|
26565
|
+
throw argError(
|
|
26566
|
+
"ERR_PARSE_ARGS_UNKNOWN_OPTION",
|
|
26567
|
+
`Unknown option '${token.rawName}'${allowPositionals ? `. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- ${JSON.stringify(token.rawName)}'` : ""}`
|
|
26568
|
+
);
|
|
26569
|
+
}
|
|
26570
|
+
store(name, token.value ?? true);
|
|
26571
|
+
continue;
|
|
26572
|
+
}
|
|
26573
|
+
if (option.type === "string") {
|
|
26574
|
+
if (token.value === void 0) {
|
|
26575
|
+
if (strict) throw argError("ERR_PARSE_ARGS_INVALID_OPTION_VALUE", `Option '${token.rawName} <value>' argument missing`);
|
|
26576
|
+
store(name, true);
|
|
26577
|
+
continue;
|
|
26578
|
+
}
|
|
26579
|
+
store(name, token.value);
|
|
26580
|
+
} else {
|
|
26581
|
+
if (token.inlineValue && strict) {
|
|
26582
|
+
throw argError("ERR_PARSE_ARGS_INVALID_OPTION_VALUE", `Option '${token.rawName}' does not take an argument`);
|
|
26583
|
+
}
|
|
26584
|
+
store(name, !negated);
|
|
26585
|
+
}
|
|
26586
|
+
}
|
|
26587
|
+
for (const [name, option] of Object.entries(options)) {
|
|
26588
|
+
if (option.default !== void 0 && values[name] === void 0) {
|
|
26589
|
+
values[name] = Array.isArray(option.default) ? option.default.slice() : option.default;
|
|
26590
|
+
}
|
|
26591
|
+
}
|
|
26592
|
+
return config2.tokens ? { values, positionals, tokens } : { values, positionals };
|
|
26593
|
+
}
|
|
26594
|
+
|
|
26319
26595
|
// src/node/util-module.ts
|
|
26320
26596
|
var customInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
26321
26597
|
var promisifyCustom = /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom");
|
|
@@ -26344,8 +26620,9 @@ function render(value, depth, seen, options) {
|
|
|
26344
26620
|
if (value === null) return "null";
|
|
26345
26621
|
const object = value;
|
|
26346
26622
|
const custom = object[customInspect];
|
|
26347
|
-
if (typeof custom === "function") {
|
|
26348
|
-
|
|
26623
|
+
if (options.customInspect !== false && typeof custom === "function") {
|
|
26624
|
+
const result = custom.call(object, depth, options, inspect);
|
|
26625
|
+
if (result !== object) return typeof result === "string" ? result : render(result, depth, seen, options);
|
|
26349
26626
|
}
|
|
26350
26627
|
if (seen.has(object)) return "[Circular *1]";
|
|
26351
26628
|
if (depth < 0) return Array.isArray(object) ? "[Array]" : "[Object]";
|
|
@@ -26680,6 +26957,7 @@ var legacy = {
|
|
|
26680
26957
|
inspect.custom = customInspect;
|
|
26681
26958
|
var utilModule = {
|
|
26682
26959
|
parseEnv,
|
|
26960
|
+
parseArgs: parseArgs2,
|
|
26683
26961
|
format,
|
|
26684
26962
|
formatWithOptions,
|
|
26685
26963
|
inspect,
|
|
@@ -28255,6 +28533,28 @@ function createCryptoModule() {
|
|
|
28255
28533
|
};
|
|
28256
28534
|
return api;
|
|
28257
28535
|
},
|
|
28536
|
+
pbkdf2Sync(password, salt, iterations, keylen, digest2) {
|
|
28537
|
+
return pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28538
|
+
},
|
|
28539
|
+
/* Node derives the key on the libuv thread pool and calls back from the poll
|
|
28540
|
+
* phase. Here it is derived on the calling thread — the ordering a program
|
|
28541
|
+
* observes is the same (the call returns first, the callback comes on a later
|
|
28542
|
+
* turn), but the main thread is busy while it computes. Invalid arguments throw
|
|
28543
|
+
* synchronously, as in Node. */
|
|
28544
|
+
pbkdf2(password, salt, iterations, keylen, digest2, callback) {
|
|
28545
|
+
if (typeof callback !== "function") {
|
|
28546
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
28547
|
+
}
|
|
28548
|
+
hashFor(digest2);
|
|
28549
|
+
let key;
|
|
28550
|
+
let failure2 = null;
|
|
28551
|
+
try {
|
|
28552
|
+
key = pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28553
|
+
} catch (error) {
|
|
28554
|
+
failure2 = error instanceof Error ? error : new Error(String(error));
|
|
28555
|
+
}
|
|
28556
|
+
setTimeout(() => failure2 ? callback(failure2) : callback(null, key), 0);
|
|
28557
|
+
},
|
|
28258
28558
|
randomBytes(size, callback) {
|
|
28259
28559
|
const value = Buffer2.alloc(size);
|
|
28260
28560
|
cryptoObject.getRandomValues(value);
|
|
@@ -28304,6 +28604,15 @@ function createCryptoModule() {
|
|
|
28304
28604
|
constants: {}
|
|
28305
28605
|
};
|
|
28306
28606
|
}
|
|
28607
|
+
function pbkdf2Key(password, salt, iterations, keylen, digest2) {
|
|
28608
|
+
if (!Number.isInteger(iterations) || iterations < 1) {
|
|
28609
|
+
throw Object.assign(new RangeError(`The value of "iterations" is out of range. It must be >= 1. Received ${iterations}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28610
|
+
}
|
|
28611
|
+
if (!Number.isInteger(keylen) || keylen < 0) {
|
|
28612
|
+
throw Object.assign(new RangeError(`The value of "keylen" is out of range. It must be >= 0. Received ${keylen}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28613
|
+
}
|
|
28614
|
+
return Buffer2.from(pbkdf2.pbkdf2(hashFor(digest2), toBytes2(password), toBytes2(salt), { c: iterations, dkLen: keylen }));
|
|
28615
|
+
}
|
|
28307
28616
|
function hashFor(algorithm) {
|
|
28308
28617
|
const hash = hashes[algorithm.toLowerCase()];
|
|
28309
28618
|
if (!hash) throw Object.assign(new Error(`Digest method not supported: ${algorithm}`), { code: "ERR_OSSL_EVP_UNSUPPORTED" });
|
|
@@ -28415,20 +28724,10 @@ function concat6(parts) {
|
|
|
28415
28724
|
return joined;
|
|
28416
28725
|
}
|
|
28417
28726
|
var ChildProcess = class extends EventEmitter4__default.default {
|
|
28418
|
-
|
|
28419
|
-
|
|
28420
|
-
stdin;
|
|
28421
|
-
stdio;
|
|
28422
|
-
pid;
|
|
28423
|
-
exitCode = null;
|
|
28424
|
-
signalCode = null;
|
|
28425
|
-
killed = false;
|
|
28426
|
-
spawnfile;
|
|
28427
|
-
spawnargs;
|
|
28428
|
-
handle;
|
|
28429
|
-
settled = false;
|
|
28430
|
-
constructor(handle, file3, args) {
|
|
28727
|
+
constructor(handle, file3, args, referenceChanged = () => {
|
|
28728
|
+
}) {
|
|
28431
28729
|
super();
|
|
28730
|
+
this.referenceChanged = referenceChanged;
|
|
28432
28731
|
this.handle = handle;
|
|
28433
28732
|
this.pid = handle.pid;
|
|
28434
28733
|
this.spawnfile = file3;
|
|
@@ -28453,31 +28752,90 @@ var ChildProcess = class extends EventEmitter4__default.default {
|
|
|
28453
28752
|
handle.on("stdout", (text2) => this.stdout.write(text2));
|
|
28454
28753
|
handle.on("stderr", (text2) => this.stderr.write(text2));
|
|
28455
28754
|
handle.on("exit", (code) => this.finish(code));
|
|
28456
|
-
|
|
28755
|
+
referenceChanged(1);
|
|
28756
|
+
try {
|
|
28757
|
+
handle.exec();
|
|
28758
|
+
} catch (error) {
|
|
28759
|
+
this.unref();
|
|
28760
|
+
throw error;
|
|
28761
|
+
}
|
|
28457
28762
|
}
|
|
28763
|
+
referenceChanged;
|
|
28764
|
+
stdout = new streamModule4__default.default.PassThrough();
|
|
28765
|
+
stderr = new streamModule4__default.default.PassThrough();
|
|
28766
|
+
stdin;
|
|
28767
|
+
stdio;
|
|
28768
|
+
pid;
|
|
28769
|
+
exitCode = null;
|
|
28770
|
+
signalCode = null;
|
|
28771
|
+
killed = false;
|
|
28772
|
+
spawnfile;
|
|
28773
|
+
spawnargs;
|
|
28774
|
+
handle;
|
|
28775
|
+
settled = false;
|
|
28776
|
+
referenced = true;
|
|
28458
28777
|
kill(signal = "SIGTERM") {
|
|
28459
28778
|
this.killed = true;
|
|
28460
28779
|
this.handle.kill(typeof signal === "number" ? "SIGTERM" : signal);
|
|
28461
28780
|
return true;
|
|
28462
28781
|
}
|
|
28463
28782
|
ref() {
|
|
28783
|
+
if (!this.settled && !this.referenced) {
|
|
28784
|
+
this.referenced = true;
|
|
28785
|
+
this.referenceChanged(1);
|
|
28786
|
+
}
|
|
28464
28787
|
return this;
|
|
28465
28788
|
}
|
|
28466
28789
|
unref() {
|
|
28790
|
+
if (this.referenced) {
|
|
28791
|
+
this.referenced = false;
|
|
28792
|
+
this.referenceChanged(-1);
|
|
28793
|
+
}
|
|
28467
28794
|
return this;
|
|
28468
28795
|
}
|
|
28469
|
-
|
|
28470
|
-
|
|
28471
|
-
|
|
28472
|
-
|
|
28473
|
-
|
|
28474
|
-
|
|
28796
|
+
channel;
|
|
28797
|
+
channelOpen = false;
|
|
28798
|
+
/** Open the parent's end of a `fork` channel. */
|
|
28799
|
+
attachChannel(transport, id) {
|
|
28800
|
+
this.channelOpen = true;
|
|
28801
|
+
this.channel = transport.attach(
|
|
28802
|
+
id,
|
|
28803
|
+
"parent",
|
|
28804
|
+
(message) => this.emit("message", message, void 0),
|
|
28805
|
+
() => this.channelClosed()
|
|
28806
|
+
);
|
|
28475
28807
|
}
|
|
28476
28808
|
get connected() {
|
|
28477
|
-
return
|
|
28809
|
+
return this.channelOpen;
|
|
28810
|
+
}
|
|
28811
|
+
/** `send(message[, sendHandle][, options][, callback])`, as Node spells it. */
|
|
28812
|
+
send(message, ...rest) {
|
|
28813
|
+
const callback = rest.find((value) => typeof value === "function");
|
|
28814
|
+
if (!this.channel || !this.channelOpen) {
|
|
28815
|
+
const error = Object.assign(new Error("Channel closed"), { code: "ERR_IPC_CHANNEL_CLOSED" });
|
|
28816
|
+
if (callback) queueMicrotask(() => callback(error));
|
|
28817
|
+
else queueMicrotask(() => this.emit("error", error));
|
|
28818
|
+
return false;
|
|
28819
|
+
}
|
|
28820
|
+
this.channel.send(message);
|
|
28821
|
+
if (callback) queueMicrotask(() => callback(null));
|
|
28822
|
+
return true;
|
|
28823
|
+
}
|
|
28824
|
+
disconnect() {
|
|
28825
|
+
if (!this.channelOpen) return;
|
|
28826
|
+
this.channel?.disconnect();
|
|
28827
|
+
this.channelClosed();
|
|
28828
|
+
}
|
|
28829
|
+
channelClosed() {
|
|
28830
|
+
if (!this.channelOpen) return;
|
|
28831
|
+
this.channelOpen = false;
|
|
28832
|
+
this.emit("disconnect");
|
|
28478
28833
|
}
|
|
28479
28834
|
finish(code) {
|
|
28480
28835
|
if (this.settled) return;
|
|
28836
|
+
this.channel?.disconnect();
|
|
28837
|
+
this.channelClosed();
|
|
28838
|
+
this.unref();
|
|
28481
28839
|
this.settled = true;
|
|
28482
28840
|
this.exitCode = code;
|
|
28483
28841
|
this.stdout.end();
|
|
@@ -28486,7 +28844,7 @@ var ChildProcess = class extends EventEmitter4__default.default {
|
|
|
28486
28844
|
queueMicrotask(() => this.emit("close", code, null));
|
|
28487
28845
|
}
|
|
28488
28846
|
};
|
|
28489
|
-
function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv = () => ({})) {
|
|
28847
|
+
function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv = () => ({}), lifecycle = {}) {
|
|
28490
28848
|
const environmentFor = (options) => options.env ? { ...options.env } : defaultEnv();
|
|
28491
28849
|
const throughShell = (command, options) => {
|
|
28492
28850
|
const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
|
|
@@ -28497,16 +28855,24 @@ function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv
|
|
|
28497
28855
|
if (stdio === "ignore") return true;
|
|
28498
28856
|
return Array.isArray(stdio) && stdio[0] === "ignore";
|
|
28499
28857
|
};
|
|
28858
|
+
const wantsChannel = (options) => Array.isArray(options.stdio) && options.stdio.includes("ipc");
|
|
28500
28859
|
const start2 = (file3, args, options) => {
|
|
28501
28860
|
const resolved = options.shell ? throughShell([file3, ...args].join(" "), options) : { file: file3, args };
|
|
28861
|
+
const channelId = wantsChannel(options) && lifecycle.ipc ? newIpcChannelId() : void 0;
|
|
28502
28862
|
const handle = spawnChild({
|
|
28503
28863
|
command: resolved.file,
|
|
28504
28864
|
args: resolved.args,
|
|
28505
28865
|
cwd: options.cwd ?? defaultCwd(),
|
|
28506
|
-
env: environmentFor(options),
|
|
28866
|
+
env: channelId ? { ...environmentFor(options), [IPC_CHANNEL_ENV]: channelId } : environmentFor(options),
|
|
28867
|
+
...options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[0] === "inherit" ? { inheritStdio: true } : {},
|
|
28507
28868
|
...stdinIgnored(options) ? { stdinIgnored: true } : {}
|
|
28508
28869
|
});
|
|
28509
|
-
|
|
28870
|
+
const child = new ChildProcess(handle, resolved.file, resolved.args, lifecycle.referenceChanged);
|
|
28871
|
+
if (channelId && lifecycle.ipc) child.attachChannel(lifecycle.ipc, channelId);
|
|
28872
|
+
const inherited = (index) => options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[index] === "inherit";
|
|
28873
|
+
if (inherited(1)) child.stdout.on("data", (chunk) => lifecycle.stdout?.(chunk.toString()));
|
|
28874
|
+
if (inherited(2)) child.stderr.on("data", (chunk) => lifecycle.stderr?.(chunk.toString()));
|
|
28875
|
+
return child;
|
|
28510
28876
|
};
|
|
28511
28877
|
const spawn = (file3, args = [], options = {}) => {
|
|
28512
28878
|
if (!Array.isArray(args)) return start2(file3, [], args);
|
|
@@ -28549,7 +28915,13 @@ ${err.join("")}`),
|
|
|
28549
28915
|
spawn,
|
|
28550
28916
|
exec,
|
|
28551
28917
|
execFile,
|
|
28552
|
-
fork: (modulePath, args = [], options = {}) =>
|
|
28918
|
+
fork: (modulePath, args = [], options = {}) => {
|
|
28919
|
+
const [list, opts] = Array.isArray(args) ? [args, options] : [[], args ?? {}];
|
|
28920
|
+
const stdio = Array.isArray(opts.stdio) ? opts.stdio : typeof opts.stdio === "string" ? [opts.stdio, opts.stdio, opts.stdio] : opts.silent ? ["pipe", "pipe", "pipe"] : ["inherit", "inherit", "inherit"];
|
|
28921
|
+
const withChannel = stdio.includes("ipc") ? stdio : [...stdio, "ipc"];
|
|
28922
|
+
const execArgv = (opts.execArgv ?? []).filter((flag) => !/^--(inspect|debug)/.test(flag));
|
|
28923
|
+
return start2("node", [...execArgv, modulePath, ...list], { ...opts, shell: false, stdio: withChannel });
|
|
28924
|
+
},
|
|
28553
28925
|
...buildSyncFamily(syncSpawn, throughShell, defaultCwd, environmentFor),
|
|
28554
28926
|
ChildProcess
|
|
28555
28927
|
};
|
|
@@ -29175,11 +29547,14 @@ function createCoreModules(options) {
|
|
|
29175
29547
|
});
|
|
29176
29548
|
const stderrWrite = options.stderr ?? (() => {
|
|
29177
29549
|
});
|
|
29178
|
-
const timers = createTrackedTimers((error) => reportUncaught(error));
|
|
29550
|
+
const timers = createTrackedTimers((error) => reportUncaught(error), () => runTicks());
|
|
29179
29551
|
const processObject = Object.assign(new EventEmitter4__default.default(), processShim__default.default, {
|
|
29180
29552
|
argv: options.argv?.slice() ?? ["/usr/bin/node"],
|
|
29181
29553
|
argv0: "node",
|
|
29182
29554
|
execPath: "/usr/bin/node",
|
|
29555
|
+
/* `process/browser.js` has no `execArgv`; Node always has an array, and
|
|
29556
|
+
* CLIs that fork copy it (`[...process.execArgv]`). */
|
|
29557
|
+
execArgv: [],
|
|
29183
29558
|
env: env2,
|
|
29184
29559
|
platform: "linux",
|
|
29185
29560
|
arch: "x64",
|
|
@@ -29218,13 +29593,14 @@ function createCoreModules(options) {
|
|
|
29218
29593
|
options.onExit?.(status);
|
|
29219
29594
|
},
|
|
29220
29595
|
nextTick: (fn, ...args) => {
|
|
29221
|
-
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
|
|
29227
|
-
|
|
29596
|
+
if (typeof fn !== "function") {
|
|
29597
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
29598
|
+
}
|
|
29599
|
+
tickQueue.push([fn, args]);
|
|
29600
|
+
if (!tickDrainScheduled) {
|
|
29601
|
+
tickDrainScheduled = true;
|
|
29602
|
+
afterMicrotasks(runTicks);
|
|
29603
|
+
}
|
|
29228
29604
|
},
|
|
29229
29605
|
kill: () => true
|
|
29230
29606
|
});
|
|
@@ -29232,10 +29608,42 @@ function createCoreModules(options) {
|
|
|
29232
29608
|
const implementation = EventEmitter4__default.default.prototype[method];
|
|
29233
29609
|
if (typeof implementation === "function") processObject[method] = implementation;
|
|
29234
29610
|
}
|
|
29611
|
+
const hrtime = (previous) => {
|
|
29612
|
+
const now = performance.timeOrigin + performance.now();
|
|
29613
|
+
let seconds = Math.floor(now / 1e3);
|
|
29614
|
+
let nanoseconds = Math.floor(now % 1e3 * 1e6);
|
|
29615
|
+
if (previous) {
|
|
29616
|
+
seconds -= previous[0];
|
|
29617
|
+
nanoseconds -= previous[1];
|
|
29618
|
+
if (nanoseconds < 0) {
|
|
29619
|
+
seconds -= 1;
|
|
29620
|
+
nanoseconds += 1e9;
|
|
29621
|
+
}
|
|
29622
|
+
}
|
|
29623
|
+
return [seconds, nanoseconds];
|
|
29624
|
+
};
|
|
29625
|
+
hrtime.bigint = () => {
|
|
29626
|
+
const [seconds, nanoseconds] = hrtime();
|
|
29627
|
+
return BigInt(seconds) * 1000000000n + BigInt(nanoseconds);
|
|
29628
|
+
};
|
|
29629
|
+
processObject.hrtime = hrtime;
|
|
29235
29630
|
const tty = options.tty === true;
|
|
29236
29631
|
processObject.stdout = makeOutputStream(stdoutWrite, 1, tty);
|
|
29237
29632
|
processObject.stderr = makeOutputStream(stderrWrite, 2, tty);
|
|
29238
29633
|
let exiting = false;
|
|
29634
|
+
const tickQueue = [];
|
|
29635
|
+
let tickDrainScheduled = false;
|
|
29636
|
+
const runTicks = () => {
|
|
29637
|
+
tickDrainScheduled = false;
|
|
29638
|
+
while (tickQueue.length && !exiting) {
|
|
29639
|
+
const [fn, args] = tickQueue.shift();
|
|
29640
|
+
try {
|
|
29641
|
+
fn(...args);
|
|
29642
|
+
} catch (error) {
|
|
29643
|
+
reportUncaught(error);
|
|
29644
|
+
}
|
|
29645
|
+
}
|
|
29646
|
+
};
|
|
29239
29647
|
const emitExit = (status) => {
|
|
29240
29648
|
if (exiting) return;
|
|
29241
29649
|
exiting = true;
|
|
@@ -29303,13 +29711,16 @@ function createCoreModules(options) {
|
|
|
29303
29711
|
const moduleBuiltin = {
|
|
29304
29712
|
builtinModules: builtinNames2.flatMap((name) => [name, `node:${name}`]),
|
|
29305
29713
|
isBuiltin: (name) => builtinNames2.includes(name.replace(/^node:/, "")),
|
|
29714
|
+
findSourceMap: () => void 0,
|
|
29306
29715
|
createRequire: () => {
|
|
29307
29716
|
throw new Error("createRequire is only available inside a loaded module");
|
|
29308
29717
|
}
|
|
29309
29718
|
};
|
|
29310
29719
|
let inFlightRequests = 0;
|
|
29720
|
+
let requestsStarted = 0;
|
|
29311
29721
|
const trackRequest = () => {
|
|
29312
29722
|
inFlightRequests++;
|
|
29723
|
+
requestsStarted += 1;
|
|
29313
29724
|
return () => {
|
|
29314
29725
|
inFlightRequests--;
|
|
29315
29726
|
};
|
|
@@ -29323,7 +29734,86 @@ function createCoreModules(options) {
|
|
|
29323
29734
|
};
|
|
29324
29735
|
const http = options.http ? createHttpModule(options.http.router, options.http.owner, httpOptions, "http:") : createUnsupportedModule("http");
|
|
29325
29736
|
const https = options.http ? createHttpModule(options.http.router, options.http.owner, httpOptions, "https:") : createUnsupportedModule("https");
|
|
29326
|
-
|
|
29737
|
+
let referencedChildren = 0;
|
|
29738
|
+
const childProcess = options.spawnChild ? createChildProcessModule(options.spawnChild, () => cwd, options.syncSpawn, () => ({ ...processObject.env }), {
|
|
29739
|
+
referenceChanged: (delta) => {
|
|
29740
|
+
referencedChildren += delta;
|
|
29741
|
+
},
|
|
29742
|
+
stdout: options.stdout,
|
|
29743
|
+
stderr: options.stderr,
|
|
29744
|
+
...options.ipc ? { ipc: options.ipc } : {}
|
|
29745
|
+
}) : createUnsupportedModule("child_process");
|
|
29746
|
+
let channelReferenced = 0;
|
|
29747
|
+
const channelId = env2[IPC_CHANNEL_ENV];
|
|
29748
|
+
if (channelId && options.ipc) {
|
|
29749
|
+
delete env2[IPC_CHANNEL_ENV];
|
|
29750
|
+
let open = true;
|
|
29751
|
+
let referenced = true;
|
|
29752
|
+
channelReferenced = 1;
|
|
29753
|
+
const close = () => {
|
|
29754
|
+
if (!open) return;
|
|
29755
|
+
open = false;
|
|
29756
|
+
if (referenced) channelReferenced = 0;
|
|
29757
|
+
processObject.connected = false;
|
|
29758
|
+
delete processObject.send;
|
|
29759
|
+
try {
|
|
29760
|
+
processObject.emit("disconnect");
|
|
29761
|
+
} catch (error) {
|
|
29762
|
+
reportUncaught(error);
|
|
29763
|
+
}
|
|
29764
|
+
runTicks();
|
|
29765
|
+
};
|
|
29766
|
+
const endpoint = options.ipc.attach(
|
|
29767
|
+
channelId,
|
|
29768
|
+
"child",
|
|
29769
|
+
(message) => {
|
|
29770
|
+
try {
|
|
29771
|
+
processObject.emit("message", message, void 0);
|
|
29772
|
+
} catch (error) {
|
|
29773
|
+
reportUncaught(error);
|
|
29774
|
+
}
|
|
29775
|
+
runTicks();
|
|
29776
|
+
},
|
|
29777
|
+
close
|
|
29778
|
+
);
|
|
29779
|
+
processObject.connected = true;
|
|
29780
|
+
processObject.send = (message, ...rest) => {
|
|
29781
|
+
const callback = rest.find((value) => typeof value === "function");
|
|
29782
|
+
if (!open) {
|
|
29783
|
+
const error = Object.assign(new Error("Channel closed"), { code: "ERR_IPC_CHANNEL_CLOSED" });
|
|
29784
|
+
if (callback) defer(() => callback(error));
|
|
29785
|
+
else defer(() => {
|
|
29786
|
+
processObject.emit("error", error);
|
|
29787
|
+
});
|
|
29788
|
+
return false;
|
|
29789
|
+
}
|
|
29790
|
+
endpoint.send(message);
|
|
29791
|
+
if (callback) defer(() => callback(null));
|
|
29792
|
+
return true;
|
|
29793
|
+
};
|
|
29794
|
+
processObject.disconnect = () => {
|
|
29795
|
+
if (open) {
|
|
29796
|
+
endpoint.disconnect();
|
|
29797
|
+
close();
|
|
29798
|
+
}
|
|
29799
|
+
};
|
|
29800
|
+
processObject.channel = {
|
|
29801
|
+
ref() {
|
|
29802
|
+
if (open && !referenced) {
|
|
29803
|
+
referenced = true;
|
|
29804
|
+
channelReferenced = 1;
|
|
29805
|
+
}
|
|
29806
|
+
return this;
|
|
29807
|
+
},
|
|
29808
|
+
unref() {
|
|
29809
|
+
if (referenced) {
|
|
29810
|
+
referenced = false;
|
|
29811
|
+
channelReferenced = 0;
|
|
29812
|
+
}
|
|
29813
|
+
return this;
|
|
29814
|
+
}
|
|
29815
|
+
};
|
|
29816
|
+
}
|
|
29327
29817
|
const readline = createReadlineModule(() => processObject.stdin, () => processObject.stdout);
|
|
29328
29818
|
const dns = createDnsModule(defer);
|
|
29329
29819
|
const builtins = {
|
|
@@ -29335,6 +29825,7 @@ function createCoreModules(options) {
|
|
|
29335
29825
|
console: consoleObject,
|
|
29336
29826
|
constants: fs.constants,
|
|
29337
29827
|
crypto: createCryptoModule(),
|
|
29828
|
+
diagnostics_channel: createDiagnosticsChannel(),
|
|
29338
29829
|
dns,
|
|
29339
29830
|
"dns/promises": dns.promises,
|
|
29340
29831
|
events: EventEmitter4__default.default,
|
|
@@ -29353,6 +29844,25 @@ function createCoreModules(options) {
|
|
|
29353
29844
|
readline,
|
|
29354
29845
|
"readline/promises": readline.promises,
|
|
29355
29846
|
stream: streamModule4__default.default,
|
|
29847
|
+
"stream/web": Object.fromEntries([
|
|
29848
|
+
"ReadableStream",
|
|
29849
|
+
"ReadableStreamDefaultReader",
|
|
29850
|
+
"ReadableStreamBYOBReader",
|
|
29851
|
+
"ReadableStreamDefaultController",
|
|
29852
|
+
"ReadableByteStreamController",
|
|
29853
|
+
"ReadableStreamBYOBRequest",
|
|
29854
|
+
"WritableStream",
|
|
29855
|
+
"WritableStreamDefaultWriter",
|
|
29856
|
+
"WritableStreamDefaultController",
|
|
29857
|
+
"TransformStream",
|
|
29858
|
+
"TransformStreamDefaultController",
|
|
29859
|
+
"ByteLengthQueuingStrategy",
|
|
29860
|
+
"CountQueuingStrategy",
|
|
29861
|
+
"TextEncoderStream",
|
|
29862
|
+
"TextDecoderStream",
|
|
29863
|
+
"CompressionStream",
|
|
29864
|
+
"DecompressionStream"
|
|
29865
|
+
].filter((name) => name in globalThis).map((name) => [name, globalThis[name]])),
|
|
29356
29866
|
"stream/promises": createStreamPromises(),
|
|
29357
29867
|
string_decoder: stringDecoderModule__default.default,
|
|
29358
29868
|
timers: { ...timersModule__default.default, ...timers.api },
|
|
@@ -29384,7 +29894,57 @@ function createCoreModules(options) {
|
|
|
29384
29894
|
})
|
|
29385
29895
|
};
|
|
29386
29896
|
for (const name of stubNames) builtins[name] = createUnsupportedModule(name);
|
|
29897
|
+
builtins.worker_threads = {
|
|
29898
|
+
MessagePort: globalThis.MessagePort ?? class MessagePort {
|
|
29899
|
+
},
|
|
29900
|
+
markAsUncloneable: () => {
|
|
29901
|
+
},
|
|
29902
|
+
isMarkedAsUncloneable: () => false,
|
|
29903
|
+
markAsUntransferable: () => {
|
|
29904
|
+
},
|
|
29905
|
+
isMarkedAsUntransferable: () => false
|
|
29906
|
+
};
|
|
29387
29907
|
builtins.net = createNetModule();
|
|
29908
|
+
builtins.inspector = createUnsupportedModule("inspector", {
|
|
29909
|
+
url: () => void 0,
|
|
29910
|
+
close: () => {
|
|
29911
|
+
},
|
|
29912
|
+
waitForDebugger: () => {
|
|
29913
|
+
throw Object.assign(new Error("Inspector is not active"), { code: "ERR_INSPECTOR_NOT_ACTIVE" });
|
|
29914
|
+
},
|
|
29915
|
+
console: consoleObject
|
|
29916
|
+
});
|
|
29917
|
+
builtins.v8 = createUnsupportedModule("v8", {
|
|
29918
|
+
getHeapStatistics: () => {
|
|
29919
|
+
const memory = performance.memory;
|
|
29920
|
+
const limit = memory?.jsHeapSizeLimit ?? 4 * 1024 ** 3;
|
|
29921
|
+
return {
|
|
29922
|
+
total_heap_size: memory?.totalJSHeapSize ?? 0,
|
|
29923
|
+
total_heap_size_executable: 0,
|
|
29924
|
+
total_physical_size: memory?.totalJSHeapSize ?? 0,
|
|
29925
|
+
total_available_size: limit - (memory?.usedJSHeapSize ?? 0),
|
|
29926
|
+
used_heap_size: memory?.usedJSHeapSize ?? 0,
|
|
29927
|
+
heap_size_limit: limit,
|
|
29928
|
+
malloced_memory: 0,
|
|
29929
|
+
peak_malloced_memory: 0,
|
|
29930
|
+
does_zap_garbage: 0,
|
|
29931
|
+
number_of_native_contexts: 1,
|
|
29932
|
+
number_of_detached_contexts: 0,
|
|
29933
|
+
total_global_handles_size: 0,
|
|
29934
|
+
used_global_handles_size: 0,
|
|
29935
|
+
external_memory: 0
|
|
29936
|
+
};
|
|
29937
|
+
},
|
|
29938
|
+
getHeapSpaceStatistics: () => [],
|
|
29939
|
+
getHeapCodeStatistics: () => ({ code_and_metadata_size: 0, bytecode_and_metadata_size: 0, external_script_source_size: 0, cpu_profiler_metadata_size: 0 }),
|
|
29940
|
+
cachedDataVersionTag: () => 0,
|
|
29941
|
+
setFlagsFromString: () => {
|
|
29942
|
+
},
|
|
29943
|
+
setHeapSnapshotNearHeapLimit: () => {
|
|
29944
|
+
},
|
|
29945
|
+
serialize: (value) => Buffer2.from(JSON.stringify(value) ?? "null"),
|
|
29946
|
+
deserialize: (buffer) => JSON.parse(Buffer2.from(buffer).toString("utf8"))
|
|
29947
|
+
});
|
|
29388
29948
|
const globals = {
|
|
29389
29949
|
Buffer: Buffer2,
|
|
29390
29950
|
console: consoleObject,
|
|
@@ -29419,7 +29979,7 @@ function createCoreModules(options) {
|
|
|
29419
29979
|
builtins,
|
|
29420
29980
|
globals,
|
|
29421
29981
|
process: processObject,
|
|
29422
|
-
pendingHandles: timers.pending,
|
|
29982
|
+
pendingHandles: () => timers.pending() + referencedChildren + channelReferenced,
|
|
29423
29983
|
pendingUnrefed: timers.pendingUnrefed,
|
|
29424
29984
|
/** Client requests sent but not yet read to completion. */
|
|
29425
29985
|
pendingRequests: () => inFlightRequests,
|
|
@@ -29428,6 +29988,18 @@ function createCoreModules(options) {
|
|
|
29428
29988
|
reportUnhandledRejection: (reason) => reportUncaught(reason, "unhandledRejection"),
|
|
29429
29989
|
exitStatus: () => normalizeExitCode(processObject.exitCode),
|
|
29430
29990
|
emitExit,
|
|
29991
|
+
runTicks,
|
|
29992
|
+
emitBeforeExit: (status) => {
|
|
29993
|
+
if (exiting || processObject.listenerCount("beforeExit") === 0) return false;
|
|
29994
|
+
try {
|
|
29995
|
+
processObject.emit("beforeExit", status);
|
|
29996
|
+
} catch (error) {
|
|
29997
|
+
reportUncaught(error);
|
|
29998
|
+
}
|
|
29999
|
+
runTicks();
|
|
30000
|
+
return true;
|
|
30001
|
+
},
|
|
30002
|
+
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
29431
30003
|
writeStdin: (data) => {
|
|
29432
30004
|
if (options.interactiveStdin) stdin.write(data);
|
|
29433
30005
|
},
|
|
@@ -29473,7 +30045,9 @@ var ASYNC_FS_METHODS = [
|
|
|
29473
30045
|
"close",
|
|
29474
30046
|
"read",
|
|
29475
30047
|
"write",
|
|
29476
|
-
"exists"
|
|
30048
|
+
"exists",
|
|
30049
|
+
"fsync",
|
|
30050
|
+
"fdatasync"
|
|
29477
30051
|
];
|
|
29478
30052
|
function createPathModule(cwd) {
|
|
29479
30053
|
const resolve3 = (...segments2) => pathModule__default.default.resolve(cwd(), ...segments2);
|
|
@@ -29696,6 +30270,12 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
29696
30270
|
unwatchFile: () => {
|
|
29697
30271
|
}
|
|
29698
30272
|
};
|
|
30273
|
+
fs.fsyncSync = (fd) => {
|
|
30274
|
+
requiredFd(fds, fd);
|
|
30275
|
+
};
|
|
30276
|
+
fs.fdatasyncSync = (fd) => {
|
|
30277
|
+
requiredFd(fds, fd);
|
|
30278
|
+
};
|
|
29699
30279
|
fs.ftruncateSync = (fd, length) => fs.truncateSync(requiredFd(fds, fd).path, length);
|
|
29700
30280
|
fs.fchmodSync = (fd, mode) => fs.chmodSync(requiredFd(fds, fd).path, mode);
|
|
29701
30281
|
fs.fchownSync = (fd, uid, gid) => fs.chownSync(requiredFd(fds, fd).path, uid, gid);
|
|
@@ -29756,6 +30336,8 @@ function makeFileHandle(fs, fd) {
|
|
|
29756
30336
|
return {
|
|
29757
30337
|
fd,
|
|
29758
30338
|
close: async () => fs.closeSync(fd),
|
|
30339
|
+
sync: async () => fs.fsyncSync(fd),
|
|
30340
|
+
datasync: async () => fs.fdatasyncSync(fd),
|
|
29759
30341
|
stat: async () => fs.fstatSync(fd),
|
|
29760
30342
|
truncate: async (length) => fs.ftruncateSync(fd, length),
|
|
29761
30343
|
chmod: async (mode) => fs.fchmodSync(fd, mode),
|
|
@@ -30038,8 +30620,28 @@ var ERRNO_CONSTANTS = {
|
|
|
30038
30620
|
EWOULDBLOCK: 11,
|
|
30039
30621
|
EXDEV: 18
|
|
30040
30622
|
};
|
|
30623
|
+
var afterMicrotasks = (() => {
|
|
30624
|
+
const host2 = globalThis.process;
|
|
30625
|
+
if (typeof host2?.nextTick === "function" && host2.versions?.node) return (fn) => host2.nextTick(fn);
|
|
30626
|
+
if (typeof MessageChannel === "function") {
|
|
30627
|
+
const queue = [];
|
|
30628
|
+
let channel = null;
|
|
30629
|
+
return (fn) => {
|
|
30630
|
+
if (!channel) {
|
|
30631
|
+
channel = new MessageChannel();
|
|
30632
|
+
channel.port1.onmessage = () => queue.shift()?.();
|
|
30633
|
+
}
|
|
30634
|
+
queue.push(fn);
|
|
30635
|
+
channel.port2.postMessage(null);
|
|
30636
|
+
};
|
|
30637
|
+
}
|
|
30638
|
+
return (fn) => {
|
|
30639
|
+
setTimeout(fn, 0);
|
|
30640
|
+
};
|
|
30641
|
+
})();
|
|
30041
30642
|
function createTrackedTimers(onError = (error) => {
|
|
30042
30643
|
throw error;
|
|
30644
|
+
}, afterCallback = () => {
|
|
30043
30645
|
}) {
|
|
30044
30646
|
const run2 = (fn, args) => {
|
|
30045
30647
|
try {
|
|
@@ -30047,11 +30649,14 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30047
30649
|
} catch (error) {
|
|
30048
30650
|
onError(error);
|
|
30049
30651
|
}
|
|
30652
|
+
afterCallback();
|
|
30050
30653
|
};
|
|
30654
|
+
let scheduled = 0;
|
|
30051
30655
|
const live = /* @__PURE__ */ new Set();
|
|
30052
30656
|
const unrefed = /* @__PURE__ */ new Set();
|
|
30053
30657
|
const states = /* @__PURE__ */ new WeakMap();
|
|
30054
30658
|
const track = (native) => {
|
|
30659
|
+
scheduled += 1;
|
|
30055
30660
|
const state = { native, active: true, referenced: true };
|
|
30056
30661
|
const handle = {
|
|
30057
30662
|
ref() {
|
|
@@ -30156,6 +30761,7 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30156
30761
|
},
|
|
30157
30762
|
pending: () => live.size,
|
|
30158
30763
|
pendingUnrefed: () => unrefed.size,
|
|
30764
|
+
scheduled: () => scheduled,
|
|
30159
30765
|
cancelAll
|
|
30160
30766
|
};
|
|
30161
30767
|
}
|
|
@@ -30325,7 +30931,7 @@ function formatUncaught(error) {
|
|
|
30325
30931
|
Node.js v22.12.0
|
|
30326
30932
|
`;
|
|
30327
30933
|
}
|
|
30328
|
-
var stubNames = ["cluster", "dgram", "
|
|
30934
|
+
var stubNames = ["cluster", "dgram", "domain", "http2", "inspector", "net", "tls", "v8", "vm", "worker_threads"];
|
|
30329
30935
|
var builtinNames2 = [
|
|
30330
30936
|
"assert",
|
|
30331
30937
|
"assert/strict",
|
|
@@ -30338,6 +30944,7 @@ var builtinNames2 = [
|
|
|
30338
30944
|
"events",
|
|
30339
30945
|
"fs",
|
|
30340
30946
|
"fs/promises",
|
|
30947
|
+
"diagnostics_channel",
|
|
30341
30948
|
"dns",
|
|
30342
30949
|
"dns/promises",
|
|
30343
30950
|
"http",
|
|
@@ -30353,6 +30960,7 @@ var builtinNames2 = [
|
|
|
30353
30960
|
"readline",
|
|
30354
30961
|
"readline/promises",
|
|
30355
30962
|
"stream",
|
|
30963
|
+
"stream/web",
|
|
30356
30964
|
"stream/promises",
|
|
30357
30965
|
"string_decoder",
|
|
30358
30966
|
"timers",
|
|
@@ -31741,6 +32349,7 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
31741
32349
|
...this.networkPolicy ? { policy: this.networkPolicy } : {}
|
|
31742
32350
|
},
|
|
31743
32351
|
spawnChild: (config2) => this.processManager.spawn(config2),
|
|
32352
|
+
ipc: hostIpcTransport,
|
|
31744
32353
|
...typeof options.stdinPath === "string" ? { stdinPath: options.stdinPath } : {},
|
|
31745
32354
|
...options.interactiveStdin ? { interactiveStdin: true } : {},
|
|
31746
32355
|
...options.tty ? { tty: true } : {},
|
|
@@ -31761,8 +32370,17 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
31761
32370
|
overrides: Object.fromEntries(Object.entries(this.modules).map(([key, value]) => [key, hostWork.wrap(value)]))
|
|
31762
32371
|
});
|
|
31763
32372
|
try {
|
|
31764
|
-
|
|
31765
|
-
|
|
32373
|
+
const main = engine.run(script);
|
|
32374
|
+
core.runTicks();
|
|
32375
|
+
await Promise.race([main, proc.waitForKill()]);
|
|
32376
|
+
const settle = () => this.settle(owner, core.pendingHandles, core.readingStdin, () => core.pendingRequests() + hostWork.pending(), () => proc.isKilled());
|
|
32377
|
+
await settle();
|
|
32378
|
+
while (!proc.isKilled()) {
|
|
32379
|
+
const activity = core.loopActivity();
|
|
32380
|
+
if (!core.emitBeforeExit(core.exitStatus())) break;
|
|
32381
|
+
await settle();
|
|
32382
|
+
if (core.loopActivity() === activity) break;
|
|
32383
|
+
}
|
|
31766
32384
|
const status = core.exitStatus();
|
|
31767
32385
|
core.emitExit(status);
|
|
31768
32386
|
return status;
|
|
@@ -32225,9 +32843,12 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
32225
32843
|
const entry = { worker, server };
|
|
32226
32844
|
this.live.add(entry);
|
|
32227
32845
|
const ownedChildren = /* @__PURE__ */ new Set();
|
|
32846
|
+
const channelEnds = /* @__PURE__ */ new Map();
|
|
32228
32847
|
const process2 = new WorkerProcess(worker, () => {
|
|
32229
32848
|
for (const child of ownedChildren) child.kill("SIGTERM");
|
|
32230
32849
|
ownedChildren.clear();
|
|
32850
|
+
for (const end of channelEnds.values()) end.disconnect();
|
|
32851
|
+
channelEnds.clear();
|
|
32231
32852
|
this.live.delete(entry);
|
|
32232
32853
|
server.close();
|
|
32233
32854
|
this.closeProxies(owner);
|
|
@@ -32292,6 +32913,30 @@ var WorkerRuntimePod = class _WorkerRuntimePod extends LocalRuntimePod {
|
|
|
32292
32913
|
case "child-kill":
|
|
32293
32914
|
children.get(message.id)?.kill(String(message.signal));
|
|
32294
32915
|
return;
|
|
32916
|
+
case "ipc-attach": {
|
|
32917
|
+
const key = `${message.side}:${message.id}`;
|
|
32918
|
+
if (channelEnds.has(key)) return;
|
|
32919
|
+
channelEnds.set(key, hostIpcTransport.attach(
|
|
32920
|
+
String(message.id),
|
|
32921
|
+
message.side === "child" ? "child" : "parent",
|
|
32922
|
+
(value) => worker.postMessage({ type: "ipc-message", id: message.id, side: message.side, value }),
|
|
32923
|
+
() => {
|
|
32924
|
+
channelEnds.delete(key);
|
|
32925
|
+
worker.postMessage({ type: "ipc-disconnect", id: message.id, side: message.side });
|
|
32926
|
+
}
|
|
32927
|
+
));
|
|
32928
|
+
return;
|
|
32929
|
+
}
|
|
32930
|
+
case "ipc-send":
|
|
32931
|
+
channelEnds.get(`${message.side}:${message.id}`)?.send(message.value);
|
|
32932
|
+
return;
|
|
32933
|
+
case "ipc-close": {
|
|
32934
|
+
const key = `${message.side}:${message.id}`;
|
|
32935
|
+
const end = channelEnds.get(key);
|
|
32936
|
+
channelEnds.delete(key);
|
|
32937
|
+
end?.disconnect();
|
|
32938
|
+
return;
|
|
32939
|
+
}
|
|
32295
32940
|
default:
|
|
32296
32941
|
return;
|
|
32297
32942
|
}
|