mphttpx 1.0.7 → 1.0.8
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/README.md +45 -45
- package/dist/index.cjs.js +1296 -1082
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +78 -156
- package/dist/index.esm.js +1296 -1082
- package/dist/index.esm.min.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
const polyfill = Symbol("isPolyfill");
|
|
3
1
|
/* eslint-disable no-prototype-builtins */
|
|
4
2
|
/** @internal */ const g = (typeof globalThis !== "undefined" && globalThis) ||
|
|
5
3
|
(typeof self !== "undefined" && self) ||
|
|
@@ -7,11 +5,28 @@ const polyfill = Symbol("isPolyfill");
|
|
|
7
5
|
(typeof global !== "undefined" && global) ||
|
|
8
6
|
{};
|
|
9
7
|
/** @internal */
|
|
8
|
+
const polyfill = "MPHTTPX";
|
|
9
|
+
/** @internal */
|
|
10
|
+
function Class_setStringTag(targetFunc, stringTag) {
|
|
11
|
+
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
12
|
+
configurable: true,
|
|
13
|
+
value: stringTag,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
function checkArgsLength(args, required, className, funcName) {
|
|
18
|
+
if (args.length < required) {
|
|
19
|
+
throw new TypeError(`Failed to ${funcName ? ("execute '" + funcName + "' on") : "construct"} '${className}': ${required} argument${required > 1 ? "s" : ""} required, but only ${args.length} present.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** @internal */
|
|
10
23
|
class MPException extends Error {
|
|
11
24
|
constructor(message, name) {
|
|
12
|
-
super();
|
|
13
|
-
this.
|
|
14
|
-
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "Error";
|
|
27
|
+
if (name) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
}
|
|
15
30
|
}
|
|
16
31
|
}
|
|
17
32
|
/** @internal */
|
|
@@ -31,35 +46,28 @@ function isPolyfillType(name, value) {
|
|
|
31
46
|
&& Array.isArray(value.isPolyfill.hierarchy)
|
|
32
47
|
&& value.isPolyfill.hierarchy.indexOf(name) > -1;
|
|
33
48
|
}
|
|
34
|
-
/** @internal */
|
|
35
|
-
function dfStringTag(targetFunc, stringTag) {
|
|
36
|
-
Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
|
|
37
|
-
configurable: true,
|
|
38
|
-
value: stringTag,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/** @internal */
|
|
42
|
-
function objectValues(obj) {
|
|
43
|
-
return Object.keys(obj).map(key => obj[key]);
|
|
44
|
-
}
|
|
45
|
-
/** @internal */
|
|
46
|
-
function objectEntries(obj) {
|
|
47
|
-
return Object.keys(obj).map(key => [key, obj[key]]);
|
|
48
|
-
}
|
|
49
49
|
|
|
50
|
+
/** @type {typeof globalThis.TextEncoder} */
|
|
50
51
|
class TextEncoderP {
|
|
51
52
|
get encoding() { return "utf-8"; }
|
|
52
53
|
encode(input = "") {
|
|
53
|
-
|
|
54
|
+
let _input = "" + input;
|
|
55
|
+
return encodeText(_input).encoded;
|
|
54
56
|
}
|
|
55
|
-
encodeInto(
|
|
56
|
-
|
|
57
|
+
encodeInto(...args) {
|
|
58
|
+
const [source, destination] = args;
|
|
59
|
+
checkArgsLength(args, 2, "TextEncoder", "encodeInto");
|
|
60
|
+
let _source = "" + source;
|
|
61
|
+
if (!(destination instanceof Uint8Array)) {
|
|
62
|
+
throw new TypeError("Failed to execute 'encodeInto' on 'TextEncoder': parameter 2 is not of type 'Uint8Array'.");
|
|
63
|
+
}
|
|
64
|
+
let result = encodeText(_source, destination);
|
|
57
65
|
return { read: result.read, written: result.written };
|
|
58
66
|
}
|
|
59
|
-
toString() { return "[object TextEncoder]"; }
|
|
60
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
67
|
+
/** @internal */ toString() { return "[object TextEncoder]"; }
|
|
68
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
|
|
61
69
|
}
|
|
62
|
-
|
|
70
|
+
Class_setStringTag(TextEncoderP, "TextEncoder");
|
|
63
71
|
function encodeText(input, destination) {
|
|
64
72
|
const HAS_DESTINATION = typeof destination !== "undefined";
|
|
65
73
|
let pos = 0;
|
|
@@ -69,26 +77,34 @@ function encodeText(input, destination) {
|
|
|
69
77
|
let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
|
|
70
78
|
let target = HAS_DESTINATION ? destination : new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
|
|
71
79
|
while (pos < len) {
|
|
72
|
-
let value = input.charCodeAt(pos
|
|
80
|
+
let value = input.charCodeAt(pos);
|
|
81
|
+
let codeUnitCount = 1;
|
|
73
82
|
if (value >= 0xd800 && value <= 0xdbff) {
|
|
74
83
|
// high surrogate
|
|
75
|
-
if (pos < len) {
|
|
76
|
-
let extra = input.charCodeAt(pos);
|
|
84
|
+
if (pos + 1 < len) {
|
|
85
|
+
let extra = input.charCodeAt(pos + 1);
|
|
77
86
|
if ((extra & 0xfc00) === 0xdc00) {
|
|
78
|
-
|
|
87
|
+
codeUnitCount = 2;
|
|
88
|
+
pos += 2;
|
|
79
89
|
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
80
90
|
}
|
|
81
91
|
else {
|
|
92
|
+
pos += 1;
|
|
82
93
|
value = 0xfffd;
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
else {
|
|
97
|
+
pos += 1;
|
|
86
98
|
value = 0xfffd;
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
else if (value >= 0xdc00 && value <= 0xdfff) {
|
|
102
|
+
pos += 1;
|
|
90
103
|
value = 0xfffd;
|
|
91
104
|
}
|
|
105
|
+
else {
|
|
106
|
+
pos += 1;
|
|
107
|
+
}
|
|
92
108
|
// expand the buffer if we couldn't write 4 bytes
|
|
93
109
|
if (!HAS_DESTINATION && at + 4 > target.length) {
|
|
94
110
|
tlen += 8; // minimum extra
|
|
@@ -118,28 +134,30 @@ function encodeText(input, destination) {
|
|
|
118
134
|
if (HAS_DESTINATION && at + byteCount > target.length) {
|
|
119
135
|
break;
|
|
120
136
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
switch (byteCount) {
|
|
138
|
+
case 1: // 1-byte
|
|
139
|
+
target[at++] = value; // ASCII
|
|
140
|
+
break;
|
|
141
|
+
case 2: // 2-byte
|
|
142
|
+
target[at++] = ((value >> 6) & 0x1f) | 0xc0;
|
|
143
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
144
|
+
break;
|
|
145
|
+
case 3: // 3-byte
|
|
146
|
+
target[at++] = ((value >> 12) & 0x0f) | 0xe0;
|
|
147
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
148
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
149
|
+
break;
|
|
150
|
+
case 4: // 4-byte
|
|
151
|
+
target[at++] = ((value >> 18) & 0x07) | 0xf0;
|
|
152
|
+
target[at++] = ((value >> 12) & 0x3f) | 0x80;
|
|
153
|
+
target[at++] = ((value >> 6) & 0x3f) | 0x80;
|
|
154
|
+
target[at++] = (value & 0x3f) | 0x80;
|
|
155
|
+
break;
|
|
138
156
|
}
|
|
139
|
-
read
|
|
157
|
+
read += codeUnitCount;
|
|
140
158
|
}
|
|
141
159
|
return {
|
|
142
|
-
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination
|
|
160
|
+
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination,
|
|
143
161
|
read: read,
|
|
144
162
|
written: at,
|
|
145
163
|
};
|
|
@@ -149,78 +167,83 @@ const TextEncoderE = g["TextEncoder"] || TextEncoderP;
|
|
|
149
167
|
var _a$a, _b$3;
|
|
150
168
|
/** @internal */
|
|
151
169
|
const state$h = Symbol( /* "TextDecoderState" */);
|
|
170
|
+
/** @type {typeof globalThis.TextDecoder} */
|
|
152
171
|
class TextDecoderP {
|
|
153
|
-
constructor(
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
|
|
173
|
+
let _label = "" + label;
|
|
174
|
+
if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_label.toLowerCase()) === -1) {
|
|
175
|
+
throw new RangeError(`Failed to construct 'TextDecoder': encoding ('${_label}') not implemented.`);
|
|
156
176
|
}
|
|
157
177
|
this[state$h] = new TextDecoderState();
|
|
158
|
-
this[state$h].fatal = fatal;
|
|
159
|
-
this[state$h].ignoreBOM = ignoreBOM;
|
|
178
|
+
this[state$h].fatal = !!fatal;
|
|
179
|
+
this[state$h].ignoreBOM = !!ignoreBOM;
|
|
160
180
|
}
|
|
161
181
|
get encoding() { return "utf-8"; }
|
|
162
182
|
get fatal() { return this[state$h].fatal; }
|
|
163
183
|
get ignoreBOM() { return this[state$h].ignoreBOM; }
|
|
164
|
-
decode(
|
|
165
|
-
const
|
|
166
|
-
let
|
|
167
|
-
if (
|
|
168
|
-
if (
|
|
169
|
-
|
|
184
|
+
decode(input, { stream = false } = {}) {
|
|
185
|
+
const s = this[state$h];
|
|
186
|
+
let bytes;
|
|
187
|
+
if (input !== undefined) {
|
|
188
|
+
if (input instanceof ArrayBuffer) {
|
|
189
|
+
bytes = new Uint8Array(input);
|
|
190
|
+
}
|
|
191
|
+
else if (input instanceof Uint8Array) {
|
|
192
|
+
bytes = input;
|
|
170
193
|
}
|
|
171
|
-
else if (ArrayBuffer.isView(
|
|
172
|
-
|
|
194
|
+
else if (ArrayBuffer.isView(input)) {
|
|
195
|
+
bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
173
196
|
}
|
|
174
197
|
else {
|
|
175
|
-
|
|
198
|
+
throw new TypeError("Failed to execute 'decode' on 'TextDecoder': parameter 1 is not of type 'ArrayBuffer'.");
|
|
176
199
|
}
|
|
177
200
|
}
|
|
178
201
|
else {
|
|
179
|
-
if (
|
|
202
|
+
if (s[_partial].length > 0) {
|
|
180
203
|
if (this.fatal) {
|
|
204
|
+
s[_partial] = [];
|
|
181
205
|
throw new TypeError("TextDecoder: Incomplete UTF-8 sequence.");
|
|
182
206
|
}
|
|
183
|
-
else {
|
|
184
|
-
that[_partial] = [];
|
|
185
|
-
}
|
|
186
207
|
}
|
|
187
208
|
return "";
|
|
188
209
|
}
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
210
|
+
if (s[_bomDone] < 3) {
|
|
211
|
+
s[_bomDone] += bytes.length;
|
|
212
|
+
if (bytes.length >= 3) {
|
|
213
|
+
if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) {
|
|
214
|
+
bytes = bytes.subarray(3); // × WeChat 2.5.0
|
|
215
|
+
}
|
|
193
216
|
}
|
|
194
217
|
}
|
|
195
|
-
if (
|
|
196
|
-
let merged = new Uint8Array(
|
|
197
|
-
merged.set(
|
|
198
|
-
merged.set(
|
|
199
|
-
|
|
200
|
-
|
|
218
|
+
if (s[_partial].length > 0) {
|
|
219
|
+
let merged = new Uint8Array(s[_partial].length + bytes.length);
|
|
220
|
+
merged.set(s[_partial], 0);
|
|
221
|
+
merged.set(bytes, s[_partial].length);
|
|
222
|
+
bytes = merged;
|
|
223
|
+
s[_partial] = [];
|
|
201
224
|
}
|
|
202
|
-
let end =
|
|
225
|
+
let end = bytes.length;
|
|
203
226
|
let res = [];
|
|
204
|
-
if (stream &&
|
|
205
|
-
let i =
|
|
206
|
-
while (i > 0 && i >
|
|
207
|
-
let byte =
|
|
227
|
+
if (stream && bytes.length > 0) {
|
|
228
|
+
let i = bytes.length;
|
|
229
|
+
while (i > 0 && i > bytes.length - 4) {
|
|
230
|
+
let byte = bytes[i - 1];
|
|
208
231
|
if ((byte & 0b11000000) !== 0b10000000) {
|
|
209
232
|
let len = getBytesPerSequence(byte);
|
|
210
|
-
if (len >
|
|
233
|
+
if (len > bytes.length - (i - 1)) {
|
|
211
234
|
end = i - 1;
|
|
212
235
|
}
|
|
213
236
|
break;
|
|
214
237
|
}
|
|
215
238
|
i--;
|
|
216
239
|
}
|
|
217
|
-
|
|
218
|
-
|
|
240
|
+
s[_partial] = Array.from(bytes.slice(end)); // save tail // × WeChat 2.5.0
|
|
241
|
+
bytes = bytes.slice(0, end); // × WeChat 2.5.0
|
|
219
242
|
}
|
|
220
243
|
let i = 0;
|
|
221
244
|
while (i < end) {
|
|
222
|
-
let firstByte = buf[i];
|
|
223
245
|
let codePoint = null;
|
|
246
|
+
let firstByte = bytes[i];
|
|
224
247
|
let bytesPerSequence = getBytesPerSequence(firstByte);
|
|
225
248
|
if (i + bytesPerSequence <= end) {
|
|
226
249
|
let secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
@@ -231,7 +254,7 @@ class TextDecoderP {
|
|
|
231
254
|
}
|
|
232
255
|
break;
|
|
233
256
|
case 2:
|
|
234
|
-
secondByte =
|
|
257
|
+
secondByte = bytes[i + 1];
|
|
235
258
|
if ((secondByte & 0xC0) === 0x80) {
|
|
236
259
|
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
237
260
|
if (tempCodePoint > 0x7F) {
|
|
@@ -240,8 +263,8 @@ class TextDecoderP {
|
|
|
240
263
|
}
|
|
241
264
|
break;
|
|
242
265
|
case 3:
|
|
243
|
-
secondByte =
|
|
244
|
-
thirdByte =
|
|
266
|
+
secondByte = bytes[i + 1];
|
|
267
|
+
thirdByte = bytes[i + 2];
|
|
245
268
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
246
269
|
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
247
270
|
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
@@ -250,27 +273,31 @@ class TextDecoderP {
|
|
|
250
273
|
}
|
|
251
274
|
break;
|
|
252
275
|
case 4:
|
|
253
|
-
secondByte =
|
|
254
|
-
thirdByte =
|
|
255
|
-
fourthByte =
|
|
276
|
+
secondByte = bytes[i + 1];
|
|
277
|
+
thirdByte = bytes[i + 2];
|
|
278
|
+
fourthByte = bytes[i + 3];
|
|
256
279
|
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
257
280
|
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
258
281
|
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
259
282
|
codePoint = tempCodePoint;
|
|
260
283
|
}
|
|
261
284
|
}
|
|
285
|
+
break;
|
|
262
286
|
}
|
|
263
287
|
}
|
|
264
288
|
if (codePoint === null) {
|
|
265
289
|
if (this.fatal) {
|
|
290
|
+
s[_partial] = [];
|
|
266
291
|
throw new TypeError("TextDecoder.decode: Decoding failed.");
|
|
267
292
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
codePoint = 0xFFFD;
|
|
272
|
-
bytesPerSequence = 1;
|
|
293
|
+
let skip = 1;
|
|
294
|
+
while (i + skip < end && (bytes[i + skip] & 0b11000000) === 0b10000000) {
|
|
295
|
+
skip += 1;
|
|
273
296
|
}
|
|
297
|
+
// we did not generate a valid codePoint so insert a replacement char (U+FFFD)
|
|
298
|
+
res.push(0xFFFD);
|
|
299
|
+
i += skip;
|
|
300
|
+
continue;
|
|
274
301
|
}
|
|
275
302
|
else if (codePoint > 0xFFFF) {
|
|
276
303
|
// encode to utf16 (surrogate pair dance)
|
|
@@ -281,62 +308,70 @@ class TextDecoderP {
|
|
|
281
308
|
res.push(codePoint);
|
|
282
309
|
i += bytesPerSequence;
|
|
283
310
|
}
|
|
284
|
-
|
|
285
|
-
for (let j = 0, len = res.length; j < len; j += 0x1000) {
|
|
286
|
-
str += String.fromCharCode.apply(String, res.slice(j, j + 0x1000));
|
|
287
|
-
}
|
|
288
|
-
return str;
|
|
311
|
+
return res.length > 0x4000 ? buildString(res) : concatString(res);
|
|
289
312
|
}
|
|
290
|
-
toString() { return "[object TextDecoder]"; }
|
|
291
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
313
|
+
/** @internal */ toString() { return "[object TextDecoder]"; }
|
|
314
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
|
|
292
315
|
}
|
|
293
|
-
|
|
294
|
-
/** @internal */ const
|
|
316
|
+
Class_setStringTag(TextDecoderP, "TextDecoder");
|
|
317
|
+
/** @internal */ const _bomDone = Symbol();
|
|
295
318
|
/** @internal */ const _partial = Symbol();
|
|
296
319
|
/** @internal */
|
|
297
320
|
class TextDecoderState {
|
|
298
321
|
constructor() {
|
|
299
322
|
this.fatal = false;
|
|
300
323
|
this.ignoreBOM = false;
|
|
301
|
-
this[_a$a] =
|
|
324
|
+
this[_a$a] = 0;
|
|
302
325
|
this[_b$3] = [];
|
|
303
326
|
}
|
|
304
327
|
}
|
|
305
|
-
_a$a =
|
|
306
|
-
const UTF8Labels = ["utf-8", "utf8", "unicode-1-1-utf-8"];
|
|
328
|
+
_a$a = _bomDone, _b$3 = _partial;
|
|
307
329
|
function getBytesPerSequence(byte) {
|
|
308
330
|
return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
|
|
309
331
|
}
|
|
332
|
+
const buildString = (res) => {
|
|
333
|
+
let arr = [];
|
|
334
|
+
for (let i = 0, len = res.length; i < len; i += 0x1000) {
|
|
335
|
+
arr.push(String.fromCharCode.apply(String, res.slice(i, i + 0x1000)));
|
|
336
|
+
}
|
|
337
|
+
return arr.join("");
|
|
338
|
+
};
|
|
339
|
+
const concatString = (res) => {
|
|
340
|
+
let str = "";
|
|
341
|
+
for (let i = 0, len = res.length; i < len; i += 0x1000) {
|
|
342
|
+
str += String.fromCharCode.apply(String, res.slice(i, i + 0x1000));
|
|
343
|
+
}
|
|
344
|
+
return str;
|
|
345
|
+
};
|
|
310
346
|
const TextDecoderE = g["TextDecoder"] || TextDecoderP;
|
|
311
347
|
|
|
312
348
|
/** @internal */
|
|
313
349
|
const state$g = Symbol( /* "BlobState" */);
|
|
350
|
+
/** @type {typeof globalThis.Blob} */
|
|
314
351
|
class BlobP {
|
|
315
352
|
constructor(blobParts = [], options) {
|
|
316
|
-
if (!Array.isArray(blobParts)) {
|
|
317
|
-
throw new TypeError("
|
|
318
|
-
}
|
|
319
|
-
let
|
|
320
|
-
let chunks =
|
|
321
|
-
|
|
322
|
-
|
|
353
|
+
if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
|
|
354
|
+
throw new TypeError("Failed to construct 'Blob/File': The provided value cannot be converted to a sequence.");
|
|
355
|
+
}
|
|
356
|
+
let _blobParts = Array.isArray(blobParts) ? blobParts : Array.from(blobParts);
|
|
357
|
+
let chunks = [];
|
|
358
|
+
for (let i = 0; i < _blobParts.length; ++i) {
|
|
359
|
+
let chunk = _blobParts[i];
|
|
360
|
+
if (isPolyfillType("Blob", chunk)) {
|
|
361
|
+
chunks.push(chunk[state$g][_buffer]);
|
|
323
362
|
}
|
|
324
|
-
else if (
|
|
325
|
-
chunks.push(BufferSource_toUint8Array(
|
|
363
|
+
else if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
|
|
364
|
+
chunks.push(BufferSource_toUint8Array(chunk));
|
|
326
365
|
}
|
|
327
366
|
else {
|
|
328
|
-
|
|
329
|
-
encoder = new TextEncoderP();
|
|
330
|
-
}
|
|
331
|
-
chunks.push(encoder.encode(String(part)));
|
|
367
|
+
chunks.push(encode$1("" + chunk));
|
|
332
368
|
}
|
|
333
|
-
|
|
334
|
-
}, []);
|
|
369
|
+
}
|
|
335
370
|
this[state$g] = new BlobState(concat(chunks));
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
|
|
339
|
-
|
|
371
|
+
const s = this[state$g];
|
|
372
|
+
s.size = s[_buffer].length;
|
|
373
|
+
let rawType = "" + ((options === null || options === void 0 ? void 0 : options.type) || "");
|
|
374
|
+
s.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
|
|
340
375
|
}
|
|
341
376
|
get size() { return this[state$g].size; }
|
|
342
377
|
get type() { return this[state$g].type; }
|
|
@@ -347,20 +382,19 @@ class BlobP {
|
|
|
347
382
|
return Promise.resolve(clone(this[state$g][_buffer].buffer));
|
|
348
383
|
}
|
|
349
384
|
slice(start, end, contentType) {
|
|
350
|
-
let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length);
|
|
351
|
-
return new BlobP([sliced], { type: contentType !== null && contentType !== void 0 ? contentType : "" });
|
|
385
|
+
let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length); // × WeChat 2.5.0
|
|
386
|
+
return new BlobP([sliced], { type: "" + (contentType !== null && contentType !== void 0 ? contentType : "") });
|
|
352
387
|
}
|
|
353
388
|
stream() {
|
|
354
|
-
throw new
|
|
389
|
+
throw new TypeError("Failed to execute 'stream' on 'Blob': method not implemented.");
|
|
355
390
|
}
|
|
356
391
|
text() {
|
|
357
|
-
|
|
358
|
-
return Promise.resolve(decoder.decode(this[state$g][_buffer]));
|
|
392
|
+
return Promise.resolve(decode$1(this[state$g][_buffer]));
|
|
359
393
|
}
|
|
360
|
-
toString() { return "[object Blob]"; }
|
|
361
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
394
|
+
/** @internal */ toString() { return "[object Blob]"; }
|
|
395
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
|
|
362
396
|
}
|
|
363
|
-
|
|
397
|
+
Class_setStringTag(BlobP, "Blob");
|
|
364
398
|
/** @internal */
|
|
365
399
|
const _buffer = Symbol();
|
|
366
400
|
/** @internal */
|
|
@@ -396,6 +430,16 @@ function concat(chunks) {
|
|
|
396
430
|
return result;
|
|
397
431
|
}
|
|
398
432
|
/** @internal */
|
|
433
|
+
function encode$1(str) {
|
|
434
|
+
let encoder = new TextEncoderP();
|
|
435
|
+
return encoder.encode(str);
|
|
436
|
+
}
|
|
437
|
+
/** @internal */
|
|
438
|
+
function decode$1(buf) {
|
|
439
|
+
let decoder = new TextDecoderP();
|
|
440
|
+
return decoder.decode(buf);
|
|
441
|
+
}
|
|
442
|
+
/** @internal */
|
|
399
443
|
function Uint8Array_toBase64(input) {
|
|
400
444
|
let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
401
445
|
let output = [];
|
|
@@ -423,20 +467,23 @@ const BlobE = g["Blob"] || BlobP;
|
|
|
423
467
|
|
|
424
468
|
/** @internal */
|
|
425
469
|
const state$f = Symbol( /* "FileState" */);
|
|
470
|
+
/** @type {typeof globalThis.File} */
|
|
426
471
|
class FileP extends BlobP {
|
|
427
|
-
constructor(
|
|
472
|
+
constructor(...args) {
|
|
473
|
+
const [fileBits, fileName, options] = args;
|
|
474
|
+
checkArgsLength(args, 2, "File");
|
|
428
475
|
super(fileBits, options);
|
|
429
476
|
this[state$f] = new FileState();
|
|
430
|
-
this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date());
|
|
431
|
-
this[state$f].name =
|
|
477
|
+
this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date()) || 0;
|
|
478
|
+
this[state$f].name = "" + fileName;
|
|
432
479
|
}
|
|
433
480
|
get lastModified() { return this[state$f].lastModified; }
|
|
434
481
|
get name() { return this[state$f].name; }
|
|
435
482
|
get webkitRelativePath() { return ""; }
|
|
436
|
-
toString() { return "[object File]"; }
|
|
437
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
483
|
+
/** @internal */ toString() { return "[object File]"; }
|
|
484
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
|
|
438
485
|
}
|
|
439
|
-
|
|
486
|
+
Class_setStringTag(FileP, "File");
|
|
440
487
|
/** @internal */
|
|
441
488
|
class FileState {
|
|
442
489
|
constructor() {
|
|
@@ -448,14 +495,17 @@ const FileE = g["Blob"] ? g["File"] : FileP;
|
|
|
448
495
|
|
|
449
496
|
var _a$9, _b$2, _c$1, _d$1, _e$1;
|
|
450
497
|
/** @internal */ const state$e = Symbol( /* "EventState" */);
|
|
498
|
+
/** @type {typeof globalThis.Event} */
|
|
451
499
|
class EventP {
|
|
452
|
-
constructor(
|
|
500
|
+
constructor(...args) {
|
|
501
|
+
const [type, eventInitDict] = args;
|
|
502
|
+
checkArgsLength(args, 1, new.target.name);
|
|
453
503
|
this[state$e] = new EventState();
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
504
|
+
const s = this[state$e];
|
|
505
|
+
s.type = "" + type;
|
|
506
|
+
s.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
|
|
507
|
+
s.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
|
|
508
|
+
s.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
|
|
459
509
|
Object.defineProperty(this, "isTrusted", {
|
|
460
510
|
enumerable: true,
|
|
461
511
|
get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
|
|
@@ -470,7 +520,7 @@ class EventP {
|
|
|
470
520
|
get eventPhase() { return this[state$e].eventPhase; }
|
|
471
521
|
get srcElement() { return this[state$e].target; }
|
|
472
522
|
get cancelBubble() { return this[state$e].cancelBubble; }
|
|
473
|
-
set cancelBubble(value) { this[state$e].cancelBubble = value; }
|
|
523
|
+
set cancelBubble(value) { this[state$e].cancelBubble = !!value; }
|
|
474
524
|
get defaultPrevented() { return this[state$e].defaultPrevented; }
|
|
475
525
|
get returnValue() { return this[state$e].returnValue; }
|
|
476
526
|
set returnValue(value) { if (!value) {
|
|
@@ -483,24 +533,26 @@ class EventP {
|
|
|
483
533
|
path.push(this.currentTarget);
|
|
484
534
|
return path;
|
|
485
535
|
}
|
|
486
|
-
initEvent(
|
|
487
|
-
const
|
|
488
|
-
|
|
536
|
+
initEvent(...args) {
|
|
537
|
+
const [type, bubbles, cancelable] = args;
|
|
538
|
+
checkArgsLength(args, 1, "Event", "initEvent");
|
|
539
|
+
const s = this[state$e];
|
|
540
|
+
if (s[_dispatched])
|
|
489
541
|
return;
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
542
|
+
s.type = "" + type;
|
|
543
|
+
s.bubbles = !!bubbles;
|
|
544
|
+
s.cancelable = !!cancelable;
|
|
493
545
|
}
|
|
494
546
|
preventDefault() {
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
547
|
+
const s = this[state$e];
|
|
548
|
+
if (s[_passive]) {
|
|
497
549
|
console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
|
|
498
550
|
return;
|
|
499
551
|
}
|
|
500
552
|
if (this.cancelable) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
553
|
+
s[_preventDefaultCalled] = true;
|
|
554
|
+
s.defaultPrevented = true;
|
|
555
|
+
s.returnValue = false;
|
|
504
556
|
}
|
|
505
557
|
}
|
|
506
558
|
stopImmediatePropagation() {
|
|
@@ -510,8 +562,8 @@ class EventP {
|
|
|
510
562
|
stopPropagation() {
|
|
511
563
|
this.cancelBubble = true;
|
|
512
564
|
}
|
|
513
|
-
toString() { return "[object Event]"; }
|
|
514
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
565
|
+
/** @internal */ toString() { return "[object Event]"; }
|
|
566
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
515
567
|
}
|
|
516
568
|
const properties$2 = {
|
|
517
569
|
NONE: { value: 0, enumerable: true },
|
|
@@ -521,7 +573,7 @@ const properties$2 = {
|
|
|
521
573
|
};
|
|
522
574
|
Object.defineProperties(EventP, properties$2);
|
|
523
575
|
Object.defineProperties(EventP.prototype, properties$2);
|
|
524
|
-
|
|
576
|
+
Class_setStringTag(EventP, "Event");
|
|
525
577
|
/** @internal */ const _timeStamp = (new Date()).getTime();
|
|
526
578
|
/** @internal */ const _isTrusted = Symbol();
|
|
527
579
|
/** @internal */ const _passive = Symbol();
|
|
@@ -610,16 +662,23 @@ const dispatched$1 = 1;
|
|
|
610
662
|
const preventDefaultCalled = 2;
|
|
611
663
|
const stopImmediatePropagationCalled = 3;
|
|
612
664
|
/** @internal */ const state$d = Symbol( /* "EventTargetState" */);
|
|
665
|
+
/** @type {typeof globalThis.EventTarget} */
|
|
613
666
|
class EventTargetP {
|
|
614
667
|
constructor() {
|
|
615
668
|
this[state$d] = new EventTargetState(this);
|
|
669
|
+
this[state$d].name = new.target.name;
|
|
616
670
|
}
|
|
617
|
-
addEventListener(
|
|
618
|
-
const
|
|
671
|
+
addEventListener(...args) {
|
|
672
|
+
const [type, callback, options] = args;
|
|
673
|
+
checkArgsLength(args, 2, this[state$d].name, "addEventListener");
|
|
674
|
+
if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
|
|
675
|
+
throw new TypeError(`Failed to execute 'addEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
|
|
676
|
+
}
|
|
677
|
+
const s = this[state$d];
|
|
619
678
|
const executor = new Executor(type, callback);
|
|
620
679
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
621
|
-
if (!
|
|
622
|
-
if (typeof options === "object") {
|
|
680
|
+
if (!s[_executors].some(x => x.equals(executor))) {
|
|
681
|
+
if (options && typeof options === "object") {
|
|
623
682
|
const { once, passive, signal } = options;
|
|
624
683
|
executor.options.once = !!once;
|
|
625
684
|
executor.options.passive = !!passive;
|
|
@@ -628,39 +687,44 @@ class EventTargetP {
|
|
|
628
687
|
reply(this, signal, executor);
|
|
629
688
|
}
|
|
630
689
|
}
|
|
631
|
-
|
|
690
|
+
s[_executors].push(executor);
|
|
632
691
|
const f = (v) => !!v.options.capture ? 0 : 1;
|
|
633
|
-
|
|
692
|
+
s[_executors] = s[_executors].sort((a, b) => f(a) - f(b));
|
|
634
693
|
}
|
|
635
694
|
}
|
|
636
|
-
dispatchEvent(
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
695
|
+
dispatchEvent(...args) {
|
|
696
|
+
const [event] = args;
|
|
697
|
+
checkArgsLength(args, 1, this[state$d].name, "dispatchEvent");
|
|
640
698
|
if (!(event instanceof EventP)) {
|
|
641
|
-
throw new TypeError(
|
|
699
|
+
throw new TypeError(`Failed to execute 'dispatchEvent' on '${this[state$d].name}': parameter 1 is not of type 'Event'.`);
|
|
642
700
|
}
|
|
643
701
|
Event_setTrusted(event, false);
|
|
644
702
|
event[state$e].target = this;
|
|
645
703
|
return EventTarget_fire(this, event);
|
|
646
704
|
}
|
|
647
|
-
removeEventListener(
|
|
648
|
-
const
|
|
705
|
+
removeEventListener(...args) {
|
|
706
|
+
const [type, callback, options] = args;
|
|
707
|
+
checkArgsLength(args, 2, this[state$d].name, "removeEventListener");
|
|
708
|
+
if (typeof callback !== "function" && typeof callback !== "object" && typeof callback !== "undefined") {
|
|
709
|
+
throw new TypeError(`Failed to execute 'removeEventListener' on '${this[state$d].name}': parameter 2 is not of type 'Object'.`);
|
|
710
|
+
}
|
|
711
|
+
const s = this[state$d];
|
|
649
712
|
const executor = new Executor(type, callback);
|
|
650
713
|
executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
|
|
651
|
-
if (
|
|
652
|
-
|
|
714
|
+
if (s[_executors].some(x => x.equals(executor))) {
|
|
715
|
+
s[_executors] = s[_executors].filter(x => !x.equals(executor));
|
|
653
716
|
}
|
|
654
717
|
}
|
|
655
|
-
toString() { return "[object EventTarget]"; }
|
|
656
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
718
|
+
/** @internal */ toString() { return "[object EventTarget]"; }
|
|
719
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
|
|
657
720
|
}
|
|
658
|
-
|
|
721
|
+
Class_setStringTag(EventTargetP, "EventTarget");
|
|
659
722
|
/** @internal */
|
|
660
723
|
const _executors = Symbol();
|
|
661
724
|
/** @internal */
|
|
662
725
|
class EventTargetState {
|
|
663
726
|
constructor(target) {
|
|
727
|
+
this.name = "EventTarget";
|
|
664
728
|
this[_a$8] = [];
|
|
665
729
|
this.target = target;
|
|
666
730
|
}
|
|
@@ -668,23 +732,25 @@ class EventTargetState {
|
|
|
668
732
|
_a$8 = _executors;
|
|
669
733
|
/** @internal */
|
|
670
734
|
function EventTarget_fire(target, event) {
|
|
671
|
-
const
|
|
672
|
-
const
|
|
735
|
+
const s = target[state$d];
|
|
736
|
+
const evs = event[state$e];
|
|
673
737
|
if (!event.target)
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
738
|
+
evs.target = target;
|
|
739
|
+
evs.currentTarget = target;
|
|
740
|
+
evs.eventPhase = EventP.AT_TARGET;
|
|
677
741
|
Event_setEtField(event, dispatched$1, true);
|
|
678
742
|
let onceIndexes = [];
|
|
679
|
-
for (let i = 0; i <
|
|
680
|
-
|
|
743
|
+
for (let i = 0; i < s[_executors].length; ++i) {
|
|
744
|
+
if (Event_getEtField(event, stopImmediatePropagationCalled))
|
|
745
|
+
break;
|
|
746
|
+
let executor = s[_executors][i];
|
|
681
747
|
if (executor.type !== event.type)
|
|
682
748
|
continue;
|
|
683
|
-
Event_setEtField(event, passive, !!executor.options.passive);
|
|
684
749
|
if (executor.options.once)
|
|
685
750
|
onceIndexes.push(i);
|
|
686
|
-
|
|
751
|
+
Event_setEtField(event, passive, !!executor.options.passive);
|
|
687
752
|
try {
|
|
753
|
+
let cb = executor.callback;
|
|
688
754
|
if (typeof cb === "function")
|
|
689
755
|
cb.call(target, event);
|
|
690
756
|
}
|
|
@@ -692,25 +758,19 @@ function EventTarget_fire(target, event) {
|
|
|
692
758
|
console.error(e);
|
|
693
759
|
}
|
|
694
760
|
Event_setEtField(event, passive, false);
|
|
695
|
-
if (Event_getEtField(event, stopImmediatePropagationCalled))
|
|
696
|
-
break;
|
|
697
761
|
}
|
|
698
762
|
if (onceIndexes.length > 0) {
|
|
699
|
-
|
|
763
|
+
s[_executors] = s[_executors].reduce((acc, cur, index) => {
|
|
700
764
|
if (onceIndexes.indexOf(index) === -1)
|
|
701
765
|
acc.push(cur);
|
|
702
766
|
return acc;
|
|
703
767
|
}, []);
|
|
704
768
|
}
|
|
705
|
-
|
|
706
|
-
|
|
769
|
+
evs.currentTarget = null;
|
|
770
|
+
evs.eventPhase = EventP.NONE;
|
|
707
771
|
Event_setEtField(event, dispatched$1, false);
|
|
708
772
|
return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
|
|
709
773
|
}
|
|
710
|
-
/** @internal */
|
|
711
|
-
function EventTarget_count(target) {
|
|
712
|
-
return target[state$d][_executors].length;
|
|
713
|
-
}
|
|
714
774
|
function reply(target, signal, executor) {
|
|
715
775
|
const s = target[state$d];
|
|
716
776
|
const onAbort = () => {
|
|
@@ -728,7 +788,7 @@ function reply(target, signal, executor) {
|
|
|
728
788
|
class Executor {
|
|
729
789
|
constructor(type, callback) {
|
|
730
790
|
this.options = {};
|
|
731
|
-
this.type =
|
|
791
|
+
this.type = "" + type;
|
|
732
792
|
this.callback = extract(callback);
|
|
733
793
|
}
|
|
734
794
|
equals(executor) {
|
|
@@ -768,23 +828,34 @@ const EventTargetE = g["EventTarget"] || EventTargetP;
|
|
|
768
828
|
|
|
769
829
|
/** @internal */
|
|
770
830
|
const state$c = Symbol( /* "ProgressEventState" */);
|
|
831
|
+
/** @type {typeof globalThis.ProgressEvent} */
|
|
771
832
|
class ProgressEventP extends EventP {
|
|
772
833
|
constructor(type, eventInitDict) {
|
|
773
834
|
var _a, _b;
|
|
774
835
|
super(type, eventInitDict);
|
|
775
836
|
this[state$c] = new ProgressEventState();
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
837
|
+
const s = this[state$c];
|
|
838
|
+
s.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
|
|
839
|
+
s.loaded = Number((_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0);
|
|
840
|
+
s.total = Number((_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0);
|
|
841
|
+
let errField = "";
|
|
842
|
+
if (isNaN(s.loaded)) {
|
|
843
|
+
errField = "loaded";
|
|
844
|
+
}
|
|
845
|
+
if (isNaN(s.total)) {
|
|
846
|
+
errField = "total";
|
|
847
|
+
}
|
|
848
|
+
if (errField) {
|
|
849
|
+
throw new TypeError(`Failed to construct 'ProgressEvent': Failed to read the '${errField}' property from 'ProgressEventInit': The provided double value is non-finite.`);
|
|
850
|
+
}
|
|
780
851
|
}
|
|
781
852
|
get lengthComputable() { return getValue(this[state$c].lengthComputable); }
|
|
782
853
|
get loaded() { return getValue(this[state$c].loaded); }
|
|
783
854
|
get total() { return getValue(this[state$c].total); }
|
|
784
|
-
toString() { return "[object ProgressEvent]"; }
|
|
785
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
855
|
+
/** @internal */ toString() { return "[object ProgressEvent]"; }
|
|
856
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
|
|
786
857
|
}
|
|
787
|
-
|
|
858
|
+
Class_setStringTag(ProgressEventP, "ProgressEvent");
|
|
788
859
|
/** @internal */
|
|
789
860
|
class ProgressEventState {
|
|
790
861
|
constructor() {
|
|
@@ -819,6 +890,7 @@ const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
|
|
|
819
890
|
var _a$7;
|
|
820
891
|
/** @internal */
|
|
821
892
|
const state$b = Symbol( /* "FileReaderState" */);
|
|
893
|
+
/** @type {typeof globalThis.FileReader} */
|
|
822
894
|
class FileReaderP extends EventTargetP {
|
|
823
895
|
constructor() {
|
|
824
896
|
super();
|
|
@@ -829,32 +901,44 @@ class FileReaderP extends EventTargetP {
|
|
|
829
901
|
get error() { return this[state$b].error; }
|
|
830
902
|
abort() {
|
|
831
903
|
if (this.readyState === FileReaderP.LOADING) {
|
|
832
|
-
this[state$b]
|
|
833
|
-
|
|
904
|
+
const s = this[state$b];
|
|
905
|
+
s.readyState = FileReaderP.DONE;
|
|
906
|
+
s.result = null;
|
|
907
|
+
s.error = new MPException("An ongoing operation was aborted, typically with a call to abort().", "AbortError");
|
|
834
908
|
emitProcessEvent(this, "abort");
|
|
835
909
|
}
|
|
836
910
|
}
|
|
837
|
-
readAsArrayBuffer(
|
|
838
|
-
read$1(this, "readAsArrayBuffer",
|
|
911
|
+
readAsArrayBuffer(...args) {
|
|
912
|
+
read$1(this, "readAsArrayBuffer", args, blob => {
|
|
839
913
|
this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
|
|
840
914
|
});
|
|
841
915
|
}
|
|
842
|
-
readAsBinaryString(
|
|
843
|
-
read$1(this, "readAsBinaryString",
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
916
|
+
readAsBinaryString(...args) {
|
|
917
|
+
read$1(this, "readAsBinaryString", args, blob => {
|
|
918
|
+
let str = [];
|
|
919
|
+
let buf = Blob_toUint8Array(blob);
|
|
920
|
+
for (let i = 0; i < buf.length; ++i) {
|
|
921
|
+
let char = buf[i];
|
|
922
|
+
str.push(String.fromCharCode(char));
|
|
923
|
+
}
|
|
924
|
+
this[state$b].result = str.join("");
|
|
848
925
|
});
|
|
849
926
|
}
|
|
850
|
-
readAsDataURL(
|
|
851
|
-
read$1(this, "readAsDataURL",
|
|
927
|
+
readAsDataURL(...args) {
|
|
928
|
+
read$1(this, "readAsDataURL", args, blob => {
|
|
852
929
|
this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
|
|
853
930
|
});
|
|
854
931
|
}
|
|
855
|
-
readAsText(
|
|
856
|
-
|
|
857
|
-
|
|
932
|
+
readAsText(...args) {
|
|
933
|
+
const encoding = args.length > 1 ? args[1] : undefined;
|
|
934
|
+
read$1(this, "readAsText", args, blob => {
|
|
935
|
+
if (encoding !== undefined) {
|
|
936
|
+
let _encoding = "" + encoding;
|
|
937
|
+
if (["utf-8", "utf8", "unicode-1-1-utf-8"].indexOf(_encoding.toLowerCase()) === -1) {
|
|
938
|
+
console.error(`TypeError: Failed to execute 'readAsText' on 'FileReader': encoding ('${_encoding}') not implemented.`);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
this[state$b].result = decode$1(Blob_toUint8Array(blob));
|
|
858
942
|
});
|
|
859
943
|
}
|
|
860
944
|
get onabort() { return this[state$b].onabort; }
|
|
@@ -869,8 +953,8 @@ class FileReaderP extends EventTargetP {
|
|
|
869
953
|
set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
|
|
870
954
|
get onprogress() { return this[state$b].onprogress; }
|
|
871
955
|
set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
|
|
872
|
-
toString() { return "[object FileReader]"; }
|
|
873
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
956
|
+
/** @internal */ toString() { return "[object FileReader]"; }
|
|
957
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
874
958
|
}
|
|
875
959
|
const properties$1 = {
|
|
876
960
|
EMPTY: { value: 0, enumerable: true },
|
|
@@ -879,7 +963,7 @@ const properties$1 = {
|
|
|
879
963
|
};
|
|
880
964
|
Object.defineProperties(FileReaderP, properties$1);
|
|
881
965
|
Object.defineProperties(FileReaderP.prototype, properties$1);
|
|
882
|
-
|
|
966
|
+
Class_setStringTag(FileReaderP, "FileReader");
|
|
883
967
|
/** @internal */
|
|
884
968
|
const _handlers$3 = Symbol();
|
|
885
969
|
/** @internal */
|
|
@@ -899,7 +983,9 @@ class FileReaderState {
|
|
|
899
983
|
}
|
|
900
984
|
}
|
|
901
985
|
_a$7 = _handlers$3;
|
|
902
|
-
function read$1(reader, kind,
|
|
986
|
+
function read$1(reader, kind, args, setResult) {
|
|
987
|
+
const [blob] = args;
|
|
988
|
+
checkArgsLength(args, 1, "FileReader", kind);
|
|
903
989
|
if (!isPolyfillType("Blob", blob)) {
|
|
904
990
|
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
|
|
905
991
|
}
|
|
@@ -911,7 +997,7 @@ function read$1(reader, kind, blob, setResult) {
|
|
|
911
997
|
if (s.readyState === FileReaderP.LOADING) {
|
|
912
998
|
s.readyState = FileReaderP.DONE;
|
|
913
999
|
try {
|
|
914
|
-
setResult();
|
|
1000
|
+
setResult(blob);
|
|
915
1001
|
emitProcessEvent(s.target, "load", blob.size, blob.size);
|
|
916
1002
|
}
|
|
917
1003
|
catch (e) {
|
|
@@ -943,106 +1029,381 @@ function getHandlers$3(s) {
|
|
|
943
1029
|
const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
|
|
944
1030
|
|
|
945
1031
|
var _a$6;
|
|
946
|
-
/** @internal */ const state$a = Symbol( /* "
|
|
1032
|
+
/** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
|
|
1033
|
+
const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
|
|
1034
|
+
/** @type {typeof globalThis.URLSearchParams} */
|
|
1035
|
+
class URLSearchParamsP {
|
|
1036
|
+
constructor(init) {
|
|
1037
|
+
this[state$a] = new URLSearchParamsState();
|
|
1038
|
+
if (init !== undefined) {
|
|
1039
|
+
if (isObjectType("URLSearchParams", init)) {
|
|
1040
|
+
init.forEach((value, name) => { this.append(name, value); }, this);
|
|
1041
|
+
}
|
|
1042
|
+
else if (init && typeof init === "object") {
|
|
1043
|
+
if (Array.isArray(init) || Symbol.iterator in init) {
|
|
1044
|
+
let _init = Array.isArray(init) ? init : Array.from(init);
|
|
1045
|
+
for (let i = 0; i < _init.length; ++i) {
|
|
1046
|
+
let item = _init[i];
|
|
1047
|
+
if (Array.isArray(item) || (item && typeof item === "object" && Symbol.iterator in item)) {
|
|
1048
|
+
let pair = Array.isArray(item) ? item : Array.from(item);
|
|
1049
|
+
if (pair.length === 2) {
|
|
1050
|
+
this.append(pair[0], pair[1]);
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
else {
|
|
1057
|
+
throw new TypeError("Failed to construct 'URLSearchParams': The provided value cannot be converted to a sequence.");
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
Object.getOwnPropertyNames(init).forEach(name => { this.append(name, init[name]); }, this);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
else {
|
|
1066
|
+
let _init = "" + init;
|
|
1067
|
+
if (_init.indexOf("?") === 0) {
|
|
1068
|
+
_init = _init.slice(1);
|
|
1069
|
+
}
|
|
1070
|
+
let pairs = _init.split("&");
|
|
1071
|
+
for (let i = 0; i < pairs.length; ++i) {
|
|
1072
|
+
let pair = pairs[i], separatorIndex = pair.indexOf("=");
|
|
1073
|
+
if (separatorIndex > -1) {
|
|
1074
|
+
this.append(decode(pair.slice(0, separatorIndex)), decode(pair.slice(separatorIndex + 1)));
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
if (pair) {
|
|
1078
|
+
this.append(decode(pair), "");
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
get size() { return this[state$a][_urlspArray].length; }
|
|
1086
|
+
append(...args) {
|
|
1087
|
+
const [name, value] = args;
|
|
1088
|
+
checkArgsFn$2(args, 2, "append");
|
|
1089
|
+
this[state$a][_urlspArray].push(["" + name, normalizeValue$1(value)]);
|
|
1090
|
+
}
|
|
1091
|
+
delete(...args) {
|
|
1092
|
+
const [name, value] = args;
|
|
1093
|
+
checkArgsFn$2(args, 1, "delete");
|
|
1094
|
+
let _name = "" + name;
|
|
1095
|
+
let index = -1;
|
|
1096
|
+
let array = this[state$a][_urlspArray];
|
|
1097
|
+
let result = [];
|
|
1098
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1099
|
+
let item = array[i];
|
|
1100
|
+
if (item[0] === _name) {
|
|
1101
|
+
if (args.length !== 1 && item[1] !== normalizeValue$1(value)) {
|
|
1102
|
+
result.push(item);
|
|
1103
|
+
}
|
|
1104
|
+
index = i;
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
result.push(item);
|
|
1108
|
+
}
|
|
1109
|
+
if (index > -1) {
|
|
1110
|
+
this[state$a][_urlspArray] = result;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
get(...args) {
|
|
1114
|
+
const [name] = args;
|
|
1115
|
+
checkArgsFn$2(args, 1, "get");
|
|
1116
|
+
let _name = "" + name;
|
|
1117
|
+
let array = this[state$a][_urlspArray];
|
|
1118
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1119
|
+
let item = array[i];
|
|
1120
|
+
if (item[0] === _name) {
|
|
1121
|
+
return item[1];
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
getAll(...args) {
|
|
1127
|
+
const [name] = args;
|
|
1128
|
+
checkArgsFn$2(args, 1, "getAll");
|
|
1129
|
+
let _name = "" + name;
|
|
1130
|
+
let array = this[state$a][_urlspArray];
|
|
1131
|
+
let result = [];
|
|
1132
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1133
|
+
let item = array[i];
|
|
1134
|
+
if (item[0] === _name) {
|
|
1135
|
+
result.push(item[1]);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return result;
|
|
1139
|
+
}
|
|
1140
|
+
has(...args) {
|
|
1141
|
+
const [name, value] = args;
|
|
1142
|
+
checkArgsFn$2(args, 1, "has");
|
|
1143
|
+
let _name = "" + name;
|
|
1144
|
+
let array = this[state$a][_urlspArray];
|
|
1145
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1146
|
+
let item = array[i];
|
|
1147
|
+
if (item[0] === _name) {
|
|
1148
|
+
if (args.length === 1) {
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
else {
|
|
1152
|
+
if (item[1] === normalizeValue$1(value)) {
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return false;
|
|
1159
|
+
}
|
|
1160
|
+
set(...args) {
|
|
1161
|
+
const [name, value] = args;
|
|
1162
|
+
checkArgsFn$2(args, 2, "set");
|
|
1163
|
+
let _name = "" + name;
|
|
1164
|
+
let _value = normalizeValue$1(value);
|
|
1165
|
+
let index = -1;
|
|
1166
|
+
let array = this[state$a][_urlspArray];
|
|
1167
|
+
let result = [];
|
|
1168
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1169
|
+
let item = array[i];
|
|
1170
|
+
if (item[0] === _name) {
|
|
1171
|
+
if (index === -1) {
|
|
1172
|
+
index = i;
|
|
1173
|
+
result.push([_name, _value]);
|
|
1174
|
+
}
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
result.push(item);
|
|
1178
|
+
}
|
|
1179
|
+
if (index === -1) {
|
|
1180
|
+
result.push([_name, _value]);
|
|
1181
|
+
}
|
|
1182
|
+
this[state$a][_urlspArray] = result;
|
|
1183
|
+
}
|
|
1184
|
+
sort() {
|
|
1185
|
+
this[state$a][_urlspArray].sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
1186
|
+
}
|
|
1187
|
+
forEach(...args) {
|
|
1188
|
+
const [callbackfn, thisArg] = args;
|
|
1189
|
+
checkArgsFn$2(args, 1, "forEach");
|
|
1190
|
+
if (typeof callbackfn !== "function") {
|
|
1191
|
+
throw new TypeError("Failed to execute 'forEach' on 'URLSearchParams': parameter 1 is not of type 'Function'.");
|
|
1192
|
+
}
|
|
1193
|
+
let array = this[state$a][_urlspArray];
|
|
1194
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1195
|
+
let item = array[i];
|
|
1196
|
+
callbackfn.call(thisArg, item[1], item[0], this);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
entries() {
|
|
1200
|
+
return this[state$a][_urlspArray].map(x => [x[0], x[1]]).values();
|
|
1201
|
+
}
|
|
1202
|
+
keys() {
|
|
1203
|
+
return this[state$a][_urlspArray].map(x => x[0]).values();
|
|
1204
|
+
}
|
|
1205
|
+
values() {
|
|
1206
|
+
return this[state$a][_urlspArray].map(x => x[1]).values();
|
|
1207
|
+
}
|
|
1208
|
+
[Symbol.iterator]() {
|
|
1209
|
+
return this.entries();
|
|
1210
|
+
}
|
|
1211
|
+
toString() {
|
|
1212
|
+
let array = this[state$a][_urlspArray];
|
|
1213
|
+
let result = [];
|
|
1214
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1215
|
+
let item = array[i];
|
|
1216
|
+
result.push(encode(item[0]) + "=" + encode(item[1]));
|
|
1217
|
+
}
|
|
1218
|
+
return result.join("&");
|
|
1219
|
+
}
|
|
1220
|
+
/** @internal */
|
|
1221
|
+
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1222
|
+
}
|
|
1223
|
+
Class_setStringTag(URLSearchParamsP, "URLSearchParams");
|
|
1224
|
+
/** @internal */
|
|
1225
|
+
const _urlspArray = Symbol();
|
|
1226
|
+
/** @internal */
|
|
1227
|
+
class URLSearchParamsState {
|
|
1228
|
+
constructor() {
|
|
1229
|
+
this[_a$6] = [];
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
_a$6 = _urlspArray;
|
|
1233
|
+
function normalizeValue$1(value) {
|
|
1234
|
+
return typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function"
|
|
1235
|
+
? value.toString()
|
|
1236
|
+
: JSON.stringify(value));
|
|
1237
|
+
}
|
|
1238
|
+
function encode(str) {
|
|
1239
|
+
const replace = {
|
|
1240
|
+
"!": "%21",
|
|
1241
|
+
"'": "%27",
|
|
1242
|
+
"(": "%28",
|
|
1243
|
+
")": "%29",
|
|
1244
|
+
"~": "%7E",
|
|
1245
|
+
"%20": "+",
|
|
1246
|
+
"%00": "\x00",
|
|
1247
|
+
};
|
|
1248
|
+
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
|
|
1249
|
+
}
|
|
1250
|
+
function decode(str) {
|
|
1251
|
+
return str
|
|
1252
|
+
.replace(/[ +]/g, "%20")
|
|
1253
|
+
.replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
|
|
1254
|
+
}
|
|
1255
|
+
const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
1256
|
+
|
|
1257
|
+
var _a$5;
|
|
1258
|
+
/** @internal */ const state$9 = Symbol( /* "FormDataState" */);
|
|
1259
|
+
const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
|
|
1260
|
+
/** @type {typeof globalThis.FormData} */
|
|
947
1261
|
class FormDataP {
|
|
948
1262
|
constructor(form, submitter) {
|
|
949
|
-
if (
|
|
950
|
-
|
|
1263
|
+
if (submitter === undefined) {
|
|
1264
|
+
if (form !== undefined) {
|
|
1265
|
+
console.error("TypeError: Failed to construct 'FormData': parameter 1 not implemented.");
|
|
1266
|
+
}
|
|
951
1267
|
}
|
|
952
|
-
|
|
953
|
-
|
|
1268
|
+
else {
|
|
1269
|
+
if (submitter !== null) {
|
|
1270
|
+
console.error("TypeError: Failed to construct 'FormData': parameter 1 and parameter 2 not implemented.");
|
|
1271
|
+
}
|
|
954
1272
|
}
|
|
955
|
-
this[state$
|
|
1273
|
+
this[state$9] = new FormDataState();
|
|
956
1274
|
}
|
|
957
|
-
append(
|
|
958
|
-
|
|
1275
|
+
append(...args) {
|
|
1276
|
+
const [name, value, filename] = args;
|
|
1277
|
+
checkArgsFn$1(args, 2, "append");
|
|
1278
|
+
this[state$9][_formData].push(normalizeArgs(name, value, filename));
|
|
959
1279
|
}
|
|
960
|
-
delete(
|
|
1280
|
+
delete(...args) {
|
|
1281
|
+
const [name] = args;
|
|
1282
|
+
checkArgsFn$1(args, 1, "delete");
|
|
1283
|
+
let _name = "" + name;
|
|
1284
|
+
let index = -1;
|
|
1285
|
+
let array = this[state$9][_formData];
|
|
961
1286
|
let result = [];
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1287
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1288
|
+
let item = array[i];
|
|
1289
|
+
if (item[0] === _name) {
|
|
1290
|
+
index = i;
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
result.push(item);
|
|
1294
|
+
}
|
|
1295
|
+
if (index > -1) {
|
|
1296
|
+
this[state$9][_formData] = result;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
get(...args) {
|
|
1300
|
+
const [name] = args;
|
|
1301
|
+
checkArgsFn$1(args, 1, "get");
|
|
1302
|
+
let _name = "" + name;
|
|
1303
|
+
let array = this[state$9][_formData];
|
|
1304
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1305
|
+
let item = array[i];
|
|
1306
|
+
if (item[0] === _name) {
|
|
1307
|
+
return item[1];
|
|
974
1308
|
}
|
|
975
1309
|
}
|
|
976
1310
|
return null;
|
|
977
1311
|
}
|
|
978
|
-
getAll(
|
|
1312
|
+
getAll(...args) {
|
|
1313
|
+
const [name] = args;
|
|
1314
|
+
checkArgsFn$1(args, 1, "getAll");
|
|
1315
|
+
let _name = "" + name;
|
|
1316
|
+
let array = this[state$9][_formData];
|
|
979
1317
|
let result = [];
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1318
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1319
|
+
let item = array[i];
|
|
1320
|
+
if (item[0] === _name) {
|
|
1321
|
+
result.push(item[1]);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
984
1324
|
return result;
|
|
985
1325
|
}
|
|
986
|
-
has(
|
|
987
|
-
name =
|
|
988
|
-
|
|
989
|
-
|
|
1326
|
+
has(...args) {
|
|
1327
|
+
const [name] = args;
|
|
1328
|
+
checkArgsFn$1(args, 1, "has");
|
|
1329
|
+
let _name = "" + name;
|
|
1330
|
+
let array = this[state$9][_formData];
|
|
1331
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1332
|
+
let item = array[i];
|
|
1333
|
+
if (item[0] === _name) {
|
|
990
1334
|
return true;
|
|
991
1335
|
}
|
|
992
1336
|
}
|
|
993
1337
|
return false;
|
|
994
1338
|
}
|
|
995
|
-
set(
|
|
996
|
-
name =
|
|
1339
|
+
set(...args) {
|
|
1340
|
+
const [name, value, filename] = args;
|
|
1341
|
+
checkArgsFn$1(args, 2, "set");
|
|
1342
|
+
let _name = "" + name;
|
|
1343
|
+
let _args = normalizeArgs(name, value, filename);
|
|
1344
|
+
let index = -1;
|
|
1345
|
+
let array = this[state$9][_formData];
|
|
997
1346
|
let result = [];
|
|
998
|
-
let
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1347
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1348
|
+
let item = array[i];
|
|
1349
|
+
if (item[0] === _name) {
|
|
1350
|
+
if (index === -1) {
|
|
1351
|
+
index = i;
|
|
1352
|
+
result.push(_args);
|
|
1353
|
+
}
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
result.push(item);
|
|
1357
|
+
}
|
|
1358
|
+
if (index === -1) {
|
|
1359
|
+
result.push(_args);
|
|
1360
|
+
}
|
|
1361
|
+
this[state$9][_formData] = result;
|
|
1007
1362
|
}
|
|
1008
|
-
forEach(
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1363
|
+
forEach(...args) {
|
|
1364
|
+
const [callbackfn, thisArg] = args;
|
|
1365
|
+
checkArgsFn$1(args, 1, "forEach");
|
|
1366
|
+
if (typeof callbackfn !== "function") {
|
|
1367
|
+
throw new TypeError("Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'.");
|
|
1368
|
+
}
|
|
1369
|
+
let array = this[state$9][_formData];
|
|
1370
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1371
|
+
let item = array[i];
|
|
1372
|
+
callbackfn.call(thisArg, item[1], item[0], thisArg);
|
|
1012
1373
|
}
|
|
1013
1374
|
}
|
|
1014
1375
|
entries() {
|
|
1015
|
-
return this[state$
|
|
1376
|
+
return this[state$9][_formData].map(x => [x[0], x[1]]).values();
|
|
1016
1377
|
}
|
|
1017
1378
|
keys() {
|
|
1018
|
-
return this[state$
|
|
1379
|
+
return this[state$9][_formData].map(x => x[0]).values();
|
|
1019
1380
|
}
|
|
1020
1381
|
values() {
|
|
1021
|
-
return this[state$
|
|
1382
|
+
return this[state$9][_formData].map(x => x[1]).values();
|
|
1022
1383
|
}
|
|
1023
1384
|
[Symbol.iterator]() {
|
|
1024
1385
|
return this.entries();
|
|
1025
1386
|
}
|
|
1026
|
-
toString() { return "[object FormData]"; }
|
|
1027
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
1387
|
+
/** @internal */ toString() { return "[object FormData]"; }
|
|
1388
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
|
|
1028
1389
|
}
|
|
1029
|
-
|
|
1390
|
+
Class_setStringTag(FormDataP, "FormData");
|
|
1030
1391
|
/** @internal */
|
|
1031
1392
|
const _formData = Symbol();
|
|
1032
1393
|
/** @internal */
|
|
1033
1394
|
class FormDataState {
|
|
1034
1395
|
constructor() {
|
|
1035
|
-
this[_a$
|
|
1396
|
+
this[_a$5] = [];
|
|
1036
1397
|
}
|
|
1037
1398
|
}
|
|
1038
|
-
_a$
|
|
1399
|
+
_a$5 = _formData;
|
|
1039
1400
|
/** @internal */
|
|
1040
1401
|
function FormData_toBlob(formData) {
|
|
1041
|
-
const boundary = "----formdata-
|
|
1402
|
+
const boundary = "----formdata-mphttpx-" + Math.random();
|
|
1042
1403
|
const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
|
|
1043
1404
|
let chunks = [];
|
|
1044
|
-
for (let i = 0; i < formData[state$
|
|
1045
|
-
let pair = formData[state$
|
|
1405
|
+
for (let i = 0; i < formData[state$9][_formData].length; ++i) {
|
|
1406
|
+
let pair = formData[state$9][_formData][i];
|
|
1046
1407
|
let name = pair[0];
|
|
1047
1408
|
let value = pair[1];
|
|
1048
1409
|
if (typeof value === "string") {
|
|
@@ -1058,418 +1419,291 @@ function FormData_toBlob(formData) {
|
|
|
1058
1419
|
function normalizeArgs(name, value, filename) {
|
|
1059
1420
|
if (isPolyfillType("Blob", value)) {
|
|
1060
1421
|
filename = filename !== undefined
|
|
1061
|
-
?
|
|
1422
|
+
? ("" + filename)
|
|
1062
1423
|
: typeof value.name === "string"
|
|
1063
1424
|
? value.name
|
|
1064
1425
|
: "blob";
|
|
1065
|
-
if (value.name !== filename ||
|
|
1426
|
+
if (value.name !== filename || isObjectType("Blob", value)) {
|
|
1066
1427
|
value = new FileP([value], filename);
|
|
1067
1428
|
}
|
|
1068
|
-
return [
|
|
1429
|
+
return ["" + name, value];
|
|
1069
1430
|
}
|
|
1070
|
-
return [
|
|
1431
|
+
return ["" + name, "" + value];
|
|
1071
1432
|
}
|
|
1433
|
+
// normalize line feeds for textarea
|
|
1434
|
+
// https://html.spec.whatwg.org/multipage/form-elements.html#textarea-line-break-normalisation-transformation
|
|
1072
1435
|
function normalizeLinefeeds(value) {
|
|
1073
1436
|
return value.replace(/\r?\n|\r/g, "\r\n");
|
|
1074
1437
|
}
|
|
1075
|
-
function each(arr, cb) {
|
|
1076
|
-
for (let i = 0; i < arr.length; ++i) {
|
|
1077
|
-
cb(arr[i]);
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
1438
|
function escape(str) {
|
|
1081
1439
|
return str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22');
|
|
1082
1440
|
}
|
|
1083
|
-
/**
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
return formData;
|
|
1093
|
-
}
|
|
1094
|
-
// 1. Extract boundary string (from the first line, removing leading "--")
|
|
1095
|
-
const firstLineEnd = body.indexOf("\r\n");
|
|
1441
|
+
/** @internal */
|
|
1442
|
+
function createFormDataFromBinaryText(text, boundary) {
|
|
1443
|
+
const throwParseError = () => {
|
|
1444
|
+
throw new TypeError("Could not parse content as FormData.");
|
|
1445
|
+
};
|
|
1446
|
+
if (typeof text !== "string" || text.trim() === "") {
|
|
1447
|
+
throwParseError();
|
|
1448
|
+
}
|
|
1449
|
+
let firstLineEnd = text.indexOf("\r\n");
|
|
1096
1450
|
if (firstLineEnd === -1) {
|
|
1097
|
-
|
|
1098
|
-
throw new TypeError(errMsg);
|
|
1451
|
+
throwParseError();
|
|
1099
1452
|
}
|
|
1100
|
-
|
|
1101
|
-
if (!
|
|
1102
|
-
|
|
1103
|
-
throw new TypeError("Invalid MIME type");
|
|
1453
|
+
let _boundary = text.substring(2, firstLineEnd).trim();
|
|
1454
|
+
if (!_boundary) {
|
|
1455
|
+
throwParseError();
|
|
1104
1456
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1457
|
+
if (boundary !== undefined && boundary !== _boundary) {
|
|
1458
|
+
throwParseError();
|
|
1459
|
+
}
|
|
1460
|
+
let parts = text.split(`--${_boundary}`).filter(part => {
|
|
1461
|
+
let trimmed = part.trim();
|
|
1108
1462
|
return trimmed !== "" && trimmed !== "--";
|
|
1109
1463
|
});
|
|
1110
1464
|
if (parts.length === 0) {
|
|
1111
|
-
|
|
1112
|
-
throw new TypeError(errMsg);
|
|
1465
|
+
throwParseError();
|
|
1113
1466
|
}
|
|
1114
|
-
|
|
1467
|
+
let formData = new FormDataP();
|
|
1115
1468
|
parts.forEach(part => {
|
|
1116
|
-
|
|
1117
|
-
const separatorIndex = part.indexOf("\r\n\r\n");
|
|
1469
|
+
let separatorIndex = part.indexOf("\r\n\r\n");
|
|
1118
1470
|
if (separatorIndex === -1) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
if (!
|
|
1130
|
-
|
|
1131
|
-
throw new TypeError(errMsg);
|
|
1132
|
-
}
|
|
1133
|
-
const fieldName = nameMatch[1];
|
|
1134
|
-
const isFile = !!filenameMatch; // Whether it's a file field
|
|
1135
|
-
const mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "application/octet-stream";
|
|
1136
|
-
// 4. Process content (text or binary)
|
|
1137
|
-
if (isFile) {
|
|
1138
|
-
// File field: Use TextEncoder to handle raw binary data
|
|
1139
|
-
try {
|
|
1140
|
-
// Remove line breaks from content (simulating browser behavior)
|
|
1141
|
-
const content = contentRaw.replace(/\r\n/g, "");
|
|
1142
|
-
// Convert string to Uint8Array using TextEncoder
|
|
1143
|
-
const encoder = new TextEncoderP();
|
|
1144
|
-
const uint8Array = encoder.encode(content);
|
|
1145
|
-
// Create File object (default filename is unknown-file)
|
|
1146
|
-
const filename = filenameMatch[1] || "unknown-file";
|
|
1147
|
-
const file = new FileP([uint8Array], filename, { type: mimeType });
|
|
1148
|
-
formData.append(fieldName, file, filename);
|
|
1149
|
-
}
|
|
1150
|
-
catch (e) {
|
|
1151
|
-
// `Failed to process file field "${fieldName}": ${(e as Error).message}`
|
|
1152
|
-
throw new TypeError(errMsg);
|
|
1153
|
-
}
|
|
1471
|
+
throwParseError();
|
|
1472
|
+
}
|
|
1473
|
+
let headerRaw = part.substring(0, separatorIndex).trim();
|
|
1474
|
+
let nameMatch = headerRaw.match(/name="([^"]*)"/);
|
|
1475
|
+
if (!nameMatch || nameMatch.length < 2) {
|
|
1476
|
+
throwParseError();
|
|
1477
|
+
}
|
|
1478
|
+
let fieldName = nameMatch[1];
|
|
1479
|
+
let filenameMatch = headerRaw.match(/filename="([^"]*)"/);
|
|
1480
|
+
let contentRaw = part.substring(separatorIndex + 4);
|
|
1481
|
+
if (!filenameMatch) {
|
|
1482
|
+
formData.append(fieldName, contentRaw.replace(/^[\r\n]+|[\r\n]+$/g, ""));
|
|
1154
1483
|
}
|
|
1155
1484
|
else {
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1485
|
+
let filename = filenameMatch[1] || "";
|
|
1486
|
+
let contentTypeMatch = headerRaw.match(/Content-Type: ([^\r\n]+)/);
|
|
1487
|
+
let mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "text/plain";
|
|
1488
|
+
let content = contentRaw.replace(/\r\n/g, "");
|
|
1489
|
+
formData.append(fieldName, new FileP([content], filename, { type: mimeType }));
|
|
1159
1490
|
}
|
|
1160
1491
|
});
|
|
1161
1492
|
return formData;
|
|
1162
1493
|
}
|
|
1163
1494
|
const FormDataE = g["FormData"] || FormDataP;
|
|
1164
1495
|
|
|
1165
|
-
var _a$
|
|
1166
|
-
/** @internal */
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1496
|
+
var _a$4, _b$1;
|
|
1497
|
+
/** @internal */ const state$8 = Symbol( /* "HeadersState" */);
|
|
1498
|
+
const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
|
|
1499
|
+
/** @type {typeof globalThis.Headers} */
|
|
1500
|
+
class HeadersP {
|
|
1169
1501
|
constructor(init) {
|
|
1170
|
-
|
|
1171
|
-
if (
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1502
|
+
this[state$8] = new HeadersState();
|
|
1503
|
+
if (init !== undefined) {
|
|
1504
|
+
if (isObjectType("Headers", init)) {
|
|
1505
|
+
init.forEach((value, name) => { this.append(name, value); }, this);
|
|
1506
|
+
}
|
|
1507
|
+
else if (Array.isArray(init) || (init && typeof init === "object" && Symbol.iterator in init)) {
|
|
1508
|
+
let _init = Array.isArray(init) ? init : Array.from(init);
|
|
1509
|
+
_init.forEach(item => {
|
|
1510
|
+
if (Array.isArray(item) || (item && typeof item === "object" && Symbol.iterator in item)) {
|
|
1511
|
+
let pair = Array.isArray(item) ? item : Array.from(item);
|
|
1512
|
+
if (pair.length === 2) {
|
|
1513
|
+
this.append(pair[0], pair[1]);
|
|
1514
|
+
}
|
|
1515
|
+
else {
|
|
1516
|
+
throw new TypeError("Failed to construct 'Headers': Invalid value");
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
else {
|
|
1520
|
+
throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
|
|
1521
|
+
}
|
|
1522
|
+
}, this);
|
|
1523
|
+
}
|
|
1524
|
+
else {
|
|
1525
|
+
if (init && typeof init === "object") {
|
|
1526
|
+
Object.getOwnPropertyNames(init).forEach(name => { this.append(name, init[name]); }, this);
|
|
1527
|
+
}
|
|
1528
|
+
else {
|
|
1529
|
+
throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(record<ByteString, ByteString> or sequence<sequence<ByteString>>)'.");
|
|
1195
1530
|
}
|
|
1196
|
-
continue;
|
|
1197
1531
|
}
|
|
1198
|
-
Object.assign(dict, { [key]: values });
|
|
1199
1532
|
}
|
|
1200
|
-
this[state$
|
|
1201
|
-
}
|
|
1202
|
-
get(name) {
|
|
1203
|
-
var _b;
|
|
1204
|
-
return this.has(name) ? (_b = this[state$9][_urlspDict][name][0]) !== null && _b !== void 0 ? _b : null : null;
|
|
1533
|
+
this[state$8][_initialized] = true;
|
|
1205
1534
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1535
|
+
append(...args) {
|
|
1536
|
+
const [name, value] = args;
|
|
1537
|
+
checkArgsFn(args, 2, "append");
|
|
1538
|
+
let _name = normalizeName(name, throwsFn(this[state$8][_initialized] ? "append" : ""));
|
|
1539
|
+
let _value = normalizeValue(value);
|
|
1540
|
+
let index = -1;
|
|
1541
|
+
let array = this[state$8][_headersArray];
|
|
1542
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1543
|
+
let item = array[i];
|
|
1544
|
+
if (item[0] === _name) {
|
|
1545
|
+
item[1] = `${item[1]}, ${_value}`;
|
|
1546
|
+
index = i;
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
if (index === -1) {
|
|
1551
|
+
array.push([_name, _value]);
|
|
1552
|
+
}
|
|
1208
1553
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1554
|
+
delete(...args) {
|
|
1555
|
+
const [name] = args;
|
|
1556
|
+
checkArgsFn(args, 1, "delete");
|
|
1557
|
+
let _name = normalizeName(name, throwsFn("delete"));
|
|
1558
|
+
let index = -1;
|
|
1559
|
+
let array = this[state$8][_headersArray];
|
|
1560
|
+
let result = [];
|
|
1561
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1562
|
+
let item = array[i];
|
|
1563
|
+
if (item[0] === _name) {
|
|
1564
|
+
index = i;
|
|
1565
|
+
continue;
|
|
1213
1566
|
}
|
|
1214
|
-
|
|
1567
|
+
result.push(item);
|
|
1215
1568
|
}
|
|
1216
|
-
|
|
1569
|
+
if (index > -1) {
|
|
1570
|
+
this[state$8][_headersArray] = result;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
get(...args) {
|
|
1574
|
+
const [name] = args;
|
|
1575
|
+
checkArgsFn(args, 1, "get");
|
|
1576
|
+
let _name = normalizeName(name, throwsFn("get"));
|
|
1577
|
+
let array = this[state$8][_headersArray];
|
|
1578
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1579
|
+
let item = array[i];
|
|
1580
|
+
if (item[0] === _name) {
|
|
1581
|
+
return item[1];
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
return null;
|
|
1217
1585
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1586
|
+
getSetCookie() {
|
|
1587
|
+
let value = this.get("Set-Cookie");
|
|
1588
|
+
return value ? value.split(", ") : [];
|
|
1220
1589
|
}
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
let
|
|
1226
|
-
for (let i = 0; i <
|
|
1227
|
-
let
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1590
|
+
has(...args) {
|
|
1591
|
+
const [name] = args;
|
|
1592
|
+
checkArgsFn(args, 1, "has");
|
|
1593
|
+
let _name = normalizeName(name, throwsFn("has"));
|
|
1594
|
+
let array = this[state$8][_headersArray];
|
|
1595
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1596
|
+
let item = array[i];
|
|
1597
|
+
if (item[0] === _name) {
|
|
1598
|
+
return true;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
return false;
|
|
1602
|
+
}
|
|
1603
|
+
set(...args) {
|
|
1604
|
+
const [name, value] = args;
|
|
1605
|
+
checkArgsFn(args, 2, "set");
|
|
1606
|
+
let _name = normalizeName(name, throwsFn("set"));
|
|
1607
|
+
let _value = normalizeValue(value);
|
|
1608
|
+
let index = -1;
|
|
1609
|
+
let array = this[state$8][_headersArray];
|
|
1610
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1611
|
+
let item = array[i];
|
|
1612
|
+
if (item[0] === _name) {
|
|
1613
|
+
item[1] = _value;
|
|
1614
|
+
index = i;
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
if (index === -1) {
|
|
1619
|
+
array.push([_name, _value]);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
forEach(...args) {
|
|
1623
|
+
const [callbackfn, thisArg] = args;
|
|
1624
|
+
checkArgsFn(args, 1, "forEach");
|
|
1625
|
+
if (typeof callbackfn !== "function") {
|
|
1626
|
+
throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
|
|
1627
|
+
}
|
|
1628
|
+
let array = this[state$8][_headersArray];
|
|
1629
|
+
for (let i = 0; i < array.length; ++i) {
|
|
1630
|
+
let item = array[i];
|
|
1631
|
+
callbackfn.call(thisArg, item[1], item[0], this);
|
|
1632
|
+
}
|
|
1238
1633
|
}
|
|
1239
1634
|
entries() {
|
|
1240
|
-
return
|
|
1241
|
-
.map(([key, values]) => {
|
|
1242
|
-
return values.map(value => {
|
|
1243
|
-
return [key, value];
|
|
1244
|
-
});
|
|
1245
|
-
})
|
|
1246
|
-
.reduce(flatCb, [])
|
|
1247
|
-
.values();
|
|
1635
|
+
return this[state$8][_headersArray].map(x => [x[0], x[1]]).values();
|
|
1248
1636
|
}
|
|
1249
1637
|
keys() {
|
|
1250
|
-
return
|
|
1638
|
+
return this[state$8][_headersArray].map(x => x[0]).values();
|
|
1251
1639
|
}
|
|
1252
1640
|
values() {
|
|
1253
|
-
return
|
|
1641
|
+
return this[state$8][_headersArray].map(x => x[1]).values();
|
|
1254
1642
|
}
|
|
1255
1643
|
[Symbol.iterator]() {
|
|
1256
1644
|
return this.entries();
|
|
1257
1645
|
}
|
|
1258
|
-
toString() {
|
|
1259
|
-
|
|
1260
|
-
let pairs = objectEntries(this[state$9][_urlspDict]);
|
|
1261
|
-
for (let i = 0; i < pairs.length; ++i) {
|
|
1262
|
-
let pair = pairs[i];
|
|
1263
|
-
let key = pair[0];
|
|
1264
|
-
let values = pair[1];
|
|
1265
|
-
let name = encode$1(key);
|
|
1266
|
-
for (let j = 0; j < values.length; ++j) {
|
|
1267
|
-
let val = values[j];
|
|
1268
|
-
query.push(name + "=" + encode$1(val));
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
return query.join("&");
|
|
1272
|
-
}
|
|
1273
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
|
|
1646
|
+
/** @internal */ toString() { return "[object Headers]"; }
|
|
1647
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
1274
1648
|
}
|
|
1275
|
-
|
|
1649
|
+
Class_setStringTag(HeadersP, "Headers");
|
|
1650
|
+
/** @internal */ const _initialized = Symbol();
|
|
1651
|
+
/** @internal */ const _headersArray = Symbol();
|
|
1276
1652
|
/** @internal */
|
|
1277
|
-
|
|
1278
|
-
/** @internal */
|
|
1279
|
-
class URLSearchParamsState {
|
|
1653
|
+
class HeadersState {
|
|
1280
1654
|
constructor() {
|
|
1281
|
-
this[_a$
|
|
1282
|
-
|
|
1283
|
-
}
|
|
1284
|
-
_a$5 = _urlspDict;
|
|
1285
|
-
function parseToDict(search) {
|
|
1286
|
-
let dict = {};
|
|
1287
|
-
if (typeof search === "object") {
|
|
1288
|
-
// if `search` is an array, treat it as a sequence
|
|
1289
|
-
if (Array.isArray(search)) {
|
|
1290
|
-
for (let i = 0; i < search.length; ++i) {
|
|
1291
|
-
let item = search[i];
|
|
1292
|
-
if (Array.isArray(item) && item.length === 2) {
|
|
1293
|
-
appendTo(dict, item[0], item[1]);
|
|
1294
|
-
}
|
|
1295
|
-
else {
|
|
1296
|
-
throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
else {
|
|
1301
|
-
let keys = Object.keys(search);
|
|
1302
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
1303
|
-
let key = keys[i];
|
|
1304
|
-
if (search.hasOwnProperty(key)) {
|
|
1305
|
-
appendTo(dict, key, search[key]);
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1655
|
+
this[_a$4] = false;
|
|
1656
|
+
this[_b$1] = [];
|
|
1309
1657
|
}
|
|
1310
|
-
else {
|
|
1311
|
-
// remove first '?'
|
|
1312
|
-
if (search.indexOf("?") === 0) {
|
|
1313
|
-
search = search.slice(1);
|
|
1314
|
-
}
|
|
1315
|
-
let pairs = search.split("&");
|
|
1316
|
-
for (let j = 0; j < pairs.length; ++j) {
|
|
1317
|
-
let value = pairs[j], index = value.indexOf("=");
|
|
1318
|
-
if (-1 < index) {
|
|
1319
|
-
appendTo(dict, decode$1(value.slice(0, index)), decode$1(value.slice(index + 1)));
|
|
1320
|
-
}
|
|
1321
|
-
else {
|
|
1322
|
-
if (value) {
|
|
1323
|
-
appendTo(dict, decode$1(value), "");
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
return dict;
|
|
1329
1658
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
dict[name].push(val);
|
|
1335
|
-
}
|
|
1336
|
-
else {
|
|
1337
|
-
dict[name] = [val];
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
function encode$1(str) {
|
|
1341
|
-
const replace = {
|
|
1342
|
-
"!": "%21",
|
|
1343
|
-
"'": "%27",
|
|
1344
|
-
"(": "%28",
|
|
1345
|
-
")": "%29",
|
|
1346
|
-
"~": "%7E",
|
|
1347
|
-
"%20": "+",
|
|
1348
|
-
"%00": "\x00",
|
|
1659
|
+
_a$4 = _initialized, _b$1 = _headersArray;
|
|
1660
|
+
function throwsFn(kind) {
|
|
1661
|
+
return () => {
|
|
1662
|
+
throw new TypeError(`Failed to ${kind ? ("execute '" + kind + "' on") : "construct"} 'Headers': Invalid name`);
|
|
1349
1663
|
};
|
|
1350
|
-
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
|
|
1351
1664
|
}
|
|
1352
|
-
function decode$1(str) {
|
|
1353
|
-
return str
|
|
1354
|
-
.replace(/[ +]/g, "%20")
|
|
1355
|
-
.replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
|
|
1356
|
-
}
|
|
1357
|
-
function hasOwnProperty(obj, prop) {
|
|
1358
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1359
|
-
}
|
|
1360
|
-
function flatCb(acc, cur) {
|
|
1361
|
-
for (let i = 0; i < cur.length; ++i) {
|
|
1362
|
-
let item = cur[i];
|
|
1363
|
-
acc.push(item);
|
|
1364
|
-
}
|
|
1365
|
-
return acc;
|
|
1366
|
-
}
|
|
1367
|
-
const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
1368
|
-
|
|
1369
|
-
var _a$4;
|
|
1370
1665
|
/** @internal */
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
let signal = createAbortSignal();
|
|
1375
|
-
AbortSignal_abort(signal, reason, false);
|
|
1376
|
-
return signal;
|
|
1377
|
-
}
|
|
1378
|
-
static any(signals) {
|
|
1379
|
-
let signal = createAbortSignal();
|
|
1380
|
-
let abortedSignal = signals.find(x => x.aborted);
|
|
1381
|
-
if (abortedSignal) {
|
|
1382
|
-
AbortSignal_abort(signal, abortedSignal.reason, false);
|
|
1383
|
-
}
|
|
1384
|
-
else {
|
|
1385
|
-
let _signals = Array.from(signals);
|
|
1386
|
-
function abortFn(ev) {
|
|
1387
|
-
for (let i = 0; i < _signals.length; ++i) {
|
|
1388
|
-
let sig = _signals[i];
|
|
1389
|
-
sig.removeEventListener("abort", abortFn);
|
|
1390
|
-
}
|
|
1391
|
-
AbortSignal_abort(signal, this.reason, true, ev.isTrusted);
|
|
1392
|
-
}
|
|
1393
|
-
for (let i = 0; i < _signals.length; ++i) {
|
|
1394
|
-
let sig = _signals[1];
|
|
1395
|
-
sig.addEventListener("abort", abortFn);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
return signal;
|
|
1399
|
-
}
|
|
1400
|
-
static timeout(milliseconds) {
|
|
1401
|
-
let signal = createAbortSignal();
|
|
1402
|
-
setTimeout(() => {
|
|
1403
|
-
AbortSignal_abort(signal, new MPException("signal timed out", "TimeoutError"));
|
|
1404
|
-
}, milliseconds);
|
|
1405
|
-
return signal;
|
|
1406
|
-
}
|
|
1407
|
-
constructor() {
|
|
1408
|
-
if (new.target === AbortSignalP) {
|
|
1409
|
-
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1410
|
-
}
|
|
1411
|
-
super();
|
|
1412
|
-
this[state$8] = new AbortSignalState(this);
|
|
1413
|
-
}
|
|
1414
|
-
get aborted() { return this[state$8].aborted; }
|
|
1415
|
-
get reason() { return this[state$8].reason; }
|
|
1416
|
-
throwIfAborted() {
|
|
1417
|
-
if (this.aborted) {
|
|
1418
|
-
throw this.reason;
|
|
1419
|
-
}
|
|
1666
|
+
function normalizeName(name, throwError) {
|
|
1667
|
+
if (typeof name !== "string") {
|
|
1668
|
+
name = "" + name;
|
|
1420
1669
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
this[state$8].onabort = value;
|
|
1424
|
-
attachFn(this, "abort", value, this[state$8][_handlers$2].onabort);
|
|
1670
|
+
if (throwError && (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "")) {
|
|
1671
|
+
throwError();
|
|
1425
1672
|
}
|
|
1426
|
-
|
|
1427
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1673
|
+
return name.toLowerCase();
|
|
1428
1674
|
}
|
|
1429
|
-
dfStringTag(AbortSignalP, "AbortSignal");
|
|
1430
|
-
/** @internal */
|
|
1431
|
-
const _handlers$2 = Symbol();
|
|
1432
1675
|
/** @internal */
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
this.aborted = false;
|
|
1436
|
-
this.reason = undefined;
|
|
1437
|
-
this[_a$4] = getHandlers$2(this);
|
|
1438
|
-
this.onabort = null;
|
|
1439
|
-
this.target = target;
|
|
1440
|
-
}
|
|
1676
|
+
function normalizeValue(value) {
|
|
1677
|
+
return typeof value === "string" ? value : ("" + value);
|
|
1441
1678
|
}
|
|
1442
|
-
_a$4 = _handlers$2;
|
|
1443
1679
|
/** @internal */
|
|
1444
|
-
function
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1680
|
+
function parseHeaders(rawHeaders) {
|
|
1681
|
+
let headers = new HeadersP();
|
|
1682
|
+
let preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
1683
|
+
preProcessedHeaders
|
|
1684
|
+
.split("\r")
|
|
1685
|
+
.map(header => header.indexOf("\n") === 0 ? header.substring(1, header.length) : header)
|
|
1686
|
+
.forEach(line => {
|
|
1687
|
+
let parts = line.split(":");
|
|
1688
|
+
let name = parts.shift().trim();
|
|
1689
|
+
if (name) {
|
|
1690
|
+
let value = parts.join(":").trim();
|
|
1691
|
+
try {
|
|
1692
|
+
headers.append(name, value);
|
|
1693
|
+
}
|
|
1694
|
+
catch (e) {
|
|
1695
|
+
console.warn(`SyntaxError: Response.headers: '${name}' is not a valid HTTP header field name.`);
|
|
1696
|
+
}
|
|
1452
1697
|
}
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
function getHandlers$2(s) {
|
|
1456
|
-
return {
|
|
1457
|
-
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
1458
|
-
};
|
|
1459
|
-
}
|
|
1460
|
-
/** @internal */
|
|
1461
|
-
function createAbortSignal() {
|
|
1462
|
-
let signal = Object.create(AbortSignalP.prototype);
|
|
1463
|
-
signal[state$d] = new EventTargetState(signal);
|
|
1464
|
-
signal[state$8] = new AbortSignalState(signal);
|
|
1465
|
-
return signal;
|
|
1698
|
+
});
|
|
1699
|
+
return headers;
|
|
1466
1700
|
}
|
|
1467
|
-
const
|
|
1701
|
+
const HeadersE = g["Headers"] || HeadersP;
|
|
1468
1702
|
|
|
1469
|
-
var _a$3
|
|
1470
|
-
/** @internal */
|
|
1471
|
-
const state$7 = Symbol( /* "BodyState" */);
|
|
1703
|
+
var _a$3;
|
|
1704
|
+
/** @internal */ const state$7 = Symbol( /* "BodyState" */);
|
|
1472
1705
|
class BodyImpl {
|
|
1706
|
+
/** @internal */
|
|
1473
1707
|
constructor() {
|
|
1474
1708
|
if (new.target === BodyImpl) {
|
|
1475
1709
|
throw new TypeError("Failed to construct 'Body': Illegal constructor");
|
|
@@ -1480,7 +1714,7 @@ class BodyImpl {
|
|
|
1480
1714
|
if (!this[state$7][_body]) {
|
|
1481
1715
|
return null;
|
|
1482
1716
|
}
|
|
1483
|
-
throw new
|
|
1717
|
+
throw new TypeError(`Failed to access 'body' on '${this[state$7].name}': property not implemented.`);
|
|
1484
1718
|
}
|
|
1485
1719
|
get bodyUsed() { return this[state$7].bodyUsed; }
|
|
1486
1720
|
;
|
|
@@ -1508,39 +1742,30 @@ class BodyImpl {
|
|
|
1508
1742
|
const kind = "text";
|
|
1509
1743
|
return consumed(this, kind) || read(this, kind);
|
|
1510
1744
|
}
|
|
1511
|
-
toString() { return "[object Body]"; }
|
|
1512
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1745
|
+
/** @internal */ toString() { return "[object Body]"; }
|
|
1746
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
|
|
1513
1747
|
}
|
|
1514
|
-
|
|
1515
|
-
/** @internal */
|
|
1516
|
-
|
|
1748
|
+
Class_setStringTag(BodyImpl, "Body");
|
|
1749
|
+
/** @internal */
|
|
1750
|
+
const _body = Symbol();
|
|
1517
1751
|
/** @internal */
|
|
1518
1752
|
class BodyState {
|
|
1519
1753
|
constructor() {
|
|
1754
|
+
this.name = "Body";
|
|
1520
1755
|
this.bodyUsed = false;
|
|
1521
|
-
this[_a$3] = "
|
|
1522
|
-
this[_b$1] = "";
|
|
1756
|
+
this[_a$3] = "";
|
|
1523
1757
|
}
|
|
1524
1758
|
}
|
|
1525
|
-
_a$3 =
|
|
1759
|
+
_a$3 = _body;
|
|
1526
1760
|
/** @internal */
|
|
1527
|
-
function Body_init(body, payload
|
|
1761
|
+
function Body_init(body, payload) {
|
|
1762
|
+
const b = body;
|
|
1528
1763
|
if (isObjectType("ReadableStream", payload)) {
|
|
1529
|
-
throw new
|
|
1764
|
+
throw new TypeError(`Failed to construct '${b[state$7].name}': ReadableStream not implemented.`);
|
|
1530
1765
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
/** @internal */
|
|
1538
|
-
function Body_setName(body, name) {
|
|
1539
|
-
body[state$7][_name] = name;
|
|
1540
|
-
}
|
|
1541
|
-
/** @internal */
|
|
1542
|
-
function Body_setBodyUsed(body, bodyUsed) {
|
|
1543
|
-
body[state$7].bodyUsed = bodyUsed;
|
|
1766
|
+
b[state$7][_body] = convert(payload, true, type => { if (!b.headers.has("Content-Type")) {
|
|
1767
|
+
b.headers.set("Content-Type", type);
|
|
1768
|
+
} });
|
|
1544
1769
|
}
|
|
1545
1770
|
/** @internal */
|
|
1546
1771
|
function Body_toPayload(body) {
|
|
@@ -1569,8 +1794,22 @@ function readSync(body, kind) {
|
|
|
1569
1794
|
return new Uint8Array(arrayBuffer);
|
|
1570
1795
|
}
|
|
1571
1796
|
else if (kind === "formData") {
|
|
1797
|
+
const extractBoundary = (contentType) => {
|
|
1798
|
+
if (!contentType) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
if (!/multipart\/form-data/i.test(contentType)) {
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
let boundaryMatch = contentType.match(/boundary\s*=\s*([^;]+)/i);
|
|
1805
|
+
if (boundaryMatch && boundaryMatch[1]) {
|
|
1806
|
+
let boundary = boundaryMatch[1].trim();
|
|
1807
|
+
return boundary.replace(/^["']|["']$/g, "");
|
|
1808
|
+
}
|
|
1809
|
+
};
|
|
1572
1810
|
let text = convertBack("text", payload);
|
|
1573
|
-
|
|
1811
|
+
let boundary = extractBoundary(body.headers.get("Content-Type")) || "";
|
|
1812
|
+
return createFormDataFromBinaryText(text, boundary);
|
|
1574
1813
|
}
|
|
1575
1814
|
else if (kind === "json") {
|
|
1576
1815
|
return convertBack("json", payload);
|
|
@@ -1584,20 +1823,12 @@ function consumed(body, kind) {
|
|
|
1584
1823
|
if (!s[_body])
|
|
1585
1824
|
return;
|
|
1586
1825
|
if (s.bodyUsed) {
|
|
1587
|
-
return Promise.reject(new TypeError(`
|
|
1826
|
+
return Promise.reject(new TypeError(`Failed to execute '${kind}' on '${s.name}': body stream already read`));
|
|
1588
1827
|
}
|
|
1589
1828
|
s.bodyUsed = true;
|
|
1590
1829
|
}
|
|
1591
|
-
const encode = (str) => {
|
|
1592
|
-
const encoder = new TextEncoderP();
|
|
1593
|
-
return encoder.encode(str).buffer;
|
|
1594
|
-
};
|
|
1595
|
-
const decode = (buf) => {
|
|
1596
|
-
let decoder = new TextDecoderP();
|
|
1597
|
-
return decoder.decode(buf);
|
|
1598
|
-
};
|
|
1599
1830
|
/** @internal */
|
|
1600
|
-
function convert(body, setContentType, setContentLength) {
|
|
1831
|
+
function convert(body, cloneArrayBuffer = true, setContentType, setContentLength) {
|
|
1601
1832
|
let result;
|
|
1602
1833
|
if (typeof body === "string") {
|
|
1603
1834
|
result = body;
|
|
@@ -1612,7 +1843,7 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1612
1843
|
}
|
|
1613
1844
|
}
|
|
1614
1845
|
else if (body instanceof ArrayBuffer) {
|
|
1615
|
-
result = body.slice(0);
|
|
1846
|
+
result = cloneArrayBuffer ? body.slice(0) : body;
|
|
1616
1847
|
}
|
|
1617
1848
|
else if (ArrayBuffer.isView(body)) {
|
|
1618
1849
|
result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
@@ -1634,10 +1865,17 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1634
1865
|
result = "";
|
|
1635
1866
|
}
|
|
1636
1867
|
else {
|
|
1637
|
-
result =
|
|
1868
|
+
result = "" + body;
|
|
1638
1869
|
}
|
|
1639
1870
|
if (setContentLength) {
|
|
1640
|
-
|
|
1871
|
+
let calculated = false, contentLength = 0;
|
|
1872
|
+
setContentLength(() => {
|
|
1873
|
+
if (!calculated) {
|
|
1874
|
+
calculated = true;
|
|
1875
|
+
contentLength = (typeof result === "string" ? encode$1(result).buffer : result).byteLength;
|
|
1876
|
+
}
|
|
1877
|
+
return contentLength;
|
|
1878
|
+
});
|
|
1641
1879
|
}
|
|
1642
1880
|
return result;
|
|
1643
1881
|
}
|
|
@@ -1645,13 +1883,13 @@ function convert(body, setContentType, setContentLength) {
|
|
|
1645
1883
|
function convertBack(type, data) {
|
|
1646
1884
|
let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
|
|
1647
1885
|
if (!type || type === "text") {
|
|
1648
|
-
return typeof temp === "string" ? temp : decode(temp);
|
|
1886
|
+
return typeof temp === "string" ? temp : decode$1(temp);
|
|
1649
1887
|
}
|
|
1650
1888
|
else if (type === "json") {
|
|
1651
|
-
return JSON.parse(typeof temp === "string" ? temp : decode(temp));
|
|
1889
|
+
return JSON.parse(typeof temp === "string" ? temp : decode$1(temp));
|
|
1652
1890
|
}
|
|
1653
1891
|
else if (type === "arraybuffer") {
|
|
1654
|
-
return temp instanceof ArrayBuffer ? temp.slice(0) : encode(temp);
|
|
1892
|
+
return temp instanceof ArrayBuffer ? temp.slice(0) : encode$1(temp).buffer;
|
|
1655
1893
|
}
|
|
1656
1894
|
else if (type === "blob") {
|
|
1657
1895
|
return new BlobP([temp]);
|
|
@@ -1663,194 +1901,124 @@ function convertBack(type, data) {
|
|
|
1663
1901
|
|
|
1664
1902
|
var _a$2;
|
|
1665
1903
|
/** @internal */
|
|
1666
|
-
const state$6 = Symbol( /* "
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
else if (Array.isArray(init)) {
|
|
1676
|
-
init.forEach(header => {
|
|
1677
|
-
if (!Array.isArray(header)) {
|
|
1678
|
-
throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
|
|
1679
|
-
}
|
|
1680
|
-
if (header.length !== 2) {
|
|
1681
|
-
throw new TypeError("Failed to construct 'Headers': Invalid value");
|
|
1682
|
-
}
|
|
1683
|
-
this.append(header[0], header[1]);
|
|
1684
|
-
});
|
|
1685
|
-
}
|
|
1686
|
-
else if (init) {
|
|
1687
|
-
objectEntries(init).forEach(([name, value]) => {
|
|
1688
|
-
this.append(name, value);
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
append(name, value) {
|
|
1693
|
-
var _b;
|
|
1694
|
-
let key = normalizeName(name, "append");
|
|
1695
|
-
let newValue = normalizeValue(value);
|
|
1696
|
-
let oldValue = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1];
|
|
1697
|
-
this[state$6][_headersMap].set(key, ["" + name, oldValue ? `${oldValue}, ${newValue}` : newValue]);
|
|
1698
|
-
}
|
|
1699
|
-
delete(name) {
|
|
1700
|
-
let key = normalizeName(name, "delete");
|
|
1701
|
-
this[state$6][_headersMap].delete(key);
|
|
1702
|
-
}
|
|
1703
|
-
get(name) {
|
|
1704
|
-
var _b, _c;
|
|
1705
|
-
let key = normalizeName(name, "get");
|
|
1706
|
-
return (_c = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : null;
|
|
1707
|
-
}
|
|
1708
|
-
getSetCookie() {
|
|
1709
|
-
let value = this.get("Set-Cookie");
|
|
1710
|
-
return value ? value.split(", ") : [];
|
|
1711
|
-
}
|
|
1712
|
-
has(name) {
|
|
1713
|
-
let key = normalizeName(name, "has");
|
|
1714
|
-
return this[state$6][_headersMap].has(key);
|
|
1715
|
-
}
|
|
1716
|
-
set(name, value) {
|
|
1717
|
-
let key = normalizeName(name, "set");
|
|
1718
|
-
this[state$6][_headersMap].set(key, ["" + name, normalizeValue(value)]);
|
|
1719
|
-
}
|
|
1720
|
-
forEach(callbackfn, thisArg) {
|
|
1721
|
-
Array.from(this.entries()).forEach(([name, value]) => {
|
|
1722
|
-
callbackfn.call(thisArg, value, name, this);
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
entries() {
|
|
1726
|
-
return this[state$6][_headersMap].values();
|
|
1727
|
-
}
|
|
1728
|
-
keys() {
|
|
1729
|
-
return Array.from(this.entries()).map(pair => pair[0]).values();
|
|
1730
|
-
}
|
|
1731
|
-
values() {
|
|
1732
|
-
return Array.from(this.entries()).map(pair => pair[1]).values();
|
|
1733
|
-
}
|
|
1734
|
-
[Symbol.iterator]() {
|
|
1735
|
-
return this.entries();
|
|
1736
|
-
}
|
|
1737
|
-
toString() { return "[object Headers]"; }
|
|
1738
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
|
|
1739
|
-
}
|
|
1740
|
-
dfStringTag(HeadersP, "Headers");
|
|
1741
|
-
/** @internal */
|
|
1742
|
-
const _headersMap = Symbol();
|
|
1743
|
-
/** @internal */
|
|
1744
|
-
class HeadersState {
|
|
1745
|
-
constructor() {
|
|
1746
|
-
this[_a$2] = new SimpleMap();
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
_a$2 = _headersMap;
|
|
1750
|
-
/** @internal */
|
|
1751
|
-
class SimpleMap {
|
|
1752
|
-
constructor() {
|
|
1753
|
-
this.array = [];
|
|
1904
|
+
const state$6 = Symbol( /* "AbortSignalState" */);
|
|
1905
|
+
/** @type {typeof globalThis.AbortSignal} */
|
|
1906
|
+
class AbortSignalP extends EventTargetP {
|
|
1907
|
+
static abort(reason) {
|
|
1908
|
+
let signal = createAbortSignal();
|
|
1909
|
+
AbortSignal_abort(signal, reason, false);
|
|
1910
|
+
return signal;
|
|
1754
1911
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}
|
|
1912
|
+
static any(...args) {
|
|
1913
|
+
const [signals] = args;
|
|
1914
|
+
checkArgsLength(args, 1, "AbortSignal", "any");
|
|
1915
|
+
if (!(Array.isArray(signals) || (signals && typeof signals === "object" && Symbol.iterator in signals))) {
|
|
1916
|
+
throw new TypeError("Failed to execute 'any' on 'AbortSignal': The provided value cannot be converted to a sequence.");
|
|
1761
1917
|
}
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
let pair = this.array[i];
|
|
1767
|
-
if (pair[0] === key) {
|
|
1768
|
-
pair[1] = value;
|
|
1769
|
-
index = i;
|
|
1770
|
-
break;
|
|
1918
|
+
let _signals = Array.isArray(signals) ? signals : Array.from(signals);
|
|
1919
|
+
_signals.forEach(sig => {
|
|
1920
|
+
if (!isPolyfillType("EventTarget", sig)) {
|
|
1921
|
+
throw new TypeError("Failed to execute 'any' on 'AbortSignal': Failed to convert value to 'AbortSignal'.");
|
|
1771
1922
|
}
|
|
1923
|
+
});
|
|
1924
|
+
let signal = createAbortSignal();
|
|
1925
|
+
let abortedSignal = _signals.find(x => x.aborted);
|
|
1926
|
+
if (abortedSignal) {
|
|
1927
|
+
AbortSignal_abort(signal, abortedSignal.reason, false);
|
|
1772
1928
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1929
|
+
else {
|
|
1930
|
+
function abortFn(ev) {
|
|
1931
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1932
|
+
let sig = _signals[i];
|
|
1933
|
+
sig.removeEventListener("abort", abortFn);
|
|
1934
|
+
}
|
|
1935
|
+
AbortSignal_abort(signal, this.reason, true, ev.isTrusted);
|
|
1936
|
+
}
|
|
1937
|
+
for (let i = 0; i < _signals.length; ++i) {
|
|
1938
|
+
let sig = _signals[i];
|
|
1939
|
+
sig.addEventListener("abort", abortFn);
|
|
1940
|
+
}
|
|
1775
1941
|
}
|
|
1776
|
-
return
|
|
1942
|
+
return signal;
|
|
1777
1943
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
}
|
|
1944
|
+
static timeout(...args) {
|
|
1945
|
+
const [milliseconds] = args;
|
|
1946
|
+
checkArgsLength(args, 1, "AbortSignal", "timeout");
|
|
1947
|
+
if (!(milliseconds >= 0)) {
|
|
1948
|
+
throw new TypeError("Failed to execute 'timeout' on 'AbortSignal': Value is outside the 'unsigned long long' value range.");
|
|
1784
1949
|
}
|
|
1785
|
-
|
|
1950
|
+
let signal = createAbortSignal();
|
|
1951
|
+
setTimeout(() => {
|
|
1952
|
+
AbortSignal_abort(signal, new MPException("signal timed out", "TimeoutError"));
|
|
1953
|
+
}, milliseconds);
|
|
1954
|
+
return signal;
|
|
1786
1955
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
let pair = this.array[i];
|
|
1792
|
-
if (pair[0] === key) {
|
|
1793
|
-
index = i;
|
|
1794
|
-
continue;
|
|
1795
|
-
}
|
|
1796
|
-
array.push(pair);
|
|
1956
|
+
/** @internal */
|
|
1957
|
+
constructor() {
|
|
1958
|
+
if (new.target === AbortSignalP) {
|
|
1959
|
+
throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
|
|
1797
1960
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1961
|
+
super();
|
|
1962
|
+
this[state$6] = new AbortSignalState(this);
|
|
1963
|
+
}
|
|
1964
|
+
get aborted() { return this[state$6].aborted; }
|
|
1965
|
+
get reason() { return this[state$6].reason; }
|
|
1966
|
+
throwIfAborted() {
|
|
1967
|
+
if (this.aborted) {
|
|
1968
|
+
throw this.reason;
|
|
1800
1969
|
}
|
|
1801
|
-
return index > -1;
|
|
1802
1970
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1971
|
+
get onabort() { return this[state$6].onabort; }
|
|
1972
|
+
set onabort(value) {
|
|
1973
|
+
this[state$6].onabort = value;
|
|
1974
|
+
attachFn(this, "abort", value, this[state$6][_handlers$2].onabort);
|
|
1805
1975
|
}
|
|
1976
|
+
/** @internal */ toString() { return "[object AbortSignal]"; }
|
|
1977
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
|
|
1806
1978
|
}
|
|
1979
|
+
Class_setStringTag(AbortSignalP, "AbortSignal");
|
|
1807
1980
|
/** @internal */
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1981
|
+
const _handlers$2 = Symbol();
|
|
1982
|
+
/** @internal */
|
|
1983
|
+
class AbortSignalState {
|
|
1984
|
+
constructor(target) {
|
|
1985
|
+
this.aborted = false;
|
|
1986
|
+
this.reason = undefined;
|
|
1987
|
+
this[_a$2] = getHandlers$2(this);
|
|
1988
|
+
this.onabort = null;
|
|
1989
|
+
this.target = target;
|
|
1816
1990
|
}
|
|
1817
|
-
return name.toLowerCase();
|
|
1818
1991
|
}
|
|
1992
|
+
_a$2 = _handlers$2;
|
|
1819
1993
|
/** @internal */
|
|
1820
|
-
function
|
|
1821
|
-
|
|
1822
|
-
|
|
1994
|
+
function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
|
|
1995
|
+
const s = signal[state$6];
|
|
1996
|
+
if (!s.aborted) {
|
|
1997
|
+
s.aborted = true;
|
|
1998
|
+
s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
|
|
1999
|
+
if (notify) {
|
|
2000
|
+
let evt = createInnerEvent(signal, "abort", undefined, isTrusted);
|
|
2001
|
+
EventTarget_fire(signal, evt);
|
|
2002
|
+
}
|
|
1823
2003
|
}
|
|
1824
|
-
|
|
2004
|
+
}
|
|
2005
|
+
function getHandlers$2(s) {
|
|
2006
|
+
return {
|
|
2007
|
+
onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
|
|
2008
|
+
};
|
|
1825
2009
|
}
|
|
1826
2010
|
/** @internal */
|
|
1827
|
-
function
|
|
1828
|
-
let
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
.map(function (header) {
|
|
1833
|
-
return header.indexOf("\n") === 0 ? header.substring(1, header.length) : header;
|
|
1834
|
-
})
|
|
1835
|
-
.forEach(function (line) {
|
|
1836
|
-
let parts = line.split(":");
|
|
1837
|
-
let key = parts.shift().trim();
|
|
1838
|
-
if (key) {
|
|
1839
|
-
let value = parts.join(":").trim();
|
|
1840
|
-
try {
|
|
1841
|
-
headers.append(key, value);
|
|
1842
|
-
}
|
|
1843
|
-
catch (error) {
|
|
1844
|
-
console.warn("Response " + error.message);
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
});
|
|
1848
|
-
return headers;
|
|
2011
|
+
function createAbortSignal() {
|
|
2012
|
+
let signal = Object.create(AbortSignalP.prototype);
|
|
2013
|
+
signal[state$d] = new EventTargetState(signal);
|
|
2014
|
+
signal[state$6] = new AbortSignalState(signal);
|
|
2015
|
+
return signal;
|
|
1849
2016
|
}
|
|
1850
|
-
const
|
|
2017
|
+
const AbortSignalE = g["AbortSignal"] || AbortSignalP;
|
|
1851
2018
|
|
|
1852
2019
|
/** @internal */
|
|
1853
2020
|
const state$5 = Symbol( /* "AbortControllerState" */);
|
|
2021
|
+
/** @type {typeof globalThis.AbortController} */
|
|
1854
2022
|
class AbortControllerP {
|
|
1855
2023
|
constructor() {
|
|
1856
2024
|
this[state$5] = new AbortControllerState();
|
|
@@ -1859,10 +2027,10 @@ class AbortControllerP {
|
|
|
1859
2027
|
abort(reason) {
|
|
1860
2028
|
AbortSignal_abort(this[state$5].signal, reason);
|
|
1861
2029
|
}
|
|
1862
|
-
toString() { return "[object AbortController]"; }
|
|
1863
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
2030
|
+
/** @internal */ toString() { return "[object AbortController]"; }
|
|
2031
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
|
|
1864
2032
|
}
|
|
1865
|
-
|
|
2033
|
+
Class_setStringTag(AbortControllerP, "AbortController");
|
|
1866
2034
|
/** @internal */
|
|
1867
2035
|
class AbortControllerState {
|
|
1868
2036
|
constructor() {
|
|
@@ -1872,69 +2040,79 @@ class AbortControllerState {
|
|
|
1872
2040
|
const AbortControllerE = g["AbortController"] || AbortControllerP;
|
|
1873
2041
|
|
|
1874
2042
|
/** @internal */ const state$4 = Symbol( /* "RequestState" */);
|
|
2043
|
+
/** @type {typeof globalThis.Request} */
|
|
1875
2044
|
class RequestP extends BodyImpl {
|
|
1876
|
-
constructor(
|
|
2045
|
+
constructor(...args) {
|
|
2046
|
+
const [input, init] = args;
|
|
2047
|
+
checkArgsLength(args, 1, "Request");
|
|
1877
2048
|
super();
|
|
1878
|
-
|
|
2049
|
+
this[state$7].name = "Request";
|
|
1879
2050
|
this[state$4] = new RequestState();
|
|
1880
|
-
const
|
|
1881
|
-
let
|
|
1882
|
-
|
|
2051
|
+
const s = this[state$4];
|
|
2052
|
+
let _init = init !== null && init !== void 0 ? init : {};
|
|
2053
|
+
if (typeof _init !== "object") {
|
|
2054
|
+
throw new TypeError("Failed to construct 'Request': The provided value is not of type 'RequestInit'.");
|
|
2055
|
+
}
|
|
2056
|
+
let body = _init.body;
|
|
1883
2057
|
if (isPolyfillType("Request", input)) {
|
|
1884
2058
|
if (input.bodyUsed) {
|
|
1885
2059
|
throw new TypeError("Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used.");
|
|
1886
2060
|
}
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
2061
|
+
s.cache = input.cache;
|
|
2062
|
+
s.credentials = input.credentials;
|
|
2063
|
+
if (!_init.headers) {
|
|
2064
|
+
s.headers = new HeadersP(input.headers);
|
|
1890
2065
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
2066
|
+
s.method = input.method;
|
|
2067
|
+
s.mode = input.mode;
|
|
1893
2068
|
let inputSignal = input[state$4].signal;
|
|
1894
2069
|
if (inputSignal) {
|
|
1895
|
-
|
|
2070
|
+
s.signal = inputSignal;
|
|
1896
2071
|
}
|
|
1897
|
-
|
|
2072
|
+
s.url = input.url;
|
|
1898
2073
|
let payload = Body_toPayload(input);
|
|
1899
|
-
if (!body && payload !==
|
|
2074
|
+
if (!body && payload !== "") {
|
|
1900
2075
|
body = payload;
|
|
1901
|
-
|
|
2076
|
+
input[state$7].bodyUsed = true;
|
|
1902
2077
|
}
|
|
1903
2078
|
}
|
|
1904
2079
|
else {
|
|
1905
|
-
|
|
2080
|
+
s.url = "" + input;
|
|
2081
|
+
}
|
|
2082
|
+
if (_init.cache) {
|
|
2083
|
+
s.cache = _init.cache;
|
|
1906
2084
|
}
|
|
1907
|
-
if (
|
|
1908
|
-
|
|
2085
|
+
if (_init.credentials) {
|
|
2086
|
+
s.credentials = _init.credentials;
|
|
1909
2087
|
}
|
|
1910
|
-
if (
|
|
1911
|
-
|
|
2088
|
+
if (_init.headers) {
|
|
2089
|
+
s.headers = new HeadersP(_init.headers);
|
|
1912
2090
|
}
|
|
1913
|
-
if (
|
|
1914
|
-
|
|
2091
|
+
if (_init.method) {
|
|
2092
|
+
s.method = normalizeMethod(_init.method);
|
|
1915
2093
|
}
|
|
1916
|
-
if (
|
|
1917
|
-
|
|
2094
|
+
if (_init.mode) {
|
|
2095
|
+
s.mode = _init.mode;
|
|
1918
2096
|
}
|
|
1919
|
-
if (
|
|
1920
|
-
|
|
2097
|
+
if (_init.signal) {
|
|
2098
|
+
s.signal = _init.signal;
|
|
1921
2099
|
}
|
|
1922
2100
|
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
1923
2101
|
throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
|
|
1924
2102
|
}
|
|
1925
|
-
Body_init(this, body
|
|
2103
|
+
Body_init(this, body);
|
|
1926
2104
|
if (this.method === "GET" || this.method === "HEAD") {
|
|
1927
|
-
if (
|
|
2105
|
+
if (_init.cache === "no-store" || _init.cache === "no-cache") {
|
|
1928
2106
|
// Search for a '_' parameter in the query string
|
|
1929
2107
|
let reParamSearch = /([?&])_=[^&]*/;
|
|
1930
2108
|
if (reParamSearch.test(this.url)) {
|
|
1931
2109
|
// If it already exists then set the value with the current time
|
|
1932
|
-
|
|
2110
|
+
s.url = this.url.replace(reParamSearch, "$1_=" + (new Date()).getTime());
|
|
1933
2111
|
}
|
|
1934
2112
|
else {
|
|
1935
2113
|
// Otherwise add a new '_' parameter to the end with the current time
|
|
1936
2114
|
let reQueryString = /\?/;
|
|
1937
|
-
|
|
2115
|
+
s.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (new Date()).getTime();
|
|
1938
2116
|
}
|
|
1939
2117
|
}
|
|
1940
2118
|
}
|
|
@@ -1943,11 +2121,11 @@ class RequestP extends BodyImpl {
|
|
|
1943
2121
|
get credentials() { return this[state$4].credentials; }
|
|
1944
2122
|
get destination() { return this[state$4].destination; }
|
|
1945
2123
|
get headers() {
|
|
1946
|
-
const
|
|
1947
|
-
if (!
|
|
1948
|
-
|
|
2124
|
+
const s = this[state$4];
|
|
2125
|
+
if (!s.headers) {
|
|
2126
|
+
s.headers = new HeadersP();
|
|
1949
2127
|
}
|
|
1950
|
-
return
|
|
2128
|
+
return s.headers;
|
|
1951
2129
|
}
|
|
1952
2130
|
get integrity() { return this[state$4].integrity; }
|
|
1953
2131
|
get keepalive() { return this[state$4].keepalive; }
|
|
@@ -1957,21 +2135,24 @@ class RequestP extends BodyImpl {
|
|
|
1957
2135
|
get referrer() { return this[state$4].referrer; }
|
|
1958
2136
|
get referrerPolicy() { return this[state$4].referrerPolicy; }
|
|
1959
2137
|
get signal() {
|
|
1960
|
-
const
|
|
1961
|
-
if (!
|
|
1962
|
-
|
|
2138
|
+
const s = this[state$4];
|
|
2139
|
+
if (!s.signal) {
|
|
2140
|
+
s.signal = (new AbortControllerP()).signal;
|
|
1963
2141
|
}
|
|
1964
|
-
return
|
|
2142
|
+
return s.signal;
|
|
1965
2143
|
}
|
|
1966
2144
|
get url() { return this[state$4].url; }
|
|
1967
2145
|
clone() {
|
|
1968
2146
|
var _a;
|
|
2147
|
+
if (this.bodyUsed) {
|
|
2148
|
+
throw new TypeError("Failed to execute 'clone' on 'Request': Request body is already used");
|
|
2149
|
+
}
|
|
1969
2150
|
return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
|
|
1970
2151
|
}
|
|
1971
|
-
toString() { return "[object Request]"; }
|
|
1972
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"
|
|
2152
|
+
/** @internal */ toString() { return "[object Request]"; }
|
|
2153
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
|
|
1973
2154
|
}
|
|
1974
|
-
|
|
2155
|
+
Class_setStringTag(RequestP, "Request");
|
|
1975
2156
|
/** @internal */
|
|
1976
2157
|
class RequestState {
|
|
1977
2158
|
constructor() {
|
|
@@ -1997,109 +2178,36 @@ function normalizeMethod(method) {
|
|
|
1997
2178
|
}
|
|
1998
2179
|
const RequestE = g["Request"] || RequestP;
|
|
1999
2180
|
|
|
2000
|
-
/** @internal */ const state$3 = Symbol( /* "ResponseState" */);
|
|
2001
|
-
class ResponseP extends BodyImpl {
|
|
2002
|
-
constructor(body, init) {
|
|
2003
|
-
super();
|
|
2004
|
-
Body_setName(this, "Response");
|
|
2005
|
-
this[state$3] = new ResponseState();
|
|
2006
|
-
const that = this[state$3];
|
|
2007
|
-
let options = init !== null && init !== void 0 ? init : {};
|
|
2008
|
-
let status = options.status === undefined ? 200 : options.status;
|
|
2009
|
-
if (status < 200 || status > 500) {
|
|
2010
|
-
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2011
|
-
}
|
|
2012
|
-
if (options.headers) {
|
|
2013
|
-
that.headers = new HeadersP(options.headers);
|
|
2014
|
-
}
|
|
2015
|
-
that.ok = this.status >= 200 && this.status < 300;
|
|
2016
|
-
that.status = status;
|
|
2017
|
-
that.statusText = options.statusText === undefined ? "" : "" + options.statusText;
|
|
2018
|
-
Body_init(this, body, this.headers);
|
|
2019
|
-
}
|
|
2020
|
-
get headers() {
|
|
2021
|
-
const that = this[state$3];
|
|
2022
|
-
if (!that.headers) {
|
|
2023
|
-
that.headers = new HeadersP();
|
|
2024
|
-
}
|
|
2025
|
-
return that.headers;
|
|
2026
|
-
}
|
|
2027
|
-
get ok() { return this[state$3].ok; }
|
|
2028
|
-
get redirected() { return this[state$3].redirected; }
|
|
2029
|
-
get status() { return this[state$3].status; }
|
|
2030
|
-
get statusText() { return this[state$3].statusText; }
|
|
2031
|
-
get type() { return this[state$3].type; }
|
|
2032
|
-
get url() { return this[state$3].url; }
|
|
2033
|
-
clone() {
|
|
2034
|
-
let response = new ResponseP(Body_toPayload(this), {
|
|
2035
|
-
headers: new HeadersP(this.headers),
|
|
2036
|
-
status: this.status,
|
|
2037
|
-
statusText: this.statusText,
|
|
2038
|
-
});
|
|
2039
|
-
response[state$3].url = this.url;
|
|
2040
|
-
return response;
|
|
2041
|
-
}
|
|
2042
|
-
static json(data, init) {
|
|
2043
|
-
return new ResponseP(JSON.stringify(data), init);
|
|
2044
|
-
}
|
|
2045
|
-
static error() {
|
|
2046
|
-
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2047
|
-
response[state$3].ok = false;
|
|
2048
|
-
response[state$3].status = 0;
|
|
2049
|
-
response[state$3].type = "error";
|
|
2050
|
-
return response;
|
|
2051
|
-
}
|
|
2052
|
-
static redirect(url, status = 301) {
|
|
2053
|
-
if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
|
|
2054
|
-
throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
|
|
2055
|
-
}
|
|
2056
|
-
return new ResponseP(null, { status, headers: { location: String(url) } });
|
|
2057
|
-
}
|
|
2058
|
-
toString() { return "[object Response]"; }
|
|
2059
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
|
|
2060
|
-
}
|
|
2061
|
-
dfStringTag(ResponseP, "Response");
|
|
2062
|
-
/** @internal */
|
|
2063
|
-
class ResponseState {
|
|
2064
|
-
constructor() {
|
|
2065
|
-
this.ok = true;
|
|
2066
|
-
this.redirected = false;
|
|
2067
|
-
this.status = 200;
|
|
2068
|
-
this.statusText = "";
|
|
2069
|
-
this.type = "default";
|
|
2070
|
-
this.url = "";
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
const ResponseE = g["Response"] || ResponseP;
|
|
2074
|
-
|
|
2075
2181
|
var _a$1;
|
|
2076
|
-
/** @internal */ const state$
|
|
2182
|
+
/** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
|
|
2183
|
+
/** @type {typeof globalThis.XMLHttpRequestEventTarget} */
|
|
2077
2184
|
class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
2185
|
+
/** @internal */
|
|
2078
2186
|
constructor() {
|
|
2079
2187
|
if (new.target === XMLHttpRequestEventTargetP) {
|
|
2080
2188
|
throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
|
|
2081
2189
|
}
|
|
2082
2190
|
super();
|
|
2083
|
-
this[state$
|
|
2084
|
-
}
|
|
2085
|
-
get onabort() { return this[state$
|
|
2086
|
-
set onabort(value) { this[state$
|
|
2087
|
-
get onerror() { return this[state$
|
|
2088
|
-
set onerror(value) { this[state$
|
|
2089
|
-
get onload() { return this[state$
|
|
2090
|
-
set onload(value) { this[state$
|
|
2091
|
-
get onloadend() { return this[state$
|
|
2092
|
-
set onloadend(value) { this[state$
|
|
2093
|
-
get onloadstart() { return this[state$
|
|
2094
|
-
set onloadstart(value) { this[state$
|
|
2095
|
-
get onprogress() { return this[state$
|
|
2096
|
-
set onprogress(value) { this[state$
|
|
2097
|
-
get ontimeout() { return this[state$
|
|
2098
|
-
set ontimeout(value) { this[state$
|
|
2099
|
-
toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
2100
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2191
|
+
this[state$3] = new XMLHttpRequestEventTargetState(this);
|
|
2192
|
+
}
|
|
2193
|
+
get onabort() { return this[state$3].onabort; }
|
|
2194
|
+
set onabort(value) { this[state$3].onabort = value; attach(this, "abort"); }
|
|
2195
|
+
get onerror() { return this[state$3].onerror; }
|
|
2196
|
+
set onerror(value) { this[state$3].onerror = value; attach(this, "error"); }
|
|
2197
|
+
get onload() { return this[state$3].onload; }
|
|
2198
|
+
set onload(value) { this[state$3].onload = value; attach(this, "load"); }
|
|
2199
|
+
get onloadend() { return this[state$3].onloadend; }
|
|
2200
|
+
set onloadend(value) { this[state$3].onloadend = value; attach(this, "loadend"); }
|
|
2201
|
+
get onloadstart() { return this[state$3].onloadstart; }
|
|
2202
|
+
set onloadstart(value) { this[state$3].onloadstart = value; attach(this, "loadstart"); }
|
|
2203
|
+
get onprogress() { return this[state$3].onprogress; }
|
|
2204
|
+
set onprogress(value) { this[state$3].onprogress = value; attach(this, "progress"); }
|
|
2205
|
+
get ontimeout() { return this[state$3].ontimeout; }
|
|
2206
|
+
set ontimeout(value) { this[state$3].ontimeout = value; attach(this, "timeout"); }
|
|
2207
|
+
/** @internal */ toString() { return "[object XMLHttpRequestEventTarget]"; }
|
|
2208
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2209
|
+
}
|
|
2210
|
+
Class_setStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
|
|
2103
2211
|
/** @internal */
|
|
2104
2212
|
const _handlers$1 = Symbol();
|
|
2105
2213
|
/** @internal */
|
|
@@ -2121,7 +2229,7 @@ class XMLHttpRequestEventTargetState {
|
|
|
2121
2229
|
}
|
|
2122
2230
|
_a$1 = _handlers$1;
|
|
2123
2231
|
function attach(target, type) {
|
|
2124
|
-
const s = target[state$
|
|
2232
|
+
const s = target[state$3];
|
|
2125
2233
|
const fnName = ("on" + type);
|
|
2126
2234
|
const cb = s[fnName];
|
|
2127
2235
|
const listener = s[_handlers$1][fnName];
|
|
@@ -2139,22 +2247,24 @@ function getHandlers$1(s) {
|
|
|
2139
2247
|
};
|
|
2140
2248
|
}
|
|
2141
2249
|
|
|
2250
|
+
/** @type {typeof globalThis.XMLHttpRequestUpload} */
|
|
2142
2251
|
class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
2252
|
+
/** @internal */
|
|
2143
2253
|
constructor() {
|
|
2144
2254
|
if (new.target === XMLHttpRequestUploadP) {
|
|
2145
2255
|
throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
|
|
2146
2256
|
}
|
|
2147
2257
|
super();
|
|
2148
2258
|
}
|
|
2149
|
-
toString() { return "[object XMLHttpRequestUpload]"; }
|
|
2150
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2259
|
+
/** @internal */ toString() { return "[object XMLHttpRequestUpload]"; }
|
|
2260
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2151
2261
|
}
|
|
2152
|
-
|
|
2262
|
+
Class_setStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
|
|
2153
2263
|
/** @internal */
|
|
2154
2264
|
function createXMLHttpRequestUpload() {
|
|
2155
2265
|
let upload = Object.create(XMLHttpRequestUploadP.prototype);
|
|
2156
2266
|
upload[state$d] = new EventTargetState(upload);
|
|
2157
|
-
upload[state$
|
|
2267
|
+
upload[state$3] = new XMLHttpRequestEventTargetState(upload);
|
|
2158
2268
|
return upload;
|
|
2159
2269
|
}
|
|
2160
2270
|
|
|
@@ -2215,146 +2325,156 @@ const request = mp$2 ? mp$2.request : function errorRequest(options) {
|
|
|
2215
2325
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2216
2326
|
const mp$1 = { request: request };
|
|
2217
2327
|
const setRequest = (request) => { mp$1.request = request; };
|
|
2218
|
-
/** @internal */
|
|
2328
|
+
/** @internal */
|
|
2329
|
+
const state$2 = Symbol( /* "XMLHttpRequestState" */);
|
|
2330
|
+
/** @type {typeof globalThis.XMLHttpRequest} */
|
|
2219
2331
|
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
2220
2332
|
constructor() {
|
|
2221
2333
|
super();
|
|
2222
|
-
this[state$
|
|
2334
|
+
this[state$2] = new XMLHttpRequestState(this);
|
|
2223
2335
|
}
|
|
2224
|
-
get readyState() { return this[state$
|
|
2225
|
-
get response() { return this[state$
|
|
2336
|
+
get readyState() { return this[state$2].readyState; }
|
|
2337
|
+
get response() { return this[state$2].response; }
|
|
2226
2338
|
get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
|
|
2227
|
-
get responseType() { return this[state$
|
|
2228
|
-
set responseType(value) { this[state$
|
|
2229
|
-
get responseURL() { return this[state$
|
|
2339
|
+
get responseType() { return this[state$2].responseType; }
|
|
2340
|
+
set responseType(value) { this[state$2].responseType = normalizeResponseType(value); }
|
|
2341
|
+
get responseURL() { return this[state$2].responseURL; }
|
|
2230
2342
|
get responseXML() { return null; }
|
|
2231
|
-
get status() { return this[state$
|
|
2343
|
+
get status() { return this[state$2].status; }
|
|
2232
2344
|
get statusText() {
|
|
2233
2345
|
if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
|
|
2234
2346
|
return "";
|
|
2235
|
-
return this[state$
|
|
2347
|
+
return this[state$2].statusText || statusTextMap(this.status);
|
|
2236
2348
|
}
|
|
2237
|
-
get timeout() { return this[state$
|
|
2238
|
-
set timeout(value) { this[state$
|
|
2349
|
+
get timeout() { return this[state$2].timeout; }
|
|
2350
|
+
set timeout(value) { this[state$2].timeout = value > 0 ? value : 0; }
|
|
2239
2351
|
get upload() {
|
|
2240
|
-
const
|
|
2241
|
-
if (!
|
|
2242
|
-
|
|
2352
|
+
const s = this[state$2];
|
|
2353
|
+
if (!s.upload) {
|
|
2354
|
+
s.upload = createXMLHttpRequestUpload();
|
|
2243
2355
|
}
|
|
2244
|
-
return
|
|
2356
|
+
return s.upload;
|
|
2245
2357
|
}
|
|
2246
|
-
get withCredentials() { return this[state$
|
|
2247
|
-
set withCredentials(value) { this[state$
|
|
2358
|
+
get withCredentials() { return this[state$2].withCredentials; }
|
|
2359
|
+
set withCredentials(value) { this[state$2].withCredentials = !!value; }
|
|
2248
2360
|
abort() {
|
|
2249
2361
|
clearRequest(this);
|
|
2250
2362
|
}
|
|
2251
2363
|
getAllResponseHeaders() {
|
|
2252
|
-
if (!this[state$
|
|
2364
|
+
if (!this[state$2][_responseHeaders])
|
|
2253
2365
|
return "";
|
|
2254
|
-
return Array.from(this[state$
|
|
2366
|
+
return Array.from(this[state$2][_responseHeaders].entries()).map(([k, v]) => `${k}: ${v}\r\n`).join("");
|
|
2255
2367
|
}
|
|
2256
|
-
getResponseHeader(
|
|
2257
|
-
|
|
2368
|
+
getResponseHeader(...args) {
|
|
2369
|
+
const [name] = args;
|
|
2370
|
+
checkArgsLength(args, 1, "XMLHttpRequest", "getResponseHeader");
|
|
2371
|
+
if (!this[state$2][_responseHeaders])
|
|
2258
2372
|
return null;
|
|
2259
|
-
return this[state$
|
|
2373
|
+
return this[state$2][_responseHeaders].get(name);
|
|
2260
2374
|
}
|
|
2261
2375
|
open(...args) {
|
|
2262
2376
|
const [method, url, async = true, username = null, password = null] = args;
|
|
2263
|
-
|
|
2264
|
-
if (args.length < 2) {
|
|
2265
|
-
throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
|
|
2266
|
-
}
|
|
2377
|
+
checkArgsLength(args, 2, "XMLHttpRequest", "open");
|
|
2267
2378
|
if (!async) {
|
|
2268
2379
|
console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
|
|
2269
2380
|
}
|
|
2381
|
+
const s = this[state$2];
|
|
2270
2382
|
clearRequest(this, false);
|
|
2271
|
-
|
|
2272
|
-
|
|
2383
|
+
s[_method] = normalizeMethod(method);
|
|
2384
|
+
s[_requestURL] = "" + url;
|
|
2273
2385
|
if (username !== null || password !== null) {
|
|
2274
|
-
let _username =
|
|
2275
|
-
let _password =
|
|
2386
|
+
let _username = "" + (username !== null && username !== void 0 ? username : "");
|
|
2387
|
+
let _password = "" + (password !== null && password !== void 0 ? password : "");
|
|
2276
2388
|
if (_username.length > 0 || _password.length > 0) {
|
|
2277
|
-
let auth = `Basic ${Uint8Array_toBase64(
|
|
2389
|
+
let auth = `Basic ${Uint8Array_toBase64(encode$1(_username + ":" + _password))}`;
|
|
2278
2390
|
this.setRequestHeader("Authorization", auth);
|
|
2279
2391
|
}
|
|
2280
2392
|
}
|
|
2281
|
-
|
|
2393
|
+
s[_inAfterOpenBeforeSend] = true;
|
|
2282
2394
|
setReadyStateAndNotify(this, XMLHttpRequestP.OPENED);
|
|
2283
2395
|
}
|
|
2284
|
-
overrideMimeType(
|
|
2285
|
-
|
|
2286
|
-
|
|
2396
|
+
overrideMimeType(...args) {
|
|
2397
|
+
const [mime] = args;
|
|
2398
|
+
checkArgsLength(args, 1, "XMLHttpRequest", "overrideMimeType");
|
|
2399
|
+
if (this[state$2][_inAfterOpenBeforeSend]) {
|
|
2400
|
+
console.error(`TypeError: Failed to execute 'overrideMimeType' on 'XMLHttpRequest': mimeType ('${mime}') not implemented.`);
|
|
2287
2401
|
}
|
|
2288
2402
|
}
|
|
2289
2403
|
send(body) {
|
|
2290
|
-
const
|
|
2291
|
-
if (!
|
|
2404
|
+
const s = this[state$2];
|
|
2405
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED) {
|
|
2292
2406
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2293
2407
|
}
|
|
2294
|
-
|
|
2295
|
-
const allowsRequestBody =
|
|
2296
|
-
const processHeaders = allowsRequestBody && !
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2299
|
-
let headers = () => Array.from(that[_requestHeaders].entries())
|
|
2300
|
-
.reduce((acc, cur) => { acc[cur[0]] = cur[1]; return acc; }, {});
|
|
2408
|
+
s[_inAfterOpenBeforeSend] = false;
|
|
2409
|
+
const allowsRequestBody = s[_method] !== "GET" && s[_method] !== "HEAD";
|
|
2410
|
+
const processHeaders = allowsRequestBody && !s[_requestHeaders].has("Content-Type");
|
|
2411
|
+
const processContentLength = allowsRequestBody && !!body;
|
|
2412
|
+
let headers = () => { let dict = {}; s[_requestHeaders].forEach((value, name) => { dict[name] = value; }); return dict; };
|
|
2301
2413
|
let contentLength = zero;
|
|
2302
|
-
const processHeadersFn = processHeaders ? (v) => {
|
|
2414
|
+
const processHeadersFn = processHeaders ? (v) => { s[_requestHeaders].set("Content-Type", v); } : void 0;
|
|
2303
2415
|
const processContentLengthFn = processContentLength ? (v) => { contentLength = v; } : void 0;
|
|
2304
2416
|
let data = body;
|
|
2305
2417
|
try {
|
|
2306
|
-
data = convert(body, processHeadersFn, processContentLengthFn);
|
|
2418
|
+
data = convert(body, false, processHeadersFn, processContentLengthFn);
|
|
2307
2419
|
}
|
|
2308
2420
|
catch (e) {
|
|
2309
2421
|
console.warn(e);
|
|
2310
2422
|
}
|
|
2311
2423
|
let options = {
|
|
2312
|
-
url:
|
|
2313
|
-
method:
|
|
2424
|
+
url: s[_requestURL],
|
|
2425
|
+
method: s[_method],
|
|
2314
2426
|
header: headers(),
|
|
2315
2427
|
data,
|
|
2316
|
-
dataType:
|
|
2317
|
-
responseType: normalizeDataType(
|
|
2318
|
-
withCredentials:
|
|
2428
|
+
dataType: s.responseType === "json" ? "json" : normalizeDataType(s.responseType),
|
|
2429
|
+
responseType: normalizeDataType(s.responseType),
|
|
2430
|
+
withCredentials: s.withCredentials,
|
|
2319
2431
|
success: requestSuccess.bind(this),
|
|
2320
2432
|
fail: requestFail.bind(this),
|
|
2321
2433
|
complete: requestComplete.bind(this),
|
|
2322
2434
|
};
|
|
2323
|
-
|
|
2435
|
+
s[_requestTask] = mp$1.request(options);
|
|
2324
2436
|
emitProcessEvent(this, "loadstart");
|
|
2325
|
-
if (processContentLength) {
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
|
|
2437
|
+
if (processContentLength && s.upload) {
|
|
2438
|
+
emitProcessEvent(this.upload, "loadstart", 0, contentLength);
|
|
2439
|
+
}
|
|
2440
|
+
setTimeout(() => {
|
|
2441
|
+
if (s.upload) {
|
|
2442
|
+
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED;
|
|
2332
2443
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
2333
2444
|
if (_aborted) {
|
|
2334
|
-
emitProcessEvent(upload, "abort");
|
|
2445
|
+
emitProcessEvent(this.upload, "abort");
|
|
2335
2446
|
}
|
|
2336
2447
|
else {
|
|
2337
|
-
if (
|
|
2338
|
-
emitProcessEvent(upload, "load", _contentLength, _contentLength);
|
|
2448
|
+
if (processContentLength) {
|
|
2449
|
+
emitProcessEvent(this.upload, "load", _contentLength, _contentLength);
|
|
2339
2450
|
}
|
|
2340
2451
|
}
|
|
2341
|
-
if (_aborted ||
|
|
2342
|
-
emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
|
|
2452
|
+
if (_aborted || processContentLength) {
|
|
2453
|
+
emitProcessEvent(this.upload, "loadend", _contentLength, _contentLength);
|
|
2343
2454
|
}
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2455
|
+
}
|
|
2456
|
+
});
|
|
2346
2457
|
checkRequestTimeout(this);
|
|
2347
2458
|
}
|
|
2348
|
-
setRequestHeader(
|
|
2349
|
-
|
|
2459
|
+
setRequestHeader(...args) {
|
|
2460
|
+
const [name, value] = args;
|
|
2461
|
+
checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
|
|
2462
|
+
const s = this[state$2];
|
|
2463
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestP.OPENED) {
|
|
2464
|
+
throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2465
|
+
}
|
|
2466
|
+
let _name = normalizeName(name, () => {
|
|
2467
|
+
throw new SyntaxError(`Failed to execute 'setRequestHeader' on 'XMLHttpRequest': '${name}' is not a valid HTTP header field name.`);
|
|
2468
|
+
});
|
|
2469
|
+
s[_requestHeaders].append(_name, value);
|
|
2350
2470
|
}
|
|
2351
|
-
get onreadystatechange() { return this[state$
|
|
2471
|
+
get onreadystatechange() { return this[state$2].onreadystatechange; }
|
|
2352
2472
|
set onreadystatechange(value) {
|
|
2353
|
-
this[state$
|
|
2354
|
-
attachFn(this, "readystatechange", value, this[state$
|
|
2473
|
+
this[state$2].onreadystatechange = value;
|
|
2474
|
+
attachFn(this, "readystatechange", value, this[state$2][_handlers].onreadystatechange);
|
|
2355
2475
|
}
|
|
2356
|
-
toString() { return "[object XMLHttpRequest]"; }
|
|
2357
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2476
|
+
/** @internal */ toString() { return "[object XMLHttpRequest]"; }
|
|
2477
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2358
2478
|
}
|
|
2359
2479
|
const properties = {
|
|
2360
2480
|
UNSENT: { value: 0, enumerable: true },
|
|
@@ -2365,7 +2485,7 @@ const properties = {
|
|
|
2365
2485
|
};
|
|
2366
2486
|
Object.defineProperties(XMLHttpRequestP, properties);
|
|
2367
2487
|
Object.defineProperties(XMLHttpRequestP.prototype, properties);
|
|
2368
|
-
|
|
2488
|
+
Class_setStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
2369
2489
|
/** @internal */ const _handlers = Symbol();
|
|
2370
2490
|
/** @internal */ const _inAfterOpenBeforeSend = Symbol();
|
|
2371
2491
|
/** @internal */ const _resetPending = Symbol();
|
|
@@ -2403,7 +2523,7 @@ class XMLHttpRequestState {
|
|
|
2403
2523
|
}
|
|
2404
2524
|
_a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
2405
2525
|
function requestSuccess({ statusCode, header, data }) {
|
|
2406
|
-
const s = this[state$
|
|
2526
|
+
const s = this[state$2];
|
|
2407
2527
|
s.responseURL = s[_requestURL];
|
|
2408
2528
|
s.status = statusCode;
|
|
2409
2529
|
s[_responseHeaders] = new HeadersP(header);
|
|
@@ -2440,7 +2560,7 @@ function requestFail(err) {
|
|
|
2440
2560
|
requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
|
|
2441
2561
|
return;
|
|
2442
2562
|
}
|
|
2443
|
-
const s = this[state$
|
|
2563
|
+
const s = this[state$2];
|
|
2444
2564
|
s.status = 0;
|
|
2445
2565
|
s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
2446
2566
|
if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestP.UNSENT && s.readyState !== XMLHttpRequestP.DONE) {
|
|
@@ -2449,7 +2569,7 @@ function requestFail(err) {
|
|
|
2449
2569
|
}
|
|
2450
2570
|
}
|
|
2451
2571
|
function requestComplete() {
|
|
2452
|
-
const s = this[state$
|
|
2572
|
+
const s = this[state$2];
|
|
2453
2573
|
s[_requestTask] = null;
|
|
2454
2574
|
if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestP.OPENED || s.readyState === XMLHttpRequestP.LOADING)) {
|
|
2455
2575
|
setReadyStateAndNotify(this, XMLHttpRequestP.DONE);
|
|
@@ -2462,7 +2582,7 @@ function requestComplete() {
|
|
|
2462
2582
|
});
|
|
2463
2583
|
}
|
|
2464
2584
|
function clearRequest(xhr, delay = true) {
|
|
2465
|
-
const s = xhr[state$
|
|
2585
|
+
const s = xhr[state$2];
|
|
2466
2586
|
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
2467
2587
|
s[_resetPending] = true;
|
|
2468
2588
|
if (s[_requestTask] && s.readyState !== XMLHttpRequestP.DONE) {
|
|
@@ -2492,7 +2612,7 @@ function clearRequest(xhr, delay = true) {
|
|
|
2492
2612
|
});
|
|
2493
2613
|
}
|
|
2494
2614
|
function checkRequestTimeout(xhr) {
|
|
2495
|
-
const s = xhr[state$
|
|
2615
|
+
const s = xhr[state$2];
|
|
2496
2616
|
if (s.timeout) {
|
|
2497
2617
|
s[_timeoutId] = setTimeout(() => {
|
|
2498
2618
|
if (!s.status && s.readyState !== XMLHttpRequestP.DONE) {
|
|
@@ -2505,7 +2625,7 @@ function checkRequestTimeout(xhr) {
|
|
|
2505
2625
|
}
|
|
2506
2626
|
}
|
|
2507
2627
|
function resetXHR(xhr) {
|
|
2508
|
-
const s = xhr[state$
|
|
2628
|
+
const s = xhr[state$2];
|
|
2509
2629
|
s[_resetPending] = false;
|
|
2510
2630
|
resetRequestTimeout(xhr);
|
|
2511
2631
|
s.response = "";
|
|
@@ -2517,14 +2637,14 @@ function resetXHR(xhr) {
|
|
|
2517
2637
|
s[_responseContentLength] = zero;
|
|
2518
2638
|
}
|
|
2519
2639
|
function resetRequestTimeout(xhr) {
|
|
2520
|
-
const s = xhr[state$
|
|
2640
|
+
const s = xhr[state$2];
|
|
2521
2641
|
if (s[_timeoutId]) {
|
|
2522
2642
|
clearTimeout(s[_timeoutId]);
|
|
2523
2643
|
s[_timeoutId] = 0;
|
|
2524
2644
|
}
|
|
2525
2645
|
}
|
|
2526
2646
|
function setReadyStateAndNotify(xhr, value) {
|
|
2527
|
-
const s = xhr[state$
|
|
2647
|
+
const s = xhr[state$2];
|
|
2528
2648
|
let hasChanged = value !== s.readyState;
|
|
2529
2649
|
s.readyState = value;
|
|
2530
2650
|
if (hasChanged) {
|
|
@@ -2544,11 +2664,6 @@ function normalizeResponseType(responseType) {
|
|
|
2544
2664
|
function normalizeDataType(responseType) {
|
|
2545
2665
|
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
2546
2666
|
}
|
|
2547
|
-
function getAllResponseHeaders(xhr) {
|
|
2548
|
-
return xhr instanceof XMLHttpRequestP
|
|
2549
|
-
? xhr[state$1][_responseHeaders]
|
|
2550
|
-
: parseHeaders(xhr.getAllResponseHeaders() || "");
|
|
2551
|
-
}
|
|
2552
2667
|
const zero = () => 0;
|
|
2553
2668
|
const statusMessages = {
|
|
2554
2669
|
100: "Continue",
|
|
@@ -2618,13 +2733,104 @@ function statusTextMap(val) {
|
|
|
2618
2733
|
}
|
|
2619
2734
|
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
2620
2735
|
|
|
2736
|
+
/** @internal */ const state$1 = Symbol( /* "ResponseState" */);
|
|
2737
|
+
/** @type {typeof globalThis.Response} */
|
|
2738
|
+
class ResponseP extends BodyImpl {
|
|
2739
|
+
constructor(body, init) {
|
|
2740
|
+
super();
|
|
2741
|
+
this[state$7].name = "Response";
|
|
2742
|
+
this[state$1] = new ResponseState();
|
|
2743
|
+
const s = this[state$1];
|
|
2744
|
+
let _init = init !== null && init !== void 0 ? init : {};
|
|
2745
|
+
if (typeof _init !== "object") {
|
|
2746
|
+
throw new TypeError("Failed to construct 'Response': The provided value is not of type 'ResponseInit'.");
|
|
2747
|
+
}
|
|
2748
|
+
let status = _init.status === undefined ? 200 : _init.status;
|
|
2749
|
+
if (status < 200 || status > 500) {
|
|
2750
|
+
throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
|
|
2751
|
+
}
|
|
2752
|
+
if (_init.headers) {
|
|
2753
|
+
s.headers = new HeadersP(_init.headers);
|
|
2754
|
+
}
|
|
2755
|
+
s.ok = status >= 200 && status < 300;
|
|
2756
|
+
s.status = status;
|
|
2757
|
+
s.statusText = _init.statusText === undefined ? "" : "" + _init.statusText;
|
|
2758
|
+
Body_init(this, body);
|
|
2759
|
+
}
|
|
2760
|
+
get headers() {
|
|
2761
|
+
const s = this[state$1];
|
|
2762
|
+
if (!s.headers) {
|
|
2763
|
+
s.headers = new HeadersP();
|
|
2764
|
+
}
|
|
2765
|
+
return s.headers;
|
|
2766
|
+
}
|
|
2767
|
+
get ok() { return this[state$1].ok; }
|
|
2768
|
+
get redirected() { return this[state$1].redirected; }
|
|
2769
|
+
get status() { return this[state$1].status; }
|
|
2770
|
+
get statusText() { return this[state$1].statusText; }
|
|
2771
|
+
get type() { return this[state$1].type; }
|
|
2772
|
+
get url() { return this[state$1].url; }
|
|
2773
|
+
clone() {
|
|
2774
|
+
if (this.bodyUsed) {
|
|
2775
|
+
throw new TypeError("Failed to execute 'clone' on 'Response': Response body is already used");
|
|
2776
|
+
}
|
|
2777
|
+
let response = new ResponseP(Body_toPayload(this), {
|
|
2778
|
+
headers: new HeadersP(this.headers),
|
|
2779
|
+
status: this.status,
|
|
2780
|
+
statusText: this.statusText,
|
|
2781
|
+
});
|
|
2782
|
+
response[state$1].url = this.url;
|
|
2783
|
+
return response;
|
|
2784
|
+
}
|
|
2785
|
+
static json(...args) {
|
|
2786
|
+
const [data, init] = args;
|
|
2787
|
+
checkArgsLength(args, 1, "Response", "json");
|
|
2788
|
+
let response = new ResponseP(typeof data === "string" ? data : JSON.stringify(data), init);
|
|
2789
|
+
response.headers.set("Content-Type", "application/json");
|
|
2790
|
+
return response;
|
|
2791
|
+
}
|
|
2792
|
+
static error() {
|
|
2793
|
+
let response = new ResponseP(null, { status: 200, statusText: "" });
|
|
2794
|
+
response[state$1].ok = false;
|
|
2795
|
+
response[state$1].status = 0;
|
|
2796
|
+
response[state$1].type = "error";
|
|
2797
|
+
return response;
|
|
2798
|
+
}
|
|
2799
|
+
static redirect(...args) {
|
|
2800
|
+
const [url, status = 301] = args;
|
|
2801
|
+
checkArgsLength(args, 1, "Response", "redirect");
|
|
2802
|
+
if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
|
|
2803
|
+
throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
|
|
2804
|
+
}
|
|
2805
|
+
return new ResponseP(null, { status, headers: { location: "" + url } });
|
|
2806
|
+
}
|
|
2807
|
+
/** @internal */ toString() { return "[object Response]"; }
|
|
2808
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
|
|
2809
|
+
}
|
|
2810
|
+
Class_setStringTag(ResponseP, "Response");
|
|
2811
|
+
/** @internal */
|
|
2812
|
+
class ResponseState {
|
|
2813
|
+
constructor() {
|
|
2814
|
+
this.ok = true;
|
|
2815
|
+
this.redirected = false;
|
|
2816
|
+
this.status = 200;
|
|
2817
|
+
this.statusText = "";
|
|
2818
|
+
this.type = "default";
|
|
2819
|
+
this.url = "";
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
const ResponseE = g["Response"] || ResponseP;
|
|
2823
|
+
|
|
2621
2824
|
const mp = { XMLHttpRequest: XMLHttpRequestE };
|
|
2622
2825
|
const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
|
|
2623
|
-
|
|
2826
|
+
/** @type {typeof globalThis["fetch"]} */
|
|
2827
|
+
function fetchP(...args) {
|
|
2624
2828
|
if (new.target === fetchP) {
|
|
2625
2829
|
throw new TypeError("fetch is not a constructor");
|
|
2626
2830
|
}
|
|
2627
|
-
|
|
2831
|
+
const [input, init] = args;
|
|
2832
|
+
checkArgsLength(args, 1, "Window", "fetch");
|
|
2833
|
+
return new Promise((resolve, reject) => {
|
|
2628
2834
|
const request = new RequestP(input, init);
|
|
2629
2835
|
const signal = request[state$4].signal;
|
|
2630
2836
|
if (signal && signal.aborted) {
|
|
@@ -2633,13 +2839,18 @@ function fetchP(input, init) {
|
|
|
2633
2839
|
let xhr = new mp.XMLHttpRequest();
|
|
2634
2840
|
xhr.onload = function () {
|
|
2635
2841
|
let options = {
|
|
2636
|
-
headers: getAllResponseHeaders(
|
|
2842
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || ""),
|
|
2637
2843
|
status: xhr.status,
|
|
2638
2844
|
statusText: xhr.statusText,
|
|
2639
2845
|
};
|
|
2846
|
+
// This check if specifically for when a user fetches a file locally from the file system
|
|
2847
|
+
// Only if the status is out of a normal range
|
|
2848
|
+
if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
2849
|
+
options.status = 200;
|
|
2850
|
+
}
|
|
2640
2851
|
setTimeout(() => {
|
|
2641
|
-
let response = new ResponseP(xhr.response, options);
|
|
2642
|
-
response[state$
|
|
2852
|
+
let response = new ResponseP("response" in xhr ? xhr.response : xhr.responseText, options);
|
|
2853
|
+
response[state$1].url = "responseURL" in xhr ? xhr.responseURL : (options.headers.get("X-Request-URL") || "");
|
|
2643
2854
|
resolve(response);
|
|
2644
2855
|
});
|
|
2645
2856
|
};
|
|
@@ -2658,28 +2869,31 @@ function fetchP(input, init) {
|
|
|
2658
2869
|
reject(new MPException("request:fail abort", "AbortError"));
|
|
2659
2870
|
});
|
|
2660
2871
|
};
|
|
2661
|
-
xhr.open(request.method, request.url);
|
|
2872
|
+
xhr.open(request.method, request.url, true);
|
|
2662
2873
|
if (request.credentials === "include") {
|
|
2663
2874
|
xhr.withCredentials = true;
|
|
2664
2875
|
}
|
|
2665
2876
|
else if (request.credentials === "omit") {
|
|
2666
2877
|
xhr.withCredentials = false;
|
|
2667
2878
|
}
|
|
2668
|
-
if (
|
|
2879
|
+
if ("responseType" in xhr) {
|
|
2880
|
+
xhr.responseType = "arraybuffer";
|
|
2881
|
+
}
|
|
2882
|
+
if (init && typeof init === "object" && typeof init.headers === "object" && !isObjectType("Headers", init.headers)) {
|
|
2669
2883
|
let headers = init.headers;
|
|
2670
2884
|
let names = [];
|
|
2671
|
-
|
|
2885
|
+
Object.getOwnPropertyNames(headers).forEach(name => {
|
|
2672
2886
|
names.push(normalizeName(name));
|
|
2673
|
-
xhr.setRequestHeader(name, normalizeValue(
|
|
2887
|
+
xhr.setRequestHeader(name, normalizeValue(headers[name]));
|
|
2674
2888
|
});
|
|
2675
|
-
request.headers.forEach(
|
|
2676
|
-
if (names.indexOf(
|
|
2889
|
+
request.headers.forEach((value, name) => {
|
|
2890
|
+
if (names.indexOf(name) === -1) {
|
|
2677
2891
|
xhr.setRequestHeader(name, value);
|
|
2678
2892
|
}
|
|
2679
2893
|
});
|
|
2680
2894
|
}
|
|
2681
2895
|
else {
|
|
2682
|
-
request.headers.forEach(
|
|
2896
|
+
request.headers.forEach((value, name) => {
|
|
2683
2897
|
xhr.setRequestHeader(name, value);
|
|
2684
2898
|
});
|
|
2685
2899
|
}
|
|
@@ -2696,14 +2910,12 @@ function fetchP(input, init) {
|
|
|
2696
2910
|
xhr.send(Body_toPayload(request));
|
|
2697
2911
|
});
|
|
2698
2912
|
}
|
|
2699
|
-
function isObjectHeaders(val) {
|
|
2700
|
-
return typeof val === "object" && !isObjectType("Headers", val);
|
|
2701
|
-
}
|
|
2702
2913
|
const fetchE = g["fetch"] || fetchP;
|
|
2703
2914
|
|
|
2704
2915
|
const dispatched = 1;
|
|
2705
2916
|
/** @internal */
|
|
2706
2917
|
const state = Symbol( /* "CustomEventState" */);
|
|
2918
|
+
/** @type {typeof globalThis.CustomEvent} */
|
|
2707
2919
|
class CustomEventP extends EventP {
|
|
2708
2920
|
constructor(type, eventInitDict) {
|
|
2709
2921
|
var _a;
|
|
@@ -2712,16 +2924,18 @@ class CustomEventP extends EventP {
|
|
|
2712
2924
|
this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
|
|
2713
2925
|
}
|
|
2714
2926
|
get detail() { return this[state].detail; }
|
|
2715
|
-
initCustomEvent(
|
|
2927
|
+
initCustomEvent(...args) {
|
|
2928
|
+
const [type, bubbles, cancelable, detail] = args;
|
|
2929
|
+
checkArgsLength(args, 1, "CustomEvent", "initCustomEvent");
|
|
2716
2930
|
if (Event_getEtField(this, dispatched))
|
|
2717
2931
|
return;
|
|
2718
2932
|
this.initEvent(type, bubbles, cancelable);
|
|
2719
2933
|
this[state].detail = detail !== null && detail !== void 0 ? detail : null;
|
|
2720
2934
|
}
|
|
2721
|
-
toString() { return "[object CustomEvent]"; }
|
|
2722
|
-
get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
2935
|
+
/** @internal */ toString() { return "[object CustomEvent]"; }
|
|
2936
|
+
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
|
|
2723
2937
|
}
|
|
2724
|
-
|
|
2938
|
+
Class_setStringTag(CustomEventP, "CustomEvent");
|
|
2725
2939
|
/** @internal */
|
|
2726
2940
|
class CustomEventState {
|
|
2727
2941
|
}
|