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