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