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