mphttpx 1.0.8 → 1.0.10
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 +930 -716
- package/dist/index.cjs.js +177 -192
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.d.ts +22 -39
- package/dist/index.esm.js +177 -192
- package/dist/index.esm.min.js +1 -1
- package/package.json +17 -4
package/dist/index.esm.js
CHANGED
|
@@ -47,7 +47,6 @@ function isPolyfillType(name, value) {
|
|
|
47
47
|
&& value.isPolyfill.hierarchy.indexOf(name) > -1;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/** @type {typeof globalThis.TextEncoder} */
|
|
51
50
|
class TextEncoderP {
|
|
52
51
|
get encoding() { return "utf-8"; }
|
|
53
52
|
encode(input = "") {
|
|
@@ -167,7 +166,6 @@ const TextEncoderE = g["TextEncoder"] || TextEncoderP;
|
|
|
167
166
|
var _a$a, _b$3;
|
|
168
167
|
/** @internal */
|
|
169
168
|
const state$h = Symbol( /* "TextDecoderState" */);
|
|
170
|
-
/** @type {typeof globalThis.TextDecoder} */
|
|
171
169
|
class TextDecoderP {
|
|
172
170
|
constructor(label = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
|
|
173
171
|
let _label = "" + label;
|
|
@@ -347,7 +345,6 @@ const TextDecoderE = g["TextDecoder"] || TextDecoderP;
|
|
|
347
345
|
|
|
348
346
|
/** @internal */
|
|
349
347
|
const state$g = Symbol( /* "BlobState" */);
|
|
350
|
-
/** @type {typeof globalThis.Blob} */
|
|
351
348
|
class BlobP {
|
|
352
349
|
constructor(blobParts = [], options) {
|
|
353
350
|
if (!(Array.isArray(blobParts) || (blobParts && typeof blobParts === "object" && Symbol.iterator in blobParts))) {
|
|
@@ -467,7 +464,6 @@ const BlobE = g["Blob"] || BlobP;
|
|
|
467
464
|
|
|
468
465
|
/** @internal */
|
|
469
466
|
const state$f = Symbol( /* "FileState" */);
|
|
470
|
-
/** @type {typeof globalThis.File} */
|
|
471
467
|
class FileP extends BlobP {
|
|
472
468
|
constructor(...args) {
|
|
473
469
|
const [fileBits, fileName, options] = args;
|
|
@@ -495,7 +491,6 @@ const FileE = g["Blob"] ? g["File"] : FileP;
|
|
|
495
491
|
|
|
496
492
|
var _a$9, _b$2, _c$1, _d$1, _e$1;
|
|
497
493
|
/** @internal */ const state$e = Symbol( /* "EventState" */);
|
|
498
|
-
/** @type {typeof globalThis.Event} */
|
|
499
494
|
class EventP {
|
|
500
495
|
constructor(...args) {
|
|
501
496
|
const [type, eventInitDict] = args;
|
|
@@ -565,14 +560,14 @@ class EventP {
|
|
|
565
560
|
/** @internal */ toString() { return "[object Event]"; }
|
|
566
561
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
|
|
567
562
|
}
|
|
568
|
-
const properties$
|
|
563
|
+
const properties$1 = {
|
|
569
564
|
NONE: { value: 0, enumerable: true },
|
|
570
565
|
CAPTURING_PHASE: { value: 1, enumerable: true },
|
|
571
566
|
AT_TARGET: { value: 2, enumerable: true },
|
|
572
567
|
BUBBLING_PHASE: { value: 3, enumerable: true },
|
|
573
568
|
};
|
|
574
|
-
Object.defineProperties(EventP, properties$
|
|
575
|
-
Object.defineProperties(EventP.prototype, properties$
|
|
569
|
+
Object.defineProperties(EventP, properties$1);
|
|
570
|
+
Object.defineProperties(EventP.prototype, properties$1);
|
|
576
571
|
Class_setStringTag(EventP, "Event");
|
|
577
572
|
/** @internal */ const _timeStamp = (new Date()).getTime();
|
|
578
573
|
/** @internal */ const _isTrusted = Symbol();
|
|
@@ -662,7 +657,6 @@ const dispatched$1 = 1;
|
|
|
662
657
|
const preventDefaultCalled = 2;
|
|
663
658
|
const stopImmediatePropagationCalled = 3;
|
|
664
659
|
/** @internal */ const state$d = Symbol( /* "EventTargetState" */);
|
|
665
|
-
/** @type {typeof globalThis.EventTarget} */
|
|
666
660
|
class EventTargetP {
|
|
667
661
|
constructor() {
|
|
668
662
|
this[state$d] = new EventTargetState(this);
|
|
@@ -828,7 +822,6 @@ const EventTargetE = g["EventTarget"] || EventTargetP;
|
|
|
828
822
|
|
|
829
823
|
/** @internal */
|
|
830
824
|
const state$c = Symbol( /* "ProgressEventState" */);
|
|
831
|
-
/** @type {typeof globalThis.ProgressEvent} */
|
|
832
825
|
class ProgressEventP extends EventP {
|
|
833
826
|
constructor(type, eventInitDict) {
|
|
834
827
|
var _a, _b;
|
|
@@ -890,7 +883,6 @@ const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
|
|
|
890
883
|
var _a$7;
|
|
891
884
|
/** @internal */
|
|
892
885
|
const state$b = Symbol( /* "FileReaderState" */);
|
|
893
|
-
/** @type {typeof globalThis.FileReader} */
|
|
894
886
|
class FileReaderP extends EventTargetP {
|
|
895
887
|
constructor() {
|
|
896
888
|
super();
|
|
@@ -956,13 +948,13 @@ class FileReaderP extends EventTargetP {
|
|
|
956
948
|
/** @internal */ toString() { return "[object FileReader]"; }
|
|
957
949
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
|
|
958
950
|
}
|
|
959
|
-
const properties
|
|
951
|
+
const properties = {
|
|
960
952
|
EMPTY: { value: 0, enumerable: true },
|
|
961
953
|
LOADING: { value: 1, enumerable: true },
|
|
962
954
|
DONE: { value: 2, enumerable: true },
|
|
963
955
|
};
|
|
964
|
-
Object.defineProperties(FileReaderP, properties
|
|
965
|
-
Object.defineProperties(FileReaderP.prototype, properties
|
|
956
|
+
Object.defineProperties(FileReaderP, properties);
|
|
957
|
+
Object.defineProperties(FileReaderP.prototype, properties);
|
|
966
958
|
Class_setStringTag(FileReaderP, "FileReader");
|
|
967
959
|
/** @internal */
|
|
968
960
|
const _handlers$3 = Symbol();
|
|
@@ -1031,7 +1023,6 @@ const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
|
|
|
1031
1023
|
var _a$6;
|
|
1032
1024
|
/** @internal */ const state$a = Symbol( /* "URLSearchParamsState" */);
|
|
1033
1025
|
const checkArgsFn$2 = (args, required, funcName) => { checkArgsLength(args, required, "URLSearchParams", funcName); };
|
|
1034
|
-
/** @type {typeof globalThis.URLSearchParams} */
|
|
1035
1026
|
class URLSearchParamsP {
|
|
1036
1027
|
constructor(init) {
|
|
1037
1028
|
this[state$a] = new URLSearchParamsState();
|
|
@@ -1257,7 +1248,6 @@ const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
|
|
|
1257
1248
|
var _a$5;
|
|
1258
1249
|
/** @internal */ const state$9 = Symbol( /* "FormDataState" */);
|
|
1259
1250
|
const checkArgsFn$1 = (args, required, funcName) => { checkArgsLength(args, required, "FormData", funcName); };
|
|
1260
|
-
/** @type {typeof globalThis.FormData} */
|
|
1261
1251
|
class FormDataP {
|
|
1262
1252
|
constructor(form, submitter) {
|
|
1263
1253
|
if (submitter === undefined) {
|
|
@@ -1496,7 +1486,6 @@ const FormDataE = g["FormData"] || FormDataP;
|
|
|
1496
1486
|
var _a$4, _b$1;
|
|
1497
1487
|
/** @internal */ const state$8 = Symbol( /* "HeadersState" */);
|
|
1498
1488
|
const checkArgsFn = (args, required, funcName) => { checkArgsLength(args, required, "Headers", funcName); };
|
|
1499
|
-
/** @type {typeof globalThis.Headers} */
|
|
1500
1489
|
class HeadersP {
|
|
1501
1490
|
constructor(init) {
|
|
1502
1491
|
this[state$8] = new HeadersState();
|
|
@@ -1902,7 +1891,6 @@ function convertBack(type, data) {
|
|
|
1902
1891
|
var _a$2;
|
|
1903
1892
|
/** @internal */
|
|
1904
1893
|
const state$6 = Symbol( /* "AbortSignalState" */);
|
|
1905
|
-
/** @type {typeof globalThis.AbortSignal} */
|
|
1906
1894
|
class AbortSignalP extends EventTargetP {
|
|
1907
1895
|
static abort(reason) {
|
|
1908
1896
|
let signal = createAbortSignal();
|
|
@@ -2018,7 +2006,6 @@ const AbortSignalE = g["AbortSignal"] || AbortSignalP;
|
|
|
2018
2006
|
|
|
2019
2007
|
/** @internal */
|
|
2020
2008
|
const state$5 = Symbol( /* "AbortControllerState" */);
|
|
2021
|
-
/** @type {typeof globalThis.AbortController} */
|
|
2022
2009
|
class AbortControllerP {
|
|
2023
2010
|
constructor() {
|
|
2024
2011
|
this[state$5] = new AbortControllerState();
|
|
@@ -2040,7 +2027,6 @@ class AbortControllerState {
|
|
|
2040
2027
|
const AbortControllerE = g["AbortController"] || AbortControllerP;
|
|
2041
2028
|
|
|
2042
2029
|
/** @internal */ const state$4 = Symbol( /* "RequestState" */);
|
|
2043
|
-
/** @type {typeof globalThis.Request} */
|
|
2044
2030
|
class RequestP extends BodyImpl {
|
|
2045
2031
|
constructor(...args) {
|
|
2046
2032
|
const [input, init] = args;
|
|
@@ -2178,9 +2164,62 @@ function normalizeMethod(method) {
|
|
|
2178
2164
|
}
|
|
2179
2165
|
const RequestE = g["Request"] || RequestP;
|
|
2180
2166
|
|
|
2167
|
+
// @ts-nocheck
|
|
2168
|
+
/** @internal */
|
|
2169
|
+
const mp$2 = (() => {
|
|
2170
|
+
let u = "undefined", r = "request", f = "function";
|
|
2171
|
+
let mp;
|
|
2172
|
+
mp =
|
|
2173
|
+
(typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
|
|
2174
|
+
(typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
|
|
2175
|
+
(typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
|
|
2176
|
+
(typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
|
|
2177
|
+
(typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
|
|
2178
|
+
(typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
|
|
2179
|
+
(typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
|
|
2180
|
+
(typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
|
|
2181
|
+
(typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
|
|
2182
|
+
undefined;
|
|
2183
|
+
if (typeof g["XMLHttpRequest"] === f) {
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if (mp === undefined)
|
|
2187
|
+
mp =
|
|
2188
|
+
(typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
|
|
2189
|
+
(typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
|
|
2190
|
+
undefined;
|
|
2191
|
+
return mp;
|
|
2192
|
+
})();
|
|
2193
|
+
|
|
2194
|
+
const request = mp$2 ? mp$2.request : function errorRequest(options) {
|
|
2195
|
+
const errMsg = "NOT_SUPPORTED_ERR";
|
|
2196
|
+
const errno = 9;
|
|
2197
|
+
const err = {
|
|
2198
|
+
errMsg,
|
|
2199
|
+
errno,
|
|
2200
|
+
exception: {
|
|
2201
|
+
retryCount: 0,
|
|
2202
|
+
reasons: [{ errMsg, errno }],
|
|
2203
|
+
},
|
|
2204
|
+
useHttpDNS: false,
|
|
2205
|
+
};
|
|
2206
|
+
Promise.resolve(err)
|
|
2207
|
+
.then(err => { try {
|
|
2208
|
+
if (options.fail) {
|
|
2209
|
+
options.fail(err);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
catch (e) {
|
|
2213
|
+
console.error(e);
|
|
2214
|
+
} })
|
|
2215
|
+
.then(() => { if (options.complete) {
|
|
2216
|
+
options.complete(err);
|
|
2217
|
+
} });
|
|
2218
|
+
throw new ReferenceError("request is not defined");
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2181
2221
|
var _a$1;
|
|
2182
2222
|
/** @internal */ const state$3 = Symbol( /* "XMLHttpRequestEventTargetState" */);
|
|
2183
|
-
/** @type {typeof globalThis.XMLHttpRequestEventTarget} */
|
|
2184
2223
|
class XMLHttpRequestEventTargetP extends EventTargetP {
|
|
2185
2224
|
/** @internal */
|
|
2186
2225
|
constructor() {
|
|
@@ -2246,8 +2285,87 @@ function getHandlers$1(s) {
|
|
|
2246
2285
|
ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
|
|
2247
2286
|
};
|
|
2248
2287
|
}
|
|
2288
|
+
/** @internal */
|
|
2289
|
+
const XHR_properties = {
|
|
2290
|
+
UNSENT: { value: 0, enumerable: true },
|
|
2291
|
+
OPENED: { value: 1, enumerable: true },
|
|
2292
|
+
HEADERS_RECEIVED: { value: 2, enumerable: true },
|
|
2293
|
+
LOADING: { value: 3, enumerable: true },
|
|
2294
|
+
DONE: { value: 4, enumerable: true },
|
|
2295
|
+
};
|
|
2296
|
+
const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
|
|
2297
|
+
/** @internal */
|
|
2298
|
+
function normalizeResponseType(responseType) {
|
|
2299
|
+
return responseTypes.indexOf(responseType) > -1 ? responseType : "";
|
|
2300
|
+
}
|
|
2301
|
+
const statusMessages = {
|
|
2302
|
+
100: "Continue",
|
|
2303
|
+
101: "Switching Protocols",
|
|
2304
|
+
102: "Processing",
|
|
2305
|
+
103: "Early Hints",
|
|
2306
|
+
200: "OK",
|
|
2307
|
+
201: "Created",
|
|
2308
|
+
202: "Accepted",
|
|
2309
|
+
203: "Non-Authoritative Information",
|
|
2310
|
+
204: "No Content",
|
|
2311
|
+
205: "Reset Content",
|
|
2312
|
+
206: "Partial Content",
|
|
2313
|
+
207: "Multi-Status",
|
|
2314
|
+
208: "Already Reported",
|
|
2315
|
+
226: "IM Used",
|
|
2316
|
+
300: "Multiple Choices",
|
|
2317
|
+
301: "Moved Permanently",
|
|
2318
|
+
302: "Found",
|
|
2319
|
+
303: "See Other",
|
|
2320
|
+
304: "Not Modified",
|
|
2321
|
+
307: "Temporary Redirect",
|
|
2322
|
+
308: "Permanent Redirect",
|
|
2323
|
+
400: "Bad Request",
|
|
2324
|
+
401: "Unauthorized",
|
|
2325
|
+
402: "Payment Required",
|
|
2326
|
+
403: "Forbidden",
|
|
2327
|
+
404: "Not Found",
|
|
2328
|
+
405: "Method Not Allowed",
|
|
2329
|
+
406: "Not Acceptable",
|
|
2330
|
+
407: "Proxy Authentication Required",
|
|
2331
|
+
408: "Request Timeout",
|
|
2332
|
+
409: "Conflict",
|
|
2333
|
+
410: "Gone",
|
|
2334
|
+
411: "Length Required",
|
|
2335
|
+
412: "Precondition Failed",
|
|
2336
|
+
413: "Content Too Large",
|
|
2337
|
+
414: "URI Too Long",
|
|
2338
|
+
415: "Unsupported Media Type",
|
|
2339
|
+
416: "Range Not Satisfiable",
|
|
2340
|
+
417: "Expectation Failed",
|
|
2341
|
+
418: "I'm a teapot",
|
|
2342
|
+
421: "Misdirected Request",
|
|
2343
|
+
422: "Unprocessable Entity",
|
|
2344
|
+
423: "Locked",
|
|
2345
|
+
424: "Failed Dependency",
|
|
2346
|
+
425: "Too Early",
|
|
2347
|
+
426: "Upgrade Required",
|
|
2348
|
+
428: "Precondition Required",
|
|
2349
|
+
429: "Too Many Requests",
|
|
2350
|
+
431: "Request Header Fields Too Large",
|
|
2351
|
+
451: "Unavailable For Legal Reasons",
|
|
2352
|
+
500: "Internal Server Error",
|
|
2353
|
+
501: "Not Implemented",
|
|
2354
|
+
502: "Bad Gateway",
|
|
2355
|
+
503: "Service Unavailable",
|
|
2356
|
+
504: "Gateway Timeout",
|
|
2357
|
+
505: "HTTP Version Not Supported",
|
|
2358
|
+
506: "Variant Also Negotiates",
|
|
2359
|
+
507: "Insufficient Storage",
|
|
2360
|
+
508: "Loop Detected",
|
|
2361
|
+
510: "Not Extended",
|
|
2362
|
+
511: "Network Authentication Required"
|
|
2363
|
+
};
|
|
2364
|
+
/** @internal */
|
|
2365
|
+
function statusTextMap(val) {
|
|
2366
|
+
return statusMessages[val] || "unknown";
|
|
2367
|
+
}
|
|
2249
2368
|
|
|
2250
|
-
/** @type {typeof globalThis.XMLHttpRequestUpload} */
|
|
2251
2369
|
class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
|
|
2252
2370
|
/** @internal */
|
|
2253
2371
|
constructor() {
|
|
@@ -2268,67 +2386,12 @@ function createXMLHttpRequestUpload() {
|
|
|
2268
2386
|
return upload;
|
|
2269
2387
|
}
|
|
2270
2388
|
|
|
2271
|
-
// @ts-nocheck
|
|
2272
|
-
/** @internal */
|
|
2273
|
-
const mp$2 = (() => {
|
|
2274
|
-
let u = "undefined", r = "request", f = "function";
|
|
2275
|
-
let mp;
|
|
2276
|
-
mp =
|
|
2277
|
-
(typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
|
|
2278
|
-
(typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
|
|
2279
|
-
(typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
|
|
2280
|
-
(typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
|
|
2281
|
-
(typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
|
|
2282
|
-
(typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
|
|
2283
|
-
(typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
|
|
2284
|
-
(typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
|
|
2285
|
-
(typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
|
|
2286
|
-
undefined;
|
|
2287
|
-
if (typeof g["XMLHttpRequest"] === f) {
|
|
2288
|
-
return;
|
|
2289
|
-
}
|
|
2290
|
-
if (mp === undefined)
|
|
2291
|
-
mp =
|
|
2292
|
-
(typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
|
|
2293
|
-
(typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
|
|
2294
|
-
undefined;
|
|
2295
|
-
return mp;
|
|
2296
|
-
})();
|
|
2297
|
-
|
|
2298
|
-
const request = mp$2 ? mp$2.request : function errorRequest(options) {
|
|
2299
|
-
const errMsg = "NOT_SUPPORTED_ERR";
|
|
2300
|
-
const errno = 9;
|
|
2301
|
-
const err = {
|
|
2302
|
-
errMsg,
|
|
2303
|
-
errno,
|
|
2304
|
-
exception: {
|
|
2305
|
-
retryCount: 0,
|
|
2306
|
-
reasons: [{ errMsg, errno }],
|
|
2307
|
-
},
|
|
2308
|
-
useHttpDNS: false,
|
|
2309
|
-
};
|
|
2310
|
-
Promise.resolve(err)
|
|
2311
|
-
.then(err => { try {
|
|
2312
|
-
if (options.fail) {
|
|
2313
|
-
options.fail(err);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
catch (e) {
|
|
2317
|
-
console.error(e);
|
|
2318
|
-
} })
|
|
2319
|
-
.then(() => { if (options.complete) {
|
|
2320
|
-
options.complete(err);
|
|
2321
|
-
} });
|
|
2322
|
-
throw new ReferenceError("request is not defined");
|
|
2323
|
-
};
|
|
2324
|
-
|
|
2325
2389
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2326
2390
|
const mp$1 = { request: request };
|
|
2327
2391
|
const setRequest = (request) => { mp$1.request = request; };
|
|
2328
2392
|
/** @internal */
|
|
2329
2393
|
const state$2 = Symbol( /* "XMLHttpRequestState" */);
|
|
2330
|
-
|
|
2331
|
-
class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
2394
|
+
class XMLHttpRequestImpl extends XMLHttpRequestEventTargetP {
|
|
2332
2395
|
constructor() {
|
|
2333
2396
|
super();
|
|
2334
2397
|
this[state$2] = new XMLHttpRequestState(this);
|
|
@@ -2342,7 +2405,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2342
2405
|
get responseXML() { return null; }
|
|
2343
2406
|
get status() { return this[state$2].status; }
|
|
2344
2407
|
get statusText() {
|
|
2345
|
-
if (this.readyState ===
|
|
2408
|
+
if (this.readyState === XMLHttpRequestImpl.UNSENT || this.readyState === XMLHttpRequestImpl.OPENED)
|
|
2346
2409
|
return "";
|
|
2347
2410
|
return this[state$2].statusText || statusTextMap(this.status);
|
|
2348
2411
|
}
|
|
@@ -2391,7 +2454,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2391
2454
|
}
|
|
2392
2455
|
}
|
|
2393
2456
|
s[_inAfterOpenBeforeSend] = true;
|
|
2394
|
-
setReadyStateAndNotify(this,
|
|
2457
|
+
setReadyStateAndNotify(this, XMLHttpRequestImpl.OPENED);
|
|
2395
2458
|
}
|
|
2396
2459
|
overrideMimeType(...args) {
|
|
2397
2460
|
const [mime] = args;
|
|
@@ -2402,7 +2465,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2402
2465
|
}
|
|
2403
2466
|
send(body) {
|
|
2404
2467
|
const s = this[state$2];
|
|
2405
|
-
if (!s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2468
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
|
|
2406
2469
|
throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2407
2470
|
}
|
|
2408
2471
|
s[_inAfterOpenBeforeSend] = false;
|
|
@@ -2410,7 +2473,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2410
2473
|
const processHeaders = allowsRequestBody && !s[_requestHeaders].has("Content-Type");
|
|
2411
2474
|
const processContentLength = allowsRequestBody && !!body;
|
|
2412
2475
|
let headers = () => { let dict = {}; s[_requestHeaders].forEach((value, name) => { dict[name] = value; }); return dict; };
|
|
2413
|
-
let contentLength =
|
|
2476
|
+
let contentLength = () => 0;
|
|
2414
2477
|
const processHeadersFn = processHeaders ? (v) => { s[_requestHeaders].set("Content-Type", v); } : void 0;
|
|
2415
2478
|
const processContentLengthFn = processContentLength ? (v) => { contentLength = v; } : void 0;
|
|
2416
2479
|
let data = body;
|
|
@@ -2424,7 +2487,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2424
2487
|
url: s[_requestURL],
|
|
2425
2488
|
method: s[_method],
|
|
2426
2489
|
header: headers(),
|
|
2427
|
-
data,
|
|
2490
|
+
data: data !== "" ? data : void 0,
|
|
2428
2491
|
dataType: s.responseType === "json" ? "json" : normalizeDataType(s.responseType),
|
|
2429
2492
|
responseType: normalizeDataType(s.responseType),
|
|
2430
2493
|
withCredentials: s.withCredentials,
|
|
@@ -2439,7 +2502,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2439
2502
|
}
|
|
2440
2503
|
setTimeout(() => {
|
|
2441
2504
|
if (s.upload) {
|
|
2442
|
-
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2505
|
+
const _aborted = s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED;
|
|
2443
2506
|
const _contentLength = _aborted ? 0 : contentLength;
|
|
2444
2507
|
if (_aborted) {
|
|
2445
2508
|
emitProcessEvent(this.upload, "abort");
|
|
@@ -2460,7 +2523,7 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2460
2523
|
const [name, value] = args;
|
|
2461
2524
|
checkArgsLength(args, 2, "XMLHttpRequest", "setRequestHeader");
|
|
2462
2525
|
const s = this[state$2];
|
|
2463
|
-
if (!s[_inAfterOpenBeforeSend] || s.readyState !==
|
|
2526
|
+
if (!s[_inAfterOpenBeforeSend] || s.readyState !== XMLHttpRequestImpl.OPENED) {
|
|
2464
2527
|
throw new MPException("Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
|
|
2465
2528
|
}
|
|
2466
2529
|
let _name = normalizeName(name, () => {
|
|
@@ -2476,16 +2539,9 @@ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
|
|
|
2476
2539
|
/** @internal */ toString() { return "[object XMLHttpRequest]"; }
|
|
2477
2540
|
/** @internal */ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
|
|
2478
2541
|
}
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
HEADERS_RECEIVED: { value: 2, enumerable: true },
|
|
2483
|
-
LOADING: { value: 3, enumerable: true },
|
|
2484
|
-
DONE: { value: 4, enumerable: true },
|
|
2485
|
-
};
|
|
2486
|
-
Object.defineProperties(XMLHttpRequestP, properties);
|
|
2487
|
-
Object.defineProperties(XMLHttpRequestP.prototype, properties);
|
|
2488
|
-
Class_setStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
2542
|
+
Object.defineProperties(XMLHttpRequestImpl, XHR_properties);
|
|
2543
|
+
Object.defineProperties(XMLHttpRequestImpl.prototype, XHR_properties);
|
|
2544
|
+
Class_setStringTag(XMLHttpRequestImpl, "XMLHttpRequest");
|
|
2489
2545
|
/** @internal */ const _handlers = Symbol();
|
|
2490
2546
|
/** @internal */ const _inAfterOpenBeforeSend = Symbol();
|
|
2491
2547
|
/** @internal */ const _resetPending = Symbol();
|
|
@@ -2499,7 +2555,7 @@ Class_setStringTag(XMLHttpRequestP, "XMLHttpRequest");
|
|
|
2499
2555
|
/** @internal */
|
|
2500
2556
|
class XMLHttpRequestState {
|
|
2501
2557
|
constructor(target) {
|
|
2502
|
-
this.readyState =
|
|
2558
|
+
this.readyState = XMLHttpRequestImpl.UNSENT;
|
|
2503
2559
|
this.response = "";
|
|
2504
2560
|
this.responseType = "";
|
|
2505
2561
|
this.responseURL = "";
|
|
@@ -2516,12 +2572,20 @@ class XMLHttpRequestState {
|
|
|
2516
2572
|
this[_f] = "GET";
|
|
2517
2573
|
this[_g] = new HeadersP();
|
|
2518
2574
|
this[_h] = null;
|
|
2519
|
-
this[_j] =
|
|
2575
|
+
this[_j] = () => 0;
|
|
2520
2576
|
this[_k] = null;
|
|
2521
2577
|
this.target = target;
|
|
2522
2578
|
}
|
|
2523
2579
|
}
|
|
2524
2580
|
_a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
|
|
2581
|
+
function getHandlers(s) {
|
|
2582
|
+
return {
|
|
2583
|
+
onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
function normalizeDataType(responseType) {
|
|
2587
|
+
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
2588
|
+
}
|
|
2525
2589
|
function requestSuccess({ statusCode, header, data }) {
|
|
2526
2590
|
const s = this[state$2];
|
|
2527
2591
|
s.responseURL = s[_requestURL];
|
|
@@ -2529,9 +2593,9 @@ function requestSuccess({ statusCode, header, data }) {
|
|
|
2529
2593
|
s[_responseHeaders] = new HeadersP(header);
|
|
2530
2594
|
let lengthStr = s[_responseHeaders].get("Content-Length");
|
|
2531
2595
|
s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
|
|
2532
|
-
if (s.readyState ===
|
|
2533
|
-
setReadyStateAndNotify(this,
|
|
2534
|
-
setReadyStateAndNotify(this,
|
|
2596
|
+
if (s.readyState === XMLHttpRequestImpl.OPENED) {
|
|
2597
|
+
setReadyStateAndNotify(this, XMLHttpRequestImpl.HEADERS_RECEIVED);
|
|
2598
|
+
setReadyStateAndNotify(this, XMLHttpRequestImpl.LOADING);
|
|
2535
2599
|
setTimeout(() => {
|
|
2536
2600
|
if (!s[_inAfterOpenBeforeSend]) {
|
|
2537
2601
|
let l = s[_responseContentLength];
|
|
@@ -2563,7 +2627,7 @@ function requestFail(err) {
|
|
|
2563
2627
|
const s = this[state$2];
|
|
2564
2628
|
s.status = 0;
|
|
2565
2629
|
s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
|
|
2566
|
-
if (!s[_inAfterOpenBeforeSend] && s.readyState !==
|
|
2630
|
+
if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestImpl.UNSENT && s.readyState !== XMLHttpRequestImpl.DONE) {
|
|
2567
2631
|
emitProcessEvent(this, "error");
|
|
2568
2632
|
resetRequestTimeout(this);
|
|
2569
2633
|
}
|
|
@@ -2571,8 +2635,8 @@ function requestFail(err) {
|
|
|
2571
2635
|
function requestComplete() {
|
|
2572
2636
|
const s = this[state$2];
|
|
2573
2637
|
s[_requestTask] = null;
|
|
2574
|
-
if (!s[_inAfterOpenBeforeSend] && (s.readyState ===
|
|
2575
|
-
setReadyStateAndNotify(this,
|
|
2638
|
+
if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestImpl.OPENED || s.readyState === XMLHttpRequestImpl.LOADING)) {
|
|
2639
|
+
setReadyStateAndNotify(this, XMLHttpRequestImpl.DONE);
|
|
2576
2640
|
}
|
|
2577
2641
|
setTimeout(() => {
|
|
2578
2642
|
if (!s[_inAfterOpenBeforeSend]) {
|
|
@@ -2585,9 +2649,9 @@ function clearRequest(xhr, delay = true) {
|
|
|
2585
2649
|
const s = xhr[state$2];
|
|
2586
2650
|
const timerFn = delay ? setTimeout : (f) => { f(); };
|
|
2587
2651
|
s[_resetPending] = true;
|
|
2588
|
-
if (s[_requestTask] && s.readyState !==
|
|
2652
|
+
if (s[_requestTask] && s.readyState !== XMLHttpRequestImpl.DONE) {
|
|
2589
2653
|
if (delay) {
|
|
2590
|
-
setReadyStateAndNotify(xhr,
|
|
2654
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
|
|
2591
2655
|
}
|
|
2592
2656
|
timerFn(() => {
|
|
2593
2657
|
const requestTask = s[_requestTask];
|
|
@@ -2605,7 +2669,7 @@ function clearRequest(xhr, delay = true) {
|
|
|
2605
2669
|
timerFn(() => {
|
|
2606
2670
|
if (s[_resetPending]) {
|
|
2607
2671
|
if (delay) {
|
|
2608
|
-
s.readyState =
|
|
2672
|
+
s.readyState = XMLHttpRequestImpl.UNSENT;
|
|
2609
2673
|
}
|
|
2610
2674
|
resetXHR(xhr);
|
|
2611
2675
|
}
|
|
@@ -2615,10 +2679,10 @@ function checkRequestTimeout(xhr) {
|
|
|
2615
2679
|
const s = xhr[state$2];
|
|
2616
2680
|
if (s.timeout) {
|
|
2617
2681
|
s[_timeoutId] = setTimeout(() => {
|
|
2618
|
-
if (!s.status && s.readyState !==
|
|
2682
|
+
if (!s.status && s.readyState !== XMLHttpRequestImpl.DONE) {
|
|
2619
2683
|
if (s[_requestTask])
|
|
2620
2684
|
s[_requestTask].abort();
|
|
2621
|
-
setReadyStateAndNotify(xhr,
|
|
2685
|
+
setReadyStateAndNotify(xhr, XMLHttpRequestImpl.DONE);
|
|
2622
2686
|
emitProcessEvent(xhr, "timeout");
|
|
2623
2687
|
}
|
|
2624
2688
|
}, s.timeout);
|
|
@@ -2634,7 +2698,7 @@ function resetXHR(xhr) {
|
|
|
2634
2698
|
s.statusText = "";
|
|
2635
2699
|
s[_requestHeaders] = new HeadersP();
|
|
2636
2700
|
s[_responseHeaders] = null;
|
|
2637
|
-
s[_responseContentLength] =
|
|
2701
|
+
s[_responseContentLength] = () => 0;
|
|
2638
2702
|
}
|
|
2639
2703
|
function resetRequestTimeout(xhr) {
|
|
2640
2704
|
const s = xhr[state$2];
|
|
@@ -2652,89 +2716,11 @@ function setReadyStateAndNotify(xhr, value) {
|
|
|
2652
2716
|
EventTarget_fire(xhr, evt);
|
|
2653
2717
|
}
|
|
2654
2718
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
|
|
2658
|
-
};
|
|
2659
|
-
}
|
|
2660
|
-
const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
|
|
2661
|
-
function normalizeResponseType(responseType) {
|
|
2662
|
-
return responseTypes.indexOf(responseType) > -1 ? responseType : "";
|
|
2663
|
-
}
|
|
2664
|
-
function normalizeDataType(responseType) {
|
|
2665
|
-
return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
|
|
2666
|
-
}
|
|
2667
|
-
const zero = () => 0;
|
|
2668
|
-
const statusMessages = {
|
|
2669
|
-
100: "Continue",
|
|
2670
|
-
101: "Switching Protocols",
|
|
2671
|
-
102: "Processing",
|
|
2672
|
-
103: "Early Hints",
|
|
2673
|
-
200: "OK",
|
|
2674
|
-
201: "Created",
|
|
2675
|
-
202: "Accepted",
|
|
2676
|
-
203: "Non-Authoritative Information",
|
|
2677
|
-
204: "No Content",
|
|
2678
|
-
205: "Reset Content",
|
|
2679
|
-
206: "Partial Content",
|
|
2680
|
-
207: "Multi-Status",
|
|
2681
|
-
208: "Already Reported",
|
|
2682
|
-
226: "IM Used",
|
|
2683
|
-
300: "Multiple Choices",
|
|
2684
|
-
301: "Moved Permanently",
|
|
2685
|
-
302: "Found",
|
|
2686
|
-
303: "See Other",
|
|
2687
|
-
304: "Not Modified",
|
|
2688
|
-
307: "Temporary Redirect",
|
|
2689
|
-
308: "Permanent Redirect",
|
|
2690
|
-
400: "Bad Request",
|
|
2691
|
-
401: "Unauthorized",
|
|
2692
|
-
402: "Payment Required",
|
|
2693
|
-
403: "Forbidden",
|
|
2694
|
-
404: "Not Found",
|
|
2695
|
-
405: "Method Not Allowed",
|
|
2696
|
-
406: "Not Acceptable",
|
|
2697
|
-
407: "Proxy Authentication Required",
|
|
2698
|
-
408: "Request Timeout",
|
|
2699
|
-
409: "Conflict",
|
|
2700
|
-
410: "Gone",
|
|
2701
|
-
411: "Length Required",
|
|
2702
|
-
412: "Precondition Failed",
|
|
2703
|
-
413: "Content Too Large",
|
|
2704
|
-
414: "URI Too Long",
|
|
2705
|
-
415: "Unsupported Media Type",
|
|
2706
|
-
416: "Range Not Satisfiable",
|
|
2707
|
-
417: "Expectation Failed",
|
|
2708
|
-
418: "I'm a teapot",
|
|
2709
|
-
421: "Misdirected Request",
|
|
2710
|
-
422: "Unprocessable Entity",
|
|
2711
|
-
423: "Locked",
|
|
2712
|
-
424: "Failed Dependency",
|
|
2713
|
-
425: "Too Early",
|
|
2714
|
-
426: "Upgrade Required",
|
|
2715
|
-
428: "Precondition Required",
|
|
2716
|
-
429: "Too Many Requests",
|
|
2717
|
-
431: "Request Header Fields Too Large",
|
|
2718
|
-
451: "Unavailable For Legal Reasons",
|
|
2719
|
-
500: "Internal Server Error",
|
|
2720
|
-
501: "Not Implemented",
|
|
2721
|
-
502: "Bad Gateway",
|
|
2722
|
-
503: "Service Unavailable",
|
|
2723
|
-
504: "Gateway Timeout",
|
|
2724
|
-
505: "HTTP Version Not Supported",
|
|
2725
|
-
506: "Variant Also Negotiates",
|
|
2726
|
-
507: "Insufficient Storage",
|
|
2727
|
-
508: "Loop Detected",
|
|
2728
|
-
510: "Not Extended",
|
|
2729
|
-
511: "Network Authentication Required"
|
|
2730
|
-
};
|
|
2731
|
-
function statusTextMap(val) {
|
|
2732
|
-
return statusMessages[val] || "unknown";
|
|
2733
|
-
}
|
|
2719
|
+
|
|
2720
|
+
const XMLHttpRequestP = XMLHttpRequestImpl;
|
|
2734
2721
|
const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
|
|
2735
2722
|
|
|
2736
2723
|
/** @internal */ const state$1 = Symbol( /* "ResponseState" */);
|
|
2737
|
-
/** @type {typeof globalThis.Response} */
|
|
2738
2724
|
class ResponseP extends BodyImpl {
|
|
2739
2725
|
constructor(body, init) {
|
|
2740
2726
|
super();
|
|
@@ -2823,7 +2809,6 @@ const ResponseE = g["Response"] || ResponseP;
|
|
|
2823
2809
|
|
|
2824
2810
|
const mp = { XMLHttpRequest: XMLHttpRequestE };
|
|
2825
2811
|
const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
|
|
2826
|
-
/** @type {typeof globalThis["fetch"]} */
|
|
2827
2812
|
function fetchP(...args) {
|
|
2828
2813
|
if (new.target === fetchP) {
|
|
2829
2814
|
throw new TypeError("fetch is not a constructor");
|
|
@@ -2907,7 +2892,8 @@ function fetchP(...args) {
|
|
|
2907
2892
|
}
|
|
2908
2893
|
};
|
|
2909
2894
|
}
|
|
2910
|
-
|
|
2895
|
+
let body = Body_toPayload(request);
|
|
2896
|
+
xhr.send(body !== "" ? body : void 0);
|
|
2911
2897
|
});
|
|
2912
2898
|
}
|
|
2913
2899
|
const fetchE = g["fetch"] || fetchP;
|
|
@@ -2915,7 +2901,6 @@ const fetchE = g["fetch"] || fetchP;
|
|
|
2915
2901
|
const dispatched = 1;
|
|
2916
2902
|
/** @internal */
|
|
2917
2903
|
const state = Symbol( /* "CustomEventState" */);
|
|
2918
|
-
/** @type {typeof globalThis.CustomEvent} */
|
|
2919
2904
|
class CustomEventP extends EventP {
|
|
2920
2905
|
constructor(type, eventInitDict) {
|
|
2921
2906
|
var _a;
|