@wiajs/req 1.7.12 → 1.7.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web/req.mjs CHANGED
@@ -1,8 +1,1288 @@
1
1
  /*!
2
- * @wia/req v1.7.12
2
+ * @wia/req v1.7.13
3
3
  * (c) 2024 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
6
+ function bind$1(fn, thisArg) {
7
+ return function wrap() {
8
+ return fn.apply(thisArg, arguments);
9
+ };
10
+ }
11
+
12
+ // utils is a library of generic helper functions non-specific to axios
13
+
14
+ const {toString: toString$1} = Object.prototype;
15
+ const {getPrototypeOf: getPrototypeOf$1} = Object;
16
+
17
+ const kindOf$1 = (cache => thing => {
18
+ const str = toString$1.call(thing);
19
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
20
+ })(Object.create(null));
21
+
22
+ const kindOfTest$1 = (type) => {
23
+ type = type.toLowerCase();
24
+ return (thing) => kindOf$1(thing) === type
25
+ };
26
+
27
+ const typeOfTest$1 = type => thing => typeof thing === type;
28
+
29
+ /**
30
+ * Determine if a value is an Array
31
+ *
32
+ * @param {Object} val The value to test
33
+ *
34
+ * @returns {boolean} True if value is an Array, otherwise false
35
+ */
36
+ const {isArray: isArray$1} = Array;
37
+
38
+ /**
39
+ * Determine if a value is undefined
40
+ *
41
+ * @param {*} val The value to test
42
+ *
43
+ * @returns {boolean} True if the value is undefined, otherwise false
44
+ */
45
+ const isUndefined$1 = typeOfTest$1('undefined');
46
+
47
+ /**
48
+ * Determine if a value is a Buffer
49
+ *
50
+ * @param {*} val The value to test
51
+ *
52
+ * @returns {boolean} True if value is a Buffer, otherwise false
53
+ */
54
+ function isBuffer$1(val) {
55
+ return val !== null && !isUndefined$1(val) && val.constructor !== null && !isUndefined$1(val.constructor)
56
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
57
+ }
58
+
59
+ /**
60
+ * Determine if a value is an ArrayBuffer
61
+ *
62
+ * @param {*} val The value to test
63
+ *
64
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
65
+ */
66
+ const isArrayBuffer$1 = kindOfTest$1('ArrayBuffer');
67
+
68
+
69
+ /**
70
+ * Determine if a value is a view on an ArrayBuffer
71
+ *
72
+ * @param {*} val The value to test
73
+ *
74
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
75
+ */
76
+ function isArrayBufferView$1(val) {
77
+ let result;
78
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
79
+ result = ArrayBuffer.isView(val);
80
+ } else {
81
+ result = (val) && (val.buffer) && (isArrayBuffer$1(val.buffer));
82
+ }
83
+ return result;
84
+ }
85
+
86
+ /**
87
+ * Determine if a value is a String
88
+ *
89
+ * @param {*} val The value to test
90
+ *
91
+ * @returns {boolean} True if value is a String, otherwise false
92
+ */
93
+ const isString$1 = typeOfTest$1('string');
94
+
95
+ /**
96
+ * Determine if a value is a Function
97
+ *
98
+ * @param {*} val The value to test
99
+ * @returns {boolean} True if value is a Function, otherwise false
100
+ */
101
+ const isFunction$1 = typeOfTest$1('function');
102
+
103
+ /**
104
+ * Determine if a value is a Number
105
+ *
106
+ * @param {*} val The value to test
107
+ *
108
+ * @returns {boolean} True if value is a Number, otherwise false
109
+ */
110
+ const isNumber$1 = typeOfTest$1('number');
111
+
112
+ /**
113
+ * Determine if a value is an Object
114
+ *
115
+ * @param {*} thing The value to test
116
+ *
117
+ * @returns {boolean} True if value is an Object, otherwise false
118
+ */
119
+ const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
120
+
121
+ /**
122
+ * Determine if a value is a Boolean
123
+ *
124
+ * @param {*} thing The value to test
125
+ * @returns {boolean} True if value is a Boolean, otherwise false
126
+ */
127
+ const isBoolean$1 = thing => thing === true || thing === false;
128
+
129
+ /**
130
+ * Determine if a value is a plain Object
131
+ *
132
+ * @param {*} val The value to test
133
+ *
134
+ * @returns {boolean} True if value is a plain Object, otherwise false
135
+ */
136
+ const isPlainObject$1 = (val) => {
137
+ if (kindOf$1(val) !== 'object') {
138
+ return false;
139
+ }
140
+
141
+ const prototype = getPrototypeOf$1(val);
142
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
143
+ };
144
+
145
+ /**
146
+ * Determine if a value is a Date
147
+ *
148
+ * @param {*} val The value to test
149
+ *
150
+ * @returns {boolean} True if value is a Date, otherwise false
151
+ */
152
+ const isDate$1 = kindOfTest$1('Date');
153
+
154
+ /**
155
+ * Determine if a value is a File
156
+ *
157
+ * @param {*} val The value to test
158
+ *
159
+ * @returns {boolean} True if value is a File, otherwise false
160
+ */
161
+ const isFile$1 = kindOfTest$1('File');
162
+
163
+ /**
164
+ * Determine if a value is a Blob
165
+ *
166
+ * @param {*} val The value to test
167
+ *
168
+ * @returns {boolean} True if value is a Blob, otherwise false
169
+ */
170
+ const isBlob$1 = kindOfTest$1('Blob');
171
+
172
+ /**
173
+ * Determine if a value is a FileList
174
+ *
175
+ * @param {*} val The value to test
176
+ *
177
+ * @returns {boolean} True if value is a File, otherwise false
178
+ */
179
+ const isFileList$1 = kindOfTest$1('FileList');
180
+
181
+ /**
182
+ * Determine if a value is a Stream
183
+ *
184
+ * @param {*} val The value to test
185
+ *
186
+ * @returns {boolean} True if value is a Stream, otherwise false
187
+ */
188
+ const isStream$1 = (val) => isObject$1(val) && isFunction$1(val.pipe);
189
+
190
+ /**
191
+ * Determine if a value is a FormData
192
+ *
193
+ * @param {*} thing The value to test
194
+ *
195
+ * @returns {boolean} True if value is an FormData, otherwise false
196
+ */
197
+ const isFormData$1 = (thing) => {
198
+ let kind;
199
+ return thing && (
200
+ (typeof FormData === 'function' && thing instanceof FormData) || (
201
+ isFunction$1(thing.append) && (
202
+ (kind = kindOf$1(thing)) === 'formdata' ||
203
+ // detect form-data instance
204
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
205
+ )
206
+ )
207
+ )
208
+ };
209
+
210
+ /**
211
+ * Determine if a value is a URLSearchParams object
212
+ *
213
+ * @param {*} val The value to test
214
+ *
215
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
216
+ */
217
+ const isURLSearchParams$1 = kindOfTest$1('URLSearchParams');
218
+
219
+ const [isReadableStream$1, isRequest$1, isResponse$1, isHeaders$1] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest$1);
220
+
221
+ /**
222
+ * Trim excess whitespace off the beginning and end of a string
223
+ *
224
+ * @param {String} str The String to trim
225
+ *
226
+ * @returns {String} The String freed of excess whitespace
227
+ */
228
+ const trim$1 = (str) => str.trim ?
229
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
230
+
231
+ /**
232
+ * Iterate over an Array or an Object invoking a function for each item.
233
+ *
234
+ * If `obj` is an Array callback will be called passing
235
+ * the value, index, and complete array for each item.
236
+ *
237
+ * If 'obj' is an Object callback will be called passing
238
+ * the value, key, and complete object for each property.
239
+ *
240
+ * @param {Object|Array} obj The object to iterate
241
+ * @param {Function} fn The callback to invoke for each item
242
+ *
243
+ * @param {Boolean} [allOwnKeys = false]
244
+ * @returns {any}
245
+ */
246
+ function forEach$1(obj, fn, {allOwnKeys = false} = {}) {
247
+ // Don't bother if no value provided
248
+ if (obj === null || typeof obj === 'undefined') {
249
+ return;
250
+ }
251
+
252
+ let i;
253
+ let l;
254
+
255
+ // Force an array if not already something iterable
256
+ if (typeof obj !== 'object') {
257
+ /*eslint no-param-reassign:0*/
258
+ obj = [obj];
259
+ }
260
+
261
+ if (isArray$1(obj)) {
262
+ // Iterate over array values
263
+ for (i = 0, l = obj.length; i < l; i++) {
264
+ fn.call(null, obj[i], i, obj);
265
+ }
266
+ } else {
267
+ // Iterate over object keys
268
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
269
+ const len = keys.length;
270
+ let key;
271
+
272
+ for (i = 0; i < len; i++) {
273
+ key = keys[i];
274
+ fn.call(null, obj[key], key, obj);
275
+ }
276
+ }
277
+ }
278
+
279
+ function findKey$1(obj, key) {
280
+ key = key.toLowerCase();
281
+ const keys = Object.keys(obj);
282
+ let i = keys.length;
283
+ let _key;
284
+ while (i-- > 0) {
285
+ _key = keys[i];
286
+ if (key === _key.toLowerCase()) {
287
+ return _key;
288
+ }
289
+ }
290
+ return null;
291
+ }
292
+
293
+ const _global$1 = (() => {
294
+ /*eslint no-undef:0*/
295
+ if (typeof globalThis !== "undefined") return globalThis;
296
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
297
+ })();
298
+
299
+ const isContextDefined$1 = (context) => !isUndefined$1(context) && context !== _global$1;
300
+
301
+ /**
302
+ * Accepts varargs expecting each argument to be an object, then
303
+ * immutably merges the properties of each object and returns result.
304
+ *
305
+ * When multiple objects contain the same key the later object in
306
+ * the arguments list will take precedence.
307
+ *
308
+ * Example:
309
+ *
310
+ * ```js
311
+ * var result = merge({foo: 123}, {foo: 456});
312
+ * console.log(result.foo); // outputs 456
313
+ * ```
314
+ *
315
+ * @param {Object} obj1 Object to merge
316
+ *
317
+ * @returns {Object} Result of all merge properties
318
+ */
319
+ function merge$1(/* obj1, obj2, obj3, ... */) {
320
+ const {caseless} = isContextDefined$1(this) && this || {};
321
+ const result = {};
322
+ const assignValue = (val, key) => {
323
+ const targetKey = caseless && findKey$1(result, key) || key;
324
+ if (isPlainObject$1(result[targetKey]) && isPlainObject$1(val)) {
325
+ result[targetKey] = merge$1(result[targetKey], val);
326
+ } else if (isPlainObject$1(val)) {
327
+ result[targetKey] = merge$1({}, val);
328
+ } else if (isArray$1(val)) {
329
+ result[targetKey] = val.slice();
330
+ } else {
331
+ result[targetKey] = val;
332
+ }
333
+ };
334
+
335
+ for (let i = 0, l = arguments.length; i < l; i++) {
336
+ arguments[i] && forEach$1(arguments[i], assignValue);
337
+ }
338
+ return result;
339
+ }
340
+
341
+ /**
342
+ * Extends object a by mutably adding to it the properties of object b.
343
+ *
344
+ * @param {Object} a The object to be extended
345
+ * @param {Object} b The object to copy properties from
346
+ * @param {Object} thisArg The object to bind function to
347
+ *
348
+ * @param {Boolean} [allOwnKeys]
349
+ * @returns {Object} The resulting value of object a
350
+ */
351
+ const extend$1 = (a, b, thisArg, {allOwnKeys} = {}) => {
352
+ forEach$1(b, (val, key) => {
353
+ if (thisArg && isFunction$1(val)) {
354
+ a[key] = bind$1(val, thisArg);
355
+ } else {
356
+ a[key] = val;
357
+ }
358
+ }, {allOwnKeys});
359
+ return a;
360
+ };
361
+
362
+ /**
363
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
364
+ *
365
+ * @param {string} content with BOM
366
+ *
367
+ * @returns {string} content value without BOM
368
+ */
369
+ const stripBOM$1 = (content) => {
370
+ if (content.charCodeAt(0) === 0xFEFF) {
371
+ content = content.slice(1);
372
+ }
373
+ return content;
374
+ };
375
+
376
+ /**
377
+ * Inherit the prototype methods from one constructor into another
378
+ * @param {function} constructor
379
+ * @param {function} superConstructor
380
+ * @param {object} [props]
381
+ * @param {object} [descriptors]
382
+ *
383
+ * @returns {void}
384
+ */
385
+ const inherits$1 = (constructor, superConstructor, props, descriptors) => {
386
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
387
+ constructor.prototype.constructor = constructor;
388
+ Object.defineProperty(constructor, 'super', {
389
+ value: superConstructor.prototype
390
+ });
391
+ props && Object.assign(constructor.prototype, props);
392
+ };
393
+
394
+ /**
395
+ * Resolve object with deep prototype chain to a flat object
396
+ * @param {Object} sourceObj source object
397
+ * @param {Object} [destObj]
398
+ * @param {Function|Boolean} [filter]
399
+ * @param {Function} [propFilter]
400
+ *
401
+ * @returns {Object}
402
+ */
403
+ const toFlatObject$1 = (sourceObj, destObj, filter, propFilter) => {
404
+ let props;
405
+ let i;
406
+ let prop;
407
+ const merged = {};
408
+
409
+ destObj = destObj || {};
410
+ // eslint-disable-next-line no-eq-null,eqeqeq
411
+ if (sourceObj == null) return destObj;
412
+
413
+ do {
414
+ props = Object.getOwnPropertyNames(sourceObj);
415
+ i = props.length;
416
+ while (i-- > 0) {
417
+ prop = props[i];
418
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
419
+ destObj[prop] = sourceObj[prop];
420
+ merged[prop] = true;
421
+ }
422
+ }
423
+ sourceObj = filter !== false && getPrototypeOf$1(sourceObj);
424
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
425
+
426
+ return destObj;
427
+ };
428
+
429
+ /**
430
+ * Determines whether a string ends with the characters of a specified string
431
+ *
432
+ * @param {String} str
433
+ * @param {String} searchString
434
+ * @param {Number} [position= 0]
435
+ *
436
+ * @returns {boolean}
437
+ */
438
+ const endsWith$1 = (str, searchString, position) => {
439
+ str = String(str);
440
+ if (position === undefined || position > str.length) {
441
+ position = str.length;
442
+ }
443
+ position -= searchString.length;
444
+ const lastIndex = str.indexOf(searchString, position);
445
+ return lastIndex !== -1 && lastIndex === position;
446
+ };
447
+
448
+
449
+ /**
450
+ * Returns new array from array like object or null if failed
451
+ *
452
+ * @param {*} [thing]
453
+ *
454
+ * @returns {?Array}
455
+ */
456
+ const toArray$1 = (thing) => {
457
+ if (!thing) return null;
458
+ if (isArray$1(thing)) return thing;
459
+ let i = thing.length;
460
+ if (!isNumber$1(i)) return null;
461
+ const arr = new Array(i);
462
+ while (i-- > 0) {
463
+ arr[i] = thing[i];
464
+ }
465
+ return arr;
466
+ };
467
+
468
+ /**
469
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
470
+ * thing passed in is an instance of Uint8Array
471
+ *
472
+ * @param {TypedArray}
473
+ *
474
+ * @returns {Array}
475
+ */
476
+ // eslint-disable-next-line func-names
477
+ const isTypedArray$1 = (TypedArray => {
478
+ // eslint-disable-next-line func-names
479
+ return thing => {
480
+ return TypedArray && thing instanceof TypedArray;
481
+ };
482
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf$1(Uint8Array));
483
+
484
+ /**
485
+ * For each entry in the object, call the function with the key and value.
486
+ *
487
+ * @param {Object<any, any>} obj - The object to iterate over.
488
+ * @param {Function} fn - The function to call for each entry.
489
+ *
490
+ * @returns {void}
491
+ */
492
+ const forEachEntry$1 = (obj, fn) => {
493
+ const generator = obj && obj[Symbol.iterator];
494
+
495
+ const iterator = generator.call(obj);
496
+
497
+ let result;
498
+
499
+ while ((result = iterator.next()) && !result.done) {
500
+ const pair = result.value;
501
+ fn.call(obj, pair[0], pair[1]);
502
+ }
503
+ };
504
+
505
+ /**
506
+ * It takes a regular expression and a string, and returns an array of all the matches
507
+ *
508
+ * @param {string} regExp - The regular expression to match against.
509
+ * @param {string} str - The string to search.
510
+ *
511
+ * @returns {Array<boolean>}
512
+ */
513
+ const matchAll$1 = (regExp, str) => {
514
+ let matches;
515
+ const arr = [];
516
+
517
+ while ((matches = regExp.exec(str)) !== null) {
518
+ arr.push(matches);
519
+ }
520
+
521
+ return arr;
522
+ };
523
+
524
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
525
+ const isHTMLForm$1 = kindOfTest$1('HTMLFormElement');
526
+
527
+ const toCamelCase$1 = str => {
528
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
529
+ function replacer(m, p1, p2) {
530
+ return p1.toUpperCase() + p2;
531
+ }
532
+ );
533
+ };
534
+
535
+ /* Creating a function that will check if an object has a property. */
536
+ const hasOwnProperty$1 = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
537
+
538
+ /**
539
+ * Determine if a value is a RegExp object
540
+ *
541
+ * @param {*} val The value to test
542
+ *
543
+ * @returns {boolean} True if value is a RegExp object, otherwise false
544
+ */
545
+ const isRegExp$1 = kindOfTest$1('RegExp');
546
+
547
+ const reduceDescriptors$1 = (obj, reducer) => {
548
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
549
+ const reducedDescriptors = {};
550
+
551
+ forEach$1(descriptors, (descriptor, name) => {
552
+ let ret;
553
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
554
+ reducedDescriptors[name] = ret || descriptor;
555
+ }
556
+ });
557
+
558
+ Object.defineProperties(obj, reducedDescriptors);
559
+ };
560
+
561
+ /**
562
+ * Makes all methods read-only
563
+ * @param {Object} obj
564
+ */
565
+
566
+ const freezeMethods$1 = (obj) => {
567
+ reduceDescriptors$1(obj, (descriptor, name) => {
568
+ // skip restricted props in strict mode
569
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
570
+ return false;
571
+ }
572
+
573
+ const value = obj[name];
574
+
575
+ if (!isFunction$1(value)) return;
576
+
577
+ descriptor.enumerable = false;
578
+
579
+ if ('writable' in descriptor) {
580
+ descriptor.writable = false;
581
+ return;
582
+ }
583
+
584
+ if (!descriptor.set) {
585
+ descriptor.set = () => {
586
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
587
+ };
588
+ }
589
+ });
590
+ };
591
+
592
+ const toObjectSet$1 = (arrayOrString, delimiter) => {
593
+ const obj = {};
594
+
595
+ const define = (arr) => {
596
+ arr.forEach(value => {
597
+ obj[value] = true;
598
+ });
599
+ };
600
+
601
+ isArray$1(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
602
+
603
+ return obj;
604
+ };
605
+
606
+ const noop$1 = () => {};
607
+
608
+ const toFiniteNumber$1 = (value, defaultValue) => {
609
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
610
+ };
611
+
612
+ const ALPHA$1 = 'abcdefghijklmnopqrstuvwxyz';
613
+
614
+ const DIGIT$1 = '0123456789';
615
+
616
+ const ALPHABET$1 = {
617
+ DIGIT: DIGIT$1,
618
+ ALPHA: ALPHA$1,
619
+ ALPHA_DIGIT: ALPHA$1 + ALPHA$1.toUpperCase() + DIGIT$1
620
+ };
621
+
622
+ const generateString$1 = (size = 16, alphabet = ALPHABET$1.ALPHA_DIGIT) => {
623
+ let str = '';
624
+ const {length} = alphabet;
625
+ while (size--) {
626
+ str += alphabet[Math.random() * length|0];
627
+ }
628
+
629
+ return str;
630
+ };
631
+
632
+ /**
633
+ * If the thing is a FormData object, return true, otherwise return false.
634
+ *
635
+ * @param {unknown} thing - The thing to check.
636
+ *
637
+ * @returns {boolean}
638
+ */
639
+ function isSpecCompliantForm$1(thing) {
640
+ return !!(thing && isFunction$1(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
641
+ }
642
+
643
+ const toJSONObject$1 = (obj) => {
644
+ const stack = new Array(10);
645
+
646
+ const visit = (source, i) => {
647
+
648
+ if (isObject$1(source)) {
649
+ if (stack.indexOf(source) >= 0) {
650
+ return;
651
+ }
652
+
653
+ if (!('toJSON' in source)) {
654
+ stack[i] = source;
655
+ const target = isArray$1(source) ? [] : {};
656
+
657
+ forEach$1(source, (value, key) => {
658
+ const reducedValue = visit(value, i + 1);
659
+ !isUndefined$1(reducedValue) && (target[key] = reducedValue);
660
+ });
661
+
662
+ stack[i] = undefined;
663
+
664
+ return target;
665
+ }
666
+ }
667
+
668
+ return source;
669
+ };
670
+
671
+ return visit(obj, 0);
672
+ };
673
+
674
+ const isAsyncFn$1 = kindOfTest$1('AsyncFunction');
675
+
676
+ const isThenable$1 = (thing) =>
677
+ thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
678
+
679
+ // original code
680
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
681
+
682
+ const _setImmediate$1 = ((setImmediateSupported, postMessageSupported) => {
683
+ if (setImmediateSupported) {
684
+ return setImmediate;
685
+ }
686
+
687
+ return postMessageSupported ? ((token, callbacks) => {
688
+ _global$1.addEventListener("message", ({source, data}) => {
689
+ if (source === _global$1 && data === token) {
690
+ callbacks.length && callbacks.shift()();
691
+ }
692
+ }, false);
693
+
694
+ return (cb) => {
695
+ callbacks.push(cb);
696
+ _global$1.postMessage(token, "*");
697
+ }
698
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
699
+ })(
700
+ typeof setImmediate === 'function',
701
+ isFunction$1(_global$1.postMessage)
702
+ );
703
+
704
+ const asap$1 = typeof queueMicrotask !== 'undefined' ?
705
+ queueMicrotask.bind(_global$1) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate$1);
706
+
707
+
708
+ function createErrorType$1(code, message, baseClass) {
709
+ // Create constructor
710
+ function CustomError(properties) {
711
+ Error.captureStackTrace(this, this.constructor);
712
+ Object.assign(this, properties || {});
713
+ this.code = code;
714
+ this.message = this.cause ? `${message}: ${this.cause.message}` : message;
715
+ }
716
+
717
+ // Attach constructor and set default properties
718
+ CustomError.prototype = new (baseClass || Error)();
719
+ CustomError.prototype.constructor = CustomError;
720
+ CustomError.prototype.name = `Error [${code}]`;
721
+ return CustomError;
722
+ }
723
+
724
+
725
+ // *********************
726
+
727
+ const utils$2 = {
728
+ isArray: isArray$1,
729
+ isArrayBuffer: isArrayBuffer$1,
730
+ isBuffer: isBuffer$1,
731
+ isFormData: isFormData$1,
732
+ isArrayBufferView: isArrayBufferView$1,
733
+ isString: isString$1,
734
+ isNumber: isNumber$1,
735
+ isBoolean: isBoolean$1,
736
+ isObject: isObject$1,
737
+ isPlainObject: isPlainObject$1,
738
+ isReadableStream: isReadableStream$1,
739
+ isRequest: isRequest$1,
740
+ isResponse: isResponse$1,
741
+ isHeaders: isHeaders$1,
742
+ isUndefined: isUndefined$1,
743
+ isDate: isDate$1,
744
+ isFile: isFile$1,
745
+ isBlob: isBlob$1,
746
+ isRegExp: isRegExp$1,
747
+ isFunction: isFunction$1,
748
+ isStream: isStream$1,
749
+ isURLSearchParams: isURLSearchParams$1,
750
+ isTypedArray: isTypedArray$1,
751
+ isFileList: isFileList$1,
752
+ forEach: forEach$1,
753
+ merge: merge$1,
754
+ extend: extend$1,
755
+ trim: trim$1,
756
+ stripBOM: stripBOM$1,
757
+ inherits: inherits$1,
758
+ toFlatObject: toFlatObject$1,
759
+ kindOf: kindOf$1,
760
+ kindOfTest: kindOfTest$1,
761
+ endsWith: endsWith$1,
762
+ toArray: toArray$1,
763
+ forEachEntry: forEachEntry$1,
764
+ matchAll: matchAll$1,
765
+ isHTMLForm: isHTMLForm$1,
766
+ hasOwnProperty: hasOwnProperty$1,
767
+ hasOwnProp: hasOwnProperty$1, // an alias to avoid ESLint no-prototype-builtins detection
768
+ reduceDescriptors: reduceDescriptors$1,
769
+ freezeMethods: freezeMethods$1,
770
+ toObjectSet: toObjectSet$1,
771
+ toCamelCase: toCamelCase$1,
772
+ noop: noop$1,
773
+ toFiniteNumber: toFiniteNumber$1,
774
+ findKey: findKey$1,
775
+ global: _global$1,
776
+ isContextDefined: isContextDefined$1,
777
+ ALPHABET: ALPHABET$1,
778
+ generateString: generateString$1,
779
+ isSpecCompliantForm: isSpecCompliantForm$1,
780
+ toJSONObject: toJSONObject$1,
781
+ isAsyncFn: isAsyncFn$1,
782
+ isThenable: isThenable$1,
783
+ setImmediate: _setImmediate$1,
784
+ asap: asap$1,
785
+ createErrorType: createErrorType$1
786
+ };
787
+
788
+ /**
789
+ * Create an Error with the specified message, config, error code, request and response.
790
+ *
791
+ * @param {string} message The error message.
792
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
793
+ * @param {Object} [config] The config.
794
+ * @param {Object} [request] The request.
795
+ * @param {Object} [response] The response.
796
+ *
797
+ * @returns {Error} The created error.
798
+ */
799
+ function AxiosError$2(message, code, config, request, response) {
800
+ Error.call(this);
801
+
802
+ if (Error.captureStackTrace) {
803
+ Error.captureStackTrace(this, this.constructor);
804
+ } else {
805
+ this.stack = (new Error()).stack;
806
+ }
807
+
808
+ this.message = message;
809
+ this.name = 'AxiosError';
810
+ code && (this.code = code);
811
+ config && (this.config = config);
812
+ request && (this.request = request);
813
+ if (response) {
814
+ this.response = response;
815
+ this.status = response.status ? response.status : null;
816
+ }
817
+ }
818
+
819
+ utils$2.inherits(AxiosError$2, Error, {
820
+ toJSON: function toJSON() {
821
+ return {
822
+ // Standard
823
+ message: this.message,
824
+ name: this.name,
825
+ // Microsoft
826
+ description: this.description,
827
+ number: this.number,
828
+ // Mozilla
829
+ fileName: this.fileName,
830
+ lineNumber: this.lineNumber,
831
+ columnNumber: this.columnNumber,
832
+ stack: this.stack,
833
+ // Axios
834
+ config: utils$2.toJSONObject(this.config),
835
+ code: this.code,
836
+ status: this.status
837
+ };
838
+ }
839
+ });
840
+
841
+ const prototype$3 = AxiosError$2.prototype;
842
+ const descriptors$1 = {};
843
+
844
+ [
845
+ 'ERR_BAD_OPTION_VALUE',
846
+ 'ERR_BAD_OPTION',
847
+ 'ECONNABORTED',
848
+ 'ETIMEDOUT',
849
+ 'ERR_NETWORK',
850
+ 'ERR_FR_TOO_MANY_REDIRECTS',
851
+ 'ERR_DEPRECATED',
852
+ 'ERR_BAD_RESPONSE',
853
+ 'ERR_BAD_REQUEST',
854
+ 'ERR_CANCELED',
855
+ 'ERR_NOT_SUPPORT',
856
+ 'ERR_INVALID_URL'
857
+ // eslint-disable-next-line func-names
858
+ ].forEach(code => {
859
+ descriptors$1[code] = {value: code};
860
+ });
861
+
862
+ Object.defineProperties(AxiosError$2, descriptors$1);
863
+ Object.defineProperty(prototype$3, 'isAxiosError', {value: true});
864
+
865
+ // eslint-disable-next-line func-names
866
+ AxiosError$2.from = (error, code, config, request, response, customProps) => {
867
+ const axiosError = Object.create(prototype$3);
868
+
869
+ utils$2.toFlatObject(error, axiosError, function filter(obj) {
870
+ return obj !== Error.prototype;
871
+ }, prop => {
872
+ return prop !== 'isAxiosError';
873
+ });
874
+
875
+ AxiosError$2.call(axiosError, error.message, code, config, request, response);
876
+
877
+ axiosError.cause = error;
878
+
879
+ axiosError.name = error.name;
880
+
881
+ customProps && Object.assign(axiosError, customProps);
882
+
883
+ return axiosError;
884
+ };
885
+
886
+ // eslint-disable-next-line strict
887
+ const HttpAdapter = null;
888
+
889
+ /**
890
+ * Determines if the given thing is a array or js object.
891
+ *
892
+ * @param {string} thing - The object or array to be visited.
893
+ *
894
+ * @returns {boolean}
895
+ */
896
+ function isVisitable$1(thing) {
897
+ return utils$2.isPlainObject(thing) || utils$2.isArray(thing);
898
+ }
899
+
900
+ /**
901
+ * It removes the brackets from the end of a string
902
+ *
903
+ * @param {string} key - The key of the parameter.
904
+ *
905
+ * @returns {string} the key without the brackets.
906
+ */
907
+ function removeBrackets$1(key) {
908
+ return utils$2.endsWith(key, '[]') ? key.slice(0, -2) : key;
909
+ }
910
+
911
+ /**
912
+ * It takes a path, a key, and a boolean, and returns a string
913
+ *
914
+ * @param {string} path - The path to the current key.
915
+ * @param {string} key - The key of the current object being iterated over.
916
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
917
+ *
918
+ * @returns {string} The path to the current key.
919
+ */
920
+ function renderKey$1(path, key, dots) {
921
+ if (!path) return key;
922
+ return path.concat(key).map(function each(token, i) {
923
+ // eslint-disable-next-line no-param-reassign
924
+ token = removeBrackets$1(token);
925
+ return !dots && i ? '[' + token + ']' : token;
926
+ }).join(dots ? '.' : '');
927
+ }
928
+
929
+ /**
930
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
931
+ *
932
+ * @param {Array<any>} arr - The array to check
933
+ *
934
+ * @returns {boolean}
935
+ */
936
+ function isFlatArray$1(arr) {
937
+ return utils$2.isArray(arr) && !arr.some(isVisitable$1);
938
+ }
939
+
940
+ const predicates$1 = utils$2.toFlatObject(utils$2, {}, null, function filter(prop) {
941
+ return /^is[A-Z]/.test(prop);
942
+ });
943
+
944
+ /**
945
+ * Convert a data object to FormData
946
+ *
947
+ * @param {Object} obj
948
+ * @param {?Object} [formData]
949
+ * @param {?Object} [options]
950
+ * @param {Function} [options.visitor]
951
+ * @param {Boolean} [options.metaTokens = true]
952
+ * @param {Boolean} [options.dots = false]
953
+ * @param {?Boolean} [options.indexes = false]
954
+ *
955
+ * @returns {Object}
956
+ **/
957
+
958
+ /**
959
+ * It converts an object into a FormData object
960
+ *
961
+ * @param {Object<any, any>} obj - The object to convert to form data.
962
+ * @param {string} formData - The FormData object to append to.
963
+ * @param {Object<string, any>} options
964
+ *
965
+ * @returns
966
+ */
967
+ function toFormData$2(obj, formData, options) {
968
+ if (!utils$2.isObject(obj)) {
969
+ throw new TypeError('target must be an object');
970
+ }
971
+
972
+ // eslint-disable-next-line no-param-reassign
973
+ formData = formData || new (FormData)();
974
+
975
+ // eslint-disable-next-line no-param-reassign
976
+ options = utils$2.toFlatObject(options, {
977
+ metaTokens: true,
978
+ dots: false,
979
+ indexes: false
980
+ }, false, function defined(option, source) {
981
+ // eslint-disable-next-line no-eq-null,eqeqeq
982
+ return !utils$2.isUndefined(source[option]);
983
+ });
984
+
985
+ const metaTokens = options.metaTokens;
986
+ // eslint-disable-next-line no-use-before-define
987
+ const visitor = options.visitor || defaultVisitor;
988
+ const dots = options.dots;
989
+ const indexes = options.indexes;
990
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
991
+ const useBlob = _Blob && utils$2.isSpecCompliantForm(formData);
992
+
993
+ if (!utils$2.isFunction(visitor)) {
994
+ throw new TypeError('visitor must be a function');
995
+ }
996
+
997
+ function convertValue(value) {
998
+ if (value === null) return '';
999
+
1000
+ if (utils$2.isDate(value)) {
1001
+ return value.toISOString();
1002
+ }
1003
+
1004
+ if (!useBlob && utils$2.isBlob(value)) {
1005
+ throw new AxiosError$2('Blob is not supported. Use a Buffer instead.');
1006
+ }
1007
+
1008
+ if (utils$2.isArrayBuffer(value) || utils$2.isTypedArray(value)) {
1009
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1010
+ }
1011
+
1012
+ return value;
1013
+ }
1014
+
1015
+ /**
1016
+ * Default visitor.
1017
+ *
1018
+ * @param {*} value
1019
+ * @param {String|Number} key
1020
+ * @param {Array<String|Number>} path
1021
+ * @this {FormData}
1022
+ *
1023
+ * @returns {boolean} return true to visit the each prop of the value recursively
1024
+ */
1025
+ function defaultVisitor(value, key, path) {
1026
+ let arr = value;
1027
+
1028
+ if (value && !path && typeof value === 'object') {
1029
+ if (utils$2.endsWith(key, '{}')) {
1030
+ // eslint-disable-next-line no-param-reassign
1031
+ key = metaTokens ? key : key.slice(0, -2);
1032
+ // eslint-disable-next-line no-param-reassign
1033
+ value = JSON.stringify(value);
1034
+ } else if (
1035
+ (utils$2.isArray(value) && isFlatArray$1(value)) ||
1036
+ ((utils$2.isFileList(value) || utils$2.endsWith(key, '[]')) && (arr = utils$2.toArray(value))
1037
+ )) {
1038
+ // eslint-disable-next-line no-param-reassign
1039
+ key = removeBrackets$1(key);
1040
+
1041
+ arr.forEach(function each(el, index) {
1042
+ !(utils$2.isUndefined(el) || el === null) && formData.append(
1043
+ // eslint-disable-next-line no-nested-ternary
1044
+ indexes === true ? renderKey$1([key], index, dots) : (indexes === null ? key : key + '[]'),
1045
+ convertValue(el)
1046
+ );
1047
+ });
1048
+ return false;
1049
+ }
1050
+ }
1051
+
1052
+ if (isVisitable$1(value)) {
1053
+ return true;
1054
+ }
1055
+
1056
+ formData.append(renderKey$1(path, key, dots), convertValue(value));
1057
+
1058
+ return false;
1059
+ }
1060
+
1061
+ const stack = [];
1062
+
1063
+ const exposedHelpers = Object.assign(predicates$1, {
1064
+ defaultVisitor,
1065
+ convertValue,
1066
+ isVisitable: isVisitable$1
1067
+ });
1068
+
1069
+ function build(value, path) {
1070
+ if (utils$2.isUndefined(value)) return;
1071
+
1072
+ if (stack.indexOf(value) !== -1) {
1073
+ throw Error('Circular reference detected in ' + path.join('.'));
1074
+ }
1075
+
1076
+ stack.push(value);
1077
+
1078
+ utils$2.forEach(value, function each(el, key) {
1079
+ const result = !(utils$2.isUndefined(el) || el === null) && visitor.call(
1080
+ formData, el, utils$2.isString(key) ? key.trim() : key, path, exposedHelpers
1081
+ );
1082
+
1083
+ if (result === true) {
1084
+ build(el, path ? path.concat(key) : [key]);
1085
+ }
1086
+ });
1087
+
1088
+ stack.pop();
1089
+ }
1090
+
1091
+ if (!utils$2.isObject(obj)) {
1092
+ throw new TypeError('data must be an object');
1093
+ }
1094
+
1095
+ build(obj);
1096
+
1097
+ return formData;
1098
+ }
1099
+
1100
+ /**
1101
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1102
+ * their percent-encoded equivalents
1103
+ *
1104
+ * @param {string} str - The string to encode.
1105
+ *
1106
+ * @returns {string} The encoded string.
1107
+ */
1108
+ function encode$2(str) {
1109
+ const charMap = {
1110
+ '!': '%21',
1111
+ "'": '%27',
1112
+ '(': '%28',
1113
+ ')': '%29',
1114
+ '~': '%7E',
1115
+ '%20': '+',
1116
+ '%00': '\x00'
1117
+ };
1118
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1119
+ return charMap[match];
1120
+ });
1121
+ }
1122
+
1123
+ /**
1124
+ * It takes a params object and converts it to a FormData object
1125
+ *
1126
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1127
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1128
+ *
1129
+ * @returns {void}
1130
+ */
1131
+ function AxiosURLSearchParams$1(params, options) {
1132
+ this._pairs = [];
1133
+
1134
+ params && toFormData$2(params, this, options);
1135
+ }
1136
+
1137
+ const prototype$2 = AxiosURLSearchParams$1.prototype;
1138
+
1139
+ prototype$2.append = function append(name, value) {
1140
+ this._pairs.push([name, value]);
1141
+ };
1142
+
1143
+ prototype$2.toString = function toString(encoder) {
1144
+ const _encode = encoder ? function(value) {
1145
+ return encoder.call(this, value, encode$2);
1146
+ } : encode$2;
1147
+
1148
+ return this._pairs.map(function each(pair) {
1149
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1150
+ }, '').join('&');
1151
+ };
1152
+
1153
+ /**
1154
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1155
+ * URI encoded counterparts
1156
+ *
1157
+ * @param {string} val The value to be encoded.
1158
+ *
1159
+ * @returns {string} The encoded value.
1160
+ */
1161
+ function encode$1(val) {
1162
+ return encodeURIComponent(val).
1163
+ replace(/%3A/gi, ':').
1164
+ replace(/%24/g, '$').
1165
+ replace(/%2C/gi, ',').
1166
+ replace(/%20/g, '+').
1167
+ replace(/%5B/gi, '[').
1168
+ replace(/%5D/gi, ']');
1169
+ }
1170
+
1171
+ /**
1172
+ * Build a URL by appending params to the end
1173
+ *
1174
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1175
+ * @param {object} [params] The params to be appended
1176
+ * @param {?object} options
1177
+ *
1178
+ * @returns {string} The formatted url
1179
+ */
1180
+ function buildURL(url, params, options) {
1181
+ /*eslint no-param-reassign:0*/
1182
+ if (!params) {
1183
+ return url;
1184
+ }
1185
+
1186
+ const _encode = options && options.encode || encode$1;
1187
+
1188
+ const serializeFn = options && options.serialize;
1189
+
1190
+ let serializedParams;
1191
+
1192
+ if (serializeFn) {
1193
+ serializedParams = serializeFn(params, options);
1194
+ } else {
1195
+ serializedParams = utils$2.isURLSearchParams(params) ?
1196
+ params.toString() :
1197
+ new AxiosURLSearchParams$1(params, options).toString(_encode);
1198
+ }
1199
+
1200
+ if (serializedParams) {
1201
+ const hashmarkIndex = url.indexOf("#");
1202
+
1203
+ if (hashmarkIndex !== -1) {
1204
+ url = url.slice(0, hashmarkIndex);
1205
+ }
1206
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1207
+ }
1208
+
1209
+ return url;
1210
+ }
1211
+
1212
+ class InterceptorManager {
1213
+ constructor() {
1214
+ this.handlers = [];
1215
+ }
1216
+
1217
+ /**
1218
+ * Add a new interceptor to the stack
1219
+ *
1220
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1221
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1222
+ *
1223
+ * @return {Number} An ID used to remove interceptor later
1224
+ */
1225
+ use(fulfilled, rejected, options) {
1226
+ this.handlers.push({
1227
+ fulfilled,
1228
+ rejected,
1229
+ synchronous: options ? options.synchronous : false,
1230
+ runWhen: options ? options.runWhen : null
1231
+ });
1232
+ return this.handlers.length - 1;
1233
+ }
1234
+
1235
+ /**
1236
+ * Remove an interceptor from the stack
1237
+ *
1238
+ * @param {Number} id The ID that was returned by `use`
1239
+ *
1240
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1241
+ */
1242
+ eject(id) {
1243
+ if (this.handlers[id]) {
1244
+ this.handlers[id] = null;
1245
+ }
1246
+ }
1247
+
1248
+ /**
1249
+ * Clear all interceptors from the stack
1250
+ *
1251
+ * @returns {void}
1252
+ */
1253
+ clear() {
1254
+ if (this.handlers) {
1255
+ this.handlers = [];
1256
+ }
1257
+ }
1258
+
1259
+ /**
1260
+ * Iterate over all the registered interceptors
1261
+ *
1262
+ * This method is particularly useful for skipping over any
1263
+ * interceptors that may have become `null` calling `eject`.
1264
+ *
1265
+ * @param {Function} fn The function to call for each interceptor
1266
+ *
1267
+ * @returns {void}
1268
+ */
1269
+ forEach(fn) {
1270
+ utils$2.forEach(this.handlers, function forEachHandler(h) {
1271
+ if (h !== null) {
1272
+ fn(h);
1273
+ }
1274
+ });
1275
+ }
1276
+ }
1277
+
1278
+ const InterceptorManager$1 = InterceptorManager;
1279
+
1280
+ const transitionalDefaults = {
1281
+ silentJSONParsing: true,
1282
+ forcedJSONParsing: true,
1283
+ clarifyTimeoutError: false
1284
+ };
1285
+
6
1286
  function bind(fn, thisArg) {
7
1287
  return function wrap() {
8
1288
  return fn.apply(thisArg, arguments);
@@ -730,8 +2010,15 @@ AxiosError$1.from = (error, code, config, request, response, customProps)=>{
730
2010
  return axiosError;
731
2011
  };
732
2012
 
733
- // eslint-disable-next-line strict
734
- const HttpAdapter = null;
2013
+ function getDefaultExportFromCjs (x) {
2014
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2015
+ }
2016
+
2017
+ /* eslint-env browser */
2018
+
2019
+ var browser = typeof self == 'object' ? self.FormData : window.FormData;
2020
+
2021
+ const FormData$2 = /*@__PURE__*/getDefaultExportFromCjs(browser);
735
2022
 
736
2023
  /**
737
2024
  * Determines if the given thing is a array or js object.
@@ -804,7 +2091,7 @@ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop)
804
2091
  throw new TypeError('target must be an object');
805
2092
  }
806
2093
  // eslint-disable-next-line no-param-reassign
807
- formData = formData || new (FormData)();
2094
+ formData = formData || new (FormData$2 || FormData)();
808
2095
  // eslint-disable-next-line no-param-reassign
809
2096
  options = utils$1.toFlatObject(options, {
810
2097
  metaTokens: true,
@@ -910,7 +2197,7 @@ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop)
910
2197
  * @param {string} str - The string to encode.
911
2198
  *
912
2199
  * @returns {string} The encoded string.
913
- */ function encode$1(str) {
2200
+ */ function encode(str) {
914
2201
  const charMap = {
915
2202
  '!': '%21',
916
2203
  "'": '%27',
@@ -942,119 +2229,14 @@ prototype.append = function append(name, value) {
942
2229
  value
943
2230
  ]);
944
2231
  };
945
- prototype.toString = function toString(encoder) {
946
- const _encode = encoder ? function(value) {
947
- return encoder.call(this, value, encode$1);
948
- } : encode$1;
949
- return this._pairs.map(function each(pair) {
950
- return _encode(pair[0]) + '=' + _encode(pair[1]);
951
- }, '').join('&');
952
- };
953
-
954
- /**
955
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
956
- * URI encoded counterparts
957
- *
958
- * @param {string} val The value to be encoded.
959
- *
960
- * @returns {string} The encoded value.
961
- */ function encode(val) {
962
- return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
963
- }
964
- /**
965
- * Build a URL by appending params to the end
966
- *
967
- * @param {string} url The base of the url (e.g., http://www.google.com)
968
- * @param {object} [params] The params to be appended
969
- * @param {?object} options
970
- *
971
- * @returns {string} The formatted url
972
- */ function buildURL(url, params, options) {
973
- /*eslint no-param-reassign:0*/ if (!params) {
974
- return url;
975
- }
976
- const _encode = options && options.encode || encode;
977
- const serializeFn = options && options.serialize;
978
- let serializedParams;
979
- if (serializeFn) {
980
- serializedParams = serializeFn(params, options);
981
- } else {
982
- serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
983
- }
984
- if (serializedParams) {
985
- const hashmarkIndex = url.indexOf("#");
986
- if (hashmarkIndex !== -1) {
987
- url = url.slice(0, hashmarkIndex);
988
- }
989
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
990
- }
991
- return url;
992
- }
993
-
994
- let InterceptorManager = class InterceptorManager {
995
- constructor(){
996
- this.handlers = [];
997
- }
998
- /**
999
- * Add a new interceptor to the stack
1000
- *
1001
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
1002
- * @param {Function} rejected The function to handle `reject` for a `Promise`
1003
- *
1004
- * @return {Number} An ID used to remove interceptor later
1005
- */ use(fulfilled, rejected, options) {
1006
- this.handlers.push({
1007
- fulfilled,
1008
- rejected,
1009
- synchronous: options ? options.synchronous : false,
1010
- runWhen: options ? options.runWhen : null
1011
- });
1012
- return this.handlers.length - 1;
1013
- }
1014
- /**
1015
- * Remove an interceptor from the stack
1016
- *
1017
- * @param {Number} id The ID that was returned by `use`
1018
- *
1019
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1020
- */ eject(id) {
1021
- if (this.handlers[id]) {
1022
- this.handlers[id] = null;
1023
- }
1024
- }
1025
- /**
1026
- * Clear all interceptors from the stack
1027
- *
1028
- * @returns {void}
1029
- */ clear() {
1030
- if (this.handlers) {
1031
- this.handlers = [];
1032
- }
1033
- }
1034
- /**
1035
- * Iterate over all the registered interceptors
1036
- *
1037
- * This method is particularly useful for skipping over any
1038
- * interceptors that may have become `null` calling `eject`.
1039
- *
1040
- * @param {Function} fn The function to call for each interceptor
1041
- *
1042
- * @returns {void}
1043
- */ forEach(fn) {
1044
- utils$1.forEach(this.handlers, function forEachHandler(h) {
1045
- if (h !== null) {
1046
- fn(h);
1047
- }
1048
- });
1049
- }
1050
- };
1051
- const InterceptorManager$1 = InterceptorManager;
1052
-
1053
- const transitionalDefaults = {
1054
- silentJSONParsing: true,
1055
- forcedJSONParsing: true,
1056
- clarifyTimeoutError: false
1057
- };
2232
+ prototype.toString = function toString(encoder) {
2233
+ const _encode = encoder ? function(value) {
2234
+ return encoder.call(this, value, encode);
2235
+ } : encode;
2236
+ return this._pairs.map(function each(pair) {
2237
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
2238
+ }, '').join('&');
2239
+ };
1058
2240
 
1059
2241
  const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1060
2242
 
@@ -1079,8 +2261,10 @@ const platform$1 = {
1079
2261
  ]
1080
2262
  };
1081
2263
 
1082
- const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1083
- const _navigator = typeof navigator === 'object' && navigator || undefined;
2264
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2265
+
2266
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
2267
+
1084
2268
  /**
1085
2269
  * Determine if we're running in a standard browser environment
1086
2270
  *
@@ -1097,11 +2281,10 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
1097
2281
  * navigator.product -> 'NativeScript' or 'NS'
1098
2282
  *
1099
2283
  * @returns {boolean}
1100
- */ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || [
1101
- 'ReactNative',
1102
- 'NativeScript',
1103
- 'NS'
1104
- ].indexOf(_navigator.product) < 0);
2284
+ */
2285
+ const hasStandardBrowserEnv = hasBrowserEnv &&
2286
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
2287
+
1105
2288
  /**
1106
2289
  * Determine if we're running in a standard browser webWorker environment
1107
2290
  *
@@ -1110,36 +2293,43 @@ const _navigator = typeof navigator === 'object' && navigator || undefined;
1110
2293
  * filtered out due to its judgment standard
1111
2294
  * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1112
2295
  * This leads to a problem when axios post `FormData` in webWorker
1113
- */ const hasStandardBrowserWebWorkerEnv = (()=>{
1114
- return typeof WorkerGlobalScope !== 'undefined' && // eslint-disable-next-line no-undef
1115
- self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
1116
- })();
2296
+ */
2297
+ const hasStandardBrowserWebWorkerEnv = (() => {
2298
+ return (
2299
+ typeof WorkerGlobalScope !== 'undefined' &&
2300
+ // eslint-disable-next-line no-undef
2301
+ self instanceof WorkerGlobalScope &&
2302
+ typeof self.importScripts === 'function'
2303
+ );
2304
+ })();
2305
+
1117
2306
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1118
2307
 
1119
2308
  const utils = /*#__PURE__*/Object.freeze({
1120
- __proto__: null,
1121
- hasBrowserEnv: hasBrowserEnv,
1122
- hasStandardBrowserEnv: hasStandardBrowserEnv,
1123
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1124
- navigator: _navigator,
1125
- origin: origin
2309
+ __proto__: null,
2310
+ hasBrowserEnv: hasBrowserEnv,
2311
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
2312
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
2313
+ navigator: _navigator,
2314
+ origin: origin
1126
2315
  });
1127
2316
 
1128
- const platform = {
1129
- ...utils,
1130
- ...platform$1
2317
+ const platform = {
2318
+ ...utils,
2319
+ ...platform$1
1131
2320
  };
1132
2321
 
1133
- function toURLEncodedForm(data, options) {
1134
- return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1135
- visitor: function(value, key, path, helpers) {
1136
- if (platform.isNode && utils$1.isBuffer(value)) {
1137
- this.append(key, value.toString('base64'));
1138
- return false;
1139
- }
1140
- return helpers.defaultVisitor.apply(this, arguments);
1141
- }
1142
- }, options));
2322
+ function toURLEncodedForm(data, options) {
2323
+ return toFormData$2(data, new platform.classes.URLSearchParams(), Object.assign({
2324
+ visitor: function(value, key, path, helpers) {
2325
+ if (platform.isNode && utils$2.isBuffer(value)) {
2326
+ this.append(key, value.toString('base64'));
2327
+ return false;
2328
+ }
2329
+
2330
+ return helpers.defaultVisitor.apply(this, arguments);
2331
+ }
2332
+ }, options));
1143
2333
  }
1144
2334
 
1145
2335
  /**
@@ -1148,74 +2338,88 @@ function toURLEncodedForm(data, options) {
1148
2338
  * @param {string} name - The name of the property to get.
1149
2339
  *
1150
2340
  * @returns An array of strings.
1151
- */ function parsePropPath(name) {
1152
- // foo[x][y][z]
1153
- // foo.x.y.z
1154
- // foo-x-y-z
1155
- // foo x y z
1156
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match)=>{
1157
- return match[0] === '[]' ? '' : match[1] || match[0];
1158
- });
1159
- }
2341
+ */
2342
+ function parsePropPath(name) {
2343
+ // foo[x][y][z]
2344
+ // foo.x.y.z
2345
+ // foo-x-y-z
2346
+ // foo x y z
2347
+ return utils$2.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
2348
+ return match[0] === '[]' ? '' : match[1] || match[0];
2349
+ });
2350
+ }
2351
+
1160
2352
  /**
1161
2353
  * Convert an array to an object.
1162
2354
  *
1163
2355
  * @param {Array<any>} arr - The array to convert to an object.
1164
2356
  *
1165
2357
  * @returns An object with the same keys and values as the array.
1166
- */ function arrayToObject(arr) {
1167
- const obj = {};
1168
- const keys = Object.keys(arr);
1169
- let i;
1170
- const len = keys.length;
1171
- let key;
1172
- for(i = 0; i < len; i++){
1173
- key = keys[i];
1174
- obj[key] = arr[key];
1175
- }
1176
- return obj;
1177
- }
2358
+ */
2359
+ function arrayToObject(arr) {
2360
+ const obj = {};
2361
+ const keys = Object.keys(arr);
2362
+ let i;
2363
+ const len = keys.length;
2364
+ let key;
2365
+ for (i = 0; i < len; i++) {
2366
+ key = keys[i];
2367
+ obj[key] = arr[key];
2368
+ }
2369
+ return obj;
2370
+ }
2371
+
1178
2372
  /**
1179
2373
  * It takes a FormData object and returns a JavaScript object
1180
2374
  *
1181
2375
  * @param {string} formData The FormData object to convert to JSON.
1182
2376
  *
1183
2377
  * @returns {Object<string, any> | null} The converted object.
1184
- */ function formDataToJSON(formData) {
1185
- function buildPath(path, value, target, index) {
1186
- let name = path[index++];
1187
- if (name === '__proto__') return true;
1188
- const isNumericKey = Number.isFinite(+name);
1189
- const isLast = index >= path.length;
1190
- name = !name && utils$1.isArray(target) ? target.length : name;
1191
- if (isLast) {
1192
- if (utils$1.hasOwnProp(target, name)) {
1193
- target[name] = [
1194
- target[name],
1195
- value
1196
- ];
1197
- } else {
1198
- target[name] = value;
1199
- }
1200
- return !isNumericKey;
1201
- }
1202
- if (!target[name] || !utils$1.isObject(target[name])) {
1203
- target[name] = [];
1204
- }
1205
- const result = buildPath(path, value, target[name], index);
1206
- if (result && utils$1.isArray(target[name])) {
1207
- target[name] = arrayToObject(target[name]);
1208
- }
1209
- return !isNumericKey;
1210
- }
1211
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1212
- const obj = {};
1213
- utils$1.forEachEntry(formData, (name, value)=>{
1214
- buildPath(parsePropPath(name), value, obj, 0);
1215
- });
1216
- return obj;
1217
- }
1218
- return null;
2378
+ */
2379
+ function formDataToJSON(formData) {
2380
+ function buildPath(path, value, target, index) {
2381
+ let name = path[index++];
2382
+
2383
+ if (name === '__proto__') return true;
2384
+
2385
+ const isNumericKey = Number.isFinite(+name);
2386
+ const isLast = index >= path.length;
2387
+ name = !name && utils$2.isArray(target) ? target.length : name;
2388
+
2389
+ if (isLast) {
2390
+ if (utils$2.hasOwnProp(target, name)) {
2391
+ target[name] = [target[name], value];
2392
+ } else {
2393
+ target[name] = value;
2394
+ }
2395
+
2396
+ return !isNumericKey;
2397
+ }
2398
+
2399
+ if (!target[name] || !utils$2.isObject(target[name])) {
2400
+ target[name] = [];
2401
+ }
2402
+
2403
+ const result = buildPath(path, value, target[name], index);
2404
+
2405
+ if (result && utils$2.isArray(target[name])) {
2406
+ target[name] = arrayToObject(target[name]);
2407
+ }
2408
+
2409
+ return !isNumericKey;
2410
+ }
2411
+
2412
+ if (utils$2.isFormData(formData) && utils$2.isFunction(formData.entries)) {
2413
+ const obj = {};
2414
+
2415
+ utils$2.forEachEntry(formData, (name, value) => {
2416
+ buildPath(parsePropPath(name), value, obj, 0);
2417
+ });
2418
+
2419
+ return obj;
2420
+ }
2421
+
2422
+ return null;
1219
2423
  }
1220
2424
 
1221
2425
  /**
@@ -1227,147 +2431,158 @@ function toURLEncodedForm(data, options) {
1227
2431
  * @param {Function} encoder - A function that takes a value and returns a string.
1228
2432
  *
1229
2433
  * @returns {string} A stringified version of the rawValue.
1230
- */ function stringifySafely(rawValue, parser, encoder) {
1231
- if (utils$1.isString(rawValue)) {
1232
- try {
1233
- (parser || JSON.parse)(rawValue);
1234
- return utils$1.trim(rawValue);
1235
- } catch (e) {
1236
- if (e.name !== 'SyntaxError') {
1237
- throw e;
1238
- }
1239
- }
1240
- }
1241
- return (encoder || JSON.stringify)(rawValue);
1242
- }
1243
- const defaults = {
1244
- transitional: transitionalDefaults,
1245
- adapter: [
1246
- 'xhr',
1247
- 'http',
1248
- 'fetch'
1249
- ],
1250
- transformRequest: [
1251
- function transformRequest(data, headers) {
1252
- const contentType = headers.getContentType() || '';
1253
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1254
- const isObjectPayload = utils$1.isObject(data);
1255
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1256
- data = new FormData(data);
1257
- }
1258
- const isFormData = utils$1.isFormData(data);
1259
- if (isFormData) {
1260
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1261
- }
1262
- if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
1263
- return data;
1264
- }
1265
- if (utils$1.isArrayBufferView(data)) {
1266
- return data.buffer;
1267
- }
1268
- if (utils$1.isURLSearchParams(data)) {
1269
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1270
- return data.toString();
1271
- }
1272
- let isFileList;
1273
- if (isObjectPayload) {
1274
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1275
- return toURLEncodedForm(data, this.formSerializer).toString();
1276
- }
1277
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1278
- const _FormData = this.env && this.env.FormData;
1279
- return toFormData$1(isFileList ? {
1280
- 'files[]': data
1281
- } : data, _FormData && new _FormData(), this.formSerializer);
1282
- }
1283
- }
1284
- if (isObjectPayload || hasJSONContentType) {
1285
- headers.setContentType('application/json', false);
1286
- return stringifySafely(data);
1287
- }
1288
- return data;
1289
- }
1290
- ],
1291
- transformResponse: [
1292
- function transformResponse(data) {
1293
- const transitional = this.transitional || defaults.transitional;
1294
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1295
- const JSONRequested = this.responseType === 'json';
1296
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1297
- return data;
1298
- }
1299
- if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1300
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
1301
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1302
- try {
1303
- return JSON.parse(data);
1304
- } catch (e) {
1305
- if (strictJSONParsing) {
1306
- if (e.name === 'SyntaxError') {
1307
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1308
- }
1309
- throw e;
1310
- }
1311
- }
1312
- }
1313
- return data;
1314
- }
1315
- ],
1316
- /**
2434
+ */
2435
+ function stringifySafely(rawValue, parser, encoder) {
2436
+ if (utils$2.isString(rawValue)) {
2437
+ try {
2438
+ (parser || JSON.parse)(rawValue);
2439
+ return utils$2.trim(rawValue);
2440
+ } catch (e) {
2441
+ if (e.name !== 'SyntaxError') {
2442
+ throw e;
2443
+ }
2444
+ }
2445
+ }
2446
+
2447
+ return (encoder || JSON.stringify)(rawValue);
2448
+ }
2449
+
2450
+ const defaults = {
2451
+
2452
+ transitional: transitionalDefaults,
2453
+
2454
+ adapter: ['xhr', 'http', 'fetch'],
2455
+
2456
+ transformRequest: [function transformRequest(data, headers) {
2457
+ const contentType = headers.getContentType() || '';
2458
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
2459
+ const isObjectPayload = utils$2.isObject(data);
2460
+
2461
+ if (isObjectPayload && utils$2.isHTMLForm(data)) {
2462
+ data = new FormData(data);
2463
+ }
2464
+
2465
+ const isFormData = utils$2.isFormData(data);
2466
+
2467
+ if (isFormData) {
2468
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2469
+ }
2470
+
2471
+ if (utils$2.isArrayBuffer(data) ||
2472
+ utils$2.isBuffer(data) ||
2473
+ utils$2.isStream(data) ||
2474
+ utils$2.isFile(data) ||
2475
+ utils$2.isBlob(data) ||
2476
+ utils$2.isReadableStream(data)
2477
+ ) {
2478
+ return data;
2479
+ }
2480
+ if (utils$2.isArrayBufferView(data)) {
2481
+ return data.buffer;
2482
+ }
2483
+ if (utils$2.isURLSearchParams(data)) {
2484
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2485
+ return data.toString();
2486
+ }
2487
+
2488
+ let isFileList;
2489
+
2490
+ if (isObjectPayload) {
2491
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2492
+ return toURLEncodedForm(data, this.formSerializer).toString();
2493
+ }
2494
+
2495
+ if ((isFileList = utils$2.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2496
+ const _FormData = this.env && this.env.FormData;
2497
+
2498
+ return toFormData$2(
2499
+ isFileList ? {'files[]': data} : data,
2500
+ _FormData && new _FormData(),
2501
+ this.formSerializer
2502
+ );
2503
+ }
2504
+ }
2505
+
2506
+ if (isObjectPayload || hasJSONContentType) {
2507
+ headers.setContentType('application/json', false);
2508
+ return stringifySafely(data);
2509
+ }
2510
+
2511
+ return data;
2512
+ }],
2513
+
2514
+ transformResponse: [function transformResponse(data) {
2515
+ const transitional = this.transitional || defaults.transitional;
2516
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2517
+ const JSONRequested = this.responseType === 'json';
2518
+
2519
+ if (utils$2.isResponse(data) || utils$2.isReadableStream(data)) {
2520
+ return data;
2521
+ }
2522
+
2523
+ if (data && utils$2.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
2524
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
2525
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
2526
+
2527
+ try {
2528
+ return JSON.parse(data);
2529
+ } catch (e) {
2530
+ if (strictJSONParsing) {
2531
+ if (e.name === 'SyntaxError') {
2532
+ throw AxiosError$2.from(e, AxiosError$2.ERR_BAD_RESPONSE, this, null, this.response);
2533
+ }
2534
+ throw e;
2535
+ }
2536
+ }
2537
+ }
2538
+
2539
+ return data;
2540
+ }],
2541
+
2542
+ /**
1317
2543
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
1318
2544
  * timeout is not created.
1319
- */ timeout: 0,
1320
- xsrfCookieName: 'XSRF-TOKEN',
1321
- xsrfHeaderName: 'X-XSRF-TOKEN',
1322
- maxContentLength: -1,
1323
- maxBodyLength: -1,
1324
- env: {
1325
- FormData: platform.classes.FormData,
1326
- Blob: platform.classes.Blob
1327
- },
1328
- validateStatus: function validateStatus(status) {
1329
- return status >= 200 && status < 300;
1330
- },
1331
- headers: {
1332
- common: {
1333
- 'Accept': 'application/json, text/plain, */*',
1334
- 'Content-Type': undefined
1335
- }
1336
- }
1337
- };
1338
- utils$1.forEach([
1339
- 'delete',
1340
- 'get',
1341
- 'head',
1342
- 'post',
1343
- 'put',
1344
- 'patch'
1345
- ], (method)=>{
1346
- defaults.headers[method] = {};
1347
- });
2545
+ */
2546
+ timeout: 0,
2547
+
2548
+ xsrfCookieName: 'XSRF-TOKEN',
2549
+ xsrfHeaderName: 'X-XSRF-TOKEN',
2550
+
2551
+ maxContentLength: -1,
2552
+ maxBodyLength: -1,
2553
+
2554
+ env: {
2555
+ FormData: platform.classes.FormData,
2556
+ Blob: platform.classes.Blob
2557
+ },
2558
+
2559
+ validateStatus: function validateStatus(status) {
2560
+ return status >= 200 && status < 300;
2561
+ },
2562
+
2563
+ headers: {
2564
+ common: {
2565
+ 'Accept': 'application/json, text/plain, */*',
2566
+ 'Content-Type': undefined
2567
+ }
2568
+ }
2569
+ };
2570
+
2571
+ utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
2572
+ defaults.headers[method] = {};
2573
+ });
2574
+
1348
2575
  const defaults$1 = defaults;
1349
2576
 
1350
- // RawAxiosHeaders whose duplicates are ignored by node
1351
- // c.f. https://nodejs.org/api/http.html#http_message_headers
1352
- const ignoreDuplicateOf = utils$1.toObjectSet([
1353
- 'age',
1354
- 'authorization',
1355
- 'content-length',
1356
- 'content-type',
1357
- 'etag',
1358
- 'expires',
1359
- 'from',
1360
- 'host',
1361
- 'if-modified-since',
1362
- 'if-unmodified-since',
1363
- 'last-modified',
1364
- 'location',
1365
- 'max-forwards',
1366
- 'proxy-authorization',
1367
- 'referer',
1368
- 'retry-after',
1369
- 'user-agent'
1370
- ]);
2577
+ // RawAxiosHeaders whose duplicates are ignored by node
2578
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
2579
+ const ignoreDuplicateOf = utils$2.toObjectSet([
2580
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
2581
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
2582
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
2583
+ 'referer', 'retry-after', 'user-agent'
2584
+ ]);
2585
+
1371
2586
  /**
1372
2587
  * Parse headers into an object
1373
2588
  *
@@ -1381,272 +2596,346 @@ const ignoreDuplicateOf = utils$1.toObjectSet([
1381
2596
  * @param {String} rawHeaders Headers needing to be parsed
1382
2597
  *
1383
2598
  * @returns {Object} Headers parsed into an object
1384
- */ const parseHeaders = ((rawHeaders)=>{
1385
- const parsed = {};
1386
- let key;
1387
- let val;
1388
- let i;
1389
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1390
- i = line.indexOf(':');
1391
- key = line.substring(0, i).trim().toLowerCase();
1392
- val = line.substring(i + 1).trim();
1393
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1394
- return;
1395
- }
1396
- if (key === 'set-cookie') {
1397
- if (parsed[key]) {
1398
- parsed[key].push(val);
1399
- } else {
1400
- parsed[key] = [
1401
- val
1402
- ];
1403
- }
1404
- } else {
1405
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1406
- }
1407
- });
1408
- return parsed;
1409
- });
2599
+ */
2600
+ const parseHeaders = rawHeaders => {
2601
+ const parsed = {};
2602
+ let key;
2603
+ let val;
2604
+ let i;
2605
+
2606
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
2607
+ i = line.indexOf(':');
2608
+ key = line.substring(0, i).trim().toLowerCase();
2609
+ val = line.substring(i + 1).trim();
2610
+
2611
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
2612
+ return;
2613
+ }
2614
+
2615
+ if (key === 'set-cookie') {
2616
+ if (parsed[key]) {
2617
+ parsed[key].push(val);
2618
+ } else {
2619
+ parsed[key] = [val];
2620
+ }
2621
+ } else {
2622
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
2623
+ }
2624
+ });
2625
+
2626
+ return parsed;
2627
+ };
1410
2628
 
1411
- var _computedKey, _computedKey1;
1412
- const $internals = Symbol('internals');
1413
- function normalizeHeader(header) {
1414
- return header && String(header).trim().toLowerCase();
1415
- }
1416
- function normalizeValue(value) {
1417
- if (value === false || value == null) {
1418
- return value;
1419
- }
1420
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1421
- }
1422
- function parseTokens(str) {
1423
- const tokens = Object.create(null);
1424
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1425
- let match;
1426
- while(match = tokensRE.exec(str)){
1427
- tokens[match[1]] = match[2];
1428
- }
1429
- return tokens;
1430
- }
1431
- const isValidHeaderName = (str)=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1432
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1433
- if (utils$1.isFunction(filter)) {
1434
- return filter.call(this, value, header);
1435
- }
1436
- if (isHeaderNameFilter) {
1437
- value = header;
1438
- }
1439
- if (!utils$1.isString(value)) return;
1440
- if (utils$1.isString(filter)) {
1441
- return value.indexOf(filter) !== -1;
1442
- }
1443
- if (utils$1.isRegExp(filter)) {
1444
- return filter.test(value);
1445
- }
1446
- }
1447
- function formatHeader(header) {
1448
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str)=>{
1449
- return char.toUpperCase() + str;
1450
- });
1451
- }
1452
- function buildAccessors(obj, header) {
1453
- const accessorName = utils$1.toCamelCase(' ' + header);
1454
- [
1455
- 'get',
1456
- 'set',
1457
- 'has'
1458
- ].forEach((methodName)=>{
1459
- Object.defineProperty(obj, methodName + accessorName, {
1460
- value: function(arg1, arg2, arg3) {
1461
- return this[methodName].call(this, header, arg1, arg2, arg3);
1462
- },
1463
- configurable: true
1464
- });
1465
- });
1466
- }
1467
- _computedKey = Symbol.iterator, _computedKey1 = Symbol.toStringTag;
1468
- let AxiosHeaders$1 = class AxiosHeaders {
1469
- constructor(headers){
1470
- headers && this.set(headers);
1471
- }
1472
- /**
2629
+ const $internals = Symbol('internals');
2630
+
2631
+ function normalizeHeader(header) {
2632
+ return header && String(header).trim().toLowerCase();
2633
+ }
2634
+
2635
+ function normalizeValue(value) {
2636
+ if (value === false || value == null) {
2637
+ return value;
2638
+ }
2639
+
2640
+ return utils$2.isArray(value) ? value.map(normalizeValue) : String(value);
2641
+ }
2642
+
2643
+ function parseTokens(str) {
2644
+ const tokens = Object.create(null);
2645
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
2646
+ let match;
2647
+
2648
+ while ((match = tokensRE.exec(str))) {
2649
+ tokens[match[1]] = match[2];
2650
+ }
2651
+
2652
+ return tokens;
2653
+ }
2654
+
2655
+ const isValidHeaderName = str => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
2656
+
2657
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
2658
+ if (utils$2.isFunction(filter)) {
2659
+ return filter.call(this, value, header);
2660
+ }
2661
+
2662
+ if (isHeaderNameFilter) {
2663
+ value = header;
2664
+ }
2665
+
2666
+ if (!utils$2.isString(value)) return;
2667
+
2668
+ if (utils$2.isString(filter)) {
2669
+ return value.indexOf(filter) !== -1;
2670
+ }
2671
+
2672
+ if (utils$2.isRegExp(filter)) {
2673
+ return filter.test(value);
2674
+ }
2675
+ }
2676
+
2677
+ function formatHeader(header) {
2678
+ return header
2679
+ .trim()
2680
+ .toLowerCase()
2681
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
2682
+ return char.toUpperCase() + str;
2683
+ });
2684
+ }
2685
+
2686
+ function buildAccessors(obj, header) {
2687
+ const accessorName = utils$2.toCamelCase(' ' + header);
2688
+ ['get', 'set', 'has'].forEach(methodName => {
2689
+ Object.defineProperty(obj, methodName + accessorName, {
2690
+ value: function (arg1, arg2, arg3) {
2691
+ return this[methodName].call(this, header, arg1, arg2, arg3);
2692
+ },
2693
+ configurable: true,
2694
+ });
2695
+ });
2696
+ }
2697
+
2698
+ let AxiosHeaders$1 = class AxiosHeaders {
2699
+ constructor(headers) {
2700
+ headers && this.set(headers);
2701
+ }
2702
+
2703
+ /**
1473
2704
  *
1474
2705
  * @param {*} header
1475
2706
  * @param {*} valueOrRewrite
1476
2707
  * @param {*} rewrite true:无论源值是否存在均赋值,false:源值如存在不覆盖,
1477
2708
  * undefined:源值不为 false 直接赋值,false 不赋值
1478
2709
  * @returns
1479
- */ set(header, valueOrRewrite, rewrite) {
1480
- const self = this;
1481
- function setHeader(_value, _header, _rewrite) {
1482
- const lHeader = normalizeHeader(_header);
1483
- if (!lHeader) {
1484
- throw new Error('header name must be a non-empty string');
1485
- }
1486
- const key = utils$1.findKey(self, lHeader);
1487
- if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1488
- self[key || _header] = normalizeValue(_value);
1489
- }
1490
- }
1491
- const setHeaders = (headers, _rewrite)=>utils$1.forEach(headers, (_value, _header)=>setHeader(_value, _header, _rewrite));
1492
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1493
- setHeaders(header, valueOrRewrite);
1494
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1495
- setHeaders(parseHeaders(header), valueOrRewrite);
1496
- } else if (utils$1.isHeaders(header)) {
1497
- for (const [key, value] of header.entries()){
1498
- setHeader(value, key, rewrite);
1499
- }
1500
- } else {
1501
- header != null && setHeader(valueOrRewrite, header, rewrite);
1502
- }
1503
- return this;
1504
- }
1505
- get(header, parser) {
1506
- header = normalizeHeader(header);
1507
- if (header) {
1508
- const key = utils$1.findKey(this, header);
1509
- if (key) {
1510
- const value = this[key];
1511
- if (!parser) {
1512
- return value;
1513
- }
1514
- if (parser === true) {
1515
- return parseTokens(value);
1516
- }
1517
- if (utils$1.isFunction(parser)) {
1518
- return parser.call(this, value, key);
1519
- }
1520
- if (utils$1.isRegExp(parser)) {
1521
- return parser.exec(value);
1522
- }
1523
- throw new TypeError('parser must be boolean|regexp|function');
1524
- }
1525
- }
1526
- }
1527
- has(header, matcher) {
1528
- header = normalizeHeader(header);
1529
- if (header) {
1530
- const key = utils$1.findKey(this, header);
1531
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1532
- }
1533
- return false;
1534
- }
1535
- delete(header, matcher) {
1536
- const self = this;
1537
- let deleted = false;
1538
- function deleteHeader(_header) {
1539
- _header = normalizeHeader(_header);
1540
- if (_header) {
1541
- const key = utils$1.findKey(self, _header);
1542
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1543
- delete self[key];
1544
- deleted = true;
1545
- }
1546
- }
1547
- }
1548
- if (utils$1.isArray(header)) {
1549
- header.forEach(deleteHeader);
1550
- } else {
1551
- deleteHeader(header);
1552
- }
1553
- return deleted;
1554
- }
1555
- clear(matcher) {
1556
- const keys = Object.keys(this);
1557
- let i = keys.length;
1558
- let deleted = false;
1559
- while(i--){
1560
- const key = keys[i];
1561
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1562
- delete this[key];
1563
- deleted = true;
1564
- }
1565
- }
1566
- return deleted;
1567
- }
1568
- normalize(format) {
1569
- const self = this;
1570
- const headers = {};
1571
- utils$1.forEach(this, (value, header)=>{
1572
- const key = utils$1.findKey(headers, header);
1573
- if (key) {
1574
- self[key] = normalizeValue(value);
1575
- delete self[header];
1576
- return;
1577
- }
1578
- const normalized = format ? formatHeader(header) : String(header).trim();
1579
- if (normalized !== header) {
1580
- delete self[header];
1581
- }
1582
- self[normalized] = normalizeValue(value);
1583
- headers[normalized] = true;
1584
- });
1585
- return this;
1586
- }
1587
- concat(...targets) {
1588
- return this.constructor.concat(this, ...targets);
1589
- }
1590
- toJSON(asStrings) {
1591
- const obj = Object.create(null);
1592
- utils$1.forEach(this, (value, header)=>{
1593
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1594
- });
1595
- return obj;
1596
- }
1597
- [_computedKey]() {
1598
- return Object.entries(this.toJSON())[Symbol.iterator]();
1599
- }
1600
- toString() {
1601
- return Object.entries(this.toJSON()).map(([header, value])=>header + ': ' + value).join('\n');
1602
- }
1603
- get [_computedKey1]() {
1604
- return 'AxiosHeaders';
1605
- }
1606
- static from(thing) {
1607
- return thing instanceof this ? thing : new this(thing);
1608
- }
1609
- static concat(first, ...targets) {
1610
- const computed = new this(first);
1611
- targets.forEach((target)=>computed.set(target));
1612
- return computed;
1613
- }
1614
- static accessor(header) {
1615
- const internals = this[$internals] = this[$internals] = {
1616
- accessors: {}
1617
- };
1618
- const accessors = internals.accessors;
1619
- const prototype = this.prototype;
1620
- function defineAccessor(_header) {
1621
- const lHeader = normalizeHeader(_header);
1622
- if (!accessors[lHeader]) {
1623
- buildAccessors(prototype, _header);
1624
- accessors[lHeader] = true;
1625
- }
1626
- }
1627
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1628
- return this;
1629
- }
1630
- };
1631
- AxiosHeaders$1.accessor([
1632
- 'Content-Type',
1633
- 'Content-Length',
1634
- 'Accept',
1635
- 'Accept-Encoding',
1636
- 'User-Agent',
1637
- 'Authorization'
1638
- ]);
1639
- // reserved names hotfix
1640
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key)=>{
1641
- let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1642
- return {
1643
- get: ()=>value,
1644
- set (headerValue) {
1645
- this[mapped] = headerValue;
1646
- }
1647
- };
1648
- });
1649
- utils$1.freezeMethods(AxiosHeaders$1);
2710
+ */
2711
+ set(header, valueOrRewrite, rewrite) {
2712
+ const self = this;
2713
+
2714
+ function setHeader(_value, _header, _rewrite) {
2715
+ const lHeader = normalizeHeader(_header);
2716
+
2717
+ if (!lHeader) {
2718
+ throw new Error('header name must be a non-empty string');
2719
+ }
2720
+
2721
+ const key = utils$2.findKey(self, lHeader);
2722
+
2723
+ if (!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
2724
+ self[key || _header] = normalizeValue(_value);
2725
+ }
2726
+ }
2727
+
2728
+ const setHeaders = (headers, _rewrite) =>
2729
+ utils$2.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
2730
+
2731
+ if (utils$2.isPlainObject(header) || header instanceof this.constructor) {
2732
+ setHeaders(header, valueOrRewrite);
2733
+ } else if (utils$2.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
2734
+ setHeaders(parseHeaders(header), valueOrRewrite);
2735
+ } else if (utils$2.isHeaders(header)) {
2736
+ for (const [key, value] of header.entries()) {
2737
+ setHeader(value, key, rewrite);
2738
+ }
2739
+ } else {
2740
+ header != null && setHeader(valueOrRewrite, header, rewrite);
2741
+ }
2742
+
2743
+ return this;
2744
+ }
2745
+
2746
+ get(header, parser) {
2747
+ header = normalizeHeader(header);
2748
+
2749
+ if (header) {
2750
+ const key = utils$2.findKey(this, header);
2751
+
2752
+ if (key) {
2753
+ const value = this[key];
2754
+
2755
+ if (!parser) {
2756
+ return value;
2757
+ }
2758
+
2759
+ if (parser === true) {
2760
+ return parseTokens(value);
2761
+ }
2762
+
2763
+ if (utils$2.isFunction(parser)) {
2764
+ return parser.call(this, value, key);
2765
+ }
2766
+
2767
+ if (utils$2.isRegExp(parser)) {
2768
+ return parser.exec(value);
2769
+ }
2770
+
2771
+ throw new TypeError('parser must be boolean|regexp|function');
2772
+ }
2773
+ }
2774
+ }
2775
+
2776
+ has(header, matcher) {
2777
+ header = normalizeHeader(header);
2778
+
2779
+ if (header) {
2780
+ const key = utils$2.findKey(this, header);
2781
+
2782
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2783
+ }
2784
+
2785
+ return false;
2786
+ }
2787
+
2788
+ delete(header, matcher) {
2789
+ const self = this;
2790
+ let deleted = false;
2791
+
2792
+ function deleteHeader(_header) {
2793
+ _header = normalizeHeader(_header);
2794
+
2795
+ if (_header) {
2796
+ const key = utils$2.findKey(self, _header);
2797
+
2798
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2799
+ delete self[key];
2800
+
2801
+ deleted = true;
2802
+ }
2803
+ }
2804
+ }
2805
+
2806
+ if (utils$2.isArray(header)) {
2807
+ header.forEach(deleteHeader);
2808
+ } else {
2809
+ deleteHeader(header);
2810
+ }
2811
+
2812
+ return deleted;
2813
+ }
2814
+
2815
+ clear(matcher) {
2816
+ const keys = Object.keys(this);
2817
+ let i = keys.length;
2818
+ let deleted = false;
2819
+
2820
+ while (i--) {
2821
+ const key = keys[i];
2822
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2823
+ delete this[key];
2824
+ deleted = true;
2825
+ }
2826
+ }
2827
+
2828
+ return deleted;
2829
+ }
2830
+
2831
+ normalize(format) {
2832
+ const self = this;
2833
+ const headers = {};
2834
+
2835
+ utils$2.forEach(this, (value, header) => {
2836
+ const key = utils$2.findKey(headers, header);
2837
+
2838
+ if (key) {
2839
+ self[key] = normalizeValue(value);
2840
+ delete self[header];
2841
+ return;
2842
+ }
2843
+
2844
+ const normalized = format ? formatHeader(header) : String(header).trim();
2845
+
2846
+ if (normalized !== header) {
2847
+ delete self[header];
2848
+ }
2849
+
2850
+ self[normalized] = normalizeValue(value);
2851
+
2852
+ headers[normalized] = true;
2853
+ });
2854
+
2855
+ return this;
2856
+ }
2857
+
2858
+ concat(...targets) {
2859
+ return this.constructor.concat(this, ...targets);
2860
+ }
2861
+
2862
+ toJSON(asStrings) {
2863
+ const obj = Object.create(null);
2864
+
2865
+ utils$2.forEach(this, (value, header) => {
2866
+ value != null && value !== false && (obj[header] = asStrings && utils$2.isArray(value) ? value.join(', ') : value);
2867
+ });
2868
+
2869
+ return obj;
2870
+ }
2871
+
2872
+ [Symbol.iterator]() {
2873
+ return Object.entries(this.toJSON())[Symbol.iterator]();
2874
+ }
2875
+
2876
+ toString() {
2877
+ return Object.entries(this.toJSON())
2878
+ .map(([header, value]) => header + ': ' + value)
2879
+ .join('\n');
2880
+ }
2881
+
2882
+ get [Symbol.toStringTag]() {
2883
+ return 'AxiosHeaders';
2884
+ }
2885
+
2886
+ static from(thing) {
2887
+ return thing instanceof this ? thing : new this(thing);
2888
+ }
2889
+
2890
+ static concat(first, ...targets) {
2891
+ const computed = new this(first);
2892
+
2893
+ targets.forEach(target => computed.set(target));
2894
+
2895
+ return computed;
2896
+ }
2897
+
2898
+ static accessor(header) {
2899
+ const internals =
2900
+ (this[$internals] =
2901
+ this[$internals] =
2902
+ {
2903
+ accessors: {},
2904
+ });
2905
+
2906
+ const accessors = internals.accessors;
2907
+ const prototype = this.prototype;
2908
+
2909
+ function defineAccessor(_header) {
2910
+ const lHeader = normalizeHeader(_header);
2911
+
2912
+ if (!accessors[lHeader]) {
2913
+ buildAccessors(prototype, _header);
2914
+ accessors[lHeader] = true;
2915
+ }
2916
+ }
2917
+
2918
+ utils$2.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2919
+
2920
+ return this;
2921
+ }
2922
+ };
2923
+
2924
+ AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2925
+
2926
+ // reserved names hotfix
2927
+ utils$2.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
2928
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2929
+ return {
2930
+ get: () => value,
2931
+ set(headerValue) {
2932
+ this[mapped] = headerValue;
2933
+ },
2934
+ };
2935
+ });
2936
+
2937
+ utils$2.freezeMethods(AxiosHeaders$1);
2938
+
1650
2939
  const AxiosHeaders$2 = AxiosHeaders$1;
1651
2940
 
1652
2941
  /**
@@ -1656,20 +2945,24 @@ const AxiosHeaders$2 = AxiosHeaders$1;
1656
2945
  * @param {?Object} response The response object
1657
2946
  *
1658
2947
  * @returns {*} The resulting transformed data
1659
- */ function transformData(fns, response) {
1660
- const config = this || defaults$1;
1661
- const context = response || config;
1662
- const headers = AxiosHeaders$2.from(context.headers);
1663
- let data = context.data;
1664
- utils$1.forEach(fns, function transform(fn) {
1665
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1666
- });
1667
- headers.normalize();
1668
- return data;
2948
+ */
2949
+ function transformData(fns, response) {
2950
+ const config = this || defaults$1;
2951
+ const context = response || config;
2952
+ const headers = AxiosHeaders$2.from(context.headers);
2953
+ let data = context.data;
2954
+
2955
+ utils$2.forEach(fns, function transform(fn) {
2956
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2957
+ });
2958
+
2959
+ headers.normalize();
2960
+
2961
+ return data;
1669
2962
  }
1670
2963
 
1671
- function isCancel$1(value) {
1672
- return !!(value && value.__CANCEL__);
2964
+ function isCancel$1(value) {
2965
+ return !!(value && value.__CANCEL__);
1673
2966
  }
1674
2967
 
1675
2968
  /**
@@ -1680,13 +2973,15 @@ function isCancel$1(value) {
1680
2973
  * @param {Object=} request The request.
1681
2974
  *
1682
2975
  * @returns {CanceledError} The created error.
1683
- */ function CanceledError$1(message, config, request) {
1684
- // eslint-disable-next-line no-eq-null,eqeqeq
1685
- AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1686
- this.name = 'CanceledError';
1687
- }
1688
- utils$1.inherits(CanceledError$1, AxiosError$1, {
1689
- __CANCEL__: true
2976
+ */
2977
+ function CanceledError$1(message, config, request) {
2978
+ // eslint-disable-next-line no-eq-null,eqeqeq
2979
+ AxiosError$2.call(this, message == null ? 'canceled' : message, AxiosError$2.ERR_CANCELED, config, request);
2980
+ this.name = 'CanceledError';
2981
+ }
2982
+
2983
+ utils$2.inherits(CanceledError$1, AxiosError$2, {
2984
+ __CANCEL__: true
1690
2985
  });
1691
2986
 
1692
2987
  /**
@@ -1695,11 +2990,12 @@ utils$1.inherits(CanceledError$1, AxiosError$1, {
1695
2990
  * @param {string} url The URL to test
1696
2991
  *
1697
2992
  * @returns {boolean} True if the specified URL is absolute, otherwise false
1698
- */ function isAbsoluteURL(url) {
1699
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1700
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1701
- // by any combination of letters, digits, plus, period, or hyphen.
1702
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2993
+ */
2994
+ function isAbsoluteURL(url) {
2995
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2996
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2997
+ // by any combination of letters, digits, plus, period, or hyphen.
2998
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1703
2999
  }
1704
3000
 
1705
3001
  /**
@@ -1709,8 +3005,11 @@ utils$1.inherits(CanceledError$1, AxiosError$1, {
1709
3005
  * @param {string} relativeURL The relative URL
1710
3006
  *
1711
3007
  * @returns {string} The combined URL
1712
- */ function combineURLs(baseURL, relativeURL) {
1713
- return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
3008
+ */
3009
+ function combineURLs(baseURL, relativeURL) {
3010
+ return relativeURL
3011
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3012
+ : baseURL;
1714
3013
  }
1715
3014
 
1716
3015
  /**
@@ -1722,76 +3021,96 @@ utils$1.inherits(CanceledError$1, AxiosError$1, {
1722
3021
  * @param {string} requestedURL Absolute or relative URL to combine
1723
3022
  *
1724
3023
  * @returns {string} The combined full path
1725
- */ function buildFullPath(baseURL, requestedURL) {
1726
- if (baseURL && !isAbsoluteURL(requestedURL)) {
1727
- return combineURLs(baseURL, requestedURL);
1728
- }
1729
- return requestedURL;
3024
+ */
3025
+ function buildFullPath(baseURL, requestedURL) {
3026
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
3027
+ return combineURLs(baseURL, requestedURL);
3028
+ }
3029
+ return requestedURL;
1730
3030
  }
1731
3031
 
1732
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
1733
- let XhrAdapter = class XhrAdapter {
1734
- constructor(config){
1735
- this.init(config);
1736
- }
1737
- init(config) {}
1738
- request() {}
1739
- stream() {}
1740
- };
3032
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3033
+ class XhrAdapter {
3034
+ constructor(config) {
3035
+ this.init(config);
3036
+ }
3037
+
3038
+ init(config) {}
3039
+
3040
+ request() {}
3041
+
3042
+ stream() {}
3043
+ }
3044
+
1741
3045
  const XhrAdapter$1 = isXHRAdapterSupported && XhrAdapter;
1742
3046
 
1743
- const knownAdapters = {
1744
- http: HttpAdapter,
1745
- xhr: XhrAdapter$1
1746
- };
3047
+ const knownAdapters = {
3048
+ http: HttpAdapter, // browser mode: httpAdapter === null
3049
+ xhr: XhrAdapter$1, // node mode: xhrAdapter === null
3050
+ };
3051
+
1747
3052
  /**
1748
3053
  * define adapter's name and adapterName to http or xhr
1749
3054
  * browser: httpAdapter is null!
1750
- */ utils$1.forEach(knownAdapters, (val, key)=>{
1751
- if (val) {
1752
- try {
1753
- Object.defineProperty(val, 'name', {
1754
- value: key
1755
- });
1756
- } catch (e) {
1757
- // eslint-disable-next-line no-empty
1758
- }
1759
- Object.defineProperty(val, 'adapterName', {
1760
- value: key
1761
- });
1762
- }
1763
- });
1764
- const adapters = {
1765
- /**
3055
+ */
3056
+ utils$2.forEach(knownAdapters, (val, key) => {
3057
+ if (val) {
3058
+ try {
3059
+ Object.defineProperty(val, 'name', {value: key});
3060
+ } catch (e) {
3061
+ // eslint-disable-next-line no-empty
3062
+ }
3063
+ Object.defineProperty(val, 'adapterName', {value: key});
3064
+ }
3065
+ });
3066
+
3067
+ const adapters = {
3068
+ /**
1766
3069
  * get http or xhr adapter
1767
3070
  * @param {*} adapters user pass or ['xhr', 'http']
1768
3071
  * @returns
1769
- */ getAdapter: (adapters)=>{
1770
- adapters = utils$1.isArray(adapters) ? adapters : [
1771
- adapters
1772
- ];
1773
- const { length } = adapters;
1774
- let nameOrAdapter;
1775
- let adapter;
1776
- // find not null adapter
1777
- for(let i = 0; i < length; i++){
1778
- nameOrAdapter = adapters[i];
1779
- if (adapter = utils$1.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
1780
- break;
1781
- }
1782
- }
1783
- if (!adapter) {
1784
- if (adapter === false) {
1785
- throw new AxiosError$1(`Adapter ${nameOrAdapter} is not supported by the environment`, 'ERR_NOT_SUPPORT');
1786
- }
1787
- throw new Error(utils$1.hasOwnProp(knownAdapters, nameOrAdapter) ? `Adapter '${nameOrAdapter}' is not available in the build` : `Unknown adapter '${nameOrAdapter}'`);
1788
- }
1789
- if (!utils$1.isFunction(adapter)) {
1790
- throw new TypeError('adapter is not a function');
1791
- }
1792
- return adapter;
1793
- },
1794
- adapters: knownAdapters
3072
+ */
3073
+ getAdapter: adapters => {
3074
+ adapters = utils$2.isArray(adapters) ? adapters : [adapters];
3075
+
3076
+ const {length} = adapters;
3077
+ let nameOrAdapter;
3078
+ let adapter;
3079
+
3080
+ // find not null adapter
3081
+ for (let i = 0; i < length; i++) {
3082
+ nameOrAdapter = adapters[i];
3083
+ if (
3084
+ (adapter = utils$2.isString(nameOrAdapter)
3085
+ ? knownAdapters[nameOrAdapter.toLowerCase()]
3086
+ : nameOrAdapter)
3087
+ ) {
3088
+ break;
3089
+ }
3090
+ }
3091
+
3092
+ if (!adapter) {
3093
+ if (adapter === false) {
3094
+ throw new AxiosError$2(
3095
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
3096
+ 'ERR_NOT_SUPPORT'
3097
+ );
3098
+ }
3099
+
3100
+ throw new Error(
3101
+ utils$2.hasOwnProp(knownAdapters, nameOrAdapter)
3102
+ ? `Adapter '${nameOrAdapter}' is not available in the build`
3103
+ : `Unknown adapter '${nameOrAdapter}'`
3104
+ );
3105
+ }
3106
+
3107
+ if (!utils$2.isFunction(adapter)) {
3108
+ throw new TypeError('adapter is not a function');
3109
+ }
3110
+
3111
+ return adapter;
3112
+ },
3113
+ adapters: knownAdapters,
1795
3114
  };
1796
3115
 
1797
3116
  /**
@@ -1800,70 +3119,82 @@ const adapters = {
1800
3119
  * @param {Object} config The config that is to be used for the request
1801
3120
  *
1802
3121
  * @returns {void}
1803
- */ function throwIfCancellationRequested(config) {
1804
- if (config.cancelToken) {
1805
- config.cancelToken.throwIfRequested();
1806
- }
1807
- if (config.signal && config.signal.aborted) {
1808
- throw new CanceledError$1(null, config);
1809
- }
1810
- }
3122
+ */
3123
+ function throwIfCancellationRequested(config) {
3124
+ if (config.cancelToken) {
3125
+ config.cancelToken.throwIfRequested();
3126
+ }
3127
+
3128
+ if (config.signal && config.signal.aborted) {
3129
+ throw new CanceledError$1(null, config)
3130
+ }
3131
+ }
3132
+
1811
3133
  /**
1812
3134
  * Dispatch a request to the server using the configured adapter.
1813
3135
  * 请求如有异常,需向外抛出异常,不拦截
1814
3136
  * @param {object} config The config that is to be used for the request
1815
3137
  *
1816
3138
  * @returns {Promise<*>} The Promise to be fulfilled
1817
- */ function dispatchRequest(config) {
1818
- let R;
1819
- throwIfCancellationRequested(config);
1820
- config.headers = AxiosHeaders$2.from(config.headers);
1821
- // Transform request data
1822
- config.data = transformData.call(config, config.transformRequest);
1823
- if ([
1824
- 'post',
1825
- 'put',
1826
- 'patch'
1827
- ].indexOf(config.method) !== -1) {
1828
- config.headers.setContentType('application/x-www-form-urlencoded', false);
1829
- }
1830
- const Adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
1831
- const adapter = new Adapter(config);
1832
- if (config.stream) R = adapter.request(this);
1833
- else {
1834
- R = adapter.request(this).then((response)=>{
1835
- throwIfCancellationRequested(config);
1836
- // Transform response data
1837
- response.data = transformData.call(config, config.transformResponse, response);
1838
- // ! body === data
1839
- Object.defineProperty(response, 'body', {
1840
- get () {
1841
- return response.data;
1842
- }
1843
- });
1844
- // if (response.data && !response.body) response.body = response.data
1845
- response.headers = AxiosHeaders$2.from(response.headers);
1846
- return response;
1847
- }, (reason)=>{
1848
- if (!isCancel$1(reason)) {
1849
- throwIfCancellationRequested(config);
1850
- // Transform response data
1851
- if (reason && reason.response) {
1852
- reason.response.data = transformData.call(config, config.transformResponse, reason.response);
1853
- // body === data
1854
- if (reason.response.data && !reason.response.body) reason.response.body = reason.response.data;
1855
- reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
1856
- }
1857
- }
1858
- return Promise.reject(reason);
1859
- });
1860
- }
1861
- return R;
3139
+ */
3140
+ function dispatchRequest(config) {
3141
+ let R;
3142
+ throwIfCancellationRequested(config);
3143
+
3144
+ config.headers = AxiosHeaders$2.from(config.headers);
3145
+
3146
+ // Transform request data
3147
+ config.data = transformData.call(config, config.transformRequest);
3148
+
3149
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3150
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3151
+ }
3152
+
3153
+ const Adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
3154
+ const adapter = new Adapter(config);
3155
+
3156
+ if (config.stream) R = adapter.request(this);
3157
+ else {
3158
+ R = adapter.request(this).then(
3159
+ response => {
3160
+ throwIfCancellationRequested(config);
3161
+
3162
+ // Transform response data
3163
+ response.data = transformData.call(config, config.transformResponse, response);
3164
+ // ! body === data
3165
+ Object.defineProperty(response, 'body', {
3166
+ get() {
3167
+ return response.data
3168
+ },
3169
+ });
3170
+ // if (response.data && !response.body) response.body = response.data
3171
+
3172
+ response.headers = AxiosHeaders$2.from(response.headers);
3173
+
3174
+ return response
3175
+ },
3176
+ reason => {
3177
+ if (!isCancel$1(reason)) {
3178
+ throwIfCancellationRequested(config);
3179
+
3180
+ // Transform response data
3181
+ if (reason && reason.response) {
3182
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
3183
+ // body === data
3184
+ if (reason.response.data && !reason.response.body) reason.response.body = reason.response.data;
3185
+ reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
3186
+ }
3187
+ }
3188
+
3189
+ return Promise.reject(reason)
3190
+ }
3191
+ );
3192
+ }
3193
+ return R
1862
3194
  }
1863
3195
 
1864
- const headersToObject = (thing)=>thing instanceof AxiosHeaders$2 ? {
1865
- ...thing
1866
- } : thing;
3196
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? { ...thing } : thing;
3197
+
1867
3198
  /**
1868
3199
  * Config-specific merge-function which creates a new config-object
1869
3200
  * by merging two configuration objects together.
@@ -1872,108 +3203,111 @@ const headersToObject = (thing)=>thing instanceof AxiosHeaders$2 ? {
1872
3203
  * @param {Object} config2
1873
3204
  *
1874
3205
  * @returns {Object} New object resulting from merging config2 to config1
1875
- */ function mergeConfig$1(config1, config2) {
1876
- // eslint-disable-next-line no-param-reassign
1877
- config2 = config2 || {};
1878
- const config = {};
1879
- function getMergedValue(target, source, caseless) {
1880
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1881
- return utils$1.merge.call({
1882
- caseless
1883
- }, target, source);
1884
- } else if (utils$1.isPlainObject(source)) {
1885
- return utils$1.merge({}, source);
1886
- } else if (utils$1.isArray(source)) {
1887
- return source.slice();
1888
- }
1889
- return source;
1890
- }
1891
- // eslint-disable-next-line consistent-return
1892
- function mergeDeepProperties(a, b, caseless) {
1893
- if (!utils$1.isUndefined(b)) {
1894
- return getMergedValue(a, b, caseless);
1895
- } else if (!utils$1.isUndefined(a)) {
1896
- return getMergedValue(undefined, a, caseless);
1897
- }
1898
- }
1899
- // eslint-disable-next-line consistent-return
1900
- function valueFromConfig2(a, b) {
1901
- if (!utils$1.isUndefined(b)) {
1902
- return getMergedValue(undefined, b);
1903
- }
1904
- }
1905
- // eslint-disable-next-line consistent-return
1906
- function defaultToConfig2(a, b) {
1907
- if (!utils$1.isUndefined(b)) {
1908
- return getMergedValue(undefined, b);
1909
- } else if (!utils$1.isUndefined(a)) {
1910
- return getMergedValue(undefined, a);
1911
- }
1912
- }
1913
- // eslint-disable-next-line consistent-return
1914
- function mergeDirectKeys(a, b, prop) {
1915
- if (prop in config2) {
1916
- return getMergedValue(a, b);
1917
- } else if (prop in config1) {
1918
- return getMergedValue(undefined, a);
1919
- }
1920
- }
1921
- const mergeMap = {
1922
- url: valueFromConfig2,
1923
- method: valueFromConfig2,
1924
- data: valueFromConfig2,
1925
- baseURL: defaultToConfig2,
1926
- transformRequest: defaultToConfig2,
1927
- transformResponse: defaultToConfig2,
1928
- paramsSerializer: defaultToConfig2,
1929
- timeout: defaultToConfig2,
1930
- timeoutMessage: defaultToConfig2,
1931
- withCredentials: defaultToConfig2,
1932
- withXSRFToken: defaultToConfig2,
1933
- adapter: defaultToConfig2,
1934
- responseType: defaultToConfig2,
1935
- xsrfCookieName: defaultToConfig2,
1936
- xsrfHeaderName: defaultToConfig2,
1937
- onUploadProgress: defaultToConfig2,
1938
- onDownloadProgress: defaultToConfig2,
1939
- decompress: defaultToConfig2,
1940
- maxContentLength: defaultToConfig2,
1941
- maxBodyLength: defaultToConfig2,
1942
- beforeRedirect: defaultToConfig2,
1943
- transport: defaultToConfig2,
1944
- httpAgent: defaultToConfig2,
1945
- httpsAgent: defaultToConfig2,
1946
- cancelToken: defaultToConfig2,
1947
- socketPath: defaultToConfig2,
1948
- responseEncoding: defaultToConfig2,
1949
- validateStatus: mergeDirectKeys,
1950
- headers: (a, b)=>mergeDeepProperties(headersToObject(a), headersToObject(b), true)
1951
- };
1952
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
1953
- const merge = mergeMap[prop] || mergeDeepProperties;
1954
- const configValue = merge(config1[prop], config2[prop], prop);
1955
- utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
1956
- });
1957
- return config;
3206
+ */
3207
+ function mergeConfig$1(config1, config2) {
3208
+ // eslint-disable-next-line no-param-reassign
3209
+ config2 = config2 || {};
3210
+ const config = {};
3211
+
3212
+ function getMergedValue(target, source, caseless) {
3213
+ if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
3214
+ return utils$2.merge.call({caseless}, target, source);
3215
+ } else if (utils$2.isPlainObject(source)) {
3216
+ return utils$2.merge({}, source);
3217
+ } else if (utils$2.isArray(source)) {
3218
+ return source.slice();
3219
+ }
3220
+ return source;
3221
+ }
3222
+
3223
+ // eslint-disable-next-line consistent-return
3224
+ function mergeDeepProperties(a, b, caseless) {
3225
+ if (!utils$2.isUndefined(b)) {
3226
+ return getMergedValue(a, b, caseless);
3227
+ } else if (!utils$2.isUndefined(a)) {
3228
+ return getMergedValue(undefined, a, caseless);
3229
+ }
3230
+ }
3231
+
3232
+ // eslint-disable-next-line consistent-return
3233
+ function valueFromConfig2(a, b) {
3234
+ if (!utils$2.isUndefined(b)) {
3235
+ return getMergedValue(undefined, b);
3236
+ }
3237
+ }
3238
+
3239
+ // eslint-disable-next-line consistent-return
3240
+ function defaultToConfig2(a, b) {
3241
+ if (!utils$2.isUndefined(b)) {
3242
+ return getMergedValue(undefined, b);
3243
+ } else if (!utils$2.isUndefined(a)) {
3244
+ return getMergedValue(undefined, a);
3245
+ }
3246
+ }
3247
+
3248
+ // eslint-disable-next-line consistent-return
3249
+ function mergeDirectKeys(a, b, prop) {
3250
+ if (prop in config2) {
3251
+ return getMergedValue(a, b);
3252
+ } else if (prop in config1) {
3253
+ return getMergedValue(undefined, a);
3254
+ }
3255
+ }
3256
+
3257
+ const mergeMap = {
3258
+ url: valueFromConfig2,
3259
+ method: valueFromConfig2,
3260
+ data: valueFromConfig2,
3261
+ baseURL: defaultToConfig2,
3262
+ transformRequest: defaultToConfig2,
3263
+ transformResponse: defaultToConfig2,
3264
+ paramsSerializer: defaultToConfig2,
3265
+ timeout: defaultToConfig2,
3266
+ timeoutMessage: defaultToConfig2,
3267
+ withCredentials: defaultToConfig2,
3268
+ withXSRFToken: defaultToConfig2,
3269
+ adapter: defaultToConfig2,
3270
+ responseType: defaultToConfig2,
3271
+ xsrfCookieName: defaultToConfig2,
3272
+ xsrfHeaderName: defaultToConfig2,
3273
+ onUploadProgress: defaultToConfig2,
3274
+ onDownloadProgress: defaultToConfig2,
3275
+ decompress: defaultToConfig2,
3276
+ maxContentLength: defaultToConfig2,
3277
+ maxBodyLength: defaultToConfig2,
3278
+ beforeRedirect: defaultToConfig2,
3279
+ transport: defaultToConfig2,
3280
+ httpAgent: defaultToConfig2,
3281
+ httpsAgent: defaultToConfig2,
3282
+ cancelToken: defaultToConfig2,
3283
+ socketPath: defaultToConfig2,
3284
+ responseEncoding: defaultToConfig2,
3285
+ validateStatus: mergeDirectKeys,
3286
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3287
+ };
3288
+
3289
+ utils$2.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3290
+ const merge = mergeMap[prop] || mergeDeepProperties;
3291
+ const configValue = merge(config1[prop], config2[prop], prop);
3292
+ (utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3293
+ });
3294
+
3295
+ return config;
1958
3296
  }
1959
3297
 
1960
3298
  const VERSION$1 = "1.7.7";
1961
3299
 
1962
- const validators$1 = {};
1963
- // eslint-disable-next-line func-names
1964
- [
1965
- 'object',
1966
- 'boolean',
1967
- 'number',
1968
- 'function',
1969
- 'string',
1970
- 'symbol'
1971
- ].forEach((type, i)=>{
1972
- validators$1[type] = function validator(thing) {
1973
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1974
- };
1975
- });
1976
- const deprecatedWarnings = {};
3300
+ const validators$1 = {};
3301
+
3302
+ // eslint-disable-next-line func-names
3303
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
3304
+ validators$1[type] = function validator(thing) {
3305
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3306
+ };
3307
+ });
3308
+
3309
+ const deprecatedWarnings = {};
3310
+
1977
3311
  /**
1978
3312
  * Transitional option validator
1979
3313
  *
@@ -1982,30 +3316,44 @@ const deprecatedWarnings = {};
1982
3316
  * @param {string?} message - some message with additional info
1983
3317
  *
1984
3318
  * @returns {function}
1985
- */ validators$1.transitional = function transitional(validator, version, message) {
1986
- function formatMessage(opt, desc) {
1987
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1988
- }
1989
- // eslint-disable-next-line func-names
1990
- return (value, opt, opts)=>{
1991
- if (validator === false) {
1992
- throw new AxiosError$1(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError$1.ERR_DEPRECATED);
1993
- }
1994
- if (version && !deprecatedWarnings[opt]) {
1995
- deprecatedWarnings[opt] = true;
1996
- // eslint-disable-next-line no-console
1997
- console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
1998
- }
1999
- return validator ? validator(value, opt, opts) : true;
2000
- };
2001
- };
2002
- validators$1.spelling = function spelling(correctSpelling) {
2003
- return (value, opt)=>{
2004
- // eslint-disable-next-line no-console
2005
- console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2006
- return true;
2007
- };
2008
- };
3319
+ */
3320
+ validators$1.transitional = function transitional(validator, version, message) {
3321
+ function formatMessage(opt, desc) {
3322
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3323
+ }
3324
+
3325
+ // eslint-disable-next-line func-names
3326
+ return (value, opt, opts) => {
3327
+ if (validator === false) {
3328
+ throw new AxiosError$2(
3329
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3330
+ AxiosError$2.ERR_DEPRECATED
3331
+ );
3332
+ }
3333
+
3334
+ if (version && !deprecatedWarnings[opt]) {
3335
+ deprecatedWarnings[opt] = true;
3336
+ // eslint-disable-next-line no-console
3337
+ console.warn(
3338
+ formatMessage(
3339
+ opt,
3340
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3341
+ )
3342
+ );
3343
+ }
3344
+
3345
+ return validator ? validator(value, opt, opts) : true;
3346
+ };
3347
+ };
3348
+
3349
+ validators$1.spelling = function spelling(correctSpelling) {
3350
+ return (value, opt) => {
3351
+ // eslint-disable-next-line no-console
3352
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3353
+ return true;
3354
+ }
3355
+ };
3356
+
2009
3357
  /**
2010
3358
  * Assert object's properties type
2011
3359
  *
@@ -2014,53 +3362,58 @@ validators$1.spelling = function spelling(correctSpelling) {
2014
3362
  * @param {boolean?} allowUnknown
2015
3363
  *
2016
3364
  * @returns {object}
2017
- */ function assertOptions(options, schema, allowUnknown) {
2018
- if (typeof options !== 'object') {
2019
- throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2020
- }
2021
- const keys = Object.keys(options);
2022
- let i = keys.length;
2023
- while(i-- > 0){
2024
- const opt = keys[i];
2025
- const validator = schema[opt];
2026
- if (validator) {
2027
- const value = options[opt];
2028
- const result = value === undefined || validator(value, opt, options);
2029
- if (result !== true) {
2030
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2031
- }
2032
- continue;
2033
- }
2034
- if (allowUnknown !== true) {
2035
- throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2036
- }
2037
- }
2038
- }
2039
- const validator = {
2040
- assertOptions,
2041
- validators: validators$1
3365
+ */
3366
+
3367
+ function assertOptions(options, schema, allowUnknown) {
3368
+ if (typeof options !== 'object') {
3369
+ throw new AxiosError$2('options must be an object', AxiosError$2.ERR_BAD_OPTION_VALUE);
3370
+ }
3371
+ const keys = Object.keys(options);
3372
+ let i = keys.length;
3373
+ while (i-- > 0) {
3374
+ const opt = keys[i];
3375
+ const validator = schema[opt];
3376
+ if (validator) {
3377
+ const value = options[opt];
3378
+ const result = value === undefined || validator(value, opt, options);
3379
+ if (result !== true) {
3380
+ throw new AxiosError$2('option ' + opt + ' must be ' + result, AxiosError$2.ERR_BAD_OPTION_VALUE);
3381
+ }
3382
+ continue;
3383
+ }
3384
+ if (allowUnknown !== true) {
3385
+ throw new AxiosError$2('Unknown option ' + opt, AxiosError$2.ERR_BAD_OPTION);
3386
+ }
3387
+ }
3388
+ }
3389
+
3390
+ const validator = {
3391
+ assertOptions,
3392
+ validators: validators$1
2042
3393
  };
2043
3394
 
2044
- const { validators } = validator;
3395
+ const {validators} = validator;
3396
+
2045
3397
  /**
2046
3398
  * Create a new instance of Axios
2047
3399
  *
2048
3400
  * @param {Object} instanceConfig The default config for the instance
2049
3401
  *
2050
3402
  * @return {Axios} A new instance of Axios
2051
- */ let Axios$1 = class Axios {
2052
- constructor(instanceConfig){
2053
- this.defaults = instanceConfig;
2054
- this.config = this.defaults // !+++
2055
- ;
2056
- this.interceptors = {
2057
- request: new InterceptorManager$1(),
2058
- response: new InterceptorManager$1()
2059
- };
2060
- this.init() // !+++
2061
- ;
2062
- }
2063
- /**
3403
+ */
3404
+ let Axios$1 = class Axios {
3405
+ constructor(instanceConfig) {
3406
+ this.defaults = instanceConfig;
3407
+ this.config = this.defaults; // !+++
3408
+ this.interceptors = {
3409
+ request: new InterceptorManager$1(),
3410
+ response: new InterceptorManager$1(),
3411
+ };
3412
+
3413
+ this.init(); // !+++
3414
+ }
3415
+
3416
+ /**
2064
3417
  * !+++
2065
3418
  * config 属性直接挂在到实例上,方便读取、设置、修改
2066
3419
  * 需注意,不要与其属性、方法冲突!!!
@@ -2073,222 +3426,252 @@ const { validators } = validator;
2073
3426
  put(url[, data[, config]])
2074
3427
  patch(url[, data[, config]])
2075
3428
  getUri([config])
2076
- */ init() {
2077
- const m = this;
2078
- [
2079
- 'url',
2080
- 'method',
2081
- 'baseURL',
2082
- 'transformRequest',
2083
- 'transformResponse',
2084
- 'headers',
2085
- 'params',
2086
- 'paramsSerializer',
2087
- 'body',
2088
- 'data',
2089
- 'timeout',
2090
- 'withCredentials',
2091
- 'adapter',
2092
- 'auth',
2093
- 'responseType',
2094
- 'responseEncoding',
2095
- 'xsrfCookieName',
2096
- 'xsrfHeaderName',
2097
- 'onUploadProgress',
2098
- 'onDownloadProgress',
2099
- 'maxContentLength',
2100
- 'maxBodyLength',
2101
- 'validateStatus',
2102
- 'maxRedirects',
2103
- 'beforeRedirect',
2104
- 'socketPath',
2105
- 'httpAgent',
2106
- 'httpsAgent',
2107
- 'agent',
2108
- 'cancelToken',
2109
- 'signal',
2110
- 'decompress',
2111
- 'insecureHTTPParser',
2112
- 'transitional',
2113
- 'env',
2114
- 'formSerializer',
2115
- 'maxRate'
2116
- ].forEach((p)=>Object.defineProperty(m, p, {
2117
- enumerable: true,
2118
- get () {
2119
- return m.config[p];
2120
- },
2121
- set (value) {
2122
- m.config[p] = value;
2123
- }
2124
- }));
2125
- }
2126
- /**
3429
+ */
3430
+ init() {
3431
+ const m = this
3432
+ ;[
3433
+ 'url',
3434
+ 'method',
3435
+ 'baseURL',
3436
+ 'transformRequest', // [function],
3437
+ 'transformResponse',
3438
+ 'headers', // {'X-Requested-With': 'XMLHttpRequest'},
3439
+ 'params', // {ID: 12345},
3440
+ 'paramsSerializer',
3441
+ 'body',
3442
+ 'data', // {firstName: 'Fred'}, 'Country=Brasil&City=Belo',
3443
+ 'timeout', // default is `0` (no timeout)
3444
+ 'withCredentials', // default false
3445
+ 'adapter', // func
3446
+ 'auth', // {username: 'janedoe', password: 's00pers3cret'}
3447
+ 'responseType', // default 'json'
3448
+ 'responseEncoding', // default 'utf8'
3449
+ 'xsrfCookieName', // default 'XSRF-TOKEN'
3450
+ 'xsrfHeaderName', // default 'X-XSRF-TOKEN'
3451
+ 'onUploadProgress', // func
3452
+ 'onDownloadProgress', // func
3453
+ 'maxContentLength',
3454
+ 'maxBodyLength',
3455
+ 'validateStatus', // status => status >= 200 && status < 300;
3456
+ 'maxRedirects', // default 21
3457
+ 'beforeRedirect', // (options, { headers }) => {}
3458
+ 'socketPath', // default null
3459
+ 'httpAgent', // new http.Agent({ keepAlive: true }),
3460
+ 'httpsAgent', // new https.Agent({ keepAlive: true }),
3461
+ 'agent', // {},
3462
+ 'cancelToken', // new CancelToken(function (cancel) {}),
3463
+ 'signal', // new AbortController().signal,
3464
+ 'decompress', // default true
3465
+ 'insecureHTTPParser', // default undefined
3466
+ 'transitional',
3467
+ 'env', // {FormData: window?.FormData || global?.FormData},
3468
+ 'formSerializer',
3469
+ 'maxRate', // [100 * 1024, 100 * 1024] // upload, download limit
3470
+ ].forEach(p =>
3471
+ Object.defineProperty(m, p, {
3472
+ enumerable: true,
3473
+ get() {
3474
+ return m.config[p]
3475
+ },
3476
+
3477
+ set(value) {
3478
+ m.config[p] = value;
3479
+ },
3480
+ })
3481
+ );
3482
+ }
3483
+
3484
+ /**
2127
3485
  * Dispatch a request
2128
3486
  * 启动执行请求,返回 Promise 实例
2129
3487
  * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2130
3488
  * @param {?Object} config
2131
3489
  * @returns {Promise} The Promise to be fulfilled
2132
- */ async request(configOrUrl, config) {
2133
- try {
2134
- return await this._request(configOrUrl, config);
2135
- } catch (err) {
2136
- if (err instanceof Error) {
2137
- let dummy = {};
2138
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2139
- // slice off the Error: ... line
2140
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
2141
- try {
2142
- if (!err.stack) {
2143
- err.stack = stack;
2144
- // match without the 2 top stack lines
2145
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
2146
- err.stack += '\n' + stack;
2147
- }
2148
- } catch (e) {
2149
- // ignore the case where "stack" is an un-writable property
2150
- }
2151
- }
2152
- throw err // 抛出异常
2153
- ;
2154
- }
2155
- }
2156
- /**
3490
+ */
3491
+ async request(configOrUrl, config) {
3492
+ try {
3493
+ return await this._request(configOrUrl, config)
3494
+ } catch (err) {
3495
+ if (err instanceof Error) {
3496
+ let dummy = {};
3497
+
3498
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3499
+
3500
+ // slice off the Error: ... line
3501
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3502
+ try {
3503
+ if (!err.stack) {
3504
+ err.stack = stack;
3505
+ // match without the 2 top stack lines
3506
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3507
+ err.stack += '\n' + stack;
3508
+ }
3509
+ } catch (e) {
3510
+ // ignore the case where "stack" is an un-writable property
3511
+ }
3512
+ }
3513
+
3514
+ throw err // 抛出异常
3515
+ }
3516
+ }
3517
+
3518
+ /**
2157
3519
  * 执行请求
2158
3520
  * @param {*} configOrUrl
2159
3521
  * @param {*} config
2160
3522
  * @param {boolean} [stream = false] - 是否返回 stream
2161
3523
  * @returns
2162
- */ _request(configOrUrl, config, stream = false) {
2163
- let R = null;
2164
- /* eslint no-param-reassign:0 */ // Allow for axios('example/url'[, config]) a la fetch API
2165
- if (typeof configOrUrl === 'string') {
2166
- config = config || {};
2167
- config.url = configOrUrl;
2168
- } else {
2169
- config = configOrUrl || {};
2170
- }
2171
- // ! body as data alias, body ==> data,内部保持data不变
2172
- if (!config.data && config.body) {
2173
- config.data = config.body;
2174
- // config.body = undefined;
2175
- }
2176
- config = mergeConfig$1(this.defaults, config);
2177
- const { transitional, paramsSerializer, headers } = config;
2178
- if (transitional !== undefined) {
2179
- validator.assertOptions(transitional, {
2180
- silentJSONParsing: validators.transitional(validators.boolean),
2181
- forcedJSONParsing: validators.transitional(validators.boolean),
2182
- clarifyTimeoutError: validators.transitional(validators.boolean)
2183
- }, false);
2184
- }
2185
- if (paramsSerializer) {
2186
- if (utils$1.isFunction(paramsSerializer)) {
2187
- config.paramsSerializer = {
2188
- serialize: paramsSerializer
2189
- };
2190
- } else {
2191
- validator.assertOptions(paramsSerializer, {
2192
- encode: validators.function,
2193
- serialize: validators.function
2194
- }, true);
2195
- }
2196
- }
2197
- validator.assertOptions(config, {
2198
- baseUrl: validators.spelling('baseURL'),
2199
- withXsrfToken: validators.spelling('withXSRFToken')
2200
- }, true);
2201
- // Set config.method
2202
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2203
- // Flatten headers,方法头覆盖通用头
2204
- const contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
2205
- headers && utils$1.forEach([
2206
- 'delete',
2207
- 'get',
2208
- 'head',
2209
- 'post',
2210
- 'put',
2211
- 'patch',
2212
- 'common'
2213
- ], (method)=>{
2214
- delete headers[method];
2215
- });
2216
- // 源值存在,则不覆盖,contextHeaders 优先于 headers
2217
- config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
2218
- // filter out skipped interceptors
2219
- const requestInterceptorChain = [] // 请求拦截器,hook
2220
- ;
2221
- let synchronousRequestInterceptors = true;
2222
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2223
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2224
- return;
2225
- }
2226
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2227
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2228
- });
2229
- const responseInterceptorChain = [] // 响应拦截器,hook
2230
- ;
2231
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2232
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2233
- });
2234
- let promise;
2235
- let i = 0;
2236
- let len;
2237
- debugger;
2238
- // 执行dispatchRequest
2239
- // !+++ stream
2240
- if (stream) {
2241
- config.stream = true;
2242
- R = dispatchRequest.call(this, config) // not promise
2243
- ;
2244
- } else if (!synchronousRequestInterceptors) {
2245
- // 异步拦截器
2246
- const chain = [
2247
- dispatchRequest.bind(this),
2248
- undefined
2249
- ] // dispatchRequest 放入运行链
2250
- ;
2251
- chain.unshift(...requestInterceptorChain) // !*** 插入头
2252
- ;
2253
- chain.push(...responseInterceptorChain) // !*** 加入尾
2254
- ;
2255
- len = chain.length;
2256
- promise = Promise.resolve(config) // promise 对象
2257
- ;
2258
- // 传入config配置,按顺序执行
2259
- while(i < len)promise = promise.then(chain[i++], chain[i++]);
2260
- R = promise;
2261
- } else {
2262
- // 同步拦截器
2263
- len = requestInterceptorChain.length;
2264
- let newConfig = config;
2265
- i = 0;
2266
- // 按加入顺序运行 request 拦截器
2267
- while(i < len){
2268
- const onFulfilled = requestInterceptorChain[i++];
2269
- const onRejected = requestInterceptorChain[i++];
2270
- try {
2271
- newConfig = onFulfilled(newConfig) // 执行
2272
- ;
2273
- } catch (error) {
2274
- onRejected.call(this, error);
2275
- break;
2276
- }
2277
- }
2278
- try {
2279
- promise = dispatchRequest.call(this, newConfig);
2280
- i = 0;
2281
- len = responseInterceptorChain.length;
2282
- // 按顺序执行响应 hook
2283
- while(i < len)promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2284
- R = promise;
2285
- } catch (error) {
2286
- R = Promise.reject(error);
2287
- }
2288
- }
2289
- return R;
2290
- }
2291
- /**
3524
+ */
3525
+ _request(configOrUrl, config, stream = false) {
3526
+ let R = null;
3527
+
3528
+ /* eslint no-param-reassign:0 */
3529
+ // Allow for axios('example/url'[, config]) a la fetch API
3530
+ if (typeof configOrUrl === 'string') {
3531
+ config = config || {};
3532
+ config.url = configOrUrl;
3533
+ } else {
3534
+ config = configOrUrl || {};
3535
+ }
3536
+
3537
+ // ! body as data alias, body ==> data,内部保持data不变
3538
+ if (!config.data && config.body) {
3539
+ config.data = config.body;
3540
+ // config.body = undefined;
3541
+ }
3542
+
3543
+ config = mergeConfig$1(this.defaults, config);
3544
+
3545
+ const {transitional, paramsSerializer, headers} = config;
3546
+
3547
+ if (transitional !== undefined) {
3548
+ validator.assertOptions(
3549
+ transitional,
3550
+ {
3551
+ silentJSONParsing: validators.transitional(validators.boolean),
3552
+ forcedJSONParsing: validators.transitional(validators.boolean),
3553
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3554
+ },
3555
+ false
3556
+ );
3557
+ }
3558
+
3559
+ if (paramsSerializer) {
3560
+ if (utils$2.isFunction(paramsSerializer)) {
3561
+ config.paramsSerializer = {
3562
+ serialize: paramsSerializer,
3563
+ };
3564
+ } else {
3565
+ validator.assertOptions(
3566
+ paramsSerializer,
3567
+ {
3568
+ encode: validators.function,
3569
+ serialize: validators.function,
3570
+ },
3571
+ true
3572
+ );
3573
+ }
3574
+ }
3575
+
3576
+ validator.assertOptions(
3577
+ config,
3578
+ {
3579
+ baseUrl: validators.spelling('baseURL'),
3580
+ withXsrfToken: validators.spelling('withXSRFToken'),
3581
+ },
3582
+ true
3583
+ );
3584
+
3585
+ // Set config.method
3586
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3587
+
3588
+ // Flatten headers,方法头覆盖通用头
3589
+ const contextHeaders = headers && utils$2.merge(headers.common, headers[config.method]);
3590
+
3591
+ headers &&
3592
+ utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], method => {
3593
+ delete headers[method];
3594
+ });
3595
+
3596
+ // 源值存在,则不覆盖,contextHeaders 优先于 headers
3597
+ config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
3598
+
3599
+ // filter out skipped interceptors
3600
+ const requestInterceptorChain = []; // 请求拦截器,hook
3601
+ let synchronousRequestInterceptors = true;
3602
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3603
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3604
+ return
3605
+ }
3606
+
3607
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3608
+
3609
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3610
+ });
3611
+
3612
+ const responseInterceptorChain = []; // 响应拦截器,hook
3613
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3614
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3615
+ });
3616
+
3617
+ let promise;
3618
+ let i = 0;
3619
+ let len;
3620
+ debugger
3621
+ // 执行dispatchRequest
3622
+ // !+++ stream
3623
+ if (stream) {
3624
+ config.stream = true;
3625
+ R = dispatchRequest.call(this, config); // not promise
3626
+ } else if (!synchronousRequestInterceptors) {
3627
+ // 异步拦截器
3628
+ const chain = [dispatchRequest.bind(this), undefined]; // dispatchRequest 放入运行链
3629
+ chain.unshift(...requestInterceptorChain); // !*** 插入头
3630
+ chain.push(...responseInterceptorChain); // !*** 加入尾
3631
+ len = chain.length;
3632
+
3633
+ promise = Promise.resolve(config); // promise 对象
3634
+
3635
+ // 传入config配置,按顺序执行
3636
+ while (i < len) promise = promise.then(chain[i++], chain[i++]);
3637
+
3638
+ R = promise;
3639
+ } else {
3640
+ // 同步拦截器
3641
+ len = requestInterceptorChain.length;
3642
+ let newConfig = config;
3643
+ i = 0;
3644
+
3645
+ // 按加入顺序运行 request 拦截器
3646
+ while (i < len) {
3647
+ const onFulfilled = requestInterceptorChain[i++];
3648
+ const onRejected = requestInterceptorChain[i++];
3649
+ try {
3650
+ newConfig = onFulfilled(newConfig); // 执行
3651
+ } catch (error) {
3652
+ onRejected.call(this, error);
3653
+ break
3654
+ }
3655
+ }
3656
+
3657
+ try {
3658
+ promise = dispatchRequest.call(this, newConfig);
3659
+ i = 0;
3660
+ len = responseInterceptorChain.length;
3661
+
3662
+ // 按顺序执行响应 hook
3663
+ while (i < len) promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3664
+
3665
+ R = promise;
3666
+ } catch (error) {
3667
+ R = Promise.reject(error);
3668
+ }
3669
+ }
3670
+
3671
+ return R
3672
+ }
3673
+
3674
+ /**
2292
3675
  * !+++
2293
3676
  * 类似 request 库,返回 stream
2294
3677
  * stream 模式下,拦截器无效
@@ -2297,99 +3680,111 @@ const { validators } = validator;
2297
3680
  * @param {*} configOrUrl
2298
3681
  * @param {*} config
2299
3682
  * @returns
2300
- */ stream(configOrUrl, config) {
2301
- return this._request(configOrUrl, config, true);
2302
- }
2303
- /**
3683
+ */
3684
+ stream(configOrUrl, config) {
3685
+ return this._request(configOrUrl, config, true)
3686
+ }
3687
+
3688
+ /**
2304
3689
  *
2305
3690
  * @param {*} config
2306
3691
  * @returns
2307
- */ getUri(config) {
2308
- config = mergeConfig$1(this.defaults, config);
2309
- const fullPath = buildFullPath(config.baseURL, config.url);
2310
- return buildURL(fullPath, config.params, config.paramsSerializer);
2311
- }
2312
- };
2313
- // Provide aliases for supported request methods
2314
- utils$1.forEach([
2315
- 'head',
2316
- 'options'
2317
- ], function forEachMethodNoData(method) {
2318
- /* eslint func-names:0 */ Axios$1.prototype[method] = function(url, config) {
2319
- return this.request(mergeConfig$1(config || {}, {
2320
- method,
2321
- url,
2322
- data: (config || {}).data
2323
- }));
2324
- };
2325
- });
2326
- // delete、get, 与 axios不同,第二个参数为 params,而不是 data
2327
- utils$1.forEach([
2328
- 'delete',
2329
- 'get'
2330
- ], function forEachMethodNoData(method) {
2331
- Axios$1.prototype[method] = function(url, params, config) {
2332
- return this.request(mergeConfig$1(config || {}, {
2333
- method,
2334
- url,
2335
- params
2336
- }));
2337
- };
2338
- });
2339
- utils$1.forEach([
2340
- 'post',
2341
- 'put',
2342
- 'patch'
2343
- ], function forEachMethodWithData(method) {
2344
- function generateHTTPMethod(isForm) {
2345
- return function httpMethod(url, data, config) {
2346
- return this.request(mergeConfig$1(config || {}, {
2347
- method,
2348
- headers: isForm ? {
2349
- 'Content-Type': 'multipart/form-data'
2350
- } : {},
2351
- url,
2352
- data
2353
- }));
2354
- };
2355
- }
2356
- Axios$1.prototype[method] = generateHTTPMethod();
2357
- Axios$1.prototype[`${method}Form`] = generateHTTPMethod(true);
2358
- });
2359
- // stream get, 与 axios不同,第二个参数为 params,而不是 data
2360
- utils$1.forEach([
2361
- 'gets'
2362
- ], function forEachMethodNoData(method) {
2363
- Axios$1.prototype[method] = function(url, params, config) {
2364
- return this.stream(mergeConfig$1(config || {}, {
2365
- method,
2366
- url,
2367
- params,
2368
- data: (config || {}).data
2369
- }));
2370
- };
2371
- });
2372
- // stream post put patch
2373
- utils$1.forEach([
2374
- 'posts',
2375
- 'puts',
2376
- 'patchs'
2377
- ], function forEachMethodWithData(method) {
2378
- function generateStreamMethod(isForm) {
2379
- return function httpMethod(url, data, config) {
2380
- return this.stream(mergeConfig$1(config || {}, {
2381
- method,
2382
- headers: isForm ? {
2383
- 'Content-Type': 'multipart/form-data'
2384
- } : {},
2385
- url,
2386
- data
2387
- }));
2388
- };
2389
- }
2390
- Axios$1.prototype[method] = generateStreamMethod();
2391
- Axios$1.prototype[`${method}Forms`] = generateStreamMethod(true);
2392
- });
3692
+ */
3693
+ getUri(config) {
3694
+ config = mergeConfig$1(this.defaults, config);
3695
+ const fullPath = buildFullPath(config.baseURL, config.url);
3696
+ return buildURL(fullPath, config.params, config.paramsSerializer)
3697
+ }
3698
+ };
3699
+
3700
+ // Provide aliases for supported request methods
3701
+ utils$2.forEach(['head', 'options'], function forEachMethodNoData(method) {
3702
+ /* eslint func-names:0 */
3703
+ Axios$1.prototype[method] = function (url, config) {
3704
+ return this.request(
3705
+ mergeConfig$1(config || {}, {
3706
+ method,
3707
+ url,
3708
+ data: (config || {}).data,
3709
+ })
3710
+ )
3711
+ };
3712
+ });
3713
+
3714
+ // delete、get, 与 axios不同,第二个参数为 params,而不是 data
3715
+ utils$2.forEach(['delete', 'get'], function forEachMethodNoData(method) {
3716
+ Axios$1.prototype[method] = function (url, params, config) {
3717
+ return this.request(
3718
+ mergeConfig$1(config || {}, {
3719
+ method,
3720
+ url,
3721
+ params,
3722
+ })
3723
+ )
3724
+ };
3725
+ });
3726
+
3727
+ utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3728
+ function generateHTTPMethod(isForm) {
3729
+ return function httpMethod(url, data, config) {
3730
+ return this.request(
3731
+ mergeConfig$1(config || {}, {
3732
+ method,
3733
+ headers: isForm
3734
+ ? {
3735
+ 'Content-Type': 'multipart/form-data',
3736
+ }
3737
+ : {},
3738
+ url,
3739
+ data,
3740
+ })
3741
+ )
3742
+ }
3743
+ }
3744
+
3745
+ Axios$1.prototype[method] = generateHTTPMethod();
3746
+
3747
+ Axios$1.prototype[`${method}Form`] = generateHTTPMethod(true);
3748
+ });
3749
+
3750
+ // stream get, 与 axios不同,第二个参数为 params,而不是 data
3751
+ utils$2.forEach(['gets'], function forEachMethodNoData(method) {
3752
+ Axios$1.prototype[method] = function (url, params, config) {
3753
+ return this.stream(
3754
+ mergeConfig$1(config || {}, {
3755
+ method,
3756
+ url,
3757
+ params,
3758
+ data: (config || {}).data,
3759
+ })
3760
+ )
3761
+ };
3762
+ });
3763
+
3764
+ // stream post put patch
3765
+ utils$2.forEach(['posts', 'puts', 'patchs'], function forEachMethodWithData(method) {
3766
+ function generateStreamMethod(isForm) {
3767
+ return function httpMethod(url, data, config) {
3768
+ return this.stream(
3769
+ mergeConfig$1(config || {}, {
3770
+ method,
3771
+ headers: isForm
3772
+ ? {
3773
+ 'Content-Type': 'multipart/form-data',
3774
+ }
3775
+ : {},
3776
+ url,
3777
+ data,
3778
+ })
3779
+ )
3780
+ }
3781
+ }
3782
+
3783
+ Axios$1.prototype[method] = generateStreamMethod();
3784
+
3785
+ Axios$1.prototype[`${method}Forms`] = generateStreamMethod(true);
3786
+ });
3787
+
2393
3788
  const Axios$2 = Axios$1;
2394
3789
 
2395
3790
  /**
@@ -2398,103 +3793,130 @@ const Axios$2 = Axios$1;
2398
3793
  * @param {Function} executor The executor function.
2399
3794
  *
2400
3795
  * @returns {CancelToken}
2401
- */ let CancelToken$1 = class CancelToken {
2402
- constructor(executor){
2403
- if (typeof executor !== 'function') {
2404
- throw new TypeError('executor must be a function.');
2405
- }
2406
- let resolvePromise;
2407
- this.promise = new Promise(function promiseExecutor(resolve) {
2408
- resolvePromise = resolve;
2409
- });
2410
- const token = this;
2411
- // eslint-disable-next-line func-names
2412
- this.promise.then((cancel)=>{
2413
- if (!token._listeners) return;
2414
- let i = token._listeners.length;
2415
- while(i-- > 0){
2416
- token._listeners[i](cancel);
2417
- }
2418
- token._listeners = null;
2419
- });
2420
- // eslint-disable-next-line func-names
2421
- this.promise.then = (onfulfilled)=>{
2422
- let _resolve;
2423
- // eslint-disable-next-line func-names
2424
- const promise = new Promise((resolve)=>{
2425
- token.subscribe(resolve);
2426
- _resolve = resolve;
2427
- }).then(onfulfilled);
2428
- promise.cancel = function reject() {
2429
- token.unsubscribe(_resolve);
2430
- };
2431
- return promise;
2432
- };
2433
- executor(function cancel(message, config, request) {
2434
- if (token.reason) {
2435
- // Cancellation has already been requested
2436
- return;
2437
- }
2438
- token.reason = new CanceledError$1(message, config, request);
2439
- resolvePromise(token.reason);
2440
- });
2441
- }
2442
- /**
3796
+ */
3797
+ let CancelToken$1 = class CancelToken {
3798
+ constructor(executor) {
3799
+ if (typeof executor !== 'function') {
3800
+ throw new TypeError('executor must be a function.');
3801
+ }
3802
+
3803
+ let resolvePromise;
3804
+
3805
+ this.promise = new Promise(function promiseExecutor(resolve) {
3806
+ resolvePromise = resolve;
3807
+ });
3808
+
3809
+ const token = this;
3810
+
3811
+ // eslint-disable-next-line func-names
3812
+ this.promise.then(cancel => {
3813
+ if (!token._listeners) return;
3814
+
3815
+ let i = token._listeners.length;
3816
+
3817
+ while (i-- > 0) {
3818
+ token._listeners[i](cancel);
3819
+ }
3820
+ token._listeners = null;
3821
+ });
3822
+
3823
+ // eslint-disable-next-line func-names
3824
+ this.promise.then = onfulfilled => {
3825
+ let _resolve;
3826
+ // eslint-disable-next-line func-names
3827
+ const promise = new Promise(resolve => {
3828
+ token.subscribe(resolve);
3829
+ _resolve = resolve;
3830
+ }).then(onfulfilled);
3831
+
3832
+ promise.cancel = function reject() {
3833
+ token.unsubscribe(_resolve);
3834
+ };
3835
+
3836
+ return promise;
3837
+ };
3838
+
3839
+ executor(function cancel(message, config, request) {
3840
+ if (token.reason) {
3841
+ // Cancellation has already been requested
3842
+ return;
3843
+ }
3844
+
3845
+ token.reason = new CanceledError$1(message, config, request);
3846
+ resolvePromise(token.reason);
3847
+ });
3848
+ }
3849
+
3850
+ /**
2443
3851
  * Throws a `CanceledError` if cancellation has been requested.
2444
- */ throwIfRequested() {
2445
- if (this.reason) {
2446
- throw this.reason;
2447
- }
2448
- }
2449
- /**
3852
+ */
3853
+ throwIfRequested() {
3854
+ if (this.reason) {
3855
+ throw this.reason;
3856
+ }
3857
+ }
3858
+
3859
+ /**
2450
3860
  * Subscribe to the cancel signal
2451
- */ subscribe(listener) {
2452
- if (this.reason) {
2453
- listener(this.reason);
2454
- return;
2455
- }
2456
- if (this._listeners) {
2457
- this._listeners.push(listener);
2458
- } else {
2459
- this._listeners = [
2460
- listener
2461
- ];
2462
- }
2463
- }
2464
- /**
3861
+ */
3862
+
3863
+ subscribe(listener) {
3864
+ if (this.reason) {
3865
+ listener(this.reason);
3866
+ return;
3867
+ }
3868
+
3869
+ if (this._listeners) {
3870
+ this._listeners.push(listener);
3871
+ } else {
3872
+ this._listeners = [listener];
3873
+ }
3874
+ }
3875
+
3876
+ /**
2465
3877
  * Unsubscribe from the cancel signal
2466
- */ unsubscribe(listener) {
2467
- if (!this._listeners) {
2468
- return;
2469
- }
2470
- const index = this._listeners.indexOf(listener);
2471
- if (index !== -1) {
2472
- this._listeners.splice(index, 1);
2473
- }
2474
- }
2475
- toAbortSignal() {
2476
- const controller = new AbortController();
2477
- const abort = (err)=>{
2478
- controller.abort(err);
2479
- };
2480
- this.subscribe(abort);
2481
- controller.signal.unsubscribe = ()=>this.unsubscribe(abort);
2482
- return controller.signal;
2483
- }
2484
- /**
3878
+ */
3879
+
3880
+ unsubscribe(listener) {
3881
+ if (!this._listeners) {
3882
+ return;
3883
+ }
3884
+ const index = this._listeners.indexOf(listener);
3885
+ if (index !== -1) {
3886
+ this._listeners.splice(index, 1);
3887
+ }
3888
+ }
3889
+
3890
+ toAbortSignal() {
3891
+ const controller = new AbortController();
3892
+
3893
+ const abort = (err) => {
3894
+ controller.abort(err);
3895
+ };
3896
+
3897
+ this.subscribe(abort);
3898
+
3899
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3900
+
3901
+ return controller.signal;
3902
+ }
3903
+
3904
+ /**
2485
3905
  * Returns an object that contains a new `CancelToken` and a function that, when called,
2486
3906
  * cancels the `CancelToken`.
2487
- */ static source() {
2488
- let cancel;
2489
- const token = new CancelToken(function executor(c) {
2490
- cancel = c;
2491
- });
2492
- return {
2493
- token,
2494
- cancel
2495
- };
2496
- }
2497
- };
3907
+ */
3908
+ static source() {
3909
+ let cancel;
3910
+ const token = new CancelToken(function executor(c) {
3911
+ cancel = c;
3912
+ });
3913
+ return {
3914
+ token,
3915
+ cancel
3916
+ };
3917
+ }
3918
+ };
3919
+
2498
3920
  const CancelToken$2 = CancelToken$1;
2499
3921
 
2500
3922
  /**
@@ -2517,10 +3939,11 @@ const CancelToken$2 = CancelToken$1;
2517
3939
  * @param {Function} callback
2518
3940
  *
2519
3941
  * @returns {Function}
2520
- */ function spread$1(callback) {
2521
- return function wrap(arr) {
2522
- return callback.apply(null, arr);
2523
- };
3942
+ */
3943
+ function spread$1(callback) {
3944
+ return function wrap(arr) {
3945
+ return callback.apply(null, arr);
3946
+ };
2524
3947
  }
2525
3948
 
2526
3949
  /**
@@ -2529,8 +3952,9 @@ const CancelToken$2 = CancelToken$1;
2529
3952
  * @param {*} payload The value to test
2530
3953
  *
2531
3954
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2532
- */ function isAxiosError$1(payload) {
2533
- return utils$1.isObject(payload) && payload.isAxiosError === true;
3955
+ */
3956
+ function isAxiosError$1(payload) {
3957
+ return utils$2.isObject(payload) && (payload.isAxiosError === true);
2534
3958
  }
2535
3959
 
2536
3960
  /**
@@ -2539,71 +3963,86 @@ const CancelToken$2 = CancelToken$1;
2539
3963
  * @param {Object} defaultConfig The default config for the instance
2540
3964
  *
2541
3965
  * @returns {Axios} A new instance of Axios
2542
- */ function createInstance(defaultConfig) {
2543
- const context = new Axios$2(defaultConfig);
2544
- const instance = bind(Axios$2.prototype.request, context);
2545
- // Copy axios.prototype to instance
2546
- utils$1.extend(instance, Axios$2.prototype, context, {
2547
- allOwnKeys: true
2548
- });
2549
- // Copy context to instance
2550
- utils$1.extend(instance, context, null, {
2551
- allOwnKeys: true
2552
- });
2553
- // Factory for creating new instances
2554
- instance.create = function create(instanceConfig) {
2555
- return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2556
- };
2557
- return instance;
2558
- }
2559
- // Create the default instance to be exported
2560
- const req = createInstance(defaults$1);
2561
- // Expose Axios class to allow class inheritance
2562
- req.Axios = Axios$2;
2563
- // Expose Cancel & CancelToken
2564
- req.CanceledError = CanceledError$1;
2565
- req.CancelToken = CancelToken$2;
2566
- req.isCancel = isCancel$1;
2567
- req.VERSION = VERSION$1;
2568
- req.toFormData = toFormData$1;
2569
- // Expose AxiosError class
2570
- req.AxiosError = AxiosError$1;
2571
- // alias for CanceledError for backward compatibility
2572
- req.Cancel = req.CanceledError;
2573
- // Expose all/spread
2574
- req.all = (promises)=>Promise.all(promises);
2575
- req.spread = spread$1;
2576
- // Expose isAxiosError
2577
- req.isAxiosError = isAxiosError$1;
2578
- // Expose mergeConfig
2579
- req.mergeConfig = mergeConfig$1;
2580
- req.AxiosHeaders = AxiosHeaders$2;
2581
- req.formToJSON = (thing)=>formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2582
- req.getAdapter = adapters.getAdapter;
2583
- req.default = req;
2584
- // this module should only have a default export
3966
+ */
3967
+ function createInstance(defaultConfig) {
3968
+ const context = new Axios$2(defaultConfig);
3969
+ const instance = bind$1(Axios$2.prototype.request, context);
3970
+
3971
+ // Copy axios.prototype to instance
3972
+ utils$2.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
3973
+
3974
+ // Copy context to instance
3975
+ utils$2.extend(instance, context, null, {allOwnKeys: true});
3976
+
3977
+ // Factory for creating new instances
3978
+ instance.create = function create(instanceConfig) {
3979
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3980
+ };
3981
+
3982
+ return instance;
3983
+ }
3984
+
3985
+ // Create the default instance to be exported
3986
+ const req = createInstance(defaults$1);
3987
+
3988
+ // Expose Axios class to allow class inheritance
3989
+ req.Axios = Axios$2;
3990
+
3991
+ // Expose Cancel & CancelToken
3992
+ req.CanceledError = CanceledError$1;
3993
+ req.CancelToken = CancelToken$2;
3994
+ req.isCancel = isCancel$1;
3995
+ req.VERSION = VERSION$1;
3996
+ req.toFormData = toFormData$2;
3997
+
3998
+ // Expose AxiosError class
3999
+ req.AxiosError = AxiosError$2;
4000
+
4001
+ // alias for CanceledError for backward compatibility
4002
+ req.Cancel = req.CanceledError;
4003
+
4004
+ // Expose all/spread
4005
+ req.all = promises => Promise.all(promises);
4006
+
4007
+ req.spread = spread$1;
4008
+
4009
+ // Expose isAxiosError
4010
+ req.isAxiosError = isAxiosError$1;
4011
+
4012
+ // Expose mergeConfig
4013
+ req.mergeConfig = mergeConfig$1;
4014
+
4015
+ req.AxiosHeaders = AxiosHeaders$2;
4016
+
4017
+ req.formToJSON = thing => formDataToJSON(utils$2.isHTMLForm(thing) ? new FormData(thing) : thing);
4018
+
4019
+ req.getAdapter = adapters.getAdapter;
4020
+
4021
+ req.default = req;
4022
+
4023
+ // this module should only have a default export
2585
4024
  const req$1 = req;
2586
4025
 
2587
4026
  // This module is intended to unwrap Axios default export as named.
2588
4027
  // Keep top-level export same with static properties
2589
4028
  // so that it can keep same with es module or cjs
2590
4029
  const {
2591
- Axios,
2592
- AxiosError,
2593
- CanceledError,
2594
- isCancel,
2595
- CancelToken,
2596
- VERSION,
2597
- all,
2598
- Cancel,
2599
- isAxiosError,
2600
- spread,
2601
- toFormData,
2602
- AxiosHeaders,
2603
- HttpStatusCode,
2604
- formToJSON,
2605
- getAdapter,
2606
- mergeConfig,
4030
+ Axios,
4031
+ AxiosError,
4032
+ CanceledError,
4033
+ isCancel,
4034
+ CancelToken,
4035
+ VERSION,
4036
+ all,
4037
+ Cancel,
4038
+ isAxiosError,
4039
+ spread,
4040
+ toFormData,
4041
+ AxiosHeaders,
4042
+ HttpStatusCode,
4043
+ formToJSON,
4044
+ getAdapter,
4045
+ mergeConfig,
2607
4046
  } = req$1;
2608
4047
 
2609
4048
  export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, req$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };