@secure-exec/nodejs 0.2.0-rc.1 → 0.2.0-rc.2
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/bridge/child-process.js +47 -1
- package/dist/bridge/fs.d.ts +6 -1
- package/dist/bridge/fs.js +12 -3
- package/dist/bridge/index.d.ts +2 -2
- package/dist/bridge/index.js +2 -2
- package/dist/bridge/network.d.ts +35 -1
- package/dist/bridge/network.js +471 -153
- package/dist/bridge/os.js +9 -3
- package/dist/bridge/polyfills.d.ts +6 -9
- package/dist/bridge/polyfills.js +616 -14
- package/dist/bridge/process.d.ts +3 -2
- package/dist/bridge/process.js +288 -61
- package/dist/bridge-contract.d.ts +21 -3
- package/dist/bridge-contract.js +2 -0
- package/dist/bridge-handlers.d.ts +10 -0
- package/dist/bridge-handlers.js +515 -179
- package/dist/bridge.js +1531 -855
- package/dist/builtin-modules.js +6 -0
- package/dist/esm-compiler.d.ts +1 -0
- package/dist/esm-compiler.js +29 -11
- package/dist/execution-driver.js +362 -10
- package/dist/host-network-adapter.js +10 -6
- package/dist/isolate-bootstrap.d.ts +6 -0
- package/dist/kernel-runtime.d.ts +3 -1
- package/dist/kernel-runtime.js +109 -11
- package/dist/module-access.d.ts +3 -0
- package/dist/module-access.js +52 -2
- package/dist/module-resolver.js +3 -3
- package/dist/module-source.d.ts +5 -0
- package/dist/module-source.js +224 -0
- package/dist/polyfills.js +27 -1
- package/package.json +5 -3
package/dist/bridge.js
CHANGED
|
@@ -31,373 +31,6 @@ var bridge = (() => {
|
|
|
31
31
|
));
|
|
32
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
33
|
|
|
34
|
-
// ../../node_modules/.pnpm/text-encoding-utf-8@1.0.2/node_modules/text-encoding-utf-8/lib/encoding.lib.js
|
|
35
|
-
var require_encoding_lib = __commonJS({
|
|
36
|
-
"../../node_modules/.pnpm/text-encoding-utf-8@1.0.2/node_modules/text-encoding-utf-8/lib/encoding.lib.js"(exports) {
|
|
37
|
-
"use strict";
|
|
38
|
-
function inRange(a, min, max) {
|
|
39
|
-
return min <= a && a <= max;
|
|
40
|
-
}
|
|
41
|
-
function ToDictionary(o) {
|
|
42
|
-
if (o === void 0) return {};
|
|
43
|
-
if (o === Object(o)) return o;
|
|
44
|
-
throw TypeError("Could not convert argument to dictionary");
|
|
45
|
-
}
|
|
46
|
-
function stringToCodePoints(string) {
|
|
47
|
-
var s = String(string);
|
|
48
|
-
var n = s.length;
|
|
49
|
-
var i = 0;
|
|
50
|
-
var u = [];
|
|
51
|
-
while (i < n) {
|
|
52
|
-
var c = s.charCodeAt(i);
|
|
53
|
-
if (c < 55296 || c > 57343) {
|
|
54
|
-
u.push(c);
|
|
55
|
-
} else if (56320 <= c && c <= 57343) {
|
|
56
|
-
u.push(65533);
|
|
57
|
-
} else if (55296 <= c && c <= 56319) {
|
|
58
|
-
if (i === n - 1) {
|
|
59
|
-
u.push(65533);
|
|
60
|
-
} else {
|
|
61
|
-
var d = string.charCodeAt(i + 1);
|
|
62
|
-
if (56320 <= d && d <= 57343) {
|
|
63
|
-
var a = c & 1023;
|
|
64
|
-
var b = d & 1023;
|
|
65
|
-
u.push(65536 + (a << 10) + b);
|
|
66
|
-
i += 1;
|
|
67
|
-
} else {
|
|
68
|
-
u.push(65533);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
i += 1;
|
|
73
|
-
}
|
|
74
|
-
return u;
|
|
75
|
-
}
|
|
76
|
-
function codePointsToString(code_points) {
|
|
77
|
-
var s = "";
|
|
78
|
-
for (var i = 0; i < code_points.length; ++i) {
|
|
79
|
-
var cp = code_points[i];
|
|
80
|
-
if (cp <= 65535) {
|
|
81
|
-
s += String.fromCharCode(cp);
|
|
82
|
-
} else {
|
|
83
|
-
cp -= 65536;
|
|
84
|
-
s += String.fromCharCode(
|
|
85
|
-
(cp >> 10) + 55296,
|
|
86
|
-
(cp & 1023) + 56320
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return s;
|
|
91
|
-
}
|
|
92
|
-
var end_of_stream = -1;
|
|
93
|
-
function Stream(tokens) {
|
|
94
|
-
this.tokens = [].slice.call(tokens);
|
|
95
|
-
}
|
|
96
|
-
Stream.prototype = {
|
|
97
|
-
/**
|
|
98
|
-
* @return {boolean} True if end-of-stream has been hit.
|
|
99
|
-
*/
|
|
100
|
-
endOfStream: function() {
|
|
101
|
-
return !this.tokens.length;
|
|
102
|
-
},
|
|
103
|
-
/**
|
|
104
|
-
* When a token is read from a stream, the first token in the
|
|
105
|
-
* stream must be returned and subsequently removed, and
|
|
106
|
-
* end-of-stream must be returned otherwise.
|
|
107
|
-
*
|
|
108
|
-
* @return {number} Get the next token from the stream, or
|
|
109
|
-
* end_of_stream.
|
|
110
|
-
*/
|
|
111
|
-
read: function() {
|
|
112
|
-
if (!this.tokens.length)
|
|
113
|
-
return end_of_stream;
|
|
114
|
-
return this.tokens.shift();
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* When one or more tokens are prepended to a stream, those tokens
|
|
118
|
-
* must be inserted, in given order, before the first token in the
|
|
119
|
-
* stream.
|
|
120
|
-
*
|
|
121
|
-
* @param {(number|!Array.<number>)} token The token(s) to prepend to the stream.
|
|
122
|
-
*/
|
|
123
|
-
prepend: function(token) {
|
|
124
|
-
if (Array.isArray(token)) {
|
|
125
|
-
var tokens = (
|
|
126
|
-
/**@type {!Array.<number>}*/
|
|
127
|
-
token
|
|
128
|
-
);
|
|
129
|
-
while (tokens.length)
|
|
130
|
-
this.tokens.unshift(tokens.pop());
|
|
131
|
-
} else {
|
|
132
|
-
this.tokens.unshift(token);
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
/**
|
|
136
|
-
* When one or more tokens are pushed to a stream, those tokens
|
|
137
|
-
* must be inserted, in given order, after the last token in the
|
|
138
|
-
* stream.
|
|
139
|
-
*
|
|
140
|
-
* @param {(number|!Array.<number>)} token The tokens(s) to prepend to the stream.
|
|
141
|
-
*/
|
|
142
|
-
push: function(token) {
|
|
143
|
-
if (Array.isArray(token)) {
|
|
144
|
-
var tokens = (
|
|
145
|
-
/**@type {!Array.<number>}*/
|
|
146
|
-
token
|
|
147
|
-
);
|
|
148
|
-
while (tokens.length)
|
|
149
|
-
this.tokens.push(tokens.shift());
|
|
150
|
-
} else {
|
|
151
|
-
this.tokens.push(token);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
var finished = -1;
|
|
156
|
-
function decoderError(fatal, opt_code_point) {
|
|
157
|
-
if (fatal)
|
|
158
|
-
throw TypeError("Decoder error");
|
|
159
|
-
return opt_code_point || 65533;
|
|
160
|
-
}
|
|
161
|
-
var DEFAULT_ENCODING = "utf-8";
|
|
162
|
-
function TextDecoder3(encoding, options) {
|
|
163
|
-
if (!(this instanceof TextDecoder3)) {
|
|
164
|
-
return new TextDecoder3(encoding, options);
|
|
165
|
-
}
|
|
166
|
-
encoding = encoding !== void 0 ? String(encoding).toLowerCase() : DEFAULT_ENCODING;
|
|
167
|
-
if (encoding !== DEFAULT_ENCODING) {
|
|
168
|
-
throw new Error("Encoding not supported. Only utf-8 is supported");
|
|
169
|
-
}
|
|
170
|
-
options = ToDictionary(options);
|
|
171
|
-
this._streaming = false;
|
|
172
|
-
this._BOMseen = false;
|
|
173
|
-
this._decoder = null;
|
|
174
|
-
this._fatal = Boolean(options["fatal"]);
|
|
175
|
-
this._ignoreBOM = Boolean(options["ignoreBOM"]);
|
|
176
|
-
Object.defineProperty(this, "encoding", { value: "utf-8" });
|
|
177
|
-
Object.defineProperty(this, "fatal", { value: this._fatal });
|
|
178
|
-
Object.defineProperty(this, "ignoreBOM", { value: this._ignoreBOM });
|
|
179
|
-
}
|
|
180
|
-
TextDecoder3.prototype = {
|
|
181
|
-
/**
|
|
182
|
-
* @param {ArrayBufferView=} input The buffer of bytes to decode.
|
|
183
|
-
* @param {Object=} options
|
|
184
|
-
* @return {string} The decoded string.
|
|
185
|
-
*/
|
|
186
|
-
decode: function decode(input, options) {
|
|
187
|
-
var bytes;
|
|
188
|
-
if (typeof input === "object" && input instanceof ArrayBuffer) {
|
|
189
|
-
bytes = new Uint8Array(input);
|
|
190
|
-
} else if (typeof input === "object" && "buffer" in input && input.buffer instanceof ArrayBuffer) {
|
|
191
|
-
bytes = new Uint8Array(
|
|
192
|
-
input.buffer,
|
|
193
|
-
input.byteOffset,
|
|
194
|
-
input.byteLength
|
|
195
|
-
);
|
|
196
|
-
} else {
|
|
197
|
-
bytes = new Uint8Array(0);
|
|
198
|
-
}
|
|
199
|
-
options = ToDictionary(options);
|
|
200
|
-
if (!this._streaming) {
|
|
201
|
-
this._decoder = new UTF8Decoder({ fatal: this._fatal });
|
|
202
|
-
this._BOMseen = false;
|
|
203
|
-
}
|
|
204
|
-
this._streaming = Boolean(options["stream"]);
|
|
205
|
-
var input_stream = new Stream(bytes);
|
|
206
|
-
var code_points = [];
|
|
207
|
-
var result;
|
|
208
|
-
while (!input_stream.endOfStream()) {
|
|
209
|
-
result = this._decoder.handler(input_stream, input_stream.read());
|
|
210
|
-
if (result === finished)
|
|
211
|
-
break;
|
|
212
|
-
if (result === null)
|
|
213
|
-
continue;
|
|
214
|
-
if (Array.isArray(result))
|
|
215
|
-
code_points.push.apply(
|
|
216
|
-
code_points,
|
|
217
|
-
/**@type {!Array.<number>}*/
|
|
218
|
-
result
|
|
219
|
-
);
|
|
220
|
-
else
|
|
221
|
-
code_points.push(result);
|
|
222
|
-
}
|
|
223
|
-
if (!this._streaming) {
|
|
224
|
-
do {
|
|
225
|
-
result = this._decoder.handler(input_stream, input_stream.read());
|
|
226
|
-
if (result === finished)
|
|
227
|
-
break;
|
|
228
|
-
if (result === null)
|
|
229
|
-
continue;
|
|
230
|
-
if (Array.isArray(result))
|
|
231
|
-
code_points.push.apply(
|
|
232
|
-
code_points,
|
|
233
|
-
/**@type {!Array.<number>}*/
|
|
234
|
-
result
|
|
235
|
-
);
|
|
236
|
-
else
|
|
237
|
-
code_points.push(result);
|
|
238
|
-
} while (!input_stream.endOfStream());
|
|
239
|
-
this._decoder = null;
|
|
240
|
-
}
|
|
241
|
-
if (code_points.length) {
|
|
242
|
-
if (["utf-8"].indexOf(this.encoding) !== -1 && !this._ignoreBOM && !this._BOMseen) {
|
|
243
|
-
if (code_points[0] === 65279) {
|
|
244
|
-
this._BOMseen = true;
|
|
245
|
-
code_points.shift();
|
|
246
|
-
} else {
|
|
247
|
-
this._BOMseen = true;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return codePointsToString(code_points);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
function TextEncoder3(encoding, options) {
|
|
255
|
-
if (!(this instanceof TextEncoder3))
|
|
256
|
-
return new TextEncoder3(encoding, options);
|
|
257
|
-
encoding = encoding !== void 0 ? String(encoding).toLowerCase() : DEFAULT_ENCODING;
|
|
258
|
-
if (encoding !== DEFAULT_ENCODING) {
|
|
259
|
-
throw new Error("Encoding not supported. Only utf-8 is supported");
|
|
260
|
-
}
|
|
261
|
-
options = ToDictionary(options);
|
|
262
|
-
this._streaming = false;
|
|
263
|
-
this._encoder = null;
|
|
264
|
-
this._options = { fatal: Boolean(options["fatal"]) };
|
|
265
|
-
Object.defineProperty(this, "encoding", { value: "utf-8" });
|
|
266
|
-
}
|
|
267
|
-
TextEncoder3.prototype = {
|
|
268
|
-
/**
|
|
269
|
-
* @param {string=} opt_string The string to encode.
|
|
270
|
-
* @param {Object=} options
|
|
271
|
-
* @return {Uint8Array} Encoded bytes, as a Uint8Array.
|
|
272
|
-
*/
|
|
273
|
-
encode: function encode(opt_string, options) {
|
|
274
|
-
opt_string = opt_string ? String(opt_string) : "";
|
|
275
|
-
options = ToDictionary(options);
|
|
276
|
-
if (!this._streaming)
|
|
277
|
-
this._encoder = new UTF8Encoder(this._options);
|
|
278
|
-
this._streaming = Boolean(options["stream"]);
|
|
279
|
-
var bytes = [];
|
|
280
|
-
var input_stream = new Stream(stringToCodePoints(opt_string));
|
|
281
|
-
var result;
|
|
282
|
-
while (!input_stream.endOfStream()) {
|
|
283
|
-
result = this._encoder.handler(input_stream, input_stream.read());
|
|
284
|
-
if (result === finished)
|
|
285
|
-
break;
|
|
286
|
-
if (Array.isArray(result))
|
|
287
|
-
bytes.push.apply(
|
|
288
|
-
bytes,
|
|
289
|
-
/**@type {!Array.<number>}*/
|
|
290
|
-
result
|
|
291
|
-
);
|
|
292
|
-
else
|
|
293
|
-
bytes.push(result);
|
|
294
|
-
}
|
|
295
|
-
if (!this._streaming) {
|
|
296
|
-
while (true) {
|
|
297
|
-
result = this._encoder.handler(input_stream, input_stream.read());
|
|
298
|
-
if (result === finished)
|
|
299
|
-
break;
|
|
300
|
-
if (Array.isArray(result))
|
|
301
|
-
bytes.push.apply(
|
|
302
|
-
bytes,
|
|
303
|
-
/**@type {!Array.<number>}*/
|
|
304
|
-
result
|
|
305
|
-
);
|
|
306
|
-
else
|
|
307
|
-
bytes.push(result);
|
|
308
|
-
}
|
|
309
|
-
this._encoder = null;
|
|
310
|
-
}
|
|
311
|
-
return new Uint8Array(bytes);
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
function UTF8Decoder(options) {
|
|
315
|
-
var fatal = options.fatal;
|
|
316
|
-
var utf8_code_point = 0, utf8_bytes_seen = 0, utf8_bytes_needed = 0, utf8_lower_boundary = 128, utf8_upper_boundary = 191;
|
|
317
|
-
this.handler = function(stream, bite) {
|
|
318
|
-
if (bite === end_of_stream && utf8_bytes_needed !== 0) {
|
|
319
|
-
utf8_bytes_needed = 0;
|
|
320
|
-
return decoderError(fatal);
|
|
321
|
-
}
|
|
322
|
-
if (bite === end_of_stream)
|
|
323
|
-
return finished;
|
|
324
|
-
if (utf8_bytes_needed === 0) {
|
|
325
|
-
if (inRange(bite, 0, 127)) {
|
|
326
|
-
return bite;
|
|
327
|
-
}
|
|
328
|
-
if (inRange(bite, 194, 223)) {
|
|
329
|
-
utf8_bytes_needed = 1;
|
|
330
|
-
utf8_code_point = bite - 192;
|
|
331
|
-
} else if (inRange(bite, 224, 239)) {
|
|
332
|
-
if (bite === 224)
|
|
333
|
-
utf8_lower_boundary = 160;
|
|
334
|
-
if (bite === 237)
|
|
335
|
-
utf8_upper_boundary = 159;
|
|
336
|
-
utf8_bytes_needed = 2;
|
|
337
|
-
utf8_code_point = bite - 224;
|
|
338
|
-
} else if (inRange(bite, 240, 244)) {
|
|
339
|
-
if (bite === 240)
|
|
340
|
-
utf8_lower_boundary = 144;
|
|
341
|
-
if (bite === 244)
|
|
342
|
-
utf8_upper_boundary = 143;
|
|
343
|
-
utf8_bytes_needed = 3;
|
|
344
|
-
utf8_code_point = bite - 240;
|
|
345
|
-
} else {
|
|
346
|
-
return decoderError(fatal);
|
|
347
|
-
}
|
|
348
|
-
utf8_code_point = utf8_code_point << 6 * utf8_bytes_needed;
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {
|
|
352
|
-
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
353
|
-
utf8_lower_boundary = 128;
|
|
354
|
-
utf8_upper_boundary = 191;
|
|
355
|
-
stream.prepend(bite);
|
|
356
|
-
return decoderError(fatal);
|
|
357
|
-
}
|
|
358
|
-
utf8_lower_boundary = 128;
|
|
359
|
-
utf8_upper_boundary = 191;
|
|
360
|
-
utf8_bytes_seen += 1;
|
|
361
|
-
utf8_code_point += bite - 128 << 6 * (utf8_bytes_needed - utf8_bytes_seen);
|
|
362
|
-
if (utf8_bytes_seen !== utf8_bytes_needed)
|
|
363
|
-
return null;
|
|
364
|
-
var code_point = utf8_code_point;
|
|
365
|
-
utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;
|
|
366
|
-
return code_point;
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
function UTF8Encoder(options) {
|
|
370
|
-
var fatal = options.fatal;
|
|
371
|
-
this.handler = function(stream, code_point) {
|
|
372
|
-
if (code_point === end_of_stream)
|
|
373
|
-
return finished;
|
|
374
|
-
if (inRange(code_point, 0, 127))
|
|
375
|
-
return code_point;
|
|
376
|
-
var count, offset;
|
|
377
|
-
if (inRange(code_point, 128, 2047)) {
|
|
378
|
-
count = 1;
|
|
379
|
-
offset = 192;
|
|
380
|
-
} else if (inRange(code_point, 2048, 65535)) {
|
|
381
|
-
count = 2;
|
|
382
|
-
offset = 224;
|
|
383
|
-
} else if (inRange(code_point, 65536, 1114111)) {
|
|
384
|
-
count = 3;
|
|
385
|
-
offset = 240;
|
|
386
|
-
}
|
|
387
|
-
var bytes = [(code_point >> 6 * count) + offset];
|
|
388
|
-
while (count > 0) {
|
|
389
|
-
var temp = code_point >> 6 * (count - 1);
|
|
390
|
-
bytes.push(128 | temp & 63);
|
|
391
|
-
count -= 1;
|
|
392
|
-
}
|
|
393
|
-
return bytes;
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
exports.TextEncoder = TextEncoder3;
|
|
397
|
-
exports.TextDecoder = TextDecoder3;
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
34
|
// ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
|
|
402
35
|
var require_base64_js = __commonJS({
|
|
403
36
|
"../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
|
|
@@ -5841,6 +5474,9 @@ var bridge = (() => {
|
|
|
5841
5474
|
var index_exports = {};
|
|
5842
5475
|
__export(index_exports, {
|
|
5843
5476
|
Buffer: () => Buffer3,
|
|
5477
|
+
CustomEvent: () => CustomEvent,
|
|
5478
|
+
Event: () => Event,
|
|
5479
|
+
EventTarget: () => EventTarget,
|
|
5844
5480
|
Module: () => Module,
|
|
5845
5481
|
ProcessExitError: () => ProcessExitError,
|
|
5846
5482
|
SourceMap: () => SourceMap,
|
|
@@ -5871,7 +5507,118 @@ var bridge = (() => {
|
|
|
5871
5507
|
});
|
|
5872
5508
|
|
|
5873
5509
|
// src/bridge/polyfills.ts
|
|
5874
|
-
|
|
5510
|
+
function defineGlobal(name, value) {
|
|
5511
|
+
globalThis[name] = value;
|
|
5512
|
+
}
|
|
5513
|
+
if (typeof globalThis.global === "undefined") {
|
|
5514
|
+
defineGlobal("global", globalThis);
|
|
5515
|
+
}
|
|
5516
|
+
if (typeof globalThis.RegExp === "function" && !("__secureExecRgiEmojiCompat" in globalThis.RegExp)) {
|
|
5517
|
+
const NativeRegExp = globalThis.RegExp;
|
|
5518
|
+
const rgiEmojiPattern = "^\\p{RGI_Emoji}$";
|
|
5519
|
+
const rgiEmojiBaseClass = "[\\u{00A9}\\u{00AE}\\u{203C}\\u{2049}\\u{2122}\\u{2139}\\u{2194}-\\u{21AA}\\u{231A}-\\u{23FF}\\u{24C2}\\u{25AA}-\\u{27BF}\\u{2934}-\\u{2935}\\u{2B05}-\\u{2B55}\\u{3030}\\u{303D}\\u{3297}\\u{3299}\\u{1F000}-\\u{1FAFF}]";
|
|
5520
|
+
const rgiEmojiKeycap = "[#*0-9]\\uFE0F?\\u20E3";
|
|
5521
|
+
const rgiEmojiFallbackSource = "^(?:" + rgiEmojiKeycap + "|\\p{Regional_Indicator}{2}|" + rgiEmojiBaseClass + "(?:\\uFE0F|\\u200D(?:" + rgiEmojiKeycap + "|" + rgiEmojiBaseClass + ")|[\\u{1F3FB}-\\u{1F3FF}])*)$";
|
|
5522
|
+
try {
|
|
5523
|
+
new NativeRegExp(rgiEmojiPattern, "v");
|
|
5524
|
+
} catch (error) {
|
|
5525
|
+
if (String(error?.message ?? error).includes("RGI_Emoji")) {
|
|
5526
|
+
const CompatRegExp = function CompatRegExp2(pattern, flags) {
|
|
5527
|
+
const normalizedPattern = pattern instanceof NativeRegExp && flags === void 0 ? pattern.source : String(pattern);
|
|
5528
|
+
const normalizedFlags = flags === void 0 ? pattern instanceof NativeRegExp ? pattern.flags : "" : String(flags);
|
|
5529
|
+
try {
|
|
5530
|
+
return new NativeRegExp(pattern, flags);
|
|
5531
|
+
} catch (innerError) {
|
|
5532
|
+
if (normalizedPattern === rgiEmojiPattern && normalizedFlags === "v") {
|
|
5533
|
+
return new NativeRegExp(rgiEmojiFallbackSource, "u");
|
|
5534
|
+
}
|
|
5535
|
+
throw innerError;
|
|
5536
|
+
}
|
|
5537
|
+
};
|
|
5538
|
+
Object.setPrototypeOf(CompatRegExp, NativeRegExp);
|
|
5539
|
+
CompatRegExp.prototype = NativeRegExp.prototype;
|
|
5540
|
+
Object.defineProperty(CompatRegExp.prototype, "constructor", {
|
|
5541
|
+
value: CompatRegExp,
|
|
5542
|
+
writable: true,
|
|
5543
|
+
configurable: true
|
|
5544
|
+
});
|
|
5545
|
+
defineGlobal(
|
|
5546
|
+
"RegExp",
|
|
5547
|
+
Object.assign(CompatRegExp, { __secureExecRgiEmojiCompat: true })
|
|
5548
|
+
);
|
|
5549
|
+
}
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
function withCode(error, code) {
|
|
5553
|
+
error.code = code;
|
|
5554
|
+
return error;
|
|
5555
|
+
}
|
|
5556
|
+
function createEncodingNotSupportedError(label) {
|
|
5557
|
+
return withCode(
|
|
5558
|
+
new RangeError(`The "${label}" encoding is not supported`),
|
|
5559
|
+
"ERR_ENCODING_NOT_SUPPORTED"
|
|
5560
|
+
);
|
|
5561
|
+
}
|
|
5562
|
+
function createEncodingInvalidDataError(encoding) {
|
|
5563
|
+
return withCode(
|
|
5564
|
+
new TypeError(`The encoded data was not valid for encoding ${encoding}`),
|
|
5565
|
+
"ERR_ENCODING_INVALID_ENCODED_DATA"
|
|
5566
|
+
);
|
|
5567
|
+
}
|
|
5568
|
+
function createInvalidDecodeInputError() {
|
|
5569
|
+
return withCode(
|
|
5570
|
+
new TypeError(
|
|
5571
|
+
'The "input" argument must be an instance of ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.'
|
|
5572
|
+
),
|
|
5573
|
+
"ERR_INVALID_ARG_TYPE"
|
|
5574
|
+
);
|
|
5575
|
+
}
|
|
5576
|
+
function trimAsciiWhitespace(value) {
|
|
5577
|
+
return value.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
|
|
5578
|
+
}
|
|
5579
|
+
function normalizeEncodingLabel(label) {
|
|
5580
|
+
const normalized = trimAsciiWhitespace(
|
|
5581
|
+
label === void 0 ? "utf-8" : String(label)
|
|
5582
|
+
).toLowerCase();
|
|
5583
|
+
switch (normalized) {
|
|
5584
|
+
case "utf-8":
|
|
5585
|
+
case "utf8":
|
|
5586
|
+
case "unicode-1-1-utf-8":
|
|
5587
|
+
case "unicode11utf8":
|
|
5588
|
+
case "unicode20utf8":
|
|
5589
|
+
case "x-unicode20utf8":
|
|
5590
|
+
return "utf-8";
|
|
5591
|
+
case "utf-16":
|
|
5592
|
+
case "utf-16le":
|
|
5593
|
+
case "ucs-2":
|
|
5594
|
+
case "ucs2":
|
|
5595
|
+
case "csunicode":
|
|
5596
|
+
case "iso-10646-ucs-2":
|
|
5597
|
+
case "unicode":
|
|
5598
|
+
case "unicodefeff":
|
|
5599
|
+
return "utf-16le";
|
|
5600
|
+
case "utf-16be":
|
|
5601
|
+
case "unicodefffe":
|
|
5602
|
+
return "utf-16be";
|
|
5603
|
+
default:
|
|
5604
|
+
throw createEncodingNotSupportedError(normalized);
|
|
5605
|
+
}
|
|
5606
|
+
}
|
|
5607
|
+
function toUint8Array(input) {
|
|
5608
|
+
if (input === void 0) {
|
|
5609
|
+
return new Uint8Array(0);
|
|
5610
|
+
}
|
|
5611
|
+
if (ArrayBuffer.isView(input)) {
|
|
5612
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
5613
|
+
}
|
|
5614
|
+
if (input instanceof ArrayBuffer) {
|
|
5615
|
+
return new Uint8Array(input);
|
|
5616
|
+
}
|
|
5617
|
+
if (typeof SharedArrayBuffer !== "undefined" && input instanceof SharedArrayBuffer) {
|
|
5618
|
+
return new Uint8Array(input);
|
|
5619
|
+
}
|
|
5620
|
+
throw createInvalidDecodeInputError();
|
|
5621
|
+
}
|
|
5875
5622
|
function encodeUtf8ScalarValue(codePoint, bytes) {
|
|
5876
5623
|
if (codePoint <= 127) {
|
|
5877
5624
|
bytes.push(codePoint);
|
|
@@ -5923,22 +5670,514 @@ var bridge = (() => {
|
|
|
5923
5670
|
}
|
|
5924
5671
|
return new Uint8Array(bytes);
|
|
5925
5672
|
}
|
|
5673
|
+
function appendCodePoint(output, codePoint) {
|
|
5674
|
+
if (codePoint <= 65535) {
|
|
5675
|
+
output.push(String.fromCharCode(codePoint));
|
|
5676
|
+
return;
|
|
5677
|
+
}
|
|
5678
|
+
const adjusted = codePoint - 65536;
|
|
5679
|
+
output.push(
|
|
5680
|
+
String.fromCharCode(55296 + (adjusted >> 10)),
|
|
5681
|
+
String.fromCharCode(56320 + (adjusted & 1023))
|
|
5682
|
+
);
|
|
5683
|
+
}
|
|
5684
|
+
function isContinuationByte(value) {
|
|
5685
|
+
return value >= 128 && value <= 191;
|
|
5686
|
+
}
|
|
5687
|
+
function decodeUtf8(bytes, fatal, stream, encoding) {
|
|
5688
|
+
const output = [];
|
|
5689
|
+
for (let index = 0; index < bytes.length; ) {
|
|
5690
|
+
const first = bytes[index];
|
|
5691
|
+
if (first <= 127) {
|
|
5692
|
+
output.push(String.fromCharCode(first));
|
|
5693
|
+
index += 1;
|
|
5694
|
+
continue;
|
|
5695
|
+
}
|
|
5696
|
+
let needed = 0;
|
|
5697
|
+
let codePoint = 0;
|
|
5698
|
+
if (first >= 194 && first <= 223) {
|
|
5699
|
+
needed = 1;
|
|
5700
|
+
codePoint = first & 31;
|
|
5701
|
+
} else if (first >= 224 && first <= 239) {
|
|
5702
|
+
needed = 2;
|
|
5703
|
+
codePoint = first & 15;
|
|
5704
|
+
} else if (first >= 240 && first <= 244) {
|
|
5705
|
+
needed = 3;
|
|
5706
|
+
codePoint = first & 7;
|
|
5707
|
+
} else {
|
|
5708
|
+
if (fatal) {
|
|
5709
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5710
|
+
}
|
|
5711
|
+
output.push("\uFFFD");
|
|
5712
|
+
index += 1;
|
|
5713
|
+
continue;
|
|
5714
|
+
}
|
|
5715
|
+
if (index + needed >= bytes.length) {
|
|
5716
|
+
if (stream) {
|
|
5717
|
+
return {
|
|
5718
|
+
text: output.join(""),
|
|
5719
|
+
pending: Array.from(bytes.slice(index))
|
|
5720
|
+
};
|
|
5721
|
+
}
|
|
5722
|
+
if (fatal) {
|
|
5723
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5724
|
+
}
|
|
5725
|
+
output.push("\uFFFD");
|
|
5726
|
+
break;
|
|
5727
|
+
}
|
|
5728
|
+
const second = bytes[index + 1];
|
|
5729
|
+
if (!isContinuationByte(second)) {
|
|
5730
|
+
if (fatal) {
|
|
5731
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5732
|
+
}
|
|
5733
|
+
output.push("\uFFFD");
|
|
5734
|
+
index += 1;
|
|
5735
|
+
continue;
|
|
5736
|
+
}
|
|
5737
|
+
if (first === 224 && second < 160 || first === 237 && second > 159 || first === 240 && second < 144 || first === 244 && second > 143) {
|
|
5738
|
+
if (fatal) {
|
|
5739
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5740
|
+
}
|
|
5741
|
+
output.push("\uFFFD");
|
|
5742
|
+
index += 1;
|
|
5743
|
+
continue;
|
|
5744
|
+
}
|
|
5745
|
+
codePoint = codePoint << 6 | second & 63;
|
|
5746
|
+
if (needed >= 2) {
|
|
5747
|
+
const third = bytes[index + 2];
|
|
5748
|
+
if (!isContinuationByte(third)) {
|
|
5749
|
+
if (fatal) {
|
|
5750
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5751
|
+
}
|
|
5752
|
+
output.push("\uFFFD");
|
|
5753
|
+
index += 1;
|
|
5754
|
+
continue;
|
|
5755
|
+
}
|
|
5756
|
+
codePoint = codePoint << 6 | third & 63;
|
|
5757
|
+
}
|
|
5758
|
+
if (needed === 3) {
|
|
5759
|
+
const fourth = bytes[index + 3];
|
|
5760
|
+
if (!isContinuationByte(fourth)) {
|
|
5761
|
+
if (fatal) {
|
|
5762
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5763
|
+
}
|
|
5764
|
+
output.push("\uFFFD");
|
|
5765
|
+
index += 1;
|
|
5766
|
+
continue;
|
|
5767
|
+
}
|
|
5768
|
+
codePoint = codePoint << 6 | fourth & 63;
|
|
5769
|
+
}
|
|
5770
|
+
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
5771
|
+
if (fatal) {
|
|
5772
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5773
|
+
}
|
|
5774
|
+
output.push("\uFFFD");
|
|
5775
|
+
index += needed + 1;
|
|
5776
|
+
continue;
|
|
5777
|
+
}
|
|
5778
|
+
appendCodePoint(output, codePoint);
|
|
5779
|
+
index += needed + 1;
|
|
5780
|
+
}
|
|
5781
|
+
return { text: output.join(""), pending: [] };
|
|
5782
|
+
}
|
|
5783
|
+
function decodeUtf16(bytes, encoding, fatal, stream, bomSeen) {
|
|
5784
|
+
const output = [];
|
|
5785
|
+
let endian = encoding === "utf-16be" ? "be" : "le";
|
|
5786
|
+
if (!bomSeen && encoding === "utf-16le" && bytes.length >= 2) {
|
|
5787
|
+
if (bytes[0] === 254 && bytes[1] === 255) {
|
|
5788
|
+
endian = "be";
|
|
5789
|
+
}
|
|
5790
|
+
}
|
|
5791
|
+
for (let index = 0; index < bytes.length; ) {
|
|
5792
|
+
if (index + 1 >= bytes.length) {
|
|
5793
|
+
if (stream) {
|
|
5794
|
+
return {
|
|
5795
|
+
text: output.join(""),
|
|
5796
|
+
pending: Array.from(bytes.slice(index))
|
|
5797
|
+
};
|
|
5798
|
+
}
|
|
5799
|
+
if (fatal) {
|
|
5800
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5801
|
+
}
|
|
5802
|
+
output.push("\uFFFD");
|
|
5803
|
+
break;
|
|
5804
|
+
}
|
|
5805
|
+
const first = bytes[index];
|
|
5806
|
+
const second = bytes[index + 1];
|
|
5807
|
+
const codeUnit = endian === "le" ? first | second << 8 : first << 8 | second;
|
|
5808
|
+
index += 2;
|
|
5809
|
+
if (codeUnit >= 55296 && codeUnit <= 56319) {
|
|
5810
|
+
if (index + 1 >= bytes.length) {
|
|
5811
|
+
if (stream) {
|
|
5812
|
+
return {
|
|
5813
|
+
text: output.join(""),
|
|
5814
|
+
pending: Array.from(bytes.slice(index - 2))
|
|
5815
|
+
};
|
|
5816
|
+
}
|
|
5817
|
+
if (fatal) {
|
|
5818
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5819
|
+
}
|
|
5820
|
+
output.push("\uFFFD");
|
|
5821
|
+
continue;
|
|
5822
|
+
}
|
|
5823
|
+
const nextFirst = bytes[index];
|
|
5824
|
+
const nextSecond = bytes[index + 1];
|
|
5825
|
+
const nextCodeUnit = endian === "le" ? nextFirst | nextSecond << 8 : nextFirst << 8 | nextSecond;
|
|
5826
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
5827
|
+
const codePoint = 65536 + (codeUnit - 55296 << 10) + (nextCodeUnit - 56320);
|
|
5828
|
+
appendCodePoint(output, codePoint);
|
|
5829
|
+
index += 2;
|
|
5830
|
+
continue;
|
|
5831
|
+
}
|
|
5832
|
+
if (fatal) {
|
|
5833
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5834
|
+
}
|
|
5835
|
+
output.push("\uFFFD");
|
|
5836
|
+
continue;
|
|
5837
|
+
}
|
|
5838
|
+
if (codeUnit >= 56320 && codeUnit <= 57343) {
|
|
5839
|
+
if (fatal) {
|
|
5840
|
+
throw createEncodingInvalidDataError(encoding);
|
|
5841
|
+
}
|
|
5842
|
+
output.push("\uFFFD");
|
|
5843
|
+
continue;
|
|
5844
|
+
}
|
|
5845
|
+
output.push(String.fromCharCode(codeUnit));
|
|
5846
|
+
}
|
|
5847
|
+
return { text: output.join(""), pending: [] };
|
|
5848
|
+
}
|
|
5926
5849
|
var PatchedTextEncoder = class {
|
|
5927
5850
|
encode(input = "") {
|
|
5928
5851
|
return encodeUtf8(input);
|
|
5929
5852
|
}
|
|
5853
|
+
encodeInto(input, destination) {
|
|
5854
|
+
const value = String(input);
|
|
5855
|
+
let read = 0;
|
|
5856
|
+
let written = 0;
|
|
5857
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
5858
|
+
const codeUnit = value.charCodeAt(index);
|
|
5859
|
+
let chunk = "";
|
|
5860
|
+
if (codeUnit >= 55296 && codeUnit <= 56319 && index + 1 < value.length) {
|
|
5861
|
+
const nextCodeUnit = value.charCodeAt(index + 1);
|
|
5862
|
+
if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
|
|
5863
|
+
chunk = value.slice(index, index + 2);
|
|
5864
|
+
}
|
|
5865
|
+
}
|
|
5866
|
+
if (chunk === "") {
|
|
5867
|
+
chunk = value[index] ?? "";
|
|
5868
|
+
}
|
|
5869
|
+
const encoded = encodeUtf8(chunk);
|
|
5870
|
+
if (written + encoded.length > destination.length) {
|
|
5871
|
+
break;
|
|
5872
|
+
}
|
|
5873
|
+
destination.set(encoded, written);
|
|
5874
|
+
written += encoded.length;
|
|
5875
|
+
read += chunk.length;
|
|
5876
|
+
if (chunk.length === 2) {
|
|
5877
|
+
index += 1;
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
return { read, written };
|
|
5881
|
+
}
|
|
5930
5882
|
get encoding() {
|
|
5931
5883
|
return "utf-8";
|
|
5932
5884
|
}
|
|
5885
|
+
get [Symbol.toStringTag]() {
|
|
5886
|
+
return "TextEncoder";
|
|
5887
|
+
}
|
|
5888
|
+
};
|
|
5889
|
+
var PatchedTextDecoder = class {
|
|
5890
|
+
normalizedEncoding;
|
|
5891
|
+
fatalFlag;
|
|
5892
|
+
ignoreBOMFlag;
|
|
5893
|
+
pendingBytes = [];
|
|
5894
|
+
bomSeen = false;
|
|
5895
|
+
constructor(label, options) {
|
|
5896
|
+
const normalizedOptions = options == null ? {} : Object(options);
|
|
5897
|
+
this.normalizedEncoding = normalizeEncodingLabel(label);
|
|
5898
|
+
this.fatalFlag = Boolean(
|
|
5899
|
+
normalizedOptions.fatal
|
|
5900
|
+
);
|
|
5901
|
+
this.ignoreBOMFlag = Boolean(
|
|
5902
|
+
normalizedOptions.ignoreBOM
|
|
5903
|
+
);
|
|
5904
|
+
}
|
|
5905
|
+
get encoding() {
|
|
5906
|
+
return this.normalizedEncoding;
|
|
5907
|
+
}
|
|
5908
|
+
get fatal() {
|
|
5909
|
+
return this.fatalFlag;
|
|
5910
|
+
}
|
|
5911
|
+
get ignoreBOM() {
|
|
5912
|
+
return this.ignoreBOMFlag;
|
|
5913
|
+
}
|
|
5914
|
+
get [Symbol.toStringTag]() {
|
|
5915
|
+
return "TextDecoder";
|
|
5916
|
+
}
|
|
5917
|
+
decode(input, options) {
|
|
5918
|
+
const normalizedOptions = options == null ? {} : Object(options);
|
|
5919
|
+
const stream = Boolean(
|
|
5920
|
+
normalizedOptions.stream
|
|
5921
|
+
);
|
|
5922
|
+
const incoming = toUint8Array(input);
|
|
5923
|
+
const merged = new Uint8Array(this.pendingBytes.length + incoming.length);
|
|
5924
|
+
merged.set(this.pendingBytes, 0);
|
|
5925
|
+
merged.set(incoming, this.pendingBytes.length);
|
|
5926
|
+
const decoded = this.normalizedEncoding === "utf-8" ? decodeUtf8(
|
|
5927
|
+
merged,
|
|
5928
|
+
this.fatalFlag,
|
|
5929
|
+
stream,
|
|
5930
|
+
this.normalizedEncoding
|
|
5931
|
+
) : decodeUtf16(
|
|
5932
|
+
merged,
|
|
5933
|
+
this.normalizedEncoding,
|
|
5934
|
+
this.fatalFlag,
|
|
5935
|
+
stream,
|
|
5936
|
+
this.bomSeen
|
|
5937
|
+
);
|
|
5938
|
+
this.pendingBytes = decoded.pending;
|
|
5939
|
+
let text = decoded.text;
|
|
5940
|
+
if (!this.bomSeen && text.length > 0) {
|
|
5941
|
+
if (!this.ignoreBOMFlag && text.charCodeAt(0) === 65279) {
|
|
5942
|
+
text = text.slice(1);
|
|
5943
|
+
}
|
|
5944
|
+
this.bomSeen = true;
|
|
5945
|
+
}
|
|
5946
|
+
if (!stream && this.pendingBytes.length > 0) {
|
|
5947
|
+
const pending = this.pendingBytes;
|
|
5948
|
+
this.pendingBytes = [];
|
|
5949
|
+
if (this.fatalFlag) {
|
|
5950
|
+
throw createEncodingInvalidDataError(this.normalizedEncoding);
|
|
5951
|
+
}
|
|
5952
|
+
return text + "\uFFFD".repeat(Math.ceil(pending.length / 2));
|
|
5953
|
+
}
|
|
5954
|
+
return text;
|
|
5955
|
+
}
|
|
5933
5956
|
};
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5957
|
+
function normalizeAddEventListenerOptions(options) {
|
|
5958
|
+
if (typeof options === "boolean") {
|
|
5959
|
+
return {
|
|
5960
|
+
capture: options,
|
|
5961
|
+
once: false,
|
|
5962
|
+
passive: false
|
|
5963
|
+
};
|
|
5964
|
+
}
|
|
5965
|
+
if (options == null) {
|
|
5966
|
+
return {
|
|
5967
|
+
capture: false,
|
|
5968
|
+
once: false,
|
|
5969
|
+
passive: false
|
|
5970
|
+
};
|
|
5971
|
+
}
|
|
5972
|
+
const normalized = Object(options);
|
|
5973
|
+
return {
|
|
5974
|
+
capture: Boolean(normalized.capture),
|
|
5975
|
+
once: Boolean(normalized.once),
|
|
5976
|
+
passive: Boolean(normalized.passive),
|
|
5977
|
+
signal: normalized.signal
|
|
5978
|
+
};
|
|
5938
5979
|
}
|
|
5939
|
-
|
|
5940
|
-
|
|
5980
|
+
function normalizeRemoveEventListenerOptions(options) {
|
|
5981
|
+
if (typeof options === "boolean") {
|
|
5982
|
+
return options;
|
|
5983
|
+
}
|
|
5984
|
+
if (options == null) {
|
|
5985
|
+
return false;
|
|
5986
|
+
}
|
|
5987
|
+
return Boolean(Object(options).capture);
|
|
5988
|
+
}
|
|
5989
|
+
function isAbortSignalLike(value) {
|
|
5990
|
+
return typeof value === "object" && value !== null && "aborted" in value && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function";
|
|
5941
5991
|
}
|
|
5992
|
+
var PatchedEvent = class {
|
|
5993
|
+
static NONE = 0;
|
|
5994
|
+
static CAPTURING_PHASE = 1;
|
|
5995
|
+
static AT_TARGET = 2;
|
|
5996
|
+
static BUBBLING_PHASE = 3;
|
|
5997
|
+
type;
|
|
5998
|
+
bubbles;
|
|
5999
|
+
cancelable;
|
|
6000
|
+
composed;
|
|
6001
|
+
detail = null;
|
|
6002
|
+
defaultPrevented = false;
|
|
6003
|
+
target = null;
|
|
6004
|
+
currentTarget = null;
|
|
6005
|
+
eventPhase = 0;
|
|
6006
|
+
returnValue = true;
|
|
6007
|
+
cancelBubble = false;
|
|
6008
|
+
timeStamp = Date.now();
|
|
6009
|
+
isTrusted = false;
|
|
6010
|
+
srcElement = null;
|
|
6011
|
+
inPassiveListener = false;
|
|
6012
|
+
propagationStopped = false;
|
|
6013
|
+
immediatePropagationStopped = false;
|
|
6014
|
+
constructor(type, init) {
|
|
6015
|
+
if (arguments.length === 0) {
|
|
6016
|
+
throw new TypeError("The event type must be provided");
|
|
6017
|
+
}
|
|
6018
|
+
const normalizedInit = init == null ? {} : Object(init);
|
|
6019
|
+
this.type = String(type);
|
|
6020
|
+
this.bubbles = Boolean(normalizedInit.bubbles);
|
|
6021
|
+
this.cancelable = Boolean(normalizedInit.cancelable);
|
|
6022
|
+
this.composed = Boolean(normalizedInit.composed);
|
|
6023
|
+
}
|
|
6024
|
+
get [Symbol.toStringTag]() {
|
|
6025
|
+
return "Event";
|
|
6026
|
+
}
|
|
6027
|
+
preventDefault() {
|
|
6028
|
+
if (this.cancelable && !this.inPassiveListener) {
|
|
6029
|
+
this.defaultPrevented = true;
|
|
6030
|
+
this.returnValue = false;
|
|
6031
|
+
}
|
|
6032
|
+
}
|
|
6033
|
+
stopPropagation() {
|
|
6034
|
+
this.propagationStopped = true;
|
|
6035
|
+
this.cancelBubble = true;
|
|
6036
|
+
}
|
|
6037
|
+
stopImmediatePropagation() {
|
|
6038
|
+
this.propagationStopped = true;
|
|
6039
|
+
this.immediatePropagationStopped = true;
|
|
6040
|
+
this.cancelBubble = true;
|
|
6041
|
+
}
|
|
6042
|
+
composedPath() {
|
|
6043
|
+
return this.target ? [this.target] : [];
|
|
6044
|
+
}
|
|
6045
|
+
_setPassive(value) {
|
|
6046
|
+
this.inPassiveListener = value;
|
|
6047
|
+
}
|
|
6048
|
+
_isPropagationStopped() {
|
|
6049
|
+
return this.propagationStopped;
|
|
6050
|
+
}
|
|
6051
|
+
_isImmediatePropagationStopped() {
|
|
6052
|
+
return this.immediatePropagationStopped;
|
|
6053
|
+
}
|
|
6054
|
+
};
|
|
6055
|
+
var PatchedCustomEvent = class extends PatchedEvent {
|
|
6056
|
+
constructor(type, init) {
|
|
6057
|
+
super(type, init);
|
|
6058
|
+
const normalizedInit = init == null ? null : Object(init);
|
|
6059
|
+
this.detail = normalizedInit && "detail" in normalizedInit ? normalizedInit.detail : null;
|
|
6060
|
+
}
|
|
6061
|
+
get [Symbol.toStringTag]() {
|
|
6062
|
+
return "CustomEvent";
|
|
6063
|
+
}
|
|
6064
|
+
};
|
|
6065
|
+
var PatchedEventTarget = class {
|
|
6066
|
+
listeners = /* @__PURE__ */ new Map();
|
|
6067
|
+
addEventListener(type, listener, options) {
|
|
6068
|
+
const normalized = normalizeAddEventListenerOptions(options);
|
|
6069
|
+
if (normalized.signal !== void 0 && !isAbortSignalLike(normalized.signal)) {
|
|
6070
|
+
throw new TypeError(
|
|
6071
|
+
'The "signal" option must be an instance of AbortSignal.'
|
|
6072
|
+
);
|
|
6073
|
+
}
|
|
6074
|
+
if (listener == null) {
|
|
6075
|
+
return void 0;
|
|
6076
|
+
}
|
|
6077
|
+
if (typeof listener !== "function" && (typeof listener !== "object" || listener === null)) {
|
|
6078
|
+
return void 0;
|
|
6079
|
+
}
|
|
6080
|
+
if (normalized.signal?.aborted) {
|
|
6081
|
+
return void 0;
|
|
6082
|
+
}
|
|
6083
|
+
const records = this.listeners.get(type) ?? [];
|
|
6084
|
+
const existing = records.find(
|
|
6085
|
+
(record2) => record2.listener === listener && record2.capture === normalized.capture
|
|
6086
|
+
);
|
|
6087
|
+
if (existing) {
|
|
6088
|
+
return void 0;
|
|
6089
|
+
}
|
|
6090
|
+
const record = {
|
|
6091
|
+
listener,
|
|
6092
|
+
capture: normalized.capture,
|
|
6093
|
+
once: normalized.once,
|
|
6094
|
+
passive: normalized.passive,
|
|
6095
|
+
kind: typeof listener === "function" ? "function" : "object",
|
|
6096
|
+
signal: normalized.signal
|
|
6097
|
+
};
|
|
6098
|
+
if (normalized.signal) {
|
|
6099
|
+
record.abortListener = () => {
|
|
6100
|
+
this.removeEventListener(type, listener, normalized.capture);
|
|
6101
|
+
};
|
|
6102
|
+
normalized.signal.addEventListener("abort", record.abortListener, {
|
|
6103
|
+
once: true
|
|
6104
|
+
});
|
|
6105
|
+
}
|
|
6106
|
+
records.push(record);
|
|
6107
|
+
this.listeners.set(type, records);
|
|
6108
|
+
return void 0;
|
|
6109
|
+
}
|
|
6110
|
+
removeEventListener(type, listener, options) {
|
|
6111
|
+
if (listener == null) {
|
|
6112
|
+
return;
|
|
6113
|
+
}
|
|
6114
|
+
const capture = normalizeRemoveEventListenerOptions(options);
|
|
6115
|
+
const records = this.listeners.get(type);
|
|
6116
|
+
if (!records) {
|
|
6117
|
+
return;
|
|
6118
|
+
}
|
|
6119
|
+
const nextRecords = records.filter((record) => {
|
|
6120
|
+
const match = record.listener === listener && record.capture === capture;
|
|
6121
|
+
if (match && record.signal && record.abortListener) {
|
|
6122
|
+
record.signal.removeEventListener("abort", record.abortListener);
|
|
6123
|
+
}
|
|
6124
|
+
return !match;
|
|
6125
|
+
});
|
|
6126
|
+
if (nextRecords.length === 0) {
|
|
6127
|
+
this.listeners.delete(type);
|
|
6128
|
+
return;
|
|
6129
|
+
}
|
|
6130
|
+
this.listeners.set(type, nextRecords);
|
|
6131
|
+
}
|
|
6132
|
+
dispatchEvent(event) {
|
|
6133
|
+
if (typeof event !== "object" || event === null || typeof event.type !== "string") {
|
|
6134
|
+
throw new TypeError("Argument 1 must be an Event");
|
|
6135
|
+
}
|
|
6136
|
+
const patchedEvent = event;
|
|
6137
|
+
const records = (this.listeners.get(patchedEvent.type) ?? []).slice();
|
|
6138
|
+
patchedEvent.target = this;
|
|
6139
|
+
patchedEvent.currentTarget = this;
|
|
6140
|
+
patchedEvent.eventPhase = 2;
|
|
6141
|
+
for (const record of records) {
|
|
6142
|
+
const active = this.listeners.get(patchedEvent.type)?.includes(record);
|
|
6143
|
+
if (!active) {
|
|
6144
|
+
continue;
|
|
6145
|
+
}
|
|
6146
|
+
if (record.once) {
|
|
6147
|
+
this.removeEventListener(patchedEvent.type, record.listener, record.capture);
|
|
6148
|
+
}
|
|
6149
|
+
patchedEvent._setPassive(record.passive);
|
|
6150
|
+
if (record.kind === "function") {
|
|
6151
|
+
record.listener.call(this, patchedEvent);
|
|
6152
|
+
} else {
|
|
6153
|
+
const handleEvent = record.listener.handleEvent;
|
|
6154
|
+
if (typeof handleEvent === "function") {
|
|
6155
|
+
handleEvent.call(record.listener, patchedEvent);
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
patchedEvent._setPassive(false);
|
|
6159
|
+
if (patchedEvent._isImmediatePropagationStopped()) {
|
|
6160
|
+
break;
|
|
6161
|
+
}
|
|
6162
|
+
if (patchedEvent._isPropagationStopped()) {
|
|
6163
|
+
break;
|
|
6164
|
+
}
|
|
6165
|
+
}
|
|
6166
|
+
patchedEvent.currentTarget = null;
|
|
6167
|
+
patchedEvent.eventPhase = 0;
|
|
6168
|
+
return !patchedEvent.defaultPrevented;
|
|
6169
|
+
}
|
|
6170
|
+
};
|
|
6171
|
+
var TextEncoder2 = PatchedTextEncoder;
|
|
6172
|
+
var TextDecoder2 = PatchedTextDecoder;
|
|
6173
|
+
var Event = PatchedEvent;
|
|
6174
|
+
var CustomEvent = PatchedCustomEvent;
|
|
6175
|
+
var EventTarget = PatchedEventTarget;
|
|
6176
|
+
defineGlobal("TextEncoder", TextEncoder2);
|
|
6177
|
+
defineGlobal("TextDecoder", TextDecoder2);
|
|
6178
|
+
defineGlobal("Event", Event);
|
|
6179
|
+
defineGlobal("CustomEvent", CustomEvent);
|
|
6180
|
+
defineGlobal("EventTarget", EventTarget);
|
|
5942
6181
|
|
|
5943
6182
|
// ../core/dist/shared/global-exposure.js
|
|
5944
6183
|
var NODE_CUSTOM_GLOBAL_INVENTORY = [
|
|
@@ -6422,6 +6661,11 @@ var bridge = (() => {
|
|
|
6422
6661
|
classification: "hardened",
|
|
6423
6662
|
rationale: "Host HTTP/2 session settings bridge reference."
|
|
6424
6663
|
},
|
|
6664
|
+
{
|
|
6665
|
+
name: "_networkHttp2SessionSetLocalWindowSizeRaw",
|
|
6666
|
+
classification: "hardened",
|
|
6667
|
+
rationale: "Host HTTP/2 session local-window bridge reference."
|
|
6668
|
+
},
|
|
6425
6669
|
{
|
|
6426
6670
|
name: "_networkHttp2SessionGoawayRaw",
|
|
6427
6671
|
classification: "hardened",
|
|
@@ -6443,24 +6687,59 @@ var bridge = (() => {
|
|
|
6443
6687
|
rationale: "Host HTTP/2 session lifetime bridge reference."
|
|
6444
6688
|
},
|
|
6445
6689
|
{
|
|
6446
|
-
name: "
|
|
6690
|
+
name: "_networkHttp2ServerPollRaw",
|
|
6691
|
+
classification: "hardened",
|
|
6692
|
+
rationale: "Host HTTP/2 server event-poll bridge reference."
|
|
6693
|
+
},
|
|
6694
|
+
{
|
|
6695
|
+
name: "_networkHttp2SessionPollRaw",
|
|
6696
|
+
classification: "hardened",
|
|
6697
|
+
rationale: "Host HTTP/2 session event-poll bridge reference."
|
|
6698
|
+
},
|
|
6699
|
+
{
|
|
6700
|
+
name: "_networkHttp2StreamRespondRaw",
|
|
6701
|
+
classification: "hardened",
|
|
6702
|
+
rationale: "Host HTTP/2 stream respond bridge reference."
|
|
6703
|
+
},
|
|
6704
|
+
{
|
|
6705
|
+
name: "_networkHttp2StreamPushStreamRaw",
|
|
6706
|
+
classification: "hardened",
|
|
6707
|
+
rationale: "Host HTTP/2 push stream bridge reference."
|
|
6708
|
+
},
|
|
6709
|
+
{
|
|
6710
|
+
name: "_networkHttp2StreamWriteRaw",
|
|
6711
|
+
classification: "hardened",
|
|
6712
|
+
rationale: "Host HTTP/2 stream write bridge reference."
|
|
6713
|
+
},
|
|
6714
|
+
{
|
|
6715
|
+
name: "_networkHttp2StreamEndRaw",
|
|
6716
|
+
classification: "hardened",
|
|
6717
|
+
rationale: "Host HTTP/2 stream end bridge reference."
|
|
6718
|
+
},
|
|
6719
|
+
{
|
|
6720
|
+
name: "_networkHttp2StreamCloseRaw",
|
|
6721
|
+
classification: "hardened",
|
|
6722
|
+
rationale: "Host HTTP/2 stream close bridge reference."
|
|
6723
|
+
},
|
|
6724
|
+
{
|
|
6725
|
+
name: "_networkHttp2StreamPauseRaw",
|
|
6447
6726
|
classification: "hardened",
|
|
6448
|
-
rationale: "Host HTTP/2 stream
|
|
6727
|
+
rationale: "Host HTTP/2 stream pause bridge reference."
|
|
6449
6728
|
},
|
|
6450
6729
|
{
|
|
6451
|
-
name: "
|
|
6730
|
+
name: "_networkHttp2StreamResumeRaw",
|
|
6452
6731
|
classification: "hardened",
|
|
6453
|
-
rationale: "Host HTTP/2
|
|
6732
|
+
rationale: "Host HTTP/2 stream resume bridge reference."
|
|
6454
6733
|
},
|
|
6455
6734
|
{
|
|
6456
|
-
name: "
|
|
6735
|
+
name: "_networkHttp2StreamRespondWithFileRaw",
|
|
6457
6736
|
classification: "hardened",
|
|
6458
|
-
rationale: "Host HTTP/2 stream
|
|
6737
|
+
rationale: "Host HTTP/2 stream respondWithFile bridge reference."
|
|
6459
6738
|
},
|
|
6460
6739
|
{
|
|
6461
|
-
name: "
|
|
6740
|
+
name: "_networkHttp2ServerRespondRaw",
|
|
6462
6741
|
classification: "hardened",
|
|
6463
|
-
rationale: "Host HTTP/2
|
|
6742
|
+
rationale: "Host HTTP/2 server-response bridge reference."
|
|
6464
6743
|
},
|
|
6465
6744
|
{
|
|
6466
6745
|
name: "_upgradeSocketWriteRaw",
|
|
@@ -6552,6 +6831,46 @@ var bridge = (() => {
|
|
|
6552
6831
|
classification: "hardened",
|
|
6553
6832
|
rationale: "Host net server close bridge reference."
|
|
6554
6833
|
},
|
|
6834
|
+
{
|
|
6835
|
+
name: "_dgramSocketCreateRaw",
|
|
6836
|
+
classification: "hardened",
|
|
6837
|
+
rationale: "Host dgram socket create bridge reference."
|
|
6838
|
+
},
|
|
6839
|
+
{
|
|
6840
|
+
name: "_dgramSocketBindRaw",
|
|
6841
|
+
classification: "hardened",
|
|
6842
|
+
rationale: "Host dgram socket bind bridge reference."
|
|
6843
|
+
},
|
|
6844
|
+
{
|
|
6845
|
+
name: "_dgramSocketRecvRaw",
|
|
6846
|
+
classification: "hardened",
|
|
6847
|
+
rationale: "Host dgram socket receive bridge reference."
|
|
6848
|
+
},
|
|
6849
|
+
{
|
|
6850
|
+
name: "_dgramSocketSendRaw",
|
|
6851
|
+
classification: "hardened",
|
|
6852
|
+
rationale: "Host dgram socket send bridge reference."
|
|
6853
|
+
},
|
|
6854
|
+
{
|
|
6855
|
+
name: "_dgramSocketCloseRaw",
|
|
6856
|
+
classification: "hardened",
|
|
6857
|
+
rationale: "Host dgram socket close bridge reference."
|
|
6858
|
+
},
|
|
6859
|
+
{
|
|
6860
|
+
name: "_dgramSocketAddressRaw",
|
|
6861
|
+
classification: "hardened",
|
|
6862
|
+
rationale: "Host dgram socket address bridge reference."
|
|
6863
|
+
},
|
|
6864
|
+
{
|
|
6865
|
+
name: "_dgramSocketSetBufferSizeRaw",
|
|
6866
|
+
classification: "hardened",
|
|
6867
|
+
rationale: "Host dgram socket buffer-size setter bridge reference."
|
|
6868
|
+
},
|
|
6869
|
+
{
|
|
6870
|
+
name: "_dgramSocketGetBufferSizeRaw",
|
|
6871
|
+
classification: "hardened",
|
|
6872
|
+
rationale: "Host dgram socket buffer-size getter bridge reference."
|
|
6873
|
+
},
|
|
6555
6874
|
{
|
|
6556
6875
|
name: "_batchResolveModules",
|
|
6557
6876
|
classification: "hardened",
|
|
@@ -6657,11 +6976,26 @@ var bridge = (() => {
|
|
|
6657
6976
|
classification: "hardened",
|
|
6658
6977
|
rationale: "Network Response API global \u2014 must not be replaceable by sandbox code."
|
|
6659
6978
|
},
|
|
6979
|
+
{
|
|
6980
|
+
name: "DOMException",
|
|
6981
|
+
classification: "hardened",
|
|
6982
|
+
rationale: "DOMException global stub for undici/bootstrap compatibility."
|
|
6983
|
+
},
|
|
6984
|
+
{
|
|
6985
|
+
name: "__importMetaResolve",
|
|
6986
|
+
classification: "hardened",
|
|
6987
|
+
rationale: "Internal import.meta.resolve helper for transformed ESM modules."
|
|
6988
|
+
},
|
|
6660
6989
|
{
|
|
6661
6990
|
name: "Blob",
|
|
6662
6991
|
classification: "hardened",
|
|
6663
6992
|
rationale: "Blob API global stub \u2014 must not be replaceable by sandbox code."
|
|
6664
6993
|
},
|
|
6994
|
+
{
|
|
6995
|
+
name: "File",
|
|
6996
|
+
classification: "hardened",
|
|
6997
|
+
rationale: "File API global stub \u2014 must not be replaceable by sandbox code."
|
|
6998
|
+
},
|
|
6665
6999
|
{
|
|
6666
7000
|
name: "FormData",
|
|
6667
7001
|
classification: "hardened",
|
|
@@ -7224,15 +7558,30 @@ var bridge = (() => {
|
|
|
7224
7558
|
async read(buffer, offset, length, position) {
|
|
7225
7559
|
const handle = _FileHandle._assertHandle(this);
|
|
7226
7560
|
let target = buffer;
|
|
7561
|
+
let readOffset = offset;
|
|
7562
|
+
let readLength = length;
|
|
7563
|
+
let readPosition = position;
|
|
7564
|
+
if (target !== null && typeof target === "object" && !ArrayBuffer.isView(target)) {
|
|
7565
|
+
readOffset = target.offset;
|
|
7566
|
+
readLength = target.length;
|
|
7567
|
+
readPosition = target.position;
|
|
7568
|
+
target = target.buffer ?? null;
|
|
7569
|
+
}
|
|
7227
7570
|
if (target === null) {
|
|
7228
7571
|
target = import_buffer.Buffer.alloc(FILE_HANDLE_READ_BUFFER_BYTES);
|
|
7229
7572
|
}
|
|
7230
7573
|
if (!ArrayBuffer.isView(target)) {
|
|
7231
7574
|
throw createInvalidArgTypeError("buffer", "an instance of ArrayBufferView", target);
|
|
7232
7575
|
}
|
|
7233
|
-
const
|
|
7234
|
-
const
|
|
7235
|
-
const bytesRead = fs.readSync(
|
|
7576
|
+
const normalizedOffset = readOffset ?? 0;
|
|
7577
|
+
const normalizedLength = readLength ?? target.byteLength - normalizedOffset;
|
|
7578
|
+
const bytesRead = fs.readSync(
|
|
7579
|
+
handle.fd,
|
|
7580
|
+
target,
|
|
7581
|
+
normalizedOffset,
|
|
7582
|
+
normalizedLength,
|
|
7583
|
+
readPosition ?? null
|
|
7584
|
+
);
|
|
7236
7585
|
return { bytesRead, buffer: target };
|
|
7237
7586
|
}
|
|
7238
7587
|
async write(buffer, offsetOrPosition, lengthOrEncoding, position) {
|
|
@@ -9973,6 +10322,12 @@ var bridge = (() => {
|
|
|
9973
10322
|
tmpdir: typeof _osConfig !== "undefined" && _osConfig.tmpdir || "/tmp",
|
|
9974
10323
|
hostname: typeof _osConfig !== "undefined" && _osConfig.hostname || "sandbox"
|
|
9975
10324
|
};
|
|
10325
|
+
function getRuntimeHomeDir() {
|
|
10326
|
+
return globalThis.process?.env?.HOME || config.homedir;
|
|
10327
|
+
}
|
|
10328
|
+
function getRuntimeTmpDir() {
|
|
10329
|
+
return globalThis.process?.env?.TMPDIR || config.tmpdir;
|
|
10330
|
+
}
|
|
9976
10331
|
var signals = {
|
|
9977
10332
|
SIGHUP: 1,
|
|
9978
10333
|
SIGINT: 2,
|
|
@@ -10116,10 +10471,10 @@ var bridge = (() => {
|
|
|
10116
10471
|
},
|
|
10117
10472
|
// Directory information
|
|
10118
10473
|
homedir() {
|
|
10119
|
-
return
|
|
10474
|
+
return getRuntimeHomeDir();
|
|
10120
10475
|
},
|
|
10121
10476
|
tmpdir() {
|
|
10122
|
-
return
|
|
10477
|
+
return getRuntimeTmpDir();
|
|
10123
10478
|
},
|
|
10124
10479
|
// System information
|
|
10125
10480
|
hostname() {
|
|
@@ -10132,7 +10487,7 @@ var bridge = (() => {
|
|
|
10132
10487
|
uid: 0,
|
|
10133
10488
|
gid: 0,
|
|
10134
10489
|
shell: "/bin/bash",
|
|
10135
|
-
homedir:
|
|
10490
|
+
homedir: getRuntimeHomeDir()
|
|
10136
10491
|
};
|
|
10137
10492
|
},
|
|
10138
10493
|
// CPU information
|
|
@@ -10225,7 +10580,7 @@ var bridge = (() => {
|
|
|
10225
10580
|
spawnSync: () => spawnSync
|
|
10226
10581
|
});
|
|
10227
10582
|
var childProcessInstances = /* @__PURE__ */ new Map();
|
|
10228
|
-
|
|
10583
|
+
function routeChildProcessEvent(sessionId, type, data) {
|
|
10229
10584
|
const child = childProcessInstances.get(sessionId);
|
|
10230
10585
|
if (!child) return;
|
|
10231
10586
|
if (type === "stdout") {
|
|
@@ -10245,6 +10600,49 @@ var bridge = (() => {
|
|
|
10245
10600
|
_unregisterHandle(`child:${sessionId}`);
|
|
10246
10601
|
}
|
|
10247
10602
|
}
|
|
10603
|
+
}
|
|
10604
|
+
var childProcessDispatch = (eventTypeOrSessionId, payloadOrType, data) => {
|
|
10605
|
+
if (typeof eventTypeOrSessionId === "number") {
|
|
10606
|
+
routeChildProcessEvent(
|
|
10607
|
+
eventTypeOrSessionId,
|
|
10608
|
+
payloadOrType,
|
|
10609
|
+
data
|
|
10610
|
+
);
|
|
10611
|
+
return;
|
|
10612
|
+
}
|
|
10613
|
+
const payload = (() => {
|
|
10614
|
+
if (payloadOrType && typeof payloadOrType === "object") {
|
|
10615
|
+
return payloadOrType;
|
|
10616
|
+
}
|
|
10617
|
+
if (typeof payloadOrType === "string") {
|
|
10618
|
+
try {
|
|
10619
|
+
return JSON.parse(payloadOrType);
|
|
10620
|
+
} catch {
|
|
10621
|
+
return null;
|
|
10622
|
+
}
|
|
10623
|
+
}
|
|
10624
|
+
return null;
|
|
10625
|
+
})();
|
|
10626
|
+
const sessionId = typeof payload?.sessionId === "number" ? payload.sessionId : Number(payload?.sessionId);
|
|
10627
|
+
if (!Number.isFinite(sessionId)) {
|
|
10628
|
+
return;
|
|
10629
|
+
}
|
|
10630
|
+
if (eventTypeOrSessionId === "child_stdout" || eventTypeOrSessionId === "child_stderr") {
|
|
10631
|
+
const encoded = typeof payload?.dataBase64 === "string" ? payload.dataBase64 : typeof payload?.data === "string" ? payload.data : "";
|
|
10632
|
+
const bytes = typeof Buffer !== "undefined" ? Buffer.from(encoded, "base64") : new Uint8Array(
|
|
10633
|
+
atob(encoded).split("").map((char) => char.charCodeAt(0))
|
|
10634
|
+
);
|
|
10635
|
+
routeChildProcessEvent(
|
|
10636
|
+
sessionId,
|
|
10637
|
+
eventTypeOrSessionId === "child_stdout" ? "stdout" : "stderr",
|
|
10638
|
+
bytes
|
|
10639
|
+
);
|
|
10640
|
+
return;
|
|
10641
|
+
}
|
|
10642
|
+
if (eventTypeOrSessionId === "child_exit") {
|
|
10643
|
+
const code = typeof payload?.code === "number" ? payload.code : Number(payload?.code ?? 1);
|
|
10644
|
+
routeChildProcessEvent(sessionId, "exit", code);
|
|
10645
|
+
}
|
|
10248
10646
|
};
|
|
10249
10647
|
exposeCustomGlobal("_childProcessDispatch", childProcessDispatch);
|
|
10250
10648
|
function checkStreamMaxListeners(stream, event) {
|
|
@@ -10823,6 +11221,79 @@ var bridge = (() => {
|
|
|
10823
11221
|
https: () => https
|
|
10824
11222
|
});
|
|
10825
11223
|
var MAX_HTTP_BODY_BYTES = 50 * 1024 * 1024;
|
|
11224
|
+
var _fetchHandleCounter = 0;
|
|
11225
|
+
function encodeFetchBody(body, bodyEncoding) {
|
|
11226
|
+
if (bodyEncoding === "base64" && typeof Buffer !== "undefined") {
|
|
11227
|
+
return new Uint8Array(Buffer.from(body, "base64"));
|
|
11228
|
+
}
|
|
11229
|
+
if (typeof TextEncoder !== "undefined") {
|
|
11230
|
+
return new TextEncoder().encode(body);
|
|
11231
|
+
}
|
|
11232
|
+
const bytes = new Uint8Array(body.length);
|
|
11233
|
+
for (let index = 0; index < body.length; index += 1) {
|
|
11234
|
+
bytes[index] = body.charCodeAt(index) & 255;
|
|
11235
|
+
}
|
|
11236
|
+
return bytes;
|
|
11237
|
+
}
|
|
11238
|
+
function createFetchBodyStream(body, bodyEncoding) {
|
|
11239
|
+
const ReadableStreamCtor = globalThis.ReadableStream;
|
|
11240
|
+
if (typeof ReadableStreamCtor !== "function") {
|
|
11241
|
+
return null;
|
|
11242
|
+
}
|
|
11243
|
+
const bytes = encodeFetchBody(body, bodyEncoding);
|
|
11244
|
+
const handleId = typeof _registerHandle === "function" ? `fetch-body:${++_fetchHandleCounter}` : null;
|
|
11245
|
+
let released = false;
|
|
11246
|
+
let delivered = false;
|
|
11247
|
+
const release = () => {
|
|
11248
|
+
if (released || !handleId) {
|
|
11249
|
+
return;
|
|
11250
|
+
}
|
|
11251
|
+
released = true;
|
|
11252
|
+
_unregisterHandle?.(handleId);
|
|
11253
|
+
};
|
|
11254
|
+
if (handleId) {
|
|
11255
|
+
_registerHandle?.(handleId, "fetch response body");
|
|
11256
|
+
}
|
|
11257
|
+
return new ReadableStreamCtor({
|
|
11258
|
+
pull(controller) {
|
|
11259
|
+
if (delivered) {
|
|
11260
|
+
release();
|
|
11261
|
+
controller.close();
|
|
11262
|
+
return;
|
|
11263
|
+
}
|
|
11264
|
+
delivered = true;
|
|
11265
|
+
controller.enqueue(bytes);
|
|
11266
|
+
controller.close();
|
|
11267
|
+
release();
|
|
11268
|
+
},
|
|
11269
|
+
cancel() {
|
|
11270
|
+
release();
|
|
11271
|
+
}
|
|
11272
|
+
});
|
|
11273
|
+
}
|
|
11274
|
+
function serializeFetchHeaders(headers) {
|
|
11275
|
+
if (!headers) {
|
|
11276
|
+
return {};
|
|
11277
|
+
}
|
|
11278
|
+
if (headers instanceof Headers) {
|
|
11279
|
+
return Object.fromEntries(headers.entries());
|
|
11280
|
+
}
|
|
11281
|
+
if (isFlatHeaderList(headers)) {
|
|
11282
|
+
const normalized = {};
|
|
11283
|
+
for (let index = 0; index < headers.length; index += 2) {
|
|
11284
|
+
const key = headers[index];
|
|
11285
|
+
const value = headers[index + 1];
|
|
11286
|
+
if (key !== void 0 && value !== void 0) {
|
|
11287
|
+
normalized[key] = value;
|
|
11288
|
+
}
|
|
11289
|
+
}
|
|
11290
|
+
return normalized;
|
|
11291
|
+
}
|
|
11292
|
+
return Object.fromEntries(new Headers(headers).entries());
|
|
11293
|
+
}
|
|
11294
|
+
function createFetchHeaders(headers) {
|
|
11295
|
+
return new Headers(serializeFetchHeaders(headers));
|
|
11296
|
+
}
|
|
10826
11297
|
async function fetch(input, options = {}) {
|
|
10827
11298
|
if (typeof _networkFetchRaw === "undefined") {
|
|
10828
11299
|
console.error("fetch requires NetworkAdapter to be configured");
|
|
@@ -10833,7 +11304,7 @@ var bridge = (() => {
|
|
|
10833
11304
|
resolvedUrl = input.url;
|
|
10834
11305
|
options = {
|
|
10835
11306
|
method: input.method,
|
|
10836
|
-
headers:
|
|
11307
|
+
headers: serializeFetchHeaders(input.headers),
|
|
10837
11308
|
body: input.body,
|
|
10838
11309
|
...options
|
|
10839
11310
|
};
|
|
@@ -10842,37 +11313,62 @@ var bridge = (() => {
|
|
|
10842
11313
|
}
|
|
10843
11314
|
const optionsJson = JSON.stringify({
|
|
10844
11315
|
method: options.method || "GET",
|
|
10845
|
-
headers: options.headers
|
|
11316
|
+
headers: serializeFetchHeaders(options.headers),
|
|
10846
11317
|
body: options.body || null
|
|
10847
11318
|
});
|
|
10848
|
-
const
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
11319
|
+
const handleId = typeof _registerHandle === "function" ? `fetch:${++_fetchHandleCounter}` : null;
|
|
11320
|
+
if (handleId) {
|
|
11321
|
+
_registerHandle?.(handleId, `fetch ${resolvedUrl}`);
|
|
11322
|
+
}
|
|
11323
|
+
try {
|
|
11324
|
+
const responseJson = await _networkFetchRaw.apply(void 0, [resolvedUrl, optionsJson], {
|
|
11325
|
+
result: { promise: true }
|
|
11326
|
+
});
|
|
11327
|
+
const response = JSON.parse(responseJson);
|
|
11328
|
+
const bodyEncoding = response.headers?.["x-body-encoding"] ?? null;
|
|
11329
|
+
const responseBody = response.body ?? "";
|
|
11330
|
+
let bodyStream;
|
|
11331
|
+
return {
|
|
11332
|
+
ok: response.ok,
|
|
11333
|
+
status: response.status,
|
|
11334
|
+
statusText: response.statusText,
|
|
11335
|
+
headers: new Map(Object.entries(response.headers || {})),
|
|
11336
|
+
url: response.url || resolvedUrl,
|
|
11337
|
+
redirected: response.redirected || false,
|
|
11338
|
+
type: "basic",
|
|
11339
|
+
get body() {
|
|
11340
|
+
if (bodyStream === void 0) {
|
|
11341
|
+
bodyStream = createFetchBodyStream(responseBody, bodyEncoding);
|
|
11342
|
+
}
|
|
11343
|
+
return bodyStream;
|
|
11344
|
+
},
|
|
11345
|
+
async text() {
|
|
11346
|
+
if (bodyEncoding === "base64" && typeof Buffer !== "undefined") {
|
|
11347
|
+
return Buffer.from(responseBody, "base64").toString("utf8");
|
|
11348
|
+
}
|
|
11349
|
+
return responseBody;
|
|
11350
|
+
},
|
|
11351
|
+
async json() {
|
|
11352
|
+
const textBody = bodyEncoding === "base64" && typeof Buffer !== "undefined" ? Buffer.from(responseBody, "base64").toString("utf8") : responseBody;
|
|
11353
|
+
return JSON.parse(textBody || "{}");
|
|
11354
|
+
},
|
|
11355
|
+
async arrayBuffer() {
|
|
11356
|
+
return Uint8Array.from(
|
|
11357
|
+
encodeFetchBody(responseBody, bodyEncoding)
|
|
11358
|
+
).buffer;
|
|
11359
|
+
},
|
|
11360
|
+
async blob() {
|
|
11361
|
+
throw new Error("Blob not supported in sandbox");
|
|
11362
|
+
},
|
|
11363
|
+
clone() {
|
|
11364
|
+
return { ...this };
|
|
11365
|
+
}
|
|
11366
|
+
};
|
|
11367
|
+
} finally {
|
|
11368
|
+
if (handleId) {
|
|
11369
|
+
_unregisterHandle?.(handleId);
|
|
10874
11370
|
}
|
|
10875
|
-
}
|
|
11371
|
+
}
|
|
10876
11372
|
}
|
|
10877
11373
|
var Headers = class _Headers {
|
|
10878
11374
|
_headers = {};
|
|
@@ -10941,7 +11437,9 @@ var bridge = (() => {
|
|
|
10941
11437
|
constructor(input, init = {}) {
|
|
10942
11438
|
this.url = typeof input === "string" ? input : input.url;
|
|
10943
11439
|
this.method = init.method || (typeof input !== "string" ? input.method : void 0) || "GET";
|
|
10944
|
-
this.headers =
|
|
11440
|
+
this.headers = createFetchHeaders(
|
|
11441
|
+
init.headers || (typeof input !== "string" ? input.headers : void 0)
|
|
11442
|
+
);
|
|
10945
11443
|
this.body = init.body || null;
|
|
10946
11444
|
this.mode = init.mode || "cors";
|
|
10947
11445
|
this.credentials = init.credentials || "same-origin";
|
|
@@ -11531,64 +12029,7 @@ var bridge = (() => {
|
|
|
11531
12029
|
}
|
|
11532
12030
|
const normalizedHeaders = normalizeRequestHeaders(this._options.headers);
|
|
11533
12031
|
const requestMethod = String(this._options.method || "GET").toUpperCase();
|
|
11534
|
-
const
|
|
11535
|
-
const directLoopbackConnectServer = requestMethod === "CONNECT" ? loopbackServerByPort : null;
|
|
11536
|
-
const directLoopbackUpgradeServer = requestMethod !== "CONNECT" && hasUpgradeRequestHeaders(normalizedHeaders) && loopbackServerByPort?.listenerCount("upgrade") ? loopbackServerByPort : null;
|
|
11537
|
-
if (directLoopbackConnectServer) {
|
|
11538
|
-
const response2 = await dispatchLoopbackConnectRequest(
|
|
11539
|
-
directLoopbackConnectServer,
|
|
11540
|
-
this._options
|
|
11541
|
-
);
|
|
11542
|
-
this.finished = true;
|
|
11543
|
-
this.socket = response2.socket;
|
|
11544
|
-
response2.response.socket = response2.socket;
|
|
11545
|
-
response2.socket.once("close", () => {
|
|
11546
|
-
this._emit("close");
|
|
11547
|
-
});
|
|
11548
|
-
this._emit("connect", response2.response, response2.socket, response2.head);
|
|
11549
|
-
process.nextTick(() => {
|
|
11550
|
-
this._finalizeSocket(socket, false);
|
|
11551
|
-
});
|
|
11552
|
-
return;
|
|
11553
|
-
}
|
|
11554
|
-
if (directLoopbackUpgradeServer) {
|
|
11555
|
-
const response2 = await dispatchLoopbackUpgradeRequest(
|
|
11556
|
-
directLoopbackUpgradeServer,
|
|
11557
|
-
this._options,
|
|
11558
|
-
this._body
|
|
11559
|
-
);
|
|
11560
|
-
this.finished = true;
|
|
11561
|
-
this.socket = response2.socket;
|
|
11562
|
-
response2.response.socket = response2.socket;
|
|
11563
|
-
response2.socket.once("close", () => {
|
|
11564
|
-
this._emit("close");
|
|
11565
|
-
});
|
|
11566
|
-
this._emit("upgrade", response2.response, response2.socket, response2.head);
|
|
11567
|
-
process.nextTick(() => {
|
|
11568
|
-
this._finalizeSocket(socket, false);
|
|
11569
|
-
});
|
|
11570
|
-
return;
|
|
11571
|
-
}
|
|
11572
|
-
const directLoopbackServer = requestMethod !== "CONNECT" && hasUpgradeRequestHeaders(normalizedHeaders) && !directLoopbackUpgradeServer ? loopbackServerByPort : findLoopbackServerForRequest(this._options);
|
|
11573
|
-
const directLoopbackHttp2CompatServer = !directLoopbackServer && requestMethod !== "CONNECT" && !hasUpgradeRequestHeaders(normalizedHeaders) ? findLoopbackHttp2CompatibilityServer(this._options) : null;
|
|
11574
|
-
const serializedRequest = JSON.stringify({
|
|
11575
|
-
method: requestMethod,
|
|
11576
|
-
url: this._options.path || "/",
|
|
11577
|
-
headers: normalizedHeaders,
|
|
11578
|
-
rawHeaders: flattenRawHeaders(normalizedHeaders),
|
|
11579
|
-
bodyBase64: this._body ? Buffer.from(this._body).toString("base64") : void 0
|
|
11580
|
-
});
|
|
11581
|
-
const loopbackResponse = directLoopbackServer ? await dispatchLoopbackServerRequest(
|
|
11582
|
-
directLoopbackServer._bridgeServerId,
|
|
11583
|
-
serializedRequest
|
|
11584
|
-
) : directLoopbackHttp2CompatServer ? await dispatchLoopbackHttp2CompatibilityRequest(
|
|
11585
|
-
directLoopbackHttp2CompatServer,
|
|
11586
|
-
serializedRequest
|
|
11587
|
-
) : null;
|
|
11588
|
-
if (loopbackResponse) {
|
|
11589
|
-
this._loopbackAbort = loopbackResponse.abortRequest;
|
|
11590
|
-
}
|
|
11591
|
-
const responseJson = loopbackResponse ? loopbackResponse.responseJson : await _networkHttpRequestRaw.apply(void 0, [url, JSON.stringify({
|
|
12032
|
+
const responseJson = await _networkHttpRequestRaw.apply(void 0, [url, JSON.stringify({
|
|
11592
12033
|
method: this._options.method || "GET",
|
|
11593
12034
|
headers: normalizedHeaders,
|
|
11594
12035
|
body: this._body || null,
|
|
@@ -11645,14 +12086,6 @@ var bridge = (() => {
|
|
|
11645
12086
|
});
|
|
11646
12087
|
return;
|
|
11647
12088
|
}
|
|
11648
|
-
if (response.connectionReset) {
|
|
11649
|
-
const error = createConnResetError();
|
|
11650
|
-
this._emit("error", error);
|
|
11651
|
-
process.nextTick(() => {
|
|
11652
|
-
this._finalizeSocket(socket, false);
|
|
11653
|
-
});
|
|
11654
|
-
return;
|
|
11655
|
-
}
|
|
11656
12089
|
for (const informational of response.informational || []) {
|
|
11657
12090
|
this._emit("information", new IncomingMessage({
|
|
11658
12091
|
headers: Object.fromEntries(informational.headers || []),
|
|
@@ -11667,9 +12100,6 @@ var bridge = (() => {
|
|
|
11667
12100
|
res.once("end", () => {
|
|
11668
12101
|
process.nextTick(() => {
|
|
11669
12102
|
this._finalizeSocket(socket, this._agent?.keepAlive === true && !this.aborted);
|
|
11670
|
-
if (response.connectionEnded) {
|
|
11671
|
-
queueMicrotask(() => socket.end?.());
|
|
11672
|
-
}
|
|
11673
12103
|
});
|
|
11674
12104
|
});
|
|
11675
12105
|
if (this._callback) {
|
|
@@ -12790,19 +13220,6 @@ var bridge = (() => {
|
|
|
12790
13220
|
const existing = target[key];
|
|
12791
13221
|
target[key] = existing === void 0 ? value : `${joinHeaderValue(existing)}, ${value}`;
|
|
12792
13222
|
}
|
|
12793
|
-
function flattenRawHeaders(headers) {
|
|
12794
|
-
const rawHeaders = [];
|
|
12795
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
12796
|
-
if (Array.isArray(value)) {
|
|
12797
|
-
value.forEach((entry) => {
|
|
12798
|
-
rawHeaders.push(key, entry);
|
|
12799
|
-
});
|
|
12800
|
-
continue;
|
|
12801
|
-
}
|
|
12802
|
-
rawHeaders.push(key, value);
|
|
12803
|
-
}
|
|
12804
|
-
return rawHeaders;
|
|
12805
|
-
}
|
|
12806
13223
|
function validateRequestMethod(method) {
|
|
12807
13224
|
if (method == null || method === "") {
|
|
12808
13225
|
return void 0;
|
|
@@ -13260,48 +13677,6 @@ ${headerLines}\r
|
|
|
13260
13677
|
const bare = hostname.startsWith("[") && hostname.endsWith("]") ? hostname.slice(1, -1) : hostname;
|
|
13261
13678
|
return bare === "localhost" || bare === "127.0.0.1" || bare === "::1";
|
|
13262
13679
|
}
|
|
13263
|
-
function findLoopbackServerForRequest(options) {
|
|
13264
|
-
if (String(options.method || "GET").toUpperCase() === "CONNECT") {
|
|
13265
|
-
return null;
|
|
13266
|
-
}
|
|
13267
|
-
return findLoopbackServerByPort(options, true);
|
|
13268
|
-
}
|
|
13269
|
-
function findLoopbackServerByPort(options, skipUpgradeHeaders = false) {
|
|
13270
|
-
const hostname = String(options.hostname || options.host || "localhost");
|
|
13271
|
-
if (!isLoopbackRequestHost(hostname)) {
|
|
13272
|
-
return null;
|
|
13273
|
-
}
|
|
13274
|
-
const normalizedHeaders = normalizeRequestHeaders(options.headers);
|
|
13275
|
-
if (skipUpgradeHeaders && hasUpgradeRequestHeaders(normalizedHeaders)) {
|
|
13276
|
-
return null;
|
|
13277
|
-
}
|
|
13278
|
-
const port = Number(options.port) || 80;
|
|
13279
|
-
for (const server of serverInstances.values()) {
|
|
13280
|
-
const address = server.address();
|
|
13281
|
-
if (!address) continue;
|
|
13282
|
-
if (address.port === port) {
|
|
13283
|
-
return server;
|
|
13284
|
-
}
|
|
13285
|
-
}
|
|
13286
|
-
return null;
|
|
13287
|
-
}
|
|
13288
|
-
function findLoopbackHttp2CompatibilityServer(options) {
|
|
13289
|
-
const hostname = String(options.hostname || options.host || "localhost");
|
|
13290
|
-
if (!isLoopbackRequestHost(hostname)) {
|
|
13291
|
-
return null;
|
|
13292
|
-
}
|
|
13293
|
-
const port = Number(options.port) || 443;
|
|
13294
|
-
for (const server of http2Servers.values()) {
|
|
13295
|
-
const address = server.address();
|
|
13296
|
-
if (!address || typeof address !== "object") {
|
|
13297
|
-
continue;
|
|
13298
|
-
}
|
|
13299
|
-
if (address.port === port && server.encrypted && server.allowHTTP1 && server.listenerCount("request") > 0) {
|
|
13300
|
-
return server;
|
|
13301
|
-
}
|
|
13302
|
-
}
|
|
13303
|
-
return null;
|
|
13304
|
-
}
|
|
13305
13680
|
var ServerIncomingMessage = class {
|
|
13306
13681
|
headers;
|
|
13307
13682
|
rawHeaders;
|
|
@@ -14413,201 +14788,6 @@ ${headerLines}\r
|
|
|
14413
14788
|
server._endRequestDispatch();
|
|
14414
14789
|
}
|
|
14415
14790
|
}
|
|
14416
|
-
async function dispatchLoopbackConnectRequest(server, options) {
|
|
14417
|
-
return await new Promise((resolve, reject) => {
|
|
14418
|
-
const request = new ServerIncomingMessage({
|
|
14419
|
-
method: "CONNECT",
|
|
14420
|
-
url: String(options.path || "/"),
|
|
14421
|
-
headers: normalizeRequestHeaders(options.headers),
|
|
14422
|
-
rawHeaders: flattenRawHeaders(normalizeRequestHeaders(options.headers))
|
|
14423
|
-
});
|
|
14424
|
-
const clientSocket = new DirectTunnelSocket({
|
|
14425
|
-
host: String(options.hostname || options.host || "127.0.0.1"),
|
|
14426
|
-
port: Number(options.port) || 80
|
|
14427
|
-
});
|
|
14428
|
-
const serverSocket = new DirectTunnelSocket({
|
|
14429
|
-
host: "127.0.0.1",
|
|
14430
|
-
port: 0
|
|
14431
|
-
});
|
|
14432
|
-
clientSocket._attachPeer(serverSocket);
|
|
14433
|
-
serverSocket._attachPeer(clientSocket);
|
|
14434
|
-
const originalWrite = serverSocket.write.bind(serverSocket);
|
|
14435
|
-
const originalEnd = serverSocket.end.bind(serverSocket);
|
|
14436
|
-
let handshakeBuffer = Buffer.alloc(0);
|
|
14437
|
-
let handshakeResolved = false;
|
|
14438
|
-
const maybeResolveHandshake = () => {
|
|
14439
|
-
if (handshakeResolved) {
|
|
14440
|
-
return;
|
|
14441
|
-
}
|
|
14442
|
-
const separator = handshakeBuffer.indexOf("\r\n\r\n");
|
|
14443
|
-
if (separator === -1) {
|
|
14444
|
-
return;
|
|
14445
|
-
}
|
|
14446
|
-
const headerBuffer = handshakeBuffer.subarray(0, separator);
|
|
14447
|
-
const head = handshakeBuffer.subarray(separator + 4);
|
|
14448
|
-
const [statusLine, ...headerLines] = headerBuffer.toString("latin1").split("\r\n");
|
|
14449
|
-
const statusMatch = /^HTTP\/1\.[01]\s+(\d{3})(?:\s+(.*))?$/.exec(statusLine);
|
|
14450
|
-
if (!statusMatch) {
|
|
14451
|
-
reject(new Error(`Invalid CONNECT response: ${statusLine}`));
|
|
14452
|
-
return;
|
|
14453
|
-
}
|
|
14454
|
-
handshakeResolved = true;
|
|
14455
|
-
const headers = {};
|
|
14456
|
-
const rawHeaders = [];
|
|
14457
|
-
for (const headerLine of headerLines) {
|
|
14458
|
-
const separatorIndex = headerLine.indexOf(":");
|
|
14459
|
-
if (separatorIndex === -1) {
|
|
14460
|
-
continue;
|
|
14461
|
-
}
|
|
14462
|
-
const key = headerLine.slice(0, separatorIndex).trim();
|
|
14463
|
-
const value = headerLine.slice(separatorIndex + 1).trim();
|
|
14464
|
-
headers[key.toLowerCase()] = value;
|
|
14465
|
-
rawHeaders.push(key, value);
|
|
14466
|
-
}
|
|
14467
|
-
resolve({
|
|
14468
|
-
response: new IncomingMessage({
|
|
14469
|
-
headers,
|
|
14470
|
-
rawHeaders,
|
|
14471
|
-
status: Number(statusMatch[1]),
|
|
14472
|
-
statusText: statusMatch[2] || HTTP_STATUS_TEXT[Number(statusMatch[1])]
|
|
14473
|
-
}),
|
|
14474
|
-
socket: clientSocket,
|
|
14475
|
-
head
|
|
14476
|
-
});
|
|
14477
|
-
};
|
|
14478
|
-
serverSocket.write = ((data, encodingOrCb, cb) => {
|
|
14479
|
-
if (handshakeResolved) {
|
|
14480
|
-
return originalWrite(data, encodingOrCb, cb);
|
|
14481
|
-
}
|
|
14482
|
-
const callback = typeof encodingOrCb === "function" ? encodingOrCb : cb;
|
|
14483
|
-
handshakeBuffer = Buffer.concat([handshakeBuffer, normalizeSocketChunk(data)]);
|
|
14484
|
-
maybeResolveHandshake();
|
|
14485
|
-
callback?.();
|
|
14486
|
-
return true;
|
|
14487
|
-
});
|
|
14488
|
-
serverSocket.end = ((data) => {
|
|
14489
|
-
if (data !== void 0) {
|
|
14490
|
-
serverSocket.write(data);
|
|
14491
|
-
}
|
|
14492
|
-
if (!handshakeResolved) {
|
|
14493
|
-
maybeResolveHandshake();
|
|
14494
|
-
}
|
|
14495
|
-
return originalEnd();
|
|
14496
|
-
});
|
|
14497
|
-
try {
|
|
14498
|
-
server._emit("connect", request, serverSocket, Buffer.alloc(0));
|
|
14499
|
-
} catch (error) {
|
|
14500
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
14501
|
-
return;
|
|
14502
|
-
}
|
|
14503
|
-
queueMicrotask(() => {
|
|
14504
|
-
if (!handshakeResolved) {
|
|
14505
|
-
reject(new Error("Loopback CONNECT handler did not establish a tunnel"));
|
|
14506
|
-
}
|
|
14507
|
-
});
|
|
14508
|
-
});
|
|
14509
|
-
}
|
|
14510
|
-
async function dispatchLoopbackUpgradeRequest(server, options, requestBody) {
|
|
14511
|
-
return await new Promise((resolve, reject) => {
|
|
14512
|
-
const normalizedHeaders = normalizeRequestHeaders(options.headers);
|
|
14513
|
-
const request = new ServerIncomingMessage({
|
|
14514
|
-
method: String(options.method || "GET").toUpperCase(),
|
|
14515
|
-
url: String(options.path || "/"),
|
|
14516
|
-
headers: normalizedHeaders,
|
|
14517
|
-
rawHeaders: flattenRawHeaders(normalizedHeaders),
|
|
14518
|
-
bodyBase64: requestBody ? Buffer.from(requestBody).toString("base64") : void 0
|
|
14519
|
-
});
|
|
14520
|
-
const clientSocket = new DirectTunnelSocket({
|
|
14521
|
-
host: String(options.hostname || options.host || "127.0.0.1"),
|
|
14522
|
-
port: Number(options.port) || 80
|
|
14523
|
-
});
|
|
14524
|
-
const serverSocket = new DirectTunnelSocket({
|
|
14525
|
-
host: "127.0.0.1",
|
|
14526
|
-
port: 0
|
|
14527
|
-
});
|
|
14528
|
-
clientSocket._attachPeer(serverSocket);
|
|
14529
|
-
serverSocket._attachPeer(clientSocket);
|
|
14530
|
-
const originalWrite = serverSocket.write.bind(serverSocket);
|
|
14531
|
-
const originalEnd = serverSocket.end.bind(serverSocket);
|
|
14532
|
-
let handshakeBuffer = Buffer.alloc(0);
|
|
14533
|
-
let handshakeResolved = false;
|
|
14534
|
-
const maybeResolveHandshake = () => {
|
|
14535
|
-
if (handshakeResolved) {
|
|
14536
|
-
return;
|
|
14537
|
-
}
|
|
14538
|
-
const separator = handshakeBuffer.indexOf("\r\n\r\n");
|
|
14539
|
-
if (separator === -1) {
|
|
14540
|
-
return;
|
|
14541
|
-
}
|
|
14542
|
-
const headerBuffer = handshakeBuffer.subarray(0, separator);
|
|
14543
|
-
const head = handshakeBuffer.subarray(separator + 4);
|
|
14544
|
-
const [statusLine, ...headerLines] = headerBuffer.toString("latin1").split("\r\n");
|
|
14545
|
-
const statusMatch = /^HTTP\/1\.[01]\s+(\d{3})(?:\s+(.*))?$/.exec(statusLine);
|
|
14546
|
-
if (!statusMatch) {
|
|
14547
|
-
reject(new Error(`Invalid upgrade response: ${statusLine}`));
|
|
14548
|
-
return;
|
|
14549
|
-
}
|
|
14550
|
-
handshakeResolved = true;
|
|
14551
|
-
const headers = {};
|
|
14552
|
-
const rawHeaders = [];
|
|
14553
|
-
for (const headerLine of headerLines) {
|
|
14554
|
-
const separatorIndex = headerLine.indexOf(":");
|
|
14555
|
-
if (separatorIndex === -1) {
|
|
14556
|
-
continue;
|
|
14557
|
-
}
|
|
14558
|
-
const key = headerLine.slice(0, separatorIndex).trim();
|
|
14559
|
-
const value = headerLine.slice(separatorIndex + 1).trim();
|
|
14560
|
-
headers[key.toLowerCase()] = value;
|
|
14561
|
-
rawHeaders.push(key, value);
|
|
14562
|
-
}
|
|
14563
|
-
resolve({
|
|
14564
|
-
response: new IncomingMessage({
|
|
14565
|
-
headers,
|
|
14566
|
-
rawHeaders,
|
|
14567
|
-
status: Number(statusMatch[1]),
|
|
14568
|
-
statusText: statusMatch[2] || HTTP_STATUS_TEXT[Number(statusMatch[1])]
|
|
14569
|
-
}),
|
|
14570
|
-
socket: clientSocket,
|
|
14571
|
-
head
|
|
14572
|
-
});
|
|
14573
|
-
};
|
|
14574
|
-
serverSocket.write = ((data, encodingOrCb, cb) => {
|
|
14575
|
-
if (handshakeResolved) {
|
|
14576
|
-
return originalWrite(data, encodingOrCb, cb);
|
|
14577
|
-
}
|
|
14578
|
-
const callback = typeof encodingOrCb === "function" ? encodingOrCb : cb;
|
|
14579
|
-
handshakeBuffer = Buffer.concat([handshakeBuffer, normalizeSocketChunk(data)]);
|
|
14580
|
-
maybeResolveHandshake();
|
|
14581
|
-
callback?.();
|
|
14582
|
-
return true;
|
|
14583
|
-
});
|
|
14584
|
-
serverSocket.end = ((data) => {
|
|
14585
|
-
if (data !== void 0) {
|
|
14586
|
-
serverSocket.write(data);
|
|
14587
|
-
}
|
|
14588
|
-
if (!handshakeResolved) {
|
|
14589
|
-
maybeResolveHandshake();
|
|
14590
|
-
}
|
|
14591
|
-
return originalEnd();
|
|
14592
|
-
});
|
|
14593
|
-
try {
|
|
14594
|
-
server._emit(
|
|
14595
|
-
"upgrade",
|
|
14596
|
-
request,
|
|
14597
|
-
serverSocket,
|
|
14598
|
-
request.rawBody || Buffer.alloc(0)
|
|
14599
|
-
);
|
|
14600
|
-
} catch (error) {
|
|
14601
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
14602
|
-
return;
|
|
14603
|
-
}
|
|
14604
|
-
queueMicrotask(() => {
|
|
14605
|
-
if (!handshakeResolved) {
|
|
14606
|
-
reject(new Error("Loopback upgrade handler did not establish a protocol switch"));
|
|
14607
|
-
}
|
|
14608
|
-
});
|
|
14609
|
-
});
|
|
14610
|
-
}
|
|
14611
14791
|
function dispatchSocketRequest(event, serverId, requestJson, headBase64, socketId) {
|
|
14612
14792
|
const server = serverInstances.get(serverId);
|
|
14613
14793
|
if (!server) {
|
|
@@ -14932,26 +15112,6 @@ ${headerLines}\r
|
|
|
14932
15112
|
STATUS_CODES: HTTP_STATUS_TEXT
|
|
14933
15113
|
};
|
|
14934
15114
|
}
|
|
14935
|
-
async function dispatchLoopbackHttp2CompatibilityRequest(server, requestInput) {
|
|
14936
|
-
const request = typeof requestInput === "string" ? JSON.parse(requestInput) : requestInput;
|
|
14937
|
-
const incoming = new ServerIncomingMessage(request);
|
|
14938
|
-
const outgoing = new ServerResponseBridge();
|
|
14939
|
-
incoming.socket = outgoing.socket;
|
|
14940
|
-
incoming.connection = outgoing.socket;
|
|
14941
|
-
server.emit("request", incoming, outgoing);
|
|
14942
|
-
if (incoming.rawBody && incoming.rawBody.length > 0) {
|
|
14943
|
-
incoming.emit("data", incoming.rawBody);
|
|
14944
|
-
}
|
|
14945
|
-
incoming.emit("end");
|
|
14946
|
-
if (!outgoing.writableFinished) {
|
|
14947
|
-
outgoing.end();
|
|
14948
|
-
}
|
|
14949
|
-
await outgoing.waitForClose();
|
|
14950
|
-
return {
|
|
14951
|
-
responseJson: JSON.stringify(outgoing.serialize()),
|
|
14952
|
-
abortRequest: () => incoming._abort()
|
|
14953
|
-
};
|
|
14954
|
-
}
|
|
14955
15115
|
var http = createHttpModule("http");
|
|
14956
15116
|
var https = createHttpModule("https");
|
|
14957
15117
|
var HTTP2_K_SOCKET = /* @__PURE__ */ Symbol.for("secure-exec.http2.kSocket");
|
|
@@ -15031,8 +15191,13 @@ ${headerLines}\r
|
|
|
15031
15191
|
remoteFamily = "IPv4";
|
|
15032
15192
|
servername;
|
|
15033
15193
|
alpnProtocol = false;
|
|
15194
|
+
readable = true;
|
|
15195
|
+
writable = true;
|
|
15034
15196
|
destroyed = false;
|
|
15197
|
+
_bridgeReadPollTimer = null;
|
|
15198
|
+
_loopbackServer = null;
|
|
15035
15199
|
_onDestroy;
|
|
15200
|
+
_destroyCallbackInvoked = false;
|
|
15036
15201
|
constructor(state, onDestroy) {
|
|
15037
15202
|
super();
|
|
15038
15203
|
this._onDestroy = onDestroy;
|
|
@@ -15051,8 +15216,27 @@ ${headerLines}\r
|
|
|
15051
15216
|
this.servername = state.servername;
|
|
15052
15217
|
this.alpnProtocol = state.alpnProtocol ?? this.alpnProtocol;
|
|
15053
15218
|
}
|
|
15219
|
+
_clearTimeoutTimer() {
|
|
15220
|
+
}
|
|
15221
|
+
_emitNet(event, error) {
|
|
15222
|
+
if (event === "error" && error) {
|
|
15223
|
+
this.emit("error", error);
|
|
15224
|
+
return;
|
|
15225
|
+
}
|
|
15226
|
+
if (event === "close") {
|
|
15227
|
+
if (!this._destroyCallbackInvoked) {
|
|
15228
|
+
this._destroyCallbackInvoked = true;
|
|
15229
|
+
queueMicrotask(() => {
|
|
15230
|
+
this._onDestroy?.();
|
|
15231
|
+
});
|
|
15232
|
+
}
|
|
15233
|
+
this.emit("close");
|
|
15234
|
+
}
|
|
15235
|
+
}
|
|
15054
15236
|
end() {
|
|
15055
15237
|
this.destroyed = true;
|
|
15238
|
+
this.readable = false;
|
|
15239
|
+
this.writable = false;
|
|
15056
15240
|
this.emit("close");
|
|
15057
15241
|
return this;
|
|
15058
15242
|
}
|
|
@@ -15061,8 +15245,9 @@ ${headerLines}\r
|
|
|
15061
15245
|
return this;
|
|
15062
15246
|
}
|
|
15063
15247
|
this.destroyed = true;
|
|
15064
|
-
this.
|
|
15065
|
-
this.
|
|
15248
|
+
this.readable = false;
|
|
15249
|
+
this.writable = false;
|
|
15250
|
+
this._emitNet("close");
|
|
15066
15251
|
return this;
|
|
15067
15252
|
}
|
|
15068
15253
|
};
|
|
@@ -15089,6 +15274,166 @@ ${headerLines}\r
|
|
|
15089
15274
|
error.code = "ERR_HTTP2_INVALID_SETTING_VALUE";
|
|
15090
15275
|
return error;
|
|
15091
15276
|
}
|
|
15277
|
+
var HTTP2_INTERNAL_BINDING_CONSTANTS = {
|
|
15278
|
+
NGHTTP2_NO_ERROR: 0,
|
|
15279
|
+
NGHTTP2_PROTOCOL_ERROR: 1,
|
|
15280
|
+
NGHTTP2_INTERNAL_ERROR: 2,
|
|
15281
|
+
NGHTTP2_FLOW_CONTROL_ERROR: 3,
|
|
15282
|
+
NGHTTP2_SETTINGS_TIMEOUT: 4,
|
|
15283
|
+
NGHTTP2_STREAM_CLOSED: 5,
|
|
15284
|
+
NGHTTP2_FRAME_SIZE_ERROR: 6,
|
|
15285
|
+
NGHTTP2_REFUSED_STREAM: 7,
|
|
15286
|
+
NGHTTP2_CANCEL: 8,
|
|
15287
|
+
NGHTTP2_COMPRESSION_ERROR: 9,
|
|
15288
|
+
NGHTTP2_CONNECT_ERROR: 10,
|
|
15289
|
+
NGHTTP2_ENHANCE_YOUR_CALM: 11,
|
|
15290
|
+
NGHTTP2_INADEQUATE_SECURITY: 12,
|
|
15291
|
+
NGHTTP2_HTTP_1_1_REQUIRED: 13,
|
|
15292
|
+
NGHTTP2_NV_FLAG_NONE: 0,
|
|
15293
|
+
NGHTTP2_NV_FLAG_NO_INDEX: 1,
|
|
15294
|
+
NGHTTP2_ERR_DEFERRED: -508,
|
|
15295
|
+
NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE: -509,
|
|
15296
|
+
NGHTTP2_ERR_STREAM_CLOSED: -510,
|
|
15297
|
+
NGHTTP2_ERR_INVALID_ARGUMENT: -501,
|
|
15298
|
+
NGHTTP2_ERR_FRAME_SIZE_ERROR: -522,
|
|
15299
|
+
NGHTTP2_ERR_NOMEM: -901,
|
|
15300
|
+
NGHTTP2_FLAG_NONE: 0,
|
|
15301
|
+
NGHTTP2_FLAG_END_STREAM: 1,
|
|
15302
|
+
NGHTTP2_FLAG_END_HEADERS: 4,
|
|
15303
|
+
NGHTTP2_FLAG_ACK: 1,
|
|
15304
|
+
NGHTTP2_FLAG_PADDED: 8,
|
|
15305
|
+
NGHTTP2_FLAG_PRIORITY: 32,
|
|
15306
|
+
NGHTTP2_DEFAULT_WEIGHT: 16,
|
|
15307
|
+
NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: 1,
|
|
15308
|
+
NGHTTP2_SETTINGS_ENABLE_PUSH: 2,
|
|
15309
|
+
NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: 3,
|
|
15310
|
+
NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: 4,
|
|
15311
|
+
NGHTTP2_SETTINGS_MAX_FRAME_SIZE: 5,
|
|
15312
|
+
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: 6,
|
|
15313
|
+
NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: 8
|
|
15314
|
+
};
|
|
15315
|
+
var HTTP2_NGHTTP2_ERROR_MESSAGES = {
|
|
15316
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_DEFERRED]: "Data deferred",
|
|
15317
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE]: "Stream ID is not available",
|
|
15318
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_STREAM_CLOSED]: "Stream was already closed or invalid",
|
|
15319
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_INVALID_ARGUMENT]: "Invalid argument",
|
|
15320
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_FRAME_SIZE_ERROR]: "Frame size error",
|
|
15321
|
+
[HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_ERR_NOMEM]: "Out of memory"
|
|
15322
|
+
};
|
|
15323
|
+
var NghttpError = class extends Error {
|
|
15324
|
+
code = "ERR_HTTP2_ERROR";
|
|
15325
|
+
constructor(message) {
|
|
15326
|
+
super(message);
|
|
15327
|
+
this.name = "Error";
|
|
15328
|
+
}
|
|
15329
|
+
};
|
|
15330
|
+
function nghttp2ErrorString(code) {
|
|
15331
|
+
return HTTP2_NGHTTP2_ERROR_MESSAGES[code] ?? `HTTP/2 error (${String(code)})`;
|
|
15332
|
+
}
|
|
15333
|
+
function createHttp2InvalidArgValueError(property, value) {
|
|
15334
|
+
return createTypeErrorWithCode(
|
|
15335
|
+
`The property 'options.${property}' is invalid. Received ${formatHttp2InvalidValue(value)}`,
|
|
15336
|
+
"ERR_INVALID_ARG_VALUE"
|
|
15337
|
+
);
|
|
15338
|
+
}
|
|
15339
|
+
function formatHttp2InvalidValue(value) {
|
|
15340
|
+
if (typeof value === "function") {
|
|
15341
|
+
return `[Function${value.name ? `: ${value.name}` : ": function"}]`;
|
|
15342
|
+
}
|
|
15343
|
+
if (typeof value === "symbol") {
|
|
15344
|
+
return value.toString();
|
|
15345
|
+
}
|
|
15346
|
+
if (Array.isArray(value)) {
|
|
15347
|
+
return "[]";
|
|
15348
|
+
}
|
|
15349
|
+
if (value === null) {
|
|
15350
|
+
return "null";
|
|
15351
|
+
}
|
|
15352
|
+
if (typeof value === "object") {
|
|
15353
|
+
return "{}";
|
|
15354
|
+
}
|
|
15355
|
+
return String(value);
|
|
15356
|
+
}
|
|
15357
|
+
function createHttp2PayloadForbiddenError(statusCode) {
|
|
15358
|
+
return createHttp2Error(
|
|
15359
|
+
"ERR_HTTP2_PAYLOAD_FORBIDDEN",
|
|
15360
|
+
`Responses with ${String(statusCode)} status must not have a payload`
|
|
15361
|
+
);
|
|
15362
|
+
}
|
|
15363
|
+
var S_IFMT = 61440;
|
|
15364
|
+
var S_IFDIR = 16384;
|
|
15365
|
+
var S_IFREG = 32768;
|
|
15366
|
+
var S_IFIFO = 4096;
|
|
15367
|
+
var S_IFSOCK = 49152;
|
|
15368
|
+
var S_IFLNK = 40960;
|
|
15369
|
+
function createHttp2BridgeStat(stat) {
|
|
15370
|
+
const atimeMs = stat.atimeMs ?? 0;
|
|
15371
|
+
const mtimeMs = stat.mtimeMs ?? atimeMs;
|
|
15372
|
+
const ctimeMs = stat.ctimeMs ?? mtimeMs;
|
|
15373
|
+
const birthtimeMs = stat.birthtimeMs ?? ctimeMs;
|
|
15374
|
+
const fileType = stat.mode & S_IFMT;
|
|
15375
|
+
return {
|
|
15376
|
+
size: stat.size,
|
|
15377
|
+
mode: stat.mode,
|
|
15378
|
+
atimeMs,
|
|
15379
|
+
mtimeMs,
|
|
15380
|
+
ctimeMs,
|
|
15381
|
+
birthtimeMs,
|
|
15382
|
+
atime: new Date(atimeMs),
|
|
15383
|
+
mtime: new Date(mtimeMs),
|
|
15384
|
+
ctime: new Date(ctimeMs),
|
|
15385
|
+
birthtime: new Date(birthtimeMs),
|
|
15386
|
+
isFile: () => fileType === S_IFREG,
|
|
15387
|
+
isDirectory: () => fileType === S_IFDIR,
|
|
15388
|
+
isFIFO: () => fileType === S_IFIFO,
|
|
15389
|
+
isSocket: () => fileType === S_IFSOCK,
|
|
15390
|
+
isSymbolicLink: () => fileType === S_IFLNK
|
|
15391
|
+
};
|
|
15392
|
+
}
|
|
15393
|
+
function normalizeHttp2FileResponseOptions(options) {
|
|
15394
|
+
const normalized = options ?? {};
|
|
15395
|
+
const offset = normalized.offset;
|
|
15396
|
+
if (offset !== void 0 && (typeof offset !== "number" || !Number.isFinite(offset))) {
|
|
15397
|
+
throw createHttp2InvalidArgValueError("offset", offset);
|
|
15398
|
+
}
|
|
15399
|
+
const length = normalized.length;
|
|
15400
|
+
if (length !== void 0 && (typeof length !== "number" || !Number.isFinite(length))) {
|
|
15401
|
+
throw createHttp2InvalidArgValueError("length", length);
|
|
15402
|
+
}
|
|
15403
|
+
const statCheck = normalized.statCheck;
|
|
15404
|
+
if (statCheck !== void 0 && typeof statCheck !== "function") {
|
|
15405
|
+
throw createHttp2InvalidArgValueError("statCheck", statCheck);
|
|
15406
|
+
}
|
|
15407
|
+
const onError = normalized.onError;
|
|
15408
|
+
return {
|
|
15409
|
+
offset: offset === void 0 ? 0 : Math.max(0, Math.trunc(offset)),
|
|
15410
|
+
length: typeof length === "number" ? Math.trunc(length) : void 0,
|
|
15411
|
+
statCheck: typeof statCheck === "function" ? statCheck : void 0,
|
|
15412
|
+
onError: typeof onError === "function" ? onError : void 0
|
|
15413
|
+
};
|
|
15414
|
+
}
|
|
15415
|
+
function sliceHttp2FileBody(body, offset, length) {
|
|
15416
|
+
const safeOffset = Math.max(0, Math.min(offset, body.length));
|
|
15417
|
+
if (length === void 0 || length < 0) {
|
|
15418
|
+
return body.subarray(safeOffset);
|
|
15419
|
+
}
|
|
15420
|
+
return body.subarray(safeOffset, Math.min(body.length, safeOffset + length));
|
|
15421
|
+
}
|
|
15422
|
+
var Http2Stream = class {
|
|
15423
|
+
constructor(_streamId) {
|
|
15424
|
+
this._streamId = _streamId;
|
|
15425
|
+
}
|
|
15426
|
+
respond(headers) {
|
|
15427
|
+
if (typeof _networkHttp2StreamRespondRaw === "undefined") {
|
|
15428
|
+
throw new Error("http2 server stream respond bridge is not available");
|
|
15429
|
+
}
|
|
15430
|
+
_networkHttp2StreamRespondRaw.applySync(void 0, [
|
|
15431
|
+
this._streamId,
|
|
15432
|
+
serializeHttp2Headers(headers)
|
|
15433
|
+
]);
|
|
15434
|
+
return 0;
|
|
15435
|
+
}
|
|
15436
|
+
};
|
|
15092
15437
|
var DEFAULT_HTTP2_SETTINGS = {
|
|
15093
15438
|
headerTableSize: 4096,
|
|
15094
15439
|
enablePush: true,
|
|
@@ -15537,7 +15882,10 @@ ${headerLines}\r
|
|
|
15537
15882
|
}
|
|
15538
15883
|
var ServerHttp2Stream = class _ServerHttp2Stream extends Http2EventEmitter {
|
|
15539
15884
|
_streamId;
|
|
15885
|
+
_binding;
|
|
15540
15886
|
_responded = false;
|
|
15887
|
+
_endQueued = false;
|
|
15888
|
+
_pendingSyntheticErrorSuppressions = 0;
|
|
15541
15889
|
_requestHeaders;
|
|
15542
15890
|
_isPushStream;
|
|
15543
15891
|
session;
|
|
@@ -15550,6 +15898,7 @@ ${headerLines}\r
|
|
|
15550
15898
|
constructor(streamId, session, requestHeaders, isPushStream = false) {
|
|
15551
15899
|
super();
|
|
15552
15900
|
this._streamId = streamId;
|
|
15901
|
+
this._binding = new Http2Stream(streamId);
|
|
15553
15902
|
this.session = session;
|
|
15554
15903
|
this._requestHeaders = requestHeaders;
|
|
15555
15904
|
this._isPushStream = isPushStream;
|
|
@@ -15562,12 +15911,56 @@ ${headerLines}\r
|
|
|
15562
15911
|
ended: requestHeaders?.[":method"] === "HEAD"
|
|
15563
15912
|
};
|
|
15564
15913
|
}
|
|
15565
|
-
|
|
15566
|
-
|
|
15567
|
-
|
|
15914
|
+
_closeWithCode(code) {
|
|
15915
|
+
this.rstCode = code;
|
|
15916
|
+
_networkHttp2StreamCloseRaw?.applySync(void 0, [this._streamId, code]);
|
|
15917
|
+
}
|
|
15918
|
+
_markSyntheticClose() {
|
|
15919
|
+
this.destroyed = true;
|
|
15920
|
+
this.readable = false;
|
|
15921
|
+
this.writable = false;
|
|
15922
|
+
}
|
|
15923
|
+
_shouldSuppressHostError() {
|
|
15924
|
+
if (this._pendingSyntheticErrorSuppressions <= 0) {
|
|
15925
|
+
return false;
|
|
15568
15926
|
}
|
|
15927
|
+
this._pendingSyntheticErrorSuppressions -= 1;
|
|
15928
|
+
return true;
|
|
15929
|
+
}
|
|
15930
|
+
_emitNghttp2Error(errorCode) {
|
|
15931
|
+
const error = new NghttpError(nghttp2ErrorString(errorCode));
|
|
15932
|
+
this._pendingSyntheticErrorSuppressions += 1;
|
|
15933
|
+
this._markSyntheticClose();
|
|
15934
|
+
this.emit("error", error);
|
|
15935
|
+
this._closeWithCode(HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_INTERNAL_ERROR);
|
|
15936
|
+
}
|
|
15937
|
+
_emitInternalStreamError() {
|
|
15938
|
+
const error = createHttp2Error(
|
|
15939
|
+
"ERR_HTTP2_STREAM_ERROR",
|
|
15940
|
+
"Stream closed with error code NGHTTP2_INTERNAL_ERROR"
|
|
15941
|
+
);
|
|
15942
|
+
this._pendingSyntheticErrorSuppressions += 1;
|
|
15943
|
+
this._markSyntheticClose();
|
|
15944
|
+
this.emit("error", error);
|
|
15945
|
+
this._closeWithCode(HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_INTERNAL_ERROR);
|
|
15946
|
+
}
|
|
15947
|
+
_submitResponse(headers) {
|
|
15569
15948
|
this._responded = true;
|
|
15570
|
-
|
|
15949
|
+
const ngError = this._binding.respond(headers);
|
|
15950
|
+
if (typeof ngError === "number" && ngError !== 0) {
|
|
15951
|
+
this._emitNghttp2Error(ngError);
|
|
15952
|
+
return false;
|
|
15953
|
+
}
|
|
15954
|
+
return true;
|
|
15955
|
+
}
|
|
15956
|
+
respond(headers) {
|
|
15957
|
+
if (this.destroyed) {
|
|
15958
|
+
throw createHttp2Error("ERR_HTTP2_INVALID_STREAM", "The stream has been destroyed");
|
|
15959
|
+
}
|
|
15960
|
+
if (this._responded) {
|
|
15961
|
+
throw createHttp2Error("ERR_HTTP2_HEADERS_SENT", "Response has already been initiated.");
|
|
15962
|
+
}
|
|
15963
|
+
this._submitResponse(headers);
|
|
15571
15964
|
}
|
|
15572
15965
|
pushStream(headers, optionsOrCallback, maybeCallback) {
|
|
15573
15966
|
if (this._isPushStream) {
|
|
@@ -15584,7 +15977,7 @@ ${headerLines}\r
|
|
|
15584
15977
|
throw new Error("http2 server stream push bridge is not available");
|
|
15585
15978
|
}
|
|
15586
15979
|
const options = optionsOrCallback && typeof optionsOrCallback === "object" && !Array.isArray(optionsOrCallback) ? optionsOrCallback : {};
|
|
15587
|
-
const resultJson = _networkHttp2StreamPushStreamRaw.
|
|
15980
|
+
const resultJson = _networkHttp2StreamPushStreamRaw.applySync(
|
|
15588
15981
|
void 0,
|
|
15589
15982
|
[
|
|
15590
15983
|
this._streamId,
|
|
@@ -15593,20 +15986,18 @@ ${headerLines}\r
|
|
|
15593
15986
|
]
|
|
15594
15987
|
);
|
|
15595
15988
|
const result = JSON.parse(resultJson);
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15602
|
-
|
|
15603
|
-
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
callback(null, pushStream, parseHttp2Headers(result.headers));
|
|
15609
|
-
});
|
|
15989
|
+
if (result.error) {
|
|
15990
|
+
callback(parseHttp2ErrorPayload(result.error));
|
|
15991
|
+
return;
|
|
15992
|
+
}
|
|
15993
|
+
const pushStream = new _ServerHttp2Stream(
|
|
15994
|
+
Number(result.streamId),
|
|
15995
|
+
this.session,
|
|
15996
|
+
parseHttp2Headers(result.headers),
|
|
15997
|
+
true
|
|
15998
|
+
);
|
|
15999
|
+
http2Streams.set(Number(result.streamId), pushStream);
|
|
16000
|
+
callback(null, pushStream, parseHttp2Headers(result.headers));
|
|
15610
16001
|
}
|
|
15611
16002
|
write(data) {
|
|
15612
16003
|
if (this._writableState.ended) {
|
|
@@ -15623,7 +16014,12 @@ ${headerLines}\r
|
|
|
15623
16014
|
}
|
|
15624
16015
|
end(data) {
|
|
15625
16016
|
if (!this._responded) {
|
|
15626
|
-
this.
|
|
16017
|
+
if (!this._submitResponse({ ":status": 200 })) {
|
|
16018
|
+
return;
|
|
16019
|
+
}
|
|
16020
|
+
}
|
|
16021
|
+
if (this._endQueued) {
|
|
16022
|
+
return;
|
|
15627
16023
|
}
|
|
15628
16024
|
if (typeof _networkHttp2StreamEndRaw === "undefined") {
|
|
15629
16025
|
throw new Error("http2 server stream end bridge is not available");
|
|
@@ -15634,8 +16030,14 @@ ${headerLines}\r
|
|
|
15634
16030
|
const buffer = Buffer.isBuffer(data) ? data : typeof data === "string" ? Buffer.from(data) : Buffer.from(data);
|
|
15635
16031
|
encoded = buffer.toString("base64");
|
|
15636
16032
|
}
|
|
15637
|
-
|
|
15638
|
-
|
|
16033
|
+
this._endQueued = true;
|
|
16034
|
+
queueMicrotask(() => {
|
|
16035
|
+
if (!this._endQueued || this.destroyed) {
|
|
16036
|
+
return;
|
|
16037
|
+
}
|
|
16038
|
+
this._endQueued = false;
|
|
16039
|
+
_networkHttp2StreamEndRaw.applySync(void 0, [this._streamId, encoded]);
|
|
16040
|
+
});
|
|
15639
16041
|
}
|
|
15640
16042
|
pause() {
|
|
15641
16043
|
this._readableState.flowing = false;
|
|
@@ -15648,18 +16050,43 @@ ${headerLines}\r
|
|
|
15648
16050
|
return this;
|
|
15649
16051
|
}
|
|
15650
16052
|
respondWithFile(path, headers, options) {
|
|
16053
|
+
if (this.destroyed) {
|
|
16054
|
+
throw createHttp2Error("ERR_HTTP2_INVALID_STREAM", "The stream has been destroyed");
|
|
16055
|
+
}
|
|
16056
|
+
if (this._responded) {
|
|
16057
|
+
throw createHttp2Error("ERR_HTTP2_HEADERS_SENT", "Response has already been initiated.");
|
|
16058
|
+
}
|
|
16059
|
+
const normalizedOptions = normalizeHttp2FileResponseOptions(options);
|
|
16060
|
+
const responseHeaders = { ...headers ?? {} };
|
|
16061
|
+
const statusCode = responseHeaders[":status"];
|
|
16062
|
+
if (statusCode === 204 || statusCode === 205 || statusCode === 304) {
|
|
16063
|
+
throw createHttp2PayloadForbiddenError(Number(statusCode));
|
|
16064
|
+
}
|
|
15651
16065
|
try {
|
|
16066
|
+
const statJson = _fs.stat.applySyncPromise(void 0, [path]);
|
|
15652
16067
|
const bodyBase64 = _fs.readFileBinary.applySyncPromise(void 0, [path]);
|
|
16068
|
+
const stat = createHttp2BridgeStat(JSON.parse(statJson));
|
|
16069
|
+
const callbackOptions = {
|
|
16070
|
+
offset: normalizedOptions.offset,
|
|
16071
|
+
length: normalizedOptions.length ?? Math.max(0, stat.size - normalizedOptions.offset)
|
|
16072
|
+
};
|
|
16073
|
+
normalizedOptions.statCheck?.(stat, responseHeaders, callbackOptions);
|
|
15653
16074
|
const body = Buffer.from(bodyBase64, "base64");
|
|
15654
|
-
|
|
15655
|
-
|
|
16075
|
+
const slicedBody = sliceHttp2FileBody(
|
|
16076
|
+
body,
|
|
16077
|
+
normalizedOptions.offset,
|
|
16078
|
+
normalizedOptions.length
|
|
16079
|
+
);
|
|
16080
|
+
if (responseHeaders["content-length"] === void 0) {
|
|
16081
|
+
responseHeaders["content-length"] = slicedBody.byteLength;
|
|
16082
|
+
}
|
|
16083
|
+
if (!this._submitResponse({
|
|
15656
16084
|
":status": 200,
|
|
15657
|
-
...
|
|
15658
|
-
})
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
});
|
|
16085
|
+
...responseHeaders
|
|
16086
|
+
})) {
|
|
16087
|
+
return;
|
|
16088
|
+
}
|
|
16089
|
+
this.end(slicedBody);
|
|
15663
16090
|
return;
|
|
15664
16091
|
} catch {
|
|
15665
16092
|
}
|
|
@@ -15681,10 +16108,22 @@ ${headerLines}\r
|
|
|
15681
16108
|
const fd = typeof fdOrHandle === "number" ? fdOrHandle : typeof fdOrHandle?.fd === "number" ? fdOrHandle.fd : NaN;
|
|
15682
16109
|
const path = Number.isFinite(fd) ? _fdGetPath.applySync(void 0, [fd]) : null;
|
|
15683
16110
|
if (!path) {
|
|
15684
|
-
|
|
16111
|
+
this._emitInternalStreamError();
|
|
16112
|
+
return;
|
|
15685
16113
|
}
|
|
15686
16114
|
this.respondWithFile(path, headers, options);
|
|
15687
16115
|
}
|
|
16116
|
+
destroy(error) {
|
|
16117
|
+
if (this.destroyed) {
|
|
16118
|
+
return this;
|
|
16119
|
+
}
|
|
16120
|
+
this.destroyed = true;
|
|
16121
|
+
if (error) {
|
|
16122
|
+
this.emit("error", error);
|
|
16123
|
+
}
|
|
16124
|
+
this._closeWithCode(HTTP2_INTERNAL_BINDING_CONSTANTS.NGHTTP2_CANCEL);
|
|
16125
|
+
return this;
|
|
16126
|
+
}
|
|
15688
16127
|
_emitData(dataBase64) {
|
|
15689
16128
|
if (!dataBase64) {
|
|
15690
16129
|
return;
|
|
@@ -15896,7 +16335,11 @@ ${headerLines}\r
|
|
|
15896
16335
|
constructor(sessionId, socketState) {
|
|
15897
16336
|
super();
|
|
15898
16337
|
this._sessionId = sessionId;
|
|
15899
|
-
this.socket = new Http2SocketProxy(socketState, () =>
|
|
16338
|
+
this.socket = new Http2SocketProxy(socketState, () => {
|
|
16339
|
+
setTimeout(() => {
|
|
16340
|
+
this.destroy();
|
|
16341
|
+
}, 0);
|
|
16342
|
+
});
|
|
15900
16343
|
this[HTTP2_K_SOCKET] = this.socket;
|
|
15901
16344
|
}
|
|
15902
16345
|
_retain() {
|
|
@@ -16468,6 +16911,9 @@ ${headerLines}\r
|
|
|
16468
16911
|
if (kind === "serverStreamError") {
|
|
16469
16912
|
const stream = http2Streams.get(id);
|
|
16470
16913
|
if (!stream) return;
|
|
16914
|
+
if (typeof stream._shouldSuppressHostError === "function" && stream._shouldSuppressHostError()) {
|
|
16915
|
+
return;
|
|
16916
|
+
}
|
|
16471
16917
|
stream.emit("error", parseHttp2ErrorPayload(data));
|
|
16472
16918
|
return;
|
|
16473
16919
|
}
|
|
@@ -16573,6 +17019,9 @@ ${headerLines}\r
|
|
|
16573
17019
|
var http2 = {
|
|
16574
17020
|
Http2ServerRequest,
|
|
16575
17021
|
Http2ServerResponse,
|
|
17022
|
+
Http2Stream,
|
|
17023
|
+
NghttpError,
|
|
17024
|
+
nghttp2ErrorString,
|
|
16576
17025
|
constants: {
|
|
16577
17026
|
HTTP2_HEADER_METHOD: ":method",
|
|
16578
17027
|
HTTP2_HEADER_PATH: ":path",
|
|
@@ -16581,19 +17030,14 @@ ${headerLines}\r
|
|
|
16581
17030
|
HTTP2_HEADER_STATUS: ":status",
|
|
16582
17031
|
HTTP2_HEADER_CONTENT_TYPE: "content-type",
|
|
16583
17032
|
HTTP2_HEADER_CONTENT_LENGTH: "content-length",
|
|
17033
|
+
HTTP2_HEADER_LAST_MODIFIED: "last-modified",
|
|
16584
17034
|
HTTP2_HEADER_ACCEPT: "accept",
|
|
16585
17035
|
HTTP2_HEADER_ACCEPT_ENCODING: "accept-encoding",
|
|
16586
17036
|
HTTP2_METHOD_GET: "GET",
|
|
16587
17037
|
HTTP2_METHOD_POST: "POST",
|
|
16588
17038
|
HTTP2_METHOD_PUT: "PUT",
|
|
16589
17039
|
HTTP2_METHOD_DELETE: "DELETE",
|
|
16590
|
-
|
|
16591
|
-
NGHTTP2_PROTOCOL_ERROR: 1,
|
|
16592
|
-
NGHTTP2_INTERNAL_ERROR: 2,
|
|
16593
|
-
NGHTTP2_FRAME_SIZE_ERROR: 6,
|
|
16594
|
-
NGHTTP2_FLOW_CONTROL_ERROR: 3,
|
|
16595
|
-
NGHTTP2_REFUSED_STREAM: 7,
|
|
16596
|
-
NGHTTP2_CANCEL: 8,
|
|
17040
|
+
...HTTP2_INTERNAL_BINDING_CONSTANTS,
|
|
16597
17041
|
DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: 65535
|
|
16598
17042
|
},
|
|
16599
17043
|
getDefaultSettings() {
|
|
@@ -16655,6 +17099,20 @@ ${headerLines}\r
|
|
|
16655
17099
|
exposeCustomGlobal("Blob", class BlobStub {
|
|
16656
17100
|
});
|
|
16657
17101
|
}
|
|
17102
|
+
if (typeof globalThis.File === "undefined") {
|
|
17103
|
+
class FileStub extends Blob {
|
|
17104
|
+
name;
|
|
17105
|
+
lastModified;
|
|
17106
|
+
webkitRelativePath;
|
|
17107
|
+
constructor(parts = [], name = "", options = {}) {
|
|
17108
|
+
super(parts, options);
|
|
17109
|
+
this.name = String(name);
|
|
17110
|
+
this.lastModified = typeof options.lastModified === "number" ? options.lastModified : Date.now();
|
|
17111
|
+
this.webkitRelativePath = "";
|
|
17112
|
+
}
|
|
17113
|
+
}
|
|
17114
|
+
exposeCustomGlobal("File", FileStub);
|
|
17115
|
+
}
|
|
16658
17116
|
if (typeof globalThis.FormData === "undefined") {
|
|
16659
17117
|
class FormDataStub {
|
|
16660
17118
|
_entries = [];
|
|
@@ -20092,10 +20550,12 @@ ${headerLines}\r
|
|
|
20092
20550
|
var _exited = false;
|
|
20093
20551
|
var ProcessExitError = class extends Error {
|
|
20094
20552
|
code;
|
|
20553
|
+
_isProcessExit;
|
|
20095
20554
|
constructor(code) {
|
|
20096
20555
|
super("process.exit(" + code + ")");
|
|
20097
20556
|
this.name = "ProcessExitError";
|
|
20098
20557
|
this.code = code;
|
|
20558
|
+
this._isProcessExit = true;
|
|
20099
20559
|
}
|
|
20100
20560
|
};
|
|
20101
20561
|
exposeCustomGlobal("ProcessExitError", ProcessExitError);
|
|
@@ -20131,6 +20591,10 @@ ${headerLines}\r
|
|
|
20131
20591
|
SIGPWR: 30,
|
|
20132
20592
|
SIGSYS: 31
|
|
20133
20593
|
};
|
|
20594
|
+
var _signalNamesByNumber = Object.fromEntries(
|
|
20595
|
+
Object.entries(_signalNumbers).map(([name, num]) => [num, name])
|
|
20596
|
+
);
|
|
20597
|
+
var _ignoredSelfSignals = /* @__PURE__ */ new Set(["SIGWINCH", "SIGCHLD", "SIGCONT", "SIGURG"]);
|
|
20134
20598
|
function _resolveSignal(signal) {
|
|
20135
20599
|
if (signal === void 0 || signal === null) return 15;
|
|
20136
20600
|
if (typeof signal === "number") return signal;
|
|
@@ -20189,6 +20653,33 @@ ${headerLines}\r
|
|
|
20189
20653
|
}
|
|
20190
20654
|
return handled;
|
|
20191
20655
|
}
|
|
20656
|
+
function isProcessExitError(error) {
|
|
20657
|
+
return Boolean(
|
|
20658
|
+
error && typeof error === "object" && (error._isProcessExit === true || error.name === "ProcessExitError")
|
|
20659
|
+
);
|
|
20660
|
+
}
|
|
20661
|
+
function normalizeAsyncError(error) {
|
|
20662
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
20663
|
+
}
|
|
20664
|
+
function routeAsyncCallbackError(error) {
|
|
20665
|
+
if (isProcessExitError(error)) {
|
|
20666
|
+
return { handled: false, rethrow: error };
|
|
20667
|
+
}
|
|
20668
|
+
const normalized = normalizeAsyncError(error);
|
|
20669
|
+
try {
|
|
20670
|
+
if (_emit("uncaughtException", normalized, "uncaughtException")) {
|
|
20671
|
+
return { handled: true, rethrow: null };
|
|
20672
|
+
}
|
|
20673
|
+
} catch (emitError) {
|
|
20674
|
+
return { handled: false, rethrow: emitError };
|
|
20675
|
+
}
|
|
20676
|
+
return { handled: false, rethrow: normalized };
|
|
20677
|
+
}
|
|
20678
|
+
function scheduleAsyncRethrow(error) {
|
|
20679
|
+
setTimeout2(() => {
|
|
20680
|
+
throw error;
|
|
20681
|
+
}, 0);
|
|
20682
|
+
}
|
|
20192
20683
|
function _getStdinIsTTY() {
|
|
20193
20684
|
return typeof __runtimeTtyConfig !== "undefined" && __runtimeTtyConfig.stdinIsTTY || false;
|
|
20194
20685
|
}
|
|
@@ -20198,60 +20689,110 @@ ${headerLines}\r
|
|
|
20198
20689
|
function _getStderrIsTTY() {
|
|
20199
20690
|
return typeof __runtimeTtyConfig !== "undefined" && __runtimeTtyConfig.stderrIsTTY || false;
|
|
20200
20691
|
}
|
|
20201
|
-
|
|
20692
|
+
function getWriteCallback(encodingOrCallback, callback) {
|
|
20693
|
+
if (typeof encodingOrCallback === "function") {
|
|
20694
|
+
return encodingOrCallback;
|
|
20695
|
+
}
|
|
20696
|
+
if (typeof callback === "function") {
|
|
20697
|
+
return callback;
|
|
20698
|
+
}
|
|
20699
|
+
return void 0;
|
|
20700
|
+
}
|
|
20701
|
+
function emitListeners(listeners, onceListeners, event, args) {
|
|
20702
|
+
const persistent = listeners[event] ? listeners[event].slice() : [];
|
|
20703
|
+
const once = onceListeners[event] ? onceListeners[event].slice() : [];
|
|
20704
|
+
if (once.length > 0) {
|
|
20705
|
+
onceListeners[event] = [];
|
|
20706
|
+
}
|
|
20707
|
+
for (const listener of persistent) {
|
|
20708
|
+
listener(...args);
|
|
20709
|
+
}
|
|
20710
|
+
for (const listener of once) {
|
|
20711
|
+
listener(...args);
|
|
20712
|
+
}
|
|
20713
|
+
return persistent.length + once.length > 0;
|
|
20714
|
+
}
|
|
20715
|
+
function createStdioWriteStream(options) {
|
|
20716
|
+
const listeners = {};
|
|
20717
|
+
const onceListeners = {};
|
|
20718
|
+
const remove = (event, listener) => {
|
|
20719
|
+
if (listeners[event]) {
|
|
20720
|
+
const idx = listeners[event].indexOf(listener);
|
|
20721
|
+
if (idx !== -1) listeners[event].splice(idx, 1);
|
|
20722
|
+
}
|
|
20723
|
+
if (onceListeners[event]) {
|
|
20724
|
+
const idx = onceListeners[event].indexOf(listener);
|
|
20725
|
+
if (idx !== -1) onceListeners[event].splice(idx, 1);
|
|
20726
|
+
}
|
|
20727
|
+
};
|
|
20728
|
+
const stream = {
|
|
20729
|
+
write(data, encodingOrCallback, callback) {
|
|
20730
|
+
options.write(String(data));
|
|
20731
|
+
const done = getWriteCallback(encodingOrCallback, callback);
|
|
20732
|
+
if (done) {
|
|
20733
|
+
_queueMicrotask(() => done(null));
|
|
20734
|
+
}
|
|
20735
|
+
return true;
|
|
20736
|
+
},
|
|
20737
|
+
end() {
|
|
20738
|
+
return stream;
|
|
20739
|
+
},
|
|
20740
|
+
on(event, listener) {
|
|
20741
|
+
if (!listeners[event]) listeners[event] = [];
|
|
20742
|
+
listeners[event].push(listener);
|
|
20743
|
+
return stream;
|
|
20744
|
+
},
|
|
20745
|
+
once(event, listener) {
|
|
20746
|
+
if (!onceListeners[event]) onceListeners[event] = [];
|
|
20747
|
+
onceListeners[event].push(listener);
|
|
20748
|
+
return stream;
|
|
20749
|
+
},
|
|
20750
|
+
off(event, listener) {
|
|
20751
|
+
remove(event, listener);
|
|
20752
|
+
return stream;
|
|
20753
|
+
},
|
|
20754
|
+
removeListener(event, listener) {
|
|
20755
|
+
remove(event, listener);
|
|
20756
|
+
return stream;
|
|
20757
|
+
},
|
|
20758
|
+
addListener(event, listener) {
|
|
20759
|
+
return stream.on(event, listener);
|
|
20760
|
+
},
|
|
20761
|
+
emit(event, ...args) {
|
|
20762
|
+
return emitListeners(listeners, onceListeners, event, args);
|
|
20763
|
+
},
|
|
20764
|
+
writable: true,
|
|
20765
|
+
get isTTY() {
|
|
20766
|
+
return options.isTTY();
|
|
20767
|
+
},
|
|
20768
|
+
columns: 80,
|
|
20769
|
+
rows: 24
|
|
20770
|
+
};
|
|
20771
|
+
return stream;
|
|
20772
|
+
}
|
|
20773
|
+
var _stdout = createStdioWriteStream({
|
|
20202
20774
|
write(data) {
|
|
20203
20775
|
if (typeof _log !== "undefined") {
|
|
20204
|
-
_log.applySync(void 0, [
|
|
20776
|
+
_log.applySync(void 0, [data]);
|
|
20205
20777
|
}
|
|
20206
|
-
return true;
|
|
20207
|
-
},
|
|
20208
|
-
end() {
|
|
20209
|
-
return this;
|
|
20210
|
-
},
|
|
20211
|
-
on() {
|
|
20212
|
-
return this;
|
|
20213
|
-
},
|
|
20214
|
-
once() {
|
|
20215
|
-
return this;
|
|
20216
20778
|
},
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
writable: true,
|
|
20221
|
-
get isTTY() {
|
|
20222
|
-
return _getStdoutIsTTY();
|
|
20223
|
-
},
|
|
20224
|
-
columns: 80,
|
|
20225
|
-
rows: 24
|
|
20226
|
-
};
|
|
20227
|
-
var _stderr = {
|
|
20779
|
+
isTTY: _getStdoutIsTTY
|
|
20780
|
+
});
|
|
20781
|
+
var _stderr = createStdioWriteStream({
|
|
20228
20782
|
write(data) {
|
|
20229
20783
|
if (typeof _error !== "undefined") {
|
|
20230
|
-
_error.applySync(void 0, [
|
|
20784
|
+
_error.applySync(void 0, [data]);
|
|
20231
20785
|
}
|
|
20232
|
-
return true;
|
|
20233
|
-
},
|
|
20234
|
-
end() {
|
|
20235
|
-
return this;
|
|
20236
|
-
},
|
|
20237
|
-
on() {
|
|
20238
|
-
return this;
|
|
20239
|
-
},
|
|
20240
|
-
once() {
|
|
20241
|
-
return this;
|
|
20242
|
-
},
|
|
20243
|
-
emit() {
|
|
20244
|
-
return false;
|
|
20245
20786
|
},
|
|
20246
|
-
|
|
20247
|
-
|
|
20248
|
-
return _getStderrIsTTY();
|
|
20249
|
-
},
|
|
20250
|
-
columns: 80,
|
|
20251
|
-
rows: 24
|
|
20252
|
-
};
|
|
20787
|
+
isTTY: _getStderrIsTTY
|
|
20788
|
+
});
|
|
20253
20789
|
var _stdinListeners = {};
|
|
20254
20790
|
var _stdinOnceListeners = {};
|
|
20791
|
+
var _stdinLiveDecoder = new TextDecoder2();
|
|
20792
|
+
var STDIN_HANDLE_ID = "process.stdin";
|
|
20793
|
+
var _stdinLiveBuffer = "";
|
|
20794
|
+
var _stdinLiveStarted = false;
|
|
20795
|
+
var _stdinLiveHandleRegistered = false;
|
|
20255
20796
|
exposeMutableRuntimeStateGlobal(
|
|
20256
20797
|
"_stdinData",
|
|
20257
20798
|
typeof _processConfig !== "undefined" && _processConfig.stdin || ""
|
|
@@ -20303,11 +20844,94 @@ ${headerLines}\r
|
|
|
20303
20844
|
}
|
|
20304
20845
|
}
|
|
20305
20846
|
}
|
|
20847
|
+
function emitStdinListeners(event, value) {
|
|
20848
|
+
const listeners = [..._stdinListeners[event] || [], ..._stdinOnceListeners[event] || []];
|
|
20849
|
+
_stdinOnceListeners[event] = [];
|
|
20850
|
+
for (const listener of listeners) {
|
|
20851
|
+
listener(value);
|
|
20852
|
+
}
|
|
20853
|
+
}
|
|
20854
|
+
function syncLiveStdinHandle(active) {
|
|
20855
|
+
if (active) {
|
|
20856
|
+
if (!_stdinLiveHandleRegistered && typeof _registerHandle === "function") {
|
|
20857
|
+
try {
|
|
20858
|
+
_registerHandle(STDIN_HANDLE_ID, "process.stdin");
|
|
20859
|
+
_stdinLiveHandleRegistered = true;
|
|
20860
|
+
} catch {
|
|
20861
|
+
}
|
|
20862
|
+
}
|
|
20863
|
+
return;
|
|
20864
|
+
}
|
|
20865
|
+
if (_stdinLiveHandleRegistered && typeof _unregisterHandle === "function") {
|
|
20866
|
+
try {
|
|
20867
|
+
_unregisterHandle(STDIN_HANDLE_ID);
|
|
20868
|
+
} catch {
|
|
20869
|
+
}
|
|
20870
|
+
_stdinLiveHandleRegistered = false;
|
|
20871
|
+
}
|
|
20872
|
+
}
|
|
20873
|
+
function flushLiveStdinBuffer() {
|
|
20874
|
+
if (!getStdinFlowMode() || _stdinLiveBuffer.length === 0) return;
|
|
20875
|
+
const chunk = _stdinLiveBuffer;
|
|
20876
|
+
_stdinLiveBuffer = "";
|
|
20877
|
+
emitStdinListeners("data", chunk);
|
|
20878
|
+
}
|
|
20879
|
+
function finishLiveStdin() {
|
|
20880
|
+
if (getStdinEnded()) return;
|
|
20881
|
+
setStdinEnded(true);
|
|
20882
|
+
flushLiveStdinBuffer();
|
|
20883
|
+
emitStdinListeners("end");
|
|
20884
|
+
emitStdinListeners("close");
|
|
20885
|
+
syncLiveStdinHandle(false);
|
|
20886
|
+
}
|
|
20887
|
+
function ensureLiveStdinStarted() {
|
|
20888
|
+
if (_stdinLiveStarted || !_getStdinIsTTY()) return;
|
|
20889
|
+
_stdinLiveStarted = true;
|
|
20890
|
+
syncLiveStdinHandle(!_stdin.paused);
|
|
20891
|
+
void (async () => {
|
|
20892
|
+
try {
|
|
20893
|
+
while (!getStdinEnded()) {
|
|
20894
|
+
if (typeof _kernelStdinRead === "undefined") {
|
|
20895
|
+
break;
|
|
20896
|
+
}
|
|
20897
|
+
const next = await _kernelStdinRead.apply(void 0, [], {
|
|
20898
|
+
result: { promise: true }
|
|
20899
|
+
});
|
|
20900
|
+
if (next?.done) {
|
|
20901
|
+
break;
|
|
20902
|
+
}
|
|
20903
|
+
const dataBase64 = String(next?.dataBase64 ?? "");
|
|
20904
|
+
if (!dataBase64) {
|
|
20905
|
+
continue;
|
|
20906
|
+
}
|
|
20907
|
+
_stdinLiveBuffer += _stdinLiveDecoder.decode(
|
|
20908
|
+
import_buffer2.Buffer.from(dataBase64, "base64"),
|
|
20909
|
+
{ stream: true }
|
|
20910
|
+
);
|
|
20911
|
+
flushLiveStdinBuffer();
|
|
20912
|
+
}
|
|
20913
|
+
} catch {
|
|
20914
|
+
}
|
|
20915
|
+
_stdinLiveBuffer += _stdinLiveDecoder.decode();
|
|
20916
|
+
finishLiveStdin();
|
|
20917
|
+
})();
|
|
20918
|
+
}
|
|
20306
20919
|
var _stdin = {
|
|
20307
20920
|
readable: true,
|
|
20308
20921
|
paused: true,
|
|
20309
20922
|
encoding: null,
|
|
20923
|
+
isRaw: false,
|
|
20310
20924
|
read(size) {
|
|
20925
|
+
if (_stdinLiveBuffer.length > 0) {
|
|
20926
|
+
if (!size || size >= _stdinLiveBuffer.length) {
|
|
20927
|
+
const chunk3 = _stdinLiveBuffer;
|
|
20928
|
+
_stdinLiveBuffer = "";
|
|
20929
|
+
return chunk3;
|
|
20930
|
+
}
|
|
20931
|
+
const chunk2 = _stdinLiveBuffer.slice(0, size);
|
|
20932
|
+
_stdinLiveBuffer = _stdinLiveBuffer.slice(size);
|
|
20933
|
+
return chunk2;
|
|
20934
|
+
}
|
|
20311
20935
|
if (getStdinPosition() >= getStdinData().length) return null;
|
|
20312
20936
|
const chunk = size ? getStdinData().slice(getStdinPosition(), getStdinPosition() + size) : getStdinData().slice(getStdinPosition());
|
|
20313
20937
|
setStdinPosition(getStdinPosition() + chunk.length);
|
|
@@ -20316,6 +20940,12 @@ ${headerLines}\r
|
|
|
20316
20940
|
on(event, listener) {
|
|
20317
20941
|
if (!_stdinListeners[event]) _stdinListeners[event] = [];
|
|
20318
20942
|
_stdinListeners[event].push(listener);
|
|
20943
|
+
if (_getStdinIsTTY() && (event === "data" || event === "end" || event === "close")) {
|
|
20944
|
+
ensureLiveStdinStarted();
|
|
20945
|
+
}
|
|
20946
|
+
if (event === "data" && this.paused) {
|
|
20947
|
+
this.resume();
|
|
20948
|
+
}
|
|
20319
20949
|
if (event === "end" && getStdinData() && !getStdinEnded()) {
|
|
20320
20950
|
setStdinFlowMode(true);
|
|
20321
20951
|
_emitStdinData();
|
|
@@ -20348,11 +20978,17 @@ ${headerLines}\r
|
|
|
20348
20978
|
pause() {
|
|
20349
20979
|
this.paused = true;
|
|
20350
20980
|
setStdinFlowMode(false);
|
|
20981
|
+
syncLiveStdinHandle(false);
|
|
20351
20982
|
return this;
|
|
20352
20983
|
},
|
|
20353
20984
|
resume() {
|
|
20985
|
+
if (_getStdinIsTTY()) {
|
|
20986
|
+
ensureLiveStdinStarted();
|
|
20987
|
+
syncLiveStdinHandle(true);
|
|
20988
|
+
}
|
|
20354
20989
|
this.paused = false;
|
|
20355
20990
|
setStdinFlowMode(true);
|
|
20991
|
+
flushLiveStdinBuffer();
|
|
20356
20992
|
_emitStdinData();
|
|
20357
20993
|
return this;
|
|
20358
20994
|
},
|
|
@@ -20367,6 +21003,7 @@ ${headerLines}\r
|
|
|
20367
21003
|
if (typeof _ptySetRawMode !== "undefined") {
|
|
20368
21004
|
_ptySetRawMode.applySync(void 0, [mode]);
|
|
20369
21005
|
}
|
|
21006
|
+
this.isRaw = mode;
|
|
20370
21007
|
return this;
|
|
20371
21008
|
},
|
|
20372
21009
|
get isTTY() {
|
|
@@ -20508,11 +21145,8 @@ ${headerLines}\r
|
|
|
20508
21145
|
return process2.exit(1);
|
|
20509
21146
|
},
|
|
20510
21147
|
nextTick(callback, ...args) {
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
} else {
|
|
20514
|
-
Promise.resolve().then(() => callback(...args));
|
|
20515
|
-
}
|
|
21148
|
+
_nextTickQueue.push({ callback, args });
|
|
21149
|
+
scheduleNextTickFlush();
|
|
20516
21150
|
},
|
|
20517
21151
|
hrtime,
|
|
20518
21152
|
getuid() {
|
|
@@ -20601,6 +21235,16 @@ ${headerLines}\r
|
|
|
20601
21235
|
throw err;
|
|
20602
21236
|
}
|
|
20603
21237
|
const sigNum = _resolveSignal(signal);
|
|
21238
|
+
if (sigNum === 0) {
|
|
21239
|
+
return true;
|
|
21240
|
+
}
|
|
21241
|
+
const sigName = _signalNamesByNumber[sigNum] ?? `SIG${sigNum}`;
|
|
21242
|
+
if (_emit(sigName, sigName)) {
|
|
21243
|
+
return true;
|
|
21244
|
+
}
|
|
21245
|
+
if (_ignoredSelfSignals.has(sigName)) {
|
|
21246
|
+
return true;
|
|
21247
|
+
}
|
|
20604
21248
|
return process2.exit(128 + sigNum);
|
|
20605
21249
|
},
|
|
20606
21250
|
// EventEmitter methods
|
|
@@ -20803,6 +21447,34 @@ ${headerLines}\r
|
|
|
20803
21447
|
}
|
|
20804
21448
|
};
|
|
20805
21449
|
var _timerEntries = /* @__PURE__ */ new Map();
|
|
21450
|
+
var _nextTickQueue = [];
|
|
21451
|
+
var _nextTickScheduled = false;
|
|
21452
|
+
function flushNextTickQueue() {
|
|
21453
|
+
_nextTickScheduled = false;
|
|
21454
|
+
while (_nextTickQueue.length > 0) {
|
|
21455
|
+
const entry = _nextTickQueue.shift();
|
|
21456
|
+
if (!entry) {
|
|
21457
|
+
break;
|
|
21458
|
+
}
|
|
21459
|
+
try {
|
|
21460
|
+
entry.callback(...entry.args);
|
|
21461
|
+
} catch (error) {
|
|
21462
|
+
const outcome = routeAsyncCallbackError(error);
|
|
21463
|
+
if (!outcome.handled && outcome.rethrow !== null) {
|
|
21464
|
+
_nextTickQueue.length = 0;
|
|
21465
|
+
scheduleAsyncRethrow(outcome.rethrow);
|
|
21466
|
+
}
|
|
21467
|
+
return;
|
|
21468
|
+
}
|
|
21469
|
+
}
|
|
21470
|
+
}
|
|
21471
|
+
function scheduleNextTickFlush() {
|
|
21472
|
+
if (_nextTickScheduled) {
|
|
21473
|
+
return;
|
|
21474
|
+
}
|
|
21475
|
+
_nextTickScheduled = true;
|
|
21476
|
+
_queueMicrotask(flushNextTickQueue);
|
|
21477
|
+
}
|
|
20806
21478
|
function timerDispatch(_eventType, payload) {
|
|
20807
21479
|
const timerId = typeof payload === "number" ? payload : Number(payload?.timerId);
|
|
20808
21480
|
if (!Number.isFinite(timerId)) return;
|
|
@@ -20814,7 +21486,12 @@ ${headerLines}\r
|
|
|
20814
21486
|
}
|
|
20815
21487
|
try {
|
|
20816
21488
|
entry.callback(...entry.args);
|
|
20817
|
-
} catch (
|
|
21489
|
+
} catch (error) {
|
|
21490
|
+
const outcome = routeAsyncCallbackError(error);
|
|
21491
|
+
if (!outcome.handled && outcome.rethrow !== null) {
|
|
21492
|
+
throw outcome.rethrow;
|
|
21493
|
+
}
|
|
21494
|
+
return;
|
|
20818
21495
|
}
|
|
20819
21496
|
if (entry.repeat && _timerEntries.has(timerId)) {
|
|
20820
21497
|
armKernelTimer(timerId);
|
|
@@ -21304,12 +21981,11 @@ ${headerLines}\r
|
|
|
21304
21981
|
g.queueMicrotask = _queueMicrotask;
|
|
21305
21982
|
}
|
|
21306
21983
|
installWhatwgUrlGlobals(g);
|
|
21307
|
-
|
|
21308
|
-
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
}
|
|
21984
|
+
g.TextEncoder = TextEncoder2;
|
|
21985
|
+
g.TextDecoder = TextDecoder2;
|
|
21986
|
+
g.Event = Event;
|
|
21987
|
+
g.CustomEvent = CustomEvent;
|
|
21988
|
+
g.EventTarget = EventTarget;
|
|
21313
21989
|
if (typeof g.Buffer === "undefined") {
|
|
21314
21990
|
g.Buffer = Buffer3;
|
|
21315
21991
|
}
|