Axios

Axios 是一个基于 promise 网络请求库,作用于node.js 和浏览器中。 它是 isomorphic 的(即同一套代码可以运行在浏览器和node.js中)。在服务端它使用原生 node.js http 模块, 而在客户端 (浏览端) 则使用 XMLHttpRequests。

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/454265/1113258/Axios.js

  1. // ==UserScript==
  2. // @name Axios
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.3
  5. // @description Axios 是一个基于 promise 网络请求库,作用于node.js 和浏览器中。 它是 isomorphic 的(即同一套代码可以运行在浏览器和node.js中)。在服务端它使用原生 node.js http 模块, 而在客户端 (浏览端) 则使用 XMLHttpRequests。
  6. // @author buyi
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=haonicheng.com
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // Axios v1.1.3 Copyright (c) 2022 Matt Zabriskie and contributors
  12. (function (global, factory) {
  13. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  14. typeof define === 'function' && define.amd ? define(factory) :
  15. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
  16. })(this, (function () { 'use strict';
  17.  
  18. function _typeof(obj) {
  19. "@babel/helpers - typeof";
  20.  
  21. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
  22. return typeof obj;
  23. } : function (obj) {
  24. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  25. }, _typeof(obj);
  26. }
  27. function _classCallCheck(instance, Constructor) {
  28. if (!(instance instanceof Constructor)) {
  29. throw new TypeError("Cannot call a class as a function");
  30. }
  31. }
  32. function _defineProperties(target, props) {
  33. for (var i = 0; i < props.length; i++) {
  34. var descriptor = props[i];
  35. descriptor.enumerable = descriptor.enumerable || false;
  36. descriptor.configurable = true;
  37. if ("value" in descriptor) descriptor.writable = true;
  38. Object.defineProperty(target, descriptor.key, descriptor);
  39. }
  40. }
  41. function _createClass(Constructor, protoProps, staticProps) {
  42. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  43. if (staticProps) _defineProperties(Constructor, staticProps);
  44. Object.defineProperty(Constructor, "prototype", {
  45. writable: false
  46. });
  47. return Constructor;
  48. }
  49.  
  50. function bind(fn, thisArg) {
  51. return function wrap() {
  52. return fn.apply(thisArg, arguments);
  53. };
  54. }
  55.  
  56. // utils is a library of generic helper functions non-specific to axios
  57.  
  58. var toString = Object.prototype.toString;
  59. var getPrototypeOf = Object.getPrototypeOf;
  60. var kindOf = function (cache) {
  61. return function (thing) {
  62. var str = toString.call(thing);
  63. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  64. };
  65. }(Object.create(null));
  66. var kindOfTest = function kindOfTest(type) {
  67. type = type.toLowerCase();
  68. return function (thing) {
  69. return kindOf(thing) === type;
  70. };
  71. };
  72. var typeOfTest = function typeOfTest(type) {
  73. return function (thing) {
  74. return _typeof(thing) === type;
  75. };
  76. };
  77.  
  78. /**
  79. * Determine if a value is an Array
  80. *
  81. * @param {Object} val The value to test
  82. *
  83. * @returns {boolean} True if value is an Array, otherwise false
  84. */
  85. var isArray = Array.isArray;
  86.  
  87. /**
  88. * Determine if a value is undefined
  89. *
  90. * @param {*} val The value to test
  91. *
  92. * @returns {boolean} True if the value is undefined, otherwise false
  93. */
  94. var isUndefined = typeOfTest('undefined');
  95.  
  96. /**
  97. * Determine if a value is a Buffer
  98. *
  99. * @param {*} val The value to test
  100. *
  101. * @returns {boolean} True if value is a Buffer, otherwise false
  102. */
  103. function isBuffer(val) {
  104. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  105. }
  106.  
  107. /**
  108. * Determine if a value is an ArrayBuffer
  109. *
  110. * @param {*} val The value to test
  111. *
  112. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  113. */
  114. var isArrayBuffer = kindOfTest('ArrayBuffer');
  115.  
  116. /**
  117. * Determine if a value is a view on an ArrayBuffer
  118. *
  119. * @param {*} val The value to test
  120. *
  121. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  122. */
  123. function isArrayBufferView(val) {
  124. var result;
  125. if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
  126. result = ArrayBuffer.isView(val);
  127. } else {
  128. result = val && val.buffer && isArrayBuffer(val.buffer);
  129. }
  130. return result;
  131. }
  132.  
  133. /**
  134. * Determine if a value is a String
  135. *
  136. * @param {*} val The value to test
  137. *
  138. * @returns {boolean} True if value is a String, otherwise false
  139. */
  140. var isString = typeOfTest('string');
  141.  
  142. /**
  143. * Determine if a value is a Function
  144. *
  145. * @param {*} val The value to test
  146. * @returns {boolean} True if value is a Function, otherwise false
  147. */
  148. var isFunction = typeOfTest('function');
  149.  
  150. /**
  151. * Determine if a value is a Number
  152. *
  153. * @param {*} val The value to test
  154. *
  155. * @returns {boolean} True if value is a Number, otherwise false
  156. */
  157. var isNumber = typeOfTest('number');
  158.  
  159. /**
  160. * Determine if a value is an Object
  161. *
  162. * @param {*} thing The value to test
  163. *
  164. * @returns {boolean} True if value is an Object, otherwise false
  165. */
  166. var isObject = function isObject(thing) {
  167. return thing !== null && _typeof(thing) === 'object';
  168. };
  169.  
  170. /**
  171. * Determine if a value is a Boolean
  172. *
  173. * @param {*} thing The value to test
  174. * @returns {boolean} True if value is a Boolean, otherwise false
  175. */
  176. var isBoolean = function isBoolean(thing) {
  177. return thing === true || thing === false;
  178. };
  179.  
  180. /**
  181. * Determine if a value is a plain Object
  182. *
  183. * @param {*} val The value to test
  184. *
  185. * @returns {boolean} True if value is a plain Object, otherwise false
  186. */
  187. var isPlainObject = function isPlainObject(val) {
  188. if (kindOf(val) !== 'object') {
  189. return false;
  190. }
  191. var prototype = getPrototypeOf(val);
  192. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
  193. };
  194.  
  195. /**
  196. * Determine if a value is a Date
  197. *
  198. * @param {*} val The value to test
  199. *
  200. * @returns {boolean} True if value is a Date, otherwise false
  201. */
  202. var isDate = kindOfTest('Date');
  203.  
  204. /**
  205. * Determine if a value is a File
  206. *
  207. * @param {*} val The value to test
  208. *
  209. * @returns {boolean} True if value is a File, otherwise false
  210. */
  211. var isFile = kindOfTest('File');
  212.  
  213. /**
  214. * Determine if a value is a Blob
  215. *
  216. * @param {*} val The value to test
  217. *
  218. * @returns {boolean} True if value is a Blob, otherwise false
  219. */
  220. var isBlob = kindOfTest('Blob');
  221.  
  222. /**
  223. * Determine if a value is a FileList
  224. *
  225. * @param {*} val The value to test
  226. *
  227. * @returns {boolean} True if value is a File, otherwise false
  228. */
  229. var isFileList = kindOfTest('FileList');
  230.  
  231. /**
  232. * Determine if a value is a Stream
  233. *
  234. * @param {*} val The value to test
  235. *
  236. * @returns {boolean} True if value is a Stream, otherwise false
  237. */
  238. var isStream = function isStream(val) {
  239. return isObject(val) && isFunction(val.pipe);
  240. };
  241.  
  242. /**
  243. * Determine if a value is a FormData
  244. *
  245. * @param {*} thing The value to test
  246. *
  247. * @returns {boolean} True if value is an FormData, otherwise false
  248. */
  249. var isFormData = function isFormData(thing) {
  250. var pattern = '[object FormData]';
  251. return thing && (typeof FormData === 'function' && thing instanceof FormData || toString.call(thing) === pattern || isFunction(thing.toString) && thing.toString() === pattern);
  252. };
  253.  
  254. /**
  255. * Determine if a value is a URLSearchParams object
  256. *
  257. * @param {*} val The value to test
  258. *
  259. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  260. */
  261. var isURLSearchParams = kindOfTest('URLSearchParams');
  262.  
  263. /**
  264. * Trim excess whitespace off the beginning and end of a string
  265. *
  266. * @param {String} str The String to trim
  267. *
  268. * @returns {String} The String freed of excess whitespace
  269. */
  270. var trim = function trim(str) {
  271. return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  272. };
  273.  
  274. /**
  275. * Iterate over an Array or an Object invoking a function for each item.
  276. *
  277. * If `obj` is an Array callback will be called passing
  278. * the value, index, and complete array for each item.
  279. *
  280. * If 'obj' is an Object callback will be called passing
  281. * the value, key, and complete object for each property.
  282. *
  283. * @param {Object|Array} obj The object to iterate
  284. * @param {Function} fn The callback to invoke for each item
  285. *
  286. * @param {Boolean} [allOwnKeys = false]
  287. * @returns {void}
  288. */
  289. function forEach(obj, fn) {
  290. var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  291. _ref$allOwnKeys = _ref.allOwnKeys,
  292. allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
  293. // Don't bother if no value provided
  294. if (obj === null || typeof obj === 'undefined') {
  295. return;
  296. }
  297. var i;
  298. var l;
  299.  
  300. // Force an array if not already something iterable
  301. if (_typeof(obj) !== 'object') {
  302. /*eslint no-param-reassign:0*/
  303. obj = [obj];
  304. }
  305. if (isArray(obj)) {
  306. // Iterate over array values
  307. for (i = 0, l = obj.length; i < l; i++) {
  308. fn.call(null, obj[i], i, obj);
  309. }
  310. } else {
  311. // Iterate over object keys
  312. var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  313. var len = keys.length;
  314. var key;
  315. for (i = 0; i < len; i++) {
  316. key = keys[i];
  317. fn.call(null, obj[key], key, obj);
  318. }
  319. }
  320. }
  321.  
  322. /**
  323. * Accepts varargs expecting each argument to be an object, then
  324. * immutably merges the properties of each object and returns result.
  325. *
  326. * When multiple objects contain the same key the later object in
  327. * the arguments list will take precedence.
  328. *
  329. * Example:
  330. *
  331. * ```js
  332. * var result = merge({foo: 123}, {foo: 456});
  333. * console.log(result.foo); // outputs 456
  334. * ```
  335. *
  336. * @param {Object} obj1 Object to merge
  337. *
  338. * @returns {Object} Result of all merge properties
  339. */
  340. function /* obj1, obj2, obj3, ... */
  341. merge() {
  342. var result = {};
  343. var assignValue = function assignValue(val, key) {
  344. if (isPlainObject(result[key]) && isPlainObject(val)) {
  345. result[key] = merge(result[key], val);
  346. } else if (isPlainObject(val)) {
  347. result[key] = merge({}, val);
  348. } else if (isArray(val)) {
  349. result[key] = val.slice();
  350. } else {
  351. result[key] = val;
  352. }
  353. };
  354. for (var i = 0, l = arguments.length; i < l; i++) {
  355. arguments[i] && forEach(arguments[i], assignValue);
  356. }
  357. return result;
  358. }
  359.  
  360. /**
  361. * Extends object a by mutably adding to it the properties of object b.
  362. *
  363. * @param {Object} a The object to be extended
  364. * @param {Object} b The object to copy properties from
  365. * @param {Object} thisArg The object to bind function to
  366. *
  367. * @param {Boolean} [allOwnKeys]
  368. * @returns {Object} The resulting value of object a
  369. */
  370. var extend = function extend(a, b, thisArg) {
  371. var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
  372. allOwnKeys = _ref2.allOwnKeys;
  373. forEach(b, function (val, key) {
  374. if (thisArg && isFunction(val)) {
  375. a[key] = bind(val, thisArg);
  376. } else {
  377. a[key] = val;
  378. }
  379. }, {
  380. allOwnKeys: allOwnKeys
  381. });
  382. return a;
  383. };
  384.  
  385. /**
  386. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  387. *
  388. * @param {string} content with BOM
  389. *
  390. * @returns {string} content value without BOM
  391. */
  392. var stripBOM = function stripBOM(content) {
  393. if (content.charCodeAt(0) === 0xFEFF) {
  394. content = content.slice(1);
  395. }
  396. return content;
  397. };
  398.  
  399. /**
  400. * Inherit the prototype methods from one constructor into another
  401. * @param {function} constructor
  402. * @param {function} superConstructor
  403. * @param {object} [props]
  404. * @param {object} [descriptors]
  405. *
  406. * @returns {void}
  407. */
  408. var inherits = function inherits(constructor, superConstructor, props, descriptors) {
  409. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  410. constructor.prototype.constructor = constructor;
  411. Object.defineProperty(constructor, 'super', {
  412. value: superConstructor.prototype
  413. });
  414. props && Object.assign(constructor.prototype, props);
  415. };
  416.  
  417. /**
  418. * Resolve object with deep prototype chain to a flat object
  419. * @param {Object} sourceObj source object
  420. * @param {Object} [destObj]
  421. * @param {Function|Boolean} [filter]
  422. * @param {Function} [propFilter]
  423. *
  424. * @returns {Object}
  425. */
  426. var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
  427. var props;
  428. var i;
  429. var prop;
  430. var merged = {};
  431. destObj = destObj || {};
  432. // eslint-disable-next-line no-eq-null,eqeqeq
  433. if (sourceObj == null) return destObj;
  434. do {
  435. props = Object.getOwnPropertyNames(sourceObj);
  436. i = props.length;
  437. while (i-- > 0) {
  438. prop = props[i];
  439. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  440. destObj[prop] = sourceObj[prop];
  441. merged[prop] = true;
  442. }
  443. }
  444. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  445. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  446. return destObj;
  447. };
  448.  
  449. /**
  450. * Determines whether a string ends with the characters of a specified string
  451. *
  452. * @param {String} str
  453. * @param {String} searchString
  454. * @param {Number} [position= 0]
  455. *
  456. * @returns {boolean}
  457. */
  458. var endsWith = function endsWith(str, searchString, position) {
  459. str = String(str);
  460. if (position === undefined || position > str.length) {
  461. position = str.length;
  462. }
  463. position -= searchString.length;
  464. var lastIndex = str.indexOf(searchString, position);
  465. return lastIndex !== -1 && lastIndex === position;
  466. };
  467.  
  468. /**
  469. * Returns new array from array like object or null if failed
  470. *
  471. * @param {*} [thing]
  472. *
  473. * @returns {?Array}
  474. */
  475. var toArray = function toArray(thing) {
  476. if (!thing) return null;
  477. if (isArray(thing)) return thing;
  478. var i = thing.length;
  479. if (!isNumber(i)) return null;
  480. var arr = new Array(i);
  481. while (i-- > 0) {
  482. arr[i] = thing[i];
  483. }
  484. return arr;
  485. };
  486.  
  487. /**
  488. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  489. * thing passed in is an instance of Uint8Array
  490. *
  491. * @param {TypedArray}
  492. *
  493. * @returns {Array}
  494. */
  495. // eslint-disable-next-line func-names
  496. var isTypedArray = function (TypedArray) {
  497. // eslint-disable-next-line func-names
  498. return function (thing) {
  499. return TypedArray && thing instanceof TypedArray;
  500. };
  501. }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  502.  
  503. /**
  504. * For each entry in the object, call the function with the key and value.
  505. *
  506. * @param {Object<any, any>} obj - The object to iterate over.
  507. * @param {Function} fn - The function to call for each entry.
  508. *
  509. * @returns {void}
  510. */
  511. var forEachEntry = function forEachEntry(obj, fn) {
  512. var generator = obj && obj[Symbol.iterator];
  513. var iterator = generator.call(obj);
  514. var result;
  515. while ((result = iterator.next()) && !result.done) {
  516. var pair = result.value;
  517. fn.call(obj, pair[0], pair[1]);
  518. }
  519. };
  520.  
  521. /**
  522. * It takes a regular expression and a string, and returns an array of all the matches
  523. *
  524. * @param {string} regExp - The regular expression to match against.
  525. * @param {string} str - The string to search.
  526. *
  527. * @returns {Array<boolean>}
  528. */
  529. var matchAll = function matchAll(regExp, str) {
  530. var matches;
  531. var arr = [];
  532. while ((matches = regExp.exec(str)) !== null) {
  533. arr.push(matches);
  534. }
  535. return arr;
  536. };
  537.  
  538. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  539. var isHTMLForm = kindOfTest('HTMLFormElement');
  540. var toCamelCase = function toCamelCase(str) {
  541. return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
  542. return p1.toUpperCase() + p2;
  543. });
  544. };
  545.  
  546. /* Creating a function that will check if an object has a property. */
  547. var hasOwnProperty = function (_ref3) {
  548. var hasOwnProperty = _ref3.hasOwnProperty;
  549. return function (obj, prop) {
  550. return hasOwnProperty.call(obj, prop);
  551. };
  552. }(Object.prototype);
  553.  
  554. /**
  555. * Determine if a value is a RegExp object
  556. *
  557. * @param {*} val The value to test
  558. *
  559. * @returns {boolean} True if value is a RegExp object, otherwise false
  560. */
  561. var isRegExp = kindOfTest('RegExp');
  562. var reduceDescriptors = function reduceDescriptors(obj, reducer) {
  563. var descriptors = Object.getOwnPropertyDescriptors(obj);
  564. var reducedDescriptors = {};
  565. forEach(descriptors, function (descriptor, name) {
  566. if (reducer(descriptor, name, obj) !== false) {
  567. reducedDescriptors[name] = descriptor;
  568. }
  569. });
  570. Object.defineProperties(obj, reducedDescriptors);
  571. };
  572.  
  573. /**
  574. * Makes all methods read-only
  575. * @param {Object} obj
  576. */
  577.  
  578. var freezeMethods = function freezeMethods(obj) {
  579. reduceDescriptors(obj, function (descriptor, name) {
  580. var value = obj[name];
  581. if (!isFunction(value)) return;
  582. descriptor.enumerable = false;
  583. if ('writable' in descriptor) {
  584. descriptor.writable = false;
  585. return;
  586. }
  587. if (!descriptor.set) {
  588. descriptor.set = function () {
  589. throw Error('Can not read-only method \'' + name + '\'');
  590. };
  591. }
  592. });
  593. };
  594. var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
  595. var obj = {};
  596. var define = function define(arr) {
  597. arr.forEach(function (value) {
  598. obj[value] = true;
  599. });
  600. };
  601. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  602. return obj;
  603. };
  604. var noop = function noop() {};
  605. var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
  606. value = +value;
  607. return Number.isFinite(value) ? value : defaultValue;
  608. };
  609. var utils = {
  610. isArray: isArray,
  611. isArrayBuffer: isArrayBuffer,
  612. isBuffer: isBuffer,
  613. isFormData: isFormData,
  614. isArrayBufferView: isArrayBufferView,
  615. isString: isString,
  616. isNumber: isNumber,
  617. isBoolean: isBoolean,
  618. isObject: isObject,
  619. isPlainObject: isPlainObject,
  620. isUndefined: isUndefined,
  621. isDate: isDate,
  622. isFile: isFile,
  623. isBlob: isBlob,
  624. isRegExp: isRegExp,
  625. isFunction: isFunction,
  626. isStream: isStream,
  627. isURLSearchParams: isURLSearchParams,
  628. isTypedArray: isTypedArray,
  629. isFileList: isFileList,
  630. forEach: forEach,
  631. merge: merge,
  632. extend: extend,
  633. trim: trim,
  634. stripBOM: stripBOM,
  635. inherits: inherits,
  636. toFlatObject: toFlatObject,
  637. kindOf: kindOf,
  638. kindOfTest: kindOfTest,
  639. endsWith: endsWith,
  640. toArray: toArray,
  641. forEachEntry: forEachEntry,
  642. matchAll: matchAll,
  643. isHTMLForm: isHTMLForm,
  644. hasOwnProperty: hasOwnProperty,
  645. hasOwnProp: hasOwnProperty,
  646. // an alias to avoid ESLint no-prototype-builtins detection
  647. reduceDescriptors: reduceDescriptors,
  648. freezeMethods: freezeMethods,
  649. toObjectSet: toObjectSet,
  650. toCamelCase: toCamelCase,
  651. noop: noop,
  652. toFiniteNumber: toFiniteNumber
  653. };
  654.  
  655. /**
  656. * Create an Error with the specified message, config, error code, request and response.
  657. *
  658. * @param {string} message The error message.
  659. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  660. * @param {Object} [config] The config.
  661. * @param {Object} [request] The request.
  662. * @param {Object} [response] The response.
  663. *
  664. * @returns {Error} The created error.
  665. */
  666. function AxiosError(message, code, config, request, response) {
  667. Error.call(this);
  668. if (Error.captureStackTrace) {
  669. Error.captureStackTrace(this, this.constructor);
  670. } else {
  671. this.stack = new Error().stack;
  672. }
  673. this.message = message;
  674. this.name = 'AxiosError';
  675. code && (this.code = code);
  676. config && (this.config = config);
  677. request && (this.request = request);
  678. response && (this.response = response);
  679. }
  680. utils.inherits(AxiosError, Error, {
  681. toJSON: function toJSON() {
  682. return {
  683. // Standard
  684. message: this.message,
  685. name: this.name,
  686. // Microsoft
  687. description: this.description,
  688. number: this.number,
  689. // Mozilla
  690. fileName: this.fileName,
  691. lineNumber: this.lineNumber,
  692. columnNumber: this.columnNumber,
  693. stack: this.stack,
  694. // Axios
  695. config: this.config,
  696. code: this.code,
  697. status: this.response && this.response.status ? this.response.status : null
  698. };
  699. }
  700. });
  701. var prototype$1 = AxiosError.prototype;
  702. var descriptors = {};
  703. ['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
  704. // eslint-disable-next-line func-names
  705. ].forEach(function (code) {
  706. descriptors[code] = {
  707. value: code
  708. };
  709. });
  710. Object.defineProperties(AxiosError, descriptors);
  711. Object.defineProperty(prototype$1, 'isAxiosError', {
  712. value: true
  713. });
  714.  
  715. // eslint-disable-next-line func-names
  716. AxiosError.from = function (error, code, config, request, response, customProps) {
  717. var axiosError = Object.create(prototype$1);
  718. utils.toFlatObject(error, axiosError, function filter(obj) {
  719. return obj !== Error.prototype;
  720. }, function (prop) {
  721. return prop !== 'isAxiosError';
  722. });
  723. AxiosError.call(axiosError, error.message, code, config, request, response);
  724. axiosError.cause = error;
  725. axiosError.name = error.name;
  726. customProps && Object.assign(axiosError, customProps);
  727. return axiosError;
  728. };
  729.  
  730. /* eslint-env browser */
  731. var browser = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' ? self.FormData : window.FormData;
  732.  
  733. /**
  734. * Determines if the given thing is a array or js object.
  735. *
  736. * @param {string} thing - The object or array to be visited.
  737. *
  738. * @returns {boolean}
  739. */
  740. function isVisitable(thing) {
  741. return utils.isPlainObject(thing) || utils.isArray(thing);
  742. }
  743.  
  744. /**
  745. * It removes the brackets from the end of a string
  746. *
  747. * @param {string} key - The key of the parameter.
  748. *
  749. * @returns {string} the key without the brackets.
  750. */
  751. function removeBrackets(key) {
  752. return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
  753. }
  754.  
  755. /**
  756. * It takes a path, a key, and a boolean, and returns a string
  757. *
  758. * @param {string} path - The path to the current key.
  759. * @param {string} key - The key of the current object being iterated over.
  760. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  761. *
  762. * @returns {string} The path to the current key.
  763. */
  764. function renderKey(path, key, dots) {
  765. if (!path) return key;
  766. return path.concat(key).map(function each(token, i) {
  767. // eslint-disable-next-line no-param-reassign
  768. token = removeBrackets(token);
  769. return !dots && i ? '[' + token + ']' : token;
  770. }).join(dots ? '.' : '');
  771. }
  772.  
  773. /**
  774. * If the array is an array and none of its elements are visitable, then it's a flat array.
  775. *
  776. * @param {Array<any>} arr - The array to check
  777. *
  778. * @returns {boolean}
  779. */
  780. function isFlatArray(arr) {
  781. return utils.isArray(arr) && !arr.some(isVisitable);
  782. }
  783. var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
  784. return /^is[A-Z]/.test(prop);
  785. });
  786.  
  787. /**
  788. * If the thing is a FormData object, return true, otherwise return false.
  789. *
  790. * @param {unknown} thing - The thing to check.
  791. *
  792. * @returns {boolean}
  793. */
  794. function isSpecCompliant(thing) {
  795. return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
  796. }
  797.  
  798. /**
  799. * Convert a data object to FormData
  800. *
  801. * @param {Object} obj
  802. * @param {?Object} [formData]
  803. * @param {?Object} [options]
  804. * @param {Function} [options.visitor]
  805. * @param {Boolean} [options.metaTokens = true]
  806. * @param {Boolean} [options.dots = false]
  807. * @param {?Boolean} [options.indexes = false]
  808. *
  809. * @returns {Object}
  810. **/
  811.  
  812. /**
  813. * It converts an object into a FormData object
  814. *
  815. * @param {Object<any, any>} obj - The object to convert to form data.
  816. * @param {string} formData - The FormData object to append to.
  817. * @param {Object<string, any>} options
  818. *
  819. * @returns
  820. */
  821. function toFormData(obj, formData, options) {
  822. if (!utils.isObject(obj)) {
  823. throw new TypeError('target must be an object');
  824. }
  825.  
  826. // eslint-disable-next-line no-param-reassign
  827. formData = formData || new (browser || FormData)();
  828.  
  829. // eslint-disable-next-line no-param-reassign
  830. options = utils.toFlatObject(options, {
  831. metaTokens: true,
  832. dots: false,
  833. indexes: false
  834. }, false, function defined(option, source) {
  835. // eslint-disable-next-line no-eq-null,eqeqeq
  836. return !utils.isUndefined(source[option]);
  837. });
  838. var metaTokens = options.metaTokens;
  839. // eslint-disable-next-line no-use-before-define
  840. var visitor = options.visitor || defaultVisitor;
  841. var dots = options.dots;
  842. var indexes = options.indexes;
  843. var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  844. var useBlob = _Blob && isSpecCompliant(formData);
  845. if (!utils.isFunction(visitor)) {
  846. throw new TypeError('visitor must be a function');
  847. }
  848. function convertValue(value) {
  849. if (value === null) return '';
  850. if (utils.isDate(value)) {
  851. return value.toISOString();
  852. }
  853. if (!useBlob && utils.isBlob(value)) {
  854. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  855. }
  856. if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
  857. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  858. }
  859. return value;
  860. }
  861.  
  862. /**
  863. * Default visitor.
  864. *
  865. * @param {*} value
  866. * @param {String|Number} key
  867. * @param {Array<String|Number>} path
  868. * @this {FormData}
  869. *
  870. * @returns {boolean} return true to visit the each prop of the value recursively
  871. */
  872. function defaultVisitor(value, key, path) {
  873. var arr = value;
  874. if (value && !path && _typeof(value) === 'object') {
  875. if (utils.endsWith(key, '{}')) {
  876. // eslint-disable-next-line no-param-reassign
  877. key = metaTokens ? key : key.slice(0, -2);
  878. // eslint-disable-next-line no-param-reassign
  879. value = JSON.stringify(value);
  880. } else if (utils.isArray(value) && isFlatArray(value) || utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
  881. // eslint-disable-next-line no-param-reassign
  882. key = removeBrackets(key);
  883. arr.forEach(function each(el, index) {
  884. !(utils.isUndefined(el) || el === null) && formData.append(
  885. // eslint-disable-next-line no-nested-ternary
  886. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
  887. });
  888. return false;
  889. }
  890. }
  891. if (isVisitable(value)) {
  892. return true;
  893. }
  894. formData.append(renderKey(path, key, dots), convertValue(value));
  895. return false;
  896. }
  897. var stack = [];
  898. var exposedHelpers = Object.assign(predicates, {
  899. defaultVisitor: defaultVisitor,
  900. convertValue: convertValue,
  901. isVisitable: isVisitable
  902. });
  903. function build(value, path) {
  904. if (utils.isUndefined(value)) return;
  905. if (stack.indexOf(value) !== -1) {
  906. throw Error('Circular reference detected in ' + path.join('.'));
  907. }
  908. stack.push(value);
  909. utils.forEach(value, function each(el, key) {
  910. var result = !(utils.isUndefined(el) || el === null) && visitor.call(formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers);
  911. if (result === true) {
  912. build(el, path ? path.concat(key) : [key]);
  913. }
  914. });
  915. stack.pop();
  916. }
  917. if (!utils.isObject(obj)) {
  918. throw new TypeError('data must be an object');
  919. }
  920. build(obj);
  921. return formData;
  922. }
  923.  
  924. /**
  925. * It encodes a string by replacing all characters that are not in the unreserved set with
  926. * their percent-encoded equivalents
  927. *
  928. * @param {string} str - The string to encode.
  929. *
  930. * @returns {string} The encoded string.
  931. */
  932. function encode$1(str) {
  933. var charMap = {
  934. '!': '%21',
  935. "'": '%27',
  936. '(': '%28',
  937. ')': '%29',
  938. '~': '%7E',
  939. '%20': '+',
  940. '%00': '\x00'
  941. };
  942. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  943. return charMap[match];
  944. });
  945. }
  946.  
  947. /**
  948. * It takes a params object and converts it to a FormData object
  949. *
  950. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  951. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  952. *
  953. * @returns {void}
  954. */
  955. function AxiosURLSearchParams(params, options) {
  956. this._pairs = [];
  957. params && toFormData(params, this, options);
  958. }
  959. var prototype = AxiosURLSearchParams.prototype;
  960. prototype.append = function append(name, value) {
  961. this._pairs.push([name, value]);
  962. };
  963. prototype.toString = function toString(encoder) {
  964. var _encode = encoder ? function (value) {
  965. return encoder.call(this, value, encode$1);
  966. } : encode$1;
  967. return this._pairs.map(function each(pair) {
  968. return _encode(pair[0]) + '=' + _encode(pair[1]);
  969. }, '').join('&');
  970. };
  971.  
  972. /**
  973. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  974. * URI encoded counterparts
  975. *
  976. * @param {string} val The value to be encoded.
  977. *
  978. * @returns {string} The encoded value.
  979. */
  980. function encode(val) {
  981. return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
  982. }
  983.  
  984. /**
  985. * Build a URL by appending params to the end
  986. *
  987. * @param {string} url The base of the url (e.g., http://www.google.com)
  988. * @param {object} [params] The params to be appended
  989. * @param {?object} options
  990. *
  991. * @returns {string} The formatted url
  992. */
  993. function buildURL(url, params, options) {
  994. /*eslint no-param-reassign:0*/
  995. if (!params) {
  996. return url;
  997. }
  998. var _encode = options && options.encode || encode;
  999. var serializeFn = options && options.serialize;
  1000. var serializedParams;
  1001. if (serializeFn) {
  1002. serializedParams = serializeFn(params, options);
  1003. } else {
  1004. serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
  1005. }
  1006. if (serializedParams) {
  1007. var hashmarkIndex = url.indexOf("#");
  1008. if (hashmarkIndex !== -1) {
  1009. url = url.slice(0, hashmarkIndex);
  1010. }
  1011. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1012. }
  1013. return url;
  1014. }
  1015.  
  1016. var InterceptorManager = /*#__PURE__*/function () {
  1017. function InterceptorManager() {
  1018. _classCallCheck(this, InterceptorManager);
  1019. this.handlers = [];
  1020. }
  1021.  
  1022. /**
  1023. * Add a new interceptor to the stack
  1024. *
  1025. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1026. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1027. *
  1028. * @return {Number} An ID used to remove interceptor later
  1029. */
  1030. _createClass(InterceptorManager, [{
  1031. key: "use",
  1032. value: function use(fulfilled, rejected, options) {
  1033. this.handlers.push({
  1034. fulfilled: fulfilled,
  1035. rejected: rejected,
  1036. synchronous: options ? options.synchronous : false,
  1037. runWhen: options ? options.runWhen : null
  1038. });
  1039. return this.handlers.length - 1;
  1040. }
  1041.  
  1042. /**
  1043. * Remove an interceptor from the stack
  1044. *
  1045. * @param {Number} id The ID that was returned by `use`
  1046. *
  1047. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  1048. */
  1049. }, {
  1050. key: "eject",
  1051. value: function eject(id) {
  1052. if (this.handlers[id]) {
  1053. this.handlers[id] = null;
  1054. }
  1055. }
  1056.  
  1057. /**
  1058. * Clear all interceptors from the stack
  1059. *
  1060. * @returns {void}
  1061. */
  1062. }, {
  1063. key: "clear",
  1064. value: function clear() {
  1065. if (this.handlers) {
  1066. this.handlers = [];
  1067. }
  1068. }
  1069.  
  1070. /**
  1071. * Iterate over all the registered interceptors
  1072. *
  1073. * This method is particularly useful for skipping over any
  1074. * interceptors that may have become `null` calling `eject`.
  1075. *
  1076. * @param {Function} fn The function to call for each interceptor
  1077. *
  1078. * @returns {void}
  1079. */
  1080. }, {
  1081. key: "forEach",
  1082. value: function forEach(fn) {
  1083. utils.forEach(this.handlers, function forEachHandler(h) {
  1084. if (h !== null) {
  1085. fn(h);
  1086. }
  1087. });
  1088. }
  1089. }]);
  1090. return InterceptorManager;
  1091. }();
  1092.  
  1093. var transitionalDefaults = {
  1094. silentJSONParsing: true,
  1095. forcedJSONParsing: true,
  1096. clarifyTimeoutError: false
  1097. };
  1098.  
  1099. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1100.  
  1101. var FormData$1 = FormData;
  1102.  
  1103. /**
  1104. * Determine if we're running in a standard browser environment
  1105. *
  1106. * This allows axios to run in a web worker, and react-native.
  1107. * Both environments support XMLHttpRequest, but not fully standard globals.
  1108. *
  1109. * web workers:
  1110. * typeof window -> undefined
  1111. * typeof document -> undefined
  1112. *
  1113. * react-native:
  1114. * navigator.product -> 'ReactNative'
  1115. * nativescript
  1116. * navigator.product -> 'NativeScript' or 'NS'
  1117. *
  1118. * @returns {boolean}
  1119. */
  1120. var isStandardBrowserEnv = function () {
  1121. var product;
  1122. if (typeof navigator !== 'undefined' && ((product = navigator.product) === 'ReactNative' || product === 'NativeScript' || product === 'NS')) {
  1123. return false;
  1124. }
  1125. return typeof window !== 'undefined' && typeof document !== 'undefined';
  1126. }();
  1127. var platform = {
  1128. isBrowser: true,
  1129. classes: {
  1130. URLSearchParams: URLSearchParams$1,
  1131. FormData: FormData$1,
  1132. Blob: Blob
  1133. },
  1134. isStandardBrowserEnv: isStandardBrowserEnv,
  1135. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1136. };
  1137.  
  1138. function toURLEncodedForm(data, options) {
  1139. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  1140. visitor: function visitor(value, key, path, helpers) {
  1141. if (platform.isNode && utils.isBuffer(value)) {
  1142. this.append(key, value.toString('base64'));
  1143. return false;
  1144. }
  1145. return helpers.defaultVisitor.apply(this, arguments);
  1146. }
  1147. }, options));
  1148. }
  1149.  
  1150. /**
  1151. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1152. *
  1153. * @param {string} name - The name of the property to get.
  1154. *
  1155. * @returns An array of strings.
  1156. */
  1157. function parsePropPath(name) {
  1158. // foo[x][y][z]
  1159. // foo.x.y.z
  1160. // foo-x-y-z
  1161. // foo x y z
  1162. return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
  1163. return match[0] === '[]' ? '' : match[1] || match[0];
  1164. });
  1165. }
  1166.  
  1167. /**
  1168. * Convert an array to an object.
  1169. *
  1170. * @param {Array<any>} arr - The array to convert to an object.
  1171. *
  1172. * @returns An object with the same keys and values as the array.
  1173. */
  1174. function arrayToObject(arr) {
  1175. var obj = {};
  1176. var keys = Object.keys(arr);
  1177. var i;
  1178. var len = keys.length;
  1179. var key;
  1180. for (i = 0; i < len; i++) {
  1181. key = keys[i];
  1182. obj[key] = arr[key];
  1183. }
  1184. return obj;
  1185. }
  1186.  
  1187. /**
  1188. * It takes a FormData object and returns a JavaScript object
  1189. *
  1190. * @param {string} formData The FormData object to convert to JSON.
  1191. *
  1192. * @returns {Object<string, any> | null} The converted object.
  1193. */
  1194. function formDataToJSON(formData) {
  1195. function buildPath(path, value, target, index) {
  1196. var name = path[index++];
  1197. var isNumericKey = Number.isFinite(+name);
  1198. var isLast = index >= path.length;
  1199. name = !name && utils.isArray(target) ? target.length : name;
  1200. if (isLast) {
  1201. if (utils.hasOwnProp(target, name)) {
  1202. target[name] = [target[name], value];
  1203. } else {
  1204. target[name] = value;
  1205. }
  1206. return !isNumericKey;
  1207. }
  1208. if (!target[name] || !utils.isObject(target[name])) {
  1209. target[name] = [];
  1210. }
  1211. var result = buildPath(path, value, target[name], index);
  1212. if (result && utils.isArray(target[name])) {
  1213. target[name] = arrayToObject(target[name]);
  1214. }
  1215. return !isNumericKey;
  1216. }
  1217. if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
  1218. var obj = {};
  1219. utils.forEachEntry(formData, function (name, value) {
  1220. buildPath(parsePropPath(name), value, obj, 0);
  1221. });
  1222. return obj;
  1223. }
  1224. return null;
  1225. }
  1226.  
  1227. /**
  1228. * Resolve or reject a Promise based on response status.
  1229. *
  1230. * @param {Function} resolve A function that resolves the promise.
  1231. * @param {Function} reject A function that rejects the promise.
  1232. * @param {object} response The response.
  1233. *
  1234. * @returns {object} The response.
  1235. */
  1236. function settle(resolve, reject, response) {
  1237. var validateStatus = response.config.validateStatus;
  1238. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1239. resolve(response);
  1240. } else {
  1241. reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
  1242. }
  1243. }
  1244.  
  1245. var cookies = platform.isStandardBrowserEnv ?
  1246. // Standard browser envs support document.cookie
  1247. function standardBrowserEnv() {
  1248. return {
  1249. write: function write(name, value, expires, path, domain, secure) {
  1250. var cookie = [];
  1251. cookie.push(name + '=' + encodeURIComponent(value));
  1252. if (utils.isNumber(expires)) {
  1253. cookie.push('expires=' + new Date(expires).toGMTString());
  1254. }
  1255. if (utils.isString(path)) {
  1256. cookie.push('path=' + path);
  1257. }
  1258. if (utils.isString(domain)) {
  1259. cookie.push('domain=' + domain);
  1260. }
  1261. if (secure === true) {
  1262. cookie.push('secure');
  1263. }
  1264. document.cookie = cookie.join('; ');
  1265. },
  1266. read: function read(name) {
  1267. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1268. return match ? decodeURIComponent(match[3]) : null;
  1269. },
  1270. remove: function remove(name) {
  1271. this.write(name, '', Date.now() - 86400000);
  1272. }
  1273. };
  1274. }() :
  1275. // Non standard browser env (web workers, react-native) lack needed support.
  1276. function nonStandardBrowserEnv() {
  1277. return {
  1278. write: function write() {},
  1279. read: function read() {
  1280. return null;
  1281. },
  1282. remove: function remove() {}
  1283. };
  1284. }();
  1285.  
  1286. /**
  1287. * Determines whether the specified URL is absolute
  1288. *
  1289. * @param {string} url The URL to test
  1290. *
  1291. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1292. */
  1293. function isAbsoluteURL(url) {
  1294. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1295. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1296. // by any combination of letters, digits, plus, period, or hyphen.
  1297. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1298. }
  1299.  
  1300. /**
  1301. * Creates a new URL by combining the specified URLs
  1302. *
  1303. * @param {string} baseURL The base URL
  1304. * @param {string} relativeURL The relative URL
  1305. *
  1306. * @returns {string} The combined URL
  1307. */
  1308. function combineURLs(baseURL, relativeURL) {
  1309. return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
  1310. }
  1311.  
  1312. /**
  1313. * Creates a new URL by combining the baseURL with the requestedURL,
  1314. * only when the requestedURL is not already an absolute URL.
  1315. * If the requestURL is absolute, this function returns the requestedURL untouched.
  1316. *
  1317. * @param {string} baseURL The base URL
  1318. * @param {string} requestedURL Absolute or relative URL to combine
  1319. *
  1320. * @returns {string} The combined full path
  1321. */
  1322. function buildFullPath(baseURL, requestedURL) {
  1323. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1324. return combineURLs(baseURL, requestedURL);
  1325. }
  1326. return requestedURL;
  1327. }
  1328.  
  1329. var isURLSameOrigin = platform.isStandardBrowserEnv ?
  1330. // Standard browser envs have full support of the APIs needed to test
  1331. // whether the request URL is of the same origin as current location.
  1332. function standardBrowserEnv() {
  1333. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1334. var urlParsingNode = document.createElement('a');
  1335. var originURL;
  1336.  
  1337. /**
  1338. * Parse a URL to discover it's components
  1339. *
  1340. * @param {String} url The URL to be parsed
  1341. * @returns {Object}
  1342. */
  1343. function resolveURL(url) {
  1344. var href = url;
  1345. if (msie) {
  1346. // IE needs attribute set twice to normalize properties
  1347. urlParsingNode.setAttribute('href', href);
  1348. href = urlParsingNode.href;
  1349. }
  1350. urlParsingNode.setAttribute('href', href);
  1351.  
  1352. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1353. return {
  1354. href: urlParsingNode.href,
  1355. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1356. host: urlParsingNode.host,
  1357. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1358. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1359. hostname: urlParsingNode.hostname,
  1360. port: urlParsingNode.port,
  1361. pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
  1362. };
  1363. }
  1364. originURL = resolveURL(window.location.href);
  1365.  
  1366. /**
  1367. * Determine if a URL shares the same origin as the current location
  1368. *
  1369. * @param {String} requestURL The URL to test
  1370. * @returns {boolean} True if URL shares the same origin, otherwise false
  1371. */
  1372. return function isURLSameOrigin(requestURL) {
  1373. var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
  1374. return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
  1375. };
  1376. }() :
  1377. // Non standard browser envs (web workers, react-native) lack needed support.
  1378. function nonStandardBrowserEnv() {
  1379. return function isURLSameOrigin() {
  1380. return true;
  1381. };
  1382. }();
  1383.  
  1384. /**
  1385. * A `CanceledError` is an object that is thrown when an operation is canceled.
  1386. *
  1387. * @param {string=} message The message.
  1388. * @param {Object=} config The config.
  1389. * @param {Object=} request The request.
  1390. *
  1391. * @returns {CanceledError} The created error.
  1392. */
  1393. function CanceledError(message, config, request) {
  1394. // eslint-disable-next-line no-eq-null,eqeqeq
  1395. AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
  1396. this.name = 'CanceledError';
  1397. }
  1398. utils.inherits(CanceledError, AxiosError, {
  1399. __CANCEL__: true
  1400. });
  1401.  
  1402. function parseProtocol(url) {
  1403. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1404. return match && match[1] || '';
  1405. }
  1406.  
  1407. // RawAxiosHeaders whose duplicates are ignored by node
  1408. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1409. var ignoreDuplicateOf = utils.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
  1410.  
  1411. /**
  1412. * Parse headers into an object
  1413. *
  1414. * ```
  1415. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1416. * Content-Type: application/json
  1417. * Connection: keep-alive
  1418. * Transfer-Encoding: chunked
  1419. * ```
  1420. *
  1421. * @param {String} rawHeaders Headers needing to be parsed
  1422. *
  1423. * @returns {Object} Headers parsed into an object
  1424. */
  1425. var parseHeaders = (function (rawHeaders) {
  1426. var parsed = {};
  1427. var key;
  1428. var val;
  1429. var i;
  1430. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1431. i = line.indexOf(':');
  1432. key = line.substring(0, i).trim().toLowerCase();
  1433. val = line.substring(i + 1).trim();
  1434. if (!key || parsed[key] && ignoreDuplicateOf[key]) {
  1435. return;
  1436. }
  1437. if (key === 'set-cookie') {
  1438. if (parsed[key]) {
  1439. parsed[key].push(val);
  1440. } else {
  1441. parsed[key] = [val];
  1442. }
  1443. } else {
  1444. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1445. }
  1446. });
  1447. return parsed;
  1448. });
  1449.  
  1450. var $internals = Symbol('internals');
  1451. var $defaults = Symbol('defaults');
  1452. function normalizeHeader(header) {
  1453. return header && String(header).trim().toLowerCase();
  1454. }
  1455. function normalizeValue(value) {
  1456. if (value === false || value == null) {
  1457. return value;
  1458. }
  1459. return utils.isArray(value) ? value.map(normalizeValue) : String(value);
  1460. }
  1461. function parseTokens(str) {
  1462. var tokens = Object.create(null);
  1463. var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1464. var match;
  1465. while (match = tokensRE.exec(str)) {
  1466. tokens[match[1]] = match[2];
  1467. }
  1468. return tokens;
  1469. }
  1470. function matchHeaderValue(context, value, header, filter) {
  1471. if (utils.isFunction(filter)) {
  1472. return filter.call(this, value, header);
  1473. }
  1474. if (!utils.isString(value)) return;
  1475. if (utils.isString(filter)) {
  1476. return value.indexOf(filter) !== -1;
  1477. }
  1478. if (utils.isRegExp(filter)) {
  1479. return filter.test(value);
  1480. }
  1481. }
  1482. function formatHeader(header) {
  1483. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
  1484. return _char.toUpperCase() + str;
  1485. });
  1486. }
  1487. function buildAccessors(obj, header) {
  1488. var accessorName = utils.toCamelCase(' ' + header);
  1489. ['get', 'set', 'has'].forEach(function (methodName) {
  1490. Object.defineProperty(obj, methodName + accessorName, {
  1491. value: function value(arg1, arg2, arg3) {
  1492. return this[methodName].call(this, header, arg1, arg2, arg3);
  1493. },
  1494. configurable: true
  1495. });
  1496. });
  1497. }
  1498. function findKey(obj, key) {
  1499. key = key.toLowerCase();
  1500. var keys = Object.keys(obj);
  1501. var i = keys.length;
  1502. var _key;
  1503. while (i-- > 0) {
  1504. _key = keys[i];
  1505. if (key === _key.toLowerCase()) {
  1506. return _key;
  1507. }
  1508. }
  1509. return null;
  1510. }
  1511. function AxiosHeaders(headers, defaults) {
  1512. headers && this.set(headers);
  1513. this[$defaults] = defaults || null;
  1514. }
  1515. Object.assign(AxiosHeaders.prototype, {
  1516. set: function set(header, valueOrRewrite, rewrite) {
  1517. var self = this;
  1518. function setHeader(_value, _header, _rewrite) {
  1519. var lHeader = normalizeHeader(_header);
  1520. if (!lHeader) {
  1521. throw new Error('header name must be a non-empty string');
  1522. }
  1523. var key = findKey(self, lHeader);
  1524. if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
  1525. return;
  1526. }
  1527. self[key || _header] = normalizeValue(_value);
  1528. }
  1529. if (utils.isPlainObject(header)) {
  1530. utils.forEach(header, function (_value, _header) {
  1531. setHeader(_value, _header, valueOrRewrite);
  1532. });
  1533. } else {
  1534. setHeader(valueOrRewrite, header, rewrite);
  1535. }
  1536. return this;
  1537. },
  1538. get: function get(header, parser) {
  1539. header = normalizeHeader(header);
  1540. if (!header) return undefined;
  1541. var key = findKey(this, header);
  1542. if (key) {
  1543. var value = this[key];
  1544. if (!parser) {
  1545. return value;
  1546. }
  1547. if (parser === true) {
  1548. return parseTokens(value);
  1549. }
  1550. if (utils.isFunction(parser)) {
  1551. return parser.call(this, value, key);
  1552. }
  1553. if (utils.isRegExp(parser)) {
  1554. return parser.exec(value);
  1555. }
  1556. throw new TypeError('parser must be boolean|regexp|function');
  1557. }
  1558. },
  1559. has: function has(header, matcher) {
  1560. header = normalizeHeader(header);
  1561. if (header) {
  1562. var key = findKey(this, header);
  1563. return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1564. }
  1565. return false;
  1566. },
  1567. "delete": function _delete(header, matcher) {
  1568. var self = this;
  1569. var deleted = false;
  1570. function deleteHeader(_header) {
  1571. _header = normalizeHeader(_header);
  1572. if (_header) {
  1573. var key = findKey(self, _header);
  1574. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1575. delete self[key];
  1576. deleted = true;
  1577. }
  1578. }
  1579. }
  1580. if (utils.isArray(header)) {
  1581. header.forEach(deleteHeader);
  1582. } else {
  1583. deleteHeader(header);
  1584. }
  1585. return deleted;
  1586. },
  1587. clear: function clear() {
  1588. return Object.keys(this).forEach(this["delete"].bind(this));
  1589. },
  1590. normalize: function normalize(format) {
  1591. var self = this;
  1592. var headers = {};
  1593. utils.forEach(this, function (value, header) {
  1594. var key = findKey(headers, header);
  1595. if (key) {
  1596. self[key] = normalizeValue(value);
  1597. delete self[header];
  1598. return;
  1599. }
  1600. var normalized = format ? formatHeader(header) : String(header).trim();
  1601. if (normalized !== header) {
  1602. delete self[header];
  1603. }
  1604. self[normalized] = normalizeValue(value);
  1605. headers[normalized] = true;
  1606. });
  1607. return this;
  1608. },
  1609. toJSON: function toJSON(asStrings) {
  1610. var obj = Object.create(null);
  1611. utils.forEach(Object.assign({}, this[$defaults] || null, this), function (value, header) {
  1612. if (value == null || value === false) return;
  1613. obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
  1614. });
  1615. return obj;
  1616. }
  1617. });
  1618. Object.assign(AxiosHeaders, {
  1619. from: function from(thing) {
  1620. if (utils.isString(thing)) {
  1621. return new this(parseHeaders(thing));
  1622. }
  1623. return thing instanceof this ? thing : new this(thing);
  1624. },
  1625. accessor: function accessor(header) {
  1626. var internals = this[$internals] = this[$internals] = {
  1627. accessors: {}
  1628. };
  1629. var accessors = internals.accessors;
  1630. var prototype = this.prototype;
  1631. function defineAccessor(_header) {
  1632. var lHeader = normalizeHeader(_header);
  1633. if (!accessors[lHeader]) {
  1634. buildAccessors(prototype, _header);
  1635. accessors[lHeader] = true;
  1636. }
  1637. }
  1638. utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  1639. return this;
  1640. }
  1641. });
  1642. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
  1643. utils.freezeMethods(AxiosHeaders.prototype);
  1644. utils.freezeMethods(AxiosHeaders);
  1645.  
  1646. /**
  1647. * Calculate data maxRate
  1648. * @param {Number} [samplesCount= 10]
  1649. * @param {Number} [min= 1000]
  1650. * @returns {Function}
  1651. */
  1652. function speedometer(samplesCount, min) {
  1653. samplesCount = samplesCount || 10;
  1654. var bytes = new Array(samplesCount);
  1655. var timestamps = new Array(samplesCount);
  1656. var head = 0;
  1657. var tail = 0;
  1658. var firstSampleTS;
  1659. min = min !== undefined ? min : 1000;
  1660. return function push(chunkLength) {
  1661. var now = Date.now();
  1662. var startedAt = timestamps[tail];
  1663. if (!firstSampleTS) {
  1664. firstSampleTS = now;
  1665. }
  1666. bytes[head] = chunkLength;
  1667. timestamps[head] = now;
  1668. var i = tail;
  1669. var bytesCount = 0;
  1670. while (i !== head) {
  1671. bytesCount += bytes[i++];
  1672. i = i % samplesCount;
  1673. }
  1674. head = (head + 1) % samplesCount;
  1675. if (head === tail) {
  1676. tail = (tail + 1) % samplesCount;
  1677. }
  1678. if (now - firstSampleTS < min) {
  1679. return;
  1680. }
  1681. var passed = startedAt && now - startedAt;
  1682. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  1683. };
  1684. }
  1685.  
  1686. function progressEventReducer(listener, isDownloadStream) {
  1687. var bytesNotified = 0;
  1688. var _speedometer = speedometer(50, 250);
  1689. return function (e) {
  1690. var loaded = e.loaded;
  1691. var total = e.lengthComputable ? e.total : undefined;
  1692. var progressBytes = loaded - bytesNotified;
  1693. var rate = _speedometer(progressBytes);
  1694. var inRange = loaded <= total;
  1695. bytesNotified = loaded;
  1696. var data = {
  1697. loaded: loaded,
  1698. total: total,
  1699. progress: total ? loaded / total : undefined,
  1700. bytes: progressBytes,
  1701. rate: rate ? rate : undefined,
  1702. estimated: rate && total && inRange ? (total - loaded) / rate : undefined
  1703. };
  1704. data[isDownloadStream ? 'download' : 'upload'] = true;
  1705. listener(data);
  1706. };
  1707. }
  1708. function xhrAdapter(config) {
  1709. return new Promise(function dispatchXhrRequest(resolve, reject) {
  1710. var requestData = config.data;
  1711. var requestHeaders = AxiosHeaders.from(config.headers).normalize();
  1712. var responseType = config.responseType;
  1713. var onCanceled;
  1714. function done() {
  1715. if (config.cancelToken) {
  1716. config.cancelToken.unsubscribe(onCanceled);
  1717. }
  1718. if (config.signal) {
  1719. config.signal.removeEventListener('abort', onCanceled);
  1720. }
  1721. }
  1722. if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
  1723. requestHeaders.setContentType(false); // Let the browser set it
  1724. }
  1725.  
  1726. var request = new XMLHttpRequest();
  1727.  
  1728. // HTTP basic authentication
  1729. if (config.auth) {
  1730. var username = config.auth.username || '';
  1731. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  1732. requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
  1733. }
  1734. var fullPath = buildFullPath(config.baseURL, config.url);
  1735. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  1736.  
  1737. // Set the request timeout in MS
  1738. request.timeout = config.timeout;
  1739. function onloadend() {
  1740. if (!request) {
  1741. return;
  1742. }
  1743. // Prepare the response
  1744. var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
  1745. var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
  1746. var response = {
  1747. data: responseData,
  1748. status: request.status,
  1749. statusText: request.statusText,
  1750. headers: responseHeaders,
  1751. config: config,
  1752. request: request
  1753. };
  1754. settle(function _resolve(value) {
  1755. resolve(value);
  1756. done();
  1757. }, function _reject(err) {
  1758. reject(err);
  1759. done();
  1760. }, response);
  1761.  
  1762. // Clean up request
  1763. request = null;
  1764. }
  1765. if ('onloadend' in request) {
  1766. // Use onloadend if available
  1767. request.onloadend = onloadend;
  1768. } else {
  1769. // Listen for ready state to emulate onloadend
  1770. request.onreadystatechange = function handleLoad() {
  1771. if (!request || request.readyState !== 4) {
  1772. return;
  1773. }
  1774.  
  1775. // The request errored out and we didn't get a response, this will be
  1776. // handled by onerror instead
  1777. // With one exception: request that using file: protocol, most browsers
  1778. // will return status as 0 even though it's a successful request
  1779. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  1780. return;
  1781. }
  1782. // readystate handler is calling before onerror or ontimeout handlers,
  1783. // so we should call onloadend on the next 'tick'
  1784. setTimeout(onloadend);
  1785. };
  1786. }
  1787.  
  1788. // Handle browser request cancellation (as opposed to a manual cancellation)
  1789. request.onabort = function handleAbort() {
  1790. if (!request) {
  1791. return;
  1792. }
  1793. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  1794.  
  1795. // Clean up request
  1796. request = null;
  1797. };
  1798.  
  1799. // Handle low level network errors
  1800. request.onerror = function handleError() {
  1801. // Real errors are hidden from us by the browser
  1802. // onerror should only fire if it's a network error
  1803. reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
  1804.  
  1805. // Clean up request
  1806. request = null;
  1807. };
  1808.  
  1809. // Handle timeout
  1810. request.ontimeout = function handleTimeout() {
  1811. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  1812. var transitional = config.transitional || transitionalDefaults;
  1813. if (config.timeoutErrorMessage) {
  1814. timeoutErrorMessage = config.timeoutErrorMessage;
  1815. }
  1816. reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
  1817.  
  1818. // Clean up request
  1819. request = null;
  1820. };
  1821.  
  1822. // Add xsrf header
  1823. // This is only done if running in a standard browser environment.
  1824. // Specifically not if we're in a web worker, or react-native.
  1825. if (platform.isStandardBrowserEnv) {
  1826. // Add xsrf header
  1827. var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
  1828. if (xsrfValue) {
  1829. requestHeaders.set(config.xsrfHeaderName, xsrfValue);
  1830. }
  1831. }
  1832.  
  1833. // Remove Content-Type if data is undefined
  1834. requestData === undefined && requestHeaders.setContentType(null);
  1835.  
  1836. // Add headers to the request
  1837. if ('setRequestHeader' in request) {
  1838. utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  1839. request.setRequestHeader(key, val);
  1840. });
  1841. }
  1842.  
  1843. // Add withCredentials to request if needed
  1844. if (!utils.isUndefined(config.withCredentials)) {
  1845. request.withCredentials = !!config.withCredentials;
  1846. }
  1847.  
  1848. // Add responseType to request if needed
  1849. if (responseType && responseType !== 'json') {
  1850. request.responseType = config.responseType;
  1851. }
  1852.  
  1853. // Handle progress if needed
  1854. if (typeof config.onDownloadProgress === 'function') {
  1855. request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
  1856. }
  1857.  
  1858. // Not all browsers support upload events
  1859. if (typeof config.onUploadProgress === 'function' && request.upload) {
  1860. request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
  1861. }
  1862. if (config.cancelToken || config.signal) {
  1863. // Handle cancellation
  1864. // eslint-disable-next-line func-names
  1865. onCanceled = function onCanceled(cancel) {
  1866. if (!request) {
  1867. return;
  1868. }
  1869. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  1870. request.abort();
  1871. request = null;
  1872. };
  1873. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  1874. if (config.signal) {
  1875. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  1876. }
  1877. }
  1878. var protocol = parseProtocol(fullPath);
  1879. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  1880. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  1881. return;
  1882. }
  1883.  
  1884. // Send the request
  1885. request.send(requestData || null);
  1886. });
  1887. }
  1888.  
  1889. var adapters = {
  1890. http: xhrAdapter,
  1891. xhr: xhrAdapter
  1892. };
  1893. var adapters$1 = {
  1894. getAdapter: function getAdapter(nameOrAdapter) {
  1895. if (utils.isString(nameOrAdapter)) {
  1896. var adapter = adapters[nameOrAdapter];
  1897. if (!nameOrAdapter) {
  1898. throw Error(utils.hasOwnProp(nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Can not resolve adapter '".concat(nameOrAdapter, "'"));
  1899. }
  1900. return adapter;
  1901. }
  1902. if (!utils.isFunction(nameOrAdapter)) {
  1903. throw new TypeError('adapter is not a function');
  1904. }
  1905. return nameOrAdapter;
  1906. },
  1907. adapters: adapters
  1908. };
  1909.  
  1910. var DEFAULT_CONTENT_TYPE = {
  1911. 'Content-Type': 'application/x-www-form-urlencoded'
  1912. };
  1913.  
  1914. /**
  1915. * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
  1916. * adapter
  1917. *
  1918. * @returns {Function}
  1919. */
  1920. function getDefaultAdapter() {
  1921. var adapter;
  1922. if (typeof XMLHttpRequest !== 'undefined') {
  1923. // For browsers use XHR adapter
  1924. adapter = adapters$1.getAdapter('xhr');
  1925. } else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
  1926. // For node use HTTP adapter
  1927. adapter = adapters$1.getAdapter('http');
  1928. }
  1929. return adapter;
  1930. }
  1931.  
  1932. /**
  1933. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1934. * of the input
  1935. *
  1936. * @param {any} rawValue - The value to be stringified.
  1937. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1938. * @param {Function} encoder - A function that takes a value and returns a string.
  1939. *
  1940. * @returns {string} A stringified version of the rawValue.
  1941. */
  1942. function stringifySafely(rawValue, parser, encoder) {
  1943. if (utils.isString(rawValue)) {
  1944. try {
  1945. (parser || JSON.parse)(rawValue);
  1946. return utils.trim(rawValue);
  1947. } catch (e) {
  1948. if (e.name !== 'SyntaxError') {
  1949. throw e;
  1950. }
  1951. }
  1952. }
  1953. return (encoder || JSON.stringify)(rawValue);
  1954. }
  1955. var defaults = {
  1956. transitional: transitionalDefaults,
  1957. adapter: getDefaultAdapter(),
  1958. transformRequest: [function transformRequest(data, headers) {
  1959. var contentType = headers.getContentType() || '';
  1960. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  1961. var isObjectPayload = utils.isObject(data);
  1962. if (isObjectPayload && utils.isHTMLForm(data)) {
  1963. data = new FormData(data);
  1964. }
  1965. var isFormData = utils.isFormData(data);
  1966. if (isFormData) {
  1967. if (!hasJSONContentType) {
  1968. return data;
  1969. }
  1970. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1971. }
  1972. if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
  1973. return data;
  1974. }
  1975. if (utils.isArrayBufferView(data)) {
  1976. return data.buffer;
  1977. }
  1978. if (utils.isURLSearchParams(data)) {
  1979. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1980. return data.toString();
  1981. }
  1982. var isFileList;
  1983. if (isObjectPayload) {
  1984. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1985. return toURLEncodedForm(data, this.formSerializer).toString();
  1986. }
  1987. if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1988. var _FormData = this.env && this.env.FormData;
  1989. return toFormData(isFileList ? {
  1990. 'files[]': data
  1991. } : data, _FormData && new _FormData(), this.formSerializer);
  1992. }
  1993. }
  1994. if (isObjectPayload || hasJSONContentType) {
  1995. headers.setContentType('application/json', false);
  1996. return stringifySafely(data);
  1997. }
  1998. return data;
  1999. }],
  2000. transformResponse: [function transformResponse(data) {
  2001. var transitional = this.transitional || defaults.transitional;
  2002. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  2003. var JSONRequested = this.responseType === 'json';
  2004. if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
  2005. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  2006. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  2007. try {
  2008. return JSON.parse(data);
  2009. } catch (e) {
  2010. if (strictJSONParsing) {
  2011. if (e.name === 'SyntaxError') {
  2012. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  2013. }
  2014. throw e;
  2015. }
  2016. }
  2017. }
  2018. return data;
  2019. }],
  2020. /**
  2021. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  2022. * timeout is not created.
  2023. */
  2024. timeout: 0,
  2025. xsrfCookieName: 'XSRF-TOKEN',
  2026. xsrfHeaderName: 'X-XSRF-TOKEN',
  2027. maxContentLength: -1,
  2028. maxBodyLength: -1,
  2029. env: {
  2030. FormData: platform.classes.FormData,
  2031. Blob: platform.classes.Blob
  2032. },
  2033. validateStatus: function validateStatus(status) {
  2034. return status >= 200 && status < 300;
  2035. },
  2036. headers: {
  2037. common: {
  2038. 'Accept': 'application/json, text/plain, */*'
  2039. }
  2040. }
  2041. };
  2042. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  2043. defaults.headers[method] = {};
  2044. });
  2045. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  2046. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  2047. });
  2048.  
  2049. /**
  2050. * Transform the data for a request or a response
  2051. *
  2052. * @param {Array|Function} fns A single function or Array of functions
  2053. * @param {?Object} response The response object
  2054. *
  2055. * @returns {*} The resulting transformed data
  2056. */
  2057. function transformData(fns, response) {
  2058. var config = this || defaults;
  2059. var context = response || config;
  2060. var headers = AxiosHeaders.from(context.headers);
  2061. var data = context.data;
  2062. utils.forEach(fns, function transform(fn) {
  2063. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  2064. });
  2065. headers.normalize();
  2066. return data;
  2067. }
  2068.  
  2069. function isCancel(value) {
  2070. return !!(value && value.__CANCEL__);
  2071. }
  2072.  
  2073. /**
  2074. * Throws a `CanceledError` if cancellation has been requested.
  2075. *
  2076. * @param {Object} config The config that is to be used for the request
  2077. *
  2078. * @returns {void}
  2079. */
  2080. function throwIfCancellationRequested(config) {
  2081. if (config.cancelToken) {
  2082. config.cancelToken.throwIfRequested();
  2083. }
  2084. if (config.signal && config.signal.aborted) {
  2085. throw new CanceledError();
  2086. }
  2087. }
  2088.  
  2089. /**
  2090. * Dispatch a request to the server using the configured adapter.
  2091. *
  2092. * @param {object} config The config that is to be used for the request
  2093. *
  2094. * @returns {Promise} The Promise to be fulfilled
  2095. */
  2096. function dispatchRequest(config) {
  2097. throwIfCancellationRequested(config);
  2098. config.headers = AxiosHeaders.from(config.headers);
  2099.  
  2100. // Transform request data
  2101. config.data = transformData.call(config, config.transformRequest);
  2102. var adapter = config.adapter || defaults.adapter;
  2103. return adapter(config).then(function onAdapterResolution(response) {
  2104. throwIfCancellationRequested(config);
  2105.  
  2106. // Transform response data
  2107. response.data = transformData.call(config, config.transformResponse, response);
  2108. response.headers = AxiosHeaders.from(response.headers);
  2109. return response;
  2110. }, function onAdapterRejection(reason) {
  2111. if (!isCancel(reason)) {
  2112. throwIfCancellationRequested(config);
  2113.  
  2114. // Transform response data
  2115. if (reason && reason.response) {
  2116. reason.response.data = transformData.call(config, config.transformResponse, reason.response);
  2117. reason.response.headers = AxiosHeaders.from(reason.response.headers);
  2118. }
  2119. }
  2120. return Promise.reject(reason);
  2121. });
  2122. }
  2123.  
  2124. /**
  2125. * Config-specific merge-function which creates a new config-object
  2126. * by merging two configuration objects together.
  2127. *
  2128. * @param {Object} config1
  2129. * @param {Object} config2
  2130. *
  2131. * @returns {Object} New object resulting from merging config2 to config1
  2132. */
  2133. function mergeConfig(config1, config2) {
  2134. // eslint-disable-next-line no-param-reassign
  2135. config2 = config2 || {};
  2136. var config = {};
  2137. function getMergedValue(target, source) {
  2138. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  2139. return utils.merge(target, source);
  2140. } else if (utils.isPlainObject(source)) {
  2141. return utils.merge({}, source);
  2142. } else if (utils.isArray(source)) {
  2143. return source.slice();
  2144. }
  2145. return source;
  2146. }
  2147.  
  2148. // eslint-disable-next-line consistent-return
  2149. function mergeDeepProperties(prop) {
  2150. if (!utils.isUndefined(config2[prop])) {
  2151. return getMergedValue(config1[prop], config2[prop]);
  2152. } else if (!utils.isUndefined(config1[prop])) {
  2153. return getMergedValue(undefined, config1[prop]);
  2154. }
  2155. }
  2156.  
  2157. // eslint-disable-next-line consistent-return
  2158. function valueFromConfig2(prop) {
  2159. if (!utils.isUndefined(config2[prop])) {
  2160. return getMergedValue(undefined, config2[prop]);
  2161. }
  2162. }
  2163.  
  2164. // eslint-disable-next-line consistent-return
  2165. function defaultToConfig2(prop) {
  2166. if (!utils.isUndefined(config2[prop])) {
  2167. return getMergedValue(undefined, config2[prop]);
  2168. } else if (!utils.isUndefined(config1[prop])) {
  2169. return getMergedValue(undefined, config1[prop]);
  2170. }
  2171. }
  2172.  
  2173. // eslint-disable-next-line consistent-return
  2174. function mergeDirectKeys(prop) {
  2175. if (prop in config2) {
  2176. return getMergedValue(config1[prop], config2[prop]);
  2177. } else if (prop in config1) {
  2178. return getMergedValue(undefined, config1[prop]);
  2179. }
  2180. }
  2181. var mergeMap = {
  2182. 'url': valueFromConfig2,
  2183. 'method': valueFromConfig2,
  2184. 'data': valueFromConfig2,
  2185. 'baseURL': defaultToConfig2,
  2186. 'transformRequest': defaultToConfig2,
  2187. 'transformResponse': defaultToConfig2,
  2188. 'paramsSerializer': defaultToConfig2,
  2189. 'timeout': defaultToConfig2,
  2190. 'timeoutMessage': defaultToConfig2,
  2191. 'withCredentials': defaultToConfig2,
  2192. 'adapter': defaultToConfig2,
  2193. 'responseType': defaultToConfig2,
  2194. 'xsrfCookieName': defaultToConfig2,
  2195. 'xsrfHeaderName': defaultToConfig2,
  2196. 'onUploadProgress': defaultToConfig2,
  2197. 'onDownloadProgress': defaultToConfig2,
  2198. 'decompress': defaultToConfig2,
  2199. 'maxContentLength': defaultToConfig2,
  2200. 'maxBodyLength': defaultToConfig2,
  2201. 'beforeRedirect': defaultToConfig2,
  2202. 'transport': defaultToConfig2,
  2203. 'httpAgent': defaultToConfig2,
  2204. 'httpsAgent': defaultToConfig2,
  2205. 'cancelToken': defaultToConfig2,
  2206. 'socketPath': defaultToConfig2,
  2207. 'responseEncoding': defaultToConfig2,
  2208. 'validateStatus': mergeDirectKeys
  2209. };
  2210. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  2211. var merge = mergeMap[prop] || mergeDeepProperties;
  2212. var configValue = merge(prop);
  2213. utils.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
  2214. });
  2215. return config;
  2216. }
  2217.  
  2218. var VERSION = "1.1.3";
  2219.  
  2220. var validators$1 = {};
  2221.  
  2222. // eslint-disable-next-line func-names
  2223. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
  2224. validators$1[type] = function validator(thing) {
  2225. return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  2226. };
  2227. });
  2228. var deprecatedWarnings = {};
  2229.  
  2230. /**
  2231. * Transitional option validator
  2232. *
  2233. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  2234. * @param {string?} version - deprecated version / removed since version
  2235. * @param {string?} message - some message with additional info
  2236. *
  2237. * @returns {function}
  2238. */
  2239. validators$1.transitional = function transitional(validator, version, message) {
  2240. function formatMessage(opt, desc) {
  2241. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  2242. }
  2243.  
  2244. // eslint-disable-next-line func-names
  2245. return function (value, opt, opts) {
  2246. if (validator === false) {
  2247. throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
  2248. }
  2249. if (version && !deprecatedWarnings[opt]) {
  2250. deprecatedWarnings[opt] = true;
  2251. // eslint-disable-next-line no-console
  2252. console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
  2253. }
  2254. return validator ? validator(value, opt, opts) : true;
  2255. };
  2256. };
  2257.  
  2258. /**
  2259. * Assert object's properties type
  2260. *
  2261. * @param {object} options
  2262. * @param {object} schema
  2263. * @param {boolean?} allowUnknown
  2264. *
  2265. * @returns {object}
  2266. */
  2267.  
  2268. function assertOptions(options, schema, allowUnknown) {
  2269. if (_typeof(options) !== 'object') {
  2270. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  2271. }
  2272. var keys = Object.keys(options);
  2273. var i = keys.length;
  2274. while (i-- > 0) {
  2275. var opt = keys[i];
  2276. var validator = schema[opt];
  2277. if (validator) {
  2278. var value = options[opt];
  2279. var result = value === undefined || validator(value, opt, options);
  2280. if (result !== true) {
  2281. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  2282. }
  2283. continue;
  2284. }
  2285. if (allowUnknown !== true) {
  2286. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  2287. }
  2288. }
  2289. }
  2290. var validator = {
  2291. assertOptions: assertOptions,
  2292. validators: validators$1
  2293. };
  2294.  
  2295. var validators = validator.validators;
  2296.  
  2297. /**
  2298. * Create a new instance of Axios
  2299. *
  2300. * @param {Object} instanceConfig The default config for the instance
  2301. *
  2302. * @return {Axios} A new instance of Axios
  2303. */
  2304. var Axios = /*#__PURE__*/function () {
  2305. function Axios(instanceConfig) {
  2306. _classCallCheck(this, Axios);
  2307. this.defaults = instanceConfig;
  2308. this.interceptors = {
  2309. request: new InterceptorManager(),
  2310. response: new InterceptorManager()
  2311. };
  2312. }
  2313.  
  2314. /**
  2315. * Dispatch a request
  2316. *
  2317. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  2318. * @param {?Object} config
  2319. *
  2320. * @returns {Promise} The Promise to be fulfilled
  2321. */
  2322. _createClass(Axios, [{
  2323. key: "request",
  2324. value: function request(configOrUrl, config) {
  2325. /*eslint no-param-reassign:0*/
  2326. // Allow for axios('example/url'[, config]) a la fetch API
  2327. if (typeof configOrUrl === 'string') {
  2328. config = config || {};
  2329. config.url = configOrUrl;
  2330. } else {
  2331. config = configOrUrl || {};
  2332. }
  2333. config = mergeConfig(this.defaults, config);
  2334. var _config = config,
  2335. transitional = _config.transitional,
  2336. paramsSerializer = _config.paramsSerializer;
  2337. if (transitional !== undefined) {
  2338. validator.assertOptions(transitional, {
  2339. silentJSONParsing: validators.transitional(validators["boolean"]),
  2340. forcedJSONParsing: validators.transitional(validators["boolean"]),
  2341. clarifyTimeoutError: validators.transitional(validators["boolean"])
  2342. }, false);
  2343. }
  2344. if (paramsSerializer !== undefined) {
  2345. validator.assertOptions(paramsSerializer, {
  2346. encode: validators["function"],
  2347. serialize: validators["function"]
  2348. }, true);
  2349. }
  2350.  
  2351. // Set config.method
  2352. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  2353.  
  2354. // Flatten headers
  2355. var defaultHeaders = config.headers && utils.merge(config.headers.common, config.headers[config.method]);
  2356. defaultHeaders && utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) {
  2357. delete config.headers[method];
  2358. });
  2359. config.headers = new AxiosHeaders(config.headers, defaultHeaders);
  2360.  
  2361. // filter out skipped interceptors
  2362. var requestInterceptorChain = [];
  2363. var synchronousRequestInterceptors = true;
  2364. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  2365. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  2366. return;
  2367. }
  2368. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  2369. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  2370. });
  2371. var responseInterceptorChain = [];
  2372. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  2373. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  2374. });
  2375. var promise;
  2376. var i = 0;
  2377. var len;
  2378. if (!synchronousRequestInterceptors) {
  2379. var chain = [dispatchRequest.bind(this), undefined];
  2380. chain.unshift.apply(chain, requestInterceptorChain);
  2381. chain.push.apply(chain, responseInterceptorChain);
  2382. len = chain.length;
  2383. promise = Promise.resolve(config);
  2384. while (i < len) {
  2385. promise = promise.then(chain[i++], chain[i++]);
  2386. }
  2387. return promise;
  2388. }
  2389. len = requestInterceptorChain.length;
  2390. var newConfig = config;
  2391. i = 0;
  2392. while (i < len) {
  2393. var onFulfilled = requestInterceptorChain[i++];
  2394. var onRejected = requestInterceptorChain[i++];
  2395. try {
  2396. newConfig = onFulfilled(newConfig);
  2397. } catch (error) {
  2398. onRejected.call(this, error);
  2399. break;
  2400. }
  2401. }
  2402. try {
  2403. promise = dispatchRequest.call(this, newConfig);
  2404. } catch (error) {
  2405. return Promise.reject(error);
  2406. }
  2407. i = 0;
  2408. len = responseInterceptorChain.length;
  2409. while (i < len) {
  2410. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  2411. }
  2412. return promise;
  2413. }
  2414. }, {
  2415. key: "getUri",
  2416. value: function getUri(config) {
  2417. config = mergeConfig(this.defaults, config);
  2418. var fullPath = buildFullPath(config.baseURL, config.url);
  2419. return buildURL(fullPath, config.params, config.paramsSerializer);
  2420. }
  2421. }]);
  2422. return Axios;
  2423. }(); // Provide aliases for supported request methods
  2424. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  2425. /*eslint func-names:0*/
  2426. Axios.prototype[method] = function (url, config) {
  2427. return this.request(mergeConfig(config || {}, {
  2428. method: method,
  2429. url: url,
  2430. data: (config || {}).data
  2431. }));
  2432. };
  2433. });
  2434. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  2435. /*eslint func-names:0*/
  2436.  
  2437. function generateHTTPMethod(isForm) {
  2438. return function httpMethod(url, data, config) {
  2439. return this.request(mergeConfig(config || {}, {
  2440. method: method,
  2441. headers: isForm ? {
  2442. 'Content-Type': 'multipart/form-data'
  2443. } : {},
  2444. url: url,
  2445. data: data
  2446. }));
  2447. };
  2448. }
  2449. Axios.prototype[method] = generateHTTPMethod();
  2450. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  2451. });
  2452.  
  2453. /**
  2454. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  2455. *
  2456. * @param {Function} executor The executor function.
  2457. *
  2458. * @returns {CancelToken}
  2459. */
  2460. var CancelToken = /*#__PURE__*/function () {
  2461. function CancelToken(executor) {
  2462. _classCallCheck(this, CancelToken);
  2463. if (typeof executor !== 'function') {
  2464. throw new TypeError('executor must be a function.');
  2465. }
  2466. var resolvePromise;
  2467. this.promise = new Promise(function promiseExecutor(resolve) {
  2468. resolvePromise = resolve;
  2469. });
  2470. var token = this;
  2471.  
  2472. // eslint-disable-next-line func-names
  2473. this.promise.then(function (cancel) {
  2474. if (!token._listeners) return;
  2475. var i = token._listeners.length;
  2476. while (i-- > 0) {
  2477. token._listeners[i](cancel);
  2478. }
  2479. token._listeners = null;
  2480. });
  2481.  
  2482. // eslint-disable-next-line func-names
  2483. this.promise.then = function (onfulfilled) {
  2484. var _resolve;
  2485. // eslint-disable-next-line func-names
  2486. var promise = new Promise(function (resolve) {
  2487. token.subscribe(resolve);
  2488. _resolve = resolve;
  2489. }).then(onfulfilled);
  2490. promise.cancel = function reject() {
  2491. token.unsubscribe(_resolve);
  2492. };
  2493. return promise;
  2494. };
  2495. executor(function cancel(message, config, request) {
  2496. if (token.reason) {
  2497. // Cancellation has already been requested
  2498. return;
  2499. }
  2500. token.reason = new CanceledError(message, config, request);
  2501. resolvePromise(token.reason);
  2502. });
  2503. }
  2504.  
  2505. /**
  2506. * Throws a `CanceledError` if cancellation has been requested.
  2507. */
  2508. _createClass(CancelToken, [{
  2509. key: "throwIfRequested",
  2510. value: function throwIfRequested() {
  2511. if (this.reason) {
  2512. throw this.reason;
  2513. }
  2514. }
  2515.  
  2516. /**
  2517. * Subscribe to the cancel signal
  2518. */
  2519. }, {
  2520. key: "subscribe",
  2521. value: function subscribe(listener) {
  2522. if (this.reason) {
  2523. listener(this.reason);
  2524. return;
  2525. }
  2526. if (this._listeners) {
  2527. this._listeners.push(listener);
  2528. } else {
  2529. this._listeners = [listener];
  2530. }
  2531. }
  2532.  
  2533. /**
  2534. * Unsubscribe from the cancel signal
  2535. */
  2536. }, {
  2537. key: "unsubscribe",
  2538. value: function unsubscribe(listener) {
  2539. if (!this._listeners) {
  2540. return;
  2541. }
  2542. var index = this._listeners.indexOf(listener);
  2543. if (index !== -1) {
  2544. this._listeners.splice(index, 1);
  2545. }
  2546. }
  2547.  
  2548. /**
  2549. * Returns an object that contains a new `CancelToken` and a function that, when called,
  2550. * cancels the `CancelToken`.
  2551. */
  2552. }], [{
  2553. key: "source",
  2554. value: function source() {
  2555. var cancel;
  2556. var token = new CancelToken(function executor(c) {
  2557. cancel = c;
  2558. });
  2559. return {
  2560. token: token,
  2561. cancel: cancel
  2562. };
  2563. }
  2564. }]);
  2565. return CancelToken;
  2566. }();
  2567.  
  2568. /**
  2569. * Syntactic sugar for invoking a function and expanding an array for arguments.
  2570. *
  2571. * Common use case would be to use `Function.prototype.apply`.
  2572. *
  2573. * ```js
  2574. * function f(x, y, z) {}
  2575. * var args = [1, 2, 3];
  2576. * f.apply(null, args);
  2577. * ```
  2578. *
  2579. * With `spread` this example can be re-written.
  2580. *
  2581. * ```js
  2582. * spread(function(x, y, z) {})([1, 2, 3]);
  2583. * ```
  2584. *
  2585. * @param {Function} callback
  2586. *
  2587. * @returns {Function}
  2588. */
  2589. function spread(callback) {
  2590. return function wrap(arr) {
  2591. return callback.apply(null, arr);
  2592. };
  2593. }
  2594.  
  2595. /**
  2596. * Determines whether the payload is an error thrown by Axios
  2597. *
  2598. * @param {*} payload The value to test
  2599. *
  2600. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  2601. */
  2602. function isAxiosError(payload) {
  2603. return utils.isObject(payload) && payload.isAxiosError === true;
  2604. }
  2605.  
  2606. /**
  2607. * Create an instance of Axios
  2608. *
  2609. * @param {Object} defaultConfig The default config for the instance
  2610. *
  2611. * @returns {Axios} A new instance of Axios
  2612. */
  2613. function createInstance(defaultConfig) {
  2614. var context = new Axios(defaultConfig);
  2615. var instance = bind(Axios.prototype.request, context);
  2616.  
  2617. // Copy axios.prototype to instance
  2618. utils.extend(instance, Axios.prototype, context, {
  2619. allOwnKeys: true
  2620. });
  2621.  
  2622. // Copy context to instance
  2623. utils.extend(instance, context, null, {
  2624. allOwnKeys: true
  2625. });
  2626.  
  2627. // Factory for creating new instances
  2628. instance.create = function create(instanceConfig) {
  2629. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  2630. };
  2631. return instance;
  2632. }
  2633.  
  2634. // Create the default instance to be exported
  2635. var axios = createInstance(defaults);
  2636.  
  2637. // Expose Axios class to allow class inheritance
  2638. axios.Axios = Axios;
  2639.  
  2640. // Expose Cancel & CancelToken
  2641. axios.CanceledError = CanceledError;
  2642. axios.CancelToken = CancelToken;
  2643. axios.isCancel = isCancel;
  2644. axios.VERSION = VERSION;
  2645. axios.toFormData = toFormData;
  2646.  
  2647. // Expose AxiosError class
  2648. axios.AxiosError = AxiosError;
  2649.  
  2650. // alias for CanceledError for backward compatibility
  2651. axios.Cancel = axios.CanceledError;
  2652.  
  2653. // Expose all/spread
  2654. axios.all = function all(promises) {
  2655. return Promise.all(promises);
  2656. };
  2657. axios.spread = spread;
  2658.  
  2659. // Expose isAxiosError
  2660. axios.isAxiosError = isAxiosError;
  2661. axios.formToJSON = function (thing) {
  2662. return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
  2663. };
  2664.  
  2665. return axios;
  2666.  
  2667. }));
  2668. //# sourceMappingURL=axios.js.map