mphttpx 2.3.1 → 2.6.0

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.
@@ -172,6 +172,14 @@ function setState(target, name, value) {
172
172
  value: value
173
173
  });
174
174
  }
175
+ // Safe wrapper around String() for type-like representations (e.g. "[object Blob]"). Axios
176
+ function typeString(value) {
177
+ try {
178
+ return String(value);
179
+ } catch (e) {
180
+ return "[object Unknown]";
181
+ }
182
+ }
175
183
  function isObjectType(name, value) {
176
184
  return Object.prototype.toString.call(value) === "[object ".concat(name, "]");
177
185
  }
@@ -570,7 +578,7 @@ function concatString(val) {
570
578
  }
571
579
  // Mini Program
572
580
  function isOtherArrayBuffer(value) {
573
- return (isObjectType("ArrayBuffer", value) || String(value) === "[object ArrayBuffer]") && !!value && _typeof(value) === "object" && "byteLength" in value && typeof value.byteLength === "number";
581
+ return !!value && _typeof(value) === "object" && "byteLength" in value && typeof value.byteLength === "number" && (isObjectType("ArrayBuffer", value) || typeString(value) === "[object ArrayBuffer]");
574
582
  }
575
583
  function isArrayBuffer(value) {
576
584
  return !!value && _typeof(value) === "object" && ArrayBuffer.prototype.isPrototypeOf(value) || isOtherArrayBuffer(value);
@@ -921,7 +929,7 @@ function isEvent(value) {
921
929
  var predicate = function predicate(str) {
922
930
  return "[object " === str.slice(0, 8) && str.slice(-6) === "Event]";
923
931
  };
924
- return !!value && _typeof(value) === "object" && (predicate(Object.prototype.toString.call(value)) || predicate(String(value))) && "type" in value && typeof value.type === "string";
932
+ return !!value && _typeof(value) === "object" && "type" in value && typeof value.type === "string" && (predicate(Object.prototype.toString.call(value)) || predicate(typeString(value)));
925
933
  }
926
934
  function whenAbort(target, executor, signal) {
927
935
  var _onAbort = function onAbort() {
@@ -1473,7 +1481,7 @@ function isExternalBlob(value) {
1473
1481
  var strict = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1474
1482
  var expects = ["[object Blob]"];
1475
1483
  if (!strict) expects.push("[object File]");
1476
- return (expects.indexOf(Object.prototype.toString.call(value)) > -1 || expects.indexOf(String(value)) > -1) && !!value && _typeof(value) === "object" && "size" in value && typeof value.size === "number" && "arrayBuffer" in value && typeof value.arrayBuffer === "function";
1484
+ return !!value && _typeof(value) === "object" && "size" in value && typeof value.size === "number" && "arrayBuffer" in value && typeof value.arrayBuffer === "function" && (expects.indexOf(Object.prototype.toString.call(value)) > -1 || expects.indexOf(typeString(value)) > -1);
1477
1485
  }
1478
1486
  var BlobE = function () {
1479
1487
  try {
@@ -2229,10 +2237,10 @@ function decode(str) {
2229
2237
  });
2230
2238
  }
2231
2239
  function isURLSearchParams(value) {
2232
- return isPolyfillType("URLSearchParams", value) || isGlobalURLSearchParams(value);
2240
+ return isPolyfillType("URLSearchParams", value) || isExternalURLSearchParams(value);
2233
2241
  }
2234
- function isGlobalURLSearchParams(value) {
2235
- return isObjectType("URLSearchParams", value) || !!value && _typeof(value) === "object" && typeof URLSearchParams !== "undefined" && URLSearchParams && URLSearchParams.prototype.isPrototypeOf(value);
2242
+ function isExternalURLSearchParams(value) {
2243
+ return isObjectType("URLSearchParams", value) || !!value && _typeof(value) === "object" && typeof URLSearchParams === "function" && value instanceof URLSearchParams;
2236
2244
  }
2237
2245
  var URLSearchParamsE = typeof URLSearchParams !== "undefined" && URLSearchParams || URLSearchParamsP;
2238
2246
 
@@ -2483,7 +2491,7 @@ function isFormData(value) {
2483
2491
  }
2484
2492
  function isExternalFormData(value) {
2485
2493
  var expect = "[object FormData]";
2486
- return (Object.prototype.toString.call(value) === expect || String(value) === expect) && !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function";
2494
+ return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect || typeString(value) === expect);
2487
2495
  }
2488
2496
  function FormData_toBlob(formData, externalBoundary) {
2489
2497
  var boundary = externalBoundary || "----formdata-mphttpx-" + Math.random();
@@ -2760,7 +2768,7 @@ function state$8(target) {
2760
2768
  }
2761
2769
  function initBody(instance, body) {
2762
2770
  var b = instance;
2763
- if (isGlobalReadableStream(body) || isOtherReadableStream(body)) {
2771
+ if (isReadableStream(body)) {
2764
2772
  throw new TypeError("Failed to construct '".concat(className(b), "': ReadableStream not implemented."));
2765
2773
  }
2766
2774
  if (body !== null && body !== undefined) {
@@ -2801,11 +2809,12 @@ function consumed(body, kind) {
2801
2809
  }
2802
2810
  return Promise.reject(new TypeError("Failed to execute '".concat(kind, "' on '").concat(className(body), "': body stream already read")));
2803
2811
  }
2804
- function isGlobalReadableStream(value) {
2805
- return !!value && _typeof(value) === "object" && typeof ReadableStream !== "undefined" && ReadableStream && ReadableStream.prototype.isPrototypeOf(value);
2812
+ function isReadableStream(value) {
2813
+ return isExternalReadableStream(value);
2806
2814
  }
2807
- function isOtherReadableStream(value) {
2808
- return (isObjectType("ReadableStream", value) || String(value) === "[object ReadableStream]") && !!value && _typeof(value) === "object" && "getReader" in value && typeof value.getReader === "function";
2815
+ function isExternalReadableStream(value) {
2816
+ var expect = "[object ReadableStream]";
2817
+ return !!value && _typeof(value) === "object" && "getReader" in value && typeof value.getReader === "function" && (Object.prototype.toString.call(value) === expect || typeString(value) === expect);
2809
2818
  }
2810
2819
 
2811
2820
  var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
@@ -2983,7 +2992,7 @@ function isHeaders(value) {
2983
2992
  }
2984
2993
  function isExternalHeaders(value) {
2985
2994
  var expect = "[object Headers]";
2986
- return (Object.prototype.toString.call(value) === expect || String(value) === expect) && !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function";
2995
+ return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect || typeString(value) === expect);
2987
2996
  }
2988
2997
  function normalizeName(name, throwError) {
2989
2998
  if (typeof name !== "string") {
@@ -3222,7 +3231,7 @@ function isRequest(value) {
3222
3231
  }
3223
3232
  function isExternalRequest(value) {
3224
3233
  var expect = "[object Request]";
3225
- return (Object.prototype.toString.call(value) === expect || String(value) === expect) && !!value && _typeof(value) === "object" && "arrayBuffer" in value && typeof value.arrayBuffer === "function";
3234
+ return !!value && _typeof(value) === "object" && "arrayBuffer" in value && typeof value.arrayBuffer === "function" && (Object.prototype.toString.call(value) === expect || typeString(value) === expect);
3226
3235
  }
3227
3236
  function createPhonyPayload(request) {
3228
3237
  var payload = Object.create(Payload.prototype);
@@ -6306,7 +6315,7 @@ var WebSocketP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
6306
6315
  onError(_this);
6307
6316
  onMessage(_this);
6308
6317
  } else {
6309
- throw new Error("connectSocket can't establish a connection to the server at ".concat("" + url, "."));
6318
+ throw new Error("connectSocket can't establish a connection to the server at ".concat(targetURL, "."));
6310
6319
  }
6311
6320
  return _this;
6312
6321
  }