@eodash/eodash 5.6.1 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/client/components/DashboardLayout.vue +1 -1
- package/core/client/composables/index.js +6 -2
- package/core/client/eodashSTAC/EodashCollection.js +5 -25
- package/core/client/eodashSTAC/createLayers.js +23 -9
- package/core/client/eodashSTAC/helpers.js +33 -0
- package/core/client/types.ts +8 -1
- package/core/client/utils/index.js +4 -0
- package/dist/client/{DashboardLayout-CqMb7OXc.js → DashboardLayout-kRsmsNW5.js} +5 -5
- package/dist/client/{DynamicWebComponent-DqKqTf7l.js → DynamicWebComponent-CnKhYo0K.js} +1 -1
- package/dist/client/{EodashChart-PkUQfH0k.js → EodashChart-CLDqE93C.js} +4 -4
- package/dist/client/{EodashDatePicker-DLJGdTtX.js → EodashDatePicker-CMPDT-ce.js} +3 -3
- package/dist/client/{EodashItemFilter-Dk8KjFcX.js → EodashItemFilter-BpdA8QQa.js} +1 -1
- package/dist/client/{EodashLayerControl-CC1Cogrn.js → EodashLayerControl-BHpDA4_0.js} +25 -7
- package/dist/client/{EodashLayoutSwitcher-5WZYd6rr.js → EodashLayoutSwitcher-B1fRUt7G.js} +3 -3
- package/dist/client/EodashMapBtns-Cpned0tc.js +478 -0
- package/dist/client/{EodashStacInfo-B90wobPc.js → EodashStacInfo-BQspAHKH.js} +1 -1
- package/dist/client/{EodashTools-CGZtTh45.js → EodashTools-1zHz26gv.js} +4 -4
- package/dist/client/{ExportState-Ce0ZnrX_.js → ExportState-DbOm8hBI.js} +4 -4
- package/dist/client/{Footer-CnZqEiop.js → Footer-BKg-VVkj.js} +1 -1
- package/dist/client/{Header-Dr5PBIm8.js → Header-DCrwCvmY.js} +2 -2
- package/dist/client/MobileLayout-vWSHpluo.js +118 -0
- package/dist/client/{PopUp-DjvE_71e.js → PopUp-9uimfK49.js} +2 -2
- package/dist/client/{ProcessList-kf3olI7W.js → ProcessList-CTTIZa06.js} +4 -4
- package/dist/client/{VImg-Bj6uWt6j.js → VImg-CrmB76ZY.js} +2 -2
- package/dist/client/{VMain-Cm0UmKGi.js → VMain-OKZNpcEG.js} +1 -1
- package/dist/client/{VTooltip-DbBu-ky3.js → VTooltip-CJw2FyWk.js} +2 -2
- package/dist/client/{WidgetsContainer-CfLnd44U.js → WidgetsContainer-BaWOnE5R.js} +1 -1
- package/dist/client/{asWebComponent-DfULAbpq.js → asWebComponent-BHWpMuE3.js} +47 -39
- package/dist/client/{async-CIbKXEEe.js → async-DSKj6g1f.js} +21 -10
- package/dist/client/create-layers-config-CBoYedqB.js +182 -0
- package/dist/client/eo-dash.js +1 -1
- package/dist/client/{forwardRefs-yj3VWOK5.js → forwardRefs-DH51zPUr.js} +2 -2
- package/dist/client/{handling-s8xt2JwF.js → handling-BrcDDlgS.js} +123 -85
- package/dist/client/{helpers-DAVGYl_f.js → helpers-DjZVl_WF.js} +2273 -1500
- package/dist/client/{index-4TrjfJ32.js → index-1JKE68n3.js} +49 -194
- package/dist/client/{index-CugS__t5.js → index-5Jhsa8Xe.js} +3 -3
- package/dist/client/index-CSG_JoOA.js +436 -0
- package/dist/client/{index-CYz6dT7K.js → index-CUjl-ZsI.js} +2 -2
- package/dist/client/{index-Bu8BMA9q.js → index-Cu3-13Xg.js} +69 -83
- package/dist/client/material-symbols-outlined.woff2 +0 -0
- package/dist/client/material-symbols-rounded.woff2 +0 -0
- package/dist/client/material-symbols-sharp.woff2 +0 -0
- package/dist/client/material-symbols-subset.woff2 +0 -0
- package/dist/client/templates.js +1 -1
- package/dist/client/{transition-DaOsiD4u.js → transition-OHcz5Qq1.js} +1 -1
- package/dist/node/cli.js +1 -1
- package/dist/types/core/client/composables/index.d.ts +1 -3
- package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +6 -7
- package/dist/types/core/client/eodashSTAC/createLayers.d.ts +3 -3
- package/dist/types/core/client/eodashSTAC/helpers.d.ts +1 -0
- package/dist/types/core/client/types.d.ts +8 -1
- package/dist/types/templates/baseConfig.d.ts +12 -0
- package/dist/types/widgets/EodashLayerControl.vue.d.ts +1 -1
- package/dist/types/widgets/EodashMap/EodashMapBtns.vue.d.ts +9 -0
- package/dist/types/widgets/EodashMap/index.vue.d.ts +7 -0
- package/dist/types/widgets/EodashMap/methods/create-layers-config.d.ts +1 -8
- package/dist/types/widgets/EodashProcess/methods/composables.d.ts +1 -1
- package/dist/types/widgets/EodashProcess/methods/handling.d.ts +13 -8
- package/dist/types/widgets/EodashTimeSlider/index.vue.d.ts +34 -0
- package/dist/types/widgets/EodashTimeSlider/methods/index.d.ts +39 -0
- package/dist/types/widgets/EodashTimeSlider/types.d.ts +62 -0
- package/package.json +32 -32
- package/widgets/EodashLayerControl.vue +22 -3
- package/widgets/EodashMap/EodashMapBtns.vue +46 -1
- package/widgets/EodashMap/index.vue +17 -5
- package/widgets/EodashMap/methods/create-layers-config.js +2 -0
- package/widgets/EodashMap/methods/index.js +23 -5
- package/widgets/EodashProcess/index.vue +1 -1
- package/widgets/EodashProcess/methods/async.js +19 -8
- package/widgets/EodashProcess/methods/composables.js +63 -77
- package/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.js +9 -5
- package/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.js +7 -4
- package/widgets/EodashProcess/methods/handling.js +105 -72
- package/widgets/EodashTimeSlider/index.vue +152 -0
- package/widgets/EodashTimeSlider/methods/index.js +279 -0
- package/widgets/EodashTimeSlider/types.ts +64 -0
- package/dist/client/EodashMapBtns-BHrSDNoC.js +0 -435
- package/dist/client/EodashTimeSlider-5vm7F3ju.js +0 -53
- package/dist/client/MobileLayout-DyMjaeif.js +0 -118
- package/dist/types/widgets/EodashTimeSlider.vue.d.ts +0 -15
- package/widgets/EodashTimeSlider.vue +0 -40
|
@@ -50,7 +50,7 @@ const { isArray } = Array;
|
|
|
50
50
|
*
|
|
51
51
|
* @returns {boolean} True if the value is undefined, otherwise false
|
|
52
52
|
*/
|
|
53
|
-
const isUndefined = typeOfTest(
|
|
53
|
+
const isUndefined = typeOfTest('undefined');
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Determine if a value is a Buffer
|
|
@@ -77,7 +77,7 @@ function isBuffer(val) {
|
|
|
77
77
|
*
|
|
78
78
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
79
79
|
*/
|
|
80
|
-
const isArrayBuffer = kindOfTest(
|
|
80
|
+
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Determine if a value is a view on an ArrayBuffer
|
|
@@ -88,7 +88,7 @@ const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
|
88
88
|
*/
|
|
89
89
|
function isArrayBufferView(val) {
|
|
90
90
|
let result;
|
|
91
|
-
if (typeof ArrayBuffer !==
|
|
91
|
+
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|
92
92
|
result = ArrayBuffer.isView(val);
|
|
93
93
|
} else {
|
|
94
94
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
@@ -103,7 +103,7 @@ function isArrayBufferView(val) {
|
|
|
103
103
|
*
|
|
104
104
|
* @returns {boolean} True if value is a String, otherwise false
|
|
105
105
|
*/
|
|
106
|
-
const isString = typeOfTest(
|
|
106
|
+
const isString = typeOfTest('string');
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Determine if a value is a Function
|
|
@@ -111,7 +111,7 @@ const isString = typeOfTest("string");
|
|
|
111
111
|
* @param {*} val The value to test
|
|
112
112
|
* @returns {boolean} True if value is a Function, otherwise false
|
|
113
113
|
*/
|
|
114
|
-
const isFunction$1 = typeOfTest(
|
|
114
|
+
const isFunction$1 = typeOfTest('function');
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* Determine if a value is a Number
|
|
@@ -120,7 +120,7 @@ const isFunction$1 = typeOfTest("function");
|
|
|
120
120
|
*
|
|
121
121
|
* @returns {boolean} True if value is a Number, otherwise false
|
|
122
122
|
*/
|
|
123
|
-
const isNumber = typeOfTest(
|
|
123
|
+
const isNumber = typeOfTest('number');
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Determine if a value is an Object
|
|
@@ -129,7 +129,7 @@ const isNumber = typeOfTest("number");
|
|
|
129
129
|
*
|
|
130
130
|
* @returns {boolean} True if value is an Object, otherwise false
|
|
131
131
|
*/
|
|
132
|
-
const isObject = (thing) => thing !== null && typeof thing ===
|
|
132
|
+
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Determine if a value is a Boolean
|
|
@@ -147,7 +147,7 @@ const isBoolean = (thing) => thing === true || thing === false;
|
|
|
147
147
|
* @returns {boolean} True if value is a plain Object, otherwise false
|
|
148
148
|
*/
|
|
149
149
|
const isPlainObject = (val) => {
|
|
150
|
-
if (kindOf(val) !==
|
|
150
|
+
if (kindOf(val) !== 'object') {
|
|
151
151
|
return false;
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -175,10 +175,7 @@ const isEmptyObject = (val) => {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
try {
|
|
178
|
-
return (
|
|
179
|
-
Object.keys(val).length === 0 &&
|
|
180
|
-
Object.getPrototypeOf(val) === Object.prototype
|
|
181
|
-
);
|
|
178
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
182
179
|
} catch (e) {
|
|
183
180
|
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
184
181
|
return false;
|
|
@@ -192,7 +189,7 @@ const isEmptyObject = (val) => {
|
|
|
192
189
|
*
|
|
193
190
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
194
191
|
*/
|
|
195
|
-
const isDate = kindOfTest(
|
|
192
|
+
const isDate = kindOfTest('Date');
|
|
196
193
|
|
|
197
194
|
/**
|
|
198
195
|
* Determine if a value is a File
|
|
@@ -201,7 +198,32 @@ const isDate = kindOfTest("Date");
|
|
|
201
198
|
*
|
|
202
199
|
* @returns {boolean} True if value is a File, otherwise false
|
|
203
200
|
*/
|
|
204
|
-
const isFile = kindOfTest(
|
|
201
|
+
const isFile = kindOfTest('File');
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Determine if a value is a React Native Blob
|
|
205
|
+
* React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|
206
|
+
* also have a `name` and `type` attribute to specify filename and content type
|
|
207
|
+
*
|
|
208
|
+
* @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|
209
|
+
*
|
|
210
|
+
* @param {*} value The value to test
|
|
211
|
+
*
|
|
212
|
+
* @returns {boolean} True if value is a React Native Blob, otherwise false
|
|
213
|
+
*/
|
|
214
|
+
const isReactNativeBlob = (value) => {
|
|
215
|
+
return !!(value && typeof value.uri !== 'undefined');
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Determine if environment is React Native
|
|
220
|
+
* ReactNative `FormData` has a non-standard `getParts()` method
|
|
221
|
+
*
|
|
222
|
+
* @param {*} formData The formData to test
|
|
223
|
+
*
|
|
224
|
+
* @returns {boolean} True if environment is React Native, otherwise false
|
|
225
|
+
*/
|
|
226
|
+
const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
|
|
205
227
|
|
|
206
228
|
/**
|
|
207
229
|
* Determine if a value is a Blob
|
|
@@ -210,16 +232,16 @@ const isFile = kindOfTest("File");
|
|
|
210
232
|
*
|
|
211
233
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
212
234
|
*/
|
|
213
|
-
const isBlob = kindOfTest(
|
|
235
|
+
const isBlob = kindOfTest('Blob');
|
|
214
236
|
|
|
215
237
|
/**
|
|
216
238
|
* Determine if a value is a FileList
|
|
217
239
|
*
|
|
218
240
|
* @param {*} val The value to test
|
|
219
241
|
*
|
|
220
|
-
* @returns {boolean} True if value is a
|
|
242
|
+
* @returns {boolean} True if value is a FileList, otherwise false
|
|
221
243
|
*/
|
|
222
|
-
const isFileList = kindOfTest(
|
|
244
|
+
const isFileList = kindOfTest('FileList');
|
|
223
245
|
|
|
224
246
|
/**
|
|
225
247
|
* Determine if a value is a Stream
|
|
@@ -237,17 +259,29 @@ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
|
237
259
|
*
|
|
238
260
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
239
261
|
*/
|
|
262
|
+
function getGlobal() {
|
|
263
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
264
|
+
if (typeof self !== 'undefined') return self;
|
|
265
|
+
if (typeof window !== 'undefined') return window;
|
|
266
|
+
if (typeof global !== 'undefined') return global;
|
|
267
|
+
return {};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const G = getGlobal();
|
|
271
|
+
const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|
272
|
+
|
|
240
273
|
const isFormData = (thing) => {
|
|
241
|
-
|
|
274
|
+
if (!thing) return false;
|
|
275
|
+
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
276
|
+
// Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|
277
|
+
const proto = getPrototypeOf(thing);
|
|
278
|
+
if (!proto || proto === Object.prototype) return false;
|
|
279
|
+
if (!isFunction$1(thing.append)) return false;
|
|
280
|
+
const kind = kindOf(thing);
|
|
242
281
|
return (
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
((kind = kindOf(thing)) === "formdata" ||
|
|
247
|
-
// detect form-data instance
|
|
248
|
-
(kind === "object" &&
|
|
249
|
-
isFunction$1(thing.toString) &&
|
|
250
|
-
thing.toString() === "[object FormData]"))))
|
|
282
|
+
kind === 'formdata' ||
|
|
283
|
+
// detect form-data instance
|
|
284
|
+
(kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
|
|
251
285
|
);
|
|
252
286
|
};
|
|
253
287
|
|
|
@@ -258,13 +292,13 @@ const isFormData = (thing) => {
|
|
|
258
292
|
*
|
|
259
293
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
260
294
|
*/
|
|
261
|
-
const isURLSearchParams = kindOfTest(
|
|
295
|
+
const isURLSearchParams = kindOfTest('URLSearchParams');
|
|
262
296
|
|
|
263
297
|
const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
298
|
+
'ReadableStream',
|
|
299
|
+
'Request',
|
|
300
|
+
'Response',
|
|
301
|
+
'Headers',
|
|
268
302
|
].map(kindOfTest);
|
|
269
303
|
|
|
270
304
|
/**
|
|
@@ -274,9 +308,9 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = [
|
|
|
274
308
|
*
|
|
275
309
|
* @returns {String} The String freed of excess whitespace
|
|
276
310
|
*/
|
|
277
|
-
const trim = (str) =>
|
|
278
|
-
str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
|
|
279
|
-
|
|
311
|
+
const trim = (str) => {
|
|
312
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
313
|
+
};
|
|
280
314
|
/**
|
|
281
315
|
* Iterate over an Array or an Object invoking a function for each item.
|
|
282
316
|
*
|
|
@@ -295,7 +329,7 @@ const trim = (str) =>
|
|
|
295
329
|
*/
|
|
296
330
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
297
331
|
// Don't bother if no value provided
|
|
298
|
-
if (obj === null || typeof obj ===
|
|
332
|
+
if (obj === null || typeof obj === 'undefined') {
|
|
299
333
|
return;
|
|
300
334
|
}
|
|
301
335
|
|
|
@@ -303,7 +337,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
303
337
|
let l;
|
|
304
338
|
|
|
305
339
|
// Force an array if not already something iterable
|
|
306
|
-
if (typeof obj !==
|
|
340
|
+
if (typeof obj !== 'object') {
|
|
307
341
|
/*eslint no-param-reassign:0*/
|
|
308
342
|
obj = [obj];
|
|
309
343
|
}
|
|
@@ -320,9 +354,7 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
320
354
|
}
|
|
321
355
|
|
|
322
356
|
// Iterate over object keys
|
|
323
|
-
const keys = allOwnKeys
|
|
324
|
-
? Object.getOwnPropertyNames(obj)
|
|
325
|
-
: Object.keys(obj);
|
|
357
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
326
358
|
const len = keys.length;
|
|
327
359
|
let key;
|
|
328
360
|
|
|
@@ -333,6 +365,14 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
|
333
365
|
}
|
|
334
366
|
}
|
|
335
367
|
|
|
368
|
+
/**
|
|
369
|
+
* Finds a key in an object, case-insensitive, returning the actual key name.
|
|
370
|
+
* Returns null if the object is a Buffer or if no match is found.
|
|
371
|
+
*
|
|
372
|
+
* @param {Object} obj - The object to search.
|
|
373
|
+
* @param {string} key - The key to find (case-insensitive).
|
|
374
|
+
* @returns {?string} The actual key name if found, otherwise null.
|
|
375
|
+
*/
|
|
336
376
|
function findKey(obj, key) {
|
|
337
377
|
if (isBuffer(obj)) {
|
|
338
378
|
return null;
|
|
@@ -353,16 +393,11 @@ function findKey(obj, key) {
|
|
|
353
393
|
|
|
354
394
|
const _global = (() => {
|
|
355
395
|
/*eslint no-undef:0*/
|
|
356
|
-
if (typeof globalThis !==
|
|
357
|
-
return typeof self !==
|
|
358
|
-
? self
|
|
359
|
-
: typeof window !== "undefined"
|
|
360
|
-
? window
|
|
361
|
-
: global;
|
|
396
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
397
|
+
return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|
362
398
|
})();
|
|
363
399
|
|
|
364
|
-
const isContextDefined = (context) =>
|
|
365
|
-
!isUndefined(context) && context !== _global;
|
|
400
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
366
401
|
|
|
367
402
|
/**
|
|
368
403
|
* Accepts varargs expecting each argument to be an object, then
|
|
@@ -382,18 +417,22 @@ const isContextDefined = (context) =>
|
|
|
382
417
|
*
|
|
383
418
|
* @returns {Object} Result of all merge properties
|
|
384
419
|
*/
|
|
385
|
-
function merge(
|
|
420
|
+
function merge(...objs) {
|
|
386
421
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
|
387
422
|
const result = {};
|
|
388
423
|
const assignValue = (val, key) => {
|
|
389
424
|
// Skip dangerous property names to prevent prototype pollution
|
|
390
|
-
if (key ===
|
|
425
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
391
426
|
return;
|
|
392
427
|
}
|
|
393
428
|
|
|
394
429
|
const targetKey = (caseless && findKey(result, key)) || key;
|
|
395
|
-
|
|
396
|
-
|
|
430
|
+
// Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|
431
|
+
// chain, so a polluted Object.prototype value could surface here and get
|
|
432
|
+
// copied into the merged result.
|
|
433
|
+
const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|
434
|
+
if (isPlainObject(existing) && isPlainObject(val)) {
|
|
435
|
+
result[targetKey] = merge(existing, val);
|
|
397
436
|
} else if (isPlainObject(val)) {
|
|
398
437
|
result[targetKey] = merge({}, val);
|
|
399
438
|
} else if (isArray(val)) {
|
|
@@ -403,8 +442,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|
|
403
442
|
}
|
|
404
443
|
};
|
|
405
444
|
|
|
406
|
-
for (let i = 0, l =
|
|
407
|
-
|
|
445
|
+
for (let i = 0, l = objs.length; i < l; i++) {
|
|
446
|
+
objs[i] && forEach(objs[i], assignValue);
|
|
408
447
|
}
|
|
409
448
|
return result;
|
|
410
449
|
}
|
|
@@ -426,6 +465,9 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
426
465
|
(val, key) => {
|
|
427
466
|
if (thisArg && isFunction$1(val)) {
|
|
428
467
|
Object.defineProperty(a, key, {
|
|
468
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot
|
|
469
|
+
// hijack defineProperty's accessor-vs-data resolution.
|
|
470
|
+
__proto__: null,
|
|
429
471
|
value: bind(val, thisArg),
|
|
430
472
|
writable: true,
|
|
431
473
|
enumerable: true,
|
|
@@ -433,6 +475,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
433
475
|
});
|
|
434
476
|
} else {
|
|
435
477
|
Object.defineProperty(a, key, {
|
|
478
|
+
__proto__: null,
|
|
436
479
|
value: val,
|
|
437
480
|
writable: true,
|
|
438
481
|
enumerable: true,
|
|
@@ -440,7 +483,7 @@ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
|
440
483
|
});
|
|
441
484
|
}
|
|
442
485
|
},
|
|
443
|
-
{ allOwnKeys }
|
|
486
|
+
{ allOwnKeys }
|
|
444
487
|
);
|
|
445
488
|
return a;
|
|
446
489
|
};
|
|
@@ -469,17 +512,16 @@ const stripBOM = (content) => {
|
|
|
469
512
|
* @returns {void}
|
|
470
513
|
*/
|
|
471
514
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
|
472
|
-
constructor.prototype = Object.create(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
);
|
|
476
|
-
Object.defineProperty(constructor.prototype, "constructor", {
|
|
515
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
516
|
+
Object.defineProperty(constructor.prototype, 'constructor', {
|
|
517
|
+
__proto__: null,
|
|
477
518
|
value: constructor,
|
|
478
519
|
writable: true,
|
|
479
520
|
enumerable: false,
|
|
480
521
|
configurable: true,
|
|
481
522
|
});
|
|
482
|
-
Object.defineProperty(constructor,
|
|
523
|
+
Object.defineProperty(constructor, 'super', {
|
|
524
|
+
__proto__: null,
|
|
483
525
|
value: superConstructor.prototype,
|
|
484
526
|
});
|
|
485
527
|
props && Object.assign(constructor.prototype, props);
|
|
@@ -509,20 +551,13 @@ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
|
|
509
551
|
i = props.length;
|
|
510
552
|
while (i-- > 0) {
|
|
511
553
|
prop = props[i];
|
|
512
|
-
if (
|
|
513
|
-
(!propFilter || propFilter(prop, sourceObj, destObj)) &&
|
|
514
|
-
!merged[prop]
|
|
515
|
-
) {
|
|
554
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
516
555
|
destObj[prop] = sourceObj[prop];
|
|
517
556
|
merged[prop] = true;
|
|
518
557
|
}
|
|
519
558
|
}
|
|
520
559
|
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|
521
|
-
} while (
|
|
522
|
-
sourceObj &&
|
|
523
|
-
(!filter || filter(sourceObj, destObj)) &&
|
|
524
|
-
sourceObj !== Object.prototype
|
|
525
|
-
);
|
|
560
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
526
561
|
|
|
527
562
|
return destObj;
|
|
528
563
|
};
|
|
@@ -579,7 +614,7 @@ const isTypedArray = ((TypedArray) => {
|
|
|
579
614
|
return (thing) => {
|
|
580
615
|
return TypedArray && thing instanceof TypedArray;
|
|
581
616
|
};
|
|
582
|
-
})(typeof Uint8Array !==
|
|
617
|
+
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|
583
618
|
|
|
584
619
|
/**
|
|
585
620
|
* For each entry in the object, call the function with the key and value.
|
|
@@ -622,14 +657,12 @@ const matchAll = (regExp, str) => {
|
|
|
622
657
|
};
|
|
623
658
|
|
|
624
659
|
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|
625
|
-
const isHTMLForm = kindOfTest(
|
|
660
|
+
const isHTMLForm = kindOfTest('HTMLFormElement');
|
|
626
661
|
|
|
627
662
|
const toCamelCase = (str) => {
|
|
628
|
-
return str
|
|
629
|
-
.
|
|
630
|
-
|
|
631
|
-
return p1.toUpperCase() + p2;
|
|
632
|
-
});
|
|
663
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|
664
|
+
return p1.toUpperCase() + p2;
|
|
665
|
+
});
|
|
633
666
|
};
|
|
634
667
|
|
|
635
668
|
/* Creating a function that will check if an object has a property. */
|
|
@@ -646,7 +679,7 @@ const hasOwnProperty = (
|
|
|
646
679
|
*
|
|
647
680
|
* @returns {boolean} True if value is a RegExp object, otherwise false
|
|
648
681
|
*/
|
|
649
|
-
const isRegExp = kindOfTest(
|
|
682
|
+
const isRegExp = kindOfTest('RegExp');
|
|
650
683
|
|
|
651
684
|
const reduceDescriptors = (obj, reducer) => {
|
|
652
685
|
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
|
@@ -670,10 +703,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
670
703
|
const freezeMethods = (obj) => {
|
|
671
704
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
672
705
|
// skip restricted props in strict mode
|
|
673
|
-
if (
|
|
674
|
-
isFunction$1(obj) &&
|
|
675
|
-
["arguments", "caller", "callee"].indexOf(name) !== -1
|
|
676
|
-
) {
|
|
706
|
+
if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|
677
707
|
return false;
|
|
678
708
|
}
|
|
679
709
|
|
|
@@ -683,7 +713,7 @@ const freezeMethods = (obj) => {
|
|
|
683
713
|
|
|
684
714
|
descriptor.enumerable = false;
|
|
685
715
|
|
|
686
|
-
if (
|
|
716
|
+
if ('writable' in descriptor) {
|
|
687
717
|
descriptor.writable = false;
|
|
688
718
|
return;
|
|
689
719
|
}
|
|
@@ -696,6 +726,14 @@ const freezeMethods = (obj) => {
|
|
|
696
726
|
});
|
|
697
727
|
};
|
|
698
728
|
|
|
729
|
+
/**
|
|
730
|
+
* Converts an array or a delimited string into an object set with values as keys and true as values.
|
|
731
|
+
* Useful for fast membership checks.
|
|
732
|
+
*
|
|
733
|
+
* @param {Array|string} arrayOrString - The array or string to convert.
|
|
734
|
+
* @param {string} delimiter - The delimiter to use if input is a string.
|
|
735
|
+
* @returns {Object} An object with keys from the array or string, values set to true.
|
|
736
|
+
*/
|
|
699
737
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
700
738
|
const obj = {};
|
|
701
739
|
|
|
@@ -705,9 +743,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
705
743
|
});
|
|
706
744
|
};
|
|
707
745
|
|
|
708
|
-
isArray(arrayOrString)
|
|
709
|
-
? define(arrayOrString)
|
|
710
|
-
: define(String(arrayOrString).split(delimiter));
|
|
746
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
711
747
|
|
|
712
748
|
return obj;
|
|
713
749
|
};
|
|
@@ -715,9 +751,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
|
|
|
715
751
|
const noop = () => {};
|
|
716
752
|
|
|
717
753
|
const toFiniteNumber = (value, defaultValue) => {
|
|
718
|
-
return value != null && Number.isFinite((value = +value))
|
|
719
|
-
? value
|
|
720
|
-
: defaultValue;
|
|
754
|
+
return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
|
|
721
755
|
};
|
|
722
756
|
|
|
723
757
|
/**
|
|
@@ -731,11 +765,17 @@ function isSpecCompliantForm(thing) {
|
|
|
731
765
|
return !!(
|
|
732
766
|
thing &&
|
|
733
767
|
isFunction$1(thing.append) &&
|
|
734
|
-
thing[toStringTag] ===
|
|
768
|
+
thing[toStringTag] === 'FormData' &&
|
|
735
769
|
thing[iterator]
|
|
736
770
|
);
|
|
737
771
|
}
|
|
738
772
|
|
|
773
|
+
/**
|
|
774
|
+
* Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|
775
|
+
*
|
|
776
|
+
* @param {Object} obj - The object to convert.
|
|
777
|
+
* @returns {Object} The JSON-compatible object.
|
|
778
|
+
*/
|
|
739
779
|
const toJSONObject = (obj) => {
|
|
740
780
|
const stack = new Array(10);
|
|
741
781
|
|
|
@@ -750,7 +790,7 @@ const toJSONObject = (obj) => {
|
|
|
750
790
|
return source;
|
|
751
791
|
}
|
|
752
792
|
|
|
753
|
-
if (!(
|
|
793
|
+
if (!('toJSON' in source)) {
|
|
754
794
|
stack[i] = source;
|
|
755
795
|
const target = isArray(source) ? [] : {};
|
|
756
796
|
|
|
@@ -771,8 +811,20 @@ const toJSONObject = (obj) => {
|
|
|
771
811
|
return visit(obj, 0);
|
|
772
812
|
};
|
|
773
813
|
|
|
774
|
-
|
|
814
|
+
/**
|
|
815
|
+
* Determines if a value is an async function.
|
|
816
|
+
*
|
|
817
|
+
* @param {*} thing - The value to test.
|
|
818
|
+
* @returns {boolean} True if value is an async function, otherwise false.
|
|
819
|
+
*/
|
|
820
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
|
775
821
|
|
|
822
|
+
/**
|
|
823
|
+
* Determines if a value is thenable (has then and catch methods).
|
|
824
|
+
*
|
|
825
|
+
* @param {*} thing - The value to test.
|
|
826
|
+
* @returns {boolean} True if value is thenable, otherwise false.
|
|
827
|
+
*/
|
|
776
828
|
const isThenable = (thing) =>
|
|
777
829
|
thing &&
|
|
778
830
|
(isObject(thing) || isFunction$1(thing)) &&
|
|
@@ -782,6 +834,14 @@ const isThenable = (thing) =>
|
|
|
782
834
|
// original code
|
|
783
835
|
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
784
836
|
|
|
837
|
+
/**
|
|
838
|
+
* Provides a cross-platform setImmediate implementation.
|
|
839
|
+
* Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|
840
|
+
*
|
|
841
|
+
* @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|
842
|
+
* @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|
843
|
+
* @returns {Function} A function to schedule a callback asynchronously.
|
|
844
|
+
*/
|
|
785
845
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
786
846
|
if (setImmediateSupported) {
|
|
787
847
|
return setImmediate;
|
|
@@ -790,27 +850,33 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
|
790
850
|
return postMessageSupported
|
|
791
851
|
? ((token, callbacks) => {
|
|
792
852
|
_global.addEventListener(
|
|
793
|
-
|
|
853
|
+
'message',
|
|
794
854
|
({ source, data }) => {
|
|
795
855
|
if (source === _global && data === token) {
|
|
796
856
|
callbacks.length && callbacks.shift()();
|
|
797
857
|
}
|
|
798
858
|
},
|
|
799
|
-
false
|
|
859
|
+
false
|
|
800
860
|
);
|
|
801
861
|
|
|
802
862
|
return (cb) => {
|
|
803
863
|
callbacks.push(cb);
|
|
804
|
-
_global.postMessage(token,
|
|
864
|
+
_global.postMessage(token, '*');
|
|
805
865
|
};
|
|
806
866
|
})(`axios@${Math.random()}`, [])
|
|
807
867
|
: (cb) => setTimeout(cb);
|
|
808
|
-
})(typeof setImmediate ===
|
|
868
|
+
})(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|
809
869
|
|
|
870
|
+
/**
|
|
871
|
+
* Schedules a microtask or asynchronous callback as soon as possible.
|
|
872
|
+
* Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|
873
|
+
*
|
|
874
|
+
* @type {Function}
|
|
875
|
+
*/
|
|
810
876
|
const asap =
|
|
811
|
-
typeof queueMicrotask !==
|
|
877
|
+
typeof queueMicrotask !== 'undefined'
|
|
812
878
|
? queueMicrotask.bind(_global)
|
|
813
|
-
: (typeof process !==
|
|
879
|
+
: (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
|
|
814
880
|
|
|
815
881
|
// *********************
|
|
816
882
|
|
|
@@ -835,6 +901,8 @@ const utils$1 = {
|
|
|
835
901
|
isUndefined,
|
|
836
902
|
isDate,
|
|
837
903
|
isFile,
|
|
904
|
+
isReactNativeBlob,
|
|
905
|
+
isReactNative,
|
|
838
906
|
isBlob,
|
|
839
907
|
isRegExp,
|
|
840
908
|
isFunction: isFunction$1,
|
|
@@ -876,1167 +944,1399 @@ const utils$1 = {
|
|
|
876
944
|
isIterable,
|
|
877
945
|
};
|
|
878
946
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
super(message);
|
|
901
|
-
this.name = 'AxiosError';
|
|
902
|
-
this.isAxiosError = true;
|
|
903
|
-
code && (this.code = code);
|
|
904
|
-
config && (this.config = config);
|
|
905
|
-
request && (this.request = request);
|
|
906
|
-
if (response) {
|
|
907
|
-
this.response = response;
|
|
908
|
-
this.status = response.status;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
toJSON() {
|
|
913
|
-
return {
|
|
914
|
-
// Standard
|
|
915
|
-
message: this.message,
|
|
916
|
-
name: this.name,
|
|
917
|
-
// Microsoft
|
|
918
|
-
description: this.description,
|
|
919
|
-
number: this.number,
|
|
920
|
-
// Mozilla
|
|
921
|
-
fileName: this.fileName,
|
|
922
|
-
lineNumber: this.lineNumber,
|
|
923
|
-
columnNumber: this.columnNumber,
|
|
924
|
-
stack: this.stack,
|
|
925
|
-
// Axios
|
|
926
|
-
config: utils$1.toJSONObject(this.config),
|
|
927
|
-
code: this.code,
|
|
928
|
-
status: this.status,
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
934
|
-
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
935
|
-
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
936
|
-
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
937
|
-
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
938
|
-
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
939
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
940
|
-
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
941
|
-
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
942
|
-
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
943
|
-
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
944
|
-
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
945
|
-
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
946
|
-
|
|
947
|
-
// eslint-disable-next-line strict
|
|
948
|
-
const httpAdapter = null;
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* Determines if the given thing is a array or js object.
|
|
952
|
-
*
|
|
953
|
-
* @param {string} thing - The object or array to be visited.
|
|
954
|
-
*
|
|
955
|
-
* @returns {boolean}
|
|
956
|
-
*/
|
|
957
|
-
function isVisitable(thing) {
|
|
958
|
-
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
* It removes the brackets from the end of a string
|
|
963
|
-
*
|
|
964
|
-
* @param {string} key - The key of the parameter.
|
|
965
|
-
*
|
|
966
|
-
* @returns {string} the key without the brackets.
|
|
967
|
-
*/
|
|
968
|
-
function removeBrackets(key) {
|
|
969
|
-
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
970
|
-
}
|
|
947
|
+
// RawAxiosHeaders whose duplicates are ignored by node
|
|
948
|
+
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
949
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
950
|
+
'age',
|
|
951
|
+
'authorization',
|
|
952
|
+
'content-length',
|
|
953
|
+
'content-type',
|
|
954
|
+
'etag',
|
|
955
|
+
'expires',
|
|
956
|
+
'from',
|
|
957
|
+
'host',
|
|
958
|
+
'if-modified-since',
|
|
959
|
+
'if-unmodified-since',
|
|
960
|
+
'last-modified',
|
|
961
|
+
'location',
|
|
962
|
+
'max-forwards',
|
|
963
|
+
'proxy-authorization',
|
|
964
|
+
'referer',
|
|
965
|
+
'retry-after',
|
|
966
|
+
'user-agent',
|
|
967
|
+
]);
|
|
971
968
|
|
|
972
969
|
/**
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
* @param {string} path - The path to the current key.
|
|
976
|
-
* @param {string} key - The key of the current object being iterated over.
|
|
977
|
-
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
970
|
+
* Parse headers into an object
|
|
978
971
|
*
|
|
979
|
-
*
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
token = removeBrackets(token);
|
|
986
|
-
return !dots && i ? '[' + token + ']' : token;
|
|
987
|
-
}).join(dots ? '.' : '');
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
972
|
+
* ```
|
|
973
|
+
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
974
|
+
* Content-Type: application/json
|
|
975
|
+
* Connection: keep-alive
|
|
976
|
+
* Transfer-Encoding: chunked
|
|
977
|
+
* ```
|
|
992
978
|
*
|
|
993
|
-
* @param {
|
|
979
|
+
* @param {String} rawHeaders Headers needing to be parsed
|
|
994
980
|
*
|
|
995
|
-
* @returns {
|
|
981
|
+
* @returns {Object} Headers parsed into an object
|
|
996
982
|
*/
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
983
|
+
const parseHeaders = (rawHeaders) => {
|
|
984
|
+
const parsed = {};
|
|
985
|
+
let key;
|
|
986
|
+
let val;
|
|
987
|
+
let i;
|
|
1000
988
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
989
|
+
rawHeaders &&
|
|
990
|
+
rawHeaders.split('\n').forEach(function parser(line) {
|
|
991
|
+
i = line.indexOf(':');
|
|
992
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
993
|
+
val = line.substring(i + 1).trim();
|
|
1004
994
|
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
* @param {Object} obj
|
|
1009
|
-
* @param {?Object} [formData]
|
|
1010
|
-
* @param {?Object} [options]
|
|
1011
|
-
* @param {Function} [options.visitor]
|
|
1012
|
-
* @param {Boolean} [options.metaTokens = true]
|
|
1013
|
-
* @param {Boolean} [options.dots = false]
|
|
1014
|
-
* @param {?Boolean} [options.indexes = false]
|
|
1015
|
-
*
|
|
1016
|
-
* @returns {Object}
|
|
1017
|
-
**/
|
|
995
|
+
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
1018
998
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
if (!utils$1.isObject(obj)) {
|
|
1030
|
-
throw new TypeError('target must be an object');
|
|
1031
|
-
}
|
|
999
|
+
if (key === 'set-cookie') {
|
|
1000
|
+
if (parsed[key]) {
|
|
1001
|
+
parsed[key].push(val);
|
|
1002
|
+
} else {
|
|
1003
|
+
parsed[key] = [val];
|
|
1004
|
+
}
|
|
1005
|
+
} else {
|
|
1006
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1032
1009
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1010
|
+
return parsed;
|
|
1011
|
+
};
|
|
1035
1012
|
|
|
1036
|
-
|
|
1037
|
-
options = utils$1.toFlatObject(options, {
|
|
1038
|
-
metaTokens: true,
|
|
1039
|
-
dots: false,
|
|
1040
|
-
indexes: false
|
|
1041
|
-
}, false, function defined(option, source) {
|
|
1042
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1043
|
-
return !utils$1.isUndefined(source[option]);
|
|
1044
|
-
});
|
|
1013
|
+
const $internals = Symbol('internals');
|
|
1045
1014
|
|
|
1046
|
-
|
|
1047
|
-
// eslint-disable-next-line no-use-before-define
|
|
1048
|
-
const visitor = options.visitor || defaultVisitor;
|
|
1049
|
-
const dots = options.dots;
|
|
1050
|
-
const indexes = options.indexes;
|
|
1051
|
-
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1052
|
-
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1015
|
+
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
1053
1016
|
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1017
|
+
function trimSPorHTAB(str) {
|
|
1018
|
+
let start = 0;
|
|
1019
|
+
let end = str.length;
|
|
1057
1020
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1021
|
+
while (start < end) {
|
|
1022
|
+
const code = str.charCodeAt(start);
|
|
1060
1023
|
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1024
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1025
|
+
break;
|
|
1063
1026
|
}
|
|
1064
1027
|
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1028
|
+
start += 1;
|
|
1029
|
+
}
|
|
1068
1030
|
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1031
|
+
while (end > start) {
|
|
1032
|
+
const code = str.charCodeAt(end - 1);
|
|
1072
1033
|
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1034
|
+
if (code !== 0x09 && code !== 0x20) {
|
|
1035
|
+
break;
|
|
1075
1036
|
}
|
|
1076
1037
|
|
|
1077
|
-
|
|
1038
|
+
end -= 1;
|
|
1078
1039
|
}
|
|
1079
1040
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
*
|
|
1083
|
-
* @param {*} value
|
|
1084
|
-
* @param {String|Number} key
|
|
1085
|
-
* @param {Array<String|Number>} path
|
|
1086
|
-
* @this {FormData}
|
|
1087
|
-
*
|
|
1088
|
-
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1089
|
-
*/
|
|
1090
|
-
function defaultVisitor(value, key, path) {
|
|
1091
|
-
let arr = value;
|
|
1041
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1042
|
+
}
|
|
1092
1043
|
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
key = metaTokens ? key : key.slice(0, -2);
|
|
1097
|
-
// eslint-disable-next-line no-param-reassign
|
|
1098
|
-
value = JSON.stringify(value);
|
|
1099
|
-
} else if (
|
|
1100
|
-
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1101
|
-
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1102
|
-
)) {
|
|
1103
|
-
// eslint-disable-next-line no-param-reassign
|
|
1104
|
-
key = removeBrackets(key);
|
|
1044
|
+
function normalizeHeader(header) {
|
|
1045
|
+
return header && String(header).trim().toLowerCase();
|
|
1046
|
+
}
|
|
1105
1047
|
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1110
|
-
convertValue(el)
|
|
1111
|
-
);
|
|
1112
|
-
});
|
|
1113
|
-
return false;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1048
|
+
function sanitizeHeaderValue(str) {
|
|
1049
|
+
return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ''));
|
|
1050
|
+
}
|
|
1116
1051
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1052
|
+
function normalizeValue(value) {
|
|
1053
|
+
if (value === false || value == null) {
|
|
1054
|
+
return value;
|
|
1055
|
+
}
|
|
1120
1056
|
|
|
1121
|
-
|
|
1057
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|
1058
|
+
}
|
|
1122
1059
|
|
|
1123
|
-
|
|
1060
|
+
function parseTokens(str) {
|
|
1061
|
+
const tokens = Object.create(null);
|
|
1062
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1063
|
+
let match;
|
|
1064
|
+
|
|
1065
|
+
while ((match = tokensRE.exec(str))) {
|
|
1066
|
+
tokens[match[1]] = match[2];
|
|
1124
1067
|
}
|
|
1125
1068
|
|
|
1126
|
-
|
|
1069
|
+
return tokens;
|
|
1070
|
+
}
|
|
1127
1071
|
|
|
1128
|
-
|
|
1129
|
-
defaultVisitor,
|
|
1130
|
-
convertValue,
|
|
1131
|
-
isVisitable
|
|
1132
|
-
});
|
|
1133
|
-
|
|
1134
|
-
function build(value, path) {
|
|
1135
|
-
if (utils$1.isUndefined(value)) return;
|
|
1136
|
-
|
|
1137
|
-
if (stack.indexOf(value) !== -1) {
|
|
1138
|
-
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1139
|
-
}
|
|
1072
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1140
1073
|
|
|
1141
|
-
|
|
1074
|
+
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1075
|
+
if (utils$1.isFunction(filter)) {
|
|
1076
|
+
return filter.call(this, value, header);
|
|
1077
|
+
}
|
|
1142
1078
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
);
|
|
1079
|
+
if (isHeaderNameFilter) {
|
|
1080
|
+
value = header;
|
|
1081
|
+
}
|
|
1147
1082
|
|
|
1148
|
-
|
|
1149
|
-
build(el, path ? path.concat(key) : [key]);
|
|
1150
|
-
}
|
|
1151
|
-
});
|
|
1083
|
+
if (!utils$1.isString(value)) return;
|
|
1152
1084
|
|
|
1153
|
-
|
|
1085
|
+
if (utils$1.isString(filter)) {
|
|
1086
|
+
return value.indexOf(filter) !== -1;
|
|
1154
1087
|
}
|
|
1155
1088
|
|
|
1156
|
-
if (
|
|
1157
|
-
|
|
1089
|
+
if (utils$1.isRegExp(filter)) {
|
|
1090
|
+
return filter.test(value);
|
|
1158
1091
|
}
|
|
1159
|
-
|
|
1160
|
-
build(obj);
|
|
1161
|
-
|
|
1162
|
-
return formData;
|
|
1163
1092
|
}
|
|
1164
1093
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
*/
|
|
1173
|
-
function encode$1(str) {
|
|
1174
|
-
const charMap = {
|
|
1175
|
-
'!': '%21',
|
|
1176
|
-
"'": '%27',
|
|
1177
|
-
'(': '%28',
|
|
1178
|
-
')': '%29',
|
|
1179
|
-
'~': '%7E',
|
|
1180
|
-
'%20': '+',
|
|
1181
|
-
'%00': '\x00'
|
|
1182
|
-
};
|
|
1183
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
1184
|
-
return charMap[match];
|
|
1185
|
-
});
|
|
1094
|
+
function formatHeader(header) {
|
|
1095
|
+
return header
|
|
1096
|
+
.trim()
|
|
1097
|
+
.toLowerCase()
|
|
1098
|
+
.replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1099
|
+
return char.toUpperCase() + str;
|
|
1100
|
+
});
|
|
1186
1101
|
}
|
|
1187
1102
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
*
|
|
1191
|
-
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1192
|
-
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1193
|
-
*
|
|
1194
|
-
* @returns {void}
|
|
1195
|
-
*/
|
|
1196
|
-
function AxiosURLSearchParams(params, options) {
|
|
1197
|
-
this._pairs = [];
|
|
1103
|
+
function buildAccessors(obj, header) {
|
|
1104
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1198
1105
|
|
|
1199
|
-
|
|
1106
|
+
['get', 'set', 'has'].forEach((methodName) => {
|
|
1107
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
1108
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1109
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1110
|
+
__proto__: null,
|
|
1111
|
+
value: function (arg1, arg2, arg3) {
|
|
1112
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1113
|
+
},
|
|
1114
|
+
configurable: true,
|
|
1115
|
+
});
|
|
1116
|
+
});
|
|
1200
1117
|
}
|
|
1201
1118
|
|
|
1202
|
-
|
|
1119
|
+
class AxiosHeaders {
|
|
1120
|
+
constructor(headers) {
|
|
1121
|
+
headers && this.set(headers);
|
|
1122
|
+
}
|
|
1203
1123
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
};
|
|
1124
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1125
|
+
const self = this;
|
|
1207
1126
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
return encoder.call(this, value, encode$1);
|
|
1211
|
-
} : encode$1;
|
|
1127
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1128
|
+
const lHeader = normalizeHeader(_header);
|
|
1212
1129
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
};
|
|
1130
|
+
if (!lHeader) {
|
|
1131
|
+
throw new Error('header name must be a non-empty string');
|
|
1132
|
+
}
|
|
1217
1133
|
|
|
1218
|
-
|
|
1219
|
-
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
|
1220
|
-
* URI encoded counterparts
|
|
1221
|
-
*
|
|
1222
|
-
* @param {string} val The value to be encoded.
|
|
1223
|
-
*
|
|
1224
|
-
* @returns {string} The encoded value.
|
|
1225
|
-
*/
|
|
1226
|
-
function encode(val) {
|
|
1227
|
-
return encodeURIComponent(val).
|
|
1228
|
-
replace(/%3A/gi, ':').
|
|
1229
|
-
replace(/%24/g, '$').
|
|
1230
|
-
replace(/%2C/gi, ',').
|
|
1231
|
-
replace(/%20/g, '+');
|
|
1232
|
-
}
|
|
1134
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1233
1135
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
function buildURL(url, params, options) {
|
|
1244
|
-
if (!params) {
|
|
1245
|
-
return url;
|
|
1246
|
-
}
|
|
1136
|
+
if (
|
|
1137
|
+
!key ||
|
|
1138
|
+
self[key] === undefined ||
|
|
1139
|
+
_rewrite === true ||
|
|
1140
|
+
(_rewrite === undefined && self[key] !== false)
|
|
1141
|
+
) {
|
|
1142
|
+
self[key || _header] = normalizeValue(_value);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1247
1145
|
|
|
1248
|
-
|
|
1146
|
+
const setHeaders = (headers, _rewrite) =>
|
|
1147
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1249
1148
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1149
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1150
|
+
setHeaders(header, valueOrRewrite);
|
|
1151
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1152
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1153
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1154
|
+
let obj = {},
|
|
1155
|
+
dest,
|
|
1156
|
+
key;
|
|
1157
|
+
for (const entry of header) {
|
|
1158
|
+
if (!utils$1.isArray(entry)) {
|
|
1159
|
+
throw TypeError('Object iterator must return a key-value pair');
|
|
1160
|
+
}
|
|
1253
1161
|
|
|
1254
|
-
|
|
1162
|
+
obj[(key = entry[0])] = (dest = obj[key])
|
|
1163
|
+
? utils$1.isArray(dest)
|
|
1164
|
+
? [...dest, entry[1]]
|
|
1165
|
+
: [dest, entry[1]]
|
|
1166
|
+
: entry[1];
|
|
1167
|
+
}
|
|
1255
1168
|
|
|
1256
|
-
|
|
1169
|
+
setHeaders(obj, valueOrRewrite);
|
|
1170
|
+
} else {
|
|
1171
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1172
|
+
}
|
|
1257
1173
|
|
|
1258
|
-
|
|
1259
|
-
serializedParams = serializeFn(params, _options);
|
|
1260
|
-
} else {
|
|
1261
|
-
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1262
|
-
params.toString() :
|
|
1263
|
-
new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1174
|
+
return this;
|
|
1264
1175
|
}
|
|
1265
1176
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1177
|
+
get(header, parser) {
|
|
1178
|
+
header = normalizeHeader(header);
|
|
1268
1179
|
|
|
1269
|
-
if (
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
1273
|
-
}
|
|
1180
|
+
if (header) {
|
|
1181
|
+
const key = utils$1.findKey(this, header);
|
|
1274
1182
|
|
|
1275
|
-
|
|
1276
|
-
|
|
1183
|
+
if (key) {
|
|
1184
|
+
const value = this[key];
|
|
1277
1185
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
}
|
|
1186
|
+
if (!parser) {
|
|
1187
|
+
return value;
|
|
1188
|
+
}
|
|
1282
1189
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1287
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1288
|
-
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1289
|
-
*
|
|
1290
|
-
* @return {Number} An ID used to remove interceptor later
|
|
1291
|
-
*/
|
|
1292
|
-
use(fulfilled, rejected, options) {
|
|
1293
|
-
this.handlers.push({
|
|
1294
|
-
fulfilled,
|
|
1295
|
-
rejected,
|
|
1296
|
-
synchronous: options ? options.synchronous : false,
|
|
1297
|
-
runWhen: options ? options.runWhen : null
|
|
1298
|
-
});
|
|
1299
|
-
return this.handlers.length - 1;
|
|
1300
|
-
}
|
|
1190
|
+
if (parser === true) {
|
|
1191
|
+
return parseTokens(value);
|
|
1192
|
+
}
|
|
1301
1193
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1194
|
+
if (utils$1.isFunction(parser)) {
|
|
1195
|
+
return parser.call(this, value, key);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
if (utils$1.isRegExp(parser)) {
|
|
1199
|
+
return parser.exec(value);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
throw new TypeError('parser must be boolean|regexp|function');
|
|
1203
|
+
}
|
|
1312
1204
|
}
|
|
1313
1205
|
}
|
|
1314
1206
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1207
|
+
has(header, matcher) {
|
|
1208
|
+
header = normalizeHeader(header);
|
|
1209
|
+
|
|
1210
|
+
if (header) {
|
|
1211
|
+
const key = utils$1.findKey(this, header);
|
|
1212
|
+
|
|
1213
|
+
return !!(
|
|
1214
|
+
key &&
|
|
1215
|
+
this[key] !== undefined &&
|
|
1216
|
+
(!matcher || matchHeaderValue(this, this[key], key, matcher))
|
|
1217
|
+
);
|
|
1323
1218
|
}
|
|
1324
|
-
}
|
|
1325
1219
|
|
|
1326
|
-
|
|
1327
|
-
* Iterate over all the registered interceptors
|
|
1328
|
-
*
|
|
1329
|
-
* This method is particularly useful for skipping over any
|
|
1330
|
-
* interceptors that may have become `null` calling `eject`.
|
|
1331
|
-
*
|
|
1332
|
-
* @param {Function} fn The function to call for each interceptor
|
|
1333
|
-
*
|
|
1334
|
-
* @returns {void}
|
|
1335
|
-
*/
|
|
1336
|
-
forEach(fn) {
|
|
1337
|
-
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1338
|
-
if (h !== null) {
|
|
1339
|
-
fn(h);
|
|
1340
|
-
}
|
|
1341
|
-
});
|
|
1220
|
+
return false;
|
|
1342
1221
|
}
|
|
1343
|
-
}
|
|
1344
1222
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
clarifyTimeoutError: false,
|
|
1349
|
-
legacyInterceptorReqResOrdering: true
|
|
1350
|
-
};
|
|
1223
|
+
delete(header, matcher) {
|
|
1224
|
+
const self = this;
|
|
1225
|
+
let deleted = false;
|
|
1351
1226
|
|
|
1352
|
-
|
|
1227
|
+
function deleteHeader(_header) {
|
|
1228
|
+
_header = normalizeHeader(_header);
|
|
1353
1229
|
|
|
1354
|
-
|
|
1230
|
+
if (_header) {
|
|
1231
|
+
const key = utils$1.findKey(self, _header);
|
|
1355
1232
|
|
|
1356
|
-
|
|
1233
|
+
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1234
|
+
delete self[key];
|
|
1357
1235
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
FormData: FormData$1,
|
|
1363
|
-
Blob: Blob$1
|
|
1364
|
-
},
|
|
1365
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1366
|
-
};
|
|
1236
|
+
deleted = true;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1367
1240
|
|
|
1368
|
-
|
|
1241
|
+
if (utils$1.isArray(header)) {
|
|
1242
|
+
header.forEach(deleteHeader);
|
|
1243
|
+
} else {
|
|
1244
|
+
deleteHeader(header);
|
|
1245
|
+
}
|
|
1369
1246
|
|
|
1370
|
-
|
|
1247
|
+
return deleted;
|
|
1248
|
+
}
|
|
1371
1249
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
1377
|
-
*
|
|
1378
|
-
* web workers:
|
|
1379
|
-
* typeof window -> undefined
|
|
1380
|
-
* typeof document -> undefined
|
|
1381
|
-
*
|
|
1382
|
-
* react-native:
|
|
1383
|
-
* navigator.product -> 'ReactNative'
|
|
1384
|
-
* nativescript
|
|
1385
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
|
1386
|
-
*
|
|
1387
|
-
* @returns {boolean}
|
|
1388
|
-
*/
|
|
1389
|
-
const hasStandardBrowserEnv = hasBrowserEnv &&
|
|
1390
|
-
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1250
|
+
clear(matcher) {
|
|
1251
|
+
const keys = Object.keys(this);
|
|
1252
|
+
let i = keys.length;
|
|
1253
|
+
let deleted = false;
|
|
1391
1254
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
|
1400
|
-
*/
|
|
1401
|
-
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1402
|
-
return (
|
|
1403
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1404
|
-
// eslint-disable-next-line no-undef
|
|
1405
|
-
self instanceof WorkerGlobalScope &&
|
|
1406
|
-
typeof self.importScripts === 'function'
|
|
1407
|
-
);
|
|
1408
|
-
})();
|
|
1255
|
+
while (i--) {
|
|
1256
|
+
const key = keys[i];
|
|
1257
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1258
|
+
delete this[key];
|
|
1259
|
+
deleted = true;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1409
1262
|
|
|
1410
|
-
|
|
1263
|
+
return deleted;
|
|
1264
|
+
}
|
|
1411
1265
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
hasStandardBrowserEnv,
|
|
1416
|
-
hasStandardBrowserWebWorkerEnv,
|
|
1417
|
-
navigator: _navigator,
|
|
1418
|
-
origin
|
|
1419
|
-
}, Symbol.toStringTag, { value: 'Module' }));
|
|
1266
|
+
normalize(format) {
|
|
1267
|
+
const self = this;
|
|
1268
|
+
const headers = {};
|
|
1420
1269
|
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
...platform$1
|
|
1424
|
-
};
|
|
1270
|
+
utils$1.forEach(this, (value, header) => {
|
|
1271
|
+
const key = utils$1.findKey(headers, header);
|
|
1425
1272
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
this.append(key, value.toString('base64'));
|
|
1431
|
-
return false;
|
|
1273
|
+
if (key) {
|
|
1274
|
+
self[key] = normalizeValue(value);
|
|
1275
|
+
delete self[header];
|
|
1276
|
+
return;
|
|
1432
1277
|
}
|
|
1433
1278
|
|
|
1434
|
-
|
|
1435
|
-
},
|
|
1436
|
-
...options
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1279
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1439
1280
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
* @param {string} name - The name of the property to get.
|
|
1444
|
-
*
|
|
1445
|
-
* @returns An array of strings.
|
|
1446
|
-
*/
|
|
1447
|
-
function parsePropPath(name) {
|
|
1448
|
-
// foo[x][y][z]
|
|
1449
|
-
// foo.x.y.z
|
|
1450
|
-
// foo-x-y-z
|
|
1451
|
-
// foo x y z
|
|
1452
|
-
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1453
|
-
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1281
|
+
if (normalized !== header) {
|
|
1282
|
+
delete self[header];
|
|
1283
|
+
}
|
|
1456
1284
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
*/
|
|
1464
|
-
function arrayToObject(arr) {
|
|
1465
|
-
const obj = {};
|
|
1466
|
-
const keys = Object.keys(arr);
|
|
1467
|
-
let i;
|
|
1468
|
-
const len = keys.length;
|
|
1469
|
-
let key;
|
|
1470
|
-
for (i = 0; i < len; i++) {
|
|
1471
|
-
key = keys[i];
|
|
1472
|
-
obj[key] = arr[key];
|
|
1285
|
+
self[normalized] = normalizeValue(value);
|
|
1286
|
+
|
|
1287
|
+
headers[normalized] = true;
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
return this;
|
|
1473
1291
|
}
|
|
1474
|
-
return obj;
|
|
1475
|
-
}
|
|
1476
1292
|
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
* @param {string} formData The FormData object to convert to JSON.
|
|
1481
|
-
*
|
|
1482
|
-
* @returns {Object<string, any> | null} The converted object.
|
|
1483
|
-
*/
|
|
1484
|
-
function formDataToJSON(formData) {
|
|
1485
|
-
function buildPath(path, value, target, index) {
|
|
1486
|
-
let name = path[index++];
|
|
1293
|
+
concat(...targets) {
|
|
1294
|
+
return this.constructor.concat(this, ...targets);
|
|
1295
|
+
}
|
|
1487
1296
|
|
|
1488
|
-
|
|
1297
|
+
toJSON(asStrings) {
|
|
1298
|
+
const obj = Object.create(null);
|
|
1489
1299
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1300
|
+
utils$1.forEach(this, (value, header) => {
|
|
1301
|
+
value != null &&
|
|
1302
|
+
value !== false &&
|
|
1303
|
+
(obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1304
|
+
});
|
|
1493
1305
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
target[name] = [target[name], value];
|
|
1497
|
-
} else {
|
|
1498
|
-
target[name] = value;
|
|
1499
|
-
}
|
|
1306
|
+
return obj;
|
|
1307
|
+
}
|
|
1500
1308
|
|
|
1501
|
-
|
|
1502
|
-
|
|
1309
|
+
[Symbol.iterator]() {
|
|
1310
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1311
|
+
}
|
|
1503
1312
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1313
|
+
toString() {
|
|
1314
|
+
return Object.entries(this.toJSON())
|
|
1315
|
+
.map(([header, value]) => header + ': ' + value)
|
|
1316
|
+
.join('\n');
|
|
1317
|
+
}
|
|
1507
1318
|
|
|
1508
|
-
|
|
1319
|
+
getSetCookie() {
|
|
1320
|
+
return this.get('set-cookie') || [];
|
|
1321
|
+
}
|
|
1509
1322
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1323
|
+
get [Symbol.toStringTag]() {
|
|
1324
|
+
return 'AxiosHeaders';
|
|
1325
|
+
}
|
|
1513
1326
|
|
|
1514
|
-
|
|
1327
|
+
static from(thing) {
|
|
1328
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1515
1329
|
}
|
|
1516
1330
|
|
|
1517
|
-
|
|
1518
|
-
const
|
|
1331
|
+
static concat(first, ...targets) {
|
|
1332
|
+
const computed = new this(first);
|
|
1519
1333
|
|
|
1520
|
-
|
|
1521
|
-
buildPath(parsePropPath(name), value, obj, 0);
|
|
1522
|
-
});
|
|
1334
|
+
targets.forEach((target) => computed.set(target));
|
|
1523
1335
|
|
|
1524
|
-
return
|
|
1336
|
+
return computed;
|
|
1525
1337
|
}
|
|
1526
1338
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1339
|
+
static accessor(header) {
|
|
1340
|
+
const internals =
|
|
1341
|
+
(this[$internals] =
|
|
1342
|
+
this[$internals] =
|
|
1343
|
+
{
|
|
1344
|
+
accessors: {},
|
|
1345
|
+
});
|
|
1529
1346
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
*/
|
|
1540
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
1541
|
-
if (utils$1.isString(rawValue)) {
|
|
1542
|
-
try {
|
|
1543
|
-
(0, JSON.parse)(rawValue);
|
|
1544
|
-
return utils$1.trim(rawValue);
|
|
1545
|
-
} catch (e) {
|
|
1546
|
-
if (e.name !== 'SyntaxError') {
|
|
1547
|
-
throw e;
|
|
1347
|
+
const accessors = internals.accessors;
|
|
1348
|
+
const prototype = this.prototype;
|
|
1349
|
+
|
|
1350
|
+
function defineAccessor(_header) {
|
|
1351
|
+
const lHeader = normalizeHeader(_header);
|
|
1352
|
+
|
|
1353
|
+
if (!accessors[lHeader]) {
|
|
1354
|
+
buildAccessors(prototype, _header);
|
|
1355
|
+
accessors[lHeader] = true;
|
|
1548
1356
|
}
|
|
1549
1357
|
}
|
|
1550
|
-
}
|
|
1551
1358
|
|
|
1552
|
-
|
|
1359
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1360
|
+
|
|
1361
|
+
return this;
|
|
1362
|
+
}
|
|
1553
1363
|
}
|
|
1554
1364
|
|
|
1555
|
-
|
|
1365
|
+
AxiosHeaders.accessor([
|
|
1366
|
+
'Content-Type',
|
|
1367
|
+
'Content-Length',
|
|
1368
|
+
'Accept',
|
|
1369
|
+
'Accept-Encoding',
|
|
1370
|
+
'User-Agent',
|
|
1371
|
+
'Authorization',
|
|
1372
|
+
]);
|
|
1556
1373
|
|
|
1557
|
-
|
|
1374
|
+
// reserved names hotfix
|
|
1375
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
1376
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1377
|
+
return {
|
|
1378
|
+
get: () => value,
|
|
1379
|
+
set(headerValue) {
|
|
1380
|
+
this[mapped] = headerValue;
|
|
1381
|
+
},
|
|
1382
|
+
};
|
|
1383
|
+
});
|
|
1558
1384
|
|
|
1559
|
-
|
|
1385
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
1560
1386
|
|
|
1561
|
-
|
|
1562
|
-
const contentType = headers.getContentType() || '';
|
|
1563
|
-
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1564
|
-
const isObjectPayload = utils$1.isObject(data);
|
|
1387
|
+
const REDACTED = '[REDACTED ****]';
|
|
1565
1388
|
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1389
|
+
function hasOwnOrPrototypeToJSON(source) {
|
|
1390
|
+
if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|
1391
|
+
return true;
|
|
1392
|
+
}
|
|
1569
1393
|
|
|
1570
|
-
|
|
1394
|
+
let prototype = Object.getPrototypeOf(source);
|
|
1571
1395
|
|
|
1572
|
-
|
|
1573
|
-
|
|
1396
|
+
while (prototype && prototype !== Object.prototype) {
|
|
1397
|
+
if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|
1398
|
+
return true;
|
|
1574
1399
|
}
|
|
1575
1400
|
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
utils$1.isStream(data) ||
|
|
1579
|
-
utils$1.isFile(data) ||
|
|
1580
|
-
utils$1.isBlob(data) ||
|
|
1581
|
-
utils$1.isReadableStream(data)
|
|
1582
|
-
) {
|
|
1583
|
-
return data;
|
|
1584
|
-
}
|
|
1585
|
-
if (utils$1.isArrayBufferView(data)) {
|
|
1586
|
-
return data.buffer;
|
|
1587
|
-
}
|
|
1588
|
-
if (utils$1.isURLSearchParams(data)) {
|
|
1589
|
-
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1590
|
-
return data.toString();
|
|
1591
|
-
}
|
|
1401
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
1402
|
+
}
|
|
1592
1403
|
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
if (isObjectPayload) {
|
|
1596
|
-
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
1597
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1598
|
-
}
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1599
1406
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1407
|
+
// Build a plain-object snapshot of `config` and replace the value of any key
|
|
1408
|
+
// (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|
1409
|
+
// and AxiosHeaders, and short-circuits on circular references.
|
|
1410
|
+
function redactConfig(config, redactKeys) {
|
|
1411
|
+
const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
|
|
1412
|
+
const seen = [];
|
|
1602
1413
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
);
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1414
|
+
const visit = (source) => {
|
|
1415
|
+
if (source === null || typeof source !== 'object') return source;
|
|
1416
|
+
if (utils$1.isBuffer(source)) return source;
|
|
1417
|
+
if (seen.indexOf(source) !== -1) return undefined;
|
|
1610
1418
|
|
|
1611
|
-
if (
|
|
1612
|
-
|
|
1613
|
-
return stringifySafely(data);
|
|
1419
|
+
if (source instanceof AxiosHeaders) {
|
|
1420
|
+
source = source.toJSON();
|
|
1614
1421
|
}
|
|
1615
1422
|
|
|
1616
|
-
|
|
1617
|
-
}],
|
|
1423
|
+
seen.push(source);
|
|
1618
1424
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1425
|
+
let result;
|
|
1426
|
+
if (utils$1.isArray(source)) {
|
|
1427
|
+
result = [];
|
|
1428
|
+
source.forEach((v, i) => {
|
|
1429
|
+
const reducedValue = visit(v);
|
|
1430
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1431
|
+
result[i] = reducedValue;
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
} else {
|
|
1435
|
+
if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|
1436
|
+
seen.pop();
|
|
1437
|
+
return source;
|
|
1438
|
+
}
|
|
1623
1439
|
|
|
1624
|
-
|
|
1625
|
-
|
|
1440
|
+
result = Object.create(null);
|
|
1441
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1442
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
|
|
1443
|
+
if (!utils$1.isUndefined(reducedValue)) {
|
|
1444
|
+
result[key] = reducedValue;
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1626
1447
|
}
|
|
1627
1448
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1449
|
+
seen.pop();
|
|
1450
|
+
return result;
|
|
1451
|
+
};
|
|
1631
1452
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1453
|
+
return visit(config);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
class AxiosError extends Error {
|
|
1457
|
+
static from(error, code, config, request, response, customProps) {
|
|
1458
|
+
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
1459
|
+
axiosError.cause = error;
|
|
1460
|
+
axiosError.name = error.name;
|
|
1461
|
+
|
|
1462
|
+
// Preserve status from the original error if not already set from response
|
|
1463
|
+
if (error.status != null && axiosError.status == null) {
|
|
1464
|
+
axiosError.status = error.status;
|
|
1642
1465
|
}
|
|
1643
1466
|
|
|
1644
|
-
|
|
1645
|
-
|
|
1467
|
+
customProps && Object.assign(axiosError, customProps);
|
|
1468
|
+
return axiosError;
|
|
1469
|
+
}
|
|
1646
1470
|
|
|
1647
1471
|
/**
|
|
1648
|
-
*
|
|
1649
|
-
*
|
|
1472
|
+
* Create an Error with the specified message, config, error code, request and response.
|
|
1473
|
+
*
|
|
1474
|
+
* @param {string} message The error message.
|
|
1475
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
1476
|
+
* @param {Object} [config] The config.
|
|
1477
|
+
* @param {Object} [request] The request.
|
|
1478
|
+
* @param {Object} [response] The response.
|
|
1479
|
+
*
|
|
1480
|
+
* @returns {Error} The created error.
|
|
1650
1481
|
*/
|
|
1651
|
-
|
|
1482
|
+
constructor(message, code, config, request, response) {
|
|
1483
|
+
super(message);
|
|
1484
|
+
|
|
1485
|
+
// Make message enumerable to maintain backward compatibility
|
|
1486
|
+
// The native Error constructor sets message as non-enumerable,
|
|
1487
|
+
// but axios < v1.13.3 had it as enumerable
|
|
1488
|
+
Object.defineProperty(this, 'message', {
|
|
1489
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
1490
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
1491
|
+
__proto__: null,
|
|
1492
|
+
value: message,
|
|
1493
|
+
enumerable: true,
|
|
1494
|
+
writable: true,
|
|
1495
|
+
configurable: true,
|
|
1496
|
+
});
|
|
1652
1497
|
|
|
1653
|
-
|
|
1654
|
-
|
|
1498
|
+
this.name = 'AxiosError';
|
|
1499
|
+
this.isAxiosError = true;
|
|
1500
|
+
code && (this.code = code);
|
|
1501
|
+
config && (this.config = config);
|
|
1502
|
+
request && (this.request = request);
|
|
1503
|
+
if (response) {
|
|
1504
|
+
this.response = response;
|
|
1505
|
+
this.status = response.status;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
toJSON() {
|
|
1510
|
+
// Opt-in redaction: when the request config carries a `redact` array, the
|
|
1511
|
+
// value of any matching key (case-insensitive, at any depth) is replaced
|
|
1512
|
+
// with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|
1513
|
+
// existing serialization behavior unchanged.
|
|
1514
|
+
const config = this.config;
|
|
1515
|
+
const redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|
1516
|
+
const serializedConfig =
|
|
1517
|
+
utils$1.isArray(redactKeys) && redactKeys.length > 0
|
|
1518
|
+
? redactConfig(config, redactKeys)
|
|
1519
|
+
: utils$1.toJSONObject(config);
|
|
1655
1520
|
|
|
1656
|
-
|
|
1657
|
-
|
|
1521
|
+
return {
|
|
1522
|
+
// Standard
|
|
1523
|
+
message: this.message,
|
|
1524
|
+
name: this.name,
|
|
1525
|
+
// Microsoft
|
|
1526
|
+
description: this.description,
|
|
1527
|
+
number: this.number,
|
|
1528
|
+
// Mozilla
|
|
1529
|
+
fileName: this.fileName,
|
|
1530
|
+
lineNumber: this.lineNumber,
|
|
1531
|
+
columnNumber: this.columnNumber,
|
|
1532
|
+
stack: this.stack,
|
|
1533
|
+
// Axios
|
|
1534
|
+
config: serializedConfig,
|
|
1535
|
+
code: this.code,
|
|
1536
|
+
status: this.status,
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1658
1540
|
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1541
|
+
// This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|
1542
|
+
AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|
1543
|
+
AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|
1544
|
+
AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|
1545
|
+
AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|
1546
|
+
AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|
1547
|
+
AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|
1548
|
+
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|
1549
|
+
AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|
1550
|
+
AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|
1551
|
+
AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|
1552
|
+
AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|
1553
|
+
AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|
1554
|
+
AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|
1555
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|
1663
1556
|
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
},
|
|
1557
|
+
// eslint-disable-next-line strict
|
|
1558
|
+
const httpAdapter = null;
|
|
1667
1559
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1560
|
+
/**
|
|
1561
|
+
* Determines if the given thing is a array or js object.
|
|
1562
|
+
*
|
|
1563
|
+
* @param {string} thing - The object or array to be visited.
|
|
1564
|
+
*
|
|
1565
|
+
* @returns {boolean}
|
|
1566
|
+
*/
|
|
1567
|
+
function isVisitable(thing) {
|
|
1568
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1569
|
+
}
|
|
1675
1570
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1571
|
+
/**
|
|
1572
|
+
* It removes the brackets from the end of a string
|
|
1573
|
+
*
|
|
1574
|
+
* @param {string} key - The key of the parameter.
|
|
1575
|
+
*
|
|
1576
|
+
* @returns {string} the key without the brackets.
|
|
1577
|
+
*/
|
|
1578
|
+
function removeBrackets(key) {
|
|
1579
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1580
|
+
}
|
|
1679
1581
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1582
|
+
/**
|
|
1583
|
+
* It takes a path, a key, and a boolean, and returns a string
|
|
1584
|
+
*
|
|
1585
|
+
* @param {string} path - The path to the current key.
|
|
1586
|
+
* @param {string} key - The key of the current object being iterated over.
|
|
1587
|
+
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|
1588
|
+
*
|
|
1589
|
+
* @returns {string} The path to the current key.
|
|
1590
|
+
*/
|
|
1591
|
+
function renderKey(path, key, dots) {
|
|
1592
|
+
if (!path) return key;
|
|
1593
|
+
return path
|
|
1594
|
+
.concat(key)
|
|
1595
|
+
.map(function each(token, i) {
|
|
1596
|
+
// eslint-disable-next-line no-param-reassign
|
|
1597
|
+
token = removeBrackets(token);
|
|
1598
|
+
return !dots && i ? '[' + token + ']' : token;
|
|
1599
|
+
})
|
|
1600
|
+
.join(dots ? '.' : '');
|
|
1601
|
+
}
|
|
1688
1602
|
|
|
1689
1603
|
/**
|
|
1690
|
-
*
|
|
1604
|
+
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
|
1691
1605
|
*
|
|
1692
|
-
*
|
|
1693
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
1694
|
-
* Content-Type: application/json
|
|
1695
|
-
* Connection: keep-alive
|
|
1696
|
-
* Transfer-Encoding: chunked
|
|
1697
|
-
* ```
|
|
1606
|
+
* @param {Array<any>} arr - The array to check
|
|
1698
1607
|
*
|
|
1699
|
-
* @
|
|
1608
|
+
* @returns {boolean}
|
|
1609
|
+
*/
|
|
1610
|
+
function isFlatArray(arr) {
|
|
1611
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
1615
|
+
return /^is[A-Z]/.test(prop);
|
|
1616
|
+
});
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Convert a data object to FormData
|
|
1700
1620
|
*
|
|
1701
|
-
* @
|
|
1621
|
+
* @param {Object} obj
|
|
1622
|
+
* @param {?Object} [formData]
|
|
1623
|
+
* @param {?Object} [options]
|
|
1624
|
+
* @param {Function} [options.visitor]
|
|
1625
|
+
* @param {Boolean} [options.metaTokens = true]
|
|
1626
|
+
* @param {Boolean} [options.dots = false]
|
|
1627
|
+
* @param {?Boolean} [options.indexes = false]
|
|
1628
|
+
*
|
|
1629
|
+
* @returns {Object}
|
|
1630
|
+
**/
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* It converts an object into a FormData object
|
|
1634
|
+
*
|
|
1635
|
+
* @param {Object<any, any>} obj - The object to convert to form data.
|
|
1636
|
+
* @param {string} formData - The FormData object to append to.
|
|
1637
|
+
* @param {Object<string, any>} options
|
|
1638
|
+
*
|
|
1639
|
+
* @returns
|
|
1702
1640
|
*/
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
let i;
|
|
1641
|
+
function toFormData(obj, formData, options) {
|
|
1642
|
+
if (!utils$1.isObject(obj)) {
|
|
1643
|
+
throw new TypeError('target must be an object');
|
|
1644
|
+
}
|
|
1708
1645
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
1712
|
-
val = line.substring(i + 1).trim();
|
|
1646
|
+
// eslint-disable-next-line no-param-reassign
|
|
1647
|
+
formData = formData || new (FormData)();
|
|
1713
1648
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1649
|
+
// eslint-disable-next-line no-param-reassign
|
|
1650
|
+
options = utils$1.toFlatObject(
|
|
1651
|
+
options,
|
|
1652
|
+
{
|
|
1653
|
+
metaTokens: true,
|
|
1654
|
+
dots: false,
|
|
1655
|
+
indexes: false,
|
|
1656
|
+
},
|
|
1657
|
+
false,
|
|
1658
|
+
function defined(option, source) {
|
|
1659
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1660
|
+
return !utils$1.isUndefined(source[option]);
|
|
1716
1661
|
}
|
|
1662
|
+
);
|
|
1717
1663
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1664
|
+
const metaTokens = options.metaTokens;
|
|
1665
|
+
// eslint-disable-next-line no-use-before-define
|
|
1666
|
+
const visitor = options.visitor || defaultVisitor;
|
|
1667
|
+
const dots = options.dots;
|
|
1668
|
+
const indexes = options.indexes;
|
|
1669
|
+
const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
|
|
1670
|
+
const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|
1671
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1672
|
+
|
|
1673
|
+
if (!utils$1.isFunction(visitor)) {
|
|
1674
|
+
throw new TypeError('visitor must be a function');
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
function convertValue(value) {
|
|
1678
|
+
if (value === null) return '';
|
|
1679
|
+
|
|
1680
|
+
if (utils$1.isDate(value)) {
|
|
1681
|
+
return value.toISOString();
|
|
1726
1682
|
}
|
|
1727
|
-
});
|
|
1728
1683
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1684
|
+
if (utils$1.isBoolean(value)) {
|
|
1685
|
+
return value.toString();
|
|
1686
|
+
}
|
|
1731
1687
|
|
|
1732
|
-
|
|
1688
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
1689
|
+
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1690
|
+
}
|
|
1733
1691
|
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
}
|
|
1692
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
1693
|
+
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1694
|
+
}
|
|
1737
1695
|
|
|
1738
|
-
function normalizeValue(value) {
|
|
1739
|
-
if (value === false || value == null) {
|
|
1740
1696
|
return value;
|
|
1741
1697
|
}
|
|
1742
1698
|
|
|
1743
|
-
|
|
1744
|
-
|
|
1699
|
+
/**
|
|
1700
|
+
* Default visitor.
|
|
1701
|
+
*
|
|
1702
|
+
* @param {*} value
|
|
1703
|
+
* @param {String|Number} key
|
|
1704
|
+
* @param {Array<String|Number>} path
|
|
1705
|
+
* @this {FormData}
|
|
1706
|
+
*
|
|
1707
|
+
* @returns {boolean} return true to visit the each prop of the value recursively
|
|
1708
|
+
*/
|
|
1709
|
+
function defaultVisitor(value, key, path) {
|
|
1710
|
+
let arr = value;
|
|
1745
1711
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1712
|
+
if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|
1713
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1750
1716
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1717
|
+
if (value && !path && typeof value === 'object') {
|
|
1718
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
1719
|
+
// eslint-disable-next-line no-param-reassign
|
|
1720
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
1721
|
+
// eslint-disable-next-line no-param-reassign
|
|
1722
|
+
value = JSON.stringify(value);
|
|
1723
|
+
} else if (
|
|
1724
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1725
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
|
|
1726
|
+
) {
|
|
1727
|
+
// eslint-disable-next-line no-param-reassign
|
|
1728
|
+
key = removeBrackets(key);
|
|
1754
1729
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1730
|
+
arr.forEach(function each(el, index) {
|
|
1731
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1732
|
+
formData.append(
|
|
1733
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1734
|
+
indexes === true
|
|
1735
|
+
? renderKey([key], index, dots)
|
|
1736
|
+
: indexes === null
|
|
1737
|
+
? key
|
|
1738
|
+
: key + '[]',
|
|
1739
|
+
convertValue(el)
|
|
1740
|
+
);
|
|
1741
|
+
});
|
|
1742
|
+
return false;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1757
1745
|
|
|
1758
|
-
|
|
1746
|
+
if (isVisitable(value)) {
|
|
1747
|
+
return true;
|
|
1748
|
+
}
|
|
1759
1749
|
|
|
1760
|
-
|
|
1761
|
-
if (utils$1.isFunction(filter)) {
|
|
1762
|
-
return filter.call(this, value, header);
|
|
1763
|
-
}
|
|
1750
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
1764
1751
|
|
|
1765
|
-
|
|
1766
|
-
value = header;
|
|
1752
|
+
return false;
|
|
1767
1753
|
}
|
|
1768
1754
|
|
|
1769
|
-
|
|
1755
|
+
const stack = [];
|
|
1770
1756
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1757
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
1758
|
+
defaultVisitor,
|
|
1759
|
+
convertValue,
|
|
1760
|
+
isVisitable,
|
|
1761
|
+
});
|
|
1774
1762
|
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
}
|
|
1778
|
-
}
|
|
1763
|
+
function build(value, path, depth = 0) {
|
|
1764
|
+
if (utils$1.isUndefined(value)) return;
|
|
1779
1765
|
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
}
|
|
1766
|
+
if (depth > maxDepth) {
|
|
1767
|
+
throw new AxiosError(
|
|
1768
|
+
'Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth,
|
|
1769
|
+
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1786
1772
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1773
|
+
if (stack.indexOf(value) !== -1) {
|
|
1774
|
+
throw Error('Circular reference detected in ' + path.join('.'));
|
|
1775
|
+
}
|
|
1789
1776
|
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1777
|
+
stack.push(value);
|
|
1778
|
+
|
|
1779
|
+
utils$1.forEach(value, function each(el, key) {
|
|
1780
|
+
const result =
|
|
1781
|
+
!(utils$1.isUndefined(el) || el === null) &&
|
|
1782
|
+
visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|
1783
|
+
|
|
1784
|
+
if (result === true) {
|
|
1785
|
+
build(el, path ? path.concat(key) : [key], depth + 1);
|
|
1786
|
+
}
|
|
1796
1787
|
});
|
|
1788
|
+
|
|
1789
|
+
stack.pop();
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
if (!utils$1.isObject(obj)) {
|
|
1793
|
+
throw new TypeError('data must be an object');
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
build(obj);
|
|
1797
|
+
|
|
1798
|
+
return formData;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* It encodes a string by replacing all characters that are not in the unreserved set with
|
|
1803
|
+
* their percent-encoded equivalents
|
|
1804
|
+
*
|
|
1805
|
+
* @param {string} str - The string to encode.
|
|
1806
|
+
*
|
|
1807
|
+
* @returns {string} The encoded string.
|
|
1808
|
+
*/
|
|
1809
|
+
function encode$1(str) {
|
|
1810
|
+
const charMap = {
|
|
1811
|
+
'!': '%21',
|
|
1812
|
+
"'": '%27',
|
|
1813
|
+
'(': '%28',
|
|
1814
|
+
')': '%29',
|
|
1815
|
+
'~': '%7E',
|
|
1816
|
+
'%20': '+',
|
|
1817
|
+
};
|
|
1818
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|
1819
|
+
return charMap[match];
|
|
1797
1820
|
});
|
|
1798
1821
|
}
|
|
1799
1822
|
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1823
|
+
/**
|
|
1824
|
+
* It takes a params object and converts it to a FormData object
|
|
1825
|
+
*
|
|
1826
|
+
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|
1827
|
+
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|
1828
|
+
*
|
|
1829
|
+
* @returns {void}
|
|
1830
|
+
*/
|
|
1831
|
+
function AxiosURLSearchParams(params, options) {
|
|
1832
|
+
this._pairs = [];
|
|
1804
1833
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1834
|
+
params && toFormData(params, this, options);
|
|
1835
|
+
}
|
|
1807
1836
|
|
|
1808
|
-
|
|
1809
|
-
const lHeader = normalizeHeader(_header);
|
|
1837
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
1810
1838
|
|
|
1811
|
-
|
|
1812
|
-
|
|
1839
|
+
prototype.append = function append(name, value) {
|
|
1840
|
+
this._pairs.push([name, value]);
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1843
|
+
prototype.toString = function toString(encoder) {
|
|
1844
|
+
const _encode = encoder
|
|
1845
|
+
? function (value) {
|
|
1846
|
+
return encoder.call(this, value, encode$1);
|
|
1813
1847
|
}
|
|
1848
|
+
: encode$1;
|
|
1814
1849
|
|
|
1815
|
-
|
|
1850
|
+
return this._pairs
|
|
1851
|
+
.map(function each(pair) {
|
|
1852
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
1853
|
+
}, '')
|
|
1854
|
+
.join('&');
|
|
1855
|
+
};
|
|
1816
1856
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1857
|
+
/**
|
|
1858
|
+
* It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|
1859
|
+
* their plain counterparts (`:`, `$`, `,`, `+`).
|
|
1860
|
+
*
|
|
1861
|
+
* @param {string} val The value to be encoded.
|
|
1862
|
+
*
|
|
1863
|
+
* @returns {string} The encoded value.
|
|
1864
|
+
*/
|
|
1865
|
+
function encode(val) {
|
|
1866
|
+
return encodeURIComponent(val)
|
|
1867
|
+
.replace(/%3A/gi, ':')
|
|
1868
|
+
.replace(/%24/g, '$')
|
|
1869
|
+
.replace(/%2C/gi, ',')
|
|
1870
|
+
.replace(/%20/g, '+');
|
|
1871
|
+
}
|
|
1821
1872
|
|
|
1822
|
-
|
|
1823
|
-
|
|
1873
|
+
/**
|
|
1874
|
+
* Build a URL by appending params to the end
|
|
1875
|
+
*
|
|
1876
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
1877
|
+
* @param {object} [params] The params to be appended
|
|
1878
|
+
* @param {?(object|Function)} options
|
|
1879
|
+
*
|
|
1880
|
+
* @returns {string} The formatted url
|
|
1881
|
+
*/
|
|
1882
|
+
function buildURL(url, params, options) {
|
|
1883
|
+
if (!params) {
|
|
1884
|
+
return url;
|
|
1885
|
+
}
|
|
1824
1886
|
|
|
1825
|
-
|
|
1826
|
-
setHeaders(header, valueOrRewrite);
|
|
1827
|
-
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1828
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1829
|
-
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1830
|
-
let obj = {}, dest, key;
|
|
1831
|
-
for (const entry of header) {
|
|
1832
|
-
if (!utils$1.isArray(entry)) {
|
|
1833
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
1834
|
-
}
|
|
1887
|
+
const _encode = (options && options.encode) || encode;
|
|
1835
1888
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1889
|
+
const _options = utils$1.isFunction(options)
|
|
1890
|
+
? {
|
|
1891
|
+
serialize: options,
|
|
1838
1892
|
}
|
|
1893
|
+
: options;
|
|
1839
1894
|
|
|
1840
|
-
|
|
1841
|
-
} else {
|
|
1842
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1843
|
-
}
|
|
1895
|
+
const serializeFn = _options && _options.serialize;
|
|
1844
1896
|
|
|
1845
|
-
|
|
1897
|
+
let serializedParams;
|
|
1898
|
+
|
|
1899
|
+
if (serializeFn) {
|
|
1900
|
+
serializedParams = serializeFn(params, _options);
|
|
1901
|
+
} else {
|
|
1902
|
+
serializedParams = utils$1.isURLSearchParams(params)
|
|
1903
|
+
? params.toString()
|
|
1904
|
+
: new AxiosURLSearchParams(params, _options).toString(_encode);
|
|
1846
1905
|
}
|
|
1847
1906
|
|
|
1848
|
-
|
|
1849
|
-
|
|
1907
|
+
if (serializedParams) {
|
|
1908
|
+
const hashmarkIndex = url.indexOf('#');
|
|
1850
1909
|
|
|
1851
|
-
if (
|
|
1852
|
-
|
|
1910
|
+
if (hashmarkIndex !== -1) {
|
|
1911
|
+
url = url.slice(0, hashmarkIndex);
|
|
1912
|
+
}
|
|
1913
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
1914
|
+
}
|
|
1853
1915
|
|
|
1854
|
-
|
|
1855
|
-
|
|
1916
|
+
return url;
|
|
1917
|
+
}
|
|
1856
1918
|
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1919
|
+
class InterceptorManager {
|
|
1920
|
+
constructor() {
|
|
1921
|
+
this.handlers = [];
|
|
1922
|
+
}
|
|
1860
1923
|
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1924
|
+
/**
|
|
1925
|
+
* Add a new interceptor to the stack
|
|
1926
|
+
*
|
|
1927
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
1928
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
1929
|
+
* @param {Object} options The options for the interceptor, synchronous and runWhen
|
|
1930
|
+
*
|
|
1931
|
+
* @return {Number} An ID used to remove interceptor later
|
|
1932
|
+
*/
|
|
1933
|
+
use(fulfilled, rejected, options) {
|
|
1934
|
+
this.handlers.push({
|
|
1935
|
+
fulfilled,
|
|
1936
|
+
rejected,
|
|
1937
|
+
synchronous: options ? options.synchronous : false,
|
|
1938
|
+
runWhen: options ? options.runWhen : null,
|
|
1939
|
+
});
|
|
1940
|
+
return this.handlers.length - 1;
|
|
1941
|
+
}
|
|
1864
1942
|
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1943
|
+
/**
|
|
1944
|
+
* Remove an interceptor from the stack
|
|
1945
|
+
*
|
|
1946
|
+
* @param {Number} id The ID that was returned by `use`
|
|
1947
|
+
*
|
|
1948
|
+
* @returns {void}
|
|
1949
|
+
*/
|
|
1950
|
+
eject(id) {
|
|
1951
|
+
if (this.handlers[id]) {
|
|
1952
|
+
this.handlers[id] = null;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1868
1955
|
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1956
|
+
/**
|
|
1957
|
+
* Clear all interceptors from the stack
|
|
1958
|
+
*
|
|
1959
|
+
* @returns {void}
|
|
1960
|
+
*/
|
|
1961
|
+
clear() {
|
|
1962
|
+
if (this.handlers) {
|
|
1963
|
+
this.handlers = [];
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1872
1966
|
|
|
1873
|
-
|
|
1967
|
+
/**
|
|
1968
|
+
* Iterate over all the registered interceptors
|
|
1969
|
+
*
|
|
1970
|
+
* This method is particularly useful for skipping over any
|
|
1971
|
+
* interceptors that may have become `null` calling `eject`.
|
|
1972
|
+
*
|
|
1973
|
+
* @param {Function} fn The function to call for each interceptor
|
|
1974
|
+
*
|
|
1975
|
+
* @returns {void}
|
|
1976
|
+
*/
|
|
1977
|
+
forEach(fn) {
|
|
1978
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1979
|
+
if (h !== null) {
|
|
1980
|
+
fn(h);
|
|
1874
1981
|
}
|
|
1875
|
-
}
|
|
1982
|
+
});
|
|
1876
1983
|
}
|
|
1984
|
+
}
|
|
1877
1985
|
|
|
1878
|
-
|
|
1879
|
-
|
|
1986
|
+
const transitionalDefaults = {
|
|
1987
|
+
silentJSONParsing: true,
|
|
1988
|
+
forcedJSONParsing: true,
|
|
1989
|
+
clarifyTimeoutError: false,
|
|
1990
|
+
legacyInterceptorReqResOrdering: true,
|
|
1991
|
+
};
|
|
1880
1992
|
|
|
1881
|
-
|
|
1882
|
-
const key = utils$1.findKey(this, header);
|
|
1993
|
+
const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|
1883
1994
|
|
|
1884
|
-
|
|
1885
|
-
}
|
|
1995
|
+
const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
1886
1996
|
|
|
1887
|
-
|
|
1888
|
-
}
|
|
1997
|
+
const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
1889
1998
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1999
|
+
const platform$1 = {
|
|
2000
|
+
isBrowser: true,
|
|
2001
|
+
classes: {
|
|
2002
|
+
URLSearchParams: URLSearchParams$1,
|
|
2003
|
+
FormData: FormData$1,
|
|
2004
|
+
Blob: Blob$1,
|
|
2005
|
+
},
|
|
2006
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
|
|
2007
|
+
};
|
|
1893
2008
|
|
|
1894
|
-
|
|
1895
|
-
_header = normalizeHeader(_header);
|
|
2009
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1896
2010
|
|
|
1897
|
-
|
|
1898
|
-
const key = utils$1.findKey(self, _header);
|
|
2011
|
+
const _navigator = (typeof navigator === 'object' && navigator) || undefined;
|
|
1899
2012
|
|
|
1900
|
-
|
|
1901
|
-
|
|
2013
|
+
/**
|
|
2014
|
+
* Determine if we're running in a standard browser environment
|
|
2015
|
+
*
|
|
2016
|
+
* This allows axios to run in a web worker, and react-native.
|
|
2017
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
|
2018
|
+
*
|
|
2019
|
+
* web workers:
|
|
2020
|
+
* typeof window -> undefined
|
|
2021
|
+
* typeof document -> undefined
|
|
2022
|
+
*
|
|
2023
|
+
* react-native:
|
|
2024
|
+
* navigator.product -> 'ReactNative'
|
|
2025
|
+
* nativescript
|
|
2026
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
|
2027
|
+
*
|
|
2028
|
+
* @returns {boolean}
|
|
2029
|
+
*/
|
|
2030
|
+
const hasStandardBrowserEnv =
|
|
2031
|
+
hasBrowserEnv &&
|
|
2032
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
1902
2033
|
|
|
1903
|
-
|
|
1904
|
-
|
|
2034
|
+
/**
|
|
2035
|
+
* Determine if we're running in a standard browser webWorker environment
|
|
2036
|
+
*
|
|
2037
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
|
2038
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
|
2039
|
+
* filtered out due to its judgment standard
|
|
2040
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
2041
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
|
2042
|
+
*/
|
|
2043
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
2044
|
+
return (
|
|
2045
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
2046
|
+
// eslint-disable-next-line no-undef
|
|
2047
|
+
self instanceof WorkerGlobalScope &&
|
|
2048
|
+
typeof self.importScripts === 'function'
|
|
2049
|
+
);
|
|
2050
|
+
})();
|
|
2051
|
+
|
|
2052
|
+
const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
|
|
2053
|
+
|
|
2054
|
+
const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
2055
|
+
__proto__: null,
|
|
2056
|
+
hasBrowserEnv,
|
|
2057
|
+
hasStandardBrowserEnv,
|
|
2058
|
+
hasStandardBrowserWebWorkerEnv,
|
|
2059
|
+
navigator: _navigator,
|
|
2060
|
+
origin
|
|
2061
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
2062
|
+
|
|
2063
|
+
const platform = {
|
|
2064
|
+
...utils,
|
|
2065
|
+
...platform$1,
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
function toURLEncodedForm(data, options) {
|
|
2069
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
2070
|
+
visitor: function (value, key, path, helpers) {
|
|
2071
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
2072
|
+
this.append(key, value.toString('base64'));
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
2077
|
+
},
|
|
2078
|
+
...options,
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
2084
|
+
*
|
|
2085
|
+
* @param {string} name - The name of the property to get.
|
|
2086
|
+
*
|
|
2087
|
+
* @returns An array of strings.
|
|
2088
|
+
*/
|
|
2089
|
+
function parsePropPath(name) {
|
|
2090
|
+
// foo[x][y][z]
|
|
2091
|
+
// foo.x.y.z
|
|
2092
|
+
// foo-x-y-z
|
|
2093
|
+
// foo x y z
|
|
2094
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
2095
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
2096
|
+
});
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
/**
|
|
2100
|
+
* Convert an array to an object.
|
|
2101
|
+
*
|
|
2102
|
+
* @param {Array<any>} arr - The array to convert to an object.
|
|
2103
|
+
*
|
|
2104
|
+
* @returns An object with the same keys and values as the array.
|
|
2105
|
+
*/
|
|
2106
|
+
function arrayToObject(arr) {
|
|
2107
|
+
const obj = {};
|
|
2108
|
+
const keys = Object.keys(arr);
|
|
2109
|
+
let i;
|
|
2110
|
+
const len = keys.length;
|
|
2111
|
+
let key;
|
|
2112
|
+
for (i = 0; i < len; i++) {
|
|
2113
|
+
key = keys[i];
|
|
2114
|
+
obj[key] = arr[key];
|
|
2115
|
+
}
|
|
2116
|
+
return obj;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
/**
|
|
2120
|
+
* It takes a FormData object and returns a JavaScript object
|
|
2121
|
+
*
|
|
2122
|
+
* @param {string} formData The FormData object to convert to JSON.
|
|
2123
|
+
*
|
|
2124
|
+
* @returns {Object<string, any> | null} The converted object.
|
|
2125
|
+
*/
|
|
2126
|
+
function formDataToJSON(formData) {
|
|
2127
|
+
function buildPath(path, value, target, index) {
|
|
2128
|
+
let name = path[index++];
|
|
2129
|
+
|
|
2130
|
+
if (name === '__proto__') return true;
|
|
2131
|
+
|
|
2132
|
+
const isNumericKey = Number.isFinite(+name);
|
|
2133
|
+
const isLast = index >= path.length;
|
|
2134
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
2135
|
+
|
|
2136
|
+
if (isLast) {
|
|
2137
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
2138
|
+
target[name] = utils$1.isArray(target[name])
|
|
2139
|
+
? target[name].concat(value)
|
|
2140
|
+
: [target[name], value];
|
|
2141
|
+
} else {
|
|
2142
|
+
target[name] = value;
|
|
1905
2143
|
}
|
|
2144
|
+
|
|
2145
|
+
return !isNumericKey;
|
|
1906
2146
|
}
|
|
1907
2147
|
|
|
1908
|
-
if (utils$1.
|
|
1909
|
-
|
|
1910
|
-
} else {
|
|
1911
|
-
deleteHeader(header);
|
|
2148
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
2149
|
+
target[name] = [];
|
|
1912
2150
|
}
|
|
1913
2151
|
|
|
1914
|
-
|
|
2152
|
+
const result = buildPath(path, value, target[name], index);
|
|
2153
|
+
|
|
2154
|
+
if (result && utils$1.isArray(target[name])) {
|
|
2155
|
+
target[name] = arrayToObject(target[name]);
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
return !isNumericKey;
|
|
1915
2159
|
}
|
|
1916
2160
|
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
let i = keys.length;
|
|
1920
|
-
let deleted = false;
|
|
2161
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
2162
|
+
const obj = {};
|
|
1921
2163
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
delete this[key];
|
|
1926
|
-
deleted = true;
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
2164
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
2165
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
2166
|
+
});
|
|
1929
2167
|
|
|
1930
|
-
return
|
|
2168
|
+
return obj;
|
|
1931
2169
|
}
|
|
1932
2170
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
const headers = {};
|
|
2171
|
+
return null;
|
|
2172
|
+
}
|
|
1936
2173
|
|
|
1937
|
-
|
|
1938
|
-
const key = utils$1.findKey(headers, header);
|
|
2174
|
+
const own = (obj, key) => (obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined);
|
|
1939
2175
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
2176
|
+
/**
|
|
2177
|
+
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
2178
|
+
* of the input
|
|
2179
|
+
*
|
|
2180
|
+
* @param {any} rawValue - The value to be stringified.
|
|
2181
|
+
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
2182
|
+
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
2183
|
+
*
|
|
2184
|
+
* @returns {string} A stringified version of the rawValue.
|
|
2185
|
+
*/
|
|
2186
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
2187
|
+
if (utils$1.isString(rawValue)) {
|
|
2188
|
+
try {
|
|
2189
|
+
(0, JSON.parse)(rawValue);
|
|
2190
|
+
return utils$1.trim(rawValue);
|
|
2191
|
+
} catch (e) {
|
|
2192
|
+
if (e.name !== 'SyntaxError') {
|
|
2193
|
+
throw e;
|
|
1944
2194
|
}
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
1945
2197
|
|
|
1946
|
-
|
|
2198
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
2199
|
+
}
|
|
1947
2200
|
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
}
|
|
2201
|
+
const defaults = {
|
|
2202
|
+
transitional: transitionalDefaults,
|
|
1951
2203
|
|
|
1952
|
-
|
|
2204
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
1953
2205
|
|
|
1954
|
-
|
|
1955
|
-
|
|
2206
|
+
transformRequest: [
|
|
2207
|
+
function transformRequest(data, headers) {
|
|
2208
|
+
const contentType = headers.getContentType() || '';
|
|
2209
|
+
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
2210
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1956
2211
|
|
|
1957
|
-
|
|
1958
|
-
|
|
2212
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
2213
|
+
data = new FormData(data);
|
|
2214
|
+
}
|
|
1959
2215
|
|
|
1960
|
-
|
|
1961
|
-
return this.constructor.concat(this, ...targets);
|
|
1962
|
-
}
|
|
2216
|
+
const isFormData = utils$1.isFormData(data);
|
|
1963
2217
|
|
|
1964
|
-
|
|
1965
|
-
|
|
2218
|
+
if (isFormData) {
|
|
2219
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
2220
|
+
}
|
|
1966
2221
|
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2222
|
+
if (
|
|
2223
|
+
utils$1.isArrayBuffer(data) ||
|
|
2224
|
+
utils$1.isBuffer(data) ||
|
|
2225
|
+
utils$1.isStream(data) ||
|
|
2226
|
+
utils$1.isFile(data) ||
|
|
2227
|
+
utils$1.isBlob(data) ||
|
|
2228
|
+
utils$1.isReadableStream(data)
|
|
2229
|
+
) {
|
|
2230
|
+
return data;
|
|
2231
|
+
}
|
|
2232
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
2233
|
+
return data.buffer;
|
|
2234
|
+
}
|
|
2235
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
2236
|
+
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
2237
|
+
return data.toString();
|
|
2238
|
+
}
|
|
1970
2239
|
|
|
1971
|
-
|
|
1972
|
-
}
|
|
2240
|
+
let isFileList;
|
|
1973
2241
|
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
2242
|
+
if (isObjectPayload) {
|
|
2243
|
+
const formSerializer = own(this, 'formSerializer');
|
|
2244
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
2245
|
+
return toURLEncodedForm(data, formSerializer).toString();
|
|
2246
|
+
}
|
|
1977
2247
|
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
2248
|
+
if (
|
|
2249
|
+
(isFileList = utils$1.isFileList(data)) ||
|
|
2250
|
+
contentType.indexOf('multipart/form-data') > -1
|
|
2251
|
+
) {
|
|
2252
|
+
const env = own(this, 'env');
|
|
2253
|
+
const _FormData = env && env.FormData;
|
|
2254
|
+
|
|
2255
|
+
return toFormData(
|
|
2256
|
+
isFileList ? { 'files[]': data } : data,
|
|
2257
|
+
_FormData && new _FormData(),
|
|
2258
|
+
formSerializer
|
|
2259
|
+
);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
1981
2262
|
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2263
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
2264
|
+
headers.setContentType('application/json', false);
|
|
2265
|
+
return stringifySafely(data);
|
|
2266
|
+
}
|
|
1985
2267
|
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
2268
|
+
return data;
|
|
2269
|
+
},
|
|
2270
|
+
],
|
|
1989
2271
|
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2272
|
+
transformResponse: [
|
|
2273
|
+
function transformResponse(data) {
|
|
2274
|
+
const transitional = own(this, 'transitional') || defaults.transitional;
|
|
2275
|
+
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
2276
|
+
const responseType = own(this, 'responseType');
|
|
2277
|
+
const JSONRequested = responseType === 'json';
|
|
1993
2278
|
|
|
1994
|
-
|
|
1995
|
-
|
|
2279
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
2280
|
+
return data;
|
|
2281
|
+
}
|
|
1996
2282
|
|
|
1997
|
-
|
|
2283
|
+
if (
|
|
2284
|
+
data &&
|
|
2285
|
+
utils$1.isString(data) &&
|
|
2286
|
+
((forcedJSONParsing && !responseType) || JSONRequested)
|
|
2287
|
+
) {
|
|
2288
|
+
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
2289
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1998
2290
|
|
|
1999
|
-
|
|
2000
|
-
|
|
2291
|
+
try {
|
|
2292
|
+
return JSON.parse(data, own(this, 'parseReviver'));
|
|
2293
|
+
} catch (e) {
|
|
2294
|
+
if (strictJSONParsing) {
|
|
2295
|
+
if (e.name === 'SyntaxError') {
|
|
2296
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|
2297
|
+
}
|
|
2298
|
+
throw e;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2001
2302
|
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
});
|
|
2303
|
+
return data;
|
|
2304
|
+
},
|
|
2305
|
+
],
|
|
2006
2306
|
|
|
2007
|
-
|
|
2008
|
-
|
|
2307
|
+
/**
|
|
2308
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
2309
|
+
* timeout is not created.
|
|
2310
|
+
*/
|
|
2311
|
+
timeout: 0,
|
|
2009
2312
|
|
|
2010
|
-
|
|
2011
|
-
|
|
2313
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
2314
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
2012
2315
|
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
accessors[lHeader] = true;
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2316
|
+
maxContentLength: -1,
|
|
2317
|
+
maxBodyLength: -1,
|
|
2018
2318
|
|
|
2019
|
-
|
|
2319
|
+
env: {
|
|
2320
|
+
FormData: platform.classes.FormData,
|
|
2321
|
+
Blob: platform.classes.Blob,
|
|
2322
|
+
},
|
|
2020
2323
|
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
}
|
|
2324
|
+
validateStatus: function validateStatus(status) {
|
|
2325
|
+
return status >= 200 && status < 300;
|
|
2326
|
+
},
|
|
2024
2327
|
|
|
2025
|
-
|
|
2328
|
+
headers: {
|
|
2329
|
+
common: {
|
|
2330
|
+
Accept: 'application/json, text/plain, */*',
|
|
2331
|
+
'Content-Type': undefined,
|
|
2332
|
+
},
|
|
2333
|
+
},
|
|
2334
|
+
};
|
|
2026
2335
|
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2030
|
-
return {
|
|
2031
|
-
get: () => value,
|
|
2032
|
-
set(headerValue) {
|
|
2033
|
-
this[mapped] = headerValue;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2336
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], (method) => {
|
|
2337
|
+
defaults.headers[method] = {};
|
|
2036
2338
|
});
|
|
2037
2339
|
|
|
2038
|
-
utils$1.freezeMethods(AxiosHeaders);
|
|
2039
|
-
|
|
2040
2340
|
/**
|
|
2041
2341
|
* Transform the data for a request or a response
|
|
2042
2342
|
*
|
|
@@ -2097,7 +2397,7 @@ function settle(resolve, reject, response) {
|
|
|
2097
2397
|
} else {
|
|
2098
2398
|
reject(new AxiosError(
|
|
2099
2399
|
'Request failed with status code ' + response.status,
|
|
2100
|
-
|
|
2400
|
+
response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE,
|
|
2101
2401
|
response.config,
|
|
2102
2402
|
response.request,
|
|
2103
2403
|
response
|
|
@@ -2106,8 +2406,8 @@ function settle(resolve, reject, response) {
|
|
|
2106
2406
|
}
|
|
2107
2407
|
|
|
2108
2408
|
function parseProtocol(url) {
|
|
2109
|
-
const match = /^([-+\w]{1,25})(
|
|
2110
|
-
return match && match[1] || '';
|
|
2409
|
+
const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|
2410
|
+
return (match && match[1]) || '';
|
|
2111
2411
|
}
|
|
2112
2412
|
|
|
2113
2413
|
/**
|
|
@@ -2158,7 +2458,7 @@ function speedometer(samplesCount, min) {
|
|
|
2158
2458
|
|
|
2159
2459
|
const passed = startedAt && now - startedAt;
|
|
2160
2460
|
|
|
2161
|
-
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|
2461
|
+
return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
|
|
2162
2462
|
};
|
|
2163
2463
|
}
|
|
2164
2464
|
|
|
@@ -2187,7 +2487,7 @@ function throttle(fn, freq) {
|
|
|
2187
2487
|
const throttled = (...args) => {
|
|
2188
2488
|
const now = Date.now();
|
|
2189
2489
|
const passed = now - timestamp;
|
|
2190
|
-
if (
|
|
2490
|
+
if (passed >= threshold) {
|
|
2191
2491
|
invoke(args, now);
|
|
2192
2492
|
} else {
|
|
2193
2493
|
lastArgs = args;
|
|
@@ -2209,25 +2509,25 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2209
2509
|
let bytesNotified = 0;
|
|
2210
2510
|
const _speedometer = speedometer(50, 250);
|
|
2211
2511
|
|
|
2212
|
-
return throttle(e => {
|
|
2213
|
-
const
|
|
2512
|
+
return throttle((e) => {
|
|
2513
|
+
const rawLoaded = e.loaded;
|
|
2214
2514
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2215
|
-
const
|
|
2515
|
+
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
2516
|
+
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
2216
2517
|
const rate = _speedometer(progressBytes);
|
|
2217
|
-
const inRange = loaded <= total;
|
|
2218
2518
|
|
|
2219
|
-
bytesNotified = loaded;
|
|
2519
|
+
bytesNotified = Math.max(bytesNotified, loaded);
|
|
2220
2520
|
|
|
2221
2521
|
const data = {
|
|
2222
2522
|
loaded,
|
|
2223
2523
|
total,
|
|
2224
|
-
progress: total ?
|
|
2524
|
+
progress: total ? loaded / total : undefined,
|
|
2225
2525
|
bytes: progressBytes,
|
|
2226
2526
|
rate: rate ? rate : undefined,
|
|
2227
|
-
estimated: rate && total
|
|
2527
|
+
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
2228
2528
|
event: e,
|
|
2229
2529
|
lengthComputable: total != null,
|
|
2230
|
-
[isDownloadStream ? 'download' : 'upload']: true
|
|
2530
|
+
[isDownloadStream ? 'download' : 'upload']: true,
|
|
2231
2531
|
};
|
|
2232
2532
|
|
|
2233
2533
|
listener(data);
|
|
@@ -2237,77 +2537,94 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2237
2537
|
const progressEventDecorator = (total, throttled) => {
|
|
2238
2538
|
const lengthComputable = total != null;
|
|
2239
2539
|
|
|
2240
|
-
return [
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2540
|
+
return [
|
|
2541
|
+
(loaded) =>
|
|
2542
|
+
throttled[0]({
|
|
2543
|
+
lengthComputable,
|
|
2544
|
+
total,
|
|
2545
|
+
loaded,
|
|
2546
|
+
}),
|
|
2547
|
+
throttled[1],
|
|
2548
|
+
];
|
|
2245
2549
|
};
|
|
2246
2550
|
|
|
2247
|
-
const asyncDecorator =
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
return (
|
|
2253
|
-
origin.protocol === url.protocol &&
|
|
2254
|
-
origin.host === url.host &&
|
|
2255
|
-
(isMSIE || origin.port === url.port)
|
|
2256
|
-
);
|
|
2257
|
-
})(
|
|
2258
|
-
new URL(platform.origin),
|
|
2259
|
-
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2260
|
-
) : () => true;
|
|
2261
|
-
|
|
2262
|
-
const cookies = platform.hasStandardBrowserEnv ?
|
|
2263
|
-
|
|
2264
|
-
// Standard browser envs support document.cookie
|
|
2265
|
-
{
|
|
2266
|
-
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2267
|
-
if (typeof document === 'undefined') return;
|
|
2551
|
+
const asyncDecorator =
|
|
2552
|
+
(fn) =>
|
|
2553
|
+
(...args) =>
|
|
2554
|
+
utils$1.asap(() => fn(...args));
|
|
2268
2555
|
|
|
2269
|
-
|
|
2556
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv
|
|
2557
|
+
? ((origin, isMSIE) => (url) => {
|
|
2558
|
+
url = new URL(url, platform.origin);
|
|
2270
2559
|
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2560
|
+
return (
|
|
2561
|
+
origin.protocol === url.protocol &&
|
|
2562
|
+
origin.host === url.host &&
|
|
2563
|
+
(isMSIE || origin.port === url.port)
|
|
2564
|
+
);
|
|
2565
|
+
})(
|
|
2566
|
+
new URL(platform.origin),
|
|
2567
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
2568
|
+
)
|
|
2569
|
+
: () => true;
|
|
2570
|
+
|
|
2571
|
+
const cookies = platform.hasStandardBrowserEnv
|
|
2572
|
+
? // Standard browser envs support document.cookie
|
|
2573
|
+
{
|
|
2574
|
+
write(name, value, expires, path, domain, secure, sameSite) {
|
|
2575
|
+
if (typeof document === 'undefined') return;
|
|
2576
|
+
|
|
2577
|
+
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
2578
|
+
|
|
2579
|
+
if (utils$1.isNumber(expires)) {
|
|
2580
|
+
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
2581
|
+
}
|
|
2582
|
+
if (utils$1.isString(path)) {
|
|
2583
|
+
cookie.push(`path=${path}`);
|
|
2584
|
+
}
|
|
2585
|
+
if (utils$1.isString(domain)) {
|
|
2586
|
+
cookie.push(`domain=${domain}`);
|
|
2587
|
+
}
|
|
2588
|
+
if (secure === true) {
|
|
2589
|
+
cookie.push('secure');
|
|
2590
|
+
}
|
|
2591
|
+
if (utils$1.isString(sameSite)) {
|
|
2592
|
+
cookie.push(`SameSite=${sameSite}`);
|
|
2593
|
+
}
|
|
2286
2594
|
|
|
2287
|
-
|
|
2288
|
-
|
|
2595
|
+
document.cookie = cookie.join('; ');
|
|
2596
|
+
},
|
|
2289
2597
|
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2598
|
+
read(name) {
|
|
2599
|
+
if (typeof document === 'undefined') return null;
|
|
2600
|
+
// Match name=value by splitting on the semicolon separator instead of building a
|
|
2601
|
+
// RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|
2602
|
+
// metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|
2603
|
+
// match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|
2604
|
+
// "; ", so ignore optional whitespace before each cookie name.
|
|
2605
|
+
const cookies = document.cookie.split(';');
|
|
2606
|
+
for (let i = 0; i < cookies.length; i++) {
|
|
2607
|
+
const cookie = cookies[i].replace(/^\s+/, '');
|
|
2608
|
+
const eq = cookie.indexOf('=');
|
|
2609
|
+
if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|
2610
|
+
return decodeURIComponent(cookie.slice(eq + 1));
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
return null;
|
|
2614
|
+
},
|
|
2295
2615
|
|
|
2296
|
-
|
|
2297
|
-
|
|
2616
|
+
remove(name) {
|
|
2617
|
+
this.write(name, '', Date.now() - 86400000, '/');
|
|
2618
|
+
},
|
|
2298
2619
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
return null;
|
|
2308
|
-
},
|
|
2309
|
-
remove() {}
|
|
2310
|
-
};
|
|
2620
|
+
: // Non-standard browser env (web workers, react-native) lack needed support.
|
|
2621
|
+
{
|
|
2622
|
+
write() {},
|
|
2623
|
+
read() {
|
|
2624
|
+
return null;
|
|
2625
|
+
},
|
|
2626
|
+
remove() {},
|
|
2627
|
+
};
|
|
2311
2628
|
|
|
2312
2629
|
/**
|
|
2313
2630
|
* Determines whether the specified URL is absolute
|
|
@@ -2353,14 +2670,13 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
2353
2670
|
*/
|
|
2354
2671
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
2355
2672
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
2356
|
-
if (baseURL && (isRelativeUrl || allowAbsoluteUrls
|
|
2673
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|
2357
2674
|
return combineURLs(baseURL, requestedURL);
|
|
2358
2675
|
}
|
|
2359
2676
|
return requestedURL;
|
|
2360
2677
|
}
|
|
2361
2678
|
|
|
2362
|
-
const headersToObject = (thing) =>
|
|
2363
|
-
thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
2679
|
+
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
|
2364
2680
|
|
|
2365
2681
|
/**
|
|
2366
2682
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2374,7 +2690,21 @@ const headersToObject = (thing) =>
|
|
|
2374
2690
|
function mergeConfig(config1, config2) {
|
|
2375
2691
|
// eslint-disable-next-line no-param-reassign
|
|
2376
2692
|
config2 = config2 || {};
|
|
2377
|
-
|
|
2693
|
+
|
|
2694
|
+
// Use a null-prototype object so that downstream reads such as `config.auth`
|
|
2695
|
+
// or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|
2696
|
+
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
2697
|
+
// ergonomics for user code that relies on it.
|
|
2698
|
+
const config = Object.create(null);
|
|
2699
|
+
Object.defineProperty(config, 'hasOwnProperty', {
|
|
2700
|
+
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
2701
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
2702
|
+
__proto__: null,
|
|
2703
|
+
value: Object.prototype.hasOwnProperty,
|
|
2704
|
+
enumerable: false,
|
|
2705
|
+
writable: true,
|
|
2706
|
+
configurable: true,
|
|
2707
|
+
});
|
|
2378
2708
|
|
|
2379
2709
|
function getMergedValue(target, source, prop, caseless) {
|
|
2380
2710
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
@@ -2413,9 +2743,9 @@ function mergeConfig(config1, config2) {
|
|
|
2413
2743
|
|
|
2414
2744
|
// eslint-disable-next-line consistent-return
|
|
2415
2745
|
function mergeDirectKeys(a, b, prop) {
|
|
2416
|
-
if (prop
|
|
2746
|
+
if (utils$1.hasOwnProp(config2, prop)) {
|
|
2417
2747
|
return getMergedValue(a, b);
|
|
2418
|
-
} else if (prop
|
|
2748
|
+
} else if (utils$1.hasOwnProp(config1, prop)) {
|
|
2419
2749
|
return getMergedValue(undefined, a);
|
|
2420
2750
|
}
|
|
2421
2751
|
}
|
|
@@ -2447,46 +2777,84 @@ function mergeConfig(config1, config2) {
|
|
|
2447
2777
|
httpsAgent: defaultToConfig2,
|
|
2448
2778
|
cancelToken: defaultToConfig2,
|
|
2449
2779
|
socketPath: defaultToConfig2,
|
|
2780
|
+
allowedSocketPaths: defaultToConfig2,
|
|
2450
2781
|
responseEncoding: defaultToConfig2,
|
|
2451
2782
|
validateStatus: mergeDirectKeys,
|
|
2452
2783
|
headers: (a, b, prop) =>
|
|
2453
2784
|
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
2454
2785
|
};
|
|
2455
2786
|
|
|
2456
|
-
utils$1.forEach(
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
return;
|
|
2465
|
-
const merge = utils$1.hasOwnProp(mergeMap, prop)
|
|
2466
|
-
? mergeMap[prop]
|
|
2467
|
-
: mergeDeepProperties;
|
|
2468
|
-
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2469
|
-
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) ||
|
|
2470
|
-
(config[prop] = configValue);
|
|
2471
|
-
},
|
|
2472
|
-
);
|
|
2787
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
2788
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
2789
|
+
const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
2790
|
+
const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
2791
|
+
const b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
2792
|
+
const configValue = merge(a, b, prop);
|
|
2793
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2794
|
+
});
|
|
2473
2795
|
|
|
2474
2796
|
return config;
|
|
2475
2797
|
}
|
|
2476
2798
|
|
|
2799
|
+
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
2800
|
+
|
|
2801
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
2802
|
+
if (policy !== 'content-only') {
|
|
2803
|
+
headers.set(formHeaders);
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2808
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
2809
|
+
headers.set(key, val);
|
|
2810
|
+
}
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
2816
|
+
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
2817
|
+
*
|
|
2818
|
+
* @param {string} str The string to encode
|
|
2819
|
+
*
|
|
2820
|
+
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
2821
|
+
*/
|
|
2822
|
+
const encodeUTF8 = (str) =>
|
|
2823
|
+
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
2824
|
+
String.fromCharCode(parseInt(hex, 16))
|
|
2825
|
+
);
|
|
2826
|
+
|
|
2477
2827
|
const resolveConfig = (config) => {
|
|
2478
2828
|
const newConfig = mergeConfig({}, config);
|
|
2479
2829
|
|
|
2480
|
-
|
|
2830
|
+
// Read only own properties to prevent prototype pollution gadgets
|
|
2831
|
+
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
2832
|
+
const own = (key) => (utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
2833
|
+
|
|
2834
|
+
const data = own('data');
|
|
2835
|
+
let withXSRFToken = own('withXSRFToken');
|
|
2836
|
+
const xsrfHeaderName = own('xsrfHeaderName');
|
|
2837
|
+
const xsrfCookieName = own('xsrfCookieName');
|
|
2838
|
+
let headers = own('headers');
|
|
2839
|
+
const auth = own('auth');
|
|
2840
|
+
const baseURL = own('baseURL');
|
|
2841
|
+
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
2842
|
+
const url = own('url');
|
|
2481
2843
|
|
|
2482
2844
|
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
2483
2845
|
|
|
2484
|
-
newConfig.url = buildURL(
|
|
2846
|
+
newConfig.url = buildURL(
|
|
2847
|
+
buildFullPath(baseURL, url, allowAbsoluteUrls),
|
|
2848
|
+
config.params,
|
|
2849
|
+
config.paramsSerializer
|
|
2850
|
+
);
|
|
2485
2851
|
|
|
2486
2852
|
// HTTP basic authentication
|
|
2487
2853
|
if (auth) {
|
|
2488
|
-
headers.set(
|
|
2489
|
-
|
|
2854
|
+
headers.set(
|
|
2855
|
+
'Authorization',
|
|
2856
|
+
'Basic ' +
|
|
2857
|
+
btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : ''))
|
|
2490
2858
|
);
|
|
2491
2859
|
}
|
|
2492
2860
|
|
|
@@ -2495,26 +2863,26 @@ const resolveConfig = (config) => {
|
|
|
2495
2863
|
headers.setContentType(undefined); // browser handles it
|
|
2496
2864
|
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
2497
2865
|
// Node.js FormData (like form-data package)
|
|
2498
|
-
|
|
2499
|
-
// Only set safe headers to avoid overwriting security headers
|
|
2500
|
-
const allowedHeaders = ['content-type', 'content-length'];
|
|
2501
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
2502
|
-
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
2503
|
-
headers.set(key, val);
|
|
2504
|
-
}
|
|
2505
|
-
});
|
|
2866
|
+
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
2506
2867
|
}
|
|
2507
|
-
}
|
|
2868
|
+
}
|
|
2508
2869
|
|
|
2509
2870
|
// Add xsrf header
|
|
2510
2871
|
// This is only done if running in a standard browser environment.
|
|
2511
2872
|
// Specifically not if we're in a web worker, or react-native.
|
|
2512
2873
|
|
|
2513
2874
|
if (platform.hasStandardBrowserEnv) {
|
|
2514
|
-
|
|
2875
|
+
if (utils$1.isFunction(withXSRFToken)) {
|
|
2876
|
+
withXSRFToken = withXSRFToken(newConfig);
|
|
2877
|
+
}
|
|
2515
2878
|
|
|
2516
|
-
|
|
2517
|
-
|
|
2879
|
+
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
2880
|
+
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
2881
|
+
// the XSRF token cross-origin.
|
|
2882
|
+
const shouldSendXSRF =
|
|
2883
|
+
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
2884
|
+
|
|
2885
|
+
if (shouldSendXSRF) {
|
|
2518
2886
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
2519
2887
|
|
|
2520
2888
|
if (xsrfValue) {
|
|
@@ -2528,196 +2896,222 @@ const resolveConfig = (config) => {
|
|
|
2528
2896
|
|
|
2529
2897
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|
2530
2898
|
|
|
2531
|
-
const xhrAdapter = isXHRAdapterSupported &&
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2899
|
+
const xhrAdapter = isXHRAdapterSupported &&
|
|
2900
|
+
function (config) {
|
|
2901
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2902
|
+
const _config = resolveConfig(config);
|
|
2903
|
+
let requestData = _config.data;
|
|
2904
|
+
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
2905
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
2906
|
+
let onCanceled;
|
|
2907
|
+
let uploadThrottled, downloadThrottled;
|
|
2908
|
+
let flushUpload, flushDownload;
|
|
2909
|
+
|
|
2910
|
+
function done() {
|
|
2911
|
+
flushUpload && flushUpload(); // flush events
|
|
2912
|
+
flushDownload && flushDownload(); // flush events
|
|
2913
|
+
|
|
2914
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
2915
|
+
|
|
2916
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
let request = new XMLHttpRequest();
|
|
2920
|
+
|
|
2921
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
2922
|
+
|
|
2923
|
+
// Set the request timeout in MS
|
|
2924
|
+
request.timeout = _config.timeout;
|
|
2925
|
+
|
|
2926
|
+
function onloadend() {
|
|
2927
|
+
if (!request) {
|
|
2928
|
+
return;
|
|
2929
|
+
}
|
|
2930
|
+
// Prepare the response
|
|
2931
|
+
const responseHeaders = AxiosHeaders.from(
|
|
2932
|
+
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2933
|
+
);
|
|
2934
|
+
const responseData =
|
|
2935
|
+
!responseType || responseType === 'text' || responseType === 'json'
|
|
2936
|
+
? request.responseText
|
|
2937
|
+
: request.response;
|
|
2938
|
+
const response = {
|
|
2939
|
+
data: responseData,
|
|
2940
|
+
status: request.status,
|
|
2941
|
+
statusText: request.statusText,
|
|
2942
|
+
headers: responseHeaders,
|
|
2943
|
+
config,
|
|
2944
|
+
request,
|
|
2945
|
+
};
|
|
2540
2946
|
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2947
|
+
settle(
|
|
2948
|
+
function _resolve(value) {
|
|
2949
|
+
resolve(value);
|
|
2950
|
+
done();
|
|
2951
|
+
},
|
|
2952
|
+
function _reject(err) {
|
|
2953
|
+
reject(err);
|
|
2954
|
+
done();
|
|
2955
|
+
},
|
|
2956
|
+
response
|
|
2957
|
+
);
|
|
2544
2958
|
|
|
2545
|
-
|
|
2959
|
+
// Clean up request
|
|
2960
|
+
request = null;
|
|
2961
|
+
}
|
|
2546
2962
|
|
|
2547
|
-
|
|
2548
|
-
|
|
2963
|
+
if ('onloadend' in request) {
|
|
2964
|
+
// Use onloadend if available
|
|
2965
|
+
request.onloadend = onloadend;
|
|
2966
|
+
} else {
|
|
2967
|
+
// Listen for ready state to emulate onloadend
|
|
2968
|
+
request.onreadystatechange = function handleLoad() {
|
|
2969
|
+
if (!request || request.readyState !== 4) {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2549
2972
|
|
|
2550
|
-
|
|
2973
|
+
// The request errored out and we didn't get a response, this will be
|
|
2974
|
+
// handled by onerror instead
|
|
2975
|
+
// With one exception: request that using file: protocol, most browsers
|
|
2976
|
+
// will return status as 0 even though it's a successful request
|
|
2977
|
+
if (
|
|
2978
|
+
request.status === 0 &&
|
|
2979
|
+
!(request.responseURL && request.responseURL.startsWith('file:'))
|
|
2980
|
+
) {
|
|
2981
|
+
return;
|
|
2982
|
+
}
|
|
2983
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2984
|
+
// so we should call onloadend on the next 'tick'
|
|
2985
|
+
setTimeout(onloadend);
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2551
2988
|
|
|
2552
|
-
|
|
2989
|
+
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2990
|
+
request.onabort = function handleAbort() {
|
|
2991
|
+
if (!request) {
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2553
2994
|
|
|
2554
|
-
|
|
2555
|
-
|
|
2995
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
2996
|
+
done();
|
|
2556
2997
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
return;
|
|
2560
|
-
}
|
|
2561
|
-
// Prepare the response
|
|
2562
|
-
const responseHeaders = AxiosHeaders.from(
|
|
2563
|
-
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2564
|
-
);
|
|
2565
|
-
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
2566
|
-
request.responseText : request.response;
|
|
2567
|
-
const response = {
|
|
2568
|
-
data: responseData,
|
|
2569
|
-
status: request.status,
|
|
2570
|
-
statusText: request.statusText,
|
|
2571
|
-
headers: responseHeaders,
|
|
2572
|
-
config,
|
|
2573
|
-
request
|
|
2998
|
+
// Clean up request
|
|
2999
|
+
request = null;
|
|
2574
3000
|
};
|
|
2575
3001
|
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
3002
|
+
// Handle low level network errors
|
|
3003
|
+
request.onerror = function handleError(event) {
|
|
3004
|
+
// Browsers deliver a ProgressEvent in XHR onerror
|
|
3005
|
+
// (message may be empty; when present, surface it)
|
|
3006
|
+
// See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|
3007
|
+
const msg = event && event.message ? event.message : 'Network Error';
|
|
3008
|
+
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
3009
|
+
// attach the underlying event for consumers who want details
|
|
3010
|
+
err.event = event || null;
|
|
2580
3011
|
reject(err);
|
|
2581
3012
|
done();
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
// Clean up request
|
|
2585
|
-
request = null;
|
|
2586
|
-
}
|
|
3013
|
+
request = null;
|
|
3014
|
+
};
|
|
2587
3015
|
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
if (
|
|
2595
|
-
|
|
3016
|
+
// Handle timeout
|
|
3017
|
+
request.ontimeout = function handleTimeout() {
|
|
3018
|
+
let timeoutErrorMessage = _config.timeout
|
|
3019
|
+
? 'timeout of ' + _config.timeout + 'ms exceeded'
|
|
3020
|
+
: 'timeout exceeded';
|
|
3021
|
+
const transitional = _config.transitional || transitionalDefaults;
|
|
3022
|
+
if (_config.timeoutErrorMessage) {
|
|
3023
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
2596
3024
|
}
|
|
3025
|
+
reject(
|
|
3026
|
+
new AxiosError(
|
|
3027
|
+
timeoutErrorMessage,
|
|
3028
|
+
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
3029
|
+
config,
|
|
3030
|
+
request
|
|
3031
|
+
)
|
|
3032
|
+
);
|
|
3033
|
+
done();
|
|
2597
3034
|
|
|
2598
|
-
//
|
|
2599
|
-
|
|
2600
|
-
// With one exception: request that using file: protocol, most browsers
|
|
2601
|
-
// will return status as 0 even though it's a successful request
|
|
2602
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
|
2603
|
-
return;
|
|
2604
|
-
}
|
|
2605
|
-
// readystate handler is calling before onerror or ontimeout handlers,
|
|
2606
|
-
// so we should call onloadend on the next 'tick'
|
|
2607
|
-
setTimeout(onloadend);
|
|
3035
|
+
// Clean up request
|
|
3036
|
+
request = null;
|
|
2608
3037
|
};
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
2612
|
-
request.onabort = function handleAbort() {
|
|
2613
|
-
if (!request) {
|
|
2614
|
-
return;
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
2618
3038
|
|
|
2619
|
-
//
|
|
2620
|
-
|
|
2621
|
-
};
|
|
3039
|
+
// Remove Content-Type if data is undefined
|
|
3040
|
+
requestData === undefined && requestHeaders.setContentType(null);
|
|
2622
3041
|
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
const msg = event && event.message ? event.message : 'Network Error';
|
|
2629
|
-
const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|
2630
|
-
// attach the underlying event for consumers who want details
|
|
2631
|
-
err.event = event || null;
|
|
2632
|
-
reject(err);
|
|
2633
|
-
request = null;
|
|
2634
|
-
};
|
|
2635
|
-
|
|
2636
|
-
// Handle timeout
|
|
2637
|
-
request.ontimeout = function handleTimeout() {
|
|
2638
|
-
let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|
2639
|
-
const transitional = _config.transitional || transitionalDefaults;
|
|
2640
|
-
if (_config.timeoutErrorMessage) {
|
|
2641
|
-
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
3042
|
+
// Add headers to the request
|
|
3043
|
+
if ('setRequestHeader' in request) {
|
|
3044
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
3045
|
+
request.setRequestHeader(key, val);
|
|
3046
|
+
});
|
|
2642
3047
|
}
|
|
2643
|
-
reject(new AxiosError(
|
|
2644
|
-
timeoutErrorMessage,
|
|
2645
|
-
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
2646
|
-
config,
|
|
2647
|
-
request));
|
|
2648
|
-
|
|
2649
|
-
// Clean up request
|
|
2650
|
-
request = null;
|
|
2651
|
-
};
|
|
2652
3048
|
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
if ('setRequestHeader' in request) {
|
|
2658
|
-
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2659
|
-
request.setRequestHeader(key, val);
|
|
2660
|
-
});
|
|
2661
|
-
}
|
|
3049
|
+
// Add withCredentials to request if needed
|
|
3050
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
3051
|
+
request.withCredentials = !!_config.withCredentials;
|
|
3052
|
+
}
|
|
2662
3053
|
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
3054
|
+
// Add responseType to request if needed
|
|
3055
|
+
if (responseType && responseType !== 'json') {
|
|
3056
|
+
request.responseType = _config.responseType;
|
|
3057
|
+
}
|
|
2667
3058
|
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
3059
|
+
// Handle progress if needed
|
|
3060
|
+
if (onDownloadProgress) {
|
|
3061
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
3062
|
+
request.addEventListener('progress', downloadThrottled);
|
|
3063
|
+
}
|
|
2672
3064
|
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
request.addEventListener('progress', downloadThrottled);
|
|
2677
|
-
}
|
|
3065
|
+
// Not all browsers support upload events
|
|
3066
|
+
if (onUploadProgress && request.upload) {
|
|
3067
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
2678
3068
|
|
|
2679
|
-
|
|
2680
|
-
if (onUploadProgress && request.upload) {
|
|
2681
|
-
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
3069
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
2682
3070
|
|
|
2683
|
-
|
|
3071
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
3072
|
+
}
|
|
2684
3073
|
|
|
2685
|
-
|
|
2686
|
-
|
|
3074
|
+
if (_config.cancelToken || _config.signal) {
|
|
3075
|
+
// Handle cancellation
|
|
3076
|
+
// eslint-disable-next-line func-names
|
|
3077
|
+
onCanceled = (cancel) => {
|
|
3078
|
+
if (!request) {
|
|
3079
|
+
return;
|
|
3080
|
+
}
|
|
3081
|
+
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
3082
|
+
request.abort();
|
|
3083
|
+
done();
|
|
3084
|
+
request = null;
|
|
3085
|
+
};
|
|
2687
3086
|
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
return;
|
|
3087
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
3088
|
+
if (_config.signal) {
|
|
3089
|
+
_config.signal.aborted
|
|
3090
|
+
? onCanceled()
|
|
3091
|
+
: _config.signal.addEventListener('abort', onCanceled);
|
|
2694
3092
|
}
|
|
2695
|
-
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|
2696
|
-
request.abort();
|
|
2697
|
-
request = null;
|
|
2698
|
-
};
|
|
2699
|
-
|
|
2700
|
-
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
2701
|
-
if (_config.signal) {
|
|
2702
|
-
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|
2703
3093
|
}
|
|
2704
|
-
}
|
|
2705
3094
|
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
2709
|
-
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
2710
|
-
return;
|
|
2711
|
-
}
|
|
3095
|
+
const protocol = parseProtocol(_config.url);
|
|
2712
3096
|
|
|
3097
|
+
if (protocol && !platform.protocols.includes(protocol)) {
|
|
3098
|
+
reject(
|
|
3099
|
+
new AxiosError(
|
|
3100
|
+
'Unsupported protocol ' + protocol + ':',
|
|
3101
|
+
AxiosError.ERR_BAD_REQUEST,
|
|
3102
|
+
config
|
|
3103
|
+
)
|
|
3104
|
+
);
|
|
3105
|
+
return;
|
|
3106
|
+
}
|
|
2713
3107
|
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
};
|
|
3108
|
+
// Send the request
|
|
3109
|
+
request.send(requestData || null);
|
|
3110
|
+
});
|
|
3111
|
+
};
|
|
2718
3112
|
|
|
2719
3113
|
const composeSignals = (signals, timeout) => {
|
|
2720
|
-
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
3114
|
+
const { length } = (signals = signals ? signals.filter(Boolean) : []);
|
|
2721
3115
|
|
|
2722
3116
|
if (timeout || length) {
|
|
2723
3117
|
let controller = new AbortController();
|
|
@@ -2729,21 +3123,29 @@ const composeSignals = (signals, timeout) => {
|
|
|
2729
3123
|
aborted = true;
|
|
2730
3124
|
unsubscribe();
|
|
2731
3125
|
const err = reason instanceof Error ? reason : this.reason;
|
|
2732
|
-
controller.abort(
|
|
3126
|
+
controller.abort(
|
|
3127
|
+
err instanceof AxiosError
|
|
3128
|
+
? err
|
|
3129
|
+
: new CanceledError(err instanceof Error ? err.message : err)
|
|
3130
|
+
);
|
|
2733
3131
|
}
|
|
2734
3132
|
};
|
|
2735
3133
|
|
|
2736
|
-
let timer =
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
3134
|
+
let timer =
|
|
3135
|
+
timeout &&
|
|
3136
|
+
setTimeout(() => {
|
|
3137
|
+
timer = null;
|
|
3138
|
+
onabort(new AxiosError(`timeout of ${timeout}ms exceeded`, AxiosError.ETIMEDOUT));
|
|
3139
|
+
}, timeout);
|
|
2740
3140
|
|
|
2741
3141
|
const unsubscribe = () => {
|
|
2742
3142
|
if (signals) {
|
|
2743
3143
|
timer && clearTimeout(timer);
|
|
2744
3144
|
timer = null;
|
|
2745
|
-
signals.forEach(signal => {
|
|
2746
|
-
signal.unsubscribe
|
|
3145
|
+
signals.forEach((signal) => {
|
|
3146
|
+
signal.unsubscribe
|
|
3147
|
+
? signal.unsubscribe(onabort)
|
|
3148
|
+
: signal.removeEventListener('abort', onabort);
|
|
2747
3149
|
});
|
|
2748
3150
|
signals = null;
|
|
2749
3151
|
}
|
|
@@ -2751,7 +3153,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2751
3153
|
|
|
2752
3154
|
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
2753
3155
|
|
|
2754
|
-
const {signal} = controller;
|
|
3156
|
+
const { signal } = controller;
|
|
2755
3157
|
|
|
2756
3158
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2757
3159
|
|
|
@@ -2792,7 +3194,7 @@ const readStream = async function* (stream) {
|
|
|
2792
3194
|
const reader = stream.getReader();
|
|
2793
3195
|
try {
|
|
2794
3196
|
for (;;) {
|
|
2795
|
-
const {done, value} = await reader.read();
|
|
3197
|
+
const { done, value } = await reader.read();
|
|
2796
3198
|
if (done) {
|
|
2797
3199
|
break;
|
|
2798
3200
|
}
|
|
@@ -2815,64 +3217,171 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
|
2815
3217
|
}
|
|
2816
3218
|
};
|
|
2817
3219
|
|
|
2818
|
-
return new ReadableStream(
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
3220
|
+
return new ReadableStream(
|
|
3221
|
+
{
|
|
3222
|
+
async pull(controller) {
|
|
3223
|
+
try {
|
|
3224
|
+
const { done, value } = await iterator.next();
|
|
2822
3225
|
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
3226
|
+
if (done) {
|
|
3227
|
+
_onFinish();
|
|
3228
|
+
controller.close();
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
2828
3231
|
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
3232
|
+
let len = value.byteLength;
|
|
3233
|
+
if (onProgress) {
|
|
3234
|
+
let loadedBytes = (bytes += len);
|
|
3235
|
+
onProgress(loadedBytes);
|
|
3236
|
+
}
|
|
3237
|
+
controller.enqueue(new Uint8Array(value));
|
|
3238
|
+
} catch (err) {
|
|
3239
|
+
_onFinish(err);
|
|
3240
|
+
throw err;
|
|
2833
3241
|
}
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
_onFinish(
|
|
2837
|
-
|
|
2838
|
-
}
|
|
3242
|
+
},
|
|
3243
|
+
cancel(reason) {
|
|
3244
|
+
_onFinish(reason);
|
|
3245
|
+
return iterator.return();
|
|
3246
|
+
},
|
|
2839
3247
|
},
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
return iterator.return();
|
|
3248
|
+
{
|
|
3249
|
+
highWaterMark: 2,
|
|
2843
3250
|
}
|
|
2844
|
-
|
|
2845
|
-
highWaterMark: 2
|
|
2846
|
-
})
|
|
3251
|
+
);
|
|
2847
3252
|
};
|
|
2848
3253
|
|
|
2849
|
-
|
|
3254
|
+
/**
|
|
3255
|
+
* Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|
3256
|
+
* - For base64: compute exact decoded size using length and padding;
|
|
3257
|
+
* handle %XX at the character-count level (no string allocation).
|
|
3258
|
+
* - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|
3259
|
+
*
|
|
3260
|
+
* @param {string} url
|
|
3261
|
+
* @returns {number}
|
|
3262
|
+
*/
|
|
3263
|
+
function estimateDataURLDecodedBytes(url) {
|
|
3264
|
+
if (!url || typeof url !== 'string') return 0;
|
|
3265
|
+
if (!url.startsWith('data:')) return 0;
|
|
3266
|
+
|
|
3267
|
+
const comma = url.indexOf(',');
|
|
3268
|
+
if (comma < 0) return 0;
|
|
3269
|
+
|
|
3270
|
+
const meta = url.slice(5, comma);
|
|
3271
|
+
const body = url.slice(comma + 1);
|
|
3272
|
+
const isBase64 = /;base64/i.test(meta);
|
|
3273
|
+
|
|
3274
|
+
if (isBase64) {
|
|
3275
|
+
let effectiveLen = body.length;
|
|
3276
|
+
const len = body.length; // cache length
|
|
3277
|
+
|
|
3278
|
+
for (let i = 0; i < len; i++) {
|
|
3279
|
+
if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|
3280
|
+
const a = body.charCodeAt(i + 1);
|
|
3281
|
+
const b = body.charCodeAt(i + 2);
|
|
3282
|
+
const isHex =
|
|
3283
|
+
((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) &&
|
|
3284
|
+
((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102));
|
|
3285
|
+
|
|
3286
|
+
if (isHex) {
|
|
3287
|
+
effectiveLen -= 2;
|
|
3288
|
+
i += 2;
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
let pad = 0;
|
|
3294
|
+
let idx = len - 1;
|
|
3295
|
+
|
|
3296
|
+
const tailIsPct3D = (j) =>
|
|
3297
|
+
j >= 2 &&
|
|
3298
|
+
body.charCodeAt(j - 2) === 37 && // '%'
|
|
3299
|
+
body.charCodeAt(j - 1) === 51 && // '3'
|
|
3300
|
+
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
|
|
3301
|
+
|
|
3302
|
+
if (idx >= 0) {
|
|
3303
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3304
|
+
pad++;
|
|
3305
|
+
idx--;
|
|
3306
|
+
} else if (tailIsPct3D(idx)) {
|
|
3307
|
+
pad++;
|
|
3308
|
+
idx -= 3;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3312
|
+
if (pad === 1 && idx >= 0) {
|
|
3313
|
+
if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|
3314
|
+
pad++;
|
|
3315
|
+
} else if (tailIsPct3D(idx)) {
|
|
3316
|
+
pad++;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
|
|
3320
|
+
const groups = Math.floor(effectiveLen / 4);
|
|
3321
|
+
const bytes = groups * 3 - (pad || 0);
|
|
3322
|
+
return bytes > 0 ? bytes : 0;
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|
3326
|
+
return Buffer.byteLength(body, 'utf8');
|
|
3327
|
+
}
|
|
2850
3328
|
|
|
2851
|
-
|
|
3329
|
+
// Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|
3330
|
+
// a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|
3331
|
+
// Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|
3332
|
+
// but 3 UTF-8 bytes).
|
|
3333
|
+
let bytes = 0;
|
|
3334
|
+
for (let i = 0, len = body.length; i < len; i++) {
|
|
3335
|
+
const c = body.charCodeAt(i);
|
|
3336
|
+
if (c < 0x80) {
|
|
3337
|
+
bytes += 1;
|
|
3338
|
+
} else if (c < 0x800) {
|
|
3339
|
+
bytes += 2;
|
|
3340
|
+
} else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
|
|
3341
|
+
const next = body.charCodeAt(i + 1);
|
|
3342
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
3343
|
+
bytes += 4;
|
|
3344
|
+
i++;
|
|
3345
|
+
} else {
|
|
3346
|
+
bytes += 3;
|
|
3347
|
+
}
|
|
3348
|
+
} else {
|
|
3349
|
+
bytes += 3;
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
return bytes;
|
|
3353
|
+
}
|
|
2852
3354
|
|
|
2853
|
-
const
|
|
2854
|
-
Request, Response
|
|
2855
|
-
}))(utils$1.global);
|
|
3355
|
+
const VERSION = "1.16.0";
|
|
2856
3356
|
|
|
2857
|
-
const
|
|
2858
|
-
ReadableStream: ReadableStream$1, TextEncoder
|
|
2859
|
-
} = utils$1.global;
|
|
3357
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2860
3358
|
|
|
3359
|
+
const { isFunction } = utils$1;
|
|
2861
3360
|
|
|
2862
3361
|
const test = (fn, ...args) => {
|
|
2863
3362
|
try {
|
|
2864
3363
|
return !!fn(...args);
|
|
2865
3364
|
} catch (e) {
|
|
2866
|
-
return false
|
|
3365
|
+
return false;
|
|
2867
3366
|
}
|
|
2868
3367
|
};
|
|
2869
3368
|
|
|
2870
3369
|
const factory = (env) => {
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
3370
|
+
const globalObject = utils$1.global ?? globalThis;
|
|
3371
|
+
const { ReadableStream, TextEncoder } = globalObject;
|
|
3372
|
+
|
|
3373
|
+
env = utils$1.merge.call(
|
|
3374
|
+
{
|
|
3375
|
+
skipUndefined: true,
|
|
3376
|
+
},
|
|
3377
|
+
{
|
|
3378
|
+
Request: globalObject.Request,
|
|
3379
|
+
Response: globalObject.Response,
|
|
3380
|
+
},
|
|
3381
|
+
env
|
|
3382
|
+
);
|
|
2874
3383
|
|
|
2875
|
-
const {fetch: envFetch, Request, Response} = env;
|
|
3384
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
2876
3385
|
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|
2877
3386
|
const isRequestSupported = isFunction(Request);
|
|
2878
3387
|
const isResponseSupported = isFunction(Response);
|
|
@@ -2881,48 +3390,69 @@ const factory = (env) => {
|
|
|
2881
3390
|
return false;
|
|
2882
3391
|
}
|
|
2883
3392
|
|
|
2884
|
-
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream
|
|
3393
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|
2885
3394
|
|
|
2886
|
-
const encodeText =
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
3395
|
+
const encodeText =
|
|
3396
|
+
isFetchSupported &&
|
|
3397
|
+
(typeof TextEncoder === 'function'
|
|
3398
|
+
? (
|
|
3399
|
+
(encoder) => (str) =>
|
|
3400
|
+
encoder.encode(str)
|
|
3401
|
+
)(new TextEncoder())
|
|
3402
|
+
: async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
2890
3403
|
|
|
2891
|
-
const supportsRequestStream =
|
|
2892
|
-
|
|
3404
|
+
const supportsRequestStream =
|
|
3405
|
+
isRequestSupported &&
|
|
3406
|
+
isReadableStreamSupported &&
|
|
3407
|
+
test(() => {
|
|
3408
|
+
let duplexAccessed = false;
|
|
2893
3409
|
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
3410
|
+
const request = new Request(platform.origin, {
|
|
3411
|
+
body: new ReadableStream(),
|
|
3412
|
+
method: 'POST',
|
|
3413
|
+
get duplex() {
|
|
3414
|
+
duplexAccessed = true;
|
|
3415
|
+
return 'half';
|
|
3416
|
+
},
|
|
3417
|
+
});
|
|
2902
3418
|
|
|
2903
|
-
|
|
2904
|
-
|
|
3419
|
+
const hasContentType = request.headers.has('Content-Type');
|
|
3420
|
+
|
|
3421
|
+
if (request.body != null) {
|
|
3422
|
+
request.body.cancel();
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
return duplexAccessed && !hasContentType;
|
|
3426
|
+
});
|
|
2905
3427
|
|
|
2906
|
-
const supportsResponseStream =
|
|
3428
|
+
const supportsResponseStream =
|
|
3429
|
+
isResponseSupported &&
|
|
3430
|
+
isReadableStreamSupported &&
|
|
2907
3431
|
test(() => utils$1.isReadableStream(new Response('').body));
|
|
2908
3432
|
|
|
2909
3433
|
const resolvers = {
|
|
2910
|
-
stream: supportsResponseStream && ((res) => res.body)
|
|
3434
|
+
stream: supportsResponseStream && ((res) => res.body),
|
|
2911
3435
|
};
|
|
2912
3436
|
|
|
2913
|
-
isFetchSupported &&
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
3437
|
+
isFetchSupported &&
|
|
3438
|
+
(() => {
|
|
3439
|
+
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
|
|
3440
|
+
!resolvers[type] &&
|
|
3441
|
+
(resolvers[type] = (res, config) => {
|
|
3442
|
+
let method = res && res[type];
|
|
2917
3443
|
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
3444
|
+
if (method) {
|
|
3445
|
+
return method.call(res);
|
|
3446
|
+
}
|
|
2921
3447
|
|
|
2922
|
-
|
|
3448
|
+
throw new AxiosError(
|
|
3449
|
+
`Response type '${type}' is not supported`,
|
|
3450
|
+
AxiosError.ERR_NOT_SUPPORT,
|
|
3451
|
+
config
|
|
3452
|
+
);
|
|
3453
|
+
});
|
|
2923
3454
|
});
|
|
2924
|
-
});
|
|
2925
|
-
})());
|
|
3455
|
+
})();
|
|
2926
3456
|
|
|
2927
3457
|
const getBodyLength = async (body) => {
|
|
2928
3458
|
if (body == null) {
|
|
@@ -2973,32 +3503,81 @@ const factory = (env) => {
|
|
|
2973
3503
|
responseType,
|
|
2974
3504
|
headers,
|
|
2975
3505
|
withCredentials = 'same-origin',
|
|
2976
|
-
fetchOptions
|
|
3506
|
+
fetchOptions,
|
|
3507
|
+
maxContentLength,
|
|
3508
|
+
maxBodyLength,
|
|
2977
3509
|
} = resolveConfig(config);
|
|
2978
3510
|
|
|
3511
|
+
const hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|
3512
|
+
const hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
3513
|
+
|
|
2979
3514
|
let _fetch = envFetch || fetch;
|
|
2980
3515
|
|
|
2981
3516
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2982
3517
|
|
|
2983
|
-
let composedSignal = composeSignals(
|
|
3518
|
+
let composedSignal = composeSignals(
|
|
3519
|
+
[signal, cancelToken && cancelToken.toAbortSignal()],
|
|
3520
|
+
timeout
|
|
3521
|
+
);
|
|
2984
3522
|
|
|
2985
3523
|
let request = null;
|
|
2986
3524
|
|
|
2987
|
-
const unsubscribe =
|
|
2988
|
-
composedSignal
|
|
2989
|
-
|
|
3525
|
+
const unsubscribe =
|
|
3526
|
+
composedSignal &&
|
|
3527
|
+
composedSignal.unsubscribe &&
|
|
3528
|
+
(() => {
|
|
3529
|
+
composedSignal.unsubscribe();
|
|
3530
|
+
});
|
|
2990
3531
|
|
|
2991
3532
|
let requestContentLength;
|
|
2992
3533
|
|
|
2993
3534
|
try {
|
|
3535
|
+
// Enforce maxContentLength for data: URLs up-front so we never materialize
|
|
3536
|
+
// an oversized payload. The HTTP adapter applies the same check (see http.js
|
|
3537
|
+
// "if (protocol === 'data:')" branch).
|
|
3538
|
+
if (hasMaxContentLength && typeof url === 'string' && url.startsWith('data:')) {
|
|
3539
|
+
const estimated = estimateDataURLDecodedBytes(url);
|
|
3540
|
+
if (estimated > maxContentLength) {
|
|
3541
|
+
throw new AxiosError(
|
|
3542
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3543
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3544
|
+
config,
|
|
3545
|
+
request
|
|
3546
|
+
);
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
// Enforce maxBodyLength against the outbound request body before dispatch.
|
|
3551
|
+
// Mirrors http.js behavior (ERR_BAD_REQUEST / 'Request body larger than
|
|
3552
|
+
// maxBodyLength limit'). Skip when the body length cannot be determined
|
|
3553
|
+
// (e.g. a live ReadableStream supplied by the caller).
|
|
3554
|
+
if (hasMaxBodyLength && method !== 'get' && method !== 'head') {
|
|
3555
|
+
const outboundLength = await resolveBodyLength(headers, data);
|
|
3556
|
+
if (
|
|
3557
|
+
typeof outboundLength === 'number' &&
|
|
3558
|
+
isFinite(outboundLength) &&
|
|
3559
|
+
outboundLength > maxBodyLength
|
|
3560
|
+
) {
|
|
3561
|
+
throw new AxiosError(
|
|
3562
|
+
'Request body larger than maxBodyLength limit',
|
|
3563
|
+
AxiosError.ERR_BAD_REQUEST,
|
|
3564
|
+
config,
|
|
3565
|
+
request
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
|
|
2994
3570
|
if (
|
|
2995
|
-
onUploadProgress &&
|
|
3571
|
+
onUploadProgress &&
|
|
3572
|
+
supportsRequestStream &&
|
|
3573
|
+
method !== 'get' &&
|
|
3574
|
+
method !== 'head' &&
|
|
2996
3575
|
(requestContentLength = await resolveBodyLength(headers, data)) !== 0
|
|
2997
3576
|
) {
|
|
2998
3577
|
let _request = new Request(url, {
|
|
2999
3578
|
method: 'POST',
|
|
3000
3579
|
body: data,
|
|
3001
|
-
duplex:
|
|
3580
|
+
duplex: 'half',
|
|
3002
3581
|
});
|
|
3003
3582
|
|
|
3004
3583
|
let contentTypeHeader;
|
|
@@ -3023,7 +3602,23 @@ const factory = (env) => {
|
|
|
3023
3602
|
|
|
3024
3603
|
// Cloudflare Workers throws when credentials are defined
|
|
3025
3604
|
// see https://github.com/cloudflare/workerd/issues/902
|
|
3026
|
-
const isCredentialsSupported = isRequestSupported &&
|
|
3605
|
+
const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
|
|
3606
|
+
|
|
3607
|
+
// If data is FormData and Content-Type is multipart/form-data without boundary,
|
|
3608
|
+
// delete it so fetch can set it correctly with the boundary
|
|
3609
|
+
if (utils$1.isFormData(data)) {
|
|
3610
|
+
const contentType = headers.getContentType();
|
|
3611
|
+
if (
|
|
3612
|
+
contentType &&
|
|
3613
|
+
/^multipart\/form-data/i.test(contentType) &&
|
|
3614
|
+
!/boundary=/i.test(contentType)
|
|
3615
|
+
) {
|
|
3616
|
+
headers.delete('content-type');
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
// Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|
3621
|
+
headers.set('User-Agent', 'axios/' + VERSION, false);
|
|
3027
3622
|
|
|
3028
3623
|
const resolvedOptions = {
|
|
3029
3624
|
...fetchOptions,
|
|
@@ -3031,32 +3626,72 @@ const factory = (env) => {
|
|
|
3031
3626
|
method: method.toUpperCase(),
|
|
3032
3627
|
headers: headers.normalize().toJSON(),
|
|
3033
3628
|
body: data,
|
|
3034
|
-
duplex:
|
|
3035
|
-
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
3629
|
+
duplex: 'half',
|
|
3630
|
+
credentials: isCredentialsSupported ? withCredentials : undefined,
|
|
3036
3631
|
};
|
|
3037
3632
|
|
|
3038
3633
|
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
3039
3634
|
|
|
3040
|
-
let response = await (isRequestSupported
|
|
3635
|
+
let response = await (isRequestSupported
|
|
3636
|
+
? _fetch(request, fetchOptions)
|
|
3637
|
+
: _fetch(url, resolvedOptions));
|
|
3638
|
+
|
|
3639
|
+
// Cheap pre-check: if the server honestly declares a content-length that
|
|
3640
|
+
// already exceeds the cap, reject before we start streaming.
|
|
3641
|
+
if (hasMaxContentLength) {
|
|
3642
|
+
const declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3643
|
+
if (declaredLength != null && declaredLength > maxContentLength) {
|
|
3644
|
+
throw new AxiosError(
|
|
3645
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3646
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3647
|
+
config,
|
|
3648
|
+
request
|
|
3649
|
+
);
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3041
3652
|
|
|
3042
|
-
const isStreamResponse =
|
|
3653
|
+
const isStreamResponse =
|
|
3654
|
+
supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
3043
3655
|
|
|
3044
|
-
if (
|
|
3656
|
+
if (
|
|
3657
|
+
supportsResponseStream &&
|
|
3658
|
+
response.body &&
|
|
3659
|
+
(onDownloadProgress || hasMaxContentLength || (isStreamResponse && unsubscribe))
|
|
3660
|
+
) {
|
|
3045
3661
|
const options = {};
|
|
3046
3662
|
|
|
3047
|
-
['status', 'statusText', 'headers'].forEach(prop => {
|
|
3663
|
+
['status', 'statusText', 'headers'].forEach((prop) => {
|
|
3048
3664
|
options[prop] = response[prop];
|
|
3049
3665
|
});
|
|
3050
3666
|
|
|
3051
3667
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3052
3668
|
|
|
3053
|
-
const [onProgress, flush] =
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3669
|
+
const [onProgress, flush] =
|
|
3670
|
+
(onDownloadProgress &&
|
|
3671
|
+
progressEventDecorator(
|
|
3672
|
+
responseContentLength,
|
|
3673
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
3674
|
+
)) ||
|
|
3675
|
+
[];
|
|
3676
|
+
|
|
3677
|
+
let bytesRead = 0;
|
|
3678
|
+
const onChunkProgress = (loadedBytes) => {
|
|
3679
|
+
if (hasMaxContentLength) {
|
|
3680
|
+
bytesRead = loadedBytes;
|
|
3681
|
+
if (bytesRead > maxContentLength) {
|
|
3682
|
+
throw new AxiosError(
|
|
3683
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3684
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3685
|
+
config,
|
|
3686
|
+
request
|
|
3687
|
+
);
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
onProgress && onProgress(loadedBytes);
|
|
3691
|
+
};
|
|
3057
3692
|
|
|
3058
3693
|
response = new Response(
|
|
3059
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
3694
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
|
|
3060
3695
|
flush && flush();
|
|
3061
3696
|
unsubscribe && unsubscribe();
|
|
3062
3697
|
}),
|
|
@@ -3066,7 +3701,37 @@ const factory = (env) => {
|
|
|
3066
3701
|
|
|
3067
3702
|
responseType = responseType || 'text';
|
|
3068
3703
|
|
|
3069
|
-
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3704
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
|
|
3705
|
+
response,
|
|
3706
|
+
config
|
|
3707
|
+
);
|
|
3708
|
+
|
|
3709
|
+
// Fallback enforcement for environments without ReadableStream support
|
|
3710
|
+
// (legacy runtimes). Detect materialized size from typed output; skip
|
|
3711
|
+
// streams/Response passthrough since the user will read those themselves.
|
|
3712
|
+
if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
|
|
3713
|
+
let materializedSize;
|
|
3714
|
+
if (responseData != null) {
|
|
3715
|
+
if (typeof responseData.byteLength === 'number') {
|
|
3716
|
+
materializedSize = responseData.byteLength;
|
|
3717
|
+
} else if (typeof responseData.size === 'number') {
|
|
3718
|
+
materializedSize = responseData.size;
|
|
3719
|
+
} else if (typeof responseData === 'string') {
|
|
3720
|
+
materializedSize =
|
|
3721
|
+
typeof TextEncoder === 'function'
|
|
3722
|
+
? new TextEncoder().encode(responseData).byteLength
|
|
3723
|
+
: responseData.length;
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
if (typeof materializedSize === 'number' && materializedSize > maxContentLength) {
|
|
3727
|
+
throw new AxiosError(
|
|
3728
|
+
'maxContentLength size of ' + maxContentLength + ' exceeded',
|
|
3729
|
+
AxiosError.ERR_BAD_RESPONSE,
|
|
3730
|
+
config,
|
|
3731
|
+
request
|
|
3732
|
+
);
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3070
3735
|
|
|
3071
3736
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3072
3737
|
|
|
@@ -3077,43 +3742,61 @@ const factory = (env) => {
|
|
|
3077
3742
|
status: response.status,
|
|
3078
3743
|
statusText: response.statusText,
|
|
3079
3744
|
config,
|
|
3080
|
-
request
|
|
3745
|
+
request,
|
|
3081
3746
|
});
|
|
3082
|
-
})
|
|
3747
|
+
});
|
|
3083
3748
|
} catch (err) {
|
|
3084
3749
|
unsubscribe && unsubscribe();
|
|
3085
3750
|
|
|
3751
|
+
// Safari can surface fetch aborts as a DOMException-like object whose
|
|
3752
|
+
// branded getters throw. Prefer our composed signal reason before reading
|
|
3753
|
+
// the caught error, preserving timeout vs cancellation semantics.
|
|
3754
|
+
if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError) {
|
|
3755
|
+
const canceledError = composedSignal.reason;
|
|
3756
|
+
canceledError.config = config;
|
|
3757
|
+
request && (canceledError.request = request);
|
|
3758
|
+
err !== canceledError && (canceledError.cause = err);
|
|
3759
|
+
throw canceledError;
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3086
3762
|
if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
|
|
3087
3763
|
throw Object.assign(
|
|
3088
|
-
new AxiosError(
|
|
3764
|
+
new AxiosError(
|
|
3765
|
+
'Network Error',
|
|
3766
|
+
AxiosError.ERR_NETWORK,
|
|
3767
|
+
config,
|
|
3768
|
+
request,
|
|
3769
|
+
err && err.response
|
|
3770
|
+
),
|
|
3089
3771
|
{
|
|
3090
|
-
cause: err.cause || err
|
|
3772
|
+
cause: err.cause || err,
|
|
3091
3773
|
}
|
|
3092
|
-
)
|
|
3774
|
+
);
|
|
3093
3775
|
}
|
|
3094
3776
|
|
|
3095
3777
|
throw AxiosError.from(err, err && err.code, config, request, err && err.response);
|
|
3096
3778
|
}
|
|
3097
|
-
}
|
|
3779
|
+
};
|
|
3098
3780
|
};
|
|
3099
3781
|
|
|
3100
3782
|
const seedCache = new Map();
|
|
3101
3783
|
|
|
3102
3784
|
const getFetch = (config) => {
|
|
3103
3785
|
let env = (config && config.env) || {};
|
|
3104
|
-
const {fetch, Request, Response} = env;
|
|
3105
|
-
const seeds = [
|
|
3106
|
-
Request, Response, fetch
|
|
3107
|
-
];
|
|
3786
|
+
const { fetch, Request, Response } = env;
|
|
3787
|
+
const seeds = [Request, Response, fetch];
|
|
3108
3788
|
|
|
3109
|
-
let len = seeds.length,
|
|
3110
|
-
|
|
3789
|
+
let len = seeds.length,
|
|
3790
|
+
i = len,
|
|
3791
|
+
seed,
|
|
3792
|
+
target,
|
|
3793
|
+
map = seedCache;
|
|
3111
3794
|
|
|
3112
3795
|
while (i--) {
|
|
3113
3796
|
seed = seeds[i];
|
|
3114
3797
|
target = map.get(seed);
|
|
3115
3798
|
|
|
3116
|
-
target === undefined && map.set(seed, target =
|
|
3799
|
+
target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
|
|
3117
3800
|
|
|
3118
3801
|
map = target;
|
|
3119
3802
|
}
|
|
@@ -3129,7 +3812,7 @@ getFetch();
|
|
|
3129
3812
|
* - `http` for Node.js
|
|
3130
3813
|
* - `xhr` for browsers
|
|
3131
3814
|
* - `fetch` for fetch API-based requests
|
|
3132
|
-
*
|
|
3815
|
+
*
|
|
3133
3816
|
* @type {Object<string, Function|Object>}
|
|
3134
3817
|
*/
|
|
3135
3818
|
const knownAdapters = {
|
|
@@ -3137,24 +3820,26 @@ const knownAdapters = {
|
|
|
3137
3820
|
xhr: xhrAdapter,
|
|
3138
3821
|
fetch: {
|
|
3139
3822
|
get: getFetch,
|
|
3140
|
-
}
|
|
3823
|
+
},
|
|
3141
3824
|
};
|
|
3142
3825
|
|
|
3143
3826
|
// Assign adapter names for easier debugging and identification
|
|
3144
3827
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3145
3828
|
if (fn) {
|
|
3146
3829
|
try {
|
|
3147
|
-
Object.
|
|
3830
|
+
// Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|
3831
|
+
// these data descriptors into accessor descriptors on the way in.
|
|
3832
|
+
Object.defineProperty(fn, 'name', { __proto__: null, value });
|
|
3148
3833
|
} catch (e) {
|
|
3149
3834
|
// eslint-disable-next-line no-empty
|
|
3150
3835
|
}
|
|
3151
|
-
Object.defineProperty(fn, 'adapterName', { value });
|
|
3836
|
+
Object.defineProperty(fn, 'adapterName', { __proto__: null, value });
|
|
3152
3837
|
}
|
|
3153
3838
|
});
|
|
3154
3839
|
|
|
3155
3840
|
/**
|
|
3156
3841
|
* Render a rejection reason string for unknown or unsupported adapters
|
|
3157
|
-
*
|
|
3842
|
+
*
|
|
3158
3843
|
* @param {string} reason
|
|
3159
3844
|
* @returns {string}
|
|
3160
3845
|
*/
|
|
@@ -3162,17 +3847,18 @@ const renderReason = (reason) => `- ${reason}`;
|
|
|
3162
3847
|
|
|
3163
3848
|
/**
|
|
3164
3849
|
* Check if the adapter is resolved (function, null, or false)
|
|
3165
|
-
*
|
|
3850
|
+
*
|
|
3166
3851
|
* @param {Function|null|false} adapter
|
|
3167
3852
|
* @returns {boolean}
|
|
3168
3853
|
*/
|
|
3169
|
-
const isResolvedHandle = (adapter) =>
|
|
3854
|
+
const isResolvedHandle = (adapter) =>
|
|
3855
|
+
utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3170
3856
|
|
|
3171
3857
|
/**
|
|
3172
3858
|
* Get the first suitable adapter from the provided list.
|
|
3173
3859
|
* Tries each adapter in order until a supported one is found.
|
|
3174
3860
|
* Throws an AxiosError if no adapter is suitable.
|
|
3175
|
-
*
|
|
3861
|
+
*
|
|
3176
3862
|
* @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|
3177
3863
|
* @param {Object} config - Axios request configuration
|
|
3178
3864
|
* @throws {AxiosError} If no suitable adapter is available
|
|
@@ -3209,14 +3895,17 @@ function getAdapter(adapters, config) {
|
|
|
3209
3895
|
}
|
|
3210
3896
|
|
|
3211
3897
|
if (!adapter) {
|
|
3212
|
-
const reasons = Object.entries(rejectedReasons)
|
|
3213
|
-
|
|
3898
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
3899
|
+
([id, state]) =>
|
|
3900
|
+
`adapter ${id} ` +
|
|
3214
3901
|
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
3215
|
-
|
|
3902
|
+
);
|
|
3216
3903
|
|
|
3217
|
-
let s = length
|
|
3218
|
-
|
|
3219
|
-
|
|
3904
|
+
let s = length
|
|
3905
|
+
? reasons.length > 1
|
|
3906
|
+
? 'since :\n' + reasons.map(renderReason).join('\n')
|
|
3907
|
+
: ' ' + renderReason(reasons[0])
|
|
3908
|
+
: 'as no adapter specified';
|
|
3220
3909
|
|
|
3221
3910
|
throw new AxiosError(
|
|
3222
3911
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
@@ -3241,7 +3930,7 @@ const adapters = {
|
|
|
3241
3930
|
* Exposes all known adapters
|
|
3242
3931
|
* @type {Object<string, Function|Object>}
|
|
3243
3932
|
*/
|
|
3244
|
-
adapters: knownAdapters
|
|
3933
|
+
adapters: knownAdapters,
|
|
3245
3934
|
};
|
|
3246
3935
|
|
|
3247
3936
|
/**
|
|
@@ -3274,10 +3963,7 @@ function dispatchRequest(config) {
|
|
|
3274
3963
|
config.headers = AxiosHeaders.from(config.headers);
|
|
3275
3964
|
|
|
3276
3965
|
// Transform request data
|
|
3277
|
-
config.data = transformData.call(
|
|
3278
|
-
config,
|
|
3279
|
-
config.transformRequest
|
|
3280
|
-
);
|
|
3966
|
+
config.data = transformData.call(config, config.transformRequest);
|
|
3281
3967
|
|
|
3282
3968
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|
3283
3969
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
@@ -3285,40 +3971,49 @@ function dispatchRequest(config) {
|
|
|
3285
3971
|
|
|
3286
3972
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
3287
3973
|
|
|
3288
|
-
return adapter(config).then(
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
// Transform response data
|
|
3292
|
-
response.data = transformData.call(
|
|
3293
|
-
config,
|
|
3294
|
-
config.transformResponse,
|
|
3295
|
-
response
|
|
3296
|
-
);
|
|
3974
|
+
return adapter(config).then(
|
|
3975
|
+
function onAdapterResolution(response) {
|
|
3976
|
+
throwIfCancellationRequested(config);
|
|
3297
3977
|
|
|
3298
|
-
|
|
3978
|
+
// Expose the current response on config so that transformResponse can
|
|
3979
|
+
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
3980
|
+
// We clean it up afterwards to avoid polluting the config object.
|
|
3981
|
+
config.response = response;
|
|
3982
|
+
try {
|
|
3983
|
+
response.data = transformData.call(config, config.transformResponse, response);
|
|
3984
|
+
} finally {
|
|
3985
|
+
delete config.response;
|
|
3986
|
+
}
|
|
3299
3987
|
|
|
3300
|
-
|
|
3301
|
-
}, function onAdapterRejection(reason) {
|
|
3302
|
-
if (!isCancel(reason)) {
|
|
3303
|
-
throwIfCancellationRequested(config);
|
|
3988
|
+
response.headers = AxiosHeaders.from(response.headers);
|
|
3304
3989
|
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
reason
|
|
3990
|
+
return response;
|
|
3991
|
+
},
|
|
3992
|
+
function onAdapterRejection(reason) {
|
|
3993
|
+
if (!isCancel(reason)) {
|
|
3994
|
+
throwIfCancellationRequested(config);
|
|
3995
|
+
|
|
3996
|
+
// Transform response data
|
|
3997
|
+
if (reason && reason.response) {
|
|
3998
|
+
config.response = reason.response;
|
|
3999
|
+
try {
|
|
4000
|
+
reason.response.data = transformData.call(
|
|
4001
|
+
config,
|
|
4002
|
+
config.transformResponse,
|
|
4003
|
+
reason.response
|
|
4004
|
+
);
|
|
4005
|
+
} finally {
|
|
4006
|
+
delete config.response;
|
|
4007
|
+
}
|
|
4008
|
+
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
4009
|
+
}
|
|
3313
4010
|
}
|
|
3314
|
-
}
|
|
3315
4011
|
|
|
3316
|
-
|
|
3317
|
-
|
|
4012
|
+
return Promise.reject(reason);
|
|
4013
|
+
}
|
|
4014
|
+
);
|
|
3318
4015
|
}
|
|
3319
4016
|
|
|
3320
|
-
const VERSION = "1.13.5";
|
|
3321
|
-
|
|
3322
4017
|
const validators$1 = {};
|
|
3323
4018
|
|
|
3324
4019
|
// eslint-disable-next-line func-names
|
|
@@ -3341,7 +4036,15 @@ const deprecatedWarnings = {};
|
|
|
3341
4036
|
*/
|
|
3342
4037
|
validators$1.transitional = function transitional(validator, version, message) {
|
|
3343
4038
|
function formatMessage(opt, desc) {
|
|
3344
|
-
return
|
|
4039
|
+
return (
|
|
4040
|
+
'[Axios v' +
|
|
4041
|
+
VERSION +
|
|
4042
|
+
"] Transitional option '" +
|
|
4043
|
+
opt +
|
|
4044
|
+
"'" +
|
|
4045
|
+
desc +
|
|
4046
|
+
(message ? '. ' + message : '')
|
|
4047
|
+
);
|
|
3345
4048
|
}
|
|
3346
4049
|
|
|
3347
4050
|
// eslint-disable-next-line func-names
|
|
@@ -3373,7 +4076,7 @@ validators$1.spelling = function spelling(correctSpelling) {
|
|
|
3373
4076
|
// eslint-disable-next-line no-console
|
|
3374
4077
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
3375
4078
|
return true;
|
|
3376
|
-
}
|
|
4079
|
+
};
|
|
3377
4080
|
};
|
|
3378
4081
|
|
|
3379
4082
|
/**
|
|
@@ -3394,12 +4097,17 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3394
4097
|
let i = keys.length;
|
|
3395
4098
|
while (i-- > 0) {
|
|
3396
4099
|
const opt = keys[i];
|
|
3397
|
-
|
|
4100
|
+
// Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|
4101
|
+
// a non-function validator and cause a TypeError.
|
|
4102
|
+
const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|
3398
4103
|
if (validator) {
|
|
3399
4104
|
const value = options[opt];
|
|
3400
4105
|
const result = value === undefined || validator(value, opt, options);
|
|
3401
4106
|
if (result !== true) {
|
|
3402
|
-
throw new AxiosError(
|
|
4107
|
+
throw new AxiosError(
|
|
4108
|
+
'option ' + opt + ' must be ' + result,
|
|
4109
|
+
AxiosError.ERR_BAD_OPTION_VALUE
|
|
4110
|
+
);
|
|
3403
4111
|
}
|
|
3404
4112
|
continue;
|
|
3405
4113
|
}
|
|
@@ -3411,7 +4119,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
3411
4119
|
|
|
3412
4120
|
const validator = {
|
|
3413
4121
|
assertOptions,
|
|
3414
|
-
validators: validators$1
|
|
4122
|
+
validators: validators$1,
|
|
3415
4123
|
};
|
|
3416
4124
|
|
|
3417
4125
|
const validators = validator.validators;
|
|
@@ -3428,7 +4136,7 @@ class Axios {
|
|
|
3428
4136
|
this.defaults = instanceConfig || {};
|
|
3429
4137
|
this.interceptors = {
|
|
3430
4138
|
request: new InterceptorManager(),
|
|
3431
|
-
response: new InterceptorManager()
|
|
4139
|
+
response: new InterceptorManager(),
|
|
3432
4140
|
};
|
|
3433
4141
|
}
|
|
3434
4142
|
|
|
@@ -3450,13 +4158,29 @@ class Axios {
|
|
|
3450
4158
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
|
3451
4159
|
|
|
3452
4160
|
// slice off the Error: ... line
|
|
3453
|
-
const stack =
|
|
4161
|
+
const stack = (() => {
|
|
4162
|
+
if (!dummy.stack) {
|
|
4163
|
+
return '';
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
const firstNewlineIndex = dummy.stack.indexOf('\n');
|
|
4167
|
+
|
|
4168
|
+
return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|
4169
|
+
})();
|
|
3454
4170
|
try {
|
|
3455
4171
|
if (!err.stack) {
|
|
3456
4172
|
err.stack = stack;
|
|
3457
4173
|
// match without the 2 top stack lines
|
|
3458
|
-
} else if (stack
|
|
3459
|
-
|
|
4174
|
+
} else if (stack) {
|
|
4175
|
+
const firstNewlineIndex = stack.indexOf('\n');
|
|
4176
|
+
const secondNewlineIndex =
|
|
4177
|
+
firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|
4178
|
+
const stackWithoutTwoTopLines =
|
|
4179
|
+
secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|
4180
|
+
|
|
4181
|
+
if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
|
|
4182
|
+
err.stack += '\n' + stack;
|
|
4183
|
+
}
|
|
3460
4184
|
}
|
|
3461
4185
|
} catch (e) {
|
|
3462
4186
|
// ignore the case where "stack" is an un-writable property
|
|
@@ -3479,27 +4203,35 @@ class Axios {
|
|
|
3479
4203
|
|
|
3480
4204
|
config = mergeConfig(this.defaults, config);
|
|
3481
4205
|
|
|
3482
|
-
const {transitional, paramsSerializer, headers} = config;
|
|
4206
|
+
const { transitional, paramsSerializer, headers } = config;
|
|
3483
4207
|
|
|
3484
4208
|
if (transitional !== undefined) {
|
|
3485
|
-
validator.assertOptions(
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
4209
|
+
validator.assertOptions(
|
|
4210
|
+
transitional,
|
|
4211
|
+
{
|
|
4212
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
4213
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
4214
|
+
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
4215
|
+
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
|
|
4216
|
+
},
|
|
4217
|
+
false
|
|
4218
|
+
);
|
|
3491
4219
|
}
|
|
3492
4220
|
|
|
3493
4221
|
if (paramsSerializer != null) {
|
|
3494
4222
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
3495
4223
|
config.paramsSerializer = {
|
|
3496
|
-
serialize: paramsSerializer
|
|
4224
|
+
serialize: paramsSerializer,
|
|
3497
4225
|
};
|
|
3498
4226
|
} else {
|
|
3499
|
-
validator.assertOptions(
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
4227
|
+
validator.assertOptions(
|
|
4228
|
+
paramsSerializer,
|
|
4229
|
+
{
|
|
4230
|
+
encode: validators.function,
|
|
4231
|
+
serialize: validators.function,
|
|
4232
|
+
},
|
|
4233
|
+
true
|
|
4234
|
+
);
|
|
3503
4235
|
}
|
|
3504
4236
|
}
|
|
3505
4237
|
|
|
@@ -3510,26 +4242,25 @@ class Axios {
|
|
|
3510
4242
|
config.allowAbsoluteUrls = true;
|
|
3511
4243
|
}
|
|
3512
4244
|
|
|
3513
|
-
validator.assertOptions(
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
4245
|
+
validator.assertOptions(
|
|
4246
|
+
config,
|
|
4247
|
+
{
|
|
4248
|
+
baseUrl: validators.spelling('baseURL'),
|
|
4249
|
+
withXsrfToken: validators.spelling('withXSRFToken'),
|
|
4250
|
+
},
|
|
4251
|
+
true
|
|
4252
|
+
);
|
|
3517
4253
|
|
|
3518
4254
|
// Set config.method
|
|
3519
4255
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3520
4256
|
|
|
3521
4257
|
// Flatten headers
|
|
3522
|
-
let contextHeaders = headers && utils$1.merge(
|
|
3523
|
-
headers.common,
|
|
3524
|
-
headers[config.method]
|
|
3525
|
-
);
|
|
4258
|
+
let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|
3526
4259
|
|
|
3527
|
-
headers &&
|
|
3528
|
-
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3529
|
-
(method) => {
|
|
4260
|
+
headers &&
|
|
4261
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], (method) => {
|
|
3530
4262
|
delete headers[method];
|
|
3531
|
-
}
|
|
3532
|
-
);
|
|
4263
|
+
});
|
|
3533
4264
|
|
|
3534
4265
|
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
3535
4266
|
|
|
@@ -3544,7 +4275,8 @@ class Axios {
|
|
|
3544
4275
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
3545
4276
|
|
|
3546
4277
|
const transitional = config.transitional || transitionalDefaults;
|
|
3547
|
-
const legacyInterceptorReqResOrdering =
|
|
4278
|
+
const legacyInterceptorReqResOrdering =
|
|
4279
|
+
transitional && transitional.legacyInterceptorReqResOrdering;
|
|
3548
4280
|
|
|
3549
4281
|
if (legacyInterceptorReqResOrdering) {
|
|
3550
4282
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
@@ -3618,34 +4350,42 @@ class Axios {
|
|
|
3618
4350
|
// Provide aliases for supported request methods
|
|
3619
4351
|
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3620
4352
|
/*eslint func-names:0*/
|
|
3621
|
-
Axios.prototype[method] = function(url, config) {
|
|
3622
|
-
return this.request(
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
4353
|
+
Axios.prototype[method] = function (url, config) {
|
|
4354
|
+
return this.request(
|
|
4355
|
+
mergeConfig(config || {}, {
|
|
4356
|
+
method,
|
|
4357
|
+
url,
|
|
4358
|
+
data: (config || {}).data,
|
|
4359
|
+
})
|
|
4360
|
+
);
|
|
3627
4361
|
};
|
|
3628
4362
|
});
|
|
3629
4363
|
|
|
3630
|
-
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3631
|
-
/*eslint func-names:0*/
|
|
3632
|
-
|
|
4364
|
+
utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|
3633
4365
|
function generateHTTPMethod(isForm) {
|
|
3634
4366
|
return function httpMethod(url, data, config) {
|
|
3635
|
-
return this.request(
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
4367
|
+
return this.request(
|
|
4368
|
+
mergeConfig(config || {}, {
|
|
4369
|
+
method,
|
|
4370
|
+
headers: isForm
|
|
4371
|
+
? {
|
|
4372
|
+
'Content-Type': 'multipart/form-data',
|
|
4373
|
+
}
|
|
4374
|
+
: {},
|
|
4375
|
+
url,
|
|
4376
|
+
data,
|
|
4377
|
+
})
|
|
4378
|
+
);
|
|
3643
4379
|
};
|
|
3644
4380
|
}
|
|
3645
4381
|
|
|
3646
4382
|
Axios.prototype[method] = generateHTTPMethod();
|
|
3647
4383
|
|
|
3648
|
-
|
|
4384
|
+
// QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|
4385
|
+
// its semantics, so no queryForm shorthand is generated.
|
|
4386
|
+
if (method !== 'query') {
|
|
4387
|
+
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
4388
|
+
}
|
|
3649
4389
|
});
|
|
3650
4390
|
|
|
3651
4391
|
/**
|
|
@@ -3670,7 +4410,7 @@ class CancelToken {
|
|
|
3670
4410
|
const token = this;
|
|
3671
4411
|
|
|
3672
4412
|
// eslint-disable-next-line func-names
|
|
3673
|
-
this.promise.then(cancel => {
|
|
4413
|
+
this.promise.then((cancel) => {
|
|
3674
4414
|
if (!token._listeners) return;
|
|
3675
4415
|
|
|
3676
4416
|
let i = token._listeners.length;
|
|
@@ -3682,10 +4422,10 @@ class CancelToken {
|
|
|
3682
4422
|
});
|
|
3683
4423
|
|
|
3684
4424
|
// eslint-disable-next-line func-names
|
|
3685
|
-
this.promise.then = onfulfilled => {
|
|
4425
|
+
this.promise.then = (onfulfilled) => {
|
|
3686
4426
|
let _resolve;
|
|
3687
4427
|
// eslint-disable-next-line func-names
|
|
3688
|
-
const promise = new Promise(resolve => {
|
|
4428
|
+
const promise = new Promise((resolve) => {
|
|
3689
4429
|
token.subscribe(resolve);
|
|
3690
4430
|
_resolve = resolve;
|
|
3691
4431
|
}).then(onfulfilled);
|
|
@@ -3773,7 +4513,7 @@ class CancelToken {
|
|
|
3773
4513
|
});
|
|
3774
4514
|
return {
|
|
3775
4515
|
token,
|
|
3776
|
-
cancel
|
|
4516
|
+
cancel,
|
|
3777
4517
|
};
|
|
3778
4518
|
}
|
|
3779
4519
|
}
|
|
@@ -3813,7 +4553,7 @@ function spread(callback) {
|
|
|
3813
4553
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3814
4554
|
*/
|
|
3815
4555
|
function isAxiosError(payload) {
|
|
3816
|
-
return utils$1.isObject(payload) &&
|
|
4556
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
3817
4557
|
}
|
|
3818
4558
|
|
|
3819
4559
|
const HttpStatusCode = {
|
|
@@ -3904,10 +4644,10 @@ function createInstance(defaultConfig) {
|
|
|
3904
4644
|
const instance = bind(Axios.prototype.request, context);
|
|
3905
4645
|
|
|
3906
4646
|
// Copy axios.prototype to instance
|
|
3907
|
-
utils$1.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
|
4647
|
+
utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
|
|
3908
4648
|
|
|
3909
4649
|
// Copy context to instance
|
|
3910
|
-
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
4650
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
3911
4651
|
|
|
3912
4652
|
// Factory for creating new instances
|
|
3913
4653
|
instance.create = function create(instanceConfig) {
|
|
@@ -3951,7 +4691,7 @@ axios$1.mergeConfig = mergeConfig;
|
|
|
3951
4691
|
|
|
3952
4692
|
axios$1.AxiosHeaders = AxiosHeaders;
|
|
3953
4693
|
|
|
3954
|
-
axios$1.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
4694
|
+
axios$1.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3955
4695
|
|
|
3956
4696
|
axios$1.getAdapter = adapters.getAdapter;
|
|
3957
4697
|
|
|
@@ -4653,6 +5393,39 @@ const findLayer = (layers, layer) => {
|
|
|
4653
5393
|
}
|
|
4654
5394
|
};
|
|
4655
5395
|
|
|
5396
|
+
/**
|
|
5397
|
+
* Removes JSON layers by ID from the layer tree
|
|
5398
|
+
* @param {import("@eox/map").EoxLayer[]} layers
|
|
5399
|
+
* @param {string[]} layerIds
|
|
5400
|
+
* @returns {import("@eox/map").EoxLayer[]}
|
|
5401
|
+
**/
|
|
5402
|
+
const removeLayers = (layers, layerIds) => {
|
|
5403
|
+
const result = [];
|
|
5404
|
+
for (const layer of layers) {
|
|
5405
|
+
// if the layer is hidden, do not include it without checking if it's a group
|
|
5406
|
+
if (layer.properties?.id && layerIds.includes(layer.properties.id)) {
|
|
5407
|
+
continue;
|
|
5408
|
+
}
|
|
5409
|
+
if (layer.type === "Group" && Array.isArray(layer.layers)) {
|
|
5410
|
+
const newGroupLayers = removeLayers(layer.layers, layerIds);
|
|
5411
|
+
// if the group is not hidden, add it with the updated layers (if any were removed)
|
|
5412
|
+
result.push(
|
|
5413
|
+
newGroupLayers !== layer.layers
|
|
5414
|
+
? { ...layer, layers: newGroupLayers }
|
|
5415
|
+
: layer,
|
|
5416
|
+
);
|
|
5417
|
+
continue;
|
|
5418
|
+
}
|
|
5419
|
+
|
|
5420
|
+
result.push(layer);
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5423
|
+
return result.length === layers.length &&
|
|
5424
|
+
result.every((l, i) => l === layers[i])
|
|
5425
|
+
? layers
|
|
5426
|
+
: result;
|
|
5427
|
+
};
|
|
5428
|
+
|
|
4656
5429
|
/**
|
|
4657
5430
|
* Removes one or more layers (by id) from a layer/group structure and inserts
|
|
4658
5431
|
* new layers in place of the first removed one.
|
|
@@ -5073,4 +5846,4 @@ function extractEoxLegendLink(link) {
|
|
|
5073
5846
|
return extraProperties;
|
|
5074
5847
|
}
|
|
5075
5848
|
|
|
5076
|
-
export { axios$1 as $,
|
|
5849
|
+
export { axios$1 as $, datetime as A, poi as B, activeTemplate as C, mapPosition as D, indicator as E, currentUrl as F, currentCompareUrl as G, compareIndicator as H, comparePoi as I, states as J, actions as K, areChartsSeparateLayout as L, chartSpec as M, compareChartSpec as N, includesProcess as O, shouldShowChartWidget as P, sanitizeBbox as Q, mapCompareEl as R, getColFromLayer as S, setMapProjFromCol as T, isGlobe as U, setActiveTemplate as V, availableMapProjection as W, changeMapProjection as X, getCompareLayers as Y, compareChartData as Z, chartData as _, extractEoxLegendLink as a, removeLayers as a0, removeUnneededProperties as a1, extractLayerConfig as b, createLayerID as c, axios as d, extractRoles as e, fetchStyle as f, addTooltipInteraction as g, createAssetID as h, mapEl as i, getProjectionCode as j, isSTACItem as k, extractLayerTimeValues as l, mergeGeojsons as m, fetchApiItems as n, getDatetimeProperty as o, fetchAllStyles as p, findLayer as q, registerProjection as r, findLayersByLayerPrefix as s, replaceLayer as t, generateFeatures as u, getLayers as v, extractLayerLegend as w, extractCollectionUrls as x, generateLinksFromItems as y, revokeCollectionBlobUrls as z };
|