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