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