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