sandboxedjs 0.1.83 → 0.1.85
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-DtVUncWL.d.ts → container-BGmhPbSD.d.cts} +10 -1
- package/dist/{container-B14Q03ng.d.cts → container-DCwYX_Cx.d.ts} +10 -1
- package/dist/{contracts-DNkSvBCM.d.cts → contracts-BkWBTH8E.d.cts} +22 -3
- package/dist/{contracts-DNkSvBCM.d.ts → contracts-BkWBTH8E.d.ts} +22 -3
- package/dist/index.cjs +2386 -397
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +2386 -397
- package/dist/index.js.map +1 -1
- package/dist/{memory-volume-n-LY8Vdv.d.cts → memory-volume-DCm-DiXH.d.cts} +1 -1
- package/dist/{memory-volume-D4FLjyEU.d.ts → memory-volume-DJA-vFYW.d.ts} +1 -1
- package/dist/python/python.data +140 -145
- package/dist/python/python.js +1 -1
- package/dist/python/python.wasm +0 -0
- package/dist/python/runtime.json +3 -3
- package/dist/python-abi.cjs +18 -4
- package/dist/python-abi.cjs.map +1 -1
- package/dist/python-abi.d.cts +3 -3
- package/dist/python-abi.d.ts +3 -3
- package/dist/python-abi.js +18 -4
- package/dist/python-abi.js.map +1 -1
- package/dist/worker-entry.js +1407 -212
- package/dist/worker-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/worker-entry.js
CHANGED
|
@@ -3882,7 +3882,7 @@ var require_acorn = __commonJS({
|
|
|
3882
3882
|
}
|
|
3883
3883
|
return i2 + 2;
|
|
3884
3884
|
};
|
|
3885
|
-
RegExpValidationState3.prototype.current = function
|
|
3885
|
+
RegExpValidationState3.prototype.current = function current3(forceU) {
|
|
3886
3886
|
if (forceU === void 0) forceU = false;
|
|
3887
3887
|
return this.at(this.pos, forceU);
|
|
3888
3888
|
};
|
|
@@ -3907,8 +3907,8 @@ var require_acorn = __commonJS({
|
|
|
3907
3907
|
var pos = this.pos;
|
|
3908
3908
|
for (var i2 = 0, list2 = chs; i2 < list2.length; i2 += 1) {
|
|
3909
3909
|
var ch = list2[i2];
|
|
3910
|
-
var
|
|
3911
|
-
if (
|
|
3910
|
+
var current3 = this.at(pos, forceU);
|
|
3911
|
+
if (current3 === -1 || current3 !== ch) {
|
|
3912
3912
|
return false;
|
|
3913
3913
|
}
|
|
3914
3914
|
pos = this.nextIndex(pos, forceU);
|
|
@@ -9583,11 +9583,11 @@ var require_stream_writable = __commonJS({
|
|
|
9583
9583
|
this.corkedRequestsFree = new CorkedRequest(this);
|
|
9584
9584
|
}
|
|
9585
9585
|
WritableState.prototype.getBuffer = function getBuffer() {
|
|
9586
|
-
var
|
|
9586
|
+
var current3 = this.bufferedRequest;
|
|
9587
9587
|
var out = [];
|
|
9588
|
-
while (
|
|
9589
|
-
out.push(
|
|
9590
|
-
|
|
9588
|
+
while (current3) {
|
|
9589
|
+
out.push(current3);
|
|
9590
|
+
current3 = current3.next;
|
|
9591
9591
|
}
|
|
9592
9592
|
return out;
|
|
9593
9593
|
};
|
|
@@ -11188,12 +11188,12 @@ var require_stream_readable = __commonJS({
|
|
|
11188
11188
|
if (!state.flowing) {
|
|
11189
11189
|
debug("resume");
|
|
11190
11190
|
state.flowing = !state.readableListening;
|
|
11191
|
-
|
|
11191
|
+
resume2(this, state);
|
|
11192
11192
|
}
|
|
11193
11193
|
state.paused = false;
|
|
11194
11194
|
return this;
|
|
11195
11195
|
};
|
|
11196
|
-
function
|
|
11196
|
+
function resume2(stream, state) {
|
|
11197
11197
|
if (!state.resumeScheduled) {
|
|
11198
11198
|
state.resumeScheduled = true;
|
|
11199
11199
|
process.nextTick(resume_, stream, state);
|
|
@@ -19169,8 +19169,8 @@ RegExpValidationState.prototype.eatChars = function eatChars(chs, forceU) {
|
|
|
19169
19169
|
var pos = this.pos;
|
|
19170
19170
|
for (var i = 0, list = chs; i < list.length; i += 1) {
|
|
19171
19171
|
var ch = list[i];
|
|
19172
|
-
var
|
|
19173
|
-
if (
|
|
19172
|
+
var current3 = this.at(pos, forceU);
|
|
19173
|
+
if (current3 === -1 || current3 !== ch) {
|
|
19174
19174
|
return false;
|
|
19175
19175
|
}
|
|
19176
19176
|
pos = this.nextIndex(pos, forceU);
|
|
@@ -21484,9 +21484,9 @@ ${applyEdits(source, edits)}` : applyEdits(source, edits),
|
|
|
21484
21484
|
}
|
|
21485
21485
|
}
|
|
21486
21486
|
function lookup(name, scope) {
|
|
21487
|
-
for (let
|
|
21488
|
-
if (
|
|
21489
|
-
return
|
|
21487
|
+
for (let current3 = scope; current3; current3 = current3.parent) {
|
|
21488
|
+
if (current3.names.has(name)) {
|
|
21489
|
+
return current3.parent === null ? importBindings.get(name) ?? null : null;
|
|
21490
21490
|
}
|
|
21491
21491
|
}
|
|
21492
21492
|
return null;
|
|
@@ -21519,7 +21519,7 @@ function containsImportExpression(node) {
|
|
|
21519
21519
|
function containsImportMeta(node) {
|
|
21520
21520
|
if (Array.isArray(node)) return node.some(containsImportMeta);
|
|
21521
21521
|
if (!isNode(node)) return false;
|
|
21522
|
-
if (node.type === "MetaProperty") return true;
|
|
21522
|
+
if (node.type === "MetaProperty" && node.meta?.name === "import") return true;
|
|
21523
21523
|
for (const [key, value] of Object.entries(node)) {
|
|
21524
21524
|
if (key === "type" || key === "start" || key === "end") continue;
|
|
21525
21525
|
if (containsImportMeta(value)) return true;
|
|
@@ -21630,6 +21630,261 @@ var NOTHING = [];
|
|
|
21630
21630
|
var PROPERTY = ["property", "key"];
|
|
21631
21631
|
var LABEL = ["label"];
|
|
21632
21632
|
|
|
21633
|
+
// src/node/async-context-transform.ts
|
|
21634
|
+
var import_acorn_jsx2 = __toESM(require_acorn_jsx());
|
|
21635
|
+
|
|
21636
|
+
// src/node/async-context.ts
|
|
21637
|
+
var EMPTY = /* @__PURE__ */ new Map();
|
|
21638
|
+
var current2 = EMPTY;
|
|
21639
|
+
function capture() {
|
|
21640
|
+
return current2;
|
|
21641
|
+
}
|
|
21642
|
+
function restore(frame) {
|
|
21643
|
+
current2 = frame ?? EMPTY;
|
|
21644
|
+
}
|
|
21645
|
+
function resume(frame, value) {
|
|
21646
|
+
current2 = frame;
|
|
21647
|
+
return value;
|
|
21648
|
+
}
|
|
21649
|
+
function runInFrame(frame, fn) {
|
|
21650
|
+
const previous = current2;
|
|
21651
|
+
current2 = frame;
|
|
21652
|
+
try {
|
|
21653
|
+
return fn();
|
|
21654
|
+
} finally {
|
|
21655
|
+
current2 = previous;
|
|
21656
|
+
}
|
|
21657
|
+
}
|
|
21658
|
+
function bindToCurrent(fn) {
|
|
21659
|
+
const frame = current2;
|
|
21660
|
+
if (frame === EMPTY) {
|
|
21661
|
+
return function(...args) {
|
|
21662
|
+
return runInFrame(EMPTY, () => fn.apply(this, args));
|
|
21663
|
+
};
|
|
21664
|
+
}
|
|
21665
|
+
return function(...args) {
|
|
21666
|
+
return runInFrame(frame, () => fn.apply(this, args));
|
|
21667
|
+
};
|
|
21668
|
+
}
|
|
21669
|
+
function installPromiseContext(PromiseClass = Promise) {
|
|
21670
|
+
const proto = PromiseClass.prototype;
|
|
21671
|
+
if (proto.__sbxContextThen) return;
|
|
21672
|
+
const nativeThen = proto.then;
|
|
21673
|
+
Object.defineProperty(proto, "then", {
|
|
21674
|
+
configurable: true,
|
|
21675
|
+
writable: true,
|
|
21676
|
+
value: function then(onFulfilled, onRejected) {
|
|
21677
|
+
const frame = current2;
|
|
21678
|
+
const wrap2 = (handler) => typeof handler === "function" ? (value) => runInFrame(frame, () => handler(value)) : handler;
|
|
21679
|
+
return nativeThen.call(this, wrap2(onFulfilled), wrap2(onRejected));
|
|
21680
|
+
}
|
|
21681
|
+
});
|
|
21682
|
+
Object.defineProperty(proto, "__sbxContextThen", { value: true });
|
|
21683
|
+
}
|
|
21684
|
+
var AsyncLocalStorage = class {
|
|
21685
|
+
#enabled = true;
|
|
21686
|
+
getStore() {
|
|
21687
|
+
return current2.get(this);
|
|
21688
|
+
}
|
|
21689
|
+
run(store, callback, ...args) {
|
|
21690
|
+
const next = new Map(current2);
|
|
21691
|
+
next.set(this, store);
|
|
21692
|
+
this.#enabled = true;
|
|
21693
|
+
return runInFrame(next, () => callback(...args));
|
|
21694
|
+
}
|
|
21695
|
+
exit(callback, ...args) {
|
|
21696
|
+
if (!current2.has(this)) return callback(...args);
|
|
21697
|
+
const next = new Map(current2);
|
|
21698
|
+
next.delete(this);
|
|
21699
|
+
return runInFrame(next, () => callback(...args));
|
|
21700
|
+
}
|
|
21701
|
+
/** Replace the store for the rest of the current execution and its continuations. */
|
|
21702
|
+
enterWith(store) {
|
|
21703
|
+
const next = new Map(current2);
|
|
21704
|
+
next.set(this, store);
|
|
21705
|
+
current2 = next;
|
|
21706
|
+
this.#enabled = true;
|
|
21707
|
+
}
|
|
21708
|
+
disable() {
|
|
21709
|
+
if (!this.#enabled) return;
|
|
21710
|
+
this.#enabled = false;
|
|
21711
|
+
if (current2.has(this)) {
|
|
21712
|
+
const next = new Map(current2);
|
|
21713
|
+
next.delete(this);
|
|
21714
|
+
current2 = next;
|
|
21715
|
+
}
|
|
21716
|
+
}
|
|
21717
|
+
static bind(fn) {
|
|
21718
|
+
return bindToCurrent(fn);
|
|
21719
|
+
}
|
|
21720
|
+
static snapshot() {
|
|
21721
|
+
const frame = current2;
|
|
21722
|
+
return (fn, ...args) => runInFrame(frame, () => fn(...args));
|
|
21723
|
+
}
|
|
21724
|
+
};
|
|
21725
|
+
var AsyncResource = class _AsyncResource {
|
|
21726
|
+
#frame;
|
|
21727
|
+
type;
|
|
21728
|
+
constructor(type, _options) {
|
|
21729
|
+
this.type = type;
|
|
21730
|
+
this.#frame = current2;
|
|
21731
|
+
}
|
|
21732
|
+
runInAsyncScope(fn, thisArg, ...args) {
|
|
21733
|
+
return runInFrame(this.#frame, () => fn.apply(thisArg, args));
|
|
21734
|
+
}
|
|
21735
|
+
bind(fn, thisArg) {
|
|
21736
|
+
return ((...args) => this.runInAsyncScope(fn, thisArg, ...args));
|
|
21737
|
+
}
|
|
21738
|
+
emitDestroy() {
|
|
21739
|
+
return this;
|
|
21740
|
+
}
|
|
21741
|
+
asyncId() {
|
|
21742
|
+
return 1;
|
|
21743
|
+
}
|
|
21744
|
+
triggerAsyncId() {
|
|
21745
|
+
return 0;
|
|
21746
|
+
}
|
|
21747
|
+
static bind(fn, type = "bound-anonymous-fn", thisArg) {
|
|
21748
|
+
return new _AsyncResource(type).bind(fn, thisArg);
|
|
21749
|
+
}
|
|
21750
|
+
};
|
|
21751
|
+
var CONTEXT_HELPERS = {
|
|
21752
|
+
capture: "__sbxCapture",
|
|
21753
|
+
resume: "__sbxResume",
|
|
21754
|
+
restore: "__sbxRestore"
|
|
21755
|
+
};
|
|
21756
|
+
|
|
21757
|
+
// src/node/async-context-transform.ts
|
|
21758
|
+
var JSX_EXTENSION2 = /\.[jt]sx$/;
|
|
21759
|
+
var JsxParser2 = Parser.extend((0, import_acorn_jsx2.default)());
|
|
21760
|
+
var MAYBE_AWAIT = /\bawait\b/;
|
|
21761
|
+
var OPTIONS_MODULE = {
|
|
21762
|
+
ecmaVersion: "latest",
|
|
21763
|
+
sourceType: "module",
|
|
21764
|
+
allowAwaitOutsideFunction: true,
|
|
21765
|
+
allowHashBang: true,
|
|
21766
|
+
allowReturnOutsideFunction: true,
|
|
21767
|
+
allowImportExportEverywhere: true
|
|
21768
|
+
};
|
|
21769
|
+
var OPTIONS_SCRIPT = { ...OPTIONS_MODULE, sourceType: "script" };
|
|
21770
|
+
var { capture: CAPTURE, resume: RESUME, restore: RESTORE } = CONTEXT_HELPERS;
|
|
21771
|
+
function transformAsyncContext(source, filename = "module.js") {
|
|
21772
|
+
if (!MAYBE_AWAIT.test(source)) return null;
|
|
21773
|
+
const ast = parseEither(source, filename);
|
|
21774
|
+
if (!ast) return null;
|
|
21775
|
+
const edits = collectEdits(ast, source, filename);
|
|
21776
|
+
if (edits.length === 0) return null;
|
|
21777
|
+
return applyEdits2(source, edits);
|
|
21778
|
+
}
|
|
21779
|
+
function parseEither(source, filename) {
|
|
21780
|
+
const parser = JSX_EXTENSION2.test(filename) ? JsxParser2.parse.bind(JsxParser2) : parse3;
|
|
21781
|
+
for (const options of [OPTIONS_SCRIPT, OPTIONS_MODULE]) {
|
|
21782
|
+
try {
|
|
21783
|
+
return parser(source, options);
|
|
21784
|
+
} catch {
|
|
21785
|
+
}
|
|
21786
|
+
}
|
|
21787
|
+
return null;
|
|
21788
|
+
}
|
|
21789
|
+
var frameCounter = 0;
|
|
21790
|
+
function collectEdits(root, source, filename) {
|
|
21791
|
+
const edits = [];
|
|
21792
|
+
const visit = (node) => {
|
|
21793
|
+
if (Array.isArray(node)) {
|
|
21794
|
+
for (const item of node) visit(item);
|
|
21795
|
+
return;
|
|
21796
|
+
}
|
|
21797
|
+
if (!isNode2(node)) return;
|
|
21798
|
+
switch (node.type) {
|
|
21799
|
+
case "AwaitExpression": {
|
|
21800
|
+
edits.push({ start: node.start, end: node.start, text: `${RESUME}(${CAPTURE}(), ` });
|
|
21801
|
+
edits.push({ start: node.end, end: node.end, text: ")" });
|
|
21802
|
+
visit(node.argument);
|
|
21803
|
+
return;
|
|
21804
|
+
}
|
|
21805
|
+
case "TryStatement": {
|
|
21806
|
+
if (containsAwait(node.block) || containsAwait(node.handler) || containsAwait(node.finalizer)) {
|
|
21807
|
+
const frame = `__sbxFrame${frameCounter++}`;
|
|
21808
|
+
edits.push({ start: node.start, end: node.start, text: `{ const ${frame} = ${CAPTURE}(); ` });
|
|
21809
|
+
const handler = node.handler;
|
|
21810
|
+
if (handler) {
|
|
21811
|
+
const body = handler.body;
|
|
21812
|
+
edits.push({ start: body.start + 1, end: body.start + 1, text: ` ${RESTORE}(${frame});` });
|
|
21813
|
+
}
|
|
21814
|
+
const finalizer = node.finalizer;
|
|
21815
|
+
if (finalizer) {
|
|
21816
|
+
edits.push({ start: finalizer.start + 1, end: finalizer.start + 1, text: ` ${RESTORE}(${frame});` });
|
|
21817
|
+
}
|
|
21818
|
+
edits.push({ start: node.end, end: node.end, text: " }" });
|
|
21819
|
+
}
|
|
21820
|
+
visit(node.block);
|
|
21821
|
+
visit(node.handler);
|
|
21822
|
+
visit(node.finalizer);
|
|
21823
|
+
return;
|
|
21824
|
+
}
|
|
21825
|
+
case "ForOfStatement": {
|
|
21826
|
+
if (node.await === true) {
|
|
21827
|
+
const frame = `__sbxFrame${frameCounter++}`;
|
|
21828
|
+
const body = node.body;
|
|
21829
|
+
edits.push({ start: node.start, end: node.start, text: `{ const ${frame} = ${CAPTURE}(); ` });
|
|
21830
|
+
if (body.type === "BlockStatement") {
|
|
21831
|
+
edits.push({ start: body.start + 1, end: body.start + 1, text: ` ${RESTORE}(${frame});` });
|
|
21832
|
+
} else {
|
|
21833
|
+
edits.push({ start: body.start, end: body.start, text: `{ ${RESTORE}(${frame}); ` });
|
|
21834
|
+
edits.push({ start: body.end, end: body.end, text: " }" });
|
|
21835
|
+
}
|
|
21836
|
+
edits.push({ start: node.end, end: node.end, text: " }" });
|
|
21837
|
+
}
|
|
21838
|
+
visit(node.left);
|
|
21839
|
+
visit(node.right);
|
|
21840
|
+
visit(node.body);
|
|
21841
|
+
return;
|
|
21842
|
+
}
|
|
21843
|
+
case "CallExpression": {
|
|
21844
|
+
const callee = node.callee;
|
|
21845
|
+
const args = node.arguments;
|
|
21846
|
+
const first = args[0];
|
|
21847
|
+
if (callee.type === "Identifier" && callee.name === "eval" && first && first.type === "Literal" && typeof first.value === "string" && MAYBE_AWAIT.test(first.value)) {
|
|
21848
|
+
const inner = transformAsyncContext(first.value, filename);
|
|
21849
|
+
if (inner !== null) edits.push({ start: first.start, end: first.end, text: JSON.stringify(inner) });
|
|
21850
|
+
for (const argument of args.slice(1)) visit(argument);
|
|
21851
|
+
return;
|
|
21852
|
+
}
|
|
21853
|
+
break;
|
|
21854
|
+
}
|
|
21855
|
+
}
|
|
21856
|
+
for (const [key, value] of Object.entries(node)) {
|
|
21857
|
+
if (key === "type" || key === "start" || key === "end") continue;
|
|
21858
|
+
if (value && typeof value === "object") visit(value);
|
|
21859
|
+
}
|
|
21860
|
+
};
|
|
21861
|
+
visit(root);
|
|
21862
|
+
return edits;
|
|
21863
|
+
}
|
|
21864
|
+
function containsAwait(node) {
|
|
21865
|
+
if (Array.isArray(node)) return node.some(containsAwait);
|
|
21866
|
+
if (!isNode2(node)) return false;
|
|
21867
|
+
if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
|
|
21868
|
+
return false;
|
|
21869
|
+
}
|
|
21870
|
+
if (node.type === "AwaitExpression") return true;
|
|
21871
|
+
if (node.type === "ForOfStatement" && node.await === true) return true;
|
|
21872
|
+
for (const [key, value] of Object.entries(node)) {
|
|
21873
|
+
if (key === "type" || key === "start" || key === "end") continue;
|
|
21874
|
+
if (value && typeof value === "object" && containsAwait(value)) return true;
|
|
21875
|
+
}
|
|
21876
|
+
return false;
|
|
21877
|
+
}
|
|
21878
|
+
function applyEdits2(source, edits) {
|
|
21879
|
+
const ordered = edits.map((edit, index) => ({ ...edit, index })).sort((a, b) => b.start - a.start || b.end - a.end || b.index - a.index);
|
|
21880
|
+
let out = source;
|
|
21881
|
+
for (const edit of ordered) out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
21882
|
+
return out;
|
|
21883
|
+
}
|
|
21884
|
+
function isNode2(value) {
|
|
21885
|
+
return typeof value === "object" && value !== null && typeof value.type === "string";
|
|
21886
|
+
}
|
|
21887
|
+
|
|
21633
21888
|
// node_modules/resolve.exports/dist/index.mjs
|
|
21634
21889
|
function e(e2, n2, r2) {
|
|
21635
21890
|
throw new Error(r2 ? `No known conditions for "${n2}" specifier in "${e2}" package` : `Missing "${n2}" specifier in "${e2}" package`);
|
|
@@ -21724,6 +21979,19 @@ var CommonJsEngine = class {
|
|
|
21724
21979
|
getOwnPropertyDescriptor: (_target, key) => this.cache.has(String(key)) ? { enumerable: true, configurable: true, writable: true, value: this.cache.get(String(key)) } : void 0
|
|
21725
21980
|
});
|
|
21726
21981
|
this.moduleApi._resolveFilename = (request, parent) => this.resolve(request, parent?.filename || join(this.cwd, "__entry__.js"));
|
|
21982
|
+
this.moduleApi._nodeModulePaths = (from) => {
|
|
21983
|
+
const directory = resolve(this.cwd, String(from));
|
|
21984
|
+
if (directory === "/") return ["/node_modules"];
|
|
21985
|
+
const parts = segments(directory);
|
|
21986
|
+
const paths = [];
|
|
21987
|
+
for (let index = parts.length; index > 0; index--) {
|
|
21988
|
+
if (parts[index - 1] === "node_modules") continue;
|
|
21989
|
+
paths.push(`/${[...parts.slice(0, index), "node_modules"].join("/")}`);
|
|
21990
|
+
}
|
|
21991
|
+
paths.push("/node_modules");
|
|
21992
|
+
return paths;
|
|
21993
|
+
};
|
|
21994
|
+
this.moduleApi._load = (request, parent) => this.makeRequire(parent ?? Object.assign(new this.moduleApi(join(this.cwd, "__entry__.js")), { filename: join(this.cwd, "__entry__.js") }))(request);
|
|
21727
21995
|
this.moduleApi.prototype.require = function(request) {
|
|
21728
21996
|
const filename = engine.moduleApi._resolveFilename(request, this);
|
|
21729
21997
|
const builtin = engine.builtin(filename, this);
|
|
@@ -21842,7 +22110,8 @@ var CommonJsEngine = class {
|
|
|
21842
22110
|
evaluate(module, source) {
|
|
21843
22111
|
if (source.startsWith("#!")) source = source.replace(/^#![^\n]*(?:\n|$)/, "");
|
|
21844
22112
|
const transformed = transformEsm(source, module.filename);
|
|
21845
|
-
const
|
|
22113
|
+
const esmBody = transformed?.code ?? source;
|
|
22114
|
+
const body = transformAsyncContext(esmBody, module.filename) ?? esmBody;
|
|
21846
22115
|
const code = transformed?.topLevelAwait ? `return (async () => {
|
|
21847
22116
|
${body}
|
|
21848
22117
|
})();` : body;
|
|
@@ -21850,7 +22119,10 @@ ${body}
|
|
|
21850
22119
|
[HELPERS.import, (specifier) => this.importNamespace(specifier, module)],
|
|
21851
22120
|
[HELPERS.dynamic, (specifier) => this.dynamicImport(specifier, module)],
|
|
21852
22121
|
[HELPERS.exportAll, exportAll],
|
|
21853
|
-
[HELPERS.meta, this.importMeta(module)]
|
|
22122
|
+
[HELPERS.meta, this.importMeta(module)],
|
|
22123
|
+
[CONTEXT_HELPERS.capture, capture],
|
|
22124
|
+
[CONTEXT_HELPERS.resume, resume],
|
|
22125
|
+
[CONTEXT_HELPERS.restore, restore]
|
|
21854
22126
|
];
|
|
21855
22127
|
const bindings = transformed?.esm ? [[HELPERS.exports, module.exports], ...helpers] : [
|
|
21856
22128
|
["exports", module.exports],
|
|
@@ -22227,10 +22499,173 @@ function newIpcChannelId() {
|
|
|
22227
22499
|
return `ipc-${random}`;
|
|
22228
22500
|
}
|
|
22229
22501
|
|
|
22502
|
+
// src/node/vm-module.ts
|
|
22503
|
+
var contexts = /* @__PURE__ */ new WeakSet();
|
|
22504
|
+
var globalEval = eval;
|
|
22505
|
+
var filenameOf = (options) => typeof options === "string" ? options : options?.filename;
|
|
22506
|
+
var withSourceUrl = (code, options) => {
|
|
22507
|
+
const filename = filenameOf(options);
|
|
22508
|
+
return filename ? `${code}
|
|
22509
|
+
//# sourceURL=${filename.replace(/\s/g, "%20")}` : code;
|
|
22510
|
+
};
|
|
22511
|
+
function runWithScope(code, sandbox, options) {
|
|
22512
|
+
const scope = new Proxy(sandbox, {
|
|
22513
|
+
/* The wrapper's own variables must resolve to the wrapper, never to the
|
|
22514
|
+
* context — otherwise `__sbx_vm_result__ = eval(…)` stores the completion
|
|
22515
|
+
* value on the sandbox and the function returns undefined. */
|
|
22516
|
+
has: (target, key) => !(typeof key === "string" && key.startsWith("__sbx_vm_")) && (key in target || !(key in globalThis)),
|
|
22517
|
+
get: (target, key) => {
|
|
22518
|
+
if (key === Symbol.unscopables) return void 0;
|
|
22519
|
+
if (key in target) return target[key];
|
|
22520
|
+
return globalThis[key];
|
|
22521
|
+
},
|
|
22522
|
+
set: (target, key, value) => {
|
|
22523
|
+
target[key] = value;
|
|
22524
|
+
return true;
|
|
22525
|
+
}
|
|
22526
|
+
});
|
|
22527
|
+
const declared = topLevelDeclarations(code);
|
|
22528
|
+
const evaluate = new Function(
|
|
22529
|
+
"__sbx_vm_scope__",
|
|
22530
|
+
"__sbx_vm_source__",
|
|
22531
|
+
"__sbx_vm_names__",
|
|
22532
|
+
"__sbx_vm_target__",
|
|
22533
|
+
"var __sbx_vm_result__; with (__sbx_vm_scope__) { __sbx_vm_result__ = eval(__sbx_vm_source__); }for (var __sbx_vm_i__ = 0; __sbx_vm_i__ < __sbx_vm_names__.length; __sbx_vm_i__++) { try { var __sbx_vm_value__ = eval(__sbx_vm_names__[__sbx_vm_i__]); if (__sbx_vm_value__ !== undefined || !(__sbx_vm_names__[__sbx_vm_i__] in __sbx_vm_target__)) __sbx_vm_target__[__sbx_vm_names__[__sbx_vm_i__]] = __sbx_vm_value__; } catch (e) {}}return __sbx_vm_result__;"
|
|
22534
|
+
);
|
|
22535
|
+
return evaluate(scope, withSourceUrl(code, options), declared, sandbox);
|
|
22536
|
+
}
|
|
22537
|
+
function topLevelDeclarations(code) {
|
|
22538
|
+
const names = /* @__PURE__ */ new Set();
|
|
22539
|
+
let depth = 0;
|
|
22540
|
+
for (let index = 0; index < code.length; index++) {
|
|
22541
|
+
const char = code[index];
|
|
22542
|
+
if (char === "/" && code[index + 1] === "/") {
|
|
22543
|
+
const end = code.indexOf("\n", index);
|
|
22544
|
+
index = end === -1 ? code.length : end;
|
|
22545
|
+
continue;
|
|
22546
|
+
}
|
|
22547
|
+
if (char === "/" && code[index + 1] === "*") {
|
|
22548
|
+
const end = code.indexOf("*/", index + 2);
|
|
22549
|
+
index = end === -1 ? code.length : end + 1;
|
|
22550
|
+
continue;
|
|
22551
|
+
}
|
|
22552
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
22553
|
+
for (index++; index < code.length && code[index] !== char; index++) if (code[index] === "\\") index++;
|
|
22554
|
+
continue;
|
|
22555
|
+
}
|
|
22556
|
+
if (char === "{") {
|
|
22557
|
+
depth++;
|
|
22558
|
+
continue;
|
|
22559
|
+
}
|
|
22560
|
+
if (char === "}") {
|
|
22561
|
+
depth = Math.max(0, depth - 1);
|
|
22562
|
+
continue;
|
|
22563
|
+
}
|
|
22564
|
+
if (depth !== 0 || !/[A-Za-z_$]/.test(char) || index > 0 && /[\w$]/.test(code[index - 1])) continue;
|
|
22565
|
+
const rest = code.slice(index);
|
|
22566
|
+
const fn = /^(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/.exec(rest);
|
|
22567
|
+
if (fn) {
|
|
22568
|
+
names.add(fn[1]);
|
|
22569
|
+
continue;
|
|
22570
|
+
}
|
|
22571
|
+
const declaration = /^var\s+([^;]+)/.exec(rest);
|
|
22572
|
+
if (declaration) {
|
|
22573
|
+
for (const part of declaration[1].split(",")) {
|
|
22574
|
+
const name = /^\s*([A-Za-z_$][\w$]*)/.exec(part);
|
|
22575
|
+
if (name) names.add(name[1]);
|
|
22576
|
+
}
|
|
22577
|
+
}
|
|
22578
|
+
}
|
|
22579
|
+
return [...names];
|
|
22580
|
+
}
|
|
22581
|
+
function createContext(sandbox = {}) {
|
|
22582
|
+
contexts.add(sandbox);
|
|
22583
|
+
if (!("globalThis" in sandbox)) Object.defineProperty(sandbox, "globalThis", { value: sandbox, writable: true, configurable: true });
|
|
22584
|
+
return sandbox;
|
|
22585
|
+
}
|
|
22586
|
+
function isContext(value) {
|
|
22587
|
+
return typeof value === "object" && value !== null && contexts.has(value);
|
|
22588
|
+
}
|
|
22589
|
+
function runInThisContext(code, options) {
|
|
22590
|
+
return globalEval(withSourceUrl(String(code), options));
|
|
22591
|
+
}
|
|
22592
|
+
function runInContext(code, context, options) {
|
|
22593
|
+
if (!isContext(context)) {
|
|
22594
|
+
throw Object.assign(new TypeError('The "contextifiedObject" argument must be an vm.Context'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
22595
|
+
}
|
|
22596
|
+
return runWithScope(String(code), context, options);
|
|
22597
|
+
}
|
|
22598
|
+
function runInNewContext(code, sandbox, options) {
|
|
22599
|
+
return runWithScope(String(code), createContext(sandbox ?? {}), options);
|
|
22600
|
+
}
|
|
22601
|
+
var Script = class {
|
|
22602
|
+
#code;
|
|
22603
|
+
#options;
|
|
22604
|
+
constructor(code, options = {}) {
|
|
22605
|
+
this.#code = String(code);
|
|
22606
|
+
this.#options = typeof options === "string" ? { filename: options } : { ...options };
|
|
22607
|
+
new Function(this.#code.replace(/^#!.*/, ""));
|
|
22608
|
+
}
|
|
22609
|
+
runInThisContext(options) {
|
|
22610
|
+
return runInThisContext(this.#code, { ...this.#options, ...options });
|
|
22611
|
+
}
|
|
22612
|
+
runInContext(context, options) {
|
|
22613
|
+
return runInContext(this.#code, context, { ...this.#options, ...options });
|
|
22614
|
+
}
|
|
22615
|
+
runInNewContext(sandbox, options) {
|
|
22616
|
+
return runInNewContext(this.#code, sandbox, { ...this.#options, ...options });
|
|
22617
|
+
}
|
|
22618
|
+
createCachedData() {
|
|
22619
|
+
return new Uint8Array();
|
|
22620
|
+
}
|
|
22621
|
+
};
|
|
22622
|
+
function compileFunction(code, params = [], options = {}) {
|
|
22623
|
+
const source = withSourceUrl(String(code), options.filename);
|
|
22624
|
+
if (options.parsingContext && isContext(options.parsingContext)) {
|
|
22625
|
+
return runWithScope(`(function (${params.join(", ")}) {
|
|
22626
|
+
${source}
|
|
22627
|
+
})`, options.parsingContext, void 0);
|
|
22628
|
+
}
|
|
22629
|
+
return new Function(...params, source);
|
|
22630
|
+
}
|
|
22631
|
+
var vmModule = {
|
|
22632
|
+
Script,
|
|
22633
|
+
createContext,
|
|
22634
|
+
isContext,
|
|
22635
|
+
runInThisContext,
|
|
22636
|
+
runInContext,
|
|
22637
|
+
runInNewContext,
|
|
22638
|
+
compileFunction,
|
|
22639
|
+
constants: {
|
|
22640
|
+
USE_MAIN_CONTEXT_DEFAULT_LOADER: /* @__PURE__ */ Symbol("vm_dynamic_import_main_context_default"),
|
|
22641
|
+
DONT_CONTEXTIFY: /* @__PURE__ */ Symbol("vm_context_no_contextify")
|
|
22642
|
+
},
|
|
22643
|
+
measureMemory: async () => ({ total: { jsMemoryEstimate: 0, jsMemoryRange: [0, 0] } })
|
|
22644
|
+
};
|
|
22645
|
+
var vm_module_default = vmModule;
|
|
22646
|
+
|
|
22230
22647
|
// src/node/buffer-module.ts
|
|
22231
22648
|
var import_buffer = __toESM(require_buffer());
|
|
22232
22649
|
var platformBuffer = globalThis.Buffer;
|
|
22233
|
-
|
|
22650
|
+
addUint8ArraySupport(addBase64UrlSupport(import_buffer.Buffer));
|
|
22651
|
+
var Buffer2 = platformBuffer ?? import_buffer.Buffer;
|
|
22652
|
+
function addUint8ArraySupport(BufferClass) {
|
|
22653
|
+
const target = BufferClass;
|
|
22654
|
+
if (target.__sandboxedUint8Array) return BufferClass;
|
|
22655
|
+
Object.defineProperty(target, "__sandboxedUint8Array", { value: true });
|
|
22656
|
+
const asBuffer = (value) => value instanceof Uint8Array && !target.isBuffer(value) ? target.from(value.buffer, value.byteOffset, value.byteLength) : value;
|
|
22657
|
+
for (const method of ["indexOf", "lastIndexOf", "includes"]) {
|
|
22658
|
+
const original = target.prototype[method];
|
|
22659
|
+
target.prototype[method] = function(value, ...rest) {
|
|
22660
|
+
return original.call(this, asBuffer(value), ...rest);
|
|
22661
|
+
};
|
|
22662
|
+
}
|
|
22663
|
+
const equals = target.prototype.equals;
|
|
22664
|
+
target.prototype.equals = function(other) {
|
|
22665
|
+
return equals.call(this, asBuffer(other));
|
|
22666
|
+
};
|
|
22667
|
+
return BufferClass;
|
|
22668
|
+
}
|
|
22234
22669
|
function addBase64UrlSupport(BufferClass) {
|
|
22235
22670
|
const target = BufferClass;
|
|
22236
22671
|
if (target.__sandboxedBase64Url) return BufferClass;
|
|
@@ -22261,7 +22696,247 @@ function normalizeEncoding(value) {
|
|
|
22261
22696
|
// src/node/core-modules.ts
|
|
22262
22697
|
var import_events4 = __toESM(require_events());
|
|
22263
22698
|
var import_path_browserify = __toESM(require_path_browserify());
|
|
22264
|
-
var
|
|
22699
|
+
var import_stream_browserify5 = __toESM(require_stream_browserify());
|
|
22700
|
+
|
|
22701
|
+
// src/node/stream-compat.ts
|
|
22702
|
+
var import_stream_browserify = __toESM(require_stream_browserify());
|
|
22703
|
+
function define2(proto, name, get) {
|
|
22704
|
+
if (Object.getOwnPropertyDescriptor(proto, name)) return;
|
|
22705
|
+
Object.defineProperty(proto, name, { configurable: true, enumerable: false, get });
|
|
22706
|
+
}
|
|
22707
|
+
var installed = false;
|
|
22708
|
+
function installWebStreamAdapters(stream) {
|
|
22709
|
+
const { Readable, Writable, Duplex } = stream;
|
|
22710
|
+
const toError = (reason) => reason instanceof Error ? reason : new Error(reason === void 0 ? "aborted" : String(reason));
|
|
22711
|
+
const readableToWeb = (source, options = {}) => {
|
|
22712
|
+
let onData;
|
|
22713
|
+
return new ReadableStream({
|
|
22714
|
+
start(controller) {
|
|
22715
|
+
const objectMode = Boolean(source?._readableState?.objectMode);
|
|
22716
|
+
onData = (chunk) => {
|
|
22717
|
+
const value = objectMode || !(chunk instanceof Uint8Array) && typeof chunk !== "string" ? chunk : typeof chunk === "string" ? new TextEncoder().encode(chunk) : new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
22718
|
+
controller.enqueue(value);
|
|
22719
|
+
if ((controller.desiredSize ?? 1) <= 0) source.pause();
|
|
22720
|
+
};
|
|
22721
|
+
source.on("data", onData);
|
|
22722
|
+
source.once("end", () => {
|
|
22723
|
+
try {
|
|
22724
|
+
controller.close();
|
|
22725
|
+
} catch {
|
|
22726
|
+
}
|
|
22727
|
+
});
|
|
22728
|
+
source.once("error", (error) => {
|
|
22729
|
+
try {
|
|
22730
|
+
controller.error(error);
|
|
22731
|
+
} catch {
|
|
22732
|
+
}
|
|
22733
|
+
});
|
|
22734
|
+
source.once("close", () => {
|
|
22735
|
+
if (!source.readableEnded && !source._readableState?.endEmitted) {
|
|
22736
|
+
try {
|
|
22737
|
+
controller.error(new Error("The stream was destroyed before it ended"));
|
|
22738
|
+
} catch {
|
|
22739
|
+
}
|
|
22740
|
+
}
|
|
22741
|
+
});
|
|
22742
|
+
},
|
|
22743
|
+
pull() {
|
|
22744
|
+
if (typeof source.isPaused === "function" && source.isPaused()) source.resume();
|
|
22745
|
+
},
|
|
22746
|
+
cancel(reason) {
|
|
22747
|
+
if (onData) source.off("data", onData);
|
|
22748
|
+
source.destroy(reason === void 0 ? void 0 : toError(reason));
|
|
22749
|
+
}
|
|
22750
|
+
}, options.strategy ?? { highWaterMark: 1 });
|
|
22751
|
+
};
|
|
22752
|
+
const readableFromWeb = (web, options = {}) => {
|
|
22753
|
+
const reader = web.getReader();
|
|
22754
|
+
let reading = false;
|
|
22755
|
+
const readable = new Readable({
|
|
22756
|
+
...options,
|
|
22757
|
+
read() {
|
|
22758
|
+
if (reading) return;
|
|
22759
|
+
reading = true;
|
|
22760
|
+
void (async () => {
|
|
22761
|
+
try {
|
|
22762
|
+
for (; ; ) {
|
|
22763
|
+
const { done, value } = await reader.read();
|
|
22764
|
+
if (done) {
|
|
22765
|
+
readable.push(null);
|
|
22766
|
+
return;
|
|
22767
|
+
}
|
|
22768
|
+
const chunk = value instanceof Uint8Array && !options.objectMode ? Buffer2.from(value.buffer, value.byteOffset, value.byteLength) : value;
|
|
22769
|
+
if (!readable.push(chunk)) return;
|
|
22770
|
+
}
|
|
22771
|
+
} catch (error) {
|
|
22772
|
+
readable.destroy(toError(error));
|
|
22773
|
+
} finally {
|
|
22774
|
+
reading = false;
|
|
22775
|
+
}
|
|
22776
|
+
})();
|
|
22777
|
+
},
|
|
22778
|
+
destroy(error, callback) {
|
|
22779
|
+
reader.cancel(error ?? void 0).catch(() => {
|
|
22780
|
+
}).finally(() => callback(error));
|
|
22781
|
+
}
|
|
22782
|
+
});
|
|
22783
|
+
return readable;
|
|
22784
|
+
};
|
|
22785
|
+
const writableToWeb = (sink) => new WritableStream({
|
|
22786
|
+
write(chunk) {
|
|
22787
|
+
return new Promise((resolve2, reject) => {
|
|
22788
|
+
const ok2 = sink.write(chunk, (error) => {
|
|
22789
|
+
if (error) reject(error);
|
|
22790
|
+
});
|
|
22791
|
+
if (ok2) resolve2();
|
|
22792
|
+
else {
|
|
22793
|
+
const onDrain = () => {
|
|
22794
|
+
sink.off("error", onError);
|
|
22795
|
+
resolve2();
|
|
22796
|
+
};
|
|
22797
|
+
const onError = (error) => {
|
|
22798
|
+
sink.off("drain", onDrain);
|
|
22799
|
+
reject(error);
|
|
22800
|
+
};
|
|
22801
|
+
sink.once("drain", onDrain);
|
|
22802
|
+
sink.once("error", onError);
|
|
22803
|
+
}
|
|
22804
|
+
});
|
|
22805
|
+
},
|
|
22806
|
+
close() {
|
|
22807
|
+
return new Promise((resolve2, reject) => {
|
|
22808
|
+
sink.once("error", reject);
|
|
22809
|
+
sink.end(() => resolve2());
|
|
22810
|
+
});
|
|
22811
|
+
},
|
|
22812
|
+
abort(reason) {
|
|
22813
|
+
sink.destroy(toError(reason));
|
|
22814
|
+
}
|
|
22815
|
+
});
|
|
22816
|
+
const writableFromWeb = (web, options = {}) => {
|
|
22817
|
+
const writer = web.getWriter();
|
|
22818
|
+
return new Writable({
|
|
22819
|
+
...options,
|
|
22820
|
+
write(chunk, _encoding, callback) {
|
|
22821
|
+
writer.write(chunk).then(() => callback(), (error) => callback(toError(error)));
|
|
22822
|
+
},
|
|
22823
|
+
final(callback) {
|
|
22824
|
+
writer.close().then(() => callback(), (error) => callback(toError(error)));
|
|
22825
|
+
},
|
|
22826
|
+
destroy(error, callback) {
|
|
22827
|
+
(error ? writer.abort(error) : writer.close()).catch(() => {
|
|
22828
|
+
}).finally(() => callback(error));
|
|
22829
|
+
}
|
|
22830
|
+
});
|
|
22831
|
+
};
|
|
22832
|
+
const define3 = (target, name, value) => {
|
|
22833
|
+
if (typeof target[name] === "function") return;
|
|
22834
|
+
Object.defineProperty(target, name, { configurable: true, writable: true, value });
|
|
22835
|
+
};
|
|
22836
|
+
define3(Readable, "toWeb", readableToWeb);
|
|
22837
|
+
define3(Readable, "fromWeb", readableFromWeb);
|
|
22838
|
+
define3(Writable, "toWeb", writableToWeb);
|
|
22839
|
+
define3(Writable, "fromWeb", writableFromWeb);
|
|
22840
|
+
define3(Duplex, "toWeb", (duplex) => ({ readable: readableToWeb(duplex), writable: writableToWeb(duplex) }));
|
|
22841
|
+
define3(Duplex, "fromWeb", (pair, options = {}) => {
|
|
22842
|
+
const readable = readableFromWeb(pair.readable, options);
|
|
22843
|
+
const writable = writableFromWeb(pair.writable, options);
|
|
22844
|
+
const duplex = new Duplex({
|
|
22845
|
+
...options,
|
|
22846
|
+
read() {
|
|
22847
|
+
readable.resume();
|
|
22848
|
+
},
|
|
22849
|
+
write(chunk, encoding, callback) {
|
|
22850
|
+
writable.write(chunk, encoding, callback);
|
|
22851
|
+
},
|
|
22852
|
+
final(callback) {
|
|
22853
|
+
writable.end(callback);
|
|
22854
|
+
}
|
|
22855
|
+
});
|
|
22856
|
+
readable.on("data", (chunk) => {
|
|
22857
|
+
if (!duplex.push(chunk)) readable.pause();
|
|
22858
|
+
});
|
|
22859
|
+
readable.once("end", () => duplex.push(null));
|
|
22860
|
+
readable.once("error", (error) => duplex.destroy(error));
|
|
22861
|
+
writable.once("error", (error) => duplex.destroy(error));
|
|
22862
|
+
return duplex;
|
|
22863
|
+
});
|
|
22864
|
+
}
|
|
22865
|
+
function installStreamCompat() {
|
|
22866
|
+
if (installed) return;
|
|
22867
|
+
installed = true;
|
|
22868
|
+
const stream = import_stream_browserify.default;
|
|
22869
|
+
const writable = (self2) => self2._writableState;
|
|
22870
|
+
const readable = (self2) => self2._readableState;
|
|
22871
|
+
for (const proto of [stream.Writable.prototype, stream.Duplex.prototype]) {
|
|
22872
|
+
define2(proto, "writableEnded", function() {
|
|
22873
|
+
return Boolean(writable(this)?.ending);
|
|
22874
|
+
});
|
|
22875
|
+
define2(proto, "writableFinished", function() {
|
|
22876
|
+
return Boolean(writable(this)?.finished);
|
|
22877
|
+
});
|
|
22878
|
+
define2(proto, "writableNeedDrain", function() {
|
|
22879
|
+
const state = writable(this);
|
|
22880
|
+
return Boolean(state && !state.destroyed && !state.ending && state.needDrain);
|
|
22881
|
+
});
|
|
22882
|
+
define2(proto, "writableCorked", function() {
|
|
22883
|
+
return Number(writable(this)?.corked ?? 0);
|
|
22884
|
+
});
|
|
22885
|
+
define2(proto, "writableObjectMode", function() {
|
|
22886
|
+
return Boolean(writable(this)?.objectMode);
|
|
22887
|
+
});
|
|
22888
|
+
define2(proto, "writableAborted", function() {
|
|
22889
|
+
const state = writable(this);
|
|
22890
|
+
return Boolean(state && state.destroyed && !state.finished);
|
|
22891
|
+
});
|
|
22892
|
+
}
|
|
22893
|
+
for (const proto of [stream.Readable.prototype, stream.Duplex.prototype]) {
|
|
22894
|
+
define2(proto, "readableEnded", function() {
|
|
22895
|
+
return Boolean(readable(this)?.endEmitted);
|
|
22896
|
+
});
|
|
22897
|
+
define2(proto, "readableAborted", function() {
|
|
22898
|
+
const state = readable(this);
|
|
22899
|
+
return Boolean(state && state.destroyed && !state.endEmitted);
|
|
22900
|
+
});
|
|
22901
|
+
define2(proto, "readableDidRead", function() {
|
|
22902
|
+
return Boolean(readable(this)?.dataEmitted ?? readable(this)?.readingMore);
|
|
22903
|
+
});
|
|
22904
|
+
}
|
|
22905
|
+
const writableProto = stream.Writable.prototype;
|
|
22906
|
+
const originalEnd = writableProto.end;
|
|
22907
|
+
const originalEmit = writableProto.emit;
|
|
22908
|
+
const inEnd = /* @__PURE__ */ new WeakSet();
|
|
22909
|
+
writableProto.end = function(...args) {
|
|
22910
|
+
inEnd.add(this);
|
|
22911
|
+
try {
|
|
22912
|
+
return originalEnd.apply(this, args);
|
|
22913
|
+
} finally {
|
|
22914
|
+
inEnd.delete(this);
|
|
22915
|
+
}
|
|
22916
|
+
};
|
|
22917
|
+
writableProto.emit = function(event, ...args) {
|
|
22918
|
+
if (event === "finish" && inEnd.has(this)) {
|
|
22919
|
+
const self2 = this;
|
|
22920
|
+
const later = globalThis.process?.nextTick;
|
|
22921
|
+
const deliver = () => {
|
|
22922
|
+
originalEmit.call(self2, event, ...args);
|
|
22923
|
+
};
|
|
22924
|
+
if (typeof later === "function") later(deliver);
|
|
22925
|
+
else queueMicrotask(deliver);
|
|
22926
|
+
return true;
|
|
22927
|
+
}
|
|
22928
|
+
return originalEmit.call(this, event, ...args);
|
|
22929
|
+
};
|
|
22930
|
+
installWebStreamAdapters(stream);
|
|
22931
|
+
for (const proto of [stream.Writable.prototype, stream.Readable.prototype, stream.Duplex.prototype]) {
|
|
22932
|
+
define2(proto, "closed", function() {
|
|
22933
|
+
return Boolean(writable(this)?.destroyed || readable(this)?.destroyed);
|
|
22934
|
+
});
|
|
22935
|
+
define2(proto, "errored", function() {
|
|
22936
|
+
return this.__sbxErrored ?? null;
|
|
22937
|
+
});
|
|
22938
|
+
}
|
|
22939
|
+
}
|
|
22265
22940
|
|
|
22266
22941
|
// src/node/readable-from.ts
|
|
22267
22942
|
function createReadableFrom(Readable) {
|
|
@@ -22308,8 +22983,8 @@ function createReadableFrom(Readable) {
|
|
|
22308
22983
|
return stream;
|
|
22309
22984
|
};
|
|
22310
22985
|
}
|
|
22311
|
-
function installReadableFrom(
|
|
22312
|
-
|
|
22986
|
+
function installReadableFrom(streamModule6) {
|
|
22987
|
+
streamModule6.Readable.from = createReadableFrom(streamModule6.Readable);
|
|
22313
22988
|
}
|
|
22314
22989
|
|
|
22315
22990
|
// src/node/env.ts
|
|
@@ -22950,12 +23625,12 @@ function matches(error, expected) {
|
|
|
22950
23625
|
return String(error) === String(expected);
|
|
22951
23626
|
}
|
|
22952
23627
|
function throws(block, expected, message) {
|
|
22953
|
-
const [error, threw] =
|
|
23628
|
+
const [error, threw] = capture2(block);
|
|
22954
23629
|
if (!threw) fail(void 0, expected, message ?? "Missing expected exception.", "throws");
|
|
22955
23630
|
if (!matches(error, expected)) throw error;
|
|
22956
23631
|
}
|
|
22957
23632
|
function doesNotThrow(block, expected, message) {
|
|
22958
|
-
const [error, threw] =
|
|
23633
|
+
const [error, threw] = capture2(block);
|
|
22959
23634
|
if (!threw) return;
|
|
22960
23635
|
if (matches(error, expected)) {
|
|
22961
23636
|
fail(error, expected, message ?? "Got unwanted exception.", "doesNotThrow");
|
|
@@ -22975,7 +23650,7 @@ async function doesNotReject(block, expected, message) {
|
|
|
22975
23650
|
}
|
|
22976
23651
|
throw error;
|
|
22977
23652
|
}
|
|
22978
|
-
function
|
|
23653
|
+
function capture2(block) {
|
|
22979
23654
|
try {
|
|
22980
23655
|
block();
|
|
22981
23656
|
return [void 0, false];
|
|
@@ -23036,7 +23711,7 @@ var assert_module_default = assertModule;
|
|
|
23036
23711
|
var import_browser = __toESM(require_browser2());
|
|
23037
23712
|
|
|
23038
23713
|
// src/node/zlib-module.ts
|
|
23039
|
-
var
|
|
23714
|
+
var import_stream_browserify2 = __toESM(require_stream_browserify());
|
|
23040
23715
|
|
|
23041
23716
|
// node_modules/pako/dist/pako.esm.mjs
|
|
23042
23717
|
var Z_FIXED$1 = 4;
|
|
@@ -25252,10 +25927,12 @@ function gzip$1(input, options) {
|
|
|
25252
25927
|
options.gzip = true;
|
|
25253
25928
|
return deflate$1(input, options);
|
|
25254
25929
|
}
|
|
25930
|
+
var Deflate_1$1 = Deflate$1;
|
|
25255
25931
|
var deflate_2 = deflate$1;
|
|
25256
25932
|
var deflateRaw_1$1 = deflateRaw$1;
|
|
25257
25933
|
var gzip_1$1 = gzip$1;
|
|
25258
25934
|
var deflate_1$1 = {
|
|
25935
|
+
Deflate: Deflate_1$1,
|
|
25259
25936
|
deflate: deflate_2,
|
|
25260
25937
|
deflateRaw: deflateRaw_1$1,
|
|
25261
25938
|
gzip: gzip_1$1};
|
|
@@ -27218,29 +27895,37 @@ function inflateRaw$1(input, options) {
|
|
|
27218
27895
|
options.raw = true;
|
|
27219
27896
|
return inflate$1(input, options);
|
|
27220
27897
|
}
|
|
27898
|
+
var Inflate_1$1 = Inflate$1;
|
|
27221
27899
|
var inflate_2 = inflate$1;
|
|
27222
27900
|
var inflateRaw_1$1 = inflateRaw$1;
|
|
27223
27901
|
var ungzip$1 = inflate$1;
|
|
27224
27902
|
var inflate_1$1 = {
|
|
27903
|
+
Inflate: Inflate_1$1,
|
|
27225
27904
|
inflate: inflate_2,
|
|
27226
27905
|
inflateRaw: inflateRaw_1$1,
|
|
27227
27906
|
ungzip: ungzip$1};
|
|
27228
|
-
var { deflate, deflateRaw, gzip } = deflate_1$1;
|
|
27229
|
-
var { inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
27907
|
+
var { Deflate, deflate, deflateRaw, gzip } = deflate_1$1;
|
|
27908
|
+
var { Inflate, inflate, inflateRaw, ungzip } = inflate_1$1;
|
|
27909
|
+
var Deflate_1 = Deflate;
|
|
27230
27910
|
var deflate_1 = deflate;
|
|
27231
27911
|
var deflateRaw_1 = deflateRaw;
|
|
27232
27912
|
var gzip_1 = gzip;
|
|
27913
|
+
var Inflate_1 = Inflate;
|
|
27233
27914
|
var inflate_1 = inflate;
|
|
27234
27915
|
var inflateRaw_1 = inflateRaw;
|
|
27235
27916
|
var ungzip_1 = ungzip;
|
|
27236
27917
|
|
|
27237
27918
|
// src/node/zlib-module.ts
|
|
27919
|
+
var Z_NO_FLUSH2 = 0;
|
|
27920
|
+
var Z_SYNC_FLUSH2 = 2;
|
|
27921
|
+
var Z_FULL_FLUSH2 = 3;
|
|
27922
|
+
var Z_FINISH2 = 4;
|
|
27238
27923
|
var bytes = (data2) => {
|
|
27239
27924
|
if (typeof data2 === "string") return new Uint8Array(Buffer2.from(data2, "utf8"));
|
|
27240
27925
|
if (data2 instanceof ArrayBuffer) return new Uint8Array(data2);
|
|
27241
27926
|
return data2;
|
|
27242
27927
|
};
|
|
27243
|
-
function codec(
|
|
27928
|
+
function codec(run2) {
|
|
27244
27929
|
const sync = (data2, options) => Buffer2.from(run2(bytes(data2), options));
|
|
27245
27930
|
const async_ = (data2, options, callback) => {
|
|
27246
27931
|
const done = typeof options === "function" ? options : callback;
|
|
@@ -27253,37 +27938,159 @@ function codec(name, run2) {
|
|
|
27253
27938
|
}
|
|
27254
27939
|
});
|
|
27255
27940
|
};
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
|
|
27259
|
-
|
|
27260
|
-
|
|
27261
|
-
|
|
27941
|
+
return { sync, async: async_ };
|
|
27942
|
+
}
|
|
27943
|
+
function createEngine(mode, options) {
|
|
27944
|
+
const windowBits = typeof options.windowBits === "number" ? options.windowBits : 15;
|
|
27945
|
+
const level = typeof options.level === "number" ? options.level : -1;
|
|
27946
|
+
const memLevel = typeof options.memLevel === "number" ? options.memLevel : 8;
|
|
27947
|
+
const strategy = typeof options.strategy === "number" ? options.strategy : 0;
|
|
27948
|
+
const deflateOptions = { level, memLevel, strategy, windowBits };
|
|
27949
|
+
switch (mode) {
|
|
27950
|
+
case "Deflate":
|
|
27951
|
+
return new Deflate_1(deflateOptions);
|
|
27952
|
+
case "Gzip":
|
|
27953
|
+
return new Deflate_1({ ...deflateOptions, gzip: true });
|
|
27954
|
+
case "DeflateRaw":
|
|
27955
|
+
return new Deflate_1({ ...deflateOptions, raw: true });
|
|
27956
|
+
case "Inflate":
|
|
27957
|
+
return new Inflate_1({ windowBits });
|
|
27958
|
+
case "InflateRaw":
|
|
27959
|
+
return new Inflate_1({ raw: true, windowBits });
|
|
27960
|
+
/* zlib's `windowBits + 16` means gzip only; `+ 32` detects gzip or zlib
|
|
27961
|
+
* from the header, which is exactly `Unzip`. */
|
|
27962
|
+
case "Gunzip":
|
|
27963
|
+
return new Inflate_1({ windowBits: windowBits + 16 });
|
|
27964
|
+
case "Unzip":
|
|
27965
|
+
return new Inflate_1({ windowBits: windowBits + 32 });
|
|
27966
|
+
}
|
|
27967
|
+
}
|
|
27968
|
+
function zlibError(engine) {
|
|
27969
|
+
const codes = { [-2]: "Z_STREAM_ERROR", [-3]: "Z_DATA_ERROR", [-4]: "Z_MEM_ERROR", [-5]: "Z_BUF_ERROR", 2: "Z_NEED_DICT" };
|
|
27970
|
+
return Object.assign(new Error(engine.msg || "zlib error"), { errno: engine.err, code: codes[engine.err] ?? "Z_DATA_ERROR" });
|
|
27971
|
+
}
|
|
27972
|
+
function zlibClass(mode) {
|
|
27973
|
+
const ZlibStream = class extends import_stream_browserify2.default.Transform {
|
|
27974
|
+
bytesWritten = 0;
|
|
27975
|
+
_handle;
|
|
27976
|
+
_engine;
|
|
27977
|
+
_settings;
|
|
27978
|
+
_output = [];
|
|
27979
|
+
_finished = false;
|
|
27980
|
+
constructor(options = {}) {
|
|
27981
|
+
super(options);
|
|
27982
|
+
this._settings = options;
|
|
27983
|
+
this._engine = this._attach(createEngine(mode, options));
|
|
27984
|
+
this._handle = { close: () => {
|
|
27985
|
+
this._handle = null;
|
|
27986
|
+
} };
|
|
27987
|
+
}
|
|
27988
|
+
_attach(engine) {
|
|
27989
|
+
engine.onData = (chunk) => this._output.push(chunk);
|
|
27990
|
+
engine.onEnd = (status) => {
|
|
27991
|
+
const state = engine;
|
|
27992
|
+
if (status !== 0) {
|
|
27993
|
+
state.err = status;
|
|
27994
|
+
state.msg = state.strm?.msg ?? state.msg;
|
|
27995
|
+
}
|
|
27996
|
+
};
|
|
27997
|
+
return engine;
|
|
27998
|
+
}
|
|
27999
|
+
/** Code one chunk now and hand back what it produced. */
|
|
28000
|
+
_processChunk(chunk, flushFlag = Z_NO_FLUSH2, callback) {
|
|
28001
|
+
const input = typeof chunk === "string" ? Buffer2.from(chunk) : chunk;
|
|
28002
|
+
try {
|
|
28003
|
+
const out = this._code(input, flushFlag);
|
|
28004
|
+
if (callback) queueMicrotask(() => callback(null, out));
|
|
28005
|
+
return out;
|
|
28006
|
+
} catch (error) {
|
|
28007
|
+
if (callback) {
|
|
28008
|
+
queueMicrotask(() => callback(error));
|
|
28009
|
+
return Buffer2.alloc(0);
|
|
28010
|
+
}
|
|
28011
|
+
throw error;
|
|
28012
|
+
}
|
|
28013
|
+
}
|
|
28014
|
+
_code(input, flushFlag) {
|
|
28015
|
+
if (this._finished) {
|
|
28016
|
+
return Buffer2.alloc(0);
|
|
28017
|
+
}
|
|
28018
|
+
this.bytesWritten += input.length;
|
|
28019
|
+
const engine = this._engine;
|
|
28020
|
+
if (input.length > 0 || flushFlag !== Z_NO_FLUSH2) {
|
|
28021
|
+
const mapped = flushFlag === Z_FINISH2 ? Z_FINISH2 : flushFlag === Z_FULL_FLUSH2 ? Z_FULL_FLUSH2 : flushFlag === Z_SYNC_FLUSH2 ? Z_SYNC_FLUSH2 : Z_NO_FLUSH2;
|
|
28022
|
+
engine.push(input, mapped);
|
|
28023
|
+
if (engine.err) throw zlibError(engine);
|
|
28024
|
+
}
|
|
28025
|
+
if (engine.ended || flushFlag === Z_FINISH2) this._finished = engine.ended === true || mode.startsWith("Deflate") || mode === "Gzip";
|
|
28026
|
+
const produced = this._output;
|
|
28027
|
+
this._output = [];
|
|
28028
|
+
return produced.length === 1 ? Buffer2.from(produced[0]) : Buffer2.concat(produced.map((part) => Buffer2.from(part)));
|
|
27262
28029
|
}
|
|
27263
28030
|
_transform(chunk, _encoding, next) {
|
|
27264
|
-
|
|
27265
|
-
|
|
28031
|
+
try {
|
|
28032
|
+
const out = this._code(chunk, typeof this._settings.flush === "number" ? this._settings.flush : Z_NO_FLUSH2);
|
|
28033
|
+
if (out.length) this.push(out);
|
|
28034
|
+
next();
|
|
28035
|
+
} catch (error) {
|
|
28036
|
+
next(error);
|
|
28037
|
+
}
|
|
27266
28038
|
}
|
|
27267
28039
|
_flush(next) {
|
|
27268
28040
|
try {
|
|
27269
|
-
this.
|
|
28041
|
+
const finish = typeof this._settings.finishFlush === "number" ? this._settings.finishFlush : Z_FINISH2;
|
|
28042
|
+
const out = this._code(new Uint8Array(0), finish);
|
|
28043
|
+
if (out.length) this.push(out);
|
|
27270
28044
|
next();
|
|
27271
28045
|
} catch (error) {
|
|
27272
28046
|
next(error);
|
|
27273
28047
|
}
|
|
27274
28048
|
}
|
|
28049
|
+
/** `flush([kind], callback)`: emit what is pending without ending the stream. */
|
|
28050
|
+
flush(kind, callback) {
|
|
28051
|
+
const done = typeof kind === "function" ? kind : callback;
|
|
28052
|
+
const flag = typeof kind === "number" ? kind : Z_FULL_FLUSH2;
|
|
28053
|
+
try {
|
|
28054
|
+
const out = this._code(new Uint8Array(0), flag);
|
|
28055
|
+
if (out.length) this.push(out);
|
|
28056
|
+
} catch (error) {
|
|
28057
|
+
this.destroy(error);
|
|
28058
|
+
}
|
|
28059
|
+
if (done) queueMicrotask(done);
|
|
28060
|
+
}
|
|
28061
|
+
reset() {
|
|
28062
|
+
this._engine = this._attach(createEngine(mode, this._settings));
|
|
28063
|
+
this._output = [];
|
|
28064
|
+
this._finished = false;
|
|
28065
|
+
}
|
|
28066
|
+
params(level, strategy, callback) {
|
|
28067
|
+
this._settings.level = level;
|
|
28068
|
+
this._settings.strategy = strategy;
|
|
28069
|
+
if (callback) queueMicrotask(callback);
|
|
28070
|
+
}
|
|
28071
|
+
close(callback) {
|
|
28072
|
+
this._handle?.close();
|
|
28073
|
+
if (callback) this.once("close", callback);
|
|
28074
|
+
if (!this.destroyed) this.destroy();
|
|
28075
|
+
}
|
|
27275
28076
|
};
|
|
27276
|
-
Object.defineProperty(
|
|
27277
|
-
return
|
|
27278
|
-
}
|
|
27279
|
-
var
|
|
27280
|
-
var
|
|
27281
|
-
var
|
|
27282
|
-
var
|
|
27283
|
-
var
|
|
27284
|
-
var
|
|
28077
|
+
Object.defineProperty(ZlibStream, "name", { value: mode });
|
|
28078
|
+
return ZlibStream;
|
|
28079
|
+
}
|
|
28080
|
+
var Gzip = zlibClass("Gzip");
|
|
28081
|
+
var Gunzip = zlibClass("Gunzip");
|
|
28082
|
+
var Deflate2 = zlibClass("Deflate");
|
|
28083
|
+
var Inflate2 = zlibClass("Inflate");
|
|
28084
|
+
var DeflateRaw = zlibClass("DeflateRaw");
|
|
28085
|
+
var InflateRaw = zlibClass("InflateRaw");
|
|
28086
|
+
var Unzip = zlibClass("Unzip");
|
|
28087
|
+
var gzipCodec = codec((input, options) => gzip_1(input, options));
|
|
28088
|
+
var gunzipCodec = codec((input) => ungzip_1(input));
|
|
28089
|
+
var deflateCodec = codec((input, options) => deflate_1(input, options));
|
|
28090
|
+
var inflateCodec = codec((input) => inflate_1(input));
|
|
28091
|
+
var deflateRawCodec = codec((input, options) => deflateRaw_1(input, options));
|
|
28092
|
+
var inflateRawCodec = codec((input) => inflateRaw_1(input));
|
|
27285
28093
|
var unzipCodec = codec(
|
|
27286
|
-
"Unzip",
|
|
27287
28094
|
(input) => input[0] === 31 && input[1] === 139 ? ungzip_1(input) : inflate_1(input)
|
|
27288
28095
|
);
|
|
27289
28096
|
function brotliUnavailable(name) {
|
|
@@ -27294,27 +28101,34 @@ function brotliUnavailable(name) {
|
|
|
27294
28101
|
throw error;
|
|
27295
28102
|
}
|
|
27296
28103
|
var zlibModule = {
|
|
28104
|
+
Gzip,
|
|
28105
|
+
Gunzip,
|
|
28106
|
+
Deflate: Deflate2,
|
|
28107
|
+
Inflate: Inflate2,
|
|
28108
|
+
DeflateRaw,
|
|
28109
|
+
InflateRaw,
|
|
28110
|
+
Unzip,
|
|
27297
28111
|
gzipSync: gzipCodec.sync,
|
|
27298
28112
|
gzip: gzipCodec.async,
|
|
27299
|
-
createGzip: (o2) => new
|
|
28113
|
+
createGzip: (o2) => new Gzip(o2),
|
|
27300
28114
|
gunzipSync: gunzipCodec.sync,
|
|
27301
28115
|
gunzip: gunzipCodec.async,
|
|
27302
|
-
createGunzip: (o2) => new
|
|
28116
|
+
createGunzip: (o2) => new Gunzip(o2),
|
|
27303
28117
|
deflateSync: deflateCodec.sync,
|
|
27304
28118
|
deflate: deflateCodec.async,
|
|
27305
|
-
createDeflate: (o2) => new
|
|
28119
|
+
createDeflate: (o2) => new Deflate2(o2),
|
|
27306
28120
|
inflateSync: inflateCodec.sync,
|
|
27307
28121
|
inflate: inflateCodec.async,
|
|
27308
|
-
createInflate: (o2) => new
|
|
28122
|
+
createInflate: (o2) => new Inflate2(o2),
|
|
27309
28123
|
deflateRawSync: deflateRawCodec.sync,
|
|
27310
28124
|
deflateRaw: deflateRawCodec.async,
|
|
27311
|
-
createDeflateRaw: (o2) => new
|
|
28125
|
+
createDeflateRaw: (o2) => new DeflateRaw(o2),
|
|
27312
28126
|
inflateRawSync: inflateRawCodec.sync,
|
|
27313
28127
|
inflateRaw: inflateRawCodec.async,
|
|
27314
|
-
createInflateRaw: (o2) => new
|
|
28128
|
+
createInflateRaw: (o2) => new InflateRaw(o2),
|
|
27315
28129
|
unzipSync: unzipCodec.sync,
|
|
27316
28130
|
unzip: unzipCodec.async,
|
|
27317
|
-
createUnzip: (o2) => new
|
|
28131
|
+
createUnzip: (o2) => new Unzip(o2),
|
|
27318
28132
|
brotliCompressSync: () => brotliUnavailable("brotliCompressSync"),
|
|
27319
28133
|
brotliDecompressSync: () => brotliUnavailable("brotliDecompressSync"),
|
|
27320
28134
|
brotliCompress: () => brotliUnavailable("brotliCompress"),
|
|
@@ -27415,7 +28229,7 @@ var url_module_default = urlModule;
|
|
|
27415
28229
|
|
|
27416
28230
|
// src/node/virtual-http.ts
|
|
27417
28231
|
var import_events = __toESM(require_events());
|
|
27418
|
-
var
|
|
28232
|
+
var import_stream_browserify3 = __toESM(require_stream_browserify());
|
|
27419
28233
|
|
|
27420
28234
|
// src/net/policy.ts
|
|
27421
28235
|
function isLoopbackHostname(hostname) {
|
|
@@ -27489,7 +28303,8 @@ function policedWebSocket(Native, policy) {
|
|
|
27489
28303
|
}
|
|
27490
28304
|
|
|
27491
28305
|
// src/node/virtual-http.ts
|
|
27492
|
-
|
|
28306
|
+
installStreamCompat();
|
|
28307
|
+
var VirtualIncomingMessage = class extends import_stream_browserify3.default.Readable {
|
|
27493
28308
|
method;
|
|
27494
28309
|
url;
|
|
27495
28310
|
headers;
|
|
@@ -27529,7 +28344,7 @@ var VirtualIncomingMessage = class extends import_stream_browserify2.default.Rea
|
|
|
27529
28344
|
return this;
|
|
27530
28345
|
}
|
|
27531
28346
|
};
|
|
27532
|
-
var VirtualServerResponse = class extends
|
|
28347
|
+
var VirtualServerResponse = class extends import_stream_browserify3.default.Writable {
|
|
27533
28348
|
statusCode = 200;
|
|
27534
28349
|
statusMessage = "OK";
|
|
27535
28350
|
headersSent = false;
|
|
@@ -27555,16 +28370,38 @@ var VirtualServerResponse = class extends import_stream_browserify2.default.Writ
|
|
|
27555
28370
|
}
|
|
27556
28371
|
_final(callback) {
|
|
27557
28372
|
this.headersSent = true;
|
|
28373
|
+
this.settle();
|
|
28374
|
+
this.once("finish", () => queueMicrotask(() => {
|
|
28375
|
+
if (!this.destroyed) this.destroy();
|
|
28376
|
+
}));
|
|
28377
|
+
callback();
|
|
28378
|
+
}
|
|
28379
|
+
/*
|
|
28380
|
+
* A destroyed response still answers.
|
|
28381
|
+
*
|
|
28382
|
+
* Node sends whatever was written and closes the socket; the caller sees a
|
|
28383
|
+
* response, however short. Here the caller is waiting on `completed`, which
|
|
28384
|
+
* only `_final` used to settle — so a response torn down before `end()`
|
|
28385
|
+
* (an aborted stream, `res.destroy(err)` from a web-stream pipe) left the
|
|
28386
|
+
* request unanswered forever while the server had already moved on.
|
|
28387
|
+
*/
|
|
28388
|
+
_destroy(error, callback) {
|
|
28389
|
+
this.settle();
|
|
28390
|
+
callback(error);
|
|
28391
|
+
}
|
|
28392
|
+
settled = false;
|
|
28393
|
+
settle() {
|
|
28394
|
+
if (this.settled) return;
|
|
28395
|
+
this.settled = true;
|
|
27558
28396
|
if (this.sendDate && !this.hasHeader("date")) this.setHeader("Date", (/* @__PURE__ */ new Date()).toUTCString());
|
|
27559
28397
|
const headers = {};
|
|
27560
|
-
for (const {
|
|
28398
|
+
for (const [key, { value }] of this.headers) headers[key] = Array.isArray(value) ? value.join(", ") : value;
|
|
27561
28399
|
this.resolve({
|
|
27562
28400
|
statusCode: this.statusCode,
|
|
27563
28401
|
statusMessage: this.statusMessage || STATUS_CODES[this.statusCode] || "",
|
|
27564
28402
|
headers,
|
|
27565
28403
|
body: new Uint8Array(Buffer2.concat(this.chunks))
|
|
27566
28404
|
});
|
|
27567
|
-
callback();
|
|
27568
28405
|
}
|
|
27569
28406
|
setHeader(name, value) {
|
|
27570
28407
|
validateHeaderName(name);
|
|
@@ -27573,9 +28410,9 @@ var VirtualServerResponse = class extends import_stream_browserify2.default.Writ
|
|
|
27573
28410
|
return this;
|
|
27574
28411
|
}
|
|
27575
28412
|
appendHeader(name, value) {
|
|
27576
|
-
const
|
|
28413
|
+
const current3 = this.getHeader(name);
|
|
27577
28414
|
const next = Array.isArray(value) ? [...value] : [String(value)];
|
|
27578
|
-
return this.setHeader(name,
|
|
28415
|
+
return this.setHeader(name, current3 === void 0 ? next : [...Array.isArray(current3) ? current3 : [String(current3)], ...next]);
|
|
27579
28416
|
}
|
|
27580
28417
|
getHeader(name) {
|
|
27581
28418
|
return this.headers.get(name.toLowerCase())?.value;
|
|
@@ -27603,6 +28440,25 @@ var VirtualServerResponse = class extends import_stream_browserify2.default.Writ
|
|
|
27603
28440
|
flushHeaders() {
|
|
27604
28441
|
this.headersSent = true;
|
|
27605
28442
|
}
|
|
28443
|
+
/*
|
|
28444
|
+
* Node's `OutgoingMessage` internals that middleware reaches past the public
|
|
28445
|
+
* API for. `compression` — which Next's dev server wraps every response in —
|
|
28446
|
+
* calls `_implicitHeader()` from its own `write`/`end` to commit the status
|
|
28447
|
+
* line before the first byte, the way Node's `write` does internally.
|
|
28448
|
+
*/
|
|
28449
|
+
_implicitHeader() {
|
|
28450
|
+
if (!this.headersSent) this.writeHead(this.statusCode);
|
|
28451
|
+
}
|
|
28452
|
+
get _header() {
|
|
28453
|
+
return this.headersSent ? `HTTP/1.1 ${this.statusCode} ${this.statusMessage}\r
|
|
28454
|
+
` : null;
|
|
28455
|
+
}
|
|
28456
|
+
get finished() {
|
|
28457
|
+
return this.writableEnded;
|
|
28458
|
+
}
|
|
28459
|
+
chunkedEncoding = false;
|
|
28460
|
+
useChunkedEncodingByDefault = true;
|
|
28461
|
+
strictContentLength = false;
|
|
27606
28462
|
writeContinue() {
|
|
27607
28463
|
}
|
|
27608
28464
|
writeProcessing() {
|
|
@@ -27614,7 +28470,7 @@ var VirtualServerResponse = class extends import_stream_browserify2.default.Writ
|
|
|
27614
28470
|
return this;
|
|
27615
28471
|
}
|
|
27616
28472
|
};
|
|
27617
|
-
var VirtualSocket = class extends
|
|
28473
|
+
var VirtualSocket = class extends import_stream_browserify3.default.Duplex {
|
|
27618
28474
|
remoteAddress = "127.0.0.1";
|
|
27619
28475
|
remotePort = 0;
|
|
27620
28476
|
localAddress = "127.0.0.1";
|
|
@@ -27819,7 +28675,7 @@ var VirtualHttpRouter = class {
|
|
|
27819
28675
|
};
|
|
27820
28676
|
}
|
|
27821
28677
|
};
|
|
27822
|
-
var VirtualClientResponse = class extends
|
|
28678
|
+
var VirtualClientResponse = class extends import_stream_browserify3.default.Readable {
|
|
27823
28679
|
constructor(statusCode, statusMessage, headers, body) {
|
|
27824
28680
|
super();
|
|
27825
28681
|
this.statusCode = statusCode;
|
|
@@ -27886,7 +28742,7 @@ function resolveTarget(input, overrides, defaultProtocol) {
|
|
|
27886
28742
|
function isLoopback(hostname) {
|
|
27887
28743
|
return isLoopbackHostname(hostname);
|
|
27888
28744
|
}
|
|
27889
|
-
var VirtualClientRequest = class extends
|
|
28745
|
+
var VirtualClientRequest = class extends import_stream_browserify3.default.Writable {
|
|
27890
28746
|
constructor(target, router, fetchImpl, trackRequest, loopback = void 0) {
|
|
27891
28747
|
super();
|
|
27892
28748
|
this.target = target;
|
|
@@ -28116,6 +28972,7 @@ function createVirtualFetch(router, options = {}) {
|
|
|
28116
28972
|
const request = new Request(input, init);
|
|
28117
28973
|
const url = new URL(request.url);
|
|
28118
28974
|
const release = options.trackRequest?.();
|
|
28975
|
+
let handedOff = false;
|
|
28119
28976
|
try {
|
|
28120
28977
|
if (!isLoopback(url.hostname)) {
|
|
28121
28978
|
if (!options.fetch) {
|
|
@@ -28123,7 +28980,10 @@ function createVirtualFetch(router, options = {}) {
|
|
|
28123
28980
|
cause: Object.assign(new Error(`getaddrinfo ENOTFOUND ${url.hostname}`), { code: "ENOTFOUND" })
|
|
28124
28981
|
});
|
|
28125
28982
|
}
|
|
28126
|
-
|
|
28983
|
+
const response = await options.fetch(request);
|
|
28984
|
+
if (!release || !response.body) return response;
|
|
28985
|
+
handedOff = true;
|
|
28986
|
+
return releaseWhenConsumed(response, release);
|
|
28127
28987
|
}
|
|
28128
28988
|
const port = Number(url.port || (url.protocol === "https:" ? 443 : 80));
|
|
28129
28989
|
const headers = {};
|
|
@@ -28163,10 +29023,44 @@ function createVirtualFetch(router, options = {}) {
|
|
|
28163
29023
|
headers: responseHeaders
|
|
28164
29024
|
});
|
|
28165
29025
|
} finally {
|
|
28166
|
-
release?.();
|
|
29026
|
+
if (!handedOff) release?.();
|
|
28167
29027
|
}
|
|
28168
29028
|
});
|
|
28169
29029
|
}
|
|
29030
|
+
function releaseWhenConsumed(response, release) {
|
|
29031
|
+
let released = false;
|
|
29032
|
+
const once = () => {
|
|
29033
|
+
if (!released) {
|
|
29034
|
+
released = true;
|
|
29035
|
+
release();
|
|
29036
|
+
}
|
|
29037
|
+
};
|
|
29038
|
+
const reader = response.body.getReader();
|
|
29039
|
+
const body = new ReadableStream({
|
|
29040
|
+
async pull(controller) {
|
|
29041
|
+
try {
|
|
29042
|
+
const { done, value } = await reader.read();
|
|
29043
|
+
if (done) {
|
|
29044
|
+
controller.close();
|
|
29045
|
+
once();
|
|
29046
|
+
return;
|
|
29047
|
+
}
|
|
29048
|
+
controller.enqueue(value);
|
|
29049
|
+
} catch (error) {
|
|
29050
|
+
controller.error(error);
|
|
29051
|
+
once();
|
|
29052
|
+
}
|
|
29053
|
+
},
|
|
29054
|
+
cancel(reason) {
|
|
29055
|
+
once();
|
|
29056
|
+
return reader.cancel(reason);
|
|
29057
|
+
}
|
|
29058
|
+
});
|
|
29059
|
+
const wrapped = new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
29060
|
+
Object.defineProperty(wrapped, "url", { value: response.url });
|
|
29061
|
+
Object.defineProperty(wrapped, "redirected", { value: response.redirected });
|
|
29062
|
+
return wrapped;
|
|
29063
|
+
}
|
|
28170
29064
|
function validateHeaderName(name) {
|
|
28171
29065
|
if (!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(name)) throw Object.assign(new TypeError(`Header name must be a valid HTTP token [${name}]`), { code: "ERR_INVALID_HTTP_TOKEN" });
|
|
28172
29066
|
}
|
|
@@ -28260,12 +29154,12 @@ function invoke(host, fn, context, timeout) {
|
|
|
28260
29154
|
function createMockTracker() {
|
|
28261
29155
|
const restorers = [];
|
|
28262
29156
|
const fn = (original = () => void 0, implementation = original) => {
|
|
28263
|
-
let
|
|
29157
|
+
let current3 = implementation;
|
|
28264
29158
|
const once = /* @__PURE__ */ new Map();
|
|
28265
29159
|
const calls = [];
|
|
28266
29160
|
const mocked = function(...args) {
|
|
28267
29161
|
const index = calls.length;
|
|
28268
|
-
const chosen = once.get(index) ??
|
|
29162
|
+
const chosen = once.get(index) ?? current3;
|
|
28269
29163
|
once.delete(index);
|
|
28270
29164
|
const call = { arguments: args, result: void 0, error: void 0, this: this };
|
|
28271
29165
|
calls.push(call);
|
|
@@ -28285,13 +29179,13 @@ function createMockTracker() {
|
|
|
28285
29179
|
calls.length = 0;
|
|
28286
29180
|
},
|
|
28287
29181
|
mockImplementation: (next) => {
|
|
28288
|
-
|
|
29182
|
+
current3 = next;
|
|
28289
29183
|
},
|
|
28290
29184
|
mockImplementationOnce: (next, onCall) => {
|
|
28291
29185
|
once.set(onCall ?? calls.length, next);
|
|
28292
29186
|
},
|
|
28293
29187
|
restore: () => {
|
|
28294
|
-
|
|
29188
|
+
current3 = original;
|
|
28295
29189
|
}
|
|
28296
29190
|
}
|
|
28297
29191
|
});
|
|
@@ -28304,21 +29198,21 @@ function createMockTracker() {
|
|
|
28304
29198
|
}
|
|
28305
29199
|
const mocked = fn(original, implementation ?? original);
|
|
28306
29200
|
object[name] = mocked;
|
|
28307
|
-
const
|
|
29201
|
+
const restore2 = () => {
|
|
28308
29202
|
object[name] = original;
|
|
28309
29203
|
};
|
|
28310
|
-
mocked.mock.restore =
|
|
28311
|
-
restorers.push(
|
|
29204
|
+
mocked.mock.restore = restore2;
|
|
29205
|
+
restorers.push(restore2);
|
|
28312
29206
|
return mocked;
|
|
28313
29207
|
};
|
|
28314
29208
|
return {
|
|
28315
29209
|
fn,
|
|
28316
29210
|
method,
|
|
28317
29211
|
reset: () => {
|
|
28318
|
-
for (const
|
|
29212
|
+
for (const restore2 of restorers.splice(0)) restore2();
|
|
28319
29213
|
},
|
|
28320
29214
|
restoreAll: () => {
|
|
28321
|
-
for (const
|
|
29215
|
+
for (const restore2 of restorers.splice(0)) restore2();
|
|
28322
29216
|
}
|
|
28323
29217
|
};
|
|
28324
29218
|
}
|
|
@@ -29806,25 +30700,25 @@ var SyncChannelClient = class {
|
|
|
29806
30700
|
waitWhile(state) {
|
|
29807
30701
|
for (; ; ) {
|
|
29808
30702
|
Atomics.wait(this.control, STATE, state, WAIT_SLICE_MS);
|
|
29809
|
-
const
|
|
29810
|
-
if (
|
|
30703
|
+
const current3 = Atomics.load(this.control, STATE);
|
|
30704
|
+
if (current3 !== state) return current3;
|
|
29811
30705
|
}
|
|
29812
30706
|
}
|
|
29813
30707
|
};
|
|
29814
30708
|
|
|
29815
30709
|
// src/node/child-process-module.ts
|
|
29816
30710
|
var import_events2 = __toESM(require_events());
|
|
29817
|
-
var
|
|
30711
|
+
var import_stream_browserify4 = __toESM(require_stream_browserify());
|
|
29818
30712
|
var ChildProcess = class extends import_events2.default {
|
|
29819
30713
|
constructor(handle, file, args, referenceChanged = () => {
|
|
29820
|
-
}) {
|
|
30714
|
+
}, extraPipes = []) {
|
|
29821
30715
|
super();
|
|
29822
30716
|
this.referenceChanged = referenceChanged;
|
|
29823
30717
|
this.handle = handle;
|
|
29824
30718
|
this.pid = handle.pid;
|
|
29825
30719
|
this.spawnfile = file;
|
|
29826
30720
|
this.spawnargs = [file, ...args];
|
|
29827
|
-
this.stdin = new
|
|
30721
|
+
this.stdin = new import_stream_browserify4.default.Writable({
|
|
29828
30722
|
write: (chunk, _encoding, done) => {
|
|
29829
30723
|
try {
|
|
29830
30724
|
handle.sendStdin(typeof chunk === "string" ? chunk : Buffer2.from(chunk).toString("utf8"));
|
|
@@ -29841,6 +30735,11 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29841
30735
|
}
|
|
29842
30736
|
});
|
|
29843
30737
|
this.stdio = [this.stdin, this.stdout, this.stderr];
|
|
30738
|
+
for (const fd of extraPipes) this.stdio[fd] = this.extraPipe(fd);
|
|
30739
|
+
handle.on("fd", (event) => {
|
|
30740
|
+
const pipe = this.stdio[event.fd];
|
|
30741
|
+
pipe?.push(Buffer2.from(event.text));
|
|
30742
|
+
});
|
|
29844
30743
|
handle.on("stdout", (text) => this.stdout.write(text));
|
|
29845
30744
|
handle.on("stderr", (text) => this.stderr.write(text));
|
|
29846
30745
|
handle.on("exit", (code) => this.finish(code));
|
|
@@ -29853,8 +30752,8 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29853
30752
|
}
|
|
29854
30753
|
}
|
|
29855
30754
|
referenceChanged;
|
|
29856
|
-
stdout = new
|
|
29857
|
-
stderr = new
|
|
30755
|
+
stdout = new import_stream_browserify4.default.PassThrough();
|
|
30756
|
+
stderr = new import_stream_browserify4.default.PassThrough();
|
|
29858
30757
|
stdin;
|
|
29859
30758
|
stdio;
|
|
29860
30759
|
pid;
|
|
@@ -29866,6 +30765,35 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29866
30765
|
handle;
|
|
29867
30766
|
settled = false;
|
|
29868
30767
|
referenced = true;
|
|
30768
|
+
/**
|
|
30769
|
+
* The parent's end of `stdio[fd] = "pipe"` for a descriptor above 2.
|
|
30770
|
+
*
|
|
30771
|
+
* One Duplex per descriptor, as Node gives: what the parent writes reaches
|
|
30772
|
+
* the child's `fd`, and what the child writes there is readable here. Chunks
|
|
30773
|
+
* are Buffers because the DevTools pipe is framed by NUL bytes and its reader
|
|
30774
|
+
* searches the chunk with `indexOf("\0")`.
|
|
30775
|
+
*/
|
|
30776
|
+
extraPipe(fd) {
|
|
30777
|
+
const handle = this.handle;
|
|
30778
|
+
return new import_stream_browserify4.default.Duplex({
|
|
30779
|
+
read() {
|
|
30780
|
+
},
|
|
30781
|
+
write(chunk, _encoding, done) {
|
|
30782
|
+
try {
|
|
30783
|
+
handle.writeFd?.(fd, typeof chunk === "string" ? chunk : Buffer2.from(chunk).toString("utf8"));
|
|
30784
|
+
} catch {
|
|
30785
|
+
}
|
|
30786
|
+
done();
|
|
30787
|
+
},
|
|
30788
|
+
final(done) {
|
|
30789
|
+
try {
|
|
30790
|
+
handle.endFd?.(fd);
|
|
30791
|
+
} catch {
|
|
30792
|
+
}
|
|
30793
|
+
done();
|
|
30794
|
+
}
|
|
30795
|
+
});
|
|
30796
|
+
}
|
|
29869
30797
|
kill(signal = "SIGTERM") {
|
|
29870
30798
|
this.killed = true;
|
|
29871
30799
|
this.handle.kill(typeof signal === "number" ? "SIGTERM" : signal);
|
|
@@ -29932,6 +30860,14 @@ var ChildProcess = class extends import_events2.default {
|
|
|
29932
30860
|
this.exitCode = code;
|
|
29933
30861
|
this.stdout.end();
|
|
29934
30862
|
this.stderr.end();
|
|
30863
|
+
for (const pipe of this.stdio.slice(3)) {
|
|
30864
|
+
if (!pipe) continue;
|
|
30865
|
+
pipe.once("end", () => pipe.destroy());
|
|
30866
|
+
pipe.push(null);
|
|
30867
|
+
if (!pipe.readableFlowing) queueMicrotask(() => {
|
|
30868
|
+
if (!pipe.readableFlowing) pipe.destroy();
|
|
30869
|
+
});
|
|
30870
|
+
}
|
|
29935
30871
|
this.emit("exit", code, null);
|
|
29936
30872
|
queueMicrotask(() => this.emit("close", code, null));
|
|
29937
30873
|
}
|
|
@@ -29948,18 +30884,21 @@ function createChildProcessModule(spawnChild, defaultCwd, syncSpawn, defaultEnv
|
|
|
29948
30884
|
return Array.isArray(stdio) && stdio[0] === "ignore";
|
|
29949
30885
|
};
|
|
29950
30886
|
const wantsChannel = (options) => Array.isArray(options.stdio) && options.stdio.includes("ipc");
|
|
30887
|
+
const extraPipesOf = (options) => Array.isArray(options.stdio) ? options.stdio.flatMap((entry, fd) => fd > 2 && (entry === "pipe" || entry === "overlapped") ? [fd] : []) : [];
|
|
29951
30888
|
const start = (file, args, options) => {
|
|
29952
30889
|
const resolved = options.shell ? throughShell([file, ...args].join(" "), options) : { file, args };
|
|
29953
30890
|
const channelId = wantsChannel(options) && lifecycle.ipc ? newIpcChannelId() : void 0;
|
|
30891
|
+
const extraPipes = extraPipesOf(options);
|
|
29954
30892
|
const handle = spawnChild({
|
|
29955
30893
|
command: resolved.file,
|
|
29956
30894
|
args: resolved.args,
|
|
29957
30895
|
cwd: options.cwd ?? defaultCwd(),
|
|
29958
30896
|
env: channelId ? { ...environmentFor(options), [IPC_CHANNEL_ENV]: channelId } : environmentFor(options),
|
|
29959
30897
|
...options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[0] === "inherit" ? { inheritStdio: true } : {},
|
|
29960
|
-
...stdinIgnored(options) ? { stdinIgnored: true } : {}
|
|
30898
|
+
...stdinIgnored(options) ? { stdinIgnored: true } : {},
|
|
30899
|
+
...extraPipes.length ? { extraPipes } : {}
|
|
29961
30900
|
});
|
|
29962
|
-
const child = new ChildProcess(handle, resolved.file, resolved.args, lifecycle.referenceChanged);
|
|
30901
|
+
const child = new ChildProcess(handle, resolved.file, resolved.args, lifecycle.referenceChanged, extraPipes);
|
|
29963
30902
|
if (channelId && lifecycle.ipc) child.attachChannel(lifecycle.ipc, channelId);
|
|
29964
30903
|
const inherited = (index) => options.stdio === "inherit" || Array.isArray(options.stdio) && options.stdio[index] === "inherit";
|
|
29965
30904
|
if (inherited(1)) child.stdout.on("data", (chunk) => lifecycle.stdout?.(chunk.toString()));
|
|
@@ -30545,7 +31484,8 @@ var KERNEL_RELEASE = "5.10.0";
|
|
|
30545
31484
|
var KERNEL_VERSION = `Linux version ${KERNEL_RELEASE} (sandboxedjs@sandbox) (gcc version 12.2.0) #1 SMP PREEMPT_DYNAMIC`;
|
|
30546
31485
|
|
|
30547
31486
|
// src/node/core-modules.ts
|
|
30548
|
-
|
|
31487
|
+
installStreamCompat();
|
|
31488
|
+
installReadableFrom(import_stream_browserify5.default);
|
|
30549
31489
|
var Dirent = class {
|
|
30550
31490
|
/** Node 20+ exposes the containing directory, and `fs.glob` consumers read it. */
|
|
30551
31491
|
constructor(name, stat, parentPath = "") {
|
|
@@ -30730,7 +31670,7 @@ function createCoreModules(options) {
|
|
|
30730
31670
|
if (typeof fn !== "function") {
|
|
30731
31671
|
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
30732
31672
|
}
|
|
30733
|
-
tickQueue.push([fn, args]);
|
|
31673
|
+
tickQueue.push([bindToCurrent(fn), args]);
|
|
30734
31674
|
if (!tickDrainScheduled) {
|
|
30735
31675
|
tickDrainScheduled = true;
|
|
30736
31676
|
afterMicrotasks(runTicks);
|
|
@@ -30802,15 +31742,16 @@ function createCoreModules(options) {
|
|
|
30802
31742
|
}
|
|
30803
31743
|
};
|
|
30804
31744
|
const defer = (fn) => {
|
|
31745
|
+
const bound = bindToCurrent(fn);
|
|
30805
31746
|
queueMicrotask(() => {
|
|
30806
31747
|
try {
|
|
30807
|
-
|
|
31748
|
+
bound();
|
|
30808
31749
|
} catch (error) {
|
|
30809
31750
|
reportUncaught(error);
|
|
30810
31751
|
}
|
|
30811
31752
|
});
|
|
30812
31753
|
};
|
|
30813
|
-
const stdin = options.interactiveStdin ? new
|
|
31754
|
+
const stdin = options.interactiveStdin ? new import_stream_browserify5.default.PassThrough() : new import_stream_browserify5.default.Readable({ read() {
|
|
30814
31755
|
this.push(null);
|
|
30815
31756
|
} });
|
|
30816
31757
|
Object.assign(stdin, {
|
|
@@ -30953,7 +31894,7 @@ function createCoreModules(options) {
|
|
|
30953
31894
|
const builtins = {
|
|
30954
31895
|
assert: assert_module_default,
|
|
30955
31896
|
"assert/strict": assert_module_default.strict ?? assert_module_default,
|
|
30956
|
-
buffer:
|
|
31897
|
+
buffer: createBufferBuiltin(),
|
|
30957
31898
|
async_hooks: asyncHooks,
|
|
30958
31899
|
child_process: childProcess,
|
|
30959
31900
|
console: consoleObject,
|
|
@@ -30977,7 +31918,7 @@ function createCoreModules(options) {
|
|
|
30977
31918
|
querystring: import_querystring_es3.default,
|
|
30978
31919
|
readline,
|
|
30979
31920
|
"readline/promises": readline.promises,
|
|
30980
|
-
stream:
|
|
31921
|
+
stream: import_stream_browserify5.default,
|
|
30981
31922
|
"stream/web": Object.fromEntries([
|
|
30982
31923
|
"ReadableStream",
|
|
30983
31924
|
"ReadableStreamDefaultReader",
|
|
@@ -31001,7 +31942,7 @@ function createCoreModules(options) {
|
|
|
31001
31942
|
string_decoder: import_string_decoder.default,
|
|
31002
31943
|
timers: { ...import_timers_browserify.default, ...timers.api },
|
|
31003
31944
|
"timers/promises": createTimerPromises(timers.api),
|
|
31004
|
-
tty: { isatty: () => false, ReadStream:
|
|
31945
|
+
tty: { isatty: () => false, ReadStream: import_stream_browserify5.default.Readable, WriteStream: import_stream_browserify5.default.Writable },
|
|
31005
31946
|
url: url_module_default,
|
|
31006
31947
|
util: util_module_default,
|
|
31007
31948
|
"util/types": util_module_default.types ?? {},
|
|
@@ -31039,6 +31980,7 @@ function createCoreModules(options) {
|
|
|
31039
31980
|
isMarkedAsUntransferable: () => false
|
|
31040
31981
|
};
|
|
31041
31982
|
builtins.net = createNetModule();
|
|
31983
|
+
builtins.vm = vm_module_default;
|
|
31042
31984
|
builtins.inspector = createUnsupportedModule("inspector", {
|
|
31043
31985
|
url: () => void 0,
|
|
31044
31986
|
close: () => {
|
|
@@ -31084,13 +32026,16 @@ function createCoreModules(options) {
|
|
|
31084
32026
|
console: consoleObject,
|
|
31085
32027
|
process: processObject,
|
|
31086
32028
|
...timers.api,
|
|
31087
|
-
queueMicrotask: (fn) =>
|
|
31088
|
-
|
|
31089
|
-
|
|
31090
|
-
|
|
31091
|
-
|
|
31092
|
-
|
|
31093
|
-
|
|
32029
|
+
queueMicrotask: (fn) => {
|
|
32030
|
+
const bound = bindToCurrent(fn);
|
|
32031
|
+
queueMicrotask(() => {
|
|
32032
|
+
try {
|
|
32033
|
+
bound();
|
|
32034
|
+
} catch (error) {
|
|
32035
|
+
reportUncaught(error);
|
|
32036
|
+
}
|
|
32037
|
+
});
|
|
32038
|
+
}
|
|
31094
32039
|
};
|
|
31095
32040
|
if (options.http) {
|
|
31096
32041
|
globals.fetch = createVirtualFetch(options.http.router, {
|
|
@@ -31135,7 +32080,7 @@ function createCoreModules(options) {
|
|
|
31135
32080
|
},
|
|
31136
32081
|
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
31137
32082
|
writeStdin: (data2) => {
|
|
31138
|
-
if (options.interactiveStdin) stdin.write(data2);
|
|
32083
|
+
if (options.interactiveStdin) stdin.write(typeof data2 === "string" ? data2 : Buffer2.from(data2));
|
|
31139
32084
|
},
|
|
31140
32085
|
endStdin: () => {
|
|
31141
32086
|
if (options.interactiveStdin) stdin.end();
|
|
@@ -31358,10 +32303,27 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
31358
32303
|
},
|
|
31359
32304
|
writeSync: (fd, data2, offset2, length, position) => {
|
|
31360
32305
|
const file = requiredFd(fds, fd);
|
|
32306
|
+
if (typeof data2 === "string") {
|
|
32307
|
+
const stringPosition = typeof offset2 === "number" ? offset2 : null;
|
|
32308
|
+
const encoding = typeof length === "string" ? length : "utf8";
|
|
32309
|
+
data2 = Buffer2.from(data2, encoding);
|
|
32310
|
+
position = stringPosition;
|
|
32311
|
+
offset2 = 0;
|
|
32312
|
+
length = data2.length;
|
|
32313
|
+
}
|
|
31361
32314
|
const input = bytes2(data2);
|
|
31362
|
-
const chunk =
|
|
32315
|
+
const chunk = input.subarray(offset2 ?? 0, (offset2 ?? 0) + (length ?? input.length));
|
|
32316
|
+
const size = volume.lstatSync(file.path).size;
|
|
32317
|
+
const append = file.flags.startsWith("a") || (position ?? file.position) >= size;
|
|
32318
|
+
if (append) {
|
|
32319
|
+
const at2 = file.flags.startsWith("a") ? size : position ?? file.position;
|
|
32320
|
+
if (at2 > size) volume.appendFileSync(file.path, new Uint8Array(at2 - size));
|
|
32321
|
+
volume.appendFileSync(file.path, chunk);
|
|
32322
|
+
if (position == null) file.position = at2 + chunk.length;
|
|
32323
|
+
return chunk.length;
|
|
32324
|
+
}
|
|
31363
32325
|
const old = volume.readFileSync(file.path);
|
|
31364
|
-
const start =
|
|
32326
|
+
const start = position ?? file.position;
|
|
31365
32327
|
const next = new Uint8Array(Math.max(old.length, start + chunk.length));
|
|
31366
32328
|
next.set(old);
|
|
31367
32329
|
next.set(chunk, start);
|
|
@@ -31369,35 +32331,10 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
31369
32331
|
if (position == null) file.position = start + chunk.length;
|
|
31370
32332
|
return chunk.length;
|
|
31371
32333
|
},
|
|
31372
|
-
|
|
31373
|
-
|
|
31374
|
-
|
|
31375
|
-
|
|
31376
|
-
const start = settings.start ?? 0;
|
|
31377
|
-
const end = settings.end === void 0 ? whole.length : Math.min(settings.end + 1, whole.length);
|
|
31378
|
-
const slice = whole.subarray(start, Math.max(start, end));
|
|
31379
|
-
const stream = import_stream_browserify4.default.Readable.from([settings.encoding ? slice.toString(settings.encoding) : slice]);
|
|
31380
|
-
Object.assign(stream, { path: target, bytesRead: slice.length, close: () => stream.destroy() });
|
|
31381
|
-
defer(() => {
|
|
31382
|
-
stream.emit("open", 0);
|
|
31383
|
-
stream.emit("ready");
|
|
31384
|
-
});
|
|
31385
|
-
return stream;
|
|
31386
|
-
},
|
|
31387
|
-
createWriteStream: (path, options) => {
|
|
31388
|
-
const target = abs(path);
|
|
31389
|
-
let first = true;
|
|
31390
|
-
return new import_stream_browserify4.default.Writable({ write(chunk, _encoding, done) {
|
|
31391
|
-
try {
|
|
31392
|
-
if (options?.flags?.startsWith("a") || !first) volume.appendFileSync(target, new Uint8Array(chunk));
|
|
31393
|
-
else volume.writeFileSync(target, new Uint8Array(chunk));
|
|
31394
|
-
first = false;
|
|
31395
|
-
done();
|
|
31396
|
-
} catch (error) {
|
|
31397
|
-
done(error);
|
|
31398
|
-
}
|
|
31399
|
-
} });
|
|
31400
|
-
},
|
|
32334
|
+
/* Looked up on `fs` at call time, so a package that replaces
|
|
32335
|
+
* `fs.ReadStream`/`fs.WriteStream` — graceful-fs does — is honoured. */
|
|
32336
|
+
createReadStream: (path, options) => new fs.ReadStream(path, options),
|
|
32337
|
+
createWriteStream: (path, options) => new fs.WriteStream(path, options),
|
|
31401
32338
|
watch: () => new FsWatcher(),
|
|
31402
32339
|
watchFile: () => {
|
|
31403
32340
|
},
|
|
@@ -31451,6 +32388,264 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
31451
32388
|
};
|
|
31452
32389
|
}
|
|
31453
32390
|
fs.realpath.native = fs.realpath;
|
|
32391
|
+
const streamSettings = (options) => typeof options === "string" ? { encoding: options } : options ?? {};
|
|
32392
|
+
function WriteStream(path, options) {
|
|
32393
|
+
const self2 = this;
|
|
32394
|
+
if (!Object.prototype.isPrototypeOf.call(WriteStream.prototype, self2)) return new WriteStream(path, options);
|
|
32395
|
+
const settings = streamSettings(options);
|
|
32396
|
+
import_stream_browserify5.default.Writable.call(self2, { highWaterMark: settings.highWaterMark, emitClose: true });
|
|
32397
|
+
self2.path = abs(path);
|
|
32398
|
+
self2.flags = settings.flags ?? "w";
|
|
32399
|
+
self2.mode = settings.mode ?? 438;
|
|
32400
|
+
self2.fd = typeof settings.fd === "number" ? settings.fd : null;
|
|
32401
|
+
self2.bytesWritten = 0;
|
|
32402
|
+
self2.pending = true;
|
|
32403
|
+
self2._opened = self2.fd !== null;
|
|
32404
|
+
self2.once("open", () => {
|
|
32405
|
+
self2._opened = true;
|
|
32406
|
+
self2.pending = false;
|
|
32407
|
+
});
|
|
32408
|
+
self2.once("finish", () => {
|
|
32409
|
+
if (!self2.destroyed) self2.destroy();
|
|
32410
|
+
});
|
|
32411
|
+
if (self2.fd === null) self2.open();
|
|
32412
|
+
else defer(() => {
|
|
32413
|
+
self2.emit("open", self2.fd);
|
|
32414
|
+
self2.emit("ready");
|
|
32415
|
+
});
|
|
32416
|
+
}
|
|
32417
|
+
WriteStream.prototype = Object.create(import_stream_browserify5.default.Writable.prototype, {
|
|
32418
|
+
constructor: { value: WriteStream, writable: true, configurable: true }
|
|
32419
|
+
});
|
|
32420
|
+
WriteStream.prototype.open = function() {
|
|
32421
|
+
const self2 = this;
|
|
32422
|
+
try {
|
|
32423
|
+
if (String(self2.flags).startsWith("a")) {
|
|
32424
|
+
if (!fs.existsSync(self2.path)) volume.writeFileSync(self2.path, new Uint8Array());
|
|
32425
|
+
} else volume.writeFileSync(self2.path, new Uint8Array());
|
|
32426
|
+
} catch (error) {
|
|
32427
|
+
defer(() => self2.destroy(error));
|
|
32428
|
+
return;
|
|
32429
|
+
}
|
|
32430
|
+
defer(() => {
|
|
32431
|
+
self2.emit("open", 0);
|
|
32432
|
+
self2.emit("ready");
|
|
32433
|
+
});
|
|
32434
|
+
};
|
|
32435
|
+
WriteStream.prototype._write = function(chunk, encoding, done) {
|
|
32436
|
+
const self2 = this;
|
|
32437
|
+
const append = () => {
|
|
32438
|
+
try {
|
|
32439
|
+
const bytes3 = typeof chunk === "string" ? Buffer2.from(chunk, encoding) : chunk;
|
|
32440
|
+
volume.appendFileSync(self2.path, new Uint8Array(bytes3));
|
|
32441
|
+
self2.bytesWritten += bytes3.length;
|
|
32442
|
+
done();
|
|
32443
|
+
} catch (error) {
|
|
32444
|
+
done(error);
|
|
32445
|
+
}
|
|
32446
|
+
};
|
|
32447
|
+
if (self2._opened) append();
|
|
32448
|
+
else self2.once("open", append);
|
|
32449
|
+
};
|
|
32450
|
+
WriteStream.prototype.close = function(callback2) {
|
|
32451
|
+
const self2 = this;
|
|
32452
|
+
if (callback2) {
|
|
32453
|
+
if (self2.closed) defer(() => callback2(null));
|
|
32454
|
+
else {
|
|
32455
|
+
self2.once("close", () => callback2(null));
|
|
32456
|
+
self2.once("error", (error) => callback2(error));
|
|
32457
|
+
}
|
|
32458
|
+
}
|
|
32459
|
+
if (!self2.writableEnded) self2.end();
|
|
32460
|
+
else if (!self2.destroyed) self2.destroy();
|
|
32461
|
+
};
|
|
32462
|
+
function ReadStream(path, options) {
|
|
32463
|
+
const self2 = this;
|
|
32464
|
+
if (!Object.prototype.isPrototypeOf.call(ReadStream.prototype, self2)) return new ReadStream(path, options);
|
|
32465
|
+
const settings = streamSettings(options);
|
|
32466
|
+
import_stream_browserify5.default.Readable.call(self2, { highWaterMark: settings.highWaterMark, encoding: settings.encoding, emitClose: true });
|
|
32467
|
+
self2.path = abs(path);
|
|
32468
|
+
self2.flags = settings.flags ?? "r";
|
|
32469
|
+
self2.mode = settings.mode ?? 438;
|
|
32470
|
+
self2.fd = typeof settings.fd === "number" ? settings.fd : null;
|
|
32471
|
+
self2.start = settings.start;
|
|
32472
|
+
self2.end = settings.end;
|
|
32473
|
+
self2.bytesRead = 0;
|
|
32474
|
+
self2.pending = true;
|
|
32475
|
+
self2._delivered = false;
|
|
32476
|
+
self2.once("open", () => {
|
|
32477
|
+
self2.pending = false;
|
|
32478
|
+
});
|
|
32479
|
+
self2.once("end", () => {
|
|
32480
|
+
if (!self2.destroyed) self2.destroy();
|
|
32481
|
+
});
|
|
32482
|
+
if (self2.fd === null) self2.open();
|
|
32483
|
+
else defer(() => {
|
|
32484
|
+
self2.emit("open", self2.fd);
|
|
32485
|
+
self2.emit("ready");
|
|
32486
|
+
});
|
|
32487
|
+
}
|
|
32488
|
+
ReadStream.prototype = Object.create(import_stream_browserify5.default.Readable.prototype, {
|
|
32489
|
+
constructor: { value: ReadStream, writable: true, configurable: true }
|
|
32490
|
+
});
|
|
32491
|
+
ReadStream.prototype.open = function() {
|
|
32492
|
+
const self2 = this;
|
|
32493
|
+
defer(() => {
|
|
32494
|
+
self2.emit("open", 0);
|
|
32495
|
+
self2.emit("ready");
|
|
32496
|
+
});
|
|
32497
|
+
};
|
|
32498
|
+
ReadStream.prototype._read = function() {
|
|
32499
|
+
const self2 = this;
|
|
32500
|
+
if (self2._delivered) {
|
|
32501
|
+
self2.push(null);
|
|
32502
|
+
return;
|
|
32503
|
+
}
|
|
32504
|
+
self2._delivered = true;
|
|
32505
|
+
let whole;
|
|
32506
|
+
try {
|
|
32507
|
+
whole = Buffer2.from(volume.readFileSync(resolveLinks(volume, self2.path)));
|
|
32508
|
+
} catch (error) {
|
|
32509
|
+
self2.destroy(error);
|
|
32510
|
+
return;
|
|
32511
|
+
}
|
|
32512
|
+
const start = self2.start ?? 0;
|
|
32513
|
+
const end = self2.end === void 0 ? whole.length : Math.min(self2.end + 1, whole.length);
|
|
32514
|
+
const slice = whole.subarray(start, Math.max(start, end));
|
|
32515
|
+
self2.bytesRead = slice.length;
|
|
32516
|
+
if (slice.length) self2.push(slice);
|
|
32517
|
+
self2.push(null);
|
|
32518
|
+
};
|
|
32519
|
+
ReadStream.prototype.close = function(callback2) {
|
|
32520
|
+
const self2 = this;
|
|
32521
|
+
if (callback2) {
|
|
32522
|
+
if (self2.closed) defer(() => callback2(null));
|
|
32523
|
+
else self2.once("close", () => callback2(null));
|
|
32524
|
+
}
|
|
32525
|
+
if (!self2.destroyed) self2.destroy();
|
|
32526
|
+
};
|
|
32527
|
+
fs.WriteStream = WriteStream;
|
|
32528
|
+
fs.ReadStream = ReadStream;
|
|
32529
|
+
fs.FileWriteStream = WriteStream;
|
|
32530
|
+
fs.FileReadStream = ReadStream;
|
|
32531
|
+
class Dir {
|
|
32532
|
+
path;
|
|
32533
|
+
entries;
|
|
32534
|
+
closed = false;
|
|
32535
|
+
constructor(path) {
|
|
32536
|
+
this.path = path;
|
|
32537
|
+
this.entries = fs.readdirSync(path, { withFileTypes: true });
|
|
32538
|
+
}
|
|
32539
|
+
assertOpen() {
|
|
32540
|
+
if (this.closed) throw Object.assign(new Error("Directory handle was closed"), { code: "ERR_DIR_CLOSED" });
|
|
32541
|
+
}
|
|
32542
|
+
readSync() {
|
|
32543
|
+
this.assertOpen();
|
|
32544
|
+
return this.entries.shift() ?? null;
|
|
32545
|
+
}
|
|
32546
|
+
read(callback2) {
|
|
32547
|
+
if (callback2) {
|
|
32548
|
+
defer(() => {
|
|
32549
|
+
let entry;
|
|
32550
|
+
try {
|
|
32551
|
+
entry = this.readSync();
|
|
32552
|
+
} catch (error) {
|
|
32553
|
+
callback2(error, null);
|
|
32554
|
+
return;
|
|
32555
|
+
}
|
|
32556
|
+
callback2(null, entry);
|
|
32557
|
+
});
|
|
32558
|
+
return;
|
|
32559
|
+
}
|
|
32560
|
+
return Promise.resolve().then(() => this.readSync());
|
|
32561
|
+
}
|
|
32562
|
+
closeSync() {
|
|
32563
|
+
this.assertOpen();
|
|
32564
|
+
this.closed = true;
|
|
32565
|
+
}
|
|
32566
|
+
close(callback2) {
|
|
32567
|
+
if (callback2) {
|
|
32568
|
+
defer(() => {
|
|
32569
|
+
try {
|
|
32570
|
+
this.closeSync();
|
|
32571
|
+
} catch (error) {
|
|
32572
|
+
callback2(error);
|
|
32573
|
+
return;
|
|
32574
|
+
}
|
|
32575
|
+
callback2(null);
|
|
32576
|
+
});
|
|
32577
|
+
return;
|
|
32578
|
+
}
|
|
32579
|
+
return Promise.resolve().then(() => this.closeSync());
|
|
32580
|
+
}
|
|
32581
|
+
/* Iterating a `Dir` reads it to the end and then closes it, as in Node. */
|
|
32582
|
+
async *[Symbol.asyncIterator]() {
|
|
32583
|
+
try {
|
|
32584
|
+
for (let entry = this.readSync(); entry; entry = this.readSync()) yield entry;
|
|
32585
|
+
} finally {
|
|
32586
|
+
if (!this.closed) this.closeSync();
|
|
32587
|
+
}
|
|
32588
|
+
}
|
|
32589
|
+
*entriesSync() {
|
|
32590
|
+
try {
|
|
32591
|
+
for (let entry = this.readSync(); entry; entry = this.readSync()) yield entry;
|
|
32592
|
+
} finally {
|
|
32593
|
+
if (!this.closed) this.closeSync();
|
|
32594
|
+
}
|
|
32595
|
+
}
|
|
32596
|
+
}
|
|
32597
|
+
fs.Dir = Dir;
|
|
32598
|
+
fs.opendirSync = (path) => new Dir(abs(path));
|
|
32599
|
+
fs.opendir = (path, options, callback2) => {
|
|
32600
|
+
const done = typeof options === "function" ? options : callback2;
|
|
32601
|
+
if (typeof done !== "function") throw new TypeError("callback must be a function");
|
|
32602
|
+
defer(() => {
|
|
32603
|
+
let dir;
|
|
32604
|
+
try {
|
|
32605
|
+
dir = fs.opendirSync(path);
|
|
32606
|
+
} catch (error) {
|
|
32607
|
+
done(error);
|
|
32608
|
+
return;
|
|
32609
|
+
}
|
|
32610
|
+
done(null, dir);
|
|
32611
|
+
});
|
|
32612
|
+
};
|
|
32613
|
+
const runThenCall = (work, cb) => {
|
|
32614
|
+
defer(() => {
|
|
32615
|
+
let result;
|
|
32616
|
+
try {
|
|
32617
|
+
result = work();
|
|
32618
|
+
} catch (error) {
|
|
32619
|
+
cb(error);
|
|
32620
|
+
return;
|
|
32621
|
+
}
|
|
32622
|
+
cb(null, ...result);
|
|
32623
|
+
});
|
|
32624
|
+
};
|
|
32625
|
+
fs.read = (fd, ...rest) => {
|
|
32626
|
+
const cb = rest.pop();
|
|
32627
|
+
if (typeof cb !== "function") throw new TypeError("callback must be a function");
|
|
32628
|
+
let buffer;
|
|
32629
|
+
let offset2;
|
|
32630
|
+
let length;
|
|
32631
|
+
let position;
|
|
32632
|
+
if (ArrayBuffer.isView(rest[0])) {
|
|
32633
|
+
buffer = rest[0];
|
|
32634
|
+
if (rest[1] !== null && typeof rest[1] === "object") ({ offset: offset2, length, position } = rest[1]);
|
|
32635
|
+
else [offset2, length, position] = [rest[1], rest[2], rest[3]];
|
|
32636
|
+
} else {
|
|
32637
|
+
const options = rest[0] ?? {};
|
|
32638
|
+
buffer = options.buffer ?? Buffer2.alloc(16384);
|
|
32639
|
+
({ offset: offset2, length, position } = options);
|
|
32640
|
+
}
|
|
32641
|
+
const start = offset2 ?? 0;
|
|
32642
|
+
runThenCall(() => [fs.readSync(fd, buffer, start, length ?? buffer.byteLength - start, position ?? null), buffer], cb);
|
|
32643
|
+
};
|
|
32644
|
+
fs.write = (fd, data2, ...rest) => {
|
|
32645
|
+
const cb = rest.pop();
|
|
32646
|
+
if (typeof cb !== "function") throw new TypeError("callback must be a function");
|
|
32647
|
+
runThenCall(() => [fs.writeSync(fd, data2, ...rest), data2], cb);
|
|
32648
|
+
};
|
|
31454
32649
|
fs.exists = (path, cb) => {
|
|
31455
32650
|
defer(() => cb(fs.existsSync(path)));
|
|
31456
32651
|
};
|
|
@@ -31462,7 +32657,8 @@ function createFsModule(volume, cwd, stdinPath, defer = queueMicrotask) {
|
|
|
31462
32657
|
/* The promise API hands back a FileHandle object rather than a numeric
|
|
31463
32658
|
* descriptor, and callers use its methods instead of passing the number
|
|
31464
32659
|
* to `fs.read`. */
|
|
31465
|
-
open: async (path, flags = "r", mode) => makeFileHandle(fs, fs.openSync(path, flags, mode))
|
|
32660
|
+
open: async (path, flags = "r", mode) => makeFileHandle(fs, fs.openSync(path, flags, mode)),
|
|
32661
|
+
opendir: async (path) => fs.opendirSync(path)
|
|
31466
32662
|
};
|
|
31467
32663
|
return fs;
|
|
31468
32664
|
}
|
|
@@ -31509,6 +32705,37 @@ function resolveLinks(volume, input) {
|
|
|
31509
32705
|
}
|
|
31510
32706
|
throw fsError("ELOOP", "realpath", input);
|
|
31511
32707
|
}
|
|
32708
|
+
function createBufferBuiltin() {
|
|
32709
|
+
const MAX_LENGTH = typeof Buffer2.kMaxLength === "number" ? Buffer2.kMaxLength : 2 ** 32;
|
|
32710
|
+
const MAX_STRING_LENGTH = 2 ** 29 - 24;
|
|
32711
|
+
const textDecoder = typeof TextDecoder === "function" ? new TextDecoder("utf-8", { fatal: true }) : void 0;
|
|
32712
|
+
return {
|
|
32713
|
+
Buffer: Buffer2,
|
|
32714
|
+
SlowBuffer: Buffer2,
|
|
32715
|
+
INSPECT_MAX_BYTES: 50,
|
|
32716
|
+
kMaxLength: MAX_LENGTH,
|
|
32717
|
+
kStringMaxLength: MAX_STRING_LENGTH,
|
|
32718
|
+
constants: { MAX_LENGTH, MAX_STRING_LENGTH },
|
|
32719
|
+
...typeof Blob === "function" ? { Blob } : {},
|
|
32720
|
+
...typeof globalThis.File === "function" ? { File: globalThis.File } : {},
|
|
32721
|
+
atob: (data2) => globalThis.atob(String(data2)),
|
|
32722
|
+
btoa: (data2) => globalThis.btoa(String(data2)),
|
|
32723
|
+
isUtf8: (input) => {
|
|
32724
|
+
if (!textDecoder) return true;
|
|
32725
|
+
try {
|
|
32726
|
+
textDecoder.decode(input);
|
|
32727
|
+
return true;
|
|
32728
|
+
} catch {
|
|
32729
|
+
return false;
|
|
32730
|
+
}
|
|
32731
|
+
},
|
|
32732
|
+
isAscii: (input) => {
|
|
32733
|
+
const bytes2 = input instanceof ArrayBuffer ? new Uint8Array(input) : new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
32734
|
+
for (const byte of bytes2) if (byte > 127) return false;
|
|
32735
|
+
return true;
|
|
32736
|
+
}
|
|
32737
|
+
};
|
|
32738
|
+
}
|
|
31512
32739
|
function requiredFd(fds, fd) {
|
|
31513
32740
|
const file = fds.get(fd);
|
|
31514
32741
|
if (!file) throw fsError("EBADF", "fd", String(fd));
|
|
@@ -31518,8 +32745,8 @@ function fsError(code, syscall, path) {
|
|
|
31518
32745
|
return Object.assign(new Error(`${code}: ${syscall}, '${path}'`), { code, syscall, path });
|
|
31519
32746
|
}
|
|
31520
32747
|
function makeOutputStream(write, fd, isTTY = false) {
|
|
31521
|
-
const stream = new
|
|
31522
|
-
write(Buffer2.isBuffer(chunk) ? chunk
|
|
32748
|
+
const stream = new import_stream_browserify5.default.Writable({ decodeStrings: false, write(chunk, _encoding, done) {
|
|
32749
|
+
write(Buffer2.isBuffer(chunk) ? new Uint8Array(chunk) : String(chunk));
|
|
31523
32750
|
done();
|
|
31524
32751
|
} });
|
|
31525
32752
|
return Object.assign(stream, { fd, isTTY, columns: 80, rows: 24 });
|
|
@@ -31785,6 +33012,12 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31785
33012
|
}
|
|
31786
33013
|
afterCallback();
|
|
31787
33014
|
};
|
|
33015
|
+
const hostSetTimeout = globalThis.setTimeout.bind(globalThis);
|
|
33016
|
+
const hostClearTimeout = globalThis.clearTimeout.bind(globalThis);
|
|
33017
|
+
const hostSetInterval = globalThis.setInterval.bind(globalThis);
|
|
33018
|
+
const hostClearInterval = globalThis.clearInterval.bind(globalThis);
|
|
33019
|
+
const hostSetImmediate = typeof globalThis.setImmediate === "function" ? globalThis.setImmediate.bind(globalThis) : void 0;
|
|
33020
|
+
const hostClearImmediate = typeof globalThis.clearImmediate === "function" ? globalThis.clearImmediate.bind(globalThis) : hostClearTimeout;
|
|
31788
33021
|
let scheduled = 0;
|
|
31789
33022
|
const live = /* @__PURE__ */ new Set();
|
|
31790
33023
|
const unrefed = /* @__PURE__ */ new Set();
|
|
@@ -31824,9 +33057,10 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31824
33057
|
live.delete(handle);
|
|
31825
33058
|
unrefed.delete(handle);
|
|
31826
33059
|
};
|
|
31827
|
-
const setTimeoutTracked = (
|
|
33060
|
+
const setTimeoutTracked = (callback, delay, ...args) => {
|
|
33061
|
+
const fn = bindToCurrent(callback);
|
|
31828
33062
|
let handle;
|
|
31829
|
-
const native =
|
|
33063
|
+
const native = hostSetTimeout(
|
|
31830
33064
|
(...inner) => {
|
|
31831
33065
|
complete(handle);
|
|
31832
33066
|
run2(fn, inner);
|
|
@@ -31837,10 +33071,13 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31837
33071
|
handle = track(native);
|
|
31838
33072
|
return handle;
|
|
31839
33073
|
};
|
|
31840
|
-
const setIntervalTracked = (
|
|
31841
|
-
|
|
31842
|
-
|
|
31843
|
-
|
|
33074
|
+
const setIntervalTracked = (callback, delay, ...args) => {
|
|
33075
|
+
const fn = bindToCurrent(callback);
|
|
33076
|
+
return track(hostSetInterval((...inner) => run2(fn, inner), delay, ...args));
|
|
33077
|
+
};
|
|
33078
|
+
const setImmediateTracked = (callback, ...args) => {
|
|
33079
|
+
if (!hostSetImmediate) return setTimeoutTracked(callback, 0, ...args);
|
|
33080
|
+
const fn = bindToCurrent(callback);
|
|
31844
33081
|
let handle;
|
|
31845
33082
|
const native = hostSetImmediate((...inner) => {
|
|
31846
33083
|
complete(handle);
|
|
@@ -31869,15 +33106,15 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31869
33106
|
if (!state) continue;
|
|
31870
33107
|
state.active = false;
|
|
31871
33108
|
try {
|
|
31872
|
-
|
|
33109
|
+
hostClearTimeout(state.native);
|
|
31873
33110
|
} catch {
|
|
31874
33111
|
}
|
|
31875
33112
|
try {
|
|
31876
|
-
|
|
33113
|
+
hostClearInterval(state.native);
|
|
31877
33114
|
} catch {
|
|
31878
33115
|
}
|
|
31879
33116
|
try {
|
|
31880
|
-
(
|
|
33117
|
+
hostClearImmediate(state.native);
|
|
31881
33118
|
} catch {
|
|
31882
33119
|
}
|
|
31883
33120
|
}
|
|
@@ -31889,9 +33126,9 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31889
33126
|
setTimeout: setTimeoutTracked,
|
|
31890
33127
|
setInterval: setIntervalTracked,
|
|
31891
33128
|
setImmediate: setImmediateTracked,
|
|
31892
|
-
clearTimeout: (handle) => clear(handle,
|
|
31893
|
-
clearInterval: (handle) => clear(handle,
|
|
31894
|
-
clearImmediate: (handle) => clear(handle,
|
|
33129
|
+
clearTimeout: (handle) => clear(handle, hostClearTimeout),
|
|
33130
|
+
clearInterval: (handle) => clear(handle, hostClearInterval),
|
|
33131
|
+
clearImmediate: (handle) => clear(handle, hostClearImmediate)
|
|
31895
33132
|
},
|
|
31896
33133
|
pending: () => live.size,
|
|
31897
33134
|
pendingUnrefed: () => unrefed.size,
|
|
@@ -31906,66 +33143,6 @@ function createTimerPromises(timers) {
|
|
|
31906
33143
|
};
|
|
31907
33144
|
}
|
|
31908
33145
|
function createAsyncHooksModule() {
|
|
31909
|
-
class AsyncResource {
|
|
31910
|
-
constructor(type, _options) {
|
|
31911
|
-
this.type = type;
|
|
31912
|
-
}
|
|
31913
|
-
type;
|
|
31914
|
-
runInAsyncScope(fn, thisArg, ...args) {
|
|
31915
|
-
return fn.apply(thisArg, args);
|
|
31916
|
-
}
|
|
31917
|
-
bind(fn, thisArg) {
|
|
31918
|
-
return ((...args) => this.runInAsyncScope(fn, thisArg, ...args));
|
|
31919
|
-
}
|
|
31920
|
-
emitDestroy() {
|
|
31921
|
-
return this;
|
|
31922
|
-
}
|
|
31923
|
-
asyncId() {
|
|
31924
|
-
return 1;
|
|
31925
|
-
}
|
|
31926
|
-
triggerAsyncId() {
|
|
31927
|
-
return 0;
|
|
31928
|
-
}
|
|
31929
|
-
static bind(fn, type = "bound-anonymous-fn", thisArg) {
|
|
31930
|
-
return new AsyncResource(type).bind(fn, thisArg);
|
|
31931
|
-
}
|
|
31932
|
-
}
|
|
31933
|
-
class AsyncLocalStorage {
|
|
31934
|
-
value;
|
|
31935
|
-
disable() {
|
|
31936
|
-
this.value = void 0;
|
|
31937
|
-
}
|
|
31938
|
-
getStore() {
|
|
31939
|
-
return this.value;
|
|
31940
|
-
}
|
|
31941
|
-
enterWith(store) {
|
|
31942
|
-
this.value = store;
|
|
31943
|
-
}
|
|
31944
|
-
run(store, callback, ...args) {
|
|
31945
|
-
const previous = this.value;
|
|
31946
|
-
this.value = store;
|
|
31947
|
-
try {
|
|
31948
|
-
return callback(...args);
|
|
31949
|
-
} finally {
|
|
31950
|
-
this.value = previous;
|
|
31951
|
-
}
|
|
31952
|
-
}
|
|
31953
|
-
exit(callback, ...args) {
|
|
31954
|
-
const previous = this.value;
|
|
31955
|
-
this.value = void 0;
|
|
31956
|
-
try {
|
|
31957
|
-
return callback(...args);
|
|
31958
|
-
} finally {
|
|
31959
|
-
this.value = previous;
|
|
31960
|
-
}
|
|
31961
|
-
}
|
|
31962
|
-
static bind(fn) {
|
|
31963
|
-
return fn;
|
|
31964
|
-
}
|
|
31965
|
-
static snapshot() {
|
|
31966
|
-
return (fn, ...args) => fn(...args);
|
|
31967
|
-
}
|
|
31968
|
-
}
|
|
31969
33146
|
return {
|
|
31970
33147
|
AsyncResource,
|
|
31971
33148
|
AsyncLocalStorage,
|
|
@@ -31983,10 +33160,10 @@ function createStreamPromises() {
|
|
|
31983
33160
|
return {
|
|
31984
33161
|
pipeline: (...streams) => new Promise((resolve2, reject) => {
|
|
31985
33162
|
const callback = (error) => error ? reject(error) : resolve2();
|
|
31986
|
-
|
|
33163
|
+
import_stream_browserify5.default.pipeline(...streams, callback);
|
|
31987
33164
|
}),
|
|
31988
33165
|
finished: (stream) => new Promise((resolve2, reject) => {
|
|
31989
|
-
|
|
33166
|
+
import_stream_browserify5.default.finished(stream, (error) => error ? reject(error) : resolve2());
|
|
31990
33167
|
})
|
|
31991
33168
|
};
|
|
31992
33169
|
}
|
|
@@ -32000,6 +33177,7 @@ function createUnsupportedModule(name, supported = {}) {
|
|
|
32000
33177
|
const module = new Proxy(target, {
|
|
32001
33178
|
get(object, key) {
|
|
32002
33179
|
if (key === "default") return module;
|
|
33180
|
+
if (key === "__esModule" || typeof key === "symbol") return object[key];
|
|
32003
33181
|
return key in object ? object[key] : unsupported;
|
|
32004
33182
|
}
|
|
32005
33183
|
});
|
|
@@ -32022,10 +33200,20 @@ function createNetModule() {
|
|
|
32022
33200
|
const count = groups.reduce((total, half) => total + half.length, 0);
|
|
32023
33201
|
return halves.length === 2 ? count <= 7 : count === 8;
|
|
32024
33202
|
};
|
|
33203
|
+
let autoSelectFamily = true;
|
|
33204
|
+
let autoSelectFamilyAttemptTimeout = 250;
|
|
32025
33205
|
return createUnsupportedModule("net", {
|
|
32026
33206
|
isIPv4,
|
|
32027
33207
|
isIPv6,
|
|
32028
|
-
isIP: (value) => isIPv4(value) ? 4 : isIPv6(value) ? 6 : 0
|
|
33208
|
+
isIP: (value) => isIPv4(value) ? 4 : isIPv6(value) ? 6 : 0,
|
|
33209
|
+
getDefaultAutoSelectFamily: () => autoSelectFamily,
|
|
33210
|
+
setDefaultAutoSelectFamily: (value) => {
|
|
33211
|
+
autoSelectFamily = Boolean(value);
|
|
33212
|
+
},
|
|
33213
|
+
getDefaultAutoSelectFamilyAttemptTimeout: () => autoSelectFamilyAttemptTimeout,
|
|
33214
|
+
setDefaultAutoSelectFamilyAttemptTimeout: (value) => {
|
|
33215
|
+
autoSelectFamilyAttemptTimeout = Math.max(10, Number(value) || 250);
|
|
33216
|
+
}
|
|
32029
33217
|
});
|
|
32030
33218
|
}
|
|
32031
33219
|
function parseTestSettings(raw) {
|
|
@@ -32243,10 +33431,10 @@ function spawnSyncOverChannel(channel, request) {
|
|
|
32243
33431
|
|
|
32244
33432
|
// src/node/global-process.ts
|
|
32245
33433
|
var import_browser2 = __toESM(require_browser2());
|
|
32246
|
-
var
|
|
33434
|
+
var installed2 = false;
|
|
32247
33435
|
function ensureProcessGlobal() {
|
|
32248
|
-
if (
|
|
32249
|
-
|
|
33436
|
+
if (installed2) return;
|
|
33437
|
+
installed2 = true;
|
|
32250
33438
|
if (typeof globalThis.process !== "undefined") return;
|
|
32251
33439
|
Object.defineProperty(globalThis, "process", {
|
|
32252
33440
|
value: import_browser2.default,
|
|
@@ -32292,6 +33480,7 @@ async function main() {
|
|
|
32292
33480
|
port.postMessage({ type: "sandboxedjs:ready" });
|
|
32293
33481
|
}
|
|
32294
33482
|
async function run(port, start) {
|
|
33483
|
+
installPromiseContext();
|
|
32295
33484
|
const channel = new SyncChannelClient(start.buffers, () => port.postMessage({ type: "wake" }));
|
|
32296
33485
|
const volume = new RemoteVolume(channel);
|
|
32297
33486
|
const router = new VirtualHttpRouter();
|
|
@@ -32356,7 +33545,7 @@ async function run(port, start) {
|
|
|
32356
33545
|
};
|
|
32357
33546
|
port.onMessage((message) => {
|
|
32358
33547
|
if (message?.type === "wake") return;
|
|
32359
|
-
if (message?.type === "stdin") core.writeStdin(String(message.data));
|
|
33548
|
+
if (message?.type === "stdin") core.writeStdin(message.data instanceof Uint8Array ? message.data : String(message.data));
|
|
32360
33549
|
if (message?.type === "stdin-end") core.endStdin();
|
|
32361
33550
|
if (message?.type === "kill") {
|
|
32362
33551
|
core.cancelTimers();
|
|
@@ -32475,6 +33664,12 @@ function hostChildProcess(port, config) {
|
|
|
32475
33664
|
endStdin() {
|
|
32476
33665
|
port.postMessage({ type: "child-stdin-end", id });
|
|
32477
33666
|
},
|
|
33667
|
+
writeFd(fd, data2) {
|
|
33668
|
+
port.postMessage({ type: "child-fd", id, fd, data: data2 });
|
|
33669
|
+
},
|
|
33670
|
+
endFd(fd) {
|
|
33671
|
+
port.postMessage({ type: "child-fd-end", id, fd });
|
|
33672
|
+
},
|
|
32478
33673
|
kill(signal = "SIGTERM") {
|
|
32479
33674
|
port.postMessage({ type: "child-kill", id, signal });
|
|
32480
33675
|
}
|