mphttpx 2.6.0 → 2.6.1
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 +1 -1
- package/dist/cjs/fetchP.js +7 -13
- package/dist/cjs/index.js +5 -17
- package/dist/esm/fetchP.js +7 -6
- package/dist/esm/index.js +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/mphttpx.cjs.js +228 -1454
- package/dist/mphttpx.cjs.min.js +1 -1
- package/dist/mphttpx.esm.js +227 -1450
- package/dist/mphttpx.esm.min.js +1 -1
- package/dist/mphttpx.umd.js +5516 -0
- package/dist/mphttpx.umd.min.js +1 -0
- package/package.json +7 -6
package/dist/mphttpx.esm.js
CHANGED
|
@@ -8,13 +8,6 @@ function _callSuper(t, o, e) {
|
|
|
8
8
|
function _classCallCheck(a, n) {
|
|
9
9
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
10
10
|
}
|
|
11
|
-
function _construct(t, e, r) {
|
|
12
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
13
|
-
var o = [null];
|
|
14
|
-
o.push.apply(o, e);
|
|
15
|
-
var p = new (t.bind.apply(t, o))();
|
|
16
|
-
return r && _setPrototypeOf(p, r.prototype), p;
|
|
17
|
-
}
|
|
18
11
|
function _defineProperties(e, r) {
|
|
19
12
|
for (var t = 0; t < r.length; t++) {
|
|
20
13
|
var o = r[t];
|
|
@@ -51,13 +44,6 @@ function _inherits(t, e) {
|
|
|
51
44
|
writable: false
|
|
52
45
|
}), e && _setPrototypeOf(t, e);
|
|
53
46
|
}
|
|
54
|
-
function _isNativeFunction(t) {
|
|
55
|
-
try {
|
|
56
|
-
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
57
|
-
} catch (n) {
|
|
58
|
-
return "function" == typeof t;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
47
|
function _isNativeReflectConstruct() {
|
|
62
48
|
try {
|
|
63
49
|
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
@@ -99,35 +85,20 @@ function _typeof(o) {
|
|
|
99
85
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
100
86
|
}, _typeof(o);
|
|
101
87
|
}
|
|
102
|
-
function _wrapNativeSuper(t) {
|
|
103
|
-
var r = "function" == typeof Map ? new Map() : void 0;
|
|
104
|
-
return _wrapNativeSuper = function (t) {
|
|
105
|
-
if (null === t || !_isNativeFunction(t)) return t;
|
|
106
|
-
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
107
|
-
if (void 0 !== r) {
|
|
108
|
-
if (r.has(t)) return r.get(t);
|
|
109
|
-
r.set(t, Wrapper);
|
|
110
|
-
}
|
|
111
|
-
function Wrapper() {
|
|
112
|
-
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
113
|
-
}
|
|
114
|
-
return Wrapper.prototype = Object.create(t.prototype, {
|
|
115
|
-
constructor: {
|
|
116
|
-
value: Wrapper,
|
|
117
|
-
enumerable: false,
|
|
118
|
-
writable: true,
|
|
119
|
-
configurable: true
|
|
120
|
-
}
|
|
121
|
-
}), _setPrototypeOf(Wrapper, t);
|
|
122
|
-
}, _wrapNativeSuper(t);
|
|
123
|
-
}
|
|
124
88
|
|
|
125
89
|
// Safe fallback for Symbol.iterator and Symbol.toStringTag — uses native Symbol when available, string keys otherwise.
|
|
126
90
|
var _Symbol = {
|
|
127
|
-
iterator:
|
|
128
|
-
|
|
91
|
+
iterator: /*#__PURE__*/function () {
|
|
92
|
+
return typeof Symbol === "function" && Symbol.iterator || "Symbol(Symbol.iterator)";
|
|
93
|
+
}(),
|
|
94
|
+
toStringTag: /*#__PURE__*/function () {
|
|
95
|
+
return typeof Symbol === "function" && Symbol.toStringTag || "Symbol(Symbol.toStringTag)";
|
|
96
|
+
}()
|
|
129
97
|
};
|
|
130
|
-
var
|
|
98
|
+
var _Error = /*#__PURE__*/function () {
|
|
99
|
+
return Error;
|
|
100
|
+
}();
|
|
101
|
+
var DOMExceptionP = /*#__PURE__*/function (_Error2, _Symbol$toStringTag) {
|
|
131
102
|
function DOMExceptionP(message, name) {
|
|
132
103
|
var _this;
|
|
133
104
|
_classCallCheck(this, DOMExceptionP);
|
|
@@ -136,7 +107,7 @@ var DOMExceptionP = /*#__PURE__*/function (_Error, _Symbol$toStringTag) {
|
|
|
136
107
|
return _this;
|
|
137
108
|
}
|
|
138
109
|
/** @internal */
|
|
139
|
-
_inherits(DOMExceptionP,
|
|
110
|
+
_inherits(DOMExceptionP, _Error2);
|
|
140
111
|
return _createClass(DOMExceptionP, [{
|
|
141
112
|
key: _Symbol$toStringTag,
|
|
142
113
|
get: function get() {
|
|
@@ -151,15 +122,19 @@ var DOMExceptionP = /*#__PURE__*/function (_Error, _Symbol$toStringTag) {
|
|
|
151
122
|
};
|
|
152
123
|
}
|
|
153
124
|
}]);
|
|
154
|
-
}(
|
|
155
|
-
|
|
125
|
+
}(_Error, _Symbol.toStringTag);
|
|
126
|
+
function isDOMExceptionSupported() {
|
|
156
127
|
try {
|
|
157
128
|
new DOMException();
|
|
158
129
|
return true;
|
|
159
130
|
} catch (e) {
|
|
160
131
|
return false;
|
|
161
132
|
}
|
|
162
|
-
}
|
|
133
|
+
}
|
|
134
|
+
function getDOMExceptionClass() {
|
|
135
|
+
return isDOMExceptionSupported() ? DOMException : DOMExceptionP;
|
|
136
|
+
}
|
|
137
|
+
var DOMExceptionE = /*#__PURE__*/getDOMExceptionClass();
|
|
163
138
|
function className(object) {
|
|
164
139
|
try {
|
|
165
140
|
return object.__MPHTTPX__.chain[0];
|
|
@@ -172,8 +147,8 @@ function setState(target, name, value) {
|
|
|
172
147
|
value: value
|
|
173
148
|
});
|
|
174
149
|
}
|
|
175
|
-
// Safe wrapper around String()
|
|
176
|
-
function
|
|
150
|
+
// Safe wrapper around String() — catches errors and returns "[object Unknown]" as fallback.
|
|
151
|
+
function safeString(value) {
|
|
177
152
|
try {
|
|
178
153
|
return String(value);
|
|
179
154
|
} catch (e) {
|
|
@@ -190,7 +165,9 @@ function isPolyfillType(name, value) {
|
|
|
190
165
|
return strict ? index === 0 : index > -1;
|
|
191
166
|
}(value[field].chain.indexOf(name));
|
|
192
167
|
}
|
|
193
|
-
var iteratorSupported =
|
|
168
|
+
var iteratorSupported = /*#__PURE__*/function () {
|
|
169
|
+
return typeof Symbol === "function" && !!Symbol.iterator;
|
|
170
|
+
}();
|
|
194
171
|
function isSequence(value) {
|
|
195
172
|
return Array.isArray(value) || !!value && _typeof(value) === "object" && iteratorSupported && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
196
173
|
}
|
|
@@ -362,11 +339,14 @@ function encodeText(input, destination) {
|
|
|
362
339
|
}
|
|
363
340
|
return {
|
|
364
341
|
encoded: !HAS_DESTINATION ? target.slice(0, at) : destination,
|
|
342
|
+
// × WeChat 2.5.0
|
|
365
343
|
read: read,
|
|
366
344
|
written: at
|
|
367
345
|
};
|
|
368
346
|
}
|
|
369
|
-
var TextEncoderE =
|
|
347
|
+
var TextEncoderE = /*#__PURE__*/function () {
|
|
348
|
+
return typeof TextEncoder !== "undefined" && TextEncoder || TextEncoderP;
|
|
349
|
+
}();
|
|
370
350
|
|
|
371
351
|
var validLabels = ["utf-8", "utf8", "unicode-1-1-utf-8"];
|
|
372
352
|
var TextDecoderP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
@@ -454,7 +434,7 @@ function decodeText(input) {
|
|
|
454
434
|
}
|
|
455
435
|
return "";
|
|
456
436
|
}
|
|
457
|
-
var bytes = isArrayBuffer(input) ? new Uint8Array(input) :
|
|
437
|
+
var bytes = isArrayBuffer(input) ? new Uint8Array(input) : ArrayBuffer_isView(input) ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength) : function () {
|
|
458
438
|
throw new TypeError("Input could not be converted to any of: ArrayBufferView, ArrayBuffer.");
|
|
459
439
|
}();
|
|
460
440
|
if (settings.partial.length > 0) {
|
|
@@ -578,12 +558,21 @@ function concatString(val) {
|
|
|
578
558
|
}
|
|
579
559
|
// Mini Program
|
|
580
560
|
function isOtherArrayBuffer(value) {
|
|
581
|
-
return !!value && _typeof(value) === "object" && "byteLength" in value && typeof value.byteLength === "number" && (isObjectType("ArrayBuffer", value) ||
|
|
561
|
+
return !!value && _typeof(value) === "object" && "byteLength" in value && typeof value.byteLength === "number" && (isObjectType("ArrayBuffer", value) || safeString(value) === "[object ArrayBuffer]");
|
|
582
562
|
}
|
|
583
563
|
function isArrayBuffer(value) {
|
|
584
564
|
return !!value && _typeof(value) === "object" && ArrayBuffer.prototype.isPrototypeOf(value) || isOtherArrayBuffer(value);
|
|
585
565
|
}
|
|
586
|
-
|
|
566
|
+
function isArrayBufferView(value) {
|
|
567
|
+
var typedArrayTags = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"];
|
|
568
|
+
return !!value && _typeof(value) === "object" && (typedArrayTags.indexOf(Object.prototype.toString.call(value)) > -1 || typeof DataView !== "undefined" && DataView.prototype.isPrototypeOf(value));
|
|
569
|
+
}
|
|
570
|
+
function ArrayBuffer_isView(value) {
|
|
571
|
+
return ArrayBuffer.isView ? ArrayBuffer.isView(value) : isArrayBufferView(value);
|
|
572
|
+
}
|
|
573
|
+
var TextDecoderE = /*#__PURE__*/function () {
|
|
574
|
+
return typeof TextDecoder !== "undefined" && TextDecoder || TextDecoderP;
|
|
575
|
+
}();
|
|
587
576
|
|
|
588
577
|
var EventP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
589
578
|
function EventP(type, eventInitDict) {
|
|
@@ -794,7 +783,9 @@ var EventState = /*#__PURE__*/_createClass(function EventState() {
|
|
|
794
783
|
function state$j(target) {
|
|
795
784
|
return target.__Event__;
|
|
796
785
|
}
|
|
797
|
-
var timeStamp =
|
|
786
|
+
var timeStamp = /*#__PURE__*/function () {
|
|
787
|
+
return new Date().getTime();
|
|
788
|
+
}();
|
|
798
789
|
function getFuncName(func) {
|
|
799
790
|
// ES5
|
|
800
791
|
return "name" in func ? func.name : "unknown";
|
|
@@ -820,7 +811,9 @@ function Event_setTrusted(event, isTrusted) {
|
|
|
820
811
|
var s = state$j(event) || {};
|
|
821
812
|
s.isTrusted = "".concat(getFuncName(createTrustedPropertyDescriptor), ":").concat(isTrusted ? "YES" : "NO");
|
|
822
813
|
}
|
|
823
|
-
var EventE =
|
|
814
|
+
var EventE = /*#__PURE__*/function () {
|
|
815
|
+
return typeof Event !== "undefined" && Event || EventP;
|
|
816
|
+
}();
|
|
824
817
|
|
|
825
818
|
var EventTargetP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
826
819
|
function EventTargetP() {
|
|
@@ -929,7 +922,7 @@ function isEvent(value) {
|
|
|
929
922
|
var predicate = function predicate(str) {
|
|
930
923
|
return "[object " === str.slice(0, 8) && str.slice(-6) === "Event]";
|
|
931
924
|
};
|
|
932
|
-
return !!value && _typeof(value) === "object" && "type" in value && typeof value.type === "string" && (predicate(Object.prototype.toString.call(value)) || predicate(
|
|
925
|
+
return !!value && _typeof(value) === "object" && "type" in value && typeof value.type === "string" && (predicate(Object.prototype.toString.call(value)) || predicate(safeString(value)));
|
|
933
926
|
}
|
|
934
927
|
function whenAbort(target, executor, signal) {
|
|
935
928
|
var _onAbort = function onAbort() {
|
|
@@ -1014,7 +1007,9 @@ function isEventTarget(value) {
|
|
|
1014
1007
|
function isExternalEventTarget(value) {
|
|
1015
1008
|
return !!value && _typeof(value) === "object" && "addEventListener" in value && typeof value.addEventListener === "function" && "removeEventListener" in value && typeof value.removeEventListener === "function";
|
|
1016
1009
|
}
|
|
1017
|
-
var EventTargetE =
|
|
1010
|
+
var EventTargetE = /*#__PURE__*/function () {
|
|
1011
|
+
return typeof EventTarget !== "undefined" && EventTarget || EventTargetP;
|
|
1012
|
+
}();
|
|
1018
1013
|
|
|
1019
1014
|
var CustomEventP = /*#__PURE__*/function (_EventP, _Symbol$toStringTag) {
|
|
1020
1015
|
function CustomEventP(type, eventInitDict) {
|
|
@@ -1070,7 +1065,9 @@ var CustomEventState = /*#__PURE__*/_createClass(function CustomEventState() {
|
|
|
1070
1065
|
function state$h(target) {
|
|
1071
1066
|
return target.__CustomEvent__;
|
|
1072
1067
|
}
|
|
1073
|
-
var CustomEventE =
|
|
1068
|
+
var CustomEventE = /*#__PURE__*/function () {
|
|
1069
|
+
return typeof CustomEvent !== "undefined" && CustomEvent || CustomEventP;
|
|
1070
|
+
}();
|
|
1074
1071
|
|
|
1075
1072
|
var AbortSignalP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
1076
1073
|
/** @internal */
|
|
@@ -1233,7 +1230,9 @@ function AbortSignal_abort(signal) {
|
|
|
1233
1230
|
}
|
|
1234
1231
|
}
|
|
1235
1232
|
}
|
|
1236
|
-
var AbortSignalE =
|
|
1233
|
+
var AbortSignalE = /*#__PURE__*/function () {
|
|
1234
|
+
return typeof AbortSignal !== "undefined" && AbortSignal || AbortSignalP;
|
|
1235
|
+
}();
|
|
1237
1236
|
|
|
1238
1237
|
var AbortControllerP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
1239
1238
|
function AbortControllerP() {
|
|
@@ -1280,12 +1279,20 @@ var AbortControllerState = /*#__PURE__*/_createClass(function AbortControllerSta
|
|
|
1280
1279
|
function state$f(target) {
|
|
1281
1280
|
return target.__AbortController__;
|
|
1282
1281
|
}
|
|
1283
|
-
var AbortControllerE =
|
|
1282
|
+
var AbortControllerE = /*#__PURE__*/function () {
|
|
1283
|
+
return typeof AbortController !== "undefined" && AbortController || AbortControllerP;
|
|
1284
|
+
}();
|
|
1284
1285
|
|
|
1285
|
-
var encode$1 =
|
|
1286
|
-
|
|
1286
|
+
var encode$1 = /*#__PURE__*/function () {
|
|
1287
|
+
return TextEncoderE.prototype.encode.bind(new TextEncoderE());
|
|
1288
|
+
}();
|
|
1289
|
+
var decode$1 = /*#__PURE__*/function () {
|
|
1290
|
+
return TextDecoderE.prototype.decode.bind(new TextDecoderE());
|
|
1291
|
+
}();
|
|
1287
1292
|
var mp$3 = {
|
|
1288
|
-
ReadableStream:
|
|
1293
|
+
ReadableStream: /*#__PURE__*/function () {
|
|
1294
|
+
return typeof ReadableStream !== "undefined" && ReadableStream || undefined;
|
|
1295
|
+
}()
|
|
1289
1296
|
};
|
|
1290
1297
|
function setReadableStreamClass(RSClass) {
|
|
1291
1298
|
mp$3.ReadableStream = RSClass;
|
|
@@ -1309,7 +1316,7 @@ var BlobP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
|
1309
1316
|
return new Uint8Array(r);
|
|
1310
1317
|
}));
|
|
1311
1318
|
} else {
|
|
1312
|
-
var bytes = isArrayBuffer(chunk) ||
|
|
1319
|
+
var bytes = isArrayBuffer(chunk) || ArrayBuffer_isView(chunk) ? BufferSource_toUint8Array(chunk) : encode$1(chunk);
|
|
1313
1320
|
size += bytes.length;
|
|
1314
1321
|
tasks.push(Promise.resolve(bytes));
|
|
1315
1322
|
}
|
|
@@ -1352,7 +1359,7 @@ var BlobP = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
|
1352
1359
|
var blob = Object.create(BlobP.prototype);
|
|
1353
1360
|
setState(blob, "__Blob__", new BlobState(state$e(this).promise.then(function (r) {
|
|
1354
1361
|
return clone(r.slice(_start, _end));
|
|
1355
|
-
})));
|
|
1362
|
+
}))); // × WeChat 2.5.0
|
|
1356
1363
|
state$e(blob).size = calcSlicedSize(this.size, _start, _end);
|
|
1357
1364
|
state$e(blob).type = normalizeType(contentType);
|
|
1358
1365
|
return blob;
|
|
@@ -1481,15 +1488,19 @@ function isExternalBlob(value) {
|
|
|
1481
1488
|
var strict = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1482
1489
|
var expects = ["[object Blob]"];
|
|
1483
1490
|
if (!strict) expects.push("[object File]");
|
|
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(
|
|
1491
|
+
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(safeString(value)) > -1);
|
|
1485
1492
|
}
|
|
1486
|
-
|
|
1493
|
+
function isBlobSupported() {
|
|
1487
1494
|
try {
|
|
1488
|
-
return new Blob([
|
|
1495
|
+
return new Blob(["ä"]).size === 2;
|
|
1489
1496
|
} catch (e) {
|
|
1490
1497
|
return false;
|
|
1491
1498
|
}
|
|
1492
|
-
}
|
|
1499
|
+
}
|
|
1500
|
+
function getBlobClass() {
|
|
1501
|
+
return isBlobSupported() ? Blob : BlobP;
|
|
1502
|
+
}
|
|
1503
|
+
var BlobE = /*#__PURE__*/getBlobClass();
|
|
1493
1504
|
|
|
1494
1505
|
function createFileClass(BlobClass) {
|
|
1495
1506
|
var FileClass = /*#__PURE__*/function (_BlobClass, _Symbol$toStringTag) {
|
|
@@ -1554,15 +1565,19 @@ var FileState = /*#__PURE__*/_createClass(function FileState() {
|
|
|
1554
1565
|
function state$d(target) {
|
|
1555
1566
|
return target.__File__;
|
|
1556
1567
|
}
|
|
1557
|
-
var FilePolyfill = createFileClass(BlobP);
|
|
1558
|
-
|
|
1568
|
+
var FilePolyfill = /*#__PURE__*/createFileClass(BlobP);
|
|
1569
|
+
function isFileSupported() {
|
|
1559
1570
|
try {
|
|
1560
1571
|
new File([], "");
|
|
1561
1572
|
return true;
|
|
1562
1573
|
} catch (e) {
|
|
1563
1574
|
return false;
|
|
1564
1575
|
}
|
|
1565
|
-
}
|
|
1576
|
+
}
|
|
1577
|
+
function getFileClass() {
|
|
1578
|
+
return isFileSupported() ? File : BlobE === BlobP ? FilePolyfill : createFileClass(BlobE);
|
|
1579
|
+
}
|
|
1580
|
+
var FileE = /*#__PURE__*/getFileClass();
|
|
1566
1581
|
|
|
1567
1582
|
var fields = ["loaded", "total"];
|
|
1568
1583
|
var ProgressEventP = /*#__PURE__*/function (_EventP, _Symbol$toStringTag) {
|
|
@@ -1839,7 +1854,7 @@ var FileReaderP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
|
1839
1854
|
/** @internal */
|
|
1840
1855
|
var FileReaderState = /*#__PURE__*/_createClass(function FileReaderState(target) {
|
|
1841
1856
|
_classCallCheck(this, FileReaderState);
|
|
1842
|
-
this.pos = 0 /* FRCycle.EMPTY */;
|
|
1857
|
+
/** @internal */this.pos = 0 /* FRCycle.EMPTY */;
|
|
1843
1858
|
this.readyState = 0 /* EMPTY */;
|
|
1844
1859
|
this.result = null;
|
|
1845
1860
|
this.error = null;
|
|
@@ -1968,7 +1983,9 @@ function Uint8Array_toBase64(input) {
|
|
|
1968
1983
|
}
|
|
1969
1984
|
return output.join("");
|
|
1970
1985
|
}
|
|
1971
|
-
var FileReaderE =
|
|
1986
|
+
var FileReaderE = /*#__PURE__*/function () {
|
|
1987
|
+
return typeof FileReader !== "undefined" && FileReader || FileReaderP;
|
|
1988
|
+
}();
|
|
1972
1989
|
|
|
1973
1990
|
var URLSearchParamsP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
1974
1991
|
function URLSearchParamsP(init) {
|
|
@@ -2240,9 +2257,11 @@ function isURLSearchParams(value) {
|
|
|
2240
2257
|
return isPolyfillType("URLSearchParams", value) || isExternalURLSearchParams(value);
|
|
2241
2258
|
}
|
|
2242
2259
|
function isExternalURLSearchParams(value) {
|
|
2243
|
-
return isObjectType("URLSearchParams", value) || !!value && _typeof(value) === "object" && typeof URLSearchParams === "function" && value instanceof URLSearchParams;
|
|
2260
|
+
return isObjectType("URLSearchParams", value) || !!value && _typeof(value) === "object" && "size" in value && typeof value.size === "number" && "forEach" in value && typeof value.forEach === "function" && typeof URLSearchParams === "function" && value instanceof URLSearchParams;
|
|
2244
2261
|
}
|
|
2245
|
-
var URLSearchParamsE =
|
|
2262
|
+
var URLSearchParamsE = /*#__PURE__*/function () {
|
|
2263
|
+
return typeof URLSearchParams !== "undefined" && URLSearchParams || URLSearchParamsP;
|
|
2264
|
+
}();
|
|
2246
2265
|
|
|
2247
2266
|
var FormDataP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
2248
2267
|
function FormDataP(form, submitter) {
|
|
@@ -2491,7 +2510,7 @@ function isFormData(value) {
|
|
|
2491
2510
|
}
|
|
2492
2511
|
function isExternalFormData(value) {
|
|
2493
2512
|
var expect = "[object FormData]";
|
|
2494
|
-
return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect ||
|
|
2513
|
+
return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect || safeString(value) === expect);
|
|
2495
2514
|
}
|
|
2496
2515
|
function FormData_toBlob(formData, externalBoundary) {
|
|
2497
2516
|
var boundary = externalBoundary || "----formdata-mphttpx-" + Math.random();
|
|
@@ -2600,12 +2619,14 @@ function createFormDataFromBinaryText(text, boundary) {
|
|
|
2600
2619
|
});
|
|
2601
2620
|
return formData;
|
|
2602
2621
|
}
|
|
2603
|
-
var FormDataE =
|
|
2622
|
+
var FormDataE = /*#__PURE__*/function () {
|
|
2623
|
+
return typeof FormData !== "undefined" && FormData || FormDataP;
|
|
2624
|
+
}();
|
|
2604
2625
|
|
|
2605
2626
|
var Payload = /*#__PURE__*/function () {
|
|
2606
2627
|
function Payload(body, contentType) {
|
|
2607
2628
|
_classCallCheck(this, Payload);
|
|
2608
|
-
this._type = "";
|
|
2629
|
+
/** @internal */this._type = "";
|
|
2609
2630
|
if (contentType) {
|
|
2610
2631
|
this.type = contentType;
|
|
2611
2632
|
}
|
|
@@ -2625,7 +2646,7 @@ var Payload = /*#__PURE__*/function () {
|
|
|
2625
2646
|
} else if (isArrayBuffer(body)) {
|
|
2626
2647
|
this.promise = Promise.resolve(body.slice(0));
|
|
2627
2648
|
this.length = body.byteLength;
|
|
2628
|
-
} else if (
|
|
2649
|
+
} else if (ArrayBuffer_isView(body)) {
|
|
2629
2650
|
var _body2 = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
|
|
2630
2651
|
this.promise = Promise.resolve(_body2);
|
|
2631
2652
|
this.length = _body2.byteLength;
|
|
@@ -2768,7 +2789,7 @@ function state$8(target) {
|
|
|
2768
2789
|
}
|
|
2769
2790
|
function initBody(instance, body) {
|
|
2770
2791
|
var b = instance;
|
|
2771
|
-
if (
|
|
2792
|
+
if (isExternalReadableStream(body)) {
|
|
2772
2793
|
throw new TypeError("Failed to construct '".concat(className(b), "': ReadableStream not implemented."));
|
|
2773
2794
|
}
|
|
2774
2795
|
if (body !== null && body !== undefined) {
|
|
@@ -2809,12 +2830,9 @@ function consumed(body, kind) {
|
|
|
2809
2830
|
}
|
|
2810
2831
|
return Promise.reject(new TypeError("Failed to execute '".concat(kind, "' on '").concat(className(body), "': body stream already read")));
|
|
2811
2832
|
}
|
|
2812
|
-
function isReadableStream(value) {
|
|
2813
|
-
return isExternalReadableStream(value);
|
|
2814
|
-
}
|
|
2815
2833
|
function isExternalReadableStream(value) {
|
|
2816
2834
|
var expect = "[object ReadableStream]";
|
|
2817
|
-
return !!value && _typeof(value) === "object" && "getReader" in value && typeof value.getReader === "function" && (Object.prototype.toString.call(value) === expect ||
|
|
2835
|
+
return !!value && _typeof(value) === "object" && "getReader" in value && typeof value.getReader === "function" && (Object.prototype.toString.call(value) === expect || safeString(value) === expect);
|
|
2818
2836
|
}
|
|
2819
2837
|
|
|
2820
2838
|
var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
@@ -2893,9 +2911,7 @@ var HeadersP = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
|
|
|
2893
2911
|
key: "forEach",
|
|
2894
2912
|
value: function forEach(callbackfn, thisArg) {
|
|
2895
2913
|
checkArgsFn(arguments.length, 1, "forEach");
|
|
2896
|
-
if (typeof callbackfn !== "function")
|
|
2897
|
-
throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
|
|
2898
|
-
}
|
|
2914
|
+
if (typeof callbackfn !== "function") throw new TypeError("Failed to execute 'forEach' on 'Headers': parameter 1 is not of type 'Function'.");
|
|
2899
2915
|
var dict = state$7(this).dict;
|
|
2900
2916
|
var names = Object.getOwnPropertyNames(dict);
|
|
2901
2917
|
for (var i = 0; i < names.length; ++i) {
|
|
@@ -2992,7 +3008,7 @@ function isHeaders(value) {
|
|
|
2992
3008
|
}
|
|
2993
3009
|
function isExternalHeaders(value) {
|
|
2994
3010
|
var expect = "[object Headers]";
|
|
2995
|
-
return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect ||
|
|
3011
|
+
return !!value && _typeof(value) === "object" && "forEach" in value && typeof value.forEach === "function" && (Object.prototype.toString.call(value) === expect || safeString(value) === expect);
|
|
2996
3012
|
}
|
|
2997
3013
|
function normalizeName(name, throwError) {
|
|
2998
3014
|
if (typeof name !== "string") {
|
|
@@ -3037,7 +3053,9 @@ function createHeaders(headers) {
|
|
|
3037
3053
|
}
|
|
3038
3054
|
return new HeadersE(headers);
|
|
3039
3055
|
}
|
|
3040
|
-
var HeadersE =
|
|
3056
|
+
var HeadersE = /*#__PURE__*/function () {
|
|
3057
|
+
return typeof Headers !== "undefined" && Headers || HeadersP;
|
|
3058
|
+
}();
|
|
3041
3059
|
|
|
3042
3060
|
var RequestP = /*#__PURE__*/function (_BodyImpl, _Symbol$toStringTag) {
|
|
3043
3061
|
function RequestP(input, init) {
|
|
@@ -3231,7 +3249,7 @@ function isRequest(value) {
|
|
|
3231
3249
|
}
|
|
3232
3250
|
function isExternalRequest(value) {
|
|
3233
3251
|
var expect = "[object Request]";
|
|
3234
|
-
return !!value && _typeof(value) === "object" && "arrayBuffer" in value && typeof value.arrayBuffer === "function" && (Object.prototype.toString.call(value) === expect ||
|
|
3252
|
+
return !!value && _typeof(value) === "object" && "arrayBuffer" in value && typeof value.arrayBuffer === "function" && (Object.prototype.toString.call(value) === expect || safeString(value) === expect);
|
|
3235
3253
|
}
|
|
3236
3254
|
function createPhonyPayload(request) {
|
|
3237
3255
|
var payload = Object.create(Payload.prototype);
|
|
@@ -3276,7 +3294,9 @@ function normalizeMethod(method) {
|
|
|
3276
3294
|
var upcased = method.toUpperCase();
|
|
3277
3295
|
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
3278
3296
|
}
|
|
3279
|
-
var RequestE =
|
|
3297
|
+
var RequestE = /*#__PURE__*/function () {
|
|
3298
|
+
return typeof Request !== "undefined" && Request || RequestP;
|
|
3299
|
+
}();
|
|
3280
3300
|
|
|
3281
3301
|
var ResponseP = /*#__PURE__*/function (_BodyImpl, _Symbol$toStringTag) {
|
|
3282
3302
|
function ResponseP(body, init) {
|
|
@@ -3424,19 +3444,29 @@ var ResponseState = /*#__PURE__*/_createClass(function ResponseState() {
|
|
|
3424
3444
|
function state$5(target) {
|
|
3425
3445
|
return target.__Response__;
|
|
3426
3446
|
}
|
|
3427
|
-
var ResponseE =
|
|
3447
|
+
var ResponseE = /*#__PURE__*/function () {
|
|
3448
|
+
return typeof Response !== "undefined" && Response || ResponseP;
|
|
3449
|
+
}();
|
|
3428
3450
|
|
|
3429
3451
|
var mp$2 = {
|
|
3430
|
-
XMLHttpRequest:
|
|
3452
|
+
XMLHttpRequest: /*#__PURE__*/function () {
|
|
3453
|
+
return typeof XMLHttpRequest !== "undefined" && XMLHttpRequest || undefined;
|
|
3454
|
+
}()
|
|
3431
3455
|
};
|
|
3432
3456
|
function setXMLHttpRequestClass(XHRClass) {
|
|
3433
3457
|
mp$2.XMLHttpRequest = XHRClass;
|
|
3434
3458
|
}
|
|
3459
|
+
var textMode = {
|
|
3460
|
+
value: false
|
|
3461
|
+
};
|
|
3462
|
+
function setTextMode(value) {
|
|
3463
|
+
textMode.value = !!value;
|
|
3464
|
+
}
|
|
3435
3465
|
function fetchP(input, init) {
|
|
3436
|
-
checkArgsLength(arguments.length, 1, "Window", "fetch"); // @ts-expect-error
|
|
3437
3466
|
if (this instanceof fetchP) {
|
|
3438
3467
|
throw new TypeError("fetch is not a constructor");
|
|
3439
3468
|
}
|
|
3469
|
+
checkArgsLength(arguments.length, 1, "globalThis", "fetch");
|
|
3440
3470
|
return new Promise(function (resolve, reject) {
|
|
3441
3471
|
var request = new RequestP(input, init);
|
|
3442
3472
|
var signal = request.__Request__.signal;
|
|
@@ -3487,7 +3517,7 @@ function fetchP(input, init) {
|
|
|
3487
3517
|
reject(new DOMExceptionE("The request timed out.", "TimeoutError"));
|
|
3488
3518
|
}, 0);
|
|
3489
3519
|
};
|
|
3490
|
-
xhr.open(request.method, fixUrl
|
|
3520
|
+
xhr.open(request.method, fixUrl(request.url), true);
|
|
3491
3521
|
if (request.credentials === "include") {
|
|
3492
3522
|
xhr.withCredentials = true;
|
|
3493
3523
|
} else if (request.credentials === "omit") {
|
|
@@ -3532,7 +3562,7 @@ function fetchP(input, init) {
|
|
|
3532
3562
|
};
|
|
3533
3563
|
}
|
|
3534
3564
|
if (!payload) xhr.send();else payload.promise.then(function (body) {
|
|
3535
|
-
if (!aborted) xhr.send(body !== "" ? body : undefined);else reject(createAbortException());
|
|
3565
|
+
if (!aborted) xhr.send(body !== "" ? coerceBody(body) : undefined);else reject(createAbortException());
|
|
3536
3566
|
}).catch(function (e) {
|
|
3537
3567
|
reject(new TypeError("Failed to fetch"));
|
|
3538
3568
|
console.error(e);
|
|
@@ -3542,15 +3572,22 @@ function fetchP(input, init) {
|
|
|
3542
3572
|
function createAbortException() {
|
|
3543
3573
|
return new DOMExceptionE("The user aborted a request.", "AbortError");
|
|
3544
3574
|
}
|
|
3545
|
-
var locationSupported =
|
|
3546
|
-
|
|
3575
|
+
var locationSupported = /*#__PURE__*/function () {
|
|
3576
|
+
return typeof location !== "undefined" && !!location;
|
|
3577
|
+
}();
|
|
3578
|
+
function fixUrl(url) {
|
|
3547
3579
|
if (url === "" && locationSupported && (location === null || location === void 0 ? void 0 : location.href)) {
|
|
3548
3580
|
return location.href;
|
|
3549
3581
|
} else {
|
|
3550
3582
|
return url;
|
|
3551
3583
|
}
|
|
3552
|
-
}
|
|
3553
|
-
|
|
3584
|
+
}
|
|
3585
|
+
function coerceBody(data) {
|
|
3586
|
+
return textMode.value && typeof data !== "string" ? decode$1(data) : data;
|
|
3587
|
+
}
|
|
3588
|
+
var fetchE$1 = /*#__PURE__*/function () {
|
|
3589
|
+
return typeof fetch !== "undefined" && fetch || fetchP;
|
|
3590
|
+
}();
|
|
3554
3591
|
|
|
3555
3592
|
var fullOverride = {
|
|
3556
3593
|
value: false
|
|
@@ -3610,10 +3647,16 @@ function fixFetch(fetchFunc) {
|
|
|
3610
3647
|
};
|
|
3611
3648
|
}
|
|
3612
3649
|
}
|
|
3650
|
+
function getSignal(val) {
|
|
3651
|
+
return !!val && _typeof(val) === "object" && "signal" in val && isEventTarget(val.signal) && val.signal;
|
|
3652
|
+
}
|
|
3613
3653
|
function _fetch(input, init) {
|
|
3614
3654
|
if (isPolyfillType("Request", input)) {
|
|
3615
3655
|
var _input = input;
|
|
3616
|
-
var _init = init
|
|
3656
|
+
var _init = init !== null && init !== void 0 ? init : {};
|
|
3657
|
+
if (_typeof(_init) !== "object") {
|
|
3658
|
+
_init = {};
|
|
3659
|
+
}
|
|
3617
3660
|
if (!_init.method) {
|
|
3618
3661
|
_init.method = _input.method;
|
|
3619
3662
|
}
|
|
@@ -3665,10 +3708,11 @@ function fixFetch(fetchFunc) {
|
|
|
3665
3708
|
if (payload.type) {
|
|
3666
3709
|
setContentType(init, payload.type);
|
|
3667
3710
|
}
|
|
3711
|
+
var signal = getSignal(init) || getSignal(input);
|
|
3668
3712
|
var removeFn = null;
|
|
3669
3713
|
var aborted = false;
|
|
3670
3714
|
var processing = true;
|
|
3671
|
-
if (
|
|
3715
|
+
if (signal) {
|
|
3672
3716
|
var abortFn = function abortFn() {
|
|
3673
3717
|
if (processing) {
|
|
3674
3718
|
aborted = true;
|
|
@@ -3676,12 +3720,12 @@ function fixFetch(fetchFunc) {
|
|
|
3676
3720
|
removeFn();
|
|
3677
3721
|
};
|
|
3678
3722
|
removeFn = function removeFn() {
|
|
3679
|
-
|
|
3723
|
+
signal.removeEventListener("abort", abortFn);
|
|
3680
3724
|
};
|
|
3681
|
-
|
|
3725
|
+
signal.addEventListener("abort", abortFn);
|
|
3682
3726
|
}
|
|
3683
3727
|
payload.promise.then(function (r) {
|
|
3684
|
-
init.body = r !== "" ? r : null;
|
|
3728
|
+
init.body = r !== "" ? coerceBody(r) : null;
|
|
3685
3729
|
if (!aborted) {
|
|
3686
3730
|
resolve(fetchFn.call(this, input, init));
|
|
3687
3731
|
} else {
|
|
@@ -3698,8 +3742,9 @@ function fixFetch(fetchFunc) {
|
|
|
3698
3742
|
}
|
|
3699
3743
|
}); // finally
|
|
3700
3744
|
} else {
|
|
3701
|
-
if (init && init.body && isPolyfillType("URLSearchParams", init.body)) {
|
|
3745
|
+
if (init && init.body && (fullOverride.value ? isURLSearchParams(init.body) : isPolyfillType("URLSearchParams", init.body))) {
|
|
3702
3746
|
setContentType(init, "application/x-www-form-urlencoded;charset=UTF-8");
|
|
3747
|
+
init.body = init.body.toString();
|
|
3703
3748
|
}
|
|
3704
3749
|
resolve(fetchFn.call(this, input, init));
|
|
3705
3750
|
}
|
|
@@ -3752,7 +3797,7 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
3752
3797
|
this.withCredentials = withCredentials;
|
|
3753
3798
|
console.warn("Illegal to set the 'withCredentials' property on 'XMLHttpRequest': The value may only be set if the object's state is UNSENT or OPENED.");
|
|
3754
3799
|
}
|
|
3755
|
-
_send.call(this, r !== "" ? r : undefined);
|
|
3800
|
+
_send.call(this, r !== "" ? coerceBody(r) : undefined);
|
|
3756
3801
|
}
|
|
3757
3802
|
state(this).aborted = false;
|
|
3758
3803
|
state(this).processing = false;
|
|
@@ -3762,7 +3807,12 @@ function fixXMLHttpRequest(XHRClass) {
|
|
|
3762
3807
|
console.error(e);
|
|
3763
3808
|
}.bind(this));
|
|
3764
3809
|
} else {
|
|
3765
|
-
if (isPolyfillType("URLSearchParams", body)
|
|
3810
|
+
if (fullOverride.value ? isURLSearchParams(body) : isPolyfillType("URLSearchParams", body)) {
|
|
3811
|
+
if (!state(this).hasContentType) {
|
|
3812
|
+
this.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
|
3813
|
+
}
|
|
3814
|
+
body = body.toString();
|
|
3815
|
+
}
|
|
3766
3816
|
_send.call(this, body);
|
|
3767
3817
|
}
|
|
3768
3818
|
};
|
|
@@ -3796,8 +3846,9 @@ function fixWebSocket(WSClass) {
|
|
|
3796
3846
|
var _send = Klass.prototype.send;
|
|
3797
3847
|
Klass.prototype.send = function (data) {
|
|
3798
3848
|
if (fullOverride.value ? isBlob(data) : isPolyfillType("Blob", data)) {
|
|
3799
|
-
|
|
3800
|
-
|
|
3849
|
+
if (this.readyState === 0 /* CONNECTING */) throw new DOMExceptionE("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
|
|
3850
|
+
if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) return console.error("WebSocket is already in CLOSING or CLOSED state.");
|
|
3851
|
+
data.arrayBuffer().then(function (r) {
|
|
3801
3852
|
if (this.readyState !== 1 /* OPEN */) return;
|
|
3802
3853
|
_send.call(this, r);
|
|
3803
3854
|
}.bind(this));
|
|
@@ -3809,831 +3860,6 @@ function fixWebSocket(WSClass) {
|
|
|
3809
3860
|
Klass["__MPHTTPX__Polyfill__"] = true;
|
|
3810
3861
|
}
|
|
3811
3862
|
|
|
3812
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3813
|
-
|
|
3814
|
-
function getDefaultExportFromCjs (x) {
|
|
3815
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3816
|
-
}
|
|
3817
|
-
|
|
3818
|
-
var requiresPort;
|
|
3819
|
-
var hasRequiredRequiresPort;
|
|
3820
|
-
function requireRequiresPort() {
|
|
3821
|
-
if (hasRequiredRequiresPort) return requiresPort;
|
|
3822
|
-
hasRequiredRequiresPort = 1;
|
|
3823
|
-
|
|
3824
|
-
/**
|
|
3825
|
-
* Check if we're required to add a port number.
|
|
3826
|
-
*
|
|
3827
|
-
* @see https://url.spec.whatwg.org/#default-port
|
|
3828
|
-
* @param {Number|String} port Port number we need to check
|
|
3829
|
-
* @param {String} protocol Protocol we need to check against.
|
|
3830
|
-
* @returns {Boolean} Is it a default port for the given protocol
|
|
3831
|
-
* @api private
|
|
3832
|
-
*/
|
|
3833
|
-
requiresPort = function required(port, protocol) {
|
|
3834
|
-
protocol = protocol.split(':')[0];
|
|
3835
|
-
port = +port;
|
|
3836
|
-
if (!port) return false;
|
|
3837
|
-
switch (protocol) {
|
|
3838
|
-
case 'http':
|
|
3839
|
-
case 'ws':
|
|
3840
|
-
return port !== 80;
|
|
3841
|
-
case 'https':
|
|
3842
|
-
case 'wss':
|
|
3843
|
-
return port !== 443;
|
|
3844
|
-
case 'ftp':
|
|
3845
|
-
return port !== 21;
|
|
3846
|
-
case 'gopher':
|
|
3847
|
-
return port !== 70;
|
|
3848
|
-
case 'file':
|
|
3849
|
-
return false;
|
|
3850
|
-
}
|
|
3851
|
-
return port !== 0;
|
|
3852
|
-
};
|
|
3853
|
-
return requiresPort;
|
|
3854
|
-
}
|
|
3855
|
-
|
|
3856
|
-
var querystringify = {};
|
|
3857
|
-
|
|
3858
|
-
var hasRequiredQuerystringify;
|
|
3859
|
-
function requireQuerystringify() {
|
|
3860
|
-
if (hasRequiredQuerystringify) return querystringify;
|
|
3861
|
-
hasRequiredQuerystringify = 1;
|
|
3862
|
-
var has = Object.prototype.hasOwnProperty,
|
|
3863
|
-
undef;
|
|
3864
|
-
|
|
3865
|
-
/**
|
|
3866
|
-
* Decode a URI encoded string.
|
|
3867
|
-
*
|
|
3868
|
-
* @param {String} input The URI encoded string.
|
|
3869
|
-
* @returns {String|Null} The decoded string.
|
|
3870
|
-
* @api private
|
|
3871
|
-
*/
|
|
3872
|
-
function decode(input) {
|
|
3873
|
-
try {
|
|
3874
|
-
return decodeURIComponent(input.replace(/\+/g, ' '));
|
|
3875
|
-
} catch (e) {
|
|
3876
|
-
return null;
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
|
|
3880
|
-
/**
|
|
3881
|
-
* Attempts to encode a given input.
|
|
3882
|
-
*
|
|
3883
|
-
* @param {String} input The string that needs to be encoded.
|
|
3884
|
-
* @returns {String|Null} The encoded string.
|
|
3885
|
-
* @api private
|
|
3886
|
-
*/
|
|
3887
|
-
function encode(input) {
|
|
3888
|
-
try {
|
|
3889
|
-
return encodeURIComponent(input);
|
|
3890
|
-
} catch (e) {
|
|
3891
|
-
return null;
|
|
3892
|
-
}
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
|
-
/**
|
|
3896
|
-
* Simple query string parser.
|
|
3897
|
-
*
|
|
3898
|
-
* @param {String} query The query string that needs to be parsed.
|
|
3899
|
-
* @returns {Object}
|
|
3900
|
-
* @api public
|
|
3901
|
-
*/
|
|
3902
|
-
function querystring(query) {
|
|
3903
|
-
var parser = /([^=?#&]+)=?([^&]*)/g,
|
|
3904
|
-
result = {},
|
|
3905
|
-
part;
|
|
3906
|
-
while (part = parser.exec(query)) {
|
|
3907
|
-
var key = decode(part[1]),
|
|
3908
|
-
value = decode(part[2]);
|
|
3909
|
-
|
|
3910
|
-
//
|
|
3911
|
-
// Prevent overriding of existing properties. This ensures that build-in
|
|
3912
|
-
// methods like `toString` or __proto__ are not overriden by malicious
|
|
3913
|
-
// querystrings.
|
|
3914
|
-
//
|
|
3915
|
-
// In the case if failed decoding, we want to omit the key/value pairs
|
|
3916
|
-
// from the result.
|
|
3917
|
-
//
|
|
3918
|
-
if (key === null || value === null || key in result) continue;
|
|
3919
|
-
result[key] = value;
|
|
3920
|
-
}
|
|
3921
|
-
return result;
|
|
3922
|
-
}
|
|
3923
|
-
|
|
3924
|
-
/**
|
|
3925
|
-
* Transform a query string to an object.
|
|
3926
|
-
*
|
|
3927
|
-
* @param {Object} obj Object that should be transformed.
|
|
3928
|
-
* @param {String} prefix Optional prefix.
|
|
3929
|
-
* @returns {String}
|
|
3930
|
-
* @api public
|
|
3931
|
-
*/
|
|
3932
|
-
function querystringify$1(obj, prefix) {
|
|
3933
|
-
prefix = prefix || '';
|
|
3934
|
-
var pairs = [],
|
|
3935
|
-
value,
|
|
3936
|
-
key;
|
|
3937
|
-
|
|
3938
|
-
//
|
|
3939
|
-
// Optionally prefix with a '?' if needed
|
|
3940
|
-
//
|
|
3941
|
-
if ('string' !== typeof prefix) prefix = '?';
|
|
3942
|
-
for (key in obj) {
|
|
3943
|
-
if (has.call(obj, key)) {
|
|
3944
|
-
value = obj[key];
|
|
3945
|
-
|
|
3946
|
-
//
|
|
3947
|
-
// Edge cases where we actually want to encode the value to an empty
|
|
3948
|
-
// string instead of the stringified value.
|
|
3949
|
-
//
|
|
3950
|
-
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
3951
|
-
value = '';
|
|
3952
|
-
}
|
|
3953
|
-
key = encode(key);
|
|
3954
|
-
value = encode(value);
|
|
3955
|
-
|
|
3956
|
-
//
|
|
3957
|
-
// If we failed to encode the strings, we should bail out as we don't
|
|
3958
|
-
// want to add invalid strings to the query.
|
|
3959
|
-
//
|
|
3960
|
-
if (key === null || value === null) continue;
|
|
3961
|
-
pairs.push(key + '=' + value);
|
|
3962
|
-
}
|
|
3963
|
-
}
|
|
3964
|
-
return pairs.length ? prefix + pairs.join('&') : '';
|
|
3965
|
-
}
|
|
3966
|
-
|
|
3967
|
-
//
|
|
3968
|
-
// Expose the module.
|
|
3969
|
-
//
|
|
3970
|
-
querystringify.stringify = querystringify$1;
|
|
3971
|
-
querystringify.parse = querystring;
|
|
3972
|
-
return querystringify;
|
|
3973
|
-
}
|
|
3974
|
-
|
|
3975
|
-
var urlParse;
|
|
3976
|
-
var hasRequiredUrlParse;
|
|
3977
|
-
function requireUrlParse() {
|
|
3978
|
-
if (hasRequiredUrlParse) return urlParse;
|
|
3979
|
-
hasRequiredUrlParse = 1;
|
|
3980
|
-
var required = requireRequiresPort(),
|
|
3981
|
-
qs = requireQuerystringify(),
|
|
3982
|
-
controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,
|
|
3983
|
-
CRHTLF = /[\n\r\t]/g,
|
|
3984
|
-
slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//,
|
|
3985
|
-
port = /:\d+$/,
|
|
3986
|
-
protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,
|
|
3987
|
-
windowsDriveLetter = /^[a-zA-Z]:/;
|
|
3988
|
-
|
|
3989
|
-
/**
|
|
3990
|
-
* Remove control characters and whitespace from the beginning of a string.
|
|
3991
|
-
*
|
|
3992
|
-
* @param {Object|String} str String to trim.
|
|
3993
|
-
* @returns {String} A new string representing `str` stripped of control
|
|
3994
|
-
* characters and whitespace from its beginning.
|
|
3995
|
-
* @public
|
|
3996
|
-
*/
|
|
3997
|
-
function trimLeft(str) {
|
|
3998
|
-
return (str ? str : '').toString().replace(controlOrWhitespace, '');
|
|
3999
|
-
}
|
|
4000
|
-
|
|
4001
|
-
/**
|
|
4002
|
-
* These are the parse rules for the URL parser, it informs the parser
|
|
4003
|
-
* about:
|
|
4004
|
-
*
|
|
4005
|
-
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
4006
|
-
* indexOf, RegExp using exec and NaN means set as current value.
|
|
4007
|
-
* 1. The property we should set when parsing this value.
|
|
4008
|
-
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
4009
|
-
* the value of extra chars that should be split off.
|
|
4010
|
-
* 3. Inherit from location if non existing in the parser.
|
|
4011
|
-
* 4. `toLowerCase` the resulting value.
|
|
4012
|
-
*/
|
|
4013
|
-
var rules = [['#', 'hash'],
|
|
4014
|
-
// Extract from the back.
|
|
4015
|
-
['?', 'query'],
|
|
4016
|
-
// Extract from the back.
|
|
4017
|
-
function sanitize(address, url) {
|
|
4018
|
-
// Sanitize what is left of the address
|
|
4019
|
-
return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address;
|
|
4020
|
-
}, ['/', 'pathname'],
|
|
4021
|
-
// Extract from the back.
|
|
4022
|
-
['@', 'auth', 1],
|
|
4023
|
-
// Extract from the front.
|
|
4024
|
-
[NaN, 'host', undefined, 1, 1],
|
|
4025
|
-
// Set left over value.
|
|
4026
|
-
[/:(\d*)$/, 'port', undefined, 1],
|
|
4027
|
-
// RegExp the back.
|
|
4028
|
-
[NaN, 'hostname', undefined, 1, 1] // Set left over.
|
|
4029
|
-
];
|
|
4030
|
-
|
|
4031
|
-
/**
|
|
4032
|
-
* These properties should not be copied or inherited from. This is only needed
|
|
4033
|
-
* for all non blob URL's as a blob URL does not include a hash, only the
|
|
4034
|
-
* origin.
|
|
4035
|
-
*
|
|
4036
|
-
* @type {Object}
|
|
4037
|
-
* @private
|
|
4038
|
-
*/
|
|
4039
|
-
var ignore = {
|
|
4040
|
-
hash: 1,
|
|
4041
|
-
query: 1
|
|
4042
|
-
};
|
|
4043
|
-
|
|
4044
|
-
/**
|
|
4045
|
-
* The location object differs when your code is loaded through a normal page,
|
|
4046
|
-
* Worker or through a worker using a blob. And with the blobble begins the
|
|
4047
|
-
* trouble as the location object will contain the URL of the blob, not the
|
|
4048
|
-
* location of the page where our code is loaded in. The actual origin is
|
|
4049
|
-
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
4050
|
-
* location from it so we can generate proper relative URL's again.
|
|
4051
|
-
*
|
|
4052
|
-
* @param {Object|String} loc Optional default location object.
|
|
4053
|
-
* @returns {Object} lolcation object.
|
|
4054
|
-
* @public
|
|
4055
|
-
*/
|
|
4056
|
-
function lolcation(loc) {
|
|
4057
|
-
var globalVar;
|
|
4058
|
-
if (typeof window !== 'undefined') globalVar = window;else if (typeof commonjsGlobal !== 'undefined') globalVar = commonjsGlobal;else if (typeof self !== 'undefined') globalVar = self;else globalVar = {};
|
|
4059
|
-
var location = globalVar.location || {};
|
|
4060
|
-
loc = loc || location;
|
|
4061
|
-
var finaldestination = {},
|
|
4062
|
-
type = _typeof(loc),
|
|
4063
|
-
key;
|
|
4064
|
-
if ('blob:' === loc.protocol) {
|
|
4065
|
-
finaldestination = new Url(unescape(loc.pathname), {});
|
|
4066
|
-
} else if ('string' === type) {
|
|
4067
|
-
finaldestination = new Url(loc, {});
|
|
4068
|
-
for (key in ignore) delete finaldestination[key];
|
|
4069
|
-
} else if ('object' === type) {
|
|
4070
|
-
for (key in loc) {
|
|
4071
|
-
if (key in ignore) continue;
|
|
4072
|
-
finaldestination[key] = loc[key];
|
|
4073
|
-
}
|
|
4074
|
-
if (finaldestination.slashes === undefined) {
|
|
4075
|
-
finaldestination.slashes = slashes.test(loc.href);
|
|
4076
|
-
}
|
|
4077
|
-
}
|
|
4078
|
-
return finaldestination;
|
|
4079
|
-
}
|
|
4080
|
-
|
|
4081
|
-
/**
|
|
4082
|
-
* Check whether a protocol scheme is special.
|
|
4083
|
-
*
|
|
4084
|
-
* @param {String} The protocol scheme of the URL
|
|
4085
|
-
* @return {Boolean} `true` if the protocol scheme is special, else `false`
|
|
4086
|
-
* @private
|
|
4087
|
-
*/
|
|
4088
|
-
function isSpecial(scheme) {
|
|
4089
|
-
return scheme === 'file:' || scheme === 'ftp:' || scheme === 'http:' || scheme === 'https:' || scheme === 'ws:' || scheme === 'wss:';
|
|
4090
|
-
}
|
|
4091
|
-
|
|
4092
|
-
/**
|
|
4093
|
-
* @typedef ProtocolExtract
|
|
4094
|
-
* @type Object
|
|
4095
|
-
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
|
4096
|
-
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
|
4097
|
-
* @property {String} rest Rest of the URL that is not part of the protocol.
|
|
4098
|
-
*/
|
|
4099
|
-
|
|
4100
|
-
/**
|
|
4101
|
-
* Extract protocol information from a URL with/without double slash ("//").
|
|
4102
|
-
*
|
|
4103
|
-
* @param {String} address URL we want to extract from.
|
|
4104
|
-
* @param {Object} location
|
|
4105
|
-
* @return {ProtocolExtract} Extracted information.
|
|
4106
|
-
* @private
|
|
4107
|
-
*/
|
|
4108
|
-
function extractProtocol(address, location) {
|
|
4109
|
-
address = trimLeft(address);
|
|
4110
|
-
address = address.replace(CRHTLF, '');
|
|
4111
|
-
location = location || {};
|
|
4112
|
-
var match = protocolre.exec(address);
|
|
4113
|
-
var protocol = match[1] ? match[1].toLowerCase() : '';
|
|
4114
|
-
var forwardSlashes = !!match[2];
|
|
4115
|
-
var otherSlashes = !!match[3];
|
|
4116
|
-
var slashesCount = 0;
|
|
4117
|
-
var rest;
|
|
4118
|
-
if (forwardSlashes) {
|
|
4119
|
-
if (otherSlashes) {
|
|
4120
|
-
rest = match[2] + match[3] + match[4];
|
|
4121
|
-
slashesCount = match[2].length + match[3].length;
|
|
4122
|
-
} else {
|
|
4123
|
-
rest = match[2] + match[4];
|
|
4124
|
-
slashesCount = match[2].length;
|
|
4125
|
-
}
|
|
4126
|
-
} else {
|
|
4127
|
-
if (otherSlashes) {
|
|
4128
|
-
rest = match[3] + match[4];
|
|
4129
|
-
slashesCount = match[3].length;
|
|
4130
|
-
} else {
|
|
4131
|
-
rest = match[4];
|
|
4132
|
-
}
|
|
4133
|
-
}
|
|
4134
|
-
if (protocol === 'file:') {
|
|
4135
|
-
if (slashesCount >= 2) {
|
|
4136
|
-
rest = rest.slice(2);
|
|
4137
|
-
}
|
|
4138
|
-
} else if (isSpecial(protocol)) {
|
|
4139
|
-
rest = match[4];
|
|
4140
|
-
} else if (protocol) {
|
|
4141
|
-
if (forwardSlashes) {
|
|
4142
|
-
rest = rest.slice(2);
|
|
4143
|
-
}
|
|
4144
|
-
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
4145
|
-
rest = match[4];
|
|
4146
|
-
}
|
|
4147
|
-
return {
|
|
4148
|
-
protocol: protocol,
|
|
4149
|
-
slashes: forwardSlashes || isSpecial(protocol),
|
|
4150
|
-
slashesCount: slashesCount,
|
|
4151
|
-
rest: rest
|
|
4152
|
-
};
|
|
4153
|
-
}
|
|
4154
|
-
|
|
4155
|
-
/**
|
|
4156
|
-
* Resolve a relative URL pathname against a base URL pathname.
|
|
4157
|
-
*
|
|
4158
|
-
* @param {String} relative Pathname of the relative URL.
|
|
4159
|
-
* @param {String} base Pathname of the base URL.
|
|
4160
|
-
* @return {String} Resolved pathname.
|
|
4161
|
-
* @private
|
|
4162
|
-
*/
|
|
4163
|
-
function resolve(relative, base) {
|
|
4164
|
-
if (relative === '') return base;
|
|
4165
|
-
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/')),
|
|
4166
|
-
i = path.length,
|
|
4167
|
-
last = path[i - 1],
|
|
4168
|
-
unshift = false,
|
|
4169
|
-
up = 0;
|
|
4170
|
-
while (i--) {
|
|
4171
|
-
if (path[i] === '.') {
|
|
4172
|
-
path.splice(i, 1);
|
|
4173
|
-
} else if (path[i] === '..') {
|
|
4174
|
-
path.splice(i, 1);
|
|
4175
|
-
up++;
|
|
4176
|
-
} else if (up) {
|
|
4177
|
-
if (i === 0) unshift = true;
|
|
4178
|
-
path.splice(i, 1);
|
|
4179
|
-
up--;
|
|
4180
|
-
}
|
|
4181
|
-
}
|
|
4182
|
-
if (unshift) path.unshift('');
|
|
4183
|
-
if (last === '.' || last === '..') path.push('');
|
|
4184
|
-
return path.join('/');
|
|
4185
|
-
}
|
|
4186
|
-
|
|
4187
|
-
/**
|
|
4188
|
-
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
4189
|
-
* create an actual constructor as it's much more memory efficient and
|
|
4190
|
-
* faster and it pleases my OCD.
|
|
4191
|
-
*
|
|
4192
|
-
* It is worth noting that we should not use `URL` as class name to prevent
|
|
4193
|
-
* clashes with the global URL instance that got introduced in browsers.
|
|
4194
|
-
*
|
|
4195
|
-
* @constructor
|
|
4196
|
-
* @param {String} address URL we want to parse.
|
|
4197
|
-
* @param {Object|String} [location] Location defaults for relative paths.
|
|
4198
|
-
* @param {Boolean|Function} [parser] Parser for the query string.
|
|
4199
|
-
* @private
|
|
4200
|
-
*/
|
|
4201
|
-
function Url(address, location, parser) {
|
|
4202
|
-
address = trimLeft(address);
|
|
4203
|
-
address = address.replace(CRHTLF, '');
|
|
4204
|
-
if (!(this instanceof Url)) {
|
|
4205
|
-
return new Url(address, location, parser);
|
|
4206
|
-
}
|
|
4207
|
-
var relative,
|
|
4208
|
-
extracted,
|
|
4209
|
-
parse,
|
|
4210
|
-
instruction,
|
|
4211
|
-
index,
|
|
4212
|
-
key,
|
|
4213
|
-
instructions = rules.slice(),
|
|
4214
|
-
type = _typeof(location),
|
|
4215
|
-
url = this,
|
|
4216
|
-
i = 0;
|
|
4217
|
-
|
|
4218
|
-
//
|
|
4219
|
-
// The following if statements allows this module two have compatibility with
|
|
4220
|
-
// 2 different API:
|
|
4221
|
-
//
|
|
4222
|
-
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
|
|
4223
|
-
// where the boolean indicates that the query string should also be parsed.
|
|
4224
|
-
//
|
|
4225
|
-
// 2. The `URL` interface of the browser which accepts a URL, object as
|
|
4226
|
-
// arguments. The supplied object will be used as default values / fall-back
|
|
4227
|
-
// for relative paths.
|
|
4228
|
-
//
|
|
4229
|
-
if ('object' !== type && 'string' !== type) {
|
|
4230
|
-
parser = location;
|
|
4231
|
-
location = null;
|
|
4232
|
-
}
|
|
4233
|
-
if (parser && 'function' !== typeof parser) parser = qs.parse;
|
|
4234
|
-
location = lolcation(location);
|
|
4235
|
-
|
|
4236
|
-
//
|
|
4237
|
-
// Extract protocol information before running the instructions.
|
|
4238
|
-
//
|
|
4239
|
-
extracted = extractProtocol(address || '', location);
|
|
4240
|
-
relative = !extracted.protocol && !extracted.slashes;
|
|
4241
|
-
url.slashes = extracted.slashes || relative && location.slashes;
|
|
4242
|
-
url.protocol = extracted.protocol || location.protocol || '';
|
|
4243
|
-
address = extracted.rest;
|
|
4244
|
-
|
|
4245
|
-
//
|
|
4246
|
-
// When the authority component is absent the URL starts with a path
|
|
4247
|
-
// component.
|
|
4248
|
-
//
|
|
4249
|
-
if (extracted.protocol === 'file:' && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
4250
|
-
instructions[3] = [/(.*)/, 'pathname'];
|
|
4251
|
-
}
|
|
4252
|
-
for (; i < instructions.length; i++) {
|
|
4253
|
-
instruction = instructions[i];
|
|
4254
|
-
if (typeof instruction === 'function') {
|
|
4255
|
-
address = instruction(address, url);
|
|
4256
|
-
continue;
|
|
4257
|
-
}
|
|
4258
|
-
parse = instruction[0];
|
|
4259
|
-
key = instruction[1];
|
|
4260
|
-
if (parse !== parse) {
|
|
4261
|
-
url[key] = address;
|
|
4262
|
-
} else if ('string' === typeof parse) {
|
|
4263
|
-
index = parse === '@' ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
4264
|
-
if (~index) {
|
|
4265
|
-
if ('number' === typeof instruction[2]) {
|
|
4266
|
-
url[key] = address.slice(0, index);
|
|
4267
|
-
address = address.slice(index + instruction[2]);
|
|
4268
|
-
} else {
|
|
4269
|
-
url[key] = address.slice(index);
|
|
4270
|
-
address = address.slice(0, index);
|
|
4271
|
-
}
|
|
4272
|
-
}
|
|
4273
|
-
} else if (index = parse.exec(address)) {
|
|
4274
|
-
url[key] = index[1];
|
|
4275
|
-
address = address.slice(0, index.index);
|
|
4276
|
-
}
|
|
4277
|
-
url[key] = url[key] || (relative && instruction[3] ? location[key] || '' : '');
|
|
4278
|
-
|
|
4279
|
-
//
|
|
4280
|
-
// Hostname, host and protocol should be lowercased so they can be used to
|
|
4281
|
-
// create a proper `origin`.
|
|
4282
|
-
//
|
|
4283
|
-
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
4284
|
-
}
|
|
4285
|
-
|
|
4286
|
-
//
|
|
4287
|
-
// Also parse the supplied query string in to an object. If we're supplied
|
|
4288
|
-
// with a custom parser as function use that instead of the default build-in
|
|
4289
|
-
// parser.
|
|
4290
|
-
//
|
|
4291
|
-
if (parser) url.query = parser(url.query);
|
|
4292
|
-
|
|
4293
|
-
//
|
|
4294
|
-
// If the URL is relative, resolve the pathname against the base URL.
|
|
4295
|
-
//
|
|
4296
|
-
if (relative && location.slashes && url.pathname.charAt(0) !== '/' && (url.pathname !== '' || location.pathname !== '')) {
|
|
4297
|
-
url.pathname = resolve(url.pathname, location.pathname);
|
|
4298
|
-
}
|
|
4299
|
-
|
|
4300
|
-
//
|
|
4301
|
-
// Default to a / for pathname if none exists. This normalizes the URL
|
|
4302
|
-
// to always have a /
|
|
4303
|
-
//
|
|
4304
|
-
if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {
|
|
4305
|
-
url.pathname = '/' + url.pathname;
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
//
|
|
4309
|
-
// We should not add port numbers if they are already the default port number
|
|
4310
|
-
// for a given protocol. As the host also contains the port number we're going
|
|
4311
|
-
// override it with the hostname which contains no port number.
|
|
4312
|
-
//
|
|
4313
|
-
if (!required(url.port, url.protocol)) {
|
|
4314
|
-
url.host = url.hostname;
|
|
4315
|
-
url.port = '';
|
|
4316
|
-
}
|
|
4317
|
-
|
|
4318
|
-
//
|
|
4319
|
-
// Parse down the `auth` for the username and password.
|
|
4320
|
-
//
|
|
4321
|
-
url.username = url.password = '';
|
|
4322
|
-
if (url.auth) {
|
|
4323
|
-
index = url.auth.indexOf(':');
|
|
4324
|
-
if (~index) {
|
|
4325
|
-
url.username = url.auth.slice(0, index);
|
|
4326
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
4327
|
-
url.password = url.auth.slice(index + 1);
|
|
4328
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
4329
|
-
} else {
|
|
4330
|
-
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
4331
|
-
}
|
|
4332
|
-
url.auth = url.password ? url.username + ':' + url.password : url.username;
|
|
4333
|
-
}
|
|
4334
|
-
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host ? url.protocol + '//' + url.host : 'null';
|
|
4335
|
-
|
|
4336
|
-
//
|
|
4337
|
-
// The href is just the compiled result.
|
|
4338
|
-
//
|
|
4339
|
-
url.href = url.toString();
|
|
4340
|
-
}
|
|
4341
|
-
|
|
4342
|
-
/**
|
|
4343
|
-
* This is convenience method for changing properties in the URL instance to
|
|
4344
|
-
* insure that they all propagate correctly.
|
|
4345
|
-
*
|
|
4346
|
-
* @param {String} part Property we need to adjust.
|
|
4347
|
-
* @param {Mixed} value The newly assigned value.
|
|
4348
|
-
* @param {Boolean|Function} fn When setting the query, it will be the function
|
|
4349
|
-
* used to parse the query.
|
|
4350
|
-
* When setting the protocol, double slash will be
|
|
4351
|
-
* removed from the final url if it is true.
|
|
4352
|
-
* @returns {URL} URL instance for chaining.
|
|
4353
|
-
* @public
|
|
4354
|
-
*/
|
|
4355
|
-
function set(part, value, fn) {
|
|
4356
|
-
var url = this;
|
|
4357
|
-
switch (part) {
|
|
4358
|
-
case 'query':
|
|
4359
|
-
if ('string' === typeof value && value.length) {
|
|
4360
|
-
value = (fn || qs.parse)(value);
|
|
4361
|
-
}
|
|
4362
|
-
url[part] = value;
|
|
4363
|
-
break;
|
|
4364
|
-
case 'port':
|
|
4365
|
-
url[part] = value;
|
|
4366
|
-
if (!required(value, url.protocol)) {
|
|
4367
|
-
url.host = url.hostname;
|
|
4368
|
-
url[part] = '';
|
|
4369
|
-
} else if (value) {
|
|
4370
|
-
url.host = url.hostname + ':' + value;
|
|
4371
|
-
}
|
|
4372
|
-
break;
|
|
4373
|
-
case 'hostname':
|
|
4374
|
-
url[part] = value;
|
|
4375
|
-
if (url.port) value += ':' + url.port;
|
|
4376
|
-
url.host = value;
|
|
4377
|
-
break;
|
|
4378
|
-
case 'host':
|
|
4379
|
-
url[part] = value;
|
|
4380
|
-
if (port.test(value)) {
|
|
4381
|
-
value = value.split(':');
|
|
4382
|
-
url.port = value.pop();
|
|
4383
|
-
url.hostname = value.join(':');
|
|
4384
|
-
} else {
|
|
4385
|
-
url.hostname = value;
|
|
4386
|
-
url.port = '';
|
|
4387
|
-
}
|
|
4388
|
-
break;
|
|
4389
|
-
case 'protocol':
|
|
4390
|
-
url.protocol = value.toLowerCase();
|
|
4391
|
-
url.slashes = !fn;
|
|
4392
|
-
break;
|
|
4393
|
-
case 'pathname':
|
|
4394
|
-
case 'hash':
|
|
4395
|
-
if (value) {
|
|
4396
|
-
var char = part === 'pathname' ? '/' : '#';
|
|
4397
|
-
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
4398
|
-
} else {
|
|
4399
|
-
url[part] = value;
|
|
4400
|
-
}
|
|
4401
|
-
break;
|
|
4402
|
-
case 'username':
|
|
4403
|
-
case 'password':
|
|
4404
|
-
url[part] = encodeURIComponent(value);
|
|
4405
|
-
break;
|
|
4406
|
-
case 'auth':
|
|
4407
|
-
var index = value.indexOf(':');
|
|
4408
|
-
if (~index) {
|
|
4409
|
-
url.username = value.slice(0, index);
|
|
4410
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
4411
|
-
url.password = value.slice(index + 1);
|
|
4412
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
4413
|
-
} else {
|
|
4414
|
-
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
for (var i = 0; i < rules.length; i++) {
|
|
4418
|
-
var ins = rules[i];
|
|
4419
|
-
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
4420
|
-
}
|
|
4421
|
-
url.auth = url.password ? url.username + ':' + url.password : url.username;
|
|
4422
|
-
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host ? url.protocol + '//' + url.host : 'null';
|
|
4423
|
-
url.href = url.toString();
|
|
4424
|
-
return url;
|
|
4425
|
-
}
|
|
4426
|
-
|
|
4427
|
-
/**
|
|
4428
|
-
* Transform the properties back in to a valid and full URL string.
|
|
4429
|
-
*
|
|
4430
|
-
* @param {Function} stringify Optional query stringify function.
|
|
4431
|
-
* @returns {String} Compiled version of the URL.
|
|
4432
|
-
* @public
|
|
4433
|
-
*/
|
|
4434
|
-
function toString(stringify) {
|
|
4435
|
-
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
|
|
4436
|
-
var query,
|
|
4437
|
-
url = this,
|
|
4438
|
-
host = url.host,
|
|
4439
|
-
protocol = url.protocol;
|
|
4440
|
-
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
|
|
4441
|
-
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? '//' : '');
|
|
4442
|
-
if (url.username) {
|
|
4443
|
-
result += url.username;
|
|
4444
|
-
if (url.password) result += ':' + url.password;
|
|
4445
|
-
result += '@';
|
|
4446
|
-
} else if (url.password) {
|
|
4447
|
-
result += ':' + url.password;
|
|
4448
|
-
result += '@';
|
|
4449
|
-
} else if (url.protocol !== 'file:' && isSpecial(url.protocol) && !host && url.pathname !== '/') {
|
|
4450
|
-
//
|
|
4451
|
-
// Add back the empty userinfo, otherwise the original invalid URL
|
|
4452
|
-
// might be transformed into a valid one with `url.pathname` as host.
|
|
4453
|
-
//
|
|
4454
|
-
result += '@';
|
|
4455
|
-
}
|
|
4456
|
-
|
|
4457
|
-
//
|
|
4458
|
-
// Trailing colon is removed from `url.host` when it is parsed. If it still
|
|
4459
|
-
// ends with a colon, then add back the trailing colon that was removed. This
|
|
4460
|
-
// prevents an invalid URL from being transformed into a valid one.
|
|
4461
|
-
//
|
|
4462
|
-
if (host[host.length - 1] === ':' || port.test(url.hostname) && !url.port) {
|
|
4463
|
-
host += ':';
|
|
4464
|
-
}
|
|
4465
|
-
result += host + url.pathname;
|
|
4466
|
-
query = 'object' === _typeof(url.query) ? stringify(url.query) : url.query;
|
|
4467
|
-
if (query) result += '?' !== query.charAt(0) ? '?' + query : query;
|
|
4468
|
-
if (url.hash) result += url.hash;
|
|
4469
|
-
return result;
|
|
4470
|
-
}
|
|
4471
|
-
Url.prototype = {
|
|
4472
|
-
set: set,
|
|
4473
|
-
toString: toString
|
|
4474
|
-
};
|
|
4475
|
-
|
|
4476
|
-
//
|
|
4477
|
-
// Expose the URL parser and some additional properties that might be useful for
|
|
4478
|
-
// others or testing.
|
|
4479
|
-
//
|
|
4480
|
-
Url.extractProtocol = extractProtocol;
|
|
4481
|
-
Url.location = lolcation;
|
|
4482
|
-
Url.trimLeft = trimLeft;
|
|
4483
|
-
Url.qs = qs;
|
|
4484
|
-
urlParse = Url;
|
|
4485
|
-
return urlParse;
|
|
4486
|
-
}
|
|
4487
|
-
|
|
4488
|
-
var urlParseExports = requireUrlParse();
|
|
4489
|
-
var Url = /*@__PURE__*/getDefaultExportFromCjs(urlParseExports);
|
|
4490
|
-
|
|
4491
|
-
var validUrl$1 = {exports: {}};
|
|
4492
|
-
|
|
4493
|
-
var hasRequiredValidUrl;
|
|
4494
|
-
function requireValidUrl() {
|
|
4495
|
-
if (hasRequiredValidUrl) return validUrl$1.exports;
|
|
4496
|
-
hasRequiredValidUrl = 1;
|
|
4497
|
-
(function (module) {
|
|
4498
|
-
(function (module) {
|
|
4499
|
-
|
|
4500
|
-
module.exports.is_uri = is_iri;
|
|
4501
|
-
module.exports.is_http_uri = is_http_iri;
|
|
4502
|
-
module.exports.is_https_uri = is_https_iri;
|
|
4503
|
-
module.exports.is_web_uri = is_web_iri;
|
|
4504
|
-
// Create aliases
|
|
4505
|
-
module.exports.isUri = is_iri;
|
|
4506
|
-
module.exports.isHttpUri = is_http_iri;
|
|
4507
|
-
module.exports.isHttpsUri = is_https_iri;
|
|
4508
|
-
module.exports.isWebUri = is_web_iri;
|
|
4509
|
-
|
|
4510
|
-
// private function
|
|
4511
|
-
// internal URI spitter method - direct from RFC 3986
|
|
4512
|
-
var splitUri = function splitUri(uri) {
|
|
4513
|
-
var splitted = uri.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
4514
|
-
return splitted;
|
|
4515
|
-
};
|
|
4516
|
-
function is_iri(value) {
|
|
4517
|
-
if (!value) {
|
|
4518
|
-
return;
|
|
4519
|
-
}
|
|
4520
|
-
|
|
4521
|
-
// check for illegal characters
|
|
4522
|
-
if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(value)) return;
|
|
4523
|
-
|
|
4524
|
-
// check for hex escapes that aren't complete
|
|
4525
|
-
if (/%[^0-9a-f]/i.test(value)) return;
|
|
4526
|
-
if (/%[0-9a-f](:?[^0-9a-f]|$)/i.test(value)) return;
|
|
4527
|
-
var splitted = [];
|
|
4528
|
-
var scheme = '';
|
|
4529
|
-
var authority = '';
|
|
4530
|
-
var path = '';
|
|
4531
|
-
var query = '';
|
|
4532
|
-
var fragment = '';
|
|
4533
|
-
var out = '';
|
|
4534
|
-
|
|
4535
|
-
// from RFC 3986
|
|
4536
|
-
splitted = splitUri(value);
|
|
4537
|
-
scheme = splitted[1];
|
|
4538
|
-
authority = splitted[2];
|
|
4539
|
-
path = splitted[3];
|
|
4540
|
-
query = splitted[4];
|
|
4541
|
-
fragment = splitted[5];
|
|
4542
|
-
|
|
4543
|
-
// scheme and path are required, though the path can be empty
|
|
4544
|
-
if (!(scheme && scheme.length && path.length >= 0)) return;
|
|
4545
|
-
|
|
4546
|
-
// if authority is present, the path must be empty or begin with a /
|
|
4547
|
-
if (authority && authority.length) {
|
|
4548
|
-
if (!(path.length === 0 || /^\//.test(path))) return;
|
|
4549
|
-
} else {
|
|
4550
|
-
// if authority is not present, the path must not start with //
|
|
4551
|
-
if (/^\/\//.test(path)) return;
|
|
4552
|
-
}
|
|
4553
|
-
|
|
4554
|
-
// scheme must begin with a letter, then consist of letters, digits, +, ., or -
|
|
4555
|
-
if (!/^[a-z][a-z0-9\+\-\.]*$/.test(scheme.toLowerCase())) return;
|
|
4556
|
-
|
|
4557
|
-
// re-assemble the URL per section 5.3 in RFC 3986
|
|
4558
|
-
out += scheme + ':';
|
|
4559
|
-
if (authority && authority.length) {
|
|
4560
|
-
out += '//' + authority;
|
|
4561
|
-
}
|
|
4562
|
-
out += path;
|
|
4563
|
-
if (query && query.length) {
|
|
4564
|
-
out += '?' + query;
|
|
4565
|
-
}
|
|
4566
|
-
if (fragment && fragment.length) {
|
|
4567
|
-
out += '#' + fragment;
|
|
4568
|
-
}
|
|
4569
|
-
return out;
|
|
4570
|
-
}
|
|
4571
|
-
function is_http_iri(value, allowHttps) {
|
|
4572
|
-
if (!is_iri(value)) {
|
|
4573
|
-
return;
|
|
4574
|
-
}
|
|
4575
|
-
var splitted = [];
|
|
4576
|
-
var scheme = '';
|
|
4577
|
-
var authority = '';
|
|
4578
|
-
var path = '';
|
|
4579
|
-
var port = '';
|
|
4580
|
-
var query = '';
|
|
4581
|
-
var fragment = '';
|
|
4582
|
-
var out = '';
|
|
4583
|
-
|
|
4584
|
-
// from RFC 3986
|
|
4585
|
-
splitted = splitUri(value);
|
|
4586
|
-
scheme = splitted[1];
|
|
4587
|
-
authority = splitted[2];
|
|
4588
|
-
path = splitted[3];
|
|
4589
|
-
query = splitted[4];
|
|
4590
|
-
fragment = splitted[5];
|
|
4591
|
-
if (!scheme) return;
|
|
4592
|
-
if (allowHttps) {
|
|
4593
|
-
if (scheme.toLowerCase() != 'https') return;
|
|
4594
|
-
} else {
|
|
4595
|
-
if (scheme.toLowerCase() != 'http') return;
|
|
4596
|
-
}
|
|
4597
|
-
|
|
4598
|
-
// fully-qualified URIs must have an authority section that is
|
|
4599
|
-
// a valid host
|
|
4600
|
-
if (!authority) {
|
|
4601
|
-
return;
|
|
4602
|
-
}
|
|
4603
|
-
|
|
4604
|
-
// enable port component
|
|
4605
|
-
if (/:(\d+)$/.test(authority)) {
|
|
4606
|
-
port = authority.match(/:(\d+)$/)[0];
|
|
4607
|
-
authority = authority.replace(/:\d+$/, '');
|
|
4608
|
-
}
|
|
4609
|
-
out += scheme + ':';
|
|
4610
|
-
out += '//' + authority;
|
|
4611
|
-
if (port) {
|
|
4612
|
-
out += port;
|
|
4613
|
-
}
|
|
4614
|
-
out += path;
|
|
4615
|
-
if (query && query.length) {
|
|
4616
|
-
out += '?' + query;
|
|
4617
|
-
}
|
|
4618
|
-
if (fragment && fragment.length) {
|
|
4619
|
-
out += '#' + fragment;
|
|
4620
|
-
}
|
|
4621
|
-
return out;
|
|
4622
|
-
}
|
|
4623
|
-
function is_https_iri(value) {
|
|
4624
|
-
return is_http_iri(value, true);
|
|
4625
|
-
}
|
|
4626
|
-
function is_web_iri(value) {
|
|
4627
|
-
return is_http_iri(value) || is_https_iri(value);
|
|
4628
|
-
}
|
|
4629
|
-
})(module);
|
|
4630
|
-
})(validUrl$1);
|
|
4631
|
-
return validUrl$1.exports;
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4634
|
-
var validUrlExports = requireValidUrl();
|
|
4635
|
-
var validUrl = /*@__PURE__*/getDefaultExportFromCjs(validUrlExports);
|
|
4636
|
-
|
|
4637
3863
|
// @ts-nocheck
|
|
4638
3864
|
var platform$2 = {
|
|
4639
3865
|
value: null
|
|
@@ -4723,15 +3949,16 @@ function getPlatform() {
|
|
|
4723
3949
|
return platform$2.value;
|
|
4724
3950
|
}
|
|
4725
3951
|
|
|
4726
|
-
var platform$1 = getPlatform();
|
|
3952
|
+
var platform$1 = /*#__PURE__*/getPlatform();
|
|
4727
3953
|
function getRequestFunc() {
|
|
4728
3954
|
var extractFn = function extractFn(platform) {
|
|
4729
3955
|
// @ts-ignore
|
|
4730
|
-
|
|
3956
|
+
var request = platform && (platform.mp.request || platform.mp.httpRequest /* DingTalk Mini Program */);
|
|
3957
|
+
return typeof request === "function" ? request.bind(platform.mp) : request;
|
|
4731
3958
|
};
|
|
4732
3959
|
return extractFn(platform$1) || function errorRequest(options) {
|
|
4733
|
-
var errMsg = "NOT_SUPPORTED_ERR"
|
|
4734
|
-
|
|
3960
|
+
var errMsg = "NOT_SUPPORTED_ERR",
|
|
3961
|
+
errno = 9; // DOMException (NotSupportedError)
|
|
4735
3962
|
var errInfo = {
|
|
4736
3963
|
errMsg: errMsg,
|
|
4737
3964
|
errno: errno,
|
|
@@ -5007,15 +4234,23 @@ function createXMLHttpRequestUpload() {
|
|
|
5007
4234
|
}
|
|
5008
4235
|
|
|
5009
4236
|
var mp$1 = {
|
|
5010
|
-
request: getRequestFunc()
|
|
4237
|
+
request: /*#__PURE__*/getRequestFunc()
|
|
5011
4238
|
};
|
|
5012
|
-
function setRequestFunc(request) {
|
|
5013
|
-
mp$1.request = request;
|
|
4239
|
+
function setRequestFunc(request, thisArg) {
|
|
4240
|
+
mp$1.request = typeof request === "function" && thisArg !== undefined ? request.bind(thisArg) : request;
|
|
5014
4241
|
}
|
|
5015
4242
|
var CookieAccessor = {
|
|
5016
4243
|
get: null,
|
|
5017
4244
|
set: null
|
|
5018
4245
|
};
|
|
4246
|
+
function useCookie(accessor) {
|
|
4247
|
+
CookieAccessor.get = function (url, withCredentials) {
|
|
4248
|
+
return accessor.get(url, withCredentials);
|
|
4249
|
+
};
|
|
4250
|
+
CookieAccessor.set = function (url, withCredentials, cookies) {
|
|
4251
|
+
return accessor.set(url, withCredentials, cookies);
|
|
4252
|
+
};
|
|
4253
|
+
}
|
|
5019
4254
|
var XMLHttpRequestP = /*#__PURE__*/function (_XMLHttpRequestEventT, _Symbol$toStringTag) {
|
|
5020
4255
|
function XMLHttpRequestP() {
|
|
5021
4256
|
var _this;
|
|
@@ -5226,8 +4461,8 @@ var XMLHttpRequestP = /*#__PURE__*/function (_XMLHttpRequestEventT, _Symbol$toSt
|
|
|
5226
4461
|
var request = function (data) {
|
|
5227
4462
|
if (requestId !== s.requestId) return;
|
|
5228
4463
|
if (s.pos !== 2 /* XHRCycle.LOADSTART */ && s.pos !== 8 /* XHRCycle.UPLOAD_LOADEND */) return;
|
|
5229
|
-
options.data = data !== "" ? data : undefined;
|
|
5230
4464
|
options.headers = options.header; // Alipay Mini Program
|
|
4465
|
+
options.data = data ? coerceBody(data) : undefined;
|
|
5231
4466
|
s.requestTask = mp$1.request(options);
|
|
5232
4467
|
}.bind(this);
|
|
5233
4468
|
checkRequestTimeout(this);
|
|
@@ -5605,501 +4840,22 @@ function execLoadend(xhr) {
|
|
|
5605
4840
|
clearRequestTimeout(s);
|
|
5606
4841
|
emitProgressEvent(xhr, "loadend", contentLength, contentLength);
|
|
5607
4842
|
}
|
|
5608
|
-
var XMLHttpRequestE =
|
|
5609
|
-
|
|
5610
|
-
var defaultParseOptions = {
|
|
5611
|
-
decodeValues: true,
|
|
5612
|
-
map: false,
|
|
5613
|
-
silent: false,
|
|
5614
|
-
split: "auto" // auto = split strings but not arrays
|
|
5615
|
-
};
|
|
5616
|
-
function isForbiddenKey(key) {
|
|
5617
|
-
return typeof key !== "string" || key in {};
|
|
5618
|
-
}
|
|
5619
|
-
function createNullObj() {
|
|
5620
|
-
return Object.create(null);
|
|
5621
|
-
}
|
|
5622
|
-
function isNonEmptyString(str) {
|
|
5623
|
-
return typeof str === "string" && !!str.trim();
|
|
5624
|
-
}
|
|
5625
|
-
function parseString(setCookieValue, options) {
|
|
5626
|
-
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
5627
|
-
var nameValuePairStr = parts.shift();
|
|
5628
|
-
if (!nameValuePairStr) {
|
|
5629
|
-
return null;
|
|
5630
|
-
}
|
|
5631
|
-
var parsed = parseNameValuePair(nameValuePairStr);
|
|
5632
|
-
var name = parsed.name;
|
|
5633
|
-
var value = parsed.value;
|
|
5634
|
-
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
5635
|
-
if (isForbiddenKey(name)) {
|
|
5636
|
-
return null;
|
|
5637
|
-
}
|
|
5638
|
-
try {
|
|
5639
|
-
value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
|
|
5640
|
-
} catch (e) {
|
|
5641
|
-
console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.", e);
|
|
5642
|
-
}
|
|
5643
|
-
var cookie = createNullObj();
|
|
5644
|
-
cookie.name = name;
|
|
5645
|
-
cookie.value = value;
|
|
5646
|
-
parts.forEach(function (part) {
|
|
5647
|
-
var sides = part.split("=");
|
|
5648
|
-
var key = sides.shift().trim().toLowerCase();
|
|
5649
|
-
if (isForbiddenKey(key)) {
|
|
5650
|
-
return;
|
|
5651
|
-
}
|
|
5652
|
-
var value = sides.join("=").trim();
|
|
5653
|
-
if (key === "expires") {
|
|
5654
|
-
cookie.expires = new Date(value);
|
|
5655
|
-
} else if (key === "max-age") {
|
|
5656
|
-
var n = parseInt(value, 10);
|
|
5657
|
-
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
5658
|
-
} else if (key === "secure") {
|
|
5659
|
-
cookie.secure = true;
|
|
5660
|
-
} else if (key === "httponly") {
|
|
5661
|
-
cookie.httpOnly = true;
|
|
5662
|
-
} else if (key === "samesite") {
|
|
5663
|
-
cookie.sameSite = value;
|
|
5664
|
-
} else if (key === "partitioned") {
|
|
5665
|
-
cookie.partitioned = true;
|
|
5666
|
-
} else if (key) {
|
|
5667
|
-
cookie[key] = value;
|
|
5668
|
-
}
|
|
5669
|
-
});
|
|
5670
|
-
return cookie;
|
|
5671
|
-
}
|
|
5672
|
-
function parseNameValuePair(nameValuePairStr) {
|
|
5673
|
-
// Parses name-value-pair according to rfc6265bis draft
|
|
5674
|
-
|
|
5675
|
-
var name = "";
|
|
5676
|
-
var value = "";
|
|
5677
|
-
var nameValueArr = nameValuePairStr.split("=");
|
|
5678
|
-
if (nameValueArr.length > 1) {
|
|
5679
|
-
name = nameValueArr.shift();
|
|
5680
|
-
value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
|
|
5681
|
-
} else {
|
|
5682
|
-
value = nameValuePairStr;
|
|
5683
|
-
}
|
|
5684
|
-
return {
|
|
5685
|
-
name: name,
|
|
5686
|
-
value: value
|
|
5687
|
-
};
|
|
5688
|
-
}
|
|
5689
|
-
function parseSetCookie(input, options) {
|
|
5690
|
-
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
5691
|
-
if (!input) {
|
|
5692
|
-
if (!options.map) {
|
|
5693
|
-
return [];
|
|
5694
|
-
} else {
|
|
5695
|
-
return createNullObj();
|
|
5696
|
-
}
|
|
5697
|
-
}
|
|
5698
|
-
if (input.headers) {
|
|
5699
|
-
if (typeof input.headers.getSetCookie === "function") {
|
|
5700
|
-
// for fetch responses - they combine headers of the same type in the headers array,
|
|
5701
|
-
// but getSetCookie returns an uncombined array
|
|
5702
|
-
input = input.headers.getSetCookie();
|
|
5703
|
-
} else if (input.headers["set-cookie"]) {
|
|
5704
|
-
// fast-path for node.js (which automatically normalizes header names to lower-case)
|
|
5705
|
-
input = input.headers["set-cookie"];
|
|
5706
|
-
} else {
|
|
5707
|
-
// slow-path for other environments - see #25
|
|
5708
|
-
var sch = input.headers[Object.keys(input.headers).find(function (key) {
|
|
5709
|
-
return key.toLowerCase() === "set-cookie";
|
|
5710
|
-
})];
|
|
5711
|
-
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
|
5712
|
-
if (!sch && input.headers.cookie && !options.silent) {
|
|
5713
|
-
console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.");
|
|
5714
|
-
}
|
|
5715
|
-
input = sch;
|
|
5716
|
-
}
|
|
5717
|
-
}
|
|
5718
|
-
var split = options.split;
|
|
5719
|
-
var isArray = Array.isArray(input);
|
|
5720
|
-
if (split === "auto") {
|
|
5721
|
-
split = !isArray;
|
|
5722
|
-
}
|
|
5723
|
-
if (!isArray) {
|
|
5724
|
-
input = [input];
|
|
5725
|
-
}
|
|
5726
|
-
input = input.filter(isNonEmptyString);
|
|
5727
|
-
if (split) {
|
|
5728
|
-
input = input.map(splitCookiesString).flat();
|
|
5729
|
-
}
|
|
5730
|
-
if (!options.map) {
|
|
5731
|
-
return input.map(function (str) {
|
|
5732
|
-
return parseString(str, options);
|
|
5733
|
-
}).filter(Boolean);
|
|
5734
|
-
} else {
|
|
5735
|
-
var cookies = createNullObj();
|
|
5736
|
-
return input.reduce(function (cookies, str) {
|
|
5737
|
-
var cookie = parseString(str, options);
|
|
5738
|
-
if (cookie && !isForbiddenKey(cookie.name)) {
|
|
5739
|
-
cookies[cookie.name] = cookie;
|
|
5740
|
-
}
|
|
5741
|
-
return cookies;
|
|
5742
|
-
}, cookies);
|
|
5743
|
-
}
|
|
5744
|
-
}
|
|
5745
|
-
|
|
5746
|
-
/*
|
|
5747
|
-
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
|
5748
|
-
that are within a single set-cookie field-value, such as in the Expires portion.
|
|
5749
|
-
|
|
5750
|
-
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
|
5751
|
-
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
|
5752
|
-
React Native's fetch does this for *every* header, including set-cookie.
|
|
5753
|
-
|
|
5754
|
-
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
|
5755
|
-
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
|
5756
|
-
*/
|
|
5757
|
-
function splitCookiesString(cookiesString) {
|
|
5758
|
-
if (Array.isArray(cookiesString)) {
|
|
5759
|
-
return cookiesString;
|
|
5760
|
-
}
|
|
5761
|
-
if (typeof cookiesString !== "string") {
|
|
5762
|
-
return [];
|
|
5763
|
-
}
|
|
5764
|
-
var cookiesStrings = [];
|
|
5765
|
-
var pos = 0;
|
|
5766
|
-
var start;
|
|
5767
|
-
var ch;
|
|
5768
|
-
var lastComma;
|
|
5769
|
-
var nextStart;
|
|
5770
|
-
var cookiesSeparatorFound;
|
|
5771
|
-
function skipWhitespace() {
|
|
5772
|
-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
5773
|
-
pos += 1;
|
|
5774
|
-
}
|
|
5775
|
-
return pos < cookiesString.length;
|
|
5776
|
-
}
|
|
5777
|
-
function notSpecialChar() {
|
|
5778
|
-
ch = cookiesString.charAt(pos);
|
|
5779
|
-
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
5780
|
-
}
|
|
5781
|
-
while (pos < cookiesString.length) {
|
|
5782
|
-
start = pos;
|
|
5783
|
-
cookiesSeparatorFound = false;
|
|
5784
|
-
while (skipWhitespace()) {
|
|
5785
|
-
ch = cookiesString.charAt(pos);
|
|
5786
|
-
if (ch === ",") {
|
|
5787
|
-
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
|
5788
|
-
lastComma = pos;
|
|
5789
|
-
pos += 1;
|
|
5790
|
-
skipWhitespace();
|
|
5791
|
-
nextStart = pos;
|
|
5792
|
-
while (pos < cookiesString.length && notSpecialChar()) {
|
|
5793
|
-
pos += 1;
|
|
5794
|
-
}
|
|
5795
|
-
|
|
5796
|
-
// currently special character
|
|
5797
|
-
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
5798
|
-
// we found cookies separator
|
|
5799
|
-
cookiesSeparatorFound = true;
|
|
5800
|
-
// pos is inside the next cookie, so back up and return it.
|
|
5801
|
-
pos = nextStart;
|
|
5802
|
-
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
5803
|
-
start = pos;
|
|
5804
|
-
} else {
|
|
5805
|
-
// in param ',' or param separator ';',
|
|
5806
|
-
// we continue from that comma
|
|
5807
|
-
pos = lastComma + 1;
|
|
5808
|
-
}
|
|
5809
|
-
} else {
|
|
5810
|
-
pos += 1;
|
|
5811
|
-
}
|
|
5812
|
-
}
|
|
5813
|
-
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
5814
|
-
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
5815
|
-
}
|
|
5816
|
-
}
|
|
5817
|
-
return cookiesStrings;
|
|
5818
|
-
}
|
|
5819
|
-
|
|
5820
|
-
// named export for CJS
|
|
5821
|
-
parseSetCookie.parseSetCookie = parseSetCookie;
|
|
5822
|
-
// for backwards compatibility
|
|
5823
|
-
parseSetCookie.parse = parseSetCookie;
|
|
5824
|
-
parseSetCookie.parseString = parseString;
|
|
5825
|
-
parseSetCookie.splitCookiesString = splitCookiesString;
|
|
5826
|
-
|
|
5827
|
-
var webSite = {
|
|
5828
|
-
url: new Url("https://example.com")
|
|
5829
|
-
};
|
|
5830
|
-
var storage = {
|
|
5831
|
-
value: null
|
|
5832
|
-
};
|
|
5833
|
-
var CookieStorage = /*#__PURE__*/function () {
|
|
5834
|
-
function CookieStorage() {
|
|
5835
|
-
_classCallCheck(this, CookieStorage);
|
|
5836
|
-
this.cookies = [];
|
|
5837
|
-
this.restore();
|
|
5838
|
-
setTimeout(function () {
|
|
5839
|
-
this.persist();
|
|
5840
|
-
}.bind(this), 0);
|
|
5841
|
-
}
|
|
5842
|
-
return _createClass(CookieStorage, [{
|
|
5843
|
-
key: "storageKey",
|
|
5844
|
-
get: function get() {
|
|
5845
|
-
return "__COOKIE_MPHTTPX__";
|
|
5846
|
-
}
|
|
5847
|
-
}, {
|
|
5848
|
-
key: "restore",
|
|
5849
|
-
value: function restore() {
|
|
5850
|
-
if (!platform$1) return;
|
|
5851
|
-
var cookies = function () {
|
|
5852
|
-
try {
|
|
5853
|
-
var data = platform$1.name !== "Alipay" ? platform$1.mp.getStorageSync(this.storageKey)
|
|
5854
|
-
// @ts-ignore
|
|
5855
|
-
: platform$1.mp.getStorageSync({
|
|
5856
|
-
key: this.storageKey
|
|
5857
|
-
}).data; // Alipay Mini Program
|
|
5858
|
-
var parsed = data ? JSON.parse(data) : [];
|
|
5859
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
5860
|
-
} catch (e) {
|
|
5861
|
-
return [];
|
|
5862
|
-
}
|
|
5863
|
-
}.bind(this)();
|
|
5864
|
-
var isValid = function isValid(val) {
|
|
5865
|
-
return _typeof(val) === "object" && val && typeof val._expires === "number";
|
|
5866
|
-
};
|
|
5867
|
-
this.cookies = cookies.filter(function (_c) {
|
|
5868
|
-
return isValid(_c);
|
|
5869
|
-
}).map(function (_c) {
|
|
5870
|
-
var copy = copyCookie(_c);
|
|
5871
|
-
copy.expires = new Date(_c._expires || 0);
|
|
5872
|
-
return copy;
|
|
5873
|
-
});
|
|
5874
|
-
}
|
|
5875
|
-
}, {
|
|
5876
|
-
key: "persist",
|
|
5877
|
-
value: function persist() {
|
|
5878
|
-
if (!platform$1) return;
|
|
5879
|
-
var cookies = this.cookies.filter(function (c) {
|
|
5880
|
-
return c.expires && c.expires > new Date();
|
|
5881
|
-
}).map(function (c) {
|
|
5882
|
-
var copy = copyCookie(c);
|
|
5883
|
-
copy._expires = c.expires.getTime();
|
|
5884
|
-
return copy;
|
|
5885
|
-
});
|
|
5886
|
-
platform$1.mp.setStorage({
|
|
5887
|
-
key: this.storageKey,
|
|
5888
|
-
data: JSON.stringify(cookies)
|
|
5889
|
-
});
|
|
5890
|
-
}
|
|
5891
|
-
}, {
|
|
5892
|
-
key: "getForUrl",
|
|
5893
|
-
value: function getForUrl(fromPage, url, withCredentials) {
|
|
5894
|
-
var currentUrl = new Url(fixUrl(url));
|
|
5895
|
-
var sameOrigin = webSite.url.origin === currentUrl.origin;
|
|
5896
|
-
if (!fromPage) {
|
|
5897
|
-
if (!sameOrigin && !withCredentials) return "";
|
|
5898
|
-
}
|
|
5899
|
-
var results = {
|
|
5900
|
-
valid: [],
|
|
5901
|
-
expired: []
|
|
5902
|
-
};
|
|
5903
|
-
for (var i = 0; i < this.cookies.length; ++i) {
|
|
5904
|
-
var cookie = this.cookies[i];
|
|
5905
|
-
if (fromPage && cookie.httpOnly) {
|
|
5906
|
-
continue;
|
|
5907
|
-
}
|
|
5908
|
-
if (!fromPage) {
|
|
5909
|
-
if (!sameOrigin && cookie.sameSite && cookie.sameSite.toLowerCase() !== "none") {
|
|
5910
|
-
continue;
|
|
5911
|
-
}
|
|
5912
|
-
if (currentUrl.hostname !== "127.0.0.1" && currentUrl.hostname !== "localhost") {
|
|
5913
|
-
if (cookie.secure && currentUrl.protocol !== "https") {
|
|
5914
|
-
continue;
|
|
5915
|
-
}
|
|
5916
|
-
}
|
|
5917
|
-
}
|
|
5918
|
-
if (checkDomain(currentUrl.hostname, cookie.domain)) {
|
|
5919
|
-
if (checkPath(currentUrl.pathname, cookie.path)) {
|
|
5920
|
-
if (!cookie.expires || cookie.expires > new Date()) {
|
|
5921
|
-
results.valid.push(cookie);
|
|
5922
|
-
} else {
|
|
5923
|
-
results.expired.push(cookie);
|
|
5924
|
-
}
|
|
5925
|
-
}
|
|
5926
|
-
}
|
|
5927
|
-
}
|
|
5928
|
-
if (results.expired.length > 0) {
|
|
5929
|
-
this.cookies = this.cookies.filter(function (c) {
|
|
5930
|
-
return !c.expires || c.expires > new Date();
|
|
5931
|
-
});
|
|
5932
|
-
setTimeout(function () {
|
|
5933
|
-
this.persist();
|
|
5934
|
-
}.bind(this), 0);
|
|
5935
|
-
}
|
|
5936
|
-
return results.valid.map(function (c) {
|
|
5937
|
-
return c.name + "=" + c.value;
|
|
5938
|
-
}).join("; ");
|
|
5939
|
-
}
|
|
5940
|
-
}, {
|
|
5941
|
-
key: "setForUrl",
|
|
5942
|
-
value: function setForUrl(fromPage, url, withCredentials, cookies) {
|
|
5943
|
-
var _this = this;
|
|
5944
|
-
if (!cookies) return;
|
|
5945
|
-
var currentUrl = new Url(fixUrl(url));
|
|
5946
|
-
var sameOrigin = webSite.url.origin === currentUrl.origin;
|
|
5947
|
-
if (!fromPage) {
|
|
5948
|
-
if (!sameOrigin && !withCredentials) return;
|
|
5949
|
-
}
|
|
5950
|
-
var results = !fromPage ? parseSetCookie(cookies) : parseSetCookie("" + cookies, {
|
|
5951
|
-
split: false
|
|
5952
|
-
});
|
|
5953
|
-
var _loop = function _loop() {
|
|
5954
|
-
var cookie = results[i];
|
|
5955
|
-
if (!cookie.name) return 0; // continue
|
|
5956
|
-
if (fromPage) {
|
|
5957
|
-
if (cookie.httpOnly) {
|
|
5958
|
-
return 0; // continue
|
|
5959
|
-
}
|
|
5960
|
-
}
|
|
5961
|
-
if (cookie.sameSite && cookie.sameSite.toLowerCase() === "none" && !cookie.secure) {
|
|
5962
|
-
return 0; // continue
|
|
5963
|
-
}
|
|
5964
|
-
if (!cookie.domain) {
|
|
5965
|
-
cookie.domain = currentUrl.hostname;
|
|
5966
|
-
} else {
|
|
5967
|
-
cookie.domain = cookie.domain.toLowerCase();
|
|
5968
|
-
if (cookie.domain.split(".").filter(function (x) {
|
|
5969
|
-
return !!x;
|
|
5970
|
-
}).length >= 2) {
|
|
5971
|
-
cookie.domain = prependDot(cookie.domain);
|
|
5972
|
-
}
|
|
5973
|
-
}
|
|
5974
|
-
if (!cookie.path) {
|
|
5975
|
-
cookie.path = currentUrl.pathname;
|
|
5976
|
-
}
|
|
5977
|
-
if (typeof cookie.maxAge === "number") {
|
|
5978
|
-
cookie.expires = new Date(new Date().getTime() + cookie.maxAge * 1000);
|
|
5979
|
-
}
|
|
5980
|
-
if (checkDomain(currentUrl.hostname, cookie.domain)) {
|
|
5981
|
-
_this.cookies = _this.cookies.filter(function (c) {
|
|
5982
|
-
return !isSameCookie(c, cookie);
|
|
5983
|
-
});
|
|
5984
|
-
if (!cookie.expires || cookie.expires > new Date()) {
|
|
5985
|
-
_this.cookies = [cookie].concat(_this.cookies);
|
|
5986
|
-
}
|
|
5987
|
-
}
|
|
5988
|
-
},
|
|
5989
|
-
_ret;
|
|
5990
|
-
for (var i = 0; i < results.length; ++i) {
|
|
5991
|
-
_ret = _loop();
|
|
5992
|
-
if (_ret === 0) continue;
|
|
5993
|
-
}
|
|
5994
|
-
this.cookies.sort(function (a, b) {
|
|
5995
|
-
var a_domain = prependDot(a.domain);
|
|
5996
|
-
var b_domain = prependDot(b.domain);
|
|
5997
|
-
if (a_domain.length !== b_domain.length) {
|
|
5998
|
-
return b_domain.length - a_domain.length;
|
|
5999
|
-
} else {
|
|
6000
|
-
var a_path = appendSlash(a.path);
|
|
6001
|
-
var b_path = appendSlash(b.path);
|
|
6002
|
-
return b_path.length - a_path.length;
|
|
6003
|
-
}
|
|
6004
|
-
});
|
|
6005
|
-
this.cookies = this.cookies.filter(function (c) {
|
|
6006
|
-
return !c.expires || c.expires > new Date();
|
|
6007
|
-
});
|
|
6008
|
-
setTimeout(function () {
|
|
6009
|
-
this.persist();
|
|
6010
|
-
}.bind(this), 0);
|
|
6011
|
-
}
|
|
6012
|
-
}]);
|
|
4843
|
+
var XMLHttpRequestE = /*#__PURE__*/function () {
|
|
4844
|
+
return typeof XMLHttpRequest !== "undefined" && XMLHttpRequest || XMLHttpRequestP;
|
|
6013
4845
|
}();
|
|
6014
|
-
function fixUrl(url) {
|
|
6015
|
-
return validUrl.isUri(url) ? url : webSite.url.origin + (url.substring(0, 1) === "/" ? "" : "/") + url;
|
|
6016
|
-
}
|
|
6017
|
-
function isSameCookie(left, right) {
|
|
6018
|
-
return left.domain === right.domain && left.path === right.path && left.name === right.name;
|
|
6019
|
-
}
|
|
6020
|
-
function copyCookie(source) {
|
|
6021
|
-
var copy = {
|
|
6022
|
-
name: source.name,
|
|
6023
|
-
value: source.value
|
|
6024
|
-
};
|
|
6025
|
-
if (source.domain !== undefined) {
|
|
6026
|
-
copy.domain = source.domain;
|
|
6027
|
-
}
|
|
6028
|
-
if (source.path !== undefined) {
|
|
6029
|
-
copy.path = source.path;
|
|
6030
|
-
}
|
|
6031
|
-
if (source.expires !== undefined) {
|
|
6032
|
-
copy.expires = source.expires;
|
|
6033
|
-
}
|
|
6034
|
-
if (source.secure !== undefined) {
|
|
6035
|
-
copy.secure = source.secure;
|
|
6036
|
-
}
|
|
6037
|
-
if (source.sameSite !== undefined) {
|
|
6038
|
-
copy.sameSite = source.sameSite;
|
|
6039
|
-
}
|
|
6040
|
-
if (source.httpOnly !== undefined) {
|
|
6041
|
-
copy.httpOnly = source.httpOnly;
|
|
6042
|
-
}
|
|
6043
|
-
if (source.partitioned !== undefined) {
|
|
6044
|
-
copy.partitioned = source.partitioned;
|
|
6045
|
-
}
|
|
6046
|
-
return copy;
|
|
6047
|
-
}
|
|
6048
|
-
function prependDot(str) {
|
|
6049
|
-
return (str.substring(0, 1) === "." ? "" : ".") + str;
|
|
6050
|
-
}
|
|
6051
|
-
function appendSlash(str) {
|
|
6052
|
-
return str + (str.slice(-1) === "/" ? "" : "/");
|
|
6053
|
-
}
|
|
6054
|
-
function checkDomain(urlDomain, cookieDomain) {
|
|
6055
|
-
if (cookieDomain.split(".").filter(function (x) {
|
|
6056
|
-
return !!x;
|
|
6057
|
-
}).length < 2) {
|
|
6058
|
-
return urlDomain === cookieDomain;
|
|
6059
|
-
}
|
|
6060
|
-
var _urlDomain = prependDot(urlDomain);
|
|
6061
|
-
var _cookieDomain = prependDot(cookieDomain);
|
|
6062
|
-
return _urlDomain.slice(-_cookieDomain.length) === _cookieDomain;
|
|
6063
|
-
}
|
|
6064
|
-
function checkPath(urlPath, cookiePath) {
|
|
6065
|
-
var _urlPath = appendSlash(urlPath);
|
|
6066
|
-
var _cookiePath = appendSlash(cookiePath);
|
|
6067
|
-
return _urlPath.slice(0, _cookiePath.length) === _cookiePath;
|
|
6068
|
-
}
|
|
6069
|
-
function createCookieInstance() {
|
|
6070
|
-
if (!storage.value) {
|
|
6071
|
-
storage.value = new CookieStorage();
|
|
6072
|
-
}
|
|
6073
|
-
var cookieSupported = typeof document !== "undefined" && document && "cookie" in document;
|
|
6074
|
-
return {
|
|
6075
|
-
get: function get() {
|
|
6076
|
-
if (cookieSupported) return document.cookie;else return storage.value.getForUrl(true, webSite.url.href, false);
|
|
6077
|
-
},
|
|
6078
|
-
set: function set(cookie) {
|
|
6079
|
-
if (cookieSupported) document.cookie = cookie;else storage.value.setForUrl(true, webSite.url.href, false, cookie);
|
|
6080
|
-
}
|
|
6081
|
-
};
|
|
6082
|
-
}
|
|
6083
|
-
var Cookie = createCookieInstance();
|
|
6084
|
-
function enableCookie(url) {
|
|
6085
|
-
if (validUrl.isUri(url)) {
|
|
6086
|
-
webSite.url = new Url(url);
|
|
6087
|
-
}
|
|
6088
|
-
if (!storage.value) {
|
|
6089
|
-
storage.value = new CookieStorage();
|
|
6090
|
-
}
|
|
6091
|
-
if (!CookieAccessor.get && !CookieAccessor.set) {
|
|
6092
|
-
CookieAccessor.get = CookieStorage.prototype.getForUrl.bind(storage.value, false);
|
|
6093
|
-
CookieAccessor.set = CookieStorage.prototype.setForUrl.bind(storage.value, false);
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
4846
|
|
|
6097
|
-
var fetches = function () {
|
|
4847
|
+
var fetches = /*#__PURE__*/function () {
|
|
4848
|
+
// Mini Program requires explicit XHR assignment,
|
|
4849
|
+
// otherwise the polyfill won't be picked up.
|
|
6098
4850
|
setXMLHttpRequestClass(XMLHttpRequestE);
|
|
6099
|
-
return [fetchE$1
|
|
4851
|
+
return [fetchE$1 /* global */, fetchP /* polyfill */];
|
|
4852
|
+
}();
|
|
4853
|
+
var fetchE = /*#__PURE__*/function () {
|
|
4854
|
+
return fetches[0];
|
|
4855
|
+
}();
|
|
4856
|
+
var fetchPolyfill = /*#__PURE__*/function () {
|
|
4857
|
+
return fetches[1];
|
|
6100
4858
|
}();
|
|
6101
|
-
var fetchE = fetches[0];
|
|
6102
|
-
var fetchPolyfill = fetches[1];
|
|
6103
4859
|
|
|
6104
4860
|
var CloseEventP = /*#__PURE__*/function (_EventP, _Symbol$toStringTag) {
|
|
6105
4861
|
function CloseEventP(type, eventInitDict) {
|
|
@@ -6253,9 +5009,13 @@ function state$1(target) {
|
|
|
6253
5009
|
return target.__MessageEvent__;
|
|
6254
5010
|
}
|
|
6255
5011
|
|
|
6256
|
-
var platform = getPlatform();
|
|
5012
|
+
var platform = /*#__PURE__*/getPlatform();
|
|
6257
5013
|
function getConnectSocketFunc() {
|
|
6258
|
-
|
|
5014
|
+
var extractFn = function extractFn(platform) {
|
|
5015
|
+
var connectSocket = platform && platform.mp.connectSocket;
|
|
5016
|
+
return typeof connectSocket === "function" ? connectSocket.bind(platform.mp) : connectSocket;
|
|
5017
|
+
};
|
|
5018
|
+
return extractFn(platform) || function errorConnectSocket(options) {
|
|
6259
5019
|
return {
|
|
6260
5020
|
send: function send(obj) {},
|
|
6261
5021
|
close: function close(obj) {},
|
|
@@ -6263,16 +5023,22 @@ function getConnectSocketFunc() {
|
|
|
6263
5023
|
onMessage: function onMessage(listener) {},
|
|
6264
5024
|
onError: function onError(listener) {
|
|
6265
5025
|
if (typeof listener === "function") {
|
|
5026
|
+
// DOMException (NotSupportedError)
|
|
6266
5027
|
listener({
|
|
6267
|
-
errMsg: "NOT_SUPPORTED_ERR"
|
|
5028
|
+
errMsg: "NOT_SUPPORTED_ERR",
|
|
5029
|
+
errno: 9
|
|
6268
5030
|
});
|
|
5031
|
+
setTimeout(function () {
|
|
5032
|
+
throw new ReferenceError("connectSocket is not defined");
|
|
5033
|
+
}, 0);
|
|
6269
5034
|
}
|
|
6270
5035
|
},
|
|
6271
5036
|
onClose: function onClose(listener) {
|
|
6272
5037
|
if (typeof listener === "function") {
|
|
5038
|
+
// Alipay Mini Program (code: 1000, 3000~4999)
|
|
6273
5039
|
setTimeout(function () {
|
|
6274
5040
|
listener({
|
|
6275
|
-
code:
|
|
5041
|
+
code: 3000 + 9,
|
|
6276
5042
|
reason: "NOT_SUPPORTED_ERR"
|
|
6277
5043
|
});
|
|
6278
5044
|
}, 0);
|
|
@@ -6283,10 +5049,10 @@ function getConnectSocketFunc() {
|
|
|
6283
5049
|
}
|
|
6284
5050
|
|
|
6285
5051
|
var mp = {
|
|
6286
|
-
connectSocket: getConnectSocketFunc()
|
|
5052
|
+
connectSocket: /*#__PURE__*/getConnectSocketFunc()
|
|
6287
5053
|
};
|
|
6288
|
-
function setConnectSocketFunc(connectSocket) {
|
|
6289
|
-
mp.connectSocket = connectSocket;
|
|
5054
|
+
function setConnectSocketFunc(connectSocket, thisArg) {
|
|
5055
|
+
mp.connectSocket = typeof connectSocket === "function" && thisArg !== undefined ? connectSocket.bind(thisArg) : connectSocket;
|
|
6290
5056
|
}
|
|
6291
5057
|
var WebSocketP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
6292
5058
|
function WebSocketP(url, protocols) {
|
|
@@ -6396,12 +5162,8 @@ var WebSocketP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
|
6396
5162
|
key: "send",
|
|
6397
5163
|
value: function send(data) {
|
|
6398
5164
|
checkArgsLength(arguments.length, 1, "WebSocket", "send");
|
|
6399
|
-
if (this.readyState === 0 /* CONNECTING */)
|
|
6400
|
-
|
|
6401
|
-
}
|
|
6402
|
-
if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) {
|
|
6403
|
-
return console.error("WebSocket is already in CLOSING or CLOSED state.");
|
|
6404
|
-
}
|
|
5165
|
+
if (this.readyState === 0 /* CONNECTING */) throw new DOMExceptionE("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.", "InvalidStateError");
|
|
5166
|
+
if (this.readyState === 2 /* CLOSING */ || this.readyState === 3 /* CLOSED */) return console.error("WebSocket is already in CLOSING or CLOSED state.");
|
|
6405
5167
|
var _send = function (data) {
|
|
6406
5168
|
if (this.readyState === 1 /* OPEN */) {
|
|
6407
5169
|
state(this).socketTask.send({
|
|
@@ -6412,11 +5174,11 @@ var WebSocketP = /*#__PURE__*/function (_EventTargetP, _Symbol$toStringTag) {
|
|
|
6412
5174
|
});
|
|
6413
5175
|
}
|
|
6414
5176
|
}.bind(this);
|
|
6415
|
-
if (typeof data !== "string" && !isArrayBuffer(data) && !isBlob(data) && !
|
|
5177
|
+
if (typeof data !== "string" && !isArrayBuffer(data) && !isBlob(data) && !ArrayBuffer_isView(data)) {
|
|
6416
5178
|
return _send(data);
|
|
6417
5179
|
}
|
|
6418
|
-
var payload =
|
|
6419
|
-
payload.
|
|
5180
|
+
var payload = createPayload(data);
|
|
5181
|
+
payload.then(function (_data) {
|
|
6420
5182
|
_send(_data);
|
|
6421
5183
|
});
|
|
6422
5184
|
}
|
|
@@ -6533,6 +5295,19 @@ function getHandlers(t) {
|
|
|
6533
5295
|
function state(target) {
|
|
6534
5296
|
return target.__WebSocket__;
|
|
6535
5297
|
}
|
|
5298
|
+
function createPayload(data) {
|
|
5299
|
+
if (typeof data === "string") {
|
|
5300
|
+
return Promise.resolve(data);
|
|
5301
|
+
} else if (isArrayBuffer(data)) {
|
|
5302
|
+
return Promise.resolve(data.slice(0));
|
|
5303
|
+
} else if (ArrayBuffer_isView(data)) {
|
|
5304
|
+
return Promise.resolve(data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength));
|
|
5305
|
+
} else if (isBlob(data)) {
|
|
5306
|
+
return data.arrayBuffer();
|
|
5307
|
+
} else {
|
|
5308
|
+
return Promise.resolve("" + data);
|
|
5309
|
+
}
|
|
5310
|
+
}
|
|
6536
5311
|
function emitEvent(target, type) {
|
|
6537
5312
|
var event = new EventP(type);
|
|
6538
5313
|
// @ts-ignore
|
|
@@ -6599,6 +5374,8 @@ function onMessage(socket) {
|
|
|
6599
5374
|
EventTarget_dispatchEvent(socket, event);
|
|
6600
5375
|
});
|
|
6601
5376
|
}
|
|
6602
|
-
var WebSocketE =
|
|
5377
|
+
var WebSocketE = /*#__PURE__*/function () {
|
|
5378
|
+
return typeof WebSocket !== "undefined" && WebSocket || WebSocketP;
|
|
5379
|
+
}();
|
|
6603
5380
|
|
|
6604
|
-
export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP,
|
|
5381
|
+
export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP, CustomEventE as CustomEvent, CustomEventP, EventE as Event, EventP, EventTargetE as EventTarget, EventTargetP, FileE as File, FilePolyfill as FileP, FileReaderE as FileReader, FileReaderP, FormDataE as FormData, FormDataP, HeadersE as Headers, HeadersP, RequestE as Request, RequestP, ResponseE as Response, ResponseP, TextDecoderE as TextDecoder, TextDecoderP, TextEncoderE as TextEncoder, TextEncoderP, URLSearchParamsE as URLSearchParams, URLSearchParamsP, WebSocketE as WebSocket, WebSocketP, XMLHttpRequestE as XMLHttpRequest, XMLHttpRequestP, fetchE as fetch, fetchPolyfill as fetchP, fixFetch, fixWebSocket, fixXMLHttpRequest, getPlatform, setConnectSocketFunc, setFullOverride, setReadableStreamClass, setRequestFunc, setTextMode, setXMLHttpRequestClass, useCookie };
|