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