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/worker-entry.js
CHANGED
|
@@ -8795,7 +8795,7 @@ var require_path_browserify = __commonJS({
|
|
|
8795
8795
|
if (hasRoot && end === 1) return "//";
|
|
8796
8796
|
return path.slice(0, end);
|
|
8797
8797
|
},
|
|
8798
|
-
basename: function
|
|
8798
|
+
basename: function basename2(path, ext) {
|
|
8799
8799
|
if (ext !== void 0 && typeof ext !== "string") throw new TypeError('"ext" argument must be a string');
|
|
8800
8800
|
assertPath(path);
|
|
8801
8801
|
var start = 0;
|
|
@@ -8849,7 +8849,7 @@ var require_path_browserify = __commonJS({
|
|
|
8849
8849
|
return path.slice(start, end);
|
|
8850
8850
|
}
|
|
8851
8851
|
},
|
|
8852
|
-
extname: function
|
|
8852
|
+
extname: function extname2(path) {
|
|
8853
8853
|
assertPath(path);
|
|
8854
8854
|
var startDot = -1;
|
|
8855
8855
|
var startPart = 0;
|
|
@@ -15513,6 +15513,18 @@ function dirname(p) {
|
|
|
15513
15513
|
if (idx === 0) return "/";
|
|
15514
15514
|
return norm.slice(0, idx);
|
|
15515
15515
|
}
|
|
15516
|
+
function basename(p, ext) {
|
|
15517
|
+
const norm = stripTrailing(normalize(p));
|
|
15518
|
+
if (norm === "/") return "/";
|
|
15519
|
+
const idx = norm.lastIndexOf("/");
|
|
15520
|
+
let base2 = idx < 0 ? norm : norm.slice(idx + 1);
|
|
15521
|
+
return base2;
|
|
15522
|
+
}
|
|
15523
|
+
function extname(p) {
|
|
15524
|
+
const base2 = basename(p);
|
|
15525
|
+
const idx = base2.lastIndexOf(".");
|
|
15526
|
+
return idx <= 0 ? "" : base2.slice(idx);
|
|
15527
|
+
}
|
|
15516
15528
|
function clean(p) {
|
|
15517
15529
|
return stripTrailing(normalize(p));
|
|
15518
15530
|
}
|
|
@@ -21686,6 +21698,49 @@ var CommonJsEngine = class {
|
|
|
21686
21698
|
this.globals = { ...options.globals };
|
|
21687
21699
|
this.aliases = { ...options.aliases };
|
|
21688
21700
|
this.overrides = { ...options.overrides };
|
|
21701
|
+
const engine = this;
|
|
21702
|
+
this.moduleApi = function Module(id = "", parent = null) {
|
|
21703
|
+
Object.assign(this, { id, filename: id, exports: {}, loaded: false, parent, children: [] });
|
|
21704
|
+
};
|
|
21705
|
+
Object.assign(this.moduleApi, this.builtins.module);
|
|
21706
|
+
this.moduleApi.Module = this.moduleApi;
|
|
21707
|
+
this.moduleApi._extensions = {
|
|
21708
|
+
".js": (module, filename) => this.evaluate(module, this.readText(filename)),
|
|
21709
|
+
".json": (module, filename) => {
|
|
21710
|
+
module.exports = JSON.parse(this.readText(filename));
|
|
21711
|
+
},
|
|
21712
|
+
".node": (_module, filename) => {
|
|
21713
|
+
throw dlopenFailed(filename);
|
|
21714
|
+
}
|
|
21715
|
+
};
|
|
21716
|
+
this.moduleApi._cache = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
21717
|
+
get: (_target, key) => typeof key === "string" ? this.cache.get(key) : void 0,
|
|
21718
|
+
set: (_target, key, value) => {
|
|
21719
|
+
this.cache.set(String(key), value);
|
|
21720
|
+
return true;
|
|
21721
|
+
},
|
|
21722
|
+
deleteProperty: (_target, key) => this.cache.delete(String(key)),
|
|
21723
|
+
ownKeys: () => [...this.cache.keys()],
|
|
21724
|
+
getOwnPropertyDescriptor: (_target, key) => this.cache.has(String(key)) ? { enumerable: true, configurable: true, writable: true, value: this.cache.get(String(key)) } : void 0
|
|
21725
|
+
});
|
|
21726
|
+
this.moduleApi._resolveFilename = (request, parent) => this.resolve(request, parent?.filename || join(this.cwd, "__entry__.js"));
|
|
21727
|
+
this.moduleApi.prototype.require = function(request) {
|
|
21728
|
+
const filename = engine.moduleApi._resolveFilename(request, this);
|
|
21729
|
+
const builtin = engine.builtin(filename, this);
|
|
21730
|
+
if (builtin.found) return builtin.value;
|
|
21731
|
+
const target = engine.load(filename, this, false);
|
|
21732
|
+
if (target.pending) throw requireOfAsyncModule(request);
|
|
21733
|
+
return target.exports;
|
|
21734
|
+
};
|
|
21735
|
+
this.moduleApi.prototype._compile = function(source, filename) {
|
|
21736
|
+
this.filename = filename;
|
|
21737
|
+
engine.evaluate(this, source);
|
|
21738
|
+
};
|
|
21739
|
+
this.moduleApi.createRequire = (filename) => {
|
|
21740
|
+
const path = String(filename).startsWith("file:") ? pathFromFileUrl(String(filename)) : String(filename);
|
|
21741
|
+
if (!path.startsWith("/")) throw new TypeError("createRequire requires an absolute path or file URL");
|
|
21742
|
+
return this.makeRequire(Object.assign(new this.moduleApi(path), { filename: path }));
|
|
21743
|
+
};
|
|
21689
21744
|
}
|
|
21690
21745
|
volume;
|
|
21691
21746
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -21698,6 +21753,7 @@ var CommonJsEngine = class {
|
|
|
21698
21753
|
/** `package.json` per directory; resolution reads them constantly. */
|
|
21699
21754
|
manifests = /* @__PURE__ */ new Map();
|
|
21700
21755
|
evaluationDepth = 0;
|
|
21756
|
+
moduleApi;
|
|
21701
21757
|
/**
|
|
21702
21758
|
* Is a module body running synchronously right now?
|
|
21703
21759
|
*
|
|
@@ -21734,7 +21790,7 @@ var CommonJsEngine = class {
|
|
|
21734
21790
|
specifier = pathFromFileUrl(specifier);
|
|
21735
21791
|
}
|
|
21736
21792
|
const builtin = this.builtin(specifier);
|
|
21737
|
-
if (builtin.found) return specifier
|
|
21793
|
+
if (builtin.found) return specifier;
|
|
21738
21794
|
if (specifier.startsWith("#")) {
|
|
21739
21795
|
const found = this.resolveImports(specifier, importer, kind);
|
|
21740
21796
|
if (found) return found;
|
|
@@ -21767,17 +21823,14 @@ var CommonJsEngine = class {
|
|
|
21767
21823
|
parent,
|
|
21768
21824
|
children: []
|
|
21769
21825
|
};
|
|
21826
|
+
Object.setPrototypeOf(module, this.moduleApi.prototype);
|
|
21770
21827
|
this.cache.set(filename, module);
|
|
21771
21828
|
parent?.children.push(module);
|
|
21772
21829
|
if (isMain) this.main = module;
|
|
21773
21830
|
try {
|
|
21774
|
-
|
|
21775
|
-
|
|
21776
|
-
|
|
21777
|
-
module.exports = JSON.parse(this.readText(filename));
|
|
21778
|
-
} else {
|
|
21779
|
-
this.evaluate(module, this.readText(filename));
|
|
21780
|
-
}
|
|
21831
|
+
const extension = extname(filename);
|
|
21832
|
+
const loader = this.moduleApi._extensions[extension] ?? this.moduleApi._extensions[".js"];
|
|
21833
|
+
loader(module, filename);
|
|
21781
21834
|
module.loaded = true;
|
|
21782
21835
|
return module;
|
|
21783
21836
|
} catch (error) {
|
|
@@ -21830,15 +21883,12 @@ ${code}
|
|
|
21830
21883
|
/** The `require` a module sees, complete with `resolve`, `cache` and `main`. */
|
|
21831
21884
|
makeRequire(module) {
|
|
21832
21885
|
const localRequire = ((specifier) => {
|
|
21833
|
-
|
|
21834
|
-
if (builtin.found) return builtin.value;
|
|
21835
|
-
const target = this.load(this.resolve(specifier, module.filename, "require"), module, false);
|
|
21836
|
-
if (target.pending) throw requireOfAsyncModule(specifier);
|
|
21837
|
-
return target.exports;
|
|
21886
|
+
return this.moduleApi.prototype.require.call(module, specifier);
|
|
21838
21887
|
});
|
|
21839
|
-
localRequire.resolve = (specifier) => this.
|
|
21888
|
+
localRequire.resolve = (specifier) => this.moduleApi._resolveFilename(specifier, module);
|
|
21840
21889
|
Object.defineProperty(localRequire, "main", { get: () => this.main });
|
|
21841
|
-
localRequire.cache =
|
|
21890
|
+
localRequire.cache = this.moduleApi._cache;
|
|
21891
|
+
localRequire.extensions = this.moduleApi._extensions;
|
|
21842
21892
|
return localRequire;
|
|
21843
21893
|
}
|
|
21844
21894
|
/**
|
|
@@ -22013,12 +22063,7 @@ ${code}
|
|
|
22013
22063
|
if (prefixOnly || !Object.prototype.hasOwnProperty.call(this.builtins, name)) {
|
|
22014
22064
|
return Object.prototype.hasOwnProperty.call(this.overrides, specifier) ? { found: true, value: this.overrides[specifier] } : { found: false, value: void 0 };
|
|
22015
22065
|
}
|
|
22016
|
-
if (name === "module"
|
|
22017
|
-
return {
|
|
22018
|
-
found: true,
|
|
22019
|
-
value: { ...this.builtins.module, createRequire: () => this.makeRequire(importer) }
|
|
22020
|
-
};
|
|
22021
|
-
}
|
|
22066
|
+
if (name === "module") return { found: true, value: this.moduleApi };
|
|
22022
22067
|
return { found: true, value: this.builtins[name] };
|
|
22023
22068
|
}
|
|
22024
22069
|
exists(path) {
|
|
@@ -22126,6 +22171,62 @@ function splitSpecifier(specifier) {
|
|
|
22126
22171
|
return { name: parts.slice(0, size).join("/"), subpath: parts.slice(size).join("/") };
|
|
22127
22172
|
}
|
|
22128
22173
|
|
|
22174
|
+
// src/node/diagnostics-channel.ts
|
|
22175
|
+
function createDiagnosticsChannel() {
|
|
22176
|
+
const channels = /* @__PURE__ */ new Map();
|
|
22177
|
+
class Channel {
|
|
22178
|
+
constructor(name) {
|
|
22179
|
+
this.name = name;
|
|
22180
|
+
}
|
|
22181
|
+
name;
|
|
22182
|
+
listeners = /* @__PURE__ */ new Set();
|
|
22183
|
+
get hasSubscribers() {
|
|
22184
|
+
return this.listeners.size > 0;
|
|
22185
|
+
}
|
|
22186
|
+
subscribe(fn) {
|
|
22187
|
+
if (typeof fn !== "function") throw new TypeError("subscriber must be a function");
|
|
22188
|
+
this.listeners.add(fn);
|
|
22189
|
+
}
|
|
22190
|
+
unsubscribe(fn) {
|
|
22191
|
+
return this.listeners.delete(fn);
|
|
22192
|
+
}
|
|
22193
|
+
publish(message) {
|
|
22194
|
+
for (const fn of [...this.listeners]) {
|
|
22195
|
+
try {
|
|
22196
|
+
fn(message, this.name);
|
|
22197
|
+
} catch (error) {
|
|
22198
|
+
queueMicrotask(() => {
|
|
22199
|
+
throw error;
|
|
22200
|
+
});
|
|
22201
|
+
}
|
|
22202
|
+
}
|
|
22203
|
+
}
|
|
22204
|
+
}
|
|
22205
|
+
const channel = (name) => {
|
|
22206
|
+
if (typeof name !== "string" && typeof name !== "symbol") throw new TypeError("channel name must be a string or symbol");
|
|
22207
|
+
let result = channels.get(name);
|
|
22208
|
+
if (!result) {
|
|
22209
|
+
result = new Channel(name);
|
|
22210
|
+
channels.set(name, result);
|
|
22211
|
+
}
|
|
22212
|
+
return result;
|
|
22213
|
+
};
|
|
22214
|
+
return {
|
|
22215
|
+
Channel,
|
|
22216
|
+
channel,
|
|
22217
|
+
hasSubscribers: (name) => channels.get(name)?.hasSubscribers ?? false,
|
|
22218
|
+
subscribe: (name, fn) => channel(name).subscribe(fn),
|
|
22219
|
+
unsubscribe: (name, fn) => channels.get(name)?.unsubscribe(fn) ?? false
|
|
22220
|
+
};
|
|
22221
|
+
}
|
|
22222
|
+
|
|
22223
|
+
// src/node/ipc-channel.ts
|
|
22224
|
+
var IPC_CHANNEL_ENV = "SANDBOXEDJS_IPC_CHANNEL";
|
|
22225
|
+
function newIpcChannelId() {
|
|
22226
|
+
const random = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : Math.random().toString(36).slice(2);
|
|
22227
|
+
return `ipc-${random}`;
|
|
22228
|
+
}
|
|
22229
|
+
|
|
22129
22230
|
// src/node/buffer-module.ts
|
|
22130
22231
|
var import_buffer = __toESM(require_buffer());
|
|
22131
22232
|
var platformBuffer = globalThis.Buffer;
|
|
@@ -22254,6 +22355,132 @@ ${lines[index]}`;
|
|
|
22254
22355
|
return out;
|
|
22255
22356
|
}
|
|
22256
22357
|
|
|
22358
|
+
// src/node/parse-args.ts
|
|
22359
|
+
function argError(code, message) {
|
|
22360
|
+
return Object.assign(new TypeError(message), { code });
|
|
22361
|
+
}
|
|
22362
|
+
function parseArgs(config = {}) {
|
|
22363
|
+
const args = config.args ?? globalThis.process?.argv?.slice(2) ?? [];
|
|
22364
|
+
const options = config.options ?? {};
|
|
22365
|
+
const strict = config.strict ?? true;
|
|
22366
|
+
const allowPositionals = config.allowPositionals ?? !strict;
|
|
22367
|
+
const allowNegative = config.allowNegative ?? false;
|
|
22368
|
+
const byShort = /* @__PURE__ */ new Map();
|
|
22369
|
+
for (const [name, option] of Object.entries(options)) {
|
|
22370
|
+
if (option.type !== "string" && option.type !== "boolean") {
|
|
22371
|
+
throw argError("ERR_INVALID_ARG_VALUE", `The property 'options.${name}.type' must be one of: 'string', 'boolean'`);
|
|
22372
|
+
}
|
|
22373
|
+
if (option.short !== void 0) {
|
|
22374
|
+
if (option.short.length !== 1) {
|
|
22375
|
+
throw argError("ERR_INVALID_ARG_VALUE", `The property 'options.${name}.short' must be a single character`);
|
|
22376
|
+
}
|
|
22377
|
+
byShort.set(option.short, name);
|
|
22378
|
+
}
|
|
22379
|
+
}
|
|
22380
|
+
const tokens = [];
|
|
22381
|
+
const takesValue = (name) => options[name]?.type === "string";
|
|
22382
|
+
for (let index = 0; index < args.length; index++) {
|
|
22383
|
+
const arg = args[index];
|
|
22384
|
+
if (arg === "--") {
|
|
22385
|
+
tokens.push({ kind: "option-terminator", index });
|
|
22386
|
+
for (let rest = index + 1; rest < args.length; rest++) tokens.push({ kind: "positional", index: rest, value: args[rest] });
|
|
22387
|
+
break;
|
|
22388
|
+
}
|
|
22389
|
+
if (arg.startsWith("--") && arg.length > 2) {
|
|
22390
|
+
const equals = arg.indexOf("=");
|
|
22391
|
+
if (equals !== -1) {
|
|
22392
|
+
tokens.push({ kind: "option", name: arg.slice(2, equals), rawName: arg.slice(0, equals), index, value: arg.slice(equals + 1), inlineValue: true });
|
|
22393
|
+
continue;
|
|
22394
|
+
}
|
|
22395
|
+
const name = arg.slice(2);
|
|
22396
|
+
if (takesValue(name) && index + 1 < args.length) {
|
|
22397
|
+
tokens.push({ kind: "option", name, rawName: arg, index, value: args[index + 1], inlineValue: false });
|
|
22398
|
+
index++;
|
|
22399
|
+
} else {
|
|
22400
|
+
tokens.push({ kind: "option", name, rawName: arg, index, value: void 0, inlineValue: void 0 });
|
|
22401
|
+
}
|
|
22402
|
+
continue;
|
|
22403
|
+
}
|
|
22404
|
+
if (arg.startsWith("-") && arg.length > 1) {
|
|
22405
|
+
for (let at2 = 1; at2 < arg.length; at2++) {
|
|
22406
|
+
const short = arg[at2];
|
|
22407
|
+
const name = byShort.get(short) ?? short;
|
|
22408
|
+
if (takesValue(name)) {
|
|
22409
|
+
if (at2 + 1 < arg.length) {
|
|
22410
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: arg.slice(at2 + 1), inlineValue: true });
|
|
22411
|
+
} else if (index + 1 < args.length) {
|
|
22412
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: args[index + 1], inlineValue: false });
|
|
22413
|
+
index++;
|
|
22414
|
+
} else {
|
|
22415
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: void 0, inlineValue: void 0 });
|
|
22416
|
+
}
|
|
22417
|
+
break;
|
|
22418
|
+
}
|
|
22419
|
+
tokens.push({ kind: "option", name, rawName: `-${short}`, index, value: void 0, inlineValue: void 0 });
|
|
22420
|
+
}
|
|
22421
|
+
continue;
|
|
22422
|
+
}
|
|
22423
|
+
tokens.push({ kind: "positional", index, value: arg });
|
|
22424
|
+
}
|
|
22425
|
+
const values = /* @__PURE__ */ Object.create(null);
|
|
22426
|
+
const positionals = [];
|
|
22427
|
+
const store = (name, value) => {
|
|
22428
|
+
if (options[name]?.multiple) {
|
|
22429
|
+
const list = values[name] ?? [];
|
|
22430
|
+
list.push(value);
|
|
22431
|
+
values[name] = list;
|
|
22432
|
+
} else {
|
|
22433
|
+
values[name] = value;
|
|
22434
|
+
}
|
|
22435
|
+
};
|
|
22436
|
+
for (const token of tokens) {
|
|
22437
|
+
if (token.kind === "option-terminator") continue;
|
|
22438
|
+
if (token.kind === "positional") {
|
|
22439
|
+
if (!allowPositionals) {
|
|
22440
|
+
throw argError("ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL", `Unexpected argument '${token.value}'. This command does not take positional arguments`);
|
|
22441
|
+
}
|
|
22442
|
+
positionals.push(token.value);
|
|
22443
|
+
continue;
|
|
22444
|
+
}
|
|
22445
|
+
let name = token.name;
|
|
22446
|
+
let negated = false;
|
|
22447
|
+
if (allowNegative && name.startsWith("no-") && token.rawName.startsWith("--") && options[name.slice(3)]?.type === "boolean") {
|
|
22448
|
+
name = name.slice(3);
|
|
22449
|
+
negated = true;
|
|
22450
|
+
}
|
|
22451
|
+
const option = options[name];
|
|
22452
|
+
if (!option) {
|
|
22453
|
+
if (strict) {
|
|
22454
|
+
throw argError(
|
|
22455
|
+
"ERR_PARSE_ARGS_UNKNOWN_OPTION",
|
|
22456
|
+
`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)}'` : ""}`
|
|
22457
|
+
);
|
|
22458
|
+
}
|
|
22459
|
+
store(name, token.value ?? true);
|
|
22460
|
+
continue;
|
|
22461
|
+
}
|
|
22462
|
+
if (option.type === "string") {
|
|
22463
|
+
if (token.value === void 0) {
|
|
22464
|
+
if (strict) throw argError("ERR_PARSE_ARGS_INVALID_OPTION_VALUE", `Option '${token.rawName} <value>' argument missing`);
|
|
22465
|
+
store(name, true);
|
|
22466
|
+
continue;
|
|
22467
|
+
}
|
|
22468
|
+
store(name, token.value);
|
|
22469
|
+
} else {
|
|
22470
|
+
if (token.inlineValue && strict) {
|
|
22471
|
+
throw argError("ERR_PARSE_ARGS_INVALID_OPTION_VALUE", `Option '${token.rawName}' does not take an argument`);
|
|
22472
|
+
}
|
|
22473
|
+
store(name, !negated);
|
|
22474
|
+
}
|
|
22475
|
+
}
|
|
22476
|
+
for (const [name, option] of Object.entries(options)) {
|
|
22477
|
+
if (option.default !== void 0 && values[name] === void 0) {
|
|
22478
|
+
values[name] = Array.isArray(option.default) ? option.default.slice() : option.default;
|
|
22479
|
+
}
|
|
22480
|
+
}
|
|
22481
|
+
return config.tokens ? { values, positionals, tokens } : { values, positionals };
|
|
22482
|
+
}
|
|
22483
|
+
|
|
22257
22484
|
// src/node/util-module.ts
|
|
22258
22485
|
var customInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
22259
22486
|
var promisifyCustom = /* @__PURE__ */ Symbol.for("nodejs.util.promisify.custom");
|
|
@@ -22282,8 +22509,9 @@ function render(value, depth, seen, options) {
|
|
|
22282
22509
|
if (value === null) return "null";
|
|
22283
22510
|
const object = value;
|
|
22284
22511
|
const custom = object[customInspect];
|
|
22285
|
-
if (typeof custom === "function") {
|
|
22286
|
-
|
|
22512
|
+
if (options.customInspect !== false && typeof custom === "function") {
|
|
22513
|
+
const result = custom.call(object, depth, options, inspect);
|
|
22514
|
+
if (result !== object) return typeof result === "string" ? result : render(result, depth, seen, options);
|
|
22287
22515
|
}
|
|
22288
22516
|
if (seen.has(object)) return "[Circular *1]";
|
|
22289
22517
|
if (depth < 0) return Array.isArray(object) ? "[Array]" : "[Object]";
|
|
@@ -22618,6 +22846,7 @@ var legacy = {
|
|
|
22618
22846
|
inspect.custom = customInspect;
|
|
22619
22847
|
var utilModule = {
|
|
22620
22848
|
parseEnv,
|
|
22849
|
+
parseArgs,
|
|
22621
22850
|
format,
|
|
22622
22851
|
formatWithOptions,
|
|
22623
22852
|
inspect,
|
|
@@ -28502,6 +28731,18 @@ function toBytes(data2) {
|
|
|
28502
28731
|
abytes(data2);
|
|
28503
28732
|
return data2;
|
|
28504
28733
|
}
|
|
28734
|
+
function kdfInputToBytes(data2) {
|
|
28735
|
+
if (typeof data2 === "string")
|
|
28736
|
+
data2 = utf8ToBytes(data2);
|
|
28737
|
+
abytes(data2);
|
|
28738
|
+
return data2;
|
|
28739
|
+
}
|
|
28740
|
+
function checkOpts(defaults, opts) {
|
|
28741
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
|
|
28742
|
+
throw new Error("options should be object or undefined");
|
|
28743
|
+
const merged = Object.assign(defaults, opts);
|
|
28744
|
+
return merged;
|
|
28745
|
+
}
|
|
28505
28746
|
var Hash = class {
|
|
28506
28747
|
};
|
|
28507
28748
|
function createHasher(hashCons) {
|
|
@@ -29304,6 +29545,51 @@ var HMAC = class extends Hash {
|
|
|
29304
29545
|
var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
29305
29546
|
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
29306
29547
|
|
|
29548
|
+
// node_modules/@noble/hashes/esm/pbkdf2.js
|
|
29549
|
+
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
29550
|
+
ahash(hash);
|
|
29551
|
+
const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts);
|
|
29552
|
+
const { c, dkLen, asyncTick } = opts;
|
|
29553
|
+
anumber(c);
|
|
29554
|
+
anumber(dkLen);
|
|
29555
|
+
anumber(asyncTick);
|
|
29556
|
+
if (c < 1)
|
|
29557
|
+
throw new Error("iterations (c) should be >= 1");
|
|
29558
|
+
const password = kdfInputToBytes(_password);
|
|
29559
|
+
const salt = kdfInputToBytes(_salt);
|
|
29560
|
+
const DK = new Uint8Array(dkLen);
|
|
29561
|
+
const PRF = hmac.create(hash, password);
|
|
29562
|
+
const PRFSalt = PRF._cloneInto().update(salt);
|
|
29563
|
+
return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
|
|
29564
|
+
}
|
|
29565
|
+
function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
29566
|
+
PRF.destroy();
|
|
29567
|
+
PRFSalt.destroy();
|
|
29568
|
+
if (prfW)
|
|
29569
|
+
prfW.destroy();
|
|
29570
|
+
clean2(u);
|
|
29571
|
+
return DK;
|
|
29572
|
+
}
|
|
29573
|
+
function pbkdf2(hash, password, salt, opts) {
|
|
29574
|
+
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
29575
|
+
let prfW;
|
|
29576
|
+
const arr = new Uint8Array(4);
|
|
29577
|
+
const view = createView(arr);
|
|
29578
|
+
const u = new Uint8Array(PRF.outputLen);
|
|
29579
|
+
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
29580
|
+
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
29581
|
+
view.setInt32(0, ti, false);
|
|
29582
|
+
(prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
|
|
29583
|
+
Ti.set(u.subarray(0, Ti.length));
|
|
29584
|
+
for (let ui = 1; ui < c; ui++) {
|
|
29585
|
+
PRF._cloneInto(prfW).update(u).digestInto(u);
|
|
29586
|
+
for (let i = 0; i < Ti.length; i++)
|
|
29587
|
+
Ti[i] ^= u[i];
|
|
29588
|
+
}
|
|
29589
|
+
}
|
|
29590
|
+
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
29591
|
+
}
|
|
29592
|
+
|
|
29307
29593
|
// src/node/crypto-module.ts
|
|
29308
29594
|
var hashes = { md5, sha1, "sha-1": sha1, sha224: sha2242, "sha-224": sha2242, sha256: sha2562, "sha-256": sha2562, sha384: sha3842, "sha-384": sha3842, sha512: sha5122, "sha-512": sha5122 };
|
|
29309
29595
|
function createCryptoModule() {
|
|
@@ -29341,6 +29627,28 @@ function createCryptoModule() {
|
|
|
29341
29627
|
};
|
|
29342
29628
|
return api;
|
|
29343
29629
|
},
|
|
29630
|
+
pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
|
29631
|
+
return pbkdf2Key(password, salt, iterations, keylen, digest);
|
|
29632
|
+
},
|
|
29633
|
+
/* Node derives the key on the libuv thread pool and calls back from the poll
|
|
29634
|
+
* phase. Here it is derived on the calling thread — the ordering a program
|
|
29635
|
+
* observes is the same (the call returns first, the callback comes on a later
|
|
29636
|
+
* turn), but the main thread is busy while it computes. Invalid arguments throw
|
|
29637
|
+
* synchronously, as in Node. */
|
|
29638
|
+
pbkdf2(password, salt, iterations, keylen, digest, callback) {
|
|
29639
|
+
if (typeof callback !== "function") {
|
|
29640
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
29641
|
+
}
|
|
29642
|
+
hashFor(digest);
|
|
29643
|
+
let key;
|
|
29644
|
+
let failure = null;
|
|
29645
|
+
try {
|
|
29646
|
+
key = pbkdf2Key(password, salt, iterations, keylen, digest);
|
|
29647
|
+
} catch (error) {
|
|
29648
|
+
failure = error instanceof Error ? error : new Error(String(error));
|
|
29649
|
+
}
|
|
29650
|
+
setTimeout(() => failure ? callback(failure) : callback(null, key), 0);
|
|
29651
|
+
},
|
|
29344
29652
|
randomBytes(size, callback) {
|
|
29345
29653
|
const value = Buffer2.alloc(size);
|
|
29346
29654
|
cryptoObject.getRandomValues(value);
|
|
@@ -29390,6 +29698,15 @@ function createCryptoModule() {
|
|
|
29390
29698
|
constants: {}
|
|
29391
29699
|
};
|
|
29392
29700
|
}
|
|
29701
|
+
function pbkdf2Key(password, salt, iterations, keylen, digest) {
|
|
29702
|
+
if (!Number.isInteger(iterations) || iterations < 1) {
|
|
29703
|
+
throw Object.assign(new RangeError(`The value of "iterations" is out of range. It must be >= 1. Received ${iterations}`), { code: "ERR_OUT_OF_RANGE" });
|
|
29704
|
+
}
|
|
29705
|
+
if (!Number.isInteger(keylen) || keylen < 0) {
|
|
29706
|
+
throw Object.assign(new RangeError(`The value of "keylen" is out of range. It must be >= 0. Received ${keylen}`), { code: "ERR_OUT_OF_RANGE" });
|
|
29707
|
+
}
|
|
29708
|
+
return Buffer2.from(pbkdf2(hashFor(digest), toBytes2(password), toBytes2(salt), { c: iterations, dkLen: keylen }));
|
|
29709
|
+
}
|
|
29393
29710
|
function hashFor(algorithm) {
|
|
29394
29711
|
const hash = hashes[algorithm.toLowerCase()];
|
|
29395
29712
|
if (!hash) throw Object.assign(new Error(`Digest method not supported: ${algorithm}`), { code: "ERR_OSSL_EVP_UNSUPPORTED" });
|
|
@@ -29499,20 +29816,10 @@ var SyncChannelClient = class {
|
|
|
29499
29816
|
var import_events2 = __toESM(require_events());
|
|
29500
29817
|
var import_stream_browserify3 = __toESM(require_stream_browserify());
|
|
29501
29818
|
var ChildProcess = class extends import_events2.default {
|
|
29502
|
-
|
|
29503
|
-
|
|
29504
|
-
stdin;
|
|
29505
|
-
stdio;
|
|
29506
|
-
pid;
|
|
29507
|
-
exitCode = null;
|
|
29508
|
-
signalCode = null;
|
|
29509
|
-
killed = false;
|
|
29510
|
-
spawnfile;
|
|
29511
|
-
spawnargs;
|
|
29512
|
-
handle;
|
|
29513
|
-
settled = false;
|
|
29514
|
-
constructor(handle, file, args) {
|
|
29819
|
+
constructor(handle, file, args, referenceChanged = () => {
|
|
29820
|
+
}) {
|
|
29515
29821
|
super();
|
|
29822
|
+
this.referenceChanged = referenceChanged;
|
|
29516
29823
|
this.handle = handle;
|
|
29517
29824
|
this.pid = handle.pid;
|
|
29518
29825
|
this.spawnfile = file;
|
|
@@ -29537,31 +29844,90 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29537
29844
|
handle.on("stdout", (text) => this.stdout.write(text));
|
|
29538
29845
|
handle.on("stderr", (text) => this.stderr.write(text));
|
|
29539
29846
|
handle.on("exit", (code) => this.finish(code));
|
|
29540
|
-
|
|
29847
|
+
referenceChanged(1);
|
|
29848
|
+
try {
|
|
29849
|
+
handle.exec();
|
|
29850
|
+
} catch (error) {
|
|
29851
|
+
this.unref();
|
|
29852
|
+
throw error;
|
|
29853
|
+
}
|
|
29541
29854
|
}
|
|
29855
|
+
referenceChanged;
|
|
29856
|
+
stdout = new import_stream_browserify3.default.PassThrough();
|
|
29857
|
+
stderr = new import_stream_browserify3.default.PassThrough();
|
|
29858
|
+
stdin;
|
|
29859
|
+
stdio;
|
|
29860
|
+
pid;
|
|
29861
|
+
exitCode = null;
|
|
29862
|
+
signalCode = null;
|
|
29863
|
+
killed = false;
|
|
29864
|
+
spawnfile;
|
|
29865
|
+
spawnargs;
|
|
29866
|
+
handle;
|
|
29867
|
+
settled = false;
|
|
29868
|
+
referenced = true;
|
|
29542
29869
|
kill(signal = "SIGTERM") {
|
|
29543
29870
|
this.killed = true;
|
|
29544
29871
|
this.handle.kill(typeof signal === "number" ? "SIGTERM" : signal);
|
|
29545
29872
|
return true;
|
|
29546
29873
|
}
|
|
29547
29874
|
ref() {
|
|
29875
|
+
if (!this.settled && !this.referenced) {
|
|
29876
|
+
this.referenced = true;
|
|
29877
|
+
this.referenceChanged(1);
|
|
29878
|
+
}
|
|
29548
29879
|
return this;
|
|
29549
29880
|
}
|
|
29550
29881
|
unref() {
|
|
29882
|
+
if (this.referenced) {
|
|
29883
|
+
this.referenced = false;
|
|
29884
|
+
this.referenceChanged(-1);
|
|
29885
|
+
}
|
|
29551
29886
|
return this;
|
|
29552
29887
|
}
|
|
29553
|
-
|
|
29554
|
-
|
|
29555
|
-
|
|
29556
|
-
|
|
29557
|
-
|
|
29558
|
-
|
|
29888
|
+
channel;
|
|
29889
|
+
channelOpen = false;
|
|
29890
|
+
/** Open the parent's end of a `fork` channel. */
|
|
29891
|
+
attachChannel(transport, id) {
|
|
29892
|
+
this.channelOpen = true;
|
|
29893
|
+
this.channel = transport.attach(
|
|
29894
|
+
id,
|
|
29895
|
+
"parent",
|
|
29896
|
+
(message) => this.emit("message", message, void 0),
|
|
29897
|
+
() => this.channelClosed()
|
|
29898
|
+
);
|
|
29559
29899
|
}
|
|
29560
29900
|
get connected() {
|
|
29561
|
-
return
|
|
29901
|
+
return this.channelOpen;
|
|
29902
|
+
}
|
|
29903
|
+
/** `send(message[, sendHandle][, options][, callback])`, as Node spells it. */
|
|
29904
|
+
send(message, ...rest) {
|
|
29905
|
+
const callback = rest.find((value) => typeof value === "function");
|
|
29906
|
+
if (!this.channel || !this.channelOpen) {
|
|
29907
|
+
const error = Object.assign(new Error("Channel closed"), { code: "ERR_IPC_CHANNEL_CLOSED" });
|
|
29908
|
+
if (callback) queueMicrotask(() => callback(error));
|
|
29909
|
+
else queueMicrotask(() => this.emit("error", error));
|
|
29910
|
+
return false;
|
|
29911
|
+
}
|
|
29912
|
+
this.channel.send(message);
|
|
29913
|
+
if (callback) queueMicrotask(() => callback(null));
|
|
29914
|
+
return true;
|
|
29915
|
+
}
|
|
29916
|
+
disconnect() {
|
|
29917
|
+
if (!this.channelOpen) return;
|
|
29918
|
+
this.channel?.disconnect();
|
|
29919
|
+
this.channelClosed();
|
|
29920
|
+
}
|
|
29921
|
+
channelClosed() {
|
|
29922
|
+
if (!this.channelOpen) return;
|
|
29923
|
+
this.channelOpen = false;
|
|
29924
|
+
this.emit("disconnect");
|
|
29562
29925
|
}
|
|
29563
29926
|
finish(code) {
|
|
29564
29927
|
if (this.settled) return;
|
|
29928
|
+
this.channel?.disconnect();
|
|
29929
|
+
this.channelClosed();
|
|
29930
|
+
this.unref();
|
|
29565
29931
|
this.settled = true;
|
|
29566
29932
|
this.exitCode = code;
|
|
29567
29933
|
this.stdout.end();
|
|
@@ -29570,7 +29936,7 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29570
29936
|
queueMicrotask(() => this.emit("close", code, null));
|
|
29571
29937
|
}
|
|
29572
29938
|
};
|
|
29573
|
-
function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv = () => ({})) {
|
|
29939
|
+
function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv = () => ({}), lifecycle = {}) {
|
|
29574
29940
|
const environmentFor = (options) => options.env ? { ...options.env } : defaultEnv();
|
|
29575
29941
|
const throughShell = (command, options) => {
|
|
29576
29942
|
const shell = typeof options.shell === "string" ? options.shell : "/bin/sh";
|
|
@@ -29581,16 +29947,24 @@ function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv
|
|
|
29581
29947
|
if (stdio === "ignore") return true;
|
|
29582
29948
|
return Array.isArray(stdio) && stdio[0] === "ignore";
|
|
29583
29949
|
};
|
|
29950
|
+
const wantsChannel = (options) => Array.isArray(options.stdio) && options.stdio.includes("ipc");
|
|
29584
29951
|
const start = (file, args, options) => {
|
|
29585
29952
|
const resolved = options.shell ? throughShell([file, ...args].join(" "), options) : { file, args };
|
|
29953
|
+
const channelId = wantsChannel(options) && lifecycle.ipc ? newIpcChannelId() : void 0;
|
|
29586
29954
|
const handle = spawnChild({
|
|
29587
29955
|
command: resolved.file,
|
|
29588
29956
|
args: resolved.args,
|
|
29589
29957
|
cwd: options.cwd ?? defaultCwd(),
|
|
29590
|
-
env: environmentFor(options),
|
|
29958
|
+
env: channelId ? { ...environmentFor(options), [IPC_CHANNEL_ENV]: channelId } : environmentFor(options),
|
|
29959
|
+
...options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[0] === "inherit" ? { inheritStdio: true } : {},
|
|
29591
29960
|
...stdinIgnored(options) ? { stdinIgnored: true } : {}
|
|
29592
29961
|
});
|
|
29593
|
-
|
|
29962
|
+
const child = new ChildProcess(handle, resolved.file, resolved.args, lifecycle.referenceChanged);
|
|
29963
|
+
if (channelId && lifecycle.ipc) child.attachChannel(lifecycle.ipc, channelId);
|
|
29964
|
+
const inherited = (index) => options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[index] === "inherit";
|
|
29965
|
+
if (inherited(1)) child.stdout.on("data", (chunk) => lifecycle.stdout?.(chunk.toString()));
|
|
29966
|
+
if (inherited(2)) child.stderr.on("data", (chunk) => lifecycle.stderr?.(chunk.toString()));
|
|
29967
|
+
return child;
|
|
29594
29968
|
};
|
|
29595
29969
|
const spawn = (file, args = [], options = {}) => {
|
|
29596
29970
|
if (!Array.isArray(args)) return start(file, [], args);
|
|
@@ -29633,7 +30007,13 @@ ${err2.join("")}`),
|
|
|
29633
30007
|
spawn,
|
|
29634
30008
|
exec,
|
|
29635
30009
|
execFile,
|
|
29636
|
-
fork: (modulePath, args = [], options = {}) =>
|
|
30010
|
+
fork: (modulePath, args = [], options = {}) => {
|
|
30011
|
+
const [list, opts] = Array.isArray(args) ? [args, options] : [[], args ?? {}];
|
|
30012
|
+
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"];
|
|
30013
|
+
const withChannel = stdio.includes("ipc") ? stdio : [...stdio, "ipc"];
|
|
30014
|
+
const execArgv = (opts.execArgv ?? []).filter((flag) => !/^--(inspect|debug)/.test(flag));
|
|
30015
|
+
return start("node", [...execArgv, modulePath, ...list], { ...opts, shell: false, stdio: withChannel });
|
|
30016
|
+
},
|
|
29637
30017
|
...buildSyncFamily(syncSpawn, throughShell, defaultCwd, environmentFor),
|
|
29638
30018
|
ChildProcess
|
|
29639
30019
|
};
|
|
@@ -30301,11 +30681,14 @@ function createCoreModules(options) {
|
|
|
30301
30681
|
});
|
|
30302
30682
|
const stderrWrite = options.stderr ?? (() => {
|
|
30303
30683
|
});
|
|
30304
|
-
const timers = createTrackedTimers((error) => reportUncaught(error));
|
|
30684
|
+
const timers = createTrackedTimers((error) => reportUncaught(error), () => runTicks());
|
|
30305
30685
|
const processObject = Object.assign(new import_events4.default(), import_browser.default, {
|
|
30306
30686
|
argv: options.argv?.slice() ?? ["/usr/bin/node"],
|
|
30307
30687
|
argv0: "node",
|
|
30308
30688
|
execPath: "/usr/bin/node",
|
|
30689
|
+
/* `process/browser.js` has no `execArgv`; Node always has an array, and
|
|
30690
|
+
* CLIs that fork copy it (`[...process.execArgv]`). */
|
|
30691
|
+
execArgv: [],
|
|
30309
30692
|
env,
|
|
30310
30693
|
platform: "linux",
|
|
30311
30694
|
arch: "x64",
|
|
@@ -30344,13 +30727,14 @@ function createCoreModules(options) {
|
|
|
30344
30727
|
options.onExit?.(status);
|
|
30345
30728
|
},
|
|
30346
30729
|
nextTick: (fn, ...args) => {
|
|
30347
|
-
|
|
30348
|
-
|
|
30349
|
-
|
|
30350
|
-
|
|
30351
|
-
|
|
30352
|
-
|
|
30353
|
-
|
|
30730
|
+
if (typeof fn !== "function") {
|
|
30731
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
30732
|
+
}
|
|
30733
|
+
tickQueue.push([fn, args]);
|
|
30734
|
+
if (!tickDrainScheduled) {
|
|
30735
|
+
tickDrainScheduled = true;
|
|
30736
|
+
afterMicrotasks(runTicks);
|
|
30737
|
+
}
|
|
30354
30738
|
},
|
|
30355
30739
|
kill: () => true
|
|
30356
30740
|
});
|
|
@@ -30358,10 +30742,42 @@ function createCoreModules(options) {
|
|
|
30358
30742
|
const implementation = import_events4.default.prototype[method];
|
|
30359
30743
|
if (typeof implementation === "function") processObject[method] = implementation;
|
|
30360
30744
|
}
|
|
30745
|
+
const hrtime = (previous) => {
|
|
30746
|
+
const now = performance.timeOrigin + performance.now();
|
|
30747
|
+
let seconds = Math.floor(now / 1e3);
|
|
30748
|
+
let nanoseconds = Math.floor(now % 1e3 * 1e6);
|
|
30749
|
+
if (previous) {
|
|
30750
|
+
seconds -= previous[0];
|
|
30751
|
+
nanoseconds -= previous[1];
|
|
30752
|
+
if (nanoseconds < 0) {
|
|
30753
|
+
seconds -= 1;
|
|
30754
|
+
nanoseconds += 1e9;
|
|
30755
|
+
}
|
|
30756
|
+
}
|
|
30757
|
+
return [seconds, nanoseconds];
|
|
30758
|
+
};
|
|
30759
|
+
hrtime.bigint = () => {
|
|
30760
|
+
const [seconds, nanoseconds] = hrtime();
|
|
30761
|
+
return BigInt(seconds) * 1000000000n + BigInt(nanoseconds);
|
|
30762
|
+
};
|
|
30763
|
+
processObject.hrtime = hrtime;
|
|
30361
30764
|
const tty = options.tty === true;
|
|
30362
30765
|
processObject.stdout = makeOutputStream(stdoutWrite, 1, tty);
|
|
30363
30766
|
processObject.stderr = makeOutputStream(stderrWrite, 2, tty);
|
|
30364
30767
|
let exiting = false;
|
|
30768
|
+
const tickQueue = [];
|
|
30769
|
+
let tickDrainScheduled = false;
|
|
30770
|
+
const runTicks = () => {
|
|
30771
|
+
tickDrainScheduled = false;
|
|
30772
|
+
while (tickQueue.length && !exiting) {
|
|
30773
|
+
const [fn, args] = tickQueue.shift();
|
|
30774
|
+
try {
|
|
30775
|
+
fn(...args);
|
|
30776
|
+
} catch (error) {
|
|
30777
|
+
reportUncaught(error);
|
|
30778
|
+
}
|
|
30779
|
+
}
|
|
30780
|
+
};
|
|
30365
30781
|
const emitExit = (status) => {
|
|
30366
30782
|
if (exiting) return;
|
|
30367
30783
|
exiting = true;
|
|
@@ -30429,13 +30845,16 @@ function createCoreModules(options) {
|
|
|
30429
30845
|
const moduleBuiltin = {
|
|
30430
30846
|
builtinModules: builtinNames.flatMap((name) => [name, `node:${name}`]),
|
|
30431
30847
|
isBuiltin: (name) => builtinNames.includes(name.replace(/^node:/, "")),
|
|
30848
|
+
findSourceMap: () => void 0,
|
|
30432
30849
|
createRequire: () => {
|
|
30433
30850
|
throw new Error("createRequire is only available inside a loaded module");
|
|
30434
30851
|
}
|
|
30435
30852
|
};
|
|
30436
30853
|
let inFlightRequests = 0;
|
|
30854
|
+
let requestsStarted = 0;
|
|
30437
30855
|
const trackRequest = () => {
|
|
30438
30856
|
inFlightRequests++;
|
|
30857
|
+
requestsStarted += 1;
|
|
30439
30858
|
return () => {
|
|
30440
30859
|
inFlightRequests--;
|
|
30441
30860
|
};
|
|
@@ -30449,7 +30868,86 @@ function createCoreModules(options) {
|
|
|
30449
30868
|
};
|
|
30450
30869
|
const http = options.http ? createHttpModule(options.http.router, options.http.owner, httpOptions, "http:") : createUnsupportedModule("http");
|
|
30451
30870
|
const https = options.http ? createHttpModule(options.http.router, options.http.owner, httpOptions, "https:") : createUnsupportedModule("https");
|
|
30452
|
-
|
|
30871
|
+
let referencedChildren = 0;
|
|
30872
|
+
const childProcess = options.spawnChild ? createChildProcessModule(options.spawnChild, () => cwd, options.syncSpawn, () => ({ ...processObject.env }), {
|
|
30873
|
+
referenceChanged: (delta) => {
|
|
30874
|
+
referencedChildren += delta;
|
|
30875
|
+
},
|
|
30876
|
+
stdout: options.stdout,
|
|
30877
|
+
stderr: options.stderr,
|
|
30878
|
+
...options.ipc ? { ipc: options.ipc } : {}
|
|
30879
|
+
}) : createUnsupportedModule("child_process");
|
|
30880
|
+
let channelReferenced = 0;
|
|
30881
|
+
const channelId = env[IPC_CHANNEL_ENV];
|
|
30882
|
+
if (channelId && options.ipc) {
|
|
30883
|
+
delete env[IPC_CHANNEL_ENV];
|
|
30884
|
+
let open = true;
|
|
30885
|
+
let referenced = true;
|
|
30886
|
+
channelReferenced = 1;
|
|
30887
|
+
const close = () => {
|
|
30888
|
+
if (!open) return;
|
|
30889
|
+
open = false;
|
|
30890
|
+
if (referenced) channelReferenced = 0;
|
|
30891
|
+
processObject.connected = false;
|
|
30892
|
+
delete processObject.send;
|
|
30893
|
+
try {
|
|
30894
|
+
processObject.emit("disconnect");
|
|
30895
|
+
} catch (error) {
|
|
30896
|
+
reportUncaught(error);
|
|
30897
|
+
}
|
|
30898
|
+
runTicks();
|
|
30899
|
+
};
|
|
30900
|
+
const endpoint = options.ipc.attach(
|
|
30901
|
+
channelId,
|
|
30902
|
+
"child",
|
|
30903
|
+
(message) => {
|
|
30904
|
+
try {
|
|
30905
|
+
processObject.emit("message", message, void 0);
|
|
30906
|
+
} catch (error) {
|
|
30907
|
+
reportUncaught(error);
|
|
30908
|
+
}
|
|
30909
|
+
runTicks();
|
|
30910
|
+
},
|
|
30911
|
+
close
|
|
30912
|
+
);
|
|
30913
|
+
processObject.connected = true;
|
|
30914
|
+
processObject.send = (message, ...rest) => {
|
|
30915
|
+
const callback = rest.find((value) => typeof value === "function");
|
|
30916
|
+
if (!open) {
|
|
30917
|
+
const error = Object.assign(new Error("Channel closed"), { code: "ERR_IPC_CHANNEL_CLOSED" });
|
|
30918
|
+
if (callback) defer(() => callback(error));
|
|
30919
|
+
else defer(() => {
|
|
30920
|
+
processObject.emit("error", error);
|
|
30921
|
+
});
|
|
30922
|
+
return false;
|
|
30923
|
+
}
|
|
30924
|
+
endpoint.send(message);
|
|
30925
|
+
if (callback) defer(() => callback(null));
|
|
30926
|
+
return true;
|
|
30927
|
+
};
|
|
30928
|
+
processObject.disconnect = () => {
|
|
30929
|
+
if (open) {
|
|
30930
|
+
endpoint.disconnect();
|
|
30931
|
+
close();
|
|
30932
|
+
}
|
|
30933
|
+
};
|
|
30934
|
+
processObject.channel = {
|
|
30935
|
+
ref() {
|
|
30936
|
+
if (open && !referenced) {
|
|
30937
|
+
referenced = true;
|
|
30938
|
+
channelReferenced = 1;
|
|
30939
|
+
}
|
|
30940
|
+
return this;
|
|
30941
|
+
},
|
|
30942
|
+
unref() {
|
|
30943
|
+
if (referenced) {
|
|
30944
|
+
referenced = false;
|
|
30945
|
+
channelReferenced = 0;
|
|
30946
|
+
}
|
|
30947
|
+
return this;
|
|
30948
|
+
}
|
|
30949
|
+
};
|
|
30950
|
+
}
|
|
30453
30951
|
const readline = createReadlineModule(() => processObject.stdin, () => processObject.stdout);
|
|
30454
30952
|
const dns = createDnsModule(defer);
|
|
30455
30953
|
const builtins = {
|
|
@@ -30461,6 +30959,7 @@ function createCoreModules(options) {
|
|
|
30461
30959
|
console: consoleObject,
|
|
30462
30960
|
constants: fs.constants,
|
|
30463
30961
|
crypto: createCryptoModule(),
|
|
30962
|
+
diagnostics_channel: createDiagnosticsChannel(),
|
|
30464
30963
|
dns,
|
|
30465
30964
|
"dns/promises": dns.promises,
|
|
30466
30965
|
events: import_events4.default,
|
|
@@ -30479,6 +30978,25 @@ function createCoreModules(options) {
|
|
|
30479
30978
|
readline,
|
|
30480
30979
|
"readline/promises": readline.promises,
|
|
30481
30980
|
stream: import_stream_browserify4.default,
|
|
30981
|
+
"stream/web": Object.fromEntries([
|
|
30982
|
+
"ReadableStream",
|
|
30983
|
+
"ReadableStreamDefaultReader",
|
|
30984
|
+
"ReadableStreamBYOBReader",
|
|
30985
|
+
"ReadableStreamDefaultController",
|
|
30986
|
+
"ReadableByteStreamController",
|
|
30987
|
+
"ReadableStreamBYOBRequest",
|
|
30988
|
+
"WritableStream",
|
|
30989
|
+
"WritableStreamDefaultWriter",
|
|
30990
|
+
"WritableStreamDefaultController",
|
|
30991
|
+
"TransformStream",
|
|
30992
|
+
"TransformStreamDefaultController",
|
|
30993
|
+
"ByteLengthQueuingStrategy",
|
|
30994
|
+
"CountQueuingStrategy",
|
|
30995
|
+
"TextEncoderStream",
|
|
30996
|
+
"TextDecoderStream",
|
|
30997
|
+
"CompressionStream",
|
|
30998
|
+
"DecompressionStream"
|
|
30999
|
+
].filter((name) => name in globalThis).map((name) => [name, globalThis[name]])),
|
|
30482
31000
|
"stream/promises": createStreamPromises(),
|
|
30483
31001
|
string_decoder: import_string_decoder.default,
|
|
30484
31002
|
timers: { ...import_timers_browserify.default, ...timers.api },
|
|
@@ -30510,7 +31028,57 @@ function createCoreModules(options) {
|
|
|
30510
31028
|
})
|
|
30511
31029
|
};
|
|
30512
31030
|
for (const name of stubNames) builtins[name] = createUnsupportedModule(name);
|
|
31031
|
+
builtins.worker_threads = {
|
|
31032
|
+
MessagePort: globalThis.MessagePort ?? class MessagePort {
|
|
31033
|
+
},
|
|
31034
|
+
markAsUncloneable: () => {
|
|
31035
|
+
},
|
|
31036
|
+
isMarkedAsUncloneable: () => false,
|
|
31037
|
+
markAsUntransferable: () => {
|
|
31038
|
+
},
|
|
31039
|
+
isMarkedAsUntransferable: () => false
|
|
31040
|
+
};
|
|
30513
31041
|
builtins.net = createNetModule();
|
|
31042
|
+
builtins.inspector = createUnsupportedModule("inspector", {
|
|
31043
|
+
url: () => void 0,
|
|
31044
|
+
close: () => {
|
|
31045
|
+
},
|
|
31046
|
+
waitForDebugger: () => {
|
|
31047
|
+
throw Object.assign(new Error("Inspector is not active"), { code: "ERR_INSPECTOR_NOT_ACTIVE" });
|
|
31048
|
+
},
|
|
31049
|
+
console: consoleObject
|
|
31050
|
+
});
|
|
31051
|
+
builtins.v8 = createUnsupportedModule("v8", {
|
|
31052
|
+
getHeapStatistics: () => {
|
|
31053
|
+
const memory = performance.memory;
|
|
31054
|
+
const limit = memory?.jsHeapSizeLimit ?? 4 * 1024 ** 3;
|
|
31055
|
+
return {
|
|
31056
|
+
total_heap_size: memory?.totalJSHeapSize ?? 0,
|
|
31057
|
+
total_heap_size_executable: 0,
|
|
31058
|
+
total_physical_size: memory?.totalJSHeapSize ?? 0,
|
|
31059
|
+
total_available_size: limit - (memory?.usedJSHeapSize ?? 0),
|
|
31060
|
+
used_heap_size: memory?.usedJSHeapSize ?? 0,
|
|
31061
|
+
heap_size_limit: limit,
|
|
31062
|
+
malloced_memory: 0,
|
|
31063
|
+
peak_malloced_memory: 0,
|
|
31064
|
+
does_zap_garbage: 0,
|
|
31065
|
+
number_of_native_contexts: 1,
|
|
31066
|
+
number_of_detached_contexts: 0,
|
|
31067
|
+
total_global_handles_size: 0,
|
|
31068
|
+
used_global_handles_size: 0,
|
|
31069
|
+
external_memory: 0
|
|
31070
|
+
};
|
|
31071
|
+
},
|
|
31072
|
+
getHeapSpaceStatistics: () => [],
|
|
31073
|
+
getHeapCodeStatistics: () => ({ code_and_metadata_size: 0, bytecode_and_metadata_size: 0, external_script_source_size: 0, cpu_profiler_metadata_size: 0 }),
|
|
31074
|
+
cachedDataVersionTag: () => 0,
|
|
31075
|
+
setFlagsFromString: () => {
|
|
31076
|
+
},
|
|
31077
|
+
setHeapSnapshotNearHeapLimit: () => {
|
|
31078
|
+
},
|
|
31079
|
+
serialize: (value) => Buffer2.from(JSON.stringify(value) ?? "null"),
|
|
31080
|
+
deserialize: (buffer) => JSON.parse(Buffer2.from(buffer).toString("utf8"))
|
|
31081
|
+
});
|
|
30514
31082
|
const globals = {
|
|
30515
31083
|
Buffer: Buffer2,
|
|
30516
31084
|
console: consoleObject,
|
|
@@ -30545,7 +31113,7 @@ function createCoreModules(options) {
|
|
|
30545
31113
|
builtins,
|
|
30546
31114
|
globals,
|
|
30547
31115
|
process: processObject,
|
|
30548
|
-
pendingHandles: timers.pending,
|
|
31116
|
+
pendingHandles: () => timers.pending() + referencedChildren + channelReferenced,
|
|
30549
31117
|
pendingUnrefed: timers.pendingUnrefed,
|
|
30550
31118
|
/** Client requests sent but not yet read to completion. */
|
|
30551
31119
|
pendingRequests: () => inFlightRequests,
|
|
@@ -30554,6 +31122,18 @@ function createCoreModules(options) {
|
|
|
30554
31122
|
reportUnhandledRejection: (reason) => reportUncaught(reason, "unhandledRejection"),
|
|
30555
31123
|
exitStatus: () => normalizeExitCode(processObject.exitCode),
|
|
30556
31124
|
emitExit,
|
|
31125
|
+
runTicks,
|
|
31126
|
+
emitBeforeExit: (status) => {
|
|
31127
|
+
if (exiting || processObject.listenerCount("beforeExit") === 0) return false;
|
|
31128
|
+
try {
|
|
31129
|
+
processObject.emit("beforeExit", status);
|
|
31130
|
+
} catch (error) {
|
|
31131
|
+
reportUncaught(error);
|
|
31132
|
+
}
|
|
31133
|
+
runTicks();
|
|
31134
|
+
return true;
|
|
31135
|
+
},
|
|
31136
|
+
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
30557
31137
|
writeStdin: (data2) => {
|
|
30558
31138
|
if (options.interactiveStdin) stdin.write(data2);
|
|
30559
31139
|
},
|
|
@@ -30599,7 +31179,9 @@ var ASYNC_FS_METHODS = [
|
|
|
30599
31179
|
"close",
|
|
30600
31180
|
"read",
|
|
30601
31181
|
"write",
|
|
30602
|
-
"exists"
|
|
31182
|
+
"exists",
|
|
31183
|
+
"fsync",
|
|
31184
|
+
"fdatasync"
|
|
30603
31185
|
];
|
|
30604
31186
|
function createPathModule(cwd) {
|
|
30605
31187
|
const resolve2 = (...segments2) => import_path_browserify.default.resolve(cwd(), ...segments2);
|
|
@@ -30822,6 +31404,12 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
30822
31404
|
unwatchFile: () => {
|
|
30823
31405
|
}
|
|
30824
31406
|
};
|
|
31407
|
+
fs.fsyncSync = (fd) => {
|
|
31408
|
+
requiredFd(fds, fd);
|
|
31409
|
+
};
|
|
31410
|
+
fs.fdatasyncSync = (fd) => {
|
|
31411
|
+
requiredFd(fds, fd);
|
|
31412
|
+
};
|
|
30825
31413
|
fs.ftruncateSync = (fd, length) => fs.truncateSync(requiredFd(fds, fd).path, length);
|
|
30826
31414
|
fs.fchmodSync = (fd, mode) => fs.chmodSync(requiredFd(fds, fd).path, mode);
|
|
30827
31415
|
fs.fchownSync = (fd, uid, gid) => fs.chownSync(requiredFd(fds, fd).path, uid, gid);
|
|
@@ -30882,6 +31470,8 @@ function makeFileHandle(fs, fd) {
|
|
|
30882
31470
|
return {
|
|
30883
31471
|
fd,
|
|
30884
31472
|
close: async () => fs.closeSync(fd),
|
|
31473
|
+
sync: async () => fs.fsyncSync(fd),
|
|
31474
|
+
datasync: async () => fs.fdatasyncSync(fd),
|
|
30885
31475
|
stat: async () => fs.fstatSync(fd),
|
|
30886
31476
|
truncate: async (length) => fs.ftruncateSync(fd, length),
|
|
30887
31477
|
chmod: async (mode) => fs.fchmodSync(fd, mode),
|
|
@@ -31164,8 +31754,28 @@ var ERRNO_CONSTANTS = {
|
|
|
31164
31754
|
EWOULDBLOCK: 11,
|
|
31165
31755
|
EXDEV: 18
|
|
31166
31756
|
};
|
|
31757
|
+
var afterMicrotasks = (() => {
|
|
31758
|
+
const host = globalThis.process;
|
|
31759
|
+
if (typeof host?.nextTick === "function" && host.versions?.node) return (fn) => host.nextTick(fn);
|
|
31760
|
+
if (typeof MessageChannel === "function") {
|
|
31761
|
+
const queue = [];
|
|
31762
|
+
let channel = null;
|
|
31763
|
+
return (fn) => {
|
|
31764
|
+
if (!channel) {
|
|
31765
|
+
channel = new MessageChannel();
|
|
31766
|
+
channel.port1.onmessage = () => queue.shift()?.();
|
|
31767
|
+
}
|
|
31768
|
+
queue.push(fn);
|
|
31769
|
+
channel.port2.postMessage(null);
|
|
31770
|
+
};
|
|
31771
|
+
}
|
|
31772
|
+
return (fn) => {
|
|
31773
|
+
setTimeout(fn, 0);
|
|
31774
|
+
};
|
|
31775
|
+
})();
|
|
31167
31776
|
function createTrackedTimers(onError = (error) => {
|
|
31168
31777
|
throw error;
|
|
31778
|
+
}, afterCallback = () => {
|
|
31169
31779
|
}) {
|
|
31170
31780
|
const run2 = (fn, args) => {
|
|
31171
31781
|
try {
|
|
@@ -31173,11 +31783,14 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31173
31783
|
} catch (error) {
|
|
31174
31784
|
onError(error);
|
|
31175
31785
|
}
|
|
31786
|
+
afterCallback();
|
|
31176
31787
|
};
|
|
31788
|
+
let scheduled = 0;
|
|
31177
31789
|
const live = /* @__PURE__ */ new Set();
|
|
31178
31790
|
const unrefed = /* @__PURE__ */ new Set();
|
|
31179
31791
|
const states = /* @__PURE__ */ new WeakMap();
|
|
31180
31792
|
const track = (native) => {
|
|
31793
|
+
scheduled += 1;
|
|
31181
31794
|
const state = { native, active: true, referenced: true };
|
|
31182
31795
|
const handle = {
|
|
31183
31796
|
ref() {
|
|
@@ -31282,6 +31895,7 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31282
31895
|
},
|
|
31283
31896
|
pending: () => live.size,
|
|
31284
31897
|
pendingUnrefed: () => unrefed.size,
|
|
31898
|
+
scheduled: () => scheduled,
|
|
31285
31899
|
cancelAll
|
|
31286
31900
|
};
|
|
31287
31901
|
}
|
|
@@ -31451,7 +32065,7 @@ function formatUncaught(error) {
|
|
|
31451
32065
|
Node.js v22.12.0
|
|
31452
32066
|
`;
|
|
31453
32067
|
}
|
|
31454
|
-
var stubNames = ["cluster", "dgram", "
|
|
32068
|
+
var stubNames = ["cluster", "dgram", "domain", "http2", "inspector", "net", "tls", "v8", "vm", "worker_threads"];
|
|
31455
32069
|
var builtinNames = [
|
|
31456
32070
|
"assert",
|
|
31457
32071
|
"assert/strict",
|
|
@@ -31464,6 +32078,7 @@ var builtinNames = [
|
|
|
31464
32078
|
"events",
|
|
31465
32079
|
"fs",
|
|
31466
32080
|
"fs/promises",
|
|
32081
|
+
"diagnostics_channel",
|
|
31467
32082
|
"dns",
|
|
31468
32083
|
"dns/promises",
|
|
31469
32084
|
"http",
|
|
@@ -31479,6 +32094,7 @@ var builtinNames = [
|
|
|
31479
32094
|
"readline",
|
|
31480
32095
|
"readline/promises",
|
|
31481
32096
|
"stream",
|
|
32097
|
+
"stream/web",
|
|
31482
32098
|
"stream/promises",
|
|
31483
32099
|
"string_decoder",
|
|
31484
32100
|
"timers",
|
|
@@ -31706,6 +32322,7 @@ async function run(port, start) {
|
|
|
31706
32322
|
/* Asynchronous children are the host's business: it owns the process table
|
|
31707
32323
|
* and the PATH. Both forms end up in the same place, one blocking. */
|
|
31708
32324
|
spawnChild: (config) => hostChildProcess(port, config),
|
|
32325
|
+
ipc: hostIpcOverPort(port),
|
|
31709
32326
|
syncSpawn: (request) => spawnSyncOverChannel(channel, request),
|
|
31710
32327
|
...start.stdinPath ? { stdinPath: start.stdinPath } : {},
|
|
31711
32328
|
...start.interactiveStdin ? { interactiveStdin: true } : {},
|
|
@@ -31767,8 +32384,16 @@ async function run(port, start) {
|
|
|
31767
32384
|
aliases: start.aliases
|
|
31768
32385
|
});
|
|
31769
32386
|
try {
|
|
31770
|
-
|
|
32387
|
+
const main2 = engine.run(start.script);
|
|
32388
|
+
core.runTicks();
|
|
32389
|
+
await main2;
|
|
31771
32390
|
await settle(router, owner, core, () => finished);
|
|
32391
|
+
while (!finished) {
|
|
32392
|
+
const activity = core.loopActivity();
|
|
32393
|
+
if (!core.emitBeforeExit(core.exitStatus())) break;
|
|
32394
|
+
await settle(router, owner, core, () => finished);
|
|
32395
|
+
if (core.loopActivity() === activity) break;
|
|
32396
|
+
}
|
|
31772
32397
|
const status = core.exitStatus();
|
|
31773
32398
|
core.emitExit(status);
|
|
31774
32399
|
finish(status);
|
|
@@ -31864,6 +32489,32 @@ function hostChildProcess(port, config) {
|
|
|
31864
32489
|
});
|
|
31865
32490
|
return handle;
|
|
31866
32491
|
}
|
|
32492
|
+
function hostIpcOverPort(port) {
|
|
32493
|
+
const ends = /* @__PURE__ */ new Map();
|
|
32494
|
+
port.onMessage((message) => {
|
|
32495
|
+
if (message?.type !== "ipc-message" && message?.type !== "ipc-disconnect") return;
|
|
32496
|
+
const end = ends.get(`${message.side}:${message.id}`);
|
|
32497
|
+
if (!end) return;
|
|
32498
|
+
if (message.type === "ipc-message") end.message(message.value);
|
|
32499
|
+
else {
|
|
32500
|
+
ends.delete(`${message.side}:${message.id}`);
|
|
32501
|
+
end.disconnect();
|
|
32502
|
+
}
|
|
32503
|
+
});
|
|
32504
|
+
return {
|
|
32505
|
+
attach(id, side, onMessage, onDisconnect) {
|
|
32506
|
+
ends.set(`${side}:${id}`, { message: onMessage, disconnect: onDisconnect });
|
|
32507
|
+
port.postMessage({ type: "ipc-attach", id, side });
|
|
32508
|
+
return {
|
|
32509
|
+
send: (value) => port.postMessage({ type: "ipc-send", id, side, value: value === void 0 ? void 0 : JSON.parse(JSON.stringify(value)) }),
|
|
32510
|
+
disconnect: () => {
|
|
32511
|
+
ends.delete(`${side}:${id}`);
|
|
32512
|
+
port.postMessage({ type: "ipc-close", id, side });
|
|
32513
|
+
}
|
|
32514
|
+
};
|
|
32515
|
+
}
|
|
32516
|
+
};
|
|
32517
|
+
}
|
|
31867
32518
|
function formatError(error) {
|
|
31868
32519
|
if (error instanceof Error) return `${error.stack ?? `${error.name}: ${error.message}`}
|
|
31869
32520
|
`;
|