| 1 | /*! Axios v1.16.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|---|
| 2 | (function (global, factory) {
|
|---|
| 3 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|---|
| 4 | typeof define === 'function' && define.amd ? define(factory) :
|
|---|
| 5 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
|
|---|
| 6 | })(this, (function () { 'use strict';
|
|---|
| 7 |
|
|---|
| 8 | function _OverloadYield(e, d) {
|
|---|
| 9 | this.v = e, this.k = d;
|
|---|
| 10 | }
|
|---|
| 11 | function _arrayLikeToArray(r, a) {
|
|---|
| 12 | (null == a || a > r.length) && (a = r.length);
|
|---|
| 13 | for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|---|
| 14 | return n;
|
|---|
| 15 | }
|
|---|
| 16 | function _arrayWithHoles(r) {
|
|---|
| 17 | if (Array.isArray(r)) return r;
|
|---|
| 18 | }
|
|---|
| 19 | function _arrayWithoutHoles(r) {
|
|---|
| 20 | if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|---|
| 21 | }
|
|---|
| 22 | function _assertThisInitialized(e) {
|
|---|
| 23 | if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|---|
| 24 | return e;
|
|---|
| 25 | }
|
|---|
| 26 | function _asyncGeneratorDelegate(t) {
|
|---|
| 27 | var e = {},
|
|---|
| 28 | n = false;
|
|---|
| 29 | function pump(e, r) {
|
|---|
| 30 | return n = true, r = new Promise(function (n) {
|
|---|
| 31 | n(t[e](r));
|
|---|
| 32 | }), {
|
|---|
| 33 | done: false,
|
|---|
| 34 | value: new _OverloadYield(r, 1)
|
|---|
| 35 | };
|
|---|
| 36 | }
|
|---|
| 37 | return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () {
|
|---|
| 38 | return this;
|
|---|
| 39 | }, e.next = function (t) {
|
|---|
| 40 | return n ? (n = false, t) : pump("next", t);
|
|---|
| 41 | }, "function" == typeof t.throw && (e.throw = function (t) {
|
|---|
| 42 | if (n) throw n = false, t;
|
|---|
| 43 | return pump("throw", t);
|
|---|
| 44 | }), "function" == typeof t.return && (e.return = function (t) {
|
|---|
| 45 | return n ? (n = false, t) : pump("return", t);
|
|---|
| 46 | }), e;
|
|---|
| 47 | }
|
|---|
| 48 | function _asyncIterator(r) {
|
|---|
| 49 | var n,
|
|---|
| 50 | t,
|
|---|
| 51 | o,
|
|---|
| 52 | e = 2;
|
|---|
| 53 | for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
|---|
| 54 | if (t && null != (n = r[t])) return n.call(r);
|
|---|
| 55 | if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|---|
| 56 | t = "@@asyncIterator", o = "@@iterator";
|
|---|
| 57 | }
|
|---|
| 58 | throw new TypeError("Object is not async iterable");
|
|---|
| 59 | }
|
|---|
| 60 | function AsyncFromSyncIterator(r) {
|
|---|
| 61 | function AsyncFromSyncIteratorContinuation(r) {
|
|---|
| 62 | if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
|
|---|
| 63 | var n = r.done;
|
|---|
| 64 | return Promise.resolve(r.value).then(function (r) {
|
|---|
| 65 | return {
|
|---|
| 66 | value: r,
|
|---|
| 67 | done: n
|
|---|
| 68 | };
|
|---|
| 69 | });
|
|---|
| 70 | }
|
|---|
| 71 | return AsyncFromSyncIterator = function (r) {
|
|---|
| 72 | this.s = r, this.n = r.next;
|
|---|
| 73 | }, AsyncFromSyncIterator.prototype = {
|
|---|
| 74 | s: null,
|
|---|
| 75 | n: null,
|
|---|
| 76 | next: function () {
|
|---|
| 77 | return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|---|
| 78 | },
|
|---|
| 79 | return: function (r) {
|
|---|
| 80 | var n = this.s.return;
|
|---|
| 81 | return void 0 === n ? Promise.resolve({
|
|---|
| 82 | value: r,
|
|---|
| 83 | done: true
|
|---|
| 84 | }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|---|
| 85 | },
|
|---|
| 86 | throw: function (r) {
|
|---|
| 87 | var n = this.s.return;
|
|---|
| 88 | return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|---|
| 89 | }
|
|---|
| 90 | }, new AsyncFromSyncIterator(r);
|
|---|
| 91 | }
|
|---|
| 92 | function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|---|
| 93 | try {
|
|---|
| 94 | var i = n[a](c),
|
|---|
| 95 | u = i.value;
|
|---|
| 96 | } catch (n) {
|
|---|
| 97 | return void e(n);
|
|---|
| 98 | }
|
|---|
| 99 | i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|---|
| 100 | }
|
|---|
| 101 | function _asyncToGenerator(n) {
|
|---|
| 102 | return function () {
|
|---|
| 103 | var t = this,
|
|---|
| 104 | e = arguments;
|
|---|
| 105 | return new Promise(function (r, o) {
|
|---|
| 106 | var a = n.apply(t, e);
|
|---|
| 107 | function _next(n) {
|
|---|
| 108 | asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|---|
| 109 | }
|
|---|
| 110 | function _throw(n) {
|
|---|
| 111 | asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|---|
| 112 | }
|
|---|
| 113 | _next(void 0);
|
|---|
| 114 | });
|
|---|
| 115 | };
|
|---|
| 116 | }
|
|---|
| 117 | function _awaitAsyncGenerator(e) {
|
|---|
| 118 | return new _OverloadYield(e, 0);
|
|---|
| 119 | }
|
|---|
| 120 | function _callSuper(t, o, e) {
|
|---|
| 121 | return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|---|
| 122 | }
|
|---|
| 123 | function _classCallCheck(a, n) {
|
|---|
| 124 | if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|---|
| 125 | }
|
|---|
| 126 | function _construct(t, e, r) {
|
|---|
| 127 | if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|---|
| 128 | var o = [null];
|
|---|
| 129 | o.push.apply(o, e);
|
|---|
| 130 | var p = new (t.bind.apply(t, o))();
|
|---|
| 131 | return r && _setPrototypeOf(p, r.prototype), p;
|
|---|
| 132 | }
|
|---|
| 133 | function _defineProperties(e, r) {
|
|---|
| 134 | for (var t = 0; t < r.length; t++) {
|
|---|
| 135 | var o = r[t];
|
|---|
| 136 | o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|---|
| 137 | }
|
|---|
| 138 | }
|
|---|
| 139 | function _createClass(e, r, t) {
|
|---|
| 140 | return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|---|
| 141 | writable: false
|
|---|
| 142 | }), e;
|
|---|
| 143 | }
|
|---|
| 144 | function _createForOfIteratorHelper(r, e) {
|
|---|
| 145 | var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|---|
| 146 | if (!t) {
|
|---|
| 147 | if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|---|
| 148 | t && (r = t);
|
|---|
| 149 | var n = 0,
|
|---|
| 150 | F = function () {};
|
|---|
| 151 | return {
|
|---|
| 152 | s: F,
|
|---|
| 153 | n: function () {
|
|---|
| 154 | return n >= r.length ? {
|
|---|
| 155 | done: true
|
|---|
| 156 | } : {
|
|---|
| 157 | done: false,
|
|---|
| 158 | value: r[n++]
|
|---|
| 159 | };
|
|---|
| 160 | },
|
|---|
| 161 | e: function (r) {
|
|---|
| 162 | throw r;
|
|---|
| 163 | },
|
|---|
| 164 | f: F
|
|---|
| 165 | };
|
|---|
| 166 | }
|
|---|
| 167 | throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|---|
| 168 | }
|
|---|
| 169 | var o,
|
|---|
| 170 | a = true,
|
|---|
| 171 | u = false;
|
|---|
| 172 | return {
|
|---|
| 173 | s: function () {
|
|---|
| 174 | t = t.call(r);
|
|---|
| 175 | },
|
|---|
| 176 | n: function () {
|
|---|
| 177 | var r = t.next();
|
|---|
| 178 | return a = r.done, r;
|
|---|
| 179 | },
|
|---|
| 180 | e: function (r) {
|
|---|
| 181 | u = true, o = r;
|
|---|
| 182 | },
|
|---|
| 183 | f: function () {
|
|---|
| 184 | try {
|
|---|
| 185 | a || null == t.return || t.return();
|
|---|
| 186 | } finally {
|
|---|
| 187 | if (u) throw o;
|
|---|
| 188 | }
|
|---|
| 189 | }
|
|---|
| 190 | };
|
|---|
| 191 | }
|
|---|
| 192 | function _defineProperty(e, r, t) {
|
|---|
| 193 | return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|---|
| 194 | value: t,
|
|---|
| 195 | enumerable: true,
|
|---|
| 196 | configurable: true,
|
|---|
| 197 | writable: true
|
|---|
| 198 | }) : e[r] = t, e;
|
|---|
| 199 | }
|
|---|
| 200 | function _getPrototypeOf(t) {
|
|---|
| 201 | return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|---|
| 202 | return t.__proto__ || Object.getPrototypeOf(t);
|
|---|
| 203 | }, _getPrototypeOf(t);
|
|---|
| 204 | }
|
|---|
| 205 | function _inherits(t, e) {
|
|---|
| 206 | if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|---|
| 207 | t.prototype = Object.create(e && e.prototype, {
|
|---|
| 208 | constructor: {
|
|---|
| 209 | value: t,
|
|---|
| 210 | writable: true,
|
|---|
| 211 | configurable: true
|
|---|
| 212 | }
|
|---|
| 213 | }), Object.defineProperty(t, "prototype", {
|
|---|
| 214 | writable: false
|
|---|
| 215 | }), e && _setPrototypeOf(t, e);
|
|---|
| 216 | }
|
|---|
| 217 | function _isNativeFunction(t) {
|
|---|
| 218 | try {
|
|---|
| 219 | return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|---|
| 220 | } catch (n) {
|
|---|
| 221 | return "function" == typeof t;
|
|---|
| 222 | }
|
|---|
| 223 | }
|
|---|
| 224 | function _isNativeReflectConstruct() {
|
|---|
| 225 | try {
|
|---|
| 226 | var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|---|
| 227 | } catch (t) {}
|
|---|
| 228 | return (_isNativeReflectConstruct = function () {
|
|---|
| 229 | return !!t;
|
|---|
| 230 | })();
|
|---|
| 231 | }
|
|---|
| 232 | function _iterableToArray(r) {
|
|---|
| 233 | if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|---|
| 234 | }
|
|---|
| 235 | function _iterableToArrayLimit(r, l) {
|
|---|
| 236 | var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|---|
| 237 | if (null != t) {
|
|---|
| 238 | var e,
|
|---|
| 239 | n,
|
|---|
| 240 | i,
|
|---|
| 241 | u,
|
|---|
| 242 | a = [],
|
|---|
| 243 | f = true,
|
|---|
| 244 | o = false;
|
|---|
| 245 | try {
|
|---|
| 246 | if (i = (t = t.call(r)).next, 0 === l) {
|
|---|
| 247 | if (Object(t) !== t) return;
|
|---|
| 248 | f = !1;
|
|---|
| 249 | } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|---|
| 250 | } catch (r) {
|
|---|
| 251 | o = true, n = r;
|
|---|
| 252 | } finally {
|
|---|
| 253 | try {
|
|---|
| 254 | if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|---|
| 255 | } finally {
|
|---|
| 256 | if (o) throw n;
|
|---|
| 257 | }
|
|---|
| 258 | }
|
|---|
| 259 | return a;
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | function _nonIterableRest() {
|
|---|
| 263 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|---|
| 264 | }
|
|---|
| 265 | function _nonIterableSpread() {
|
|---|
| 266 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|---|
| 267 | }
|
|---|
| 268 | function ownKeys(e, r) {
|
|---|
| 269 | var t = Object.keys(e);
|
|---|
| 270 | if (Object.getOwnPropertySymbols) {
|
|---|
| 271 | var o = Object.getOwnPropertySymbols(e);
|
|---|
| 272 | r && (o = o.filter(function (r) {
|
|---|
| 273 | return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|---|
| 274 | })), t.push.apply(t, o);
|
|---|
| 275 | }
|
|---|
| 276 | return t;
|
|---|
| 277 | }
|
|---|
| 278 | function _objectSpread2(e) {
|
|---|
| 279 | for (var r = 1; r < arguments.length; r++) {
|
|---|
| 280 | var t = null != arguments[r] ? arguments[r] : {};
|
|---|
| 281 | r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|---|
| 282 | _defineProperty(e, r, t[r]);
|
|---|
| 283 | }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|---|
| 284 | Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|---|
| 285 | });
|
|---|
| 286 | }
|
|---|
| 287 | return e;
|
|---|
| 288 | }
|
|---|
| 289 | function _possibleConstructorReturn(t, e) {
|
|---|
| 290 | if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|---|
| 291 | if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|---|
| 292 | return _assertThisInitialized(t);
|
|---|
| 293 | }
|
|---|
| 294 | function _regenerator() {
|
|---|
| 295 | /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|---|
| 296 | var e,
|
|---|
| 297 | t,
|
|---|
| 298 | r = "function" == typeof Symbol ? Symbol : {},
|
|---|
| 299 | n = r.iterator || "@@iterator",
|
|---|
| 300 | o = r.toStringTag || "@@toStringTag";
|
|---|
| 301 | function i(r, n, o, i) {
|
|---|
| 302 | var c = n && n.prototype instanceof Generator ? n : Generator,
|
|---|
| 303 | u = Object.create(c.prototype);
|
|---|
| 304 | return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|---|
| 305 | var i,
|
|---|
| 306 | c,
|
|---|
| 307 | u,
|
|---|
| 308 | f = 0,
|
|---|
| 309 | p = o || [],
|
|---|
| 310 | y = false,
|
|---|
| 311 | G = {
|
|---|
| 312 | p: 0,
|
|---|
| 313 | n: 0,
|
|---|
| 314 | v: e,
|
|---|
| 315 | a: d,
|
|---|
| 316 | f: d.bind(e, 4),
|
|---|
| 317 | d: function (t, r) {
|
|---|
| 318 | return i = t, c = 0, u = e, G.n = r, a;
|
|---|
| 319 | }
|
|---|
| 320 | };
|
|---|
| 321 | function d(r, n) {
|
|---|
| 322 | for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|---|
| 323 | var o,
|
|---|
| 324 | i = p[t],
|
|---|
| 325 | d = G.p,
|
|---|
| 326 | l = i[2];
|
|---|
| 327 | r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|---|
| 328 | }
|
|---|
| 329 | if (o || r > 1) return a;
|
|---|
| 330 | throw y = true, n;
|
|---|
| 331 | }
|
|---|
| 332 | return function (o, p, l) {
|
|---|
| 333 | if (f > 1) throw TypeError("Generator is already running");
|
|---|
| 334 | for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|---|
| 335 | i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|---|
| 336 | try {
|
|---|
| 337 | if (f = 2, i) {
|
|---|
| 338 | if (c || (o = "next"), t = i[o]) {
|
|---|
| 339 | if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|---|
| 340 | if (!t.done) return t;
|
|---|
| 341 | u = t.value, c < 2 && (c = 0);
|
|---|
| 342 | } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|---|
| 343 | i = e;
|
|---|
| 344 | } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|---|
| 345 | } catch (t) {
|
|---|
| 346 | i = e, c = 1, u = t;
|
|---|
| 347 | } finally {
|
|---|
| 348 | f = 1;
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 | return {
|
|---|
| 352 | value: t,
|
|---|
| 353 | done: y
|
|---|
| 354 | };
|
|---|
| 355 | };
|
|---|
| 356 | }(r, o, i), true), u;
|
|---|
| 357 | }
|
|---|
| 358 | var a = {};
|
|---|
| 359 | function Generator() {}
|
|---|
| 360 | function GeneratorFunction() {}
|
|---|
| 361 | function GeneratorFunctionPrototype() {}
|
|---|
| 362 | t = Object.getPrototypeOf;
|
|---|
| 363 | var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|---|
| 364 | return this;
|
|---|
| 365 | }), t),
|
|---|
| 366 | u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|---|
| 367 | function f(e) {
|
|---|
| 368 | return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|---|
| 369 | }
|
|---|
| 370 | return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|---|
| 371 | return this;
|
|---|
| 372 | }), _regeneratorDefine(u, "toString", function () {
|
|---|
| 373 | return "[object Generator]";
|
|---|
| 374 | }), (_regenerator = function () {
|
|---|
| 375 | return {
|
|---|
| 376 | w: i,
|
|---|
| 377 | m: f
|
|---|
| 378 | };
|
|---|
| 379 | })();
|
|---|
| 380 | }
|
|---|
| 381 | function _regeneratorDefine(e, r, n, t) {
|
|---|
| 382 | var i = Object.defineProperty;
|
|---|
| 383 | try {
|
|---|
| 384 | i({}, "", {});
|
|---|
| 385 | } catch (e) {
|
|---|
| 386 | i = 0;
|
|---|
| 387 | }
|
|---|
| 388 | _regeneratorDefine = function (e, r, n, t) {
|
|---|
| 389 | function o(r, n) {
|
|---|
| 390 | _regeneratorDefine(e, r, function (e) {
|
|---|
| 391 | return this._invoke(r, n, e);
|
|---|
| 392 | });
|
|---|
| 393 | }
|
|---|
| 394 | r ? i ? i(e, r, {
|
|---|
| 395 | value: n,
|
|---|
| 396 | enumerable: !t,
|
|---|
| 397 | configurable: !t,
|
|---|
| 398 | writable: !t
|
|---|
| 399 | }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|---|
| 400 | }, _regeneratorDefine(e, r, n, t);
|
|---|
| 401 | }
|
|---|
| 402 | function _regeneratorValues(e) {
|
|---|
| 403 | if (null != e) {
|
|---|
| 404 | var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|---|
| 405 | r = 0;
|
|---|
| 406 | if (t) return t.call(e);
|
|---|
| 407 | if ("function" == typeof e.next) return e;
|
|---|
| 408 | if (!isNaN(e.length)) return {
|
|---|
| 409 | next: function () {
|
|---|
| 410 | return e && r >= e.length && (e = void 0), {
|
|---|
| 411 | value: e && e[r++],
|
|---|
| 412 | done: !e
|
|---|
| 413 | };
|
|---|
| 414 | }
|
|---|
| 415 | };
|
|---|
| 416 | }
|
|---|
| 417 | throw new TypeError(typeof e + " is not iterable");
|
|---|
| 418 | }
|
|---|
| 419 | function _setPrototypeOf(t, e) {
|
|---|
| 420 | return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|---|
| 421 | return t.__proto__ = e, t;
|
|---|
| 422 | }, _setPrototypeOf(t, e);
|
|---|
| 423 | }
|
|---|
| 424 | function _slicedToArray(r, e) {
|
|---|
| 425 | return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|---|
| 426 | }
|
|---|
| 427 | function _toConsumableArray(r) {
|
|---|
| 428 | return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|---|
| 429 | }
|
|---|
| 430 | function _toPrimitive(t, r) {
|
|---|
| 431 | if ("object" != typeof t || !t) return t;
|
|---|
| 432 | var e = t[Symbol.toPrimitive];
|
|---|
| 433 | if (void 0 !== e) {
|
|---|
| 434 | var i = e.call(t, r);
|
|---|
| 435 | if ("object" != typeof i) return i;
|
|---|
| 436 | throw new TypeError("@@toPrimitive must return a primitive value.");
|
|---|
| 437 | }
|
|---|
| 438 | return ("string" === r ? String : Number)(t);
|
|---|
| 439 | }
|
|---|
| 440 | function _toPropertyKey(t) {
|
|---|
| 441 | var i = _toPrimitive(t, "string");
|
|---|
| 442 | return "symbol" == typeof i ? i : i + "";
|
|---|
| 443 | }
|
|---|
| 444 | function _typeof(o) {
|
|---|
| 445 | "@babel/helpers - typeof";
|
|---|
| 446 |
|
|---|
| 447 | return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|---|
| 448 | return typeof o;
|
|---|
| 449 | } : function (o) {
|
|---|
| 450 | return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|---|
| 451 | }, _typeof(o);
|
|---|
| 452 | }
|
|---|
| 453 | function _unsupportedIterableToArray(r, a) {
|
|---|
| 454 | if (r) {
|
|---|
| 455 | if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|---|
| 456 | var t = {}.toString.call(r).slice(8, -1);
|
|---|
| 457 | return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|---|
| 458 | }
|
|---|
| 459 | }
|
|---|
| 460 | function _wrapAsyncGenerator(e) {
|
|---|
| 461 | return function () {
|
|---|
| 462 | return new AsyncGenerator(e.apply(this, arguments));
|
|---|
| 463 | };
|
|---|
| 464 | }
|
|---|
| 465 | function AsyncGenerator(e) {
|
|---|
| 466 | var r, t;
|
|---|
| 467 | function resume(r, t) {
|
|---|
| 468 | try {
|
|---|
| 469 | var n = e[r](t),
|
|---|
| 470 | o = n.value,
|
|---|
| 471 | u = o instanceof _OverloadYield;
|
|---|
| 472 | Promise.resolve(u ? o.v : o).then(function (t) {
|
|---|
| 473 | if (u) {
|
|---|
| 474 | var i = "return" === r ? "return" : "next";
|
|---|
| 475 | if (!o.k || t.done) return resume(i, t);
|
|---|
| 476 | t = e[i](t).value;
|
|---|
| 477 | }
|
|---|
| 478 | settle(n.done ? "return" : "normal", t);
|
|---|
| 479 | }, function (e) {
|
|---|
| 480 | resume("throw", e);
|
|---|
| 481 | });
|
|---|
| 482 | } catch (e) {
|
|---|
| 483 | settle("throw", e);
|
|---|
| 484 | }
|
|---|
| 485 | }
|
|---|
| 486 | function settle(e, n) {
|
|---|
| 487 | switch (e) {
|
|---|
| 488 | case "return":
|
|---|
| 489 | r.resolve({
|
|---|
| 490 | value: n,
|
|---|
| 491 | done: true
|
|---|
| 492 | });
|
|---|
| 493 | break;
|
|---|
| 494 | case "throw":
|
|---|
| 495 | r.reject(n);
|
|---|
| 496 | break;
|
|---|
| 497 | default:
|
|---|
| 498 | r.resolve({
|
|---|
| 499 | value: n,
|
|---|
| 500 | done: false
|
|---|
| 501 | });
|
|---|
| 502 | }
|
|---|
| 503 | (r = r.next) ? resume(r.key, r.arg) : t = null;
|
|---|
| 504 | }
|
|---|
| 505 | this._invoke = function (e, n) {
|
|---|
| 506 | return new Promise(function (o, u) {
|
|---|
| 507 | var i = {
|
|---|
| 508 | key: e,
|
|---|
| 509 | arg: n,
|
|---|
| 510 | resolve: o,
|
|---|
| 511 | reject: u,
|
|---|
| 512 | next: null
|
|---|
| 513 | };
|
|---|
| 514 | t ? t = t.next = i : (r = t = i, resume(e, n));
|
|---|
| 515 | });
|
|---|
| 516 | }, "function" != typeof e.return && (this.return = void 0);
|
|---|
| 517 | }
|
|---|
| 518 | AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () {
|
|---|
| 519 | return this;
|
|---|
| 520 | }, AsyncGenerator.prototype.next = function (e) {
|
|---|
| 521 | return this._invoke("next", e);
|
|---|
| 522 | }, AsyncGenerator.prototype.throw = function (e) {
|
|---|
| 523 | return this._invoke("throw", e);
|
|---|
| 524 | }, AsyncGenerator.prototype.return = function (e) {
|
|---|
| 525 | return this._invoke("return", e);
|
|---|
| 526 | };
|
|---|
| 527 | function _wrapNativeSuper(t) {
|
|---|
| 528 | var r = "function" == typeof Map ? new Map() : void 0;
|
|---|
| 529 | return _wrapNativeSuper = function (t) {
|
|---|
| 530 | if (null === t || !_isNativeFunction(t)) return t;
|
|---|
| 531 | if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|---|
| 532 | if (void 0 !== r) {
|
|---|
| 533 | if (r.has(t)) return r.get(t);
|
|---|
| 534 | r.set(t, Wrapper);
|
|---|
| 535 | }
|
|---|
| 536 | function Wrapper() {
|
|---|
| 537 | return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|---|
| 538 | }
|
|---|
| 539 | return Wrapper.prototype = Object.create(t.prototype, {
|
|---|
| 540 | constructor: {
|
|---|
| 541 | value: Wrapper,
|
|---|
| 542 | enumerable: false,
|
|---|
| 543 | writable: true,
|
|---|
| 544 | configurable: true
|
|---|
| 545 | }
|
|---|
| 546 | }), _setPrototypeOf(Wrapper, t);
|
|---|
| 547 | }, _wrapNativeSuper(t);
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | /**
|
|---|
| 551 | * Create a bound version of a function with a specified `this` context
|
|---|
| 552 | *
|
|---|
| 553 | * @param {Function} fn - The function to bind
|
|---|
| 554 | * @param {*} thisArg - The value to be passed as the `this` parameter
|
|---|
| 555 | * @returns {Function} A new function that will call the original function with the specified `this` context
|
|---|
| 556 | */
|
|---|
| 557 | function bind(fn, thisArg) {
|
|---|
| 558 | return function wrap() {
|
|---|
| 559 | return fn.apply(thisArg, arguments);
|
|---|
| 560 | };
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | // utils is a library of generic helper functions non-specific to axios
|
|---|
| 564 |
|
|---|
| 565 | var toString = Object.prototype.toString;
|
|---|
| 566 | var getPrototypeOf = Object.getPrototypeOf;
|
|---|
| 567 | var iterator = Symbol.iterator,
|
|---|
| 568 | toStringTag = Symbol.toStringTag;
|
|---|
| 569 | var kindOf = function (cache) {
|
|---|
| 570 | return function (thing) {
|
|---|
| 571 | var str = toString.call(thing);
|
|---|
| 572 | return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|---|
| 573 | };
|
|---|
| 574 | }(Object.create(null));
|
|---|
| 575 | var kindOfTest = function kindOfTest(type) {
|
|---|
| 576 | type = type.toLowerCase();
|
|---|
| 577 | return function (thing) {
|
|---|
| 578 | return kindOf(thing) === type;
|
|---|
| 579 | };
|
|---|
| 580 | };
|
|---|
| 581 | var typeOfTest = function typeOfTest(type) {
|
|---|
| 582 | return function (thing) {
|
|---|
| 583 | return _typeof(thing) === type;
|
|---|
| 584 | };
|
|---|
| 585 | };
|
|---|
| 586 |
|
|---|
| 587 | /**
|
|---|
| 588 | * Determine if a value is a non-null object
|
|---|
| 589 | *
|
|---|
| 590 | * @param {Object} val The value to test
|
|---|
| 591 | *
|
|---|
| 592 | * @returns {boolean} True if value is an Array, otherwise false
|
|---|
| 593 | */
|
|---|
| 594 | var isArray = Array.isArray;
|
|---|
| 595 |
|
|---|
| 596 | /**
|
|---|
| 597 | * Determine if a value is undefined
|
|---|
| 598 | *
|
|---|
| 599 | * @param {*} val The value to test
|
|---|
| 600 | *
|
|---|
| 601 | * @returns {boolean} True if the value is undefined, otherwise false
|
|---|
| 602 | */
|
|---|
| 603 | var isUndefined = typeOfTest('undefined');
|
|---|
| 604 |
|
|---|
| 605 | /**
|
|---|
| 606 | * Determine if a value is a Buffer
|
|---|
| 607 | *
|
|---|
| 608 | * @param {*} val The value to test
|
|---|
| 609 | *
|
|---|
| 610 | * @returns {boolean} True if value is a Buffer, otherwise false
|
|---|
| 611 | */
|
|---|
| 612 | function isBuffer(val) {
|
|---|
| 613 | return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | /**
|
|---|
| 617 | * Determine if a value is an ArrayBuffer
|
|---|
| 618 | *
|
|---|
| 619 | * @param {*} val The value to test
|
|---|
| 620 | *
|
|---|
| 621 | * @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|---|
| 622 | */
|
|---|
| 623 | var isArrayBuffer = kindOfTest('ArrayBuffer');
|
|---|
| 624 |
|
|---|
| 625 | /**
|
|---|
| 626 | * Determine if a value is a view on an ArrayBuffer
|
|---|
| 627 | *
|
|---|
| 628 | * @param {*} val The value to test
|
|---|
| 629 | *
|
|---|
| 630 | * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
|---|
| 631 | */
|
|---|
| 632 | function isArrayBufferView(val) {
|
|---|
| 633 | var result;
|
|---|
| 634 | if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
|---|
| 635 | result = ArrayBuffer.isView(val);
|
|---|
| 636 | } else {
|
|---|
| 637 | result = val && val.buffer && isArrayBuffer(val.buffer);
|
|---|
| 638 | }
|
|---|
| 639 | return result;
|
|---|
| 640 | }
|
|---|
| 641 |
|
|---|
| 642 | /**
|
|---|
| 643 | * Determine if a value is a String
|
|---|
| 644 | *
|
|---|
| 645 | * @param {*} val The value to test
|
|---|
| 646 | *
|
|---|
| 647 | * @returns {boolean} True if value is a String, otherwise false
|
|---|
| 648 | */
|
|---|
| 649 | var isString = typeOfTest('string');
|
|---|
| 650 |
|
|---|
| 651 | /**
|
|---|
| 652 | * Determine if a value is a Function
|
|---|
| 653 | *
|
|---|
| 654 | * @param {*} val The value to test
|
|---|
| 655 | * @returns {boolean} True if value is a Function, otherwise false
|
|---|
| 656 | */
|
|---|
| 657 | var isFunction$1 = typeOfTest('function');
|
|---|
| 658 |
|
|---|
| 659 | /**
|
|---|
| 660 | * Determine if a value is a Number
|
|---|
| 661 | *
|
|---|
| 662 | * @param {*} val The value to test
|
|---|
| 663 | *
|
|---|
| 664 | * @returns {boolean} True if value is a Number, otherwise false
|
|---|
| 665 | */
|
|---|
| 666 | var isNumber = typeOfTest('number');
|
|---|
| 667 |
|
|---|
| 668 | /**
|
|---|
| 669 | * Determine if a value is an Object
|
|---|
| 670 | *
|
|---|
| 671 | * @param {*} thing The value to test
|
|---|
| 672 | *
|
|---|
| 673 | * @returns {boolean} True if value is an Object, otherwise false
|
|---|
| 674 | */
|
|---|
| 675 | var isObject = function isObject(thing) {
|
|---|
| 676 | return thing !== null && _typeof(thing) === 'object';
|
|---|
| 677 | };
|
|---|
| 678 |
|
|---|
| 679 | /**
|
|---|
| 680 | * Determine if a value is a Boolean
|
|---|
| 681 | *
|
|---|
| 682 | * @param {*} thing The value to test
|
|---|
| 683 | * @returns {boolean} True if value is a Boolean, otherwise false
|
|---|
| 684 | */
|
|---|
| 685 | var isBoolean = function isBoolean(thing) {
|
|---|
| 686 | return thing === true || thing === false;
|
|---|
| 687 | };
|
|---|
| 688 |
|
|---|
| 689 | /**
|
|---|
| 690 | * Determine if a value is a plain Object
|
|---|
| 691 | *
|
|---|
| 692 | * @param {*} val The value to test
|
|---|
| 693 | *
|
|---|
| 694 | * @returns {boolean} True if value is a plain Object, otherwise false
|
|---|
| 695 | */
|
|---|
| 696 | var isPlainObject = function isPlainObject(val) {
|
|---|
| 697 | if (kindOf(val) !== 'object') {
|
|---|
| 698 | return false;
|
|---|
| 699 | }
|
|---|
| 700 | var prototype = getPrototypeOf(val);
|
|---|
| 701 | return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|---|
| 702 | };
|
|---|
| 703 |
|
|---|
| 704 | /**
|
|---|
| 705 | * Determine if a value is an empty object (safely handles Buffers)
|
|---|
| 706 | *
|
|---|
| 707 | * @param {*} val The value to test
|
|---|
| 708 | *
|
|---|
| 709 | * @returns {boolean} True if value is an empty object, otherwise false
|
|---|
| 710 | */
|
|---|
| 711 | var isEmptyObject = function isEmptyObject(val) {
|
|---|
| 712 | // Early return for non-objects or Buffers to prevent RangeError
|
|---|
| 713 | if (!isObject(val) || isBuffer(val)) {
|
|---|
| 714 | return false;
|
|---|
| 715 | }
|
|---|
| 716 | try {
|
|---|
| 717 | return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|---|
| 718 | } catch (e) {
|
|---|
| 719 | // Fallback for any other objects that might cause RangeError with Object.keys()
|
|---|
| 720 | return false;
|
|---|
| 721 | }
|
|---|
| 722 | };
|
|---|
| 723 |
|
|---|
| 724 | /**
|
|---|
| 725 | * Determine if a value is a Date
|
|---|
| 726 | *
|
|---|
| 727 | * @param {*} val The value to test
|
|---|
| 728 | *
|
|---|
| 729 | * @returns {boolean} True if value is a Date, otherwise false
|
|---|
| 730 | */
|
|---|
| 731 | var isDate = kindOfTest('Date');
|
|---|
| 732 |
|
|---|
| 733 | /**
|
|---|
| 734 | * Determine if a value is a File
|
|---|
| 735 | *
|
|---|
| 736 | * @param {*} val The value to test
|
|---|
| 737 | *
|
|---|
| 738 | * @returns {boolean} True if value is a File, otherwise false
|
|---|
| 739 | */
|
|---|
| 740 | var isFile = kindOfTest('File');
|
|---|
| 741 |
|
|---|
| 742 | /**
|
|---|
| 743 | * Determine if a value is a React Native Blob
|
|---|
| 744 | * React Native "blob": an object with a `uri` attribute. Optionally, it can
|
|---|
| 745 | * also have a `name` and `type` attribute to specify filename and content type
|
|---|
| 746 | *
|
|---|
| 747 | * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
|
|---|
| 748 | *
|
|---|
| 749 | * @param {*} value The value to test
|
|---|
| 750 | *
|
|---|
| 751 | * @returns {boolean} True if value is a React Native Blob, otherwise false
|
|---|
| 752 | */
|
|---|
| 753 | var isReactNativeBlob = function isReactNativeBlob(value) {
|
|---|
| 754 | return !!(value && typeof value.uri !== 'undefined');
|
|---|
| 755 | };
|
|---|
| 756 |
|
|---|
| 757 | /**
|
|---|
| 758 | * Determine if environment is React Native
|
|---|
| 759 | * ReactNative `FormData` has a non-standard `getParts()` method
|
|---|
| 760 | *
|
|---|
| 761 | * @param {*} formData The formData to test
|
|---|
| 762 | *
|
|---|
| 763 | * @returns {boolean} True if environment is React Native, otherwise false
|
|---|
| 764 | */
|
|---|
| 765 | var isReactNative = function isReactNative(formData) {
|
|---|
| 766 | return formData && typeof formData.getParts !== 'undefined';
|
|---|
| 767 | };
|
|---|
| 768 |
|
|---|
| 769 | /**
|
|---|
| 770 | * Determine if a value is a Blob
|
|---|
| 771 | *
|
|---|
| 772 | * @param {*} val The value to test
|
|---|
| 773 | *
|
|---|
| 774 | * @returns {boolean} True if value is a Blob, otherwise false
|
|---|
| 775 | */
|
|---|
| 776 | var isBlob = kindOfTest('Blob');
|
|---|
| 777 |
|
|---|
| 778 | /**
|
|---|
| 779 | * Determine if a value is a FileList
|
|---|
| 780 | *
|
|---|
| 781 | * @param {*} val The value to test
|
|---|
| 782 | *
|
|---|
| 783 | * @returns {boolean} True if value is a FileList, otherwise false
|
|---|
| 784 | */
|
|---|
| 785 | var isFileList = kindOfTest('FileList');
|
|---|
| 786 |
|
|---|
| 787 | /**
|
|---|
| 788 | * Determine if a value is a Stream
|
|---|
| 789 | *
|
|---|
| 790 | * @param {*} val The value to test
|
|---|
| 791 | *
|
|---|
| 792 | * @returns {boolean} True if value is a Stream, otherwise false
|
|---|
| 793 | */
|
|---|
| 794 | var isStream = function isStream(val) {
|
|---|
| 795 | return isObject(val) && isFunction$1(val.pipe);
|
|---|
| 796 | };
|
|---|
| 797 |
|
|---|
| 798 | /**
|
|---|
| 799 | * Determine if a value is a FormData
|
|---|
| 800 | *
|
|---|
| 801 | * @param {*} thing The value to test
|
|---|
| 802 | *
|
|---|
| 803 | * @returns {boolean} True if value is an FormData, otherwise false
|
|---|
| 804 | */
|
|---|
| 805 | function getGlobal() {
|
|---|
| 806 | if (typeof globalThis !== 'undefined') return globalThis;
|
|---|
| 807 | if (typeof self !== 'undefined') return self;
|
|---|
| 808 | if (typeof window !== 'undefined') return window;
|
|---|
| 809 | if (typeof global !== 'undefined') return global;
|
|---|
| 810 | return {};
|
|---|
| 811 | }
|
|---|
| 812 | var G = getGlobal();
|
|---|
| 813 | var FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
|
|---|
| 814 | var isFormData = function isFormData(thing) {
|
|---|
| 815 | if (!thing) return false;
|
|---|
| 816 | if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|---|
| 817 | // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
|
|---|
| 818 | var proto = getPrototypeOf(thing);
|
|---|
| 819 | if (!proto || proto === Object.prototype) return false;
|
|---|
| 820 | if (!isFunction$1(thing.append)) return false;
|
|---|
| 821 | var kind = kindOf(thing);
|
|---|
| 822 | return kind === 'formdata' ||
|
|---|
| 823 | // detect form-data instance
|
|---|
| 824 | kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]';
|
|---|
| 825 | };
|
|---|
| 826 |
|
|---|
| 827 | /**
|
|---|
| 828 | * Determine if a value is a URLSearchParams object
|
|---|
| 829 | *
|
|---|
| 830 | * @param {*} val The value to test
|
|---|
| 831 | *
|
|---|
| 832 | * @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|---|
| 833 | */
|
|---|
| 834 | var isURLSearchParams = kindOfTest('URLSearchParams');
|
|---|
| 835 | var _map = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest),
|
|---|
| 836 | _map2 = _slicedToArray(_map, 4),
|
|---|
| 837 | isReadableStream = _map2[0],
|
|---|
| 838 | isRequest = _map2[1],
|
|---|
| 839 | isResponse = _map2[2],
|
|---|
| 840 | isHeaders = _map2[3];
|
|---|
| 841 |
|
|---|
| 842 | /**
|
|---|
| 843 | * Trim excess whitespace off the beginning and end of a string
|
|---|
| 844 | *
|
|---|
| 845 | * @param {String} str The String to trim
|
|---|
| 846 | *
|
|---|
| 847 | * @returns {String} The String freed of excess whitespace
|
|---|
| 848 | */
|
|---|
| 849 | var trim = function trim(str) {
|
|---|
| 850 | return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|---|
| 851 | };
|
|---|
| 852 | /**
|
|---|
| 853 | * Iterate over an Array or an Object invoking a function for each item.
|
|---|
| 854 | *
|
|---|
| 855 | * If `obj` is an Array callback will be called passing
|
|---|
| 856 | * the value, index, and complete array for each item.
|
|---|
| 857 | *
|
|---|
| 858 | * If 'obj' is an Object callback will be called passing
|
|---|
| 859 | * the value, key, and complete object for each property.
|
|---|
| 860 | *
|
|---|
| 861 | * @param {Object|Array<unknown>} obj The object to iterate
|
|---|
| 862 | * @param {Function} fn The callback to invoke for each item
|
|---|
| 863 | *
|
|---|
| 864 | * @param {Object} [options]
|
|---|
| 865 | * @param {Boolean} [options.allOwnKeys = false]
|
|---|
| 866 | * @returns {any}
|
|---|
| 867 | */
|
|---|
| 868 | function forEach(obj, fn) {
|
|---|
| 869 | var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|---|
| 870 | _ref$allOwnKeys = _ref.allOwnKeys,
|
|---|
| 871 | allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
|
|---|
| 872 | // Don't bother if no value provided
|
|---|
| 873 | if (obj === null || typeof obj === 'undefined') {
|
|---|
| 874 | return;
|
|---|
| 875 | }
|
|---|
| 876 | var i;
|
|---|
| 877 | var l;
|
|---|
| 878 |
|
|---|
| 879 | // Force an array if not already something iterable
|
|---|
| 880 | if (_typeof(obj) !== 'object') {
|
|---|
| 881 | /*eslint no-param-reassign:0*/
|
|---|
| 882 | obj = [obj];
|
|---|
| 883 | }
|
|---|
| 884 | if (isArray(obj)) {
|
|---|
| 885 | // Iterate over array values
|
|---|
| 886 | for (i = 0, l = obj.length; i < l; i++) {
|
|---|
| 887 | fn.call(null, obj[i], i, obj);
|
|---|
| 888 | }
|
|---|
| 889 | } else {
|
|---|
| 890 | // Buffer check
|
|---|
| 891 | if (isBuffer(obj)) {
|
|---|
| 892 | return;
|
|---|
| 893 | }
|
|---|
| 894 |
|
|---|
| 895 | // Iterate over object keys
|
|---|
| 896 | var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|---|
| 897 | var len = keys.length;
|
|---|
| 898 | var key;
|
|---|
| 899 | for (i = 0; i < len; i++) {
|
|---|
| 900 | key = keys[i];
|
|---|
| 901 | fn.call(null, obj[key], key, obj);
|
|---|
| 902 | }
|
|---|
| 903 | }
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 | /**
|
|---|
| 907 | * Finds a key in an object, case-insensitive, returning the actual key name.
|
|---|
| 908 | * Returns null if the object is a Buffer or if no match is found.
|
|---|
| 909 | *
|
|---|
| 910 | * @param {Object} obj - The object to search.
|
|---|
| 911 | * @param {string} key - The key to find (case-insensitive).
|
|---|
| 912 | * @returns {?string} The actual key name if found, otherwise null.
|
|---|
| 913 | */
|
|---|
| 914 | function findKey(obj, key) {
|
|---|
| 915 | if (isBuffer(obj)) {
|
|---|
| 916 | return null;
|
|---|
| 917 | }
|
|---|
| 918 | key = key.toLowerCase();
|
|---|
| 919 | var keys = Object.keys(obj);
|
|---|
| 920 | var i = keys.length;
|
|---|
| 921 | var _key;
|
|---|
| 922 | while (i-- > 0) {
|
|---|
| 923 | _key = keys[i];
|
|---|
| 924 | if (key === _key.toLowerCase()) {
|
|---|
| 925 | return _key;
|
|---|
| 926 | }
|
|---|
| 927 | }
|
|---|
| 928 | return null;
|
|---|
| 929 | }
|
|---|
| 930 | var _global = function () {
|
|---|
| 931 | /*eslint no-undef:0*/
|
|---|
| 932 | if (typeof globalThis !== 'undefined') return globalThis;
|
|---|
| 933 | return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
|
|---|
| 934 | }();
|
|---|
| 935 | var isContextDefined = function isContextDefined(context) {
|
|---|
| 936 | return !isUndefined(context) && context !== _global;
|
|---|
| 937 | };
|
|---|
| 938 |
|
|---|
| 939 | /**
|
|---|
| 940 | * Accepts varargs expecting each argument to be an object, then
|
|---|
| 941 | * immutably merges the properties of each object and returns result.
|
|---|
| 942 | *
|
|---|
| 943 | * When multiple objects contain the same key the later object in
|
|---|
| 944 | * the arguments list will take precedence.
|
|---|
| 945 | *
|
|---|
| 946 | * Example:
|
|---|
| 947 | *
|
|---|
| 948 | * ```js
|
|---|
| 949 | * const result = merge({foo: 123}, {foo: 456});
|
|---|
| 950 | * console.log(result.foo); // outputs 456
|
|---|
| 951 | * ```
|
|---|
| 952 | *
|
|---|
| 953 | * @param {Object} obj1 Object to merge
|
|---|
| 954 | *
|
|---|
| 955 | * @returns {Object} Result of all merge properties
|
|---|
| 956 | */
|
|---|
| 957 | function merge() {
|
|---|
| 958 | var _ref2 = isContextDefined(this) && this || {},
|
|---|
| 959 | caseless = _ref2.caseless,
|
|---|
| 960 | skipUndefined = _ref2.skipUndefined;
|
|---|
| 961 | var result = {};
|
|---|
| 962 | var assignValue = function assignValue(val, key) {
|
|---|
| 963 | // Skip dangerous property names to prevent prototype pollution
|
|---|
| 964 | if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|---|
| 965 | return;
|
|---|
| 966 | }
|
|---|
| 967 | var targetKey = caseless && findKey(result, key) || key;
|
|---|
| 968 | // Read via own-prop only — a bare `result[targetKey]` walks the prototype
|
|---|
| 969 | // chain, so a polluted Object.prototype value could surface here and get
|
|---|
| 970 | // copied into the merged result.
|
|---|
| 971 | var existing = hasOwnProperty(result, targetKey) ? result[targetKey] : undefined;
|
|---|
| 972 | if (isPlainObject(existing) && isPlainObject(val)) {
|
|---|
| 973 | result[targetKey] = merge(existing, val);
|
|---|
| 974 | } else if (isPlainObject(val)) {
|
|---|
| 975 | result[targetKey] = merge({}, val);
|
|---|
| 976 | } else if (isArray(val)) {
|
|---|
| 977 | result[targetKey] = val.slice();
|
|---|
| 978 | } else if (!skipUndefined || !isUndefined(val)) {
|
|---|
| 979 | result[targetKey] = val;
|
|---|
| 980 | }
|
|---|
| 981 | };
|
|---|
| 982 | for (var _len = arguments.length, objs = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
|
|---|
| 983 | objs[_key2] = arguments[_key2];
|
|---|
| 984 | }
|
|---|
| 985 | for (var i = 0, l = objs.length; i < l; i++) {
|
|---|
| 986 | objs[i] && forEach(objs[i], assignValue);
|
|---|
| 987 | }
|
|---|
| 988 | return result;
|
|---|
| 989 | }
|
|---|
| 990 |
|
|---|
| 991 | /**
|
|---|
| 992 | * Extends object a by mutably adding to it the properties of object b.
|
|---|
| 993 | *
|
|---|
| 994 | * @param {Object} a The object to be extended
|
|---|
| 995 | * @param {Object} b The object to copy properties from
|
|---|
| 996 | * @param {Object} thisArg The object to bind function to
|
|---|
| 997 | *
|
|---|
| 998 | * @param {Object} [options]
|
|---|
| 999 | * @param {Boolean} [options.allOwnKeys]
|
|---|
| 1000 | * @returns {Object} The resulting value of object a
|
|---|
| 1001 | */
|
|---|
| 1002 | var extend = function extend(a, b, thisArg) {
|
|---|
| 1003 | var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|---|
| 1004 | allOwnKeys = _ref3.allOwnKeys;
|
|---|
| 1005 | forEach(b, function (val, key) {
|
|---|
| 1006 | if (thisArg && isFunction$1(val)) {
|
|---|
| 1007 | Object.defineProperty(a, key, {
|
|---|
| 1008 | // Null-proto descriptor so a polluted Object.prototype.get cannot
|
|---|
| 1009 | // hijack defineProperty's accessor-vs-data resolution.
|
|---|
| 1010 | __proto__: null,
|
|---|
| 1011 | value: bind(val, thisArg),
|
|---|
| 1012 | writable: true,
|
|---|
| 1013 | enumerable: true,
|
|---|
| 1014 | configurable: true
|
|---|
| 1015 | });
|
|---|
| 1016 | } else {
|
|---|
| 1017 | Object.defineProperty(a, key, {
|
|---|
| 1018 | __proto__: null,
|
|---|
| 1019 | value: val,
|
|---|
| 1020 | writable: true,
|
|---|
| 1021 | enumerable: true,
|
|---|
| 1022 | configurable: true
|
|---|
| 1023 | });
|
|---|
| 1024 | }
|
|---|
| 1025 | }, {
|
|---|
| 1026 | allOwnKeys: allOwnKeys
|
|---|
| 1027 | });
|
|---|
| 1028 | return a;
|
|---|
| 1029 | };
|
|---|
| 1030 |
|
|---|
| 1031 | /**
|
|---|
| 1032 | * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
|---|
| 1033 | *
|
|---|
| 1034 | * @param {string} content with BOM
|
|---|
| 1035 | *
|
|---|
| 1036 | * @returns {string} content value without BOM
|
|---|
| 1037 | */
|
|---|
| 1038 | var stripBOM = function stripBOM(content) {
|
|---|
| 1039 | if (content.charCodeAt(0) === 0xfeff) {
|
|---|
| 1040 | content = content.slice(1);
|
|---|
| 1041 | }
|
|---|
| 1042 | return content;
|
|---|
| 1043 | };
|
|---|
| 1044 |
|
|---|
| 1045 | /**
|
|---|
| 1046 | * Inherit the prototype methods from one constructor into another
|
|---|
| 1047 | * @param {function} constructor
|
|---|
| 1048 | * @param {function} superConstructor
|
|---|
| 1049 | * @param {object} [props]
|
|---|
| 1050 | * @param {object} [descriptors]
|
|---|
| 1051 | *
|
|---|
| 1052 | * @returns {void}
|
|---|
| 1053 | */
|
|---|
| 1054 | var inherits = function inherits(constructor, superConstructor, props, descriptors) {
|
|---|
| 1055 | constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|---|
| 1056 | Object.defineProperty(constructor.prototype, 'constructor', {
|
|---|
| 1057 | __proto__: null,
|
|---|
| 1058 | value: constructor,
|
|---|
| 1059 | writable: true,
|
|---|
| 1060 | enumerable: false,
|
|---|
| 1061 | configurable: true
|
|---|
| 1062 | });
|
|---|
| 1063 | Object.defineProperty(constructor, 'super', {
|
|---|
| 1064 | __proto__: null,
|
|---|
| 1065 | value: superConstructor.prototype
|
|---|
| 1066 | });
|
|---|
| 1067 | props && Object.assign(constructor.prototype, props);
|
|---|
| 1068 | };
|
|---|
| 1069 |
|
|---|
| 1070 | /**
|
|---|
| 1071 | * Resolve object with deep prototype chain to a flat object
|
|---|
| 1072 | * @param {Object} sourceObj source object
|
|---|
| 1073 | * @param {Object} [destObj]
|
|---|
| 1074 | * @param {Function|Boolean} [filter]
|
|---|
| 1075 | * @param {Function} [propFilter]
|
|---|
| 1076 | *
|
|---|
| 1077 | * @returns {Object}
|
|---|
| 1078 | */
|
|---|
| 1079 | var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
|---|
| 1080 | var props;
|
|---|
| 1081 | var i;
|
|---|
| 1082 | var prop;
|
|---|
| 1083 | var merged = {};
|
|---|
| 1084 | destObj = destObj || {};
|
|---|
| 1085 | // eslint-disable-next-line no-eq-null,eqeqeq
|
|---|
| 1086 | if (sourceObj == null) return destObj;
|
|---|
| 1087 | do {
|
|---|
| 1088 | props = Object.getOwnPropertyNames(sourceObj);
|
|---|
| 1089 | i = props.length;
|
|---|
| 1090 | while (i-- > 0) {
|
|---|
| 1091 | prop = props[i];
|
|---|
| 1092 | if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|---|
| 1093 | destObj[prop] = sourceObj[prop];
|
|---|
| 1094 | merged[prop] = true;
|
|---|
| 1095 | }
|
|---|
| 1096 | }
|
|---|
| 1097 | sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
|---|
| 1098 | } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|---|
| 1099 | return destObj;
|
|---|
| 1100 | };
|
|---|
| 1101 |
|
|---|
| 1102 | /**
|
|---|
| 1103 | * Determines whether a string ends with the characters of a specified string
|
|---|
| 1104 | *
|
|---|
| 1105 | * @param {String} str
|
|---|
| 1106 | * @param {String} searchString
|
|---|
| 1107 | * @param {Number} [position= 0]
|
|---|
| 1108 | *
|
|---|
| 1109 | * @returns {boolean}
|
|---|
| 1110 | */
|
|---|
| 1111 | var endsWith = function endsWith(str, searchString, position) {
|
|---|
| 1112 | str = String(str);
|
|---|
| 1113 | if (position === undefined || position > str.length) {
|
|---|
| 1114 | position = str.length;
|
|---|
| 1115 | }
|
|---|
| 1116 | position -= searchString.length;
|
|---|
| 1117 | var lastIndex = str.indexOf(searchString, position);
|
|---|
| 1118 | return lastIndex !== -1 && lastIndex === position;
|
|---|
| 1119 | };
|
|---|
| 1120 |
|
|---|
| 1121 | /**
|
|---|
| 1122 | * Returns new array from array like object or null if failed
|
|---|
| 1123 | *
|
|---|
| 1124 | * @param {*} [thing]
|
|---|
| 1125 | *
|
|---|
| 1126 | * @returns {?Array}
|
|---|
| 1127 | */
|
|---|
| 1128 | var toArray = function toArray(thing) {
|
|---|
| 1129 | if (!thing) return null;
|
|---|
| 1130 | if (isArray(thing)) return thing;
|
|---|
| 1131 | var i = thing.length;
|
|---|
| 1132 | if (!isNumber(i)) return null;
|
|---|
| 1133 | var arr = new Array(i);
|
|---|
| 1134 | while (i-- > 0) {
|
|---|
| 1135 | arr[i] = thing[i];
|
|---|
| 1136 | }
|
|---|
| 1137 | return arr;
|
|---|
| 1138 | };
|
|---|
| 1139 |
|
|---|
| 1140 | /**
|
|---|
| 1141 | * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
|---|
| 1142 | * thing passed in is an instance of Uint8Array
|
|---|
| 1143 | *
|
|---|
| 1144 | * @param {TypedArray}
|
|---|
| 1145 | *
|
|---|
| 1146 | * @returns {Array}
|
|---|
| 1147 | */
|
|---|
| 1148 | // eslint-disable-next-line func-names
|
|---|
| 1149 | var isTypedArray = function (TypedArray) {
|
|---|
| 1150 | // eslint-disable-next-line func-names
|
|---|
| 1151 | return function (thing) {
|
|---|
| 1152 | return TypedArray && thing instanceof TypedArray;
|
|---|
| 1153 | };
|
|---|
| 1154 | }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
|---|
| 1155 |
|
|---|
| 1156 | /**
|
|---|
| 1157 | * For each entry in the object, call the function with the key and value.
|
|---|
| 1158 | *
|
|---|
| 1159 | * @param {Object<any, any>} obj - The object to iterate over.
|
|---|
| 1160 | * @param {Function} fn - The function to call for each entry.
|
|---|
| 1161 | *
|
|---|
| 1162 | * @returns {void}
|
|---|
| 1163 | */
|
|---|
| 1164 | var forEachEntry = function forEachEntry(obj, fn) {
|
|---|
| 1165 | var generator = obj && obj[iterator];
|
|---|
| 1166 | var _iterator = generator.call(obj);
|
|---|
| 1167 | var result;
|
|---|
| 1168 | while ((result = _iterator.next()) && !result.done) {
|
|---|
| 1169 | var pair = result.value;
|
|---|
| 1170 | fn.call(obj, pair[0], pair[1]);
|
|---|
| 1171 | }
|
|---|
| 1172 | };
|
|---|
| 1173 |
|
|---|
| 1174 | /**
|
|---|
| 1175 | * It takes a regular expression and a string, and returns an array of all the matches
|
|---|
| 1176 | *
|
|---|
| 1177 | * @param {string} regExp - The regular expression to match against.
|
|---|
| 1178 | * @param {string} str - The string to search.
|
|---|
| 1179 | *
|
|---|
| 1180 | * @returns {Array<boolean>}
|
|---|
| 1181 | */
|
|---|
| 1182 | var matchAll = function matchAll(regExp, str) {
|
|---|
| 1183 | var matches;
|
|---|
| 1184 | var arr = [];
|
|---|
| 1185 | while ((matches = regExp.exec(str)) !== null) {
|
|---|
| 1186 | arr.push(matches);
|
|---|
| 1187 | }
|
|---|
| 1188 | return arr;
|
|---|
| 1189 | };
|
|---|
| 1190 |
|
|---|
| 1191 | /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
|---|
| 1192 | var isHTMLForm = kindOfTest('HTMLFormElement');
|
|---|
| 1193 | var toCamelCase = function toCamelCase(str) {
|
|---|
| 1194 | return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
|---|
| 1195 | return p1.toUpperCase() + p2;
|
|---|
| 1196 | });
|
|---|
| 1197 | };
|
|---|
| 1198 |
|
|---|
| 1199 | /* Creating a function that will check if an object has a property. */
|
|---|
| 1200 | var hasOwnProperty = function (_ref4) {
|
|---|
| 1201 | var hasOwnProperty = _ref4.hasOwnProperty;
|
|---|
| 1202 | return function (obj, prop) {
|
|---|
| 1203 | return hasOwnProperty.call(obj, prop);
|
|---|
| 1204 | };
|
|---|
| 1205 | }(Object.prototype);
|
|---|
| 1206 |
|
|---|
| 1207 | /**
|
|---|
| 1208 | * Determine if a value is a RegExp object
|
|---|
| 1209 | *
|
|---|
| 1210 | * @param {*} val The value to test
|
|---|
| 1211 | *
|
|---|
| 1212 | * @returns {boolean} True if value is a RegExp object, otherwise false
|
|---|
| 1213 | */
|
|---|
| 1214 | var isRegExp = kindOfTest('RegExp');
|
|---|
| 1215 | var reduceDescriptors = function reduceDescriptors(obj, reducer) {
|
|---|
| 1216 | var descriptors = Object.getOwnPropertyDescriptors(obj);
|
|---|
| 1217 | var reducedDescriptors = {};
|
|---|
| 1218 | forEach(descriptors, function (descriptor, name) {
|
|---|
| 1219 | var ret;
|
|---|
| 1220 | if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|---|
| 1221 | reducedDescriptors[name] = ret || descriptor;
|
|---|
| 1222 | }
|
|---|
| 1223 | });
|
|---|
| 1224 | Object.defineProperties(obj, reducedDescriptors);
|
|---|
| 1225 | };
|
|---|
| 1226 |
|
|---|
| 1227 | /**
|
|---|
| 1228 | * Makes all methods read-only
|
|---|
| 1229 | * @param {Object} obj
|
|---|
| 1230 | */
|
|---|
| 1231 |
|
|---|
| 1232 | var freezeMethods = function freezeMethods(obj) {
|
|---|
| 1233 | reduceDescriptors(obj, function (descriptor, name) {
|
|---|
| 1234 | // skip restricted props in strict mode
|
|---|
| 1235 | if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
|---|
| 1236 | return false;
|
|---|
| 1237 | }
|
|---|
| 1238 | var value = obj[name];
|
|---|
| 1239 | if (!isFunction$1(value)) return;
|
|---|
| 1240 | descriptor.enumerable = false;
|
|---|
| 1241 | if ('writable' in descriptor) {
|
|---|
| 1242 | descriptor.writable = false;
|
|---|
| 1243 | return;
|
|---|
| 1244 | }
|
|---|
| 1245 | if (!descriptor.set) {
|
|---|
| 1246 | descriptor.set = function () {
|
|---|
| 1247 | throw Error("Can not rewrite read-only method '" + name + "'");
|
|---|
| 1248 | };
|
|---|
| 1249 | }
|
|---|
| 1250 | });
|
|---|
| 1251 | };
|
|---|
| 1252 |
|
|---|
| 1253 | /**
|
|---|
| 1254 | * Converts an array or a delimited string into an object set with values as keys and true as values.
|
|---|
| 1255 | * Useful for fast membership checks.
|
|---|
| 1256 | *
|
|---|
| 1257 | * @param {Array|string} arrayOrString - The array or string to convert.
|
|---|
| 1258 | * @param {string} delimiter - The delimiter to use if input is a string.
|
|---|
| 1259 | * @returns {Object} An object with keys from the array or string, values set to true.
|
|---|
| 1260 | */
|
|---|
| 1261 | var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
|
|---|
| 1262 | var obj = {};
|
|---|
| 1263 | var define = function define(arr) {
|
|---|
| 1264 | arr.forEach(function (value) {
|
|---|
| 1265 | obj[value] = true;
|
|---|
| 1266 | });
|
|---|
| 1267 | };
|
|---|
| 1268 | isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|---|
| 1269 | return obj;
|
|---|
| 1270 | };
|
|---|
| 1271 | var noop = function noop() {};
|
|---|
| 1272 | var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
|
|---|
| 1273 | return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|---|
| 1274 | };
|
|---|
| 1275 |
|
|---|
| 1276 | /**
|
|---|
| 1277 | * If the thing is a FormData object, return true, otherwise return false.
|
|---|
| 1278 | *
|
|---|
| 1279 | * @param {unknown} thing - The thing to check.
|
|---|
| 1280 | *
|
|---|
| 1281 | * @returns {boolean}
|
|---|
| 1282 | */
|
|---|
| 1283 | function isSpecCompliantForm(thing) {
|
|---|
| 1284 | return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|---|
| 1285 | }
|
|---|
| 1286 |
|
|---|
| 1287 | /**
|
|---|
| 1288 | * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
|
|---|
| 1289 | *
|
|---|
| 1290 | * @param {Object} obj - The object to convert.
|
|---|
| 1291 | * @returns {Object} The JSON-compatible object.
|
|---|
| 1292 | */
|
|---|
| 1293 | var toJSONObject = function toJSONObject(obj) {
|
|---|
| 1294 | var visited = new WeakSet();
|
|---|
| 1295 | var _visit = function visit(source) {
|
|---|
| 1296 | if (isObject(source)) {
|
|---|
| 1297 | if (visited.has(source)) {
|
|---|
| 1298 | return;
|
|---|
| 1299 | }
|
|---|
| 1300 |
|
|---|
| 1301 | //Buffer check
|
|---|
| 1302 | if (isBuffer(source)) {
|
|---|
| 1303 | return source;
|
|---|
| 1304 | }
|
|---|
| 1305 | if (!('toJSON' in source)) {
|
|---|
| 1306 | // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|---|
| 1307 | visited.add(source);
|
|---|
| 1308 | var target = isArray(source) ? [] : {};
|
|---|
| 1309 | forEach(source, function (value, key) {
|
|---|
| 1310 | var reducedValue = _visit(value);
|
|---|
| 1311 | !isUndefined(reducedValue) && (target[key] = reducedValue);
|
|---|
| 1312 | });
|
|---|
| 1313 | visited["delete"](source);
|
|---|
| 1314 | return target;
|
|---|
| 1315 | }
|
|---|
| 1316 | }
|
|---|
| 1317 | return source;
|
|---|
| 1318 | };
|
|---|
| 1319 | return _visit(obj);
|
|---|
| 1320 | };
|
|---|
| 1321 |
|
|---|
| 1322 | /**
|
|---|
| 1323 | * Determines if a value is an async function.
|
|---|
| 1324 | *
|
|---|
| 1325 | * @param {*} thing - The value to test.
|
|---|
| 1326 | * @returns {boolean} True if value is an async function, otherwise false.
|
|---|
| 1327 | */
|
|---|
| 1328 | var isAsyncFn = kindOfTest('AsyncFunction');
|
|---|
| 1329 |
|
|---|
| 1330 | /**
|
|---|
| 1331 | * Determines if a value is thenable (has then and catch methods).
|
|---|
| 1332 | *
|
|---|
| 1333 | * @param {*} thing - The value to test.
|
|---|
| 1334 | * @returns {boolean} True if value is thenable, otherwise false.
|
|---|
| 1335 | */
|
|---|
| 1336 | var isThenable = function isThenable(thing) {
|
|---|
| 1337 | return thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing["catch"]);
|
|---|
| 1338 | };
|
|---|
| 1339 |
|
|---|
| 1340 | // original code
|
|---|
| 1341 | // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|---|
| 1342 |
|
|---|
| 1343 | /**
|
|---|
| 1344 | * Provides a cross-platform setImmediate implementation.
|
|---|
| 1345 | * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
|
|---|
| 1346 | *
|
|---|
| 1347 | * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
|
|---|
| 1348 | * @param {boolean} postMessageSupported - Whether postMessage is supported.
|
|---|
| 1349 | * @returns {Function} A function to schedule a callback asynchronously.
|
|---|
| 1350 | */
|
|---|
| 1351 | var _setImmediate = function (setImmediateSupported, postMessageSupported) {
|
|---|
| 1352 | if (setImmediateSupported) {
|
|---|
| 1353 | return setImmediate;
|
|---|
| 1354 | }
|
|---|
| 1355 | return postMessageSupported ? function (token, callbacks) {
|
|---|
| 1356 | _global.addEventListener('message', function (_ref5) {
|
|---|
| 1357 | var source = _ref5.source,
|
|---|
| 1358 | data = _ref5.data;
|
|---|
| 1359 | if (source === _global && data === token) {
|
|---|
| 1360 | callbacks.length && callbacks.shift()();
|
|---|
| 1361 | }
|
|---|
| 1362 | }, false);
|
|---|
| 1363 | return function (cb) {
|
|---|
| 1364 | callbacks.push(cb);
|
|---|
| 1365 | _global.postMessage(token, '*');
|
|---|
| 1366 | };
|
|---|
| 1367 | }("axios@".concat(Math.random()), []) : function (cb) {
|
|---|
| 1368 | return setTimeout(cb);
|
|---|
| 1369 | };
|
|---|
| 1370 | }(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
|
|---|
| 1371 |
|
|---|
| 1372 | /**
|
|---|
| 1373 | * Schedules a microtask or asynchronous callback as soon as possible.
|
|---|
| 1374 | * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
|
|---|
| 1375 | *
|
|---|
| 1376 | * @type {Function}
|
|---|
| 1377 | */
|
|---|
| 1378 | var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
|
|---|
| 1379 |
|
|---|
| 1380 | // *********************
|
|---|
| 1381 |
|
|---|
| 1382 | var isIterable = function isIterable(thing) {
|
|---|
| 1383 | return thing != null && isFunction$1(thing[iterator]);
|
|---|
| 1384 | };
|
|---|
| 1385 | var utils$1 = {
|
|---|
| 1386 | isArray: isArray,
|
|---|
| 1387 | isArrayBuffer: isArrayBuffer,
|
|---|
| 1388 | isBuffer: isBuffer,
|
|---|
| 1389 | isFormData: isFormData,
|
|---|
| 1390 | isArrayBufferView: isArrayBufferView,
|
|---|
| 1391 | isString: isString,
|
|---|
| 1392 | isNumber: isNumber,
|
|---|
| 1393 | isBoolean: isBoolean,
|
|---|
| 1394 | isObject: isObject,
|
|---|
| 1395 | isPlainObject: isPlainObject,
|
|---|
| 1396 | isEmptyObject: isEmptyObject,
|
|---|
| 1397 | isReadableStream: isReadableStream,
|
|---|
| 1398 | isRequest: isRequest,
|
|---|
| 1399 | isResponse: isResponse,
|
|---|
| 1400 | isHeaders: isHeaders,
|
|---|
| 1401 | isUndefined: isUndefined,
|
|---|
| 1402 | isDate: isDate,
|
|---|
| 1403 | isFile: isFile,
|
|---|
| 1404 | isReactNativeBlob: isReactNativeBlob,
|
|---|
| 1405 | isReactNative: isReactNative,
|
|---|
| 1406 | isBlob: isBlob,
|
|---|
| 1407 | isRegExp: isRegExp,
|
|---|
| 1408 | isFunction: isFunction$1,
|
|---|
| 1409 | isStream: isStream,
|
|---|
| 1410 | isURLSearchParams: isURLSearchParams,
|
|---|
| 1411 | isTypedArray: isTypedArray,
|
|---|
| 1412 | isFileList: isFileList,
|
|---|
| 1413 | forEach: forEach,
|
|---|
| 1414 | merge: merge,
|
|---|
| 1415 | extend: extend,
|
|---|
| 1416 | trim: trim,
|
|---|
| 1417 | stripBOM: stripBOM,
|
|---|
| 1418 | inherits: inherits,
|
|---|
| 1419 | toFlatObject: toFlatObject,
|
|---|
| 1420 | kindOf: kindOf,
|
|---|
| 1421 | kindOfTest: kindOfTest,
|
|---|
| 1422 | endsWith: endsWith,
|
|---|
| 1423 | toArray: toArray,
|
|---|
| 1424 | forEachEntry: forEachEntry,
|
|---|
| 1425 | matchAll: matchAll,
|
|---|
| 1426 | isHTMLForm: isHTMLForm,
|
|---|
| 1427 | hasOwnProperty: hasOwnProperty,
|
|---|
| 1428 | hasOwnProp: hasOwnProperty,
|
|---|
| 1429 | // an alias to avoid ESLint no-prototype-builtins detection
|
|---|
| 1430 | reduceDescriptors: reduceDescriptors,
|
|---|
| 1431 | freezeMethods: freezeMethods,
|
|---|
| 1432 | toObjectSet: toObjectSet,
|
|---|
| 1433 | toCamelCase: toCamelCase,
|
|---|
| 1434 | noop: noop,
|
|---|
| 1435 | toFiniteNumber: toFiniteNumber,
|
|---|
| 1436 | findKey: findKey,
|
|---|
| 1437 | global: _global,
|
|---|
| 1438 | isContextDefined: isContextDefined,
|
|---|
| 1439 | isSpecCompliantForm: isSpecCompliantForm,
|
|---|
| 1440 | toJSONObject: toJSONObject,
|
|---|
| 1441 | isAsyncFn: isAsyncFn,
|
|---|
| 1442 | isThenable: isThenable,
|
|---|
| 1443 | setImmediate: _setImmediate,
|
|---|
| 1444 | asap: asap,
|
|---|
| 1445 | isIterable: isIterable
|
|---|
| 1446 | };
|
|---|
| 1447 |
|
|---|
| 1448 | // RawAxiosHeaders whose duplicates are ignored by node
|
|---|
| 1449 | // c.f. https://nodejs.org/api/http.html#http_message_headers
|
|---|
| 1450 | var ignoreDuplicateOf = utils$1.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']);
|
|---|
| 1451 |
|
|---|
| 1452 | /**
|
|---|
| 1453 | * Parse headers into an object
|
|---|
| 1454 | *
|
|---|
| 1455 | * ```
|
|---|
| 1456 | * Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|---|
| 1457 | * Content-Type: application/json
|
|---|
| 1458 | * Connection: keep-alive
|
|---|
| 1459 | * Transfer-Encoding: chunked
|
|---|
| 1460 | * ```
|
|---|
| 1461 | *
|
|---|
| 1462 | * @param {String} rawHeaders Headers needing to be parsed
|
|---|
| 1463 | *
|
|---|
| 1464 | * @returns {Object} Headers parsed into an object
|
|---|
| 1465 | */
|
|---|
| 1466 | var parseHeaders = (function (rawHeaders) {
|
|---|
| 1467 | var parsed = {};
|
|---|
| 1468 | var key;
|
|---|
| 1469 | var val;
|
|---|
| 1470 | var i;
|
|---|
| 1471 | rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
|---|
| 1472 | i = line.indexOf(':');
|
|---|
| 1473 | key = line.substring(0, i).trim().toLowerCase();
|
|---|
| 1474 | val = line.substring(i + 1).trim();
|
|---|
| 1475 | if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
|---|
| 1476 | return;
|
|---|
| 1477 | }
|
|---|
| 1478 | if (key === 'set-cookie') {
|
|---|
| 1479 | if (parsed[key]) {
|
|---|
| 1480 | parsed[key].push(val);
|
|---|
| 1481 | } else {
|
|---|
| 1482 | parsed[key] = [val];
|
|---|
| 1483 | }
|
|---|
| 1484 | } else {
|
|---|
| 1485 | parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|---|
| 1486 | }
|
|---|
| 1487 | });
|
|---|
| 1488 | return parsed;
|
|---|
| 1489 | });
|
|---|
| 1490 |
|
|---|
| 1491 | function trimSPorHTAB(str) {
|
|---|
| 1492 | var start = 0;
|
|---|
| 1493 | var end = str.length;
|
|---|
| 1494 | while (start < end) {
|
|---|
| 1495 | var code = str.charCodeAt(start);
|
|---|
| 1496 | if (code !== 0x09 && code !== 0x20) {
|
|---|
| 1497 | break;
|
|---|
| 1498 | }
|
|---|
| 1499 | start += 1;
|
|---|
| 1500 | }
|
|---|
| 1501 | while (end > start) {
|
|---|
| 1502 | var _code = str.charCodeAt(end - 1);
|
|---|
| 1503 | if (_code !== 0x09 && _code !== 0x20) {
|
|---|
| 1504 | break;
|
|---|
| 1505 | }
|
|---|
| 1506 | end -= 1;
|
|---|
| 1507 | }
|
|---|
| 1508 | return start === 0 && end === str.length ? str : str.slice(start, end);
|
|---|
| 1509 | }
|
|---|
| 1510 |
|
|---|
| 1511 | // The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|---|
| 1512 | // eslint-disable-next-line no-control-regex
|
|---|
| 1513 | var INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+", 'g');
|
|---|
| 1514 | // eslint-disable-next-line no-control-regex
|
|---|
| 1515 | var INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+", 'g');
|
|---|
| 1516 | function sanitizeValue(value, invalidChars) {
|
|---|
| 1517 | if (utils$1.isArray(value)) {
|
|---|
| 1518 | return value.map(function (item) {
|
|---|
| 1519 | return sanitizeValue(item, invalidChars);
|
|---|
| 1520 | });
|
|---|
| 1521 | }
|
|---|
| 1522 | return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|---|
| 1523 | }
|
|---|
| 1524 | var sanitizeHeaderValue = function sanitizeHeaderValue(value) {
|
|---|
| 1525 | return sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|---|
| 1526 | };
|
|---|
| 1527 | var sanitizeByteStringHeaderValue = function sanitizeByteStringHeaderValue(value) {
|
|---|
| 1528 | return sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|---|
| 1529 | };
|
|---|
| 1530 | function toByteStringHeaderObject(headers) {
|
|---|
| 1531 | var byteStringHeaders = Object.create(null);
|
|---|
| 1532 | utils$1.forEach(headers.toJSON(), function (value, header) {
|
|---|
| 1533 | byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|---|
| 1534 | });
|
|---|
| 1535 | return byteStringHeaders;
|
|---|
| 1536 | }
|
|---|
| 1537 |
|
|---|
| 1538 | var $internals = Symbol('internals');
|
|---|
| 1539 | function normalizeHeader(header) {
|
|---|
| 1540 | return header && String(header).trim().toLowerCase();
|
|---|
| 1541 | }
|
|---|
| 1542 | function normalizeValue(value) {
|
|---|
| 1543 | if (value === false || value == null) {
|
|---|
| 1544 | return value;
|
|---|
| 1545 | }
|
|---|
| 1546 | return utils$1.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
|
|---|
| 1547 | }
|
|---|
| 1548 | function parseTokens(str) {
|
|---|
| 1549 | var tokens = Object.create(null);
|
|---|
| 1550 | var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|---|
| 1551 | var match;
|
|---|
| 1552 | while (match = tokensRE.exec(str)) {
|
|---|
| 1553 | tokens[match[1]] = match[2];
|
|---|
| 1554 | }
|
|---|
| 1555 | return tokens;
|
|---|
| 1556 | }
|
|---|
| 1557 | var isValidHeaderName = function isValidHeaderName(str) {
|
|---|
| 1558 | return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|---|
| 1559 | };
|
|---|
| 1560 | function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|---|
| 1561 | if (utils$1.isFunction(filter)) {
|
|---|
| 1562 | return filter.call(this, value, header);
|
|---|
| 1563 | }
|
|---|
| 1564 | if (isHeaderNameFilter) {
|
|---|
| 1565 | value = header;
|
|---|
| 1566 | }
|
|---|
| 1567 | if (!utils$1.isString(value)) return;
|
|---|
| 1568 | if (utils$1.isString(filter)) {
|
|---|
| 1569 | return value.indexOf(filter) !== -1;
|
|---|
| 1570 | }
|
|---|
| 1571 | if (utils$1.isRegExp(filter)) {
|
|---|
| 1572 | return filter.test(value);
|
|---|
| 1573 | }
|
|---|
| 1574 | }
|
|---|
| 1575 | function formatHeader(header) {
|
|---|
| 1576 | return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
|
|---|
| 1577 | return _char.toUpperCase() + str;
|
|---|
| 1578 | });
|
|---|
| 1579 | }
|
|---|
| 1580 | function buildAccessors(obj, header) {
|
|---|
| 1581 | var accessorName = utils$1.toCamelCase(' ' + header);
|
|---|
| 1582 | ['get', 'set', 'has'].forEach(function (methodName) {
|
|---|
| 1583 | Object.defineProperty(obj, methodName + accessorName, {
|
|---|
| 1584 | // Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|---|
| 1585 | // this data descriptor into an accessor descriptor on the way in.
|
|---|
| 1586 | __proto__: null,
|
|---|
| 1587 | value: function value(arg1, arg2, arg3) {
|
|---|
| 1588 | return this[methodName].call(this, header, arg1, arg2, arg3);
|
|---|
| 1589 | },
|
|---|
| 1590 | configurable: true
|
|---|
| 1591 | });
|
|---|
| 1592 | });
|
|---|
| 1593 | }
|
|---|
| 1594 | var AxiosHeaders = /*#__PURE__*/function () {
|
|---|
| 1595 | function AxiosHeaders(headers) {
|
|---|
| 1596 | _classCallCheck(this, AxiosHeaders);
|
|---|
| 1597 | headers && this.set(headers);
|
|---|
| 1598 | }
|
|---|
| 1599 | return _createClass(AxiosHeaders, [{
|
|---|
| 1600 | key: "set",
|
|---|
| 1601 | value: function set(header, valueOrRewrite, rewrite) {
|
|---|
| 1602 | var self = this;
|
|---|
| 1603 | function setHeader(_value, _header, _rewrite) {
|
|---|
| 1604 | var lHeader = normalizeHeader(_header);
|
|---|
| 1605 | if (!lHeader) {
|
|---|
| 1606 | throw new Error('header name must be a non-empty string');
|
|---|
| 1607 | }
|
|---|
| 1608 | var key = utils$1.findKey(self, lHeader);
|
|---|
| 1609 | if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
|
|---|
| 1610 | self[key || _header] = normalizeValue(_value);
|
|---|
| 1611 | }
|
|---|
| 1612 | }
|
|---|
| 1613 | var setHeaders = function setHeaders(headers, _rewrite) {
|
|---|
| 1614 | return utils$1.forEach(headers, function (_value, _header) {
|
|---|
| 1615 | return setHeader(_value, _header, _rewrite);
|
|---|
| 1616 | });
|
|---|
| 1617 | };
|
|---|
| 1618 | if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|---|
| 1619 | setHeaders(header, valueOrRewrite);
|
|---|
| 1620 | } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|---|
| 1621 | setHeaders(parseHeaders(header), valueOrRewrite);
|
|---|
| 1622 | } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|---|
| 1623 | var obj = {},
|
|---|
| 1624 | dest,
|
|---|
| 1625 | key;
|
|---|
| 1626 | var _iterator = _createForOfIteratorHelper(header),
|
|---|
| 1627 | _step;
|
|---|
| 1628 | try {
|
|---|
| 1629 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|---|
| 1630 | var entry = _step.value;
|
|---|
| 1631 | if (!utils$1.isArray(entry)) {
|
|---|
| 1632 | throw TypeError('Object iterator must return a key-value pair');
|
|---|
| 1633 | }
|
|---|
| 1634 | obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
|
|---|
| 1635 | }
|
|---|
| 1636 | } catch (err) {
|
|---|
| 1637 | _iterator.e(err);
|
|---|
| 1638 | } finally {
|
|---|
| 1639 | _iterator.f();
|
|---|
| 1640 | }
|
|---|
| 1641 | setHeaders(obj, valueOrRewrite);
|
|---|
| 1642 | } else {
|
|---|
| 1643 | header != null && setHeader(valueOrRewrite, header, rewrite);
|
|---|
| 1644 | }
|
|---|
| 1645 | return this;
|
|---|
| 1646 | }
|
|---|
| 1647 | }, {
|
|---|
| 1648 | key: "get",
|
|---|
| 1649 | value: function get(header, parser) {
|
|---|
| 1650 | header = normalizeHeader(header);
|
|---|
| 1651 | if (header) {
|
|---|
| 1652 | var key = utils$1.findKey(this, header);
|
|---|
| 1653 | if (key) {
|
|---|
| 1654 | var value = this[key];
|
|---|
| 1655 | if (!parser) {
|
|---|
| 1656 | return value;
|
|---|
| 1657 | }
|
|---|
| 1658 | if (parser === true) {
|
|---|
| 1659 | return parseTokens(value);
|
|---|
| 1660 | }
|
|---|
| 1661 | if (utils$1.isFunction(parser)) {
|
|---|
| 1662 | return parser.call(this, value, key);
|
|---|
| 1663 | }
|
|---|
| 1664 | if (utils$1.isRegExp(parser)) {
|
|---|
| 1665 | return parser.exec(value);
|
|---|
| 1666 | }
|
|---|
| 1667 | throw new TypeError('parser must be boolean|regexp|function');
|
|---|
| 1668 | }
|
|---|
| 1669 | }
|
|---|
| 1670 | }
|
|---|
| 1671 | }, {
|
|---|
| 1672 | key: "has",
|
|---|
| 1673 | value: function has(header, matcher) {
|
|---|
| 1674 | header = normalizeHeader(header);
|
|---|
| 1675 | if (header) {
|
|---|
| 1676 | var key = utils$1.findKey(this, header);
|
|---|
| 1677 | return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|---|
| 1678 | }
|
|---|
| 1679 | return false;
|
|---|
| 1680 | }
|
|---|
| 1681 | }, {
|
|---|
| 1682 | key: "delete",
|
|---|
| 1683 | value: function _delete(header, matcher) {
|
|---|
| 1684 | var self = this;
|
|---|
| 1685 | var deleted = false;
|
|---|
| 1686 | function deleteHeader(_header) {
|
|---|
| 1687 | _header = normalizeHeader(_header);
|
|---|
| 1688 | if (_header) {
|
|---|
| 1689 | var key = utils$1.findKey(self, _header);
|
|---|
| 1690 | if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|---|
| 1691 | delete self[key];
|
|---|
| 1692 | deleted = true;
|
|---|
| 1693 | }
|
|---|
| 1694 | }
|
|---|
| 1695 | }
|
|---|
| 1696 | if (utils$1.isArray(header)) {
|
|---|
| 1697 | header.forEach(deleteHeader);
|
|---|
| 1698 | } else {
|
|---|
| 1699 | deleteHeader(header);
|
|---|
| 1700 | }
|
|---|
| 1701 | return deleted;
|
|---|
| 1702 | }
|
|---|
| 1703 | }, {
|
|---|
| 1704 | key: "clear",
|
|---|
| 1705 | value: function clear(matcher) {
|
|---|
| 1706 | var keys = Object.keys(this);
|
|---|
| 1707 | var i = keys.length;
|
|---|
| 1708 | var deleted = false;
|
|---|
| 1709 | while (i--) {
|
|---|
| 1710 | var key = keys[i];
|
|---|
| 1711 | if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|---|
| 1712 | delete this[key];
|
|---|
| 1713 | deleted = true;
|
|---|
| 1714 | }
|
|---|
| 1715 | }
|
|---|
| 1716 | return deleted;
|
|---|
| 1717 | }
|
|---|
| 1718 | }, {
|
|---|
| 1719 | key: "normalize",
|
|---|
| 1720 | value: function normalize(format) {
|
|---|
| 1721 | var self = this;
|
|---|
| 1722 | var headers = {};
|
|---|
| 1723 | utils$1.forEach(this, function (value, header) {
|
|---|
| 1724 | var key = utils$1.findKey(headers, header);
|
|---|
| 1725 | if (key) {
|
|---|
| 1726 | self[key] = normalizeValue(value);
|
|---|
| 1727 | delete self[header];
|
|---|
| 1728 | return;
|
|---|
| 1729 | }
|
|---|
| 1730 | var normalized = format ? formatHeader(header) : String(header).trim();
|
|---|
| 1731 | if (normalized !== header) {
|
|---|
| 1732 | delete self[header];
|
|---|
| 1733 | }
|
|---|
| 1734 | self[normalized] = normalizeValue(value);
|
|---|
| 1735 | headers[normalized] = true;
|
|---|
| 1736 | });
|
|---|
| 1737 | return this;
|
|---|
| 1738 | }
|
|---|
| 1739 | }, {
|
|---|
| 1740 | key: "concat",
|
|---|
| 1741 | value: function concat() {
|
|---|
| 1742 | var _this$constructor;
|
|---|
| 1743 | for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
|
|---|
| 1744 | targets[_key] = arguments[_key];
|
|---|
| 1745 | }
|
|---|
| 1746 | return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
|
|---|
| 1747 | }
|
|---|
| 1748 | }, {
|
|---|
| 1749 | key: "toJSON",
|
|---|
| 1750 | value: function toJSON(asStrings) {
|
|---|
| 1751 | var obj = Object.create(null);
|
|---|
| 1752 | utils$1.forEach(this, function (value, header) {
|
|---|
| 1753 | value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|---|
| 1754 | });
|
|---|
| 1755 | return obj;
|
|---|
| 1756 | }
|
|---|
| 1757 | }, {
|
|---|
| 1758 | key: Symbol.iterator,
|
|---|
| 1759 | value: function value() {
|
|---|
| 1760 | return Object.entries(this.toJSON())[Symbol.iterator]();
|
|---|
| 1761 | }
|
|---|
| 1762 | }, {
|
|---|
| 1763 | key: "toString",
|
|---|
| 1764 | value: function toString() {
|
|---|
| 1765 | return Object.entries(this.toJSON()).map(function (_ref) {
|
|---|
| 1766 | var _ref2 = _slicedToArray(_ref, 2),
|
|---|
| 1767 | header = _ref2[0],
|
|---|
| 1768 | value = _ref2[1];
|
|---|
| 1769 | return header + ': ' + value;
|
|---|
| 1770 | }).join('\n');
|
|---|
| 1771 | }
|
|---|
| 1772 | }, {
|
|---|
| 1773 | key: "getSetCookie",
|
|---|
| 1774 | value: function getSetCookie() {
|
|---|
| 1775 | return this.get('set-cookie') || [];
|
|---|
| 1776 | }
|
|---|
| 1777 | }, {
|
|---|
| 1778 | key: Symbol.toStringTag,
|
|---|
| 1779 | get: function get() {
|
|---|
| 1780 | return 'AxiosHeaders';
|
|---|
| 1781 | }
|
|---|
| 1782 | }], [{
|
|---|
| 1783 | key: "from",
|
|---|
| 1784 | value: function from(thing) {
|
|---|
| 1785 | return thing instanceof this ? thing : new this(thing);
|
|---|
| 1786 | }
|
|---|
| 1787 | }, {
|
|---|
| 1788 | key: "concat",
|
|---|
| 1789 | value: function concat(first) {
|
|---|
| 1790 | var computed = new this(first);
|
|---|
| 1791 | for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|---|
| 1792 | targets[_key2 - 1] = arguments[_key2];
|
|---|
| 1793 | }
|
|---|
| 1794 | targets.forEach(function (target) {
|
|---|
| 1795 | return computed.set(target);
|
|---|
| 1796 | });
|
|---|
| 1797 | return computed;
|
|---|
| 1798 | }
|
|---|
| 1799 | }, {
|
|---|
| 1800 | key: "accessor",
|
|---|
| 1801 | value: function accessor(header) {
|
|---|
| 1802 | var internals = this[$internals] = this[$internals] = {
|
|---|
| 1803 | accessors: {}
|
|---|
| 1804 | };
|
|---|
| 1805 | var accessors = internals.accessors;
|
|---|
| 1806 | var prototype = this.prototype;
|
|---|
| 1807 | function defineAccessor(_header) {
|
|---|
| 1808 | var lHeader = normalizeHeader(_header);
|
|---|
| 1809 | if (!accessors[lHeader]) {
|
|---|
| 1810 | buildAccessors(prototype, _header);
|
|---|
| 1811 | accessors[lHeader] = true;
|
|---|
| 1812 | }
|
|---|
| 1813 | }
|
|---|
| 1814 | utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|---|
| 1815 | return this;
|
|---|
| 1816 | }
|
|---|
| 1817 | }]);
|
|---|
| 1818 | }();
|
|---|
| 1819 | AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|---|
| 1820 |
|
|---|
| 1821 | // reserved names hotfix
|
|---|
| 1822 | utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
|
|---|
| 1823 | var value = _ref3.value;
|
|---|
| 1824 | var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|---|
| 1825 | return {
|
|---|
| 1826 | get: function get() {
|
|---|
| 1827 | return value;
|
|---|
| 1828 | },
|
|---|
| 1829 | set: function set(headerValue) {
|
|---|
| 1830 | this[mapped] = headerValue;
|
|---|
| 1831 | }
|
|---|
| 1832 | };
|
|---|
| 1833 | });
|
|---|
| 1834 | utils$1.freezeMethods(AxiosHeaders);
|
|---|
| 1835 |
|
|---|
| 1836 | var REDACTED = '[REDACTED ****]';
|
|---|
| 1837 | function hasOwnOrPrototypeToJSON(source) {
|
|---|
| 1838 | if (utils$1.hasOwnProp(source, 'toJSON')) {
|
|---|
| 1839 | return true;
|
|---|
| 1840 | }
|
|---|
| 1841 | var prototype = Object.getPrototypeOf(source);
|
|---|
| 1842 | while (prototype && prototype !== Object.prototype) {
|
|---|
| 1843 | if (utils$1.hasOwnProp(prototype, 'toJSON')) {
|
|---|
| 1844 | return true;
|
|---|
| 1845 | }
|
|---|
| 1846 | prototype = Object.getPrototypeOf(prototype);
|
|---|
| 1847 | }
|
|---|
| 1848 | return false;
|
|---|
| 1849 | }
|
|---|
| 1850 |
|
|---|
| 1851 | // Build a plain-object snapshot of `config` and replace the value of any key
|
|---|
| 1852 | // (case-insensitive) listed in `redactKeys` with REDACTED. Walks through arrays
|
|---|
| 1853 | // and AxiosHeaders, and short-circuits on circular references.
|
|---|
| 1854 | function redactConfig(config, redactKeys) {
|
|---|
| 1855 | var lowerKeys = new Set(redactKeys.map(function (k) {
|
|---|
| 1856 | return String(k).toLowerCase();
|
|---|
| 1857 | }));
|
|---|
| 1858 | var seen = [];
|
|---|
| 1859 | var _visit = function visit(source) {
|
|---|
| 1860 | if (source === null || _typeof(source) !== 'object') return source;
|
|---|
| 1861 | if (utils$1.isBuffer(source)) return source;
|
|---|
| 1862 | if (seen.indexOf(source) !== -1) return undefined;
|
|---|
| 1863 | if (source instanceof AxiosHeaders) {
|
|---|
| 1864 | source = source.toJSON();
|
|---|
| 1865 | }
|
|---|
| 1866 | seen.push(source);
|
|---|
| 1867 | var result;
|
|---|
| 1868 | if (utils$1.isArray(source)) {
|
|---|
| 1869 | result = [];
|
|---|
| 1870 | source.forEach(function (v, i) {
|
|---|
| 1871 | var reducedValue = _visit(v);
|
|---|
| 1872 | if (!utils$1.isUndefined(reducedValue)) {
|
|---|
| 1873 | result[i] = reducedValue;
|
|---|
| 1874 | }
|
|---|
| 1875 | });
|
|---|
| 1876 | } else {
|
|---|
| 1877 | if (!utils$1.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
|
|---|
| 1878 | seen.pop();
|
|---|
| 1879 | return source;
|
|---|
| 1880 | }
|
|---|
| 1881 | result = Object.create(null);
|
|---|
| 1882 | for (var _i = 0, _Object$entries = Object.entries(source); _i < _Object$entries.length; _i++) {
|
|---|
| 1883 | var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|---|
| 1884 | key = _Object$entries$_i[0],
|
|---|
| 1885 | value = _Object$entries$_i[1];
|
|---|
| 1886 | var reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : _visit(value);
|
|---|
| 1887 | if (!utils$1.isUndefined(reducedValue)) {
|
|---|
| 1888 | result[key] = reducedValue;
|
|---|
| 1889 | }
|
|---|
| 1890 | }
|
|---|
| 1891 | }
|
|---|
| 1892 | seen.pop();
|
|---|
| 1893 | return result;
|
|---|
| 1894 | };
|
|---|
| 1895 | return _visit(config);
|
|---|
| 1896 | }
|
|---|
| 1897 | var AxiosError = /*#__PURE__*/function (_Error) {
|
|---|
| 1898 | /**
|
|---|
| 1899 | * Create an Error with the specified message, config, error code, request and response.
|
|---|
| 1900 | *
|
|---|
| 1901 | * @param {string} message The error message.
|
|---|
| 1902 | * @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|---|
| 1903 | * @param {Object} [config] The config.
|
|---|
| 1904 | * @param {Object} [request] The request.
|
|---|
| 1905 | * @param {Object} [response] The response.
|
|---|
| 1906 | *
|
|---|
| 1907 | * @returns {Error} The created error.
|
|---|
| 1908 | */
|
|---|
| 1909 | function AxiosError(message, code, config, request, response) {
|
|---|
| 1910 | var _this;
|
|---|
| 1911 | _classCallCheck(this, AxiosError);
|
|---|
| 1912 | _this = _callSuper(this, AxiosError, [message]);
|
|---|
| 1913 |
|
|---|
| 1914 | // Make message enumerable to maintain backward compatibility
|
|---|
| 1915 | // The native Error constructor sets message as non-enumerable,
|
|---|
| 1916 | // but axios < v1.13.3 had it as enumerable
|
|---|
| 1917 | Object.defineProperty(_this, 'message', {
|
|---|
| 1918 | // Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|---|
| 1919 | // this data descriptor into an accessor descriptor on the way in.
|
|---|
| 1920 | __proto__: null,
|
|---|
| 1921 | value: message,
|
|---|
| 1922 | enumerable: true,
|
|---|
| 1923 | writable: true,
|
|---|
| 1924 | configurable: true
|
|---|
| 1925 | });
|
|---|
| 1926 | _this.name = 'AxiosError';
|
|---|
| 1927 | _this.isAxiosError = true;
|
|---|
| 1928 | code && (_this.code = code);
|
|---|
| 1929 | config && (_this.config = config);
|
|---|
| 1930 | request && (_this.request = request);
|
|---|
| 1931 | if (response) {
|
|---|
| 1932 | _this.response = response;
|
|---|
| 1933 | _this.status = response.status;
|
|---|
| 1934 | }
|
|---|
| 1935 | return _this;
|
|---|
| 1936 | }
|
|---|
| 1937 | _inherits(AxiosError, _Error);
|
|---|
| 1938 | return _createClass(AxiosError, [{
|
|---|
| 1939 | key: "toJSON",
|
|---|
| 1940 | value: function toJSON() {
|
|---|
| 1941 | // Opt-in redaction: when the request config carries a `redact` array, the
|
|---|
| 1942 | // value of any matching key (case-insensitive, at any depth) is replaced
|
|---|
| 1943 | // with REDACTED in the serialized snapshot. Undefined or empty leaves the
|
|---|
| 1944 | // existing serialization behavior unchanged.
|
|---|
| 1945 | var config = this.config;
|
|---|
| 1946 | var redactKeys = config && utils$1.hasOwnProp(config, 'redact') ? config.redact : undefined;
|
|---|
| 1947 | var serializedConfig = utils$1.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils$1.toJSONObject(config);
|
|---|
| 1948 | return {
|
|---|
| 1949 | // Standard
|
|---|
| 1950 | message: this.message,
|
|---|
| 1951 | name: this.name,
|
|---|
| 1952 | // Microsoft
|
|---|
| 1953 | description: this.description,
|
|---|
| 1954 | number: this.number,
|
|---|
| 1955 | // Mozilla
|
|---|
| 1956 | fileName: this.fileName,
|
|---|
| 1957 | lineNumber: this.lineNumber,
|
|---|
| 1958 | columnNumber: this.columnNumber,
|
|---|
| 1959 | stack: this.stack,
|
|---|
| 1960 | // Axios
|
|---|
| 1961 | config: serializedConfig,
|
|---|
| 1962 | code: this.code,
|
|---|
| 1963 | status: this.status
|
|---|
| 1964 | };
|
|---|
| 1965 | }
|
|---|
| 1966 | }], [{
|
|---|
| 1967 | key: "from",
|
|---|
| 1968 | value: function from(error, code, config, request, response, customProps) {
|
|---|
| 1969 | var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|---|
| 1970 | axiosError.cause = error;
|
|---|
| 1971 | axiosError.name = error.name;
|
|---|
| 1972 |
|
|---|
| 1973 | // Preserve status from the original error if not already set from response
|
|---|
| 1974 | if (error.status != null && axiosError.status == null) {
|
|---|
| 1975 | axiosError.status = error.status;
|
|---|
| 1976 | }
|
|---|
| 1977 | customProps && Object.assign(axiosError, customProps);
|
|---|
| 1978 | return axiosError;
|
|---|
| 1979 | }
|
|---|
| 1980 | }]);
|
|---|
| 1981 | }(/*#__PURE__*/_wrapNativeSuper(Error)); // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
|
|---|
| 1982 | AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
|
|---|
| 1983 | AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
|
|---|
| 1984 | AxiosError.ECONNABORTED = 'ECONNABORTED';
|
|---|
| 1985 | AxiosError.ETIMEDOUT = 'ETIMEDOUT';
|
|---|
| 1986 | AxiosError.ECONNREFUSED = 'ECONNREFUSED';
|
|---|
| 1987 | AxiosError.ERR_NETWORK = 'ERR_NETWORK';
|
|---|
| 1988 | AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
|
|---|
| 1989 | AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
|
|---|
| 1990 | AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
|
|---|
| 1991 | AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
|
|---|
| 1992 | AxiosError.ERR_CANCELED = 'ERR_CANCELED';
|
|---|
| 1993 | AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
|
|---|
| 1994 | AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
|
|---|
| 1995 | AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = 'ERR_FORM_DATA_DEPTH_EXCEEDED';
|
|---|
| 1996 |
|
|---|
| 1997 | // eslint-disable-next-line strict
|
|---|
| 1998 | var httpAdapter = null;
|
|---|
| 1999 |
|
|---|
| 2000 | /**
|
|---|
| 2001 | * Determines if the given thing is a array or js object.
|
|---|
| 2002 | *
|
|---|
| 2003 | * @param {string} thing - The object or array to be visited.
|
|---|
| 2004 | *
|
|---|
| 2005 | * @returns {boolean}
|
|---|
| 2006 | */
|
|---|
| 2007 | function isVisitable(thing) {
|
|---|
| 2008 | return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|---|
| 2009 | }
|
|---|
| 2010 |
|
|---|
| 2011 | /**
|
|---|
| 2012 | * It removes the brackets from the end of a string
|
|---|
| 2013 | *
|
|---|
| 2014 | * @param {string} key - The key of the parameter.
|
|---|
| 2015 | *
|
|---|
| 2016 | * @returns {string} the key without the brackets.
|
|---|
| 2017 | */
|
|---|
| 2018 | function removeBrackets(key) {
|
|---|
| 2019 | return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|---|
| 2020 | }
|
|---|
| 2021 |
|
|---|
| 2022 | /**
|
|---|
| 2023 | * It takes a path, a key, and a boolean, and returns a string
|
|---|
| 2024 | *
|
|---|
| 2025 | * @param {string} path - The path to the current key.
|
|---|
| 2026 | * @param {string} key - The key of the current object being iterated over.
|
|---|
| 2027 | * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
|---|
| 2028 | *
|
|---|
| 2029 | * @returns {string} The path to the current key.
|
|---|
| 2030 | */
|
|---|
| 2031 | function renderKey(path, key, dots) {
|
|---|
| 2032 | if (!path) return key;
|
|---|
| 2033 | return path.concat(key).map(function each(token, i) {
|
|---|
| 2034 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2035 | token = removeBrackets(token);
|
|---|
| 2036 | return !dots && i ? '[' + token + ']' : token;
|
|---|
| 2037 | }).join(dots ? '.' : '');
|
|---|
| 2038 | }
|
|---|
| 2039 |
|
|---|
| 2040 | /**
|
|---|
| 2041 | * If the array is an array and none of its elements are visitable, then it's a flat array.
|
|---|
| 2042 | *
|
|---|
| 2043 | * @param {Array<any>} arr - The array to check
|
|---|
| 2044 | *
|
|---|
| 2045 | * @returns {boolean}
|
|---|
| 2046 | */
|
|---|
| 2047 | function isFlatArray(arr) {
|
|---|
| 2048 | return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|---|
| 2049 | }
|
|---|
| 2050 | var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|---|
| 2051 | return /^is[A-Z]/.test(prop);
|
|---|
| 2052 | });
|
|---|
| 2053 |
|
|---|
| 2054 | /**
|
|---|
| 2055 | * Convert a data object to FormData
|
|---|
| 2056 | *
|
|---|
| 2057 | * @param {Object} obj
|
|---|
| 2058 | * @param {?Object} [formData]
|
|---|
| 2059 | * @param {?Object} [options]
|
|---|
| 2060 | * @param {Function} [options.visitor]
|
|---|
| 2061 | * @param {Boolean} [options.metaTokens = true]
|
|---|
| 2062 | * @param {Boolean} [options.dots = false]
|
|---|
| 2063 | * @param {?Boolean} [options.indexes = false]
|
|---|
| 2064 | *
|
|---|
| 2065 | * @returns {Object}
|
|---|
| 2066 | **/
|
|---|
| 2067 |
|
|---|
| 2068 | /**
|
|---|
| 2069 | * It converts an object into a FormData object
|
|---|
| 2070 | *
|
|---|
| 2071 | * @param {Object<any, any>} obj - The object to convert to form data.
|
|---|
| 2072 | * @param {string} formData - The FormData object to append to.
|
|---|
| 2073 | * @param {Object<string, any>} options
|
|---|
| 2074 | *
|
|---|
| 2075 | * @returns
|
|---|
| 2076 | */
|
|---|
| 2077 | function toFormData(obj, formData, options) {
|
|---|
| 2078 | if (!utils$1.isObject(obj)) {
|
|---|
| 2079 | throw new TypeError('target must be an object');
|
|---|
| 2080 | }
|
|---|
| 2081 |
|
|---|
| 2082 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2083 | formData = formData || new (FormData)();
|
|---|
| 2084 |
|
|---|
| 2085 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2086 | options = utils$1.toFlatObject(options, {
|
|---|
| 2087 | metaTokens: true,
|
|---|
| 2088 | dots: false,
|
|---|
| 2089 | indexes: false
|
|---|
| 2090 | }, false, function defined(option, source) {
|
|---|
| 2091 | // eslint-disable-next-line no-eq-null,eqeqeq
|
|---|
| 2092 | return !utils$1.isUndefined(source[option]);
|
|---|
| 2093 | });
|
|---|
| 2094 | var metaTokens = options.metaTokens;
|
|---|
| 2095 | // eslint-disable-next-line no-use-before-define
|
|---|
| 2096 | var visitor = options.visitor || defaultVisitor;
|
|---|
| 2097 | var dots = options.dots;
|
|---|
| 2098 | var indexes = options.indexes;
|
|---|
| 2099 | var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|---|
| 2100 | var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
|
|---|
| 2101 | var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|---|
| 2102 | if (!utils$1.isFunction(visitor)) {
|
|---|
| 2103 | throw new TypeError('visitor must be a function');
|
|---|
| 2104 | }
|
|---|
| 2105 | function convertValue(value) {
|
|---|
| 2106 | if (value === null) return '';
|
|---|
| 2107 | if (utils$1.isDate(value)) {
|
|---|
| 2108 | return value.toISOString();
|
|---|
| 2109 | }
|
|---|
| 2110 | if (utils$1.isBoolean(value)) {
|
|---|
| 2111 | return value.toString();
|
|---|
| 2112 | }
|
|---|
| 2113 | if (!useBlob && utils$1.isBlob(value)) {
|
|---|
| 2114 | throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|---|
| 2115 | }
|
|---|
| 2116 | if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|---|
| 2117 | return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|---|
| 2118 | }
|
|---|
| 2119 | return value;
|
|---|
| 2120 | }
|
|---|
| 2121 |
|
|---|
| 2122 | /**
|
|---|
| 2123 | * Default visitor.
|
|---|
| 2124 | *
|
|---|
| 2125 | * @param {*} value
|
|---|
| 2126 | * @param {String|Number} key
|
|---|
| 2127 | * @param {Array<String|Number>} path
|
|---|
| 2128 | * @this {FormData}
|
|---|
| 2129 | *
|
|---|
| 2130 | * @returns {boolean} return true to visit the each prop of the value recursively
|
|---|
| 2131 | */
|
|---|
| 2132 | function defaultVisitor(value, key, path) {
|
|---|
| 2133 | var arr = value;
|
|---|
| 2134 | if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
|
|---|
| 2135 | formData.append(renderKey(path, key, dots), convertValue(value));
|
|---|
| 2136 | return false;
|
|---|
| 2137 | }
|
|---|
| 2138 | if (value && !path && _typeof(value) === 'object') {
|
|---|
| 2139 | if (utils$1.endsWith(key, '{}')) {
|
|---|
| 2140 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2141 | key = metaTokens ? key : key.slice(0, -2);
|
|---|
| 2142 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2143 | value = JSON.stringify(value);
|
|---|
| 2144 | } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
|
|---|
| 2145 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2146 | key = removeBrackets(key);
|
|---|
| 2147 | arr.forEach(function each(el, index) {
|
|---|
| 2148 | !(utils$1.isUndefined(el) || el === null) && formData.append(
|
|---|
| 2149 | // eslint-disable-next-line no-nested-ternary
|
|---|
| 2150 | indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
|
|---|
| 2151 | });
|
|---|
| 2152 | return false;
|
|---|
| 2153 | }
|
|---|
| 2154 | }
|
|---|
| 2155 | if (isVisitable(value)) {
|
|---|
| 2156 | return true;
|
|---|
| 2157 | }
|
|---|
| 2158 | formData.append(renderKey(path, key, dots), convertValue(value));
|
|---|
| 2159 | return false;
|
|---|
| 2160 | }
|
|---|
| 2161 | var stack = [];
|
|---|
| 2162 | var exposedHelpers = Object.assign(predicates, {
|
|---|
| 2163 | defaultVisitor: defaultVisitor,
|
|---|
| 2164 | convertValue: convertValue,
|
|---|
| 2165 | isVisitable: isVisitable
|
|---|
| 2166 | });
|
|---|
| 2167 | function build(value, path) {
|
|---|
| 2168 | var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|---|
| 2169 | if (utils$1.isUndefined(value)) return;
|
|---|
| 2170 | if (depth > maxDepth) {
|
|---|
| 2171 | throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
|
|---|
| 2172 | }
|
|---|
| 2173 | if (stack.indexOf(value) !== -1) {
|
|---|
| 2174 | throw Error('Circular reference detected in ' + path.join('.'));
|
|---|
| 2175 | }
|
|---|
| 2176 | stack.push(value);
|
|---|
| 2177 | utils$1.forEach(value, function each(el, key) {
|
|---|
| 2178 | var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
|
|---|
| 2179 | if (result === true) {
|
|---|
| 2180 | build(el, path ? path.concat(key) : [key], depth + 1);
|
|---|
| 2181 | }
|
|---|
| 2182 | });
|
|---|
| 2183 | stack.pop();
|
|---|
| 2184 | }
|
|---|
| 2185 | if (!utils$1.isObject(obj)) {
|
|---|
| 2186 | throw new TypeError('data must be an object');
|
|---|
| 2187 | }
|
|---|
| 2188 | build(obj);
|
|---|
| 2189 | return formData;
|
|---|
| 2190 | }
|
|---|
| 2191 |
|
|---|
| 2192 | /**
|
|---|
| 2193 | * It encodes a string by replacing all characters that are not in the unreserved set with
|
|---|
| 2194 | * their percent-encoded equivalents
|
|---|
| 2195 | *
|
|---|
| 2196 | * @param {string} str - The string to encode.
|
|---|
| 2197 | *
|
|---|
| 2198 | * @returns {string} The encoded string.
|
|---|
| 2199 | */
|
|---|
| 2200 | function encode$1(str) {
|
|---|
| 2201 | var charMap = {
|
|---|
| 2202 | '!': '%21',
|
|---|
| 2203 | "'": '%27',
|
|---|
| 2204 | '(': '%28',
|
|---|
| 2205 | ')': '%29',
|
|---|
| 2206 | '~': '%7E',
|
|---|
| 2207 | '%20': '+'
|
|---|
| 2208 | };
|
|---|
| 2209 | return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
|
|---|
| 2210 | return charMap[match];
|
|---|
| 2211 | });
|
|---|
| 2212 | }
|
|---|
| 2213 |
|
|---|
| 2214 | /**
|
|---|
| 2215 | * It takes a params object and converts it to a FormData object
|
|---|
| 2216 | *
|
|---|
| 2217 | * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
|---|
| 2218 | * @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
|---|
| 2219 | *
|
|---|
| 2220 | * @returns {void}
|
|---|
| 2221 | */
|
|---|
| 2222 | function AxiosURLSearchParams(params, options) {
|
|---|
| 2223 | this._pairs = [];
|
|---|
| 2224 | params && toFormData(params, this, options);
|
|---|
| 2225 | }
|
|---|
| 2226 | var prototype = AxiosURLSearchParams.prototype;
|
|---|
| 2227 | prototype.append = function append(name, value) {
|
|---|
| 2228 | this._pairs.push([name, value]);
|
|---|
| 2229 | };
|
|---|
| 2230 | prototype.toString = function toString(encoder) {
|
|---|
| 2231 | var _encode = encoder ? function (value) {
|
|---|
| 2232 | return encoder.call(this, value, encode$1);
|
|---|
| 2233 | } : encode$1;
|
|---|
| 2234 | return this._pairs.map(function each(pair) {
|
|---|
| 2235 | return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|---|
| 2236 | }, '').join('&');
|
|---|
| 2237 | };
|
|---|
| 2238 |
|
|---|
| 2239 | /**
|
|---|
| 2240 | * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
|
|---|
| 2241 | * their plain counterparts (`:`, `$`, `,`, `+`).
|
|---|
| 2242 | *
|
|---|
| 2243 | * @param {string} val The value to be encoded.
|
|---|
| 2244 | *
|
|---|
| 2245 | * @returns {string} The encoded value.
|
|---|
| 2246 | */
|
|---|
| 2247 | function encode(val) {
|
|---|
| 2248 | return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+');
|
|---|
| 2249 | }
|
|---|
| 2250 |
|
|---|
| 2251 | /**
|
|---|
| 2252 | * Build a URL by appending params to the end
|
|---|
| 2253 | *
|
|---|
| 2254 | * @param {string} url The base of the url (e.g., http://www.google.com)
|
|---|
| 2255 | * @param {object} [params] The params to be appended
|
|---|
| 2256 | * @param {?(object|Function)} options
|
|---|
| 2257 | *
|
|---|
| 2258 | * @returns {string} The formatted url
|
|---|
| 2259 | */
|
|---|
| 2260 | function buildURL(url, params, options) {
|
|---|
| 2261 | if (!params) {
|
|---|
| 2262 | return url;
|
|---|
| 2263 | }
|
|---|
| 2264 | var _encode = options && options.encode || encode;
|
|---|
| 2265 | var _options = utils$1.isFunction(options) ? {
|
|---|
| 2266 | serialize: options
|
|---|
| 2267 | } : options;
|
|---|
| 2268 | var serializeFn = _options && _options.serialize;
|
|---|
| 2269 | var serializedParams;
|
|---|
| 2270 | if (serializeFn) {
|
|---|
| 2271 | serializedParams = serializeFn(params, _options);
|
|---|
| 2272 | } else {
|
|---|
| 2273 | serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
|
|---|
| 2274 | }
|
|---|
| 2275 | if (serializedParams) {
|
|---|
| 2276 | var hashmarkIndex = url.indexOf('#');
|
|---|
| 2277 | if (hashmarkIndex !== -1) {
|
|---|
| 2278 | url = url.slice(0, hashmarkIndex);
|
|---|
| 2279 | }
|
|---|
| 2280 | url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|---|
| 2281 | }
|
|---|
| 2282 | return url;
|
|---|
| 2283 | }
|
|---|
| 2284 |
|
|---|
| 2285 | var InterceptorManager = /*#__PURE__*/function () {
|
|---|
| 2286 | function InterceptorManager() {
|
|---|
| 2287 | _classCallCheck(this, InterceptorManager);
|
|---|
| 2288 | this.handlers = [];
|
|---|
| 2289 | }
|
|---|
| 2290 |
|
|---|
| 2291 | /**
|
|---|
| 2292 | * Add a new interceptor to the stack
|
|---|
| 2293 | *
|
|---|
| 2294 | * @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|---|
| 2295 | * @param {Function} rejected The function to handle `reject` for a `Promise`
|
|---|
| 2296 | * @param {Object} options The options for the interceptor, synchronous and runWhen
|
|---|
| 2297 | *
|
|---|
| 2298 | * @return {Number} An ID used to remove interceptor later
|
|---|
| 2299 | */
|
|---|
| 2300 | return _createClass(InterceptorManager, [{
|
|---|
| 2301 | key: "use",
|
|---|
| 2302 | value: function use(fulfilled, rejected, options) {
|
|---|
| 2303 | this.handlers.push({
|
|---|
| 2304 | fulfilled: fulfilled,
|
|---|
| 2305 | rejected: rejected,
|
|---|
| 2306 | synchronous: options ? options.synchronous : false,
|
|---|
| 2307 | runWhen: options ? options.runWhen : null
|
|---|
| 2308 | });
|
|---|
| 2309 | return this.handlers.length - 1;
|
|---|
| 2310 | }
|
|---|
| 2311 |
|
|---|
| 2312 | /**
|
|---|
| 2313 | * Remove an interceptor from the stack
|
|---|
| 2314 | *
|
|---|
| 2315 | * @param {Number} id The ID that was returned by `use`
|
|---|
| 2316 | *
|
|---|
| 2317 | * @returns {void}
|
|---|
| 2318 | */
|
|---|
| 2319 | }, {
|
|---|
| 2320 | key: "eject",
|
|---|
| 2321 | value: function eject(id) {
|
|---|
| 2322 | if (this.handlers[id]) {
|
|---|
| 2323 | this.handlers[id] = null;
|
|---|
| 2324 | }
|
|---|
| 2325 | }
|
|---|
| 2326 |
|
|---|
| 2327 | /**
|
|---|
| 2328 | * Clear all interceptors from the stack
|
|---|
| 2329 | *
|
|---|
| 2330 | * @returns {void}
|
|---|
| 2331 | */
|
|---|
| 2332 | }, {
|
|---|
| 2333 | key: "clear",
|
|---|
| 2334 | value: function clear() {
|
|---|
| 2335 | if (this.handlers) {
|
|---|
| 2336 | this.handlers = [];
|
|---|
| 2337 | }
|
|---|
| 2338 | }
|
|---|
| 2339 |
|
|---|
| 2340 | /**
|
|---|
| 2341 | * Iterate over all the registered interceptors
|
|---|
| 2342 | *
|
|---|
| 2343 | * This method is particularly useful for skipping over any
|
|---|
| 2344 | * interceptors that may have become `null` calling `eject`.
|
|---|
| 2345 | *
|
|---|
| 2346 | * @param {Function} fn The function to call for each interceptor
|
|---|
| 2347 | *
|
|---|
| 2348 | * @returns {void}
|
|---|
| 2349 | */
|
|---|
| 2350 | }, {
|
|---|
| 2351 | key: "forEach",
|
|---|
| 2352 | value: function forEach(fn) {
|
|---|
| 2353 | utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|---|
| 2354 | if (h !== null) {
|
|---|
| 2355 | fn(h);
|
|---|
| 2356 | }
|
|---|
| 2357 | });
|
|---|
| 2358 | }
|
|---|
| 2359 | }]);
|
|---|
| 2360 | }();
|
|---|
| 2361 |
|
|---|
| 2362 | var transitionalDefaults = {
|
|---|
| 2363 | silentJSONParsing: true,
|
|---|
| 2364 | forcedJSONParsing: true,
|
|---|
| 2365 | clarifyTimeoutError: false,
|
|---|
| 2366 | legacyInterceptorReqResOrdering: true
|
|---|
| 2367 | };
|
|---|
| 2368 |
|
|---|
| 2369 | var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
|---|
| 2370 |
|
|---|
| 2371 | var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|---|
| 2372 |
|
|---|
| 2373 | var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|---|
| 2374 |
|
|---|
| 2375 | var platform$1 = {
|
|---|
| 2376 | isBrowser: true,
|
|---|
| 2377 | classes: {
|
|---|
| 2378 | URLSearchParams: URLSearchParams$1,
|
|---|
| 2379 | FormData: FormData$1,
|
|---|
| 2380 | Blob: Blob$1
|
|---|
| 2381 | },
|
|---|
| 2382 | protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|---|
| 2383 | };
|
|---|
| 2384 |
|
|---|
| 2385 | var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|---|
| 2386 | var _navigator = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && navigator || undefined;
|
|---|
| 2387 |
|
|---|
| 2388 | /**
|
|---|
| 2389 | * Determine if we're running in a standard browser environment
|
|---|
| 2390 | *
|
|---|
| 2391 | * This allows axios to run in a web worker, and react-native.
|
|---|
| 2392 | * Both environments support XMLHttpRequest, but not fully standard globals.
|
|---|
| 2393 | *
|
|---|
| 2394 | * web workers:
|
|---|
| 2395 | * typeof window -> undefined
|
|---|
| 2396 | * typeof document -> undefined
|
|---|
| 2397 | *
|
|---|
| 2398 | * react-native:
|
|---|
| 2399 | * navigator.product -> 'ReactNative'
|
|---|
| 2400 | * nativescript
|
|---|
| 2401 | * navigator.product -> 'NativeScript' or 'NS'
|
|---|
| 2402 | *
|
|---|
| 2403 | * @returns {boolean}
|
|---|
| 2404 | */
|
|---|
| 2405 | var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|---|
| 2406 |
|
|---|
| 2407 | /**
|
|---|
| 2408 | * Determine if we're running in a standard browser webWorker environment
|
|---|
| 2409 | *
|
|---|
| 2410 | * Although the `isStandardBrowserEnv` method indicates that
|
|---|
| 2411 | * `allows axios to run in a web worker`, the WebWorker will still be
|
|---|
| 2412 | * filtered out due to its judgment standard
|
|---|
| 2413 | * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|---|
| 2414 | * This leads to a problem when axios post `FormData` in webWorker
|
|---|
| 2415 | */
|
|---|
| 2416 | var hasStandardBrowserWebWorkerEnv = function () {
|
|---|
| 2417 | return typeof WorkerGlobalScope !== 'undefined' &&
|
|---|
| 2418 | // eslint-disable-next-line no-undef
|
|---|
| 2419 | self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
|
|---|
| 2420 | }();
|
|---|
| 2421 | var origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|---|
| 2422 |
|
|---|
| 2423 | var utils = /*#__PURE__*/Object.freeze({
|
|---|
| 2424 | __proto__: null,
|
|---|
| 2425 | hasBrowserEnv: hasBrowserEnv,
|
|---|
| 2426 | hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|---|
| 2427 | hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|---|
| 2428 | navigator: _navigator,
|
|---|
| 2429 | origin: origin
|
|---|
| 2430 | });
|
|---|
| 2431 |
|
|---|
| 2432 | var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
|
|---|
| 2433 |
|
|---|
| 2434 | function toURLEncodedForm(data, options) {
|
|---|
| 2435 | return toFormData(data, new platform.classes.URLSearchParams(), _objectSpread2({
|
|---|
| 2436 | visitor: function visitor(value, key, path, helpers) {
|
|---|
| 2437 | if (platform.isNode && utils$1.isBuffer(value)) {
|
|---|
| 2438 | this.append(key, value.toString('base64'));
|
|---|
| 2439 | return false;
|
|---|
| 2440 | }
|
|---|
| 2441 | return helpers.defaultVisitor.apply(this, arguments);
|
|---|
| 2442 | }
|
|---|
| 2443 | }, options));
|
|---|
| 2444 | }
|
|---|
| 2445 |
|
|---|
| 2446 | /**
|
|---|
| 2447 | * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|---|
| 2448 | *
|
|---|
| 2449 | * @param {string} name - The name of the property to get.
|
|---|
| 2450 | *
|
|---|
| 2451 | * @returns An array of strings.
|
|---|
| 2452 | */
|
|---|
| 2453 | function parsePropPath(name) {
|
|---|
| 2454 | // foo[x][y][z]
|
|---|
| 2455 | // foo.x.y.z
|
|---|
| 2456 | // foo-x-y-z
|
|---|
| 2457 | // foo x y z
|
|---|
| 2458 | return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
|
|---|
| 2459 | return match[0] === '[]' ? '' : match[1] || match[0];
|
|---|
| 2460 | });
|
|---|
| 2461 | }
|
|---|
| 2462 |
|
|---|
| 2463 | /**
|
|---|
| 2464 | * Convert an array to an object.
|
|---|
| 2465 | *
|
|---|
| 2466 | * @param {Array<any>} arr - The array to convert to an object.
|
|---|
| 2467 | *
|
|---|
| 2468 | * @returns An object with the same keys and values as the array.
|
|---|
| 2469 | */
|
|---|
| 2470 | function arrayToObject(arr) {
|
|---|
| 2471 | var obj = {};
|
|---|
| 2472 | var keys = Object.keys(arr);
|
|---|
| 2473 | var i;
|
|---|
| 2474 | var len = keys.length;
|
|---|
| 2475 | var key;
|
|---|
| 2476 | for (i = 0; i < len; i++) {
|
|---|
| 2477 | key = keys[i];
|
|---|
| 2478 | obj[key] = arr[key];
|
|---|
| 2479 | }
|
|---|
| 2480 | return obj;
|
|---|
| 2481 | }
|
|---|
| 2482 |
|
|---|
| 2483 | /**
|
|---|
| 2484 | * It takes a FormData object and returns a JavaScript object
|
|---|
| 2485 | *
|
|---|
| 2486 | * @param {string} formData The FormData object to convert to JSON.
|
|---|
| 2487 | *
|
|---|
| 2488 | * @returns {Object<string, any> | null} The converted object.
|
|---|
| 2489 | */
|
|---|
| 2490 | function formDataToJSON(formData) {
|
|---|
| 2491 | function buildPath(path, value, target, index) {
|
|---|
| 2492 | var name = path[index++];
|
|---|
| 2493 | if (name === '__proto__') return true;
|
|---|
| 2494 | var isNumericKey = Number.isFinite(+name);
|
|---|
| 2495 | var isLast = index >= path.length;
|
|---|
| 2496 | name = !name && utils$1.isArray(target) ? target.length : name;
|
|---|
| 2497 | if (isLast) {
|
|---|
| 2498 | if (utils$1.hasOwnProp(target, name)) {
|
|---|
| 2499 | target[name] = utils$1.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
|
|---|
| 2500 | } else {
|
|---|
| 2501 | target[name] = value;
|
|---|
| 2502 | }
|
|---|
| 2503 | return !isNumericKey;
|
|---|
| 2504 | }
|
|---|
| 2505 | if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|---|
| 2506 | target[name] = [];
|
|---|
| 2507 | }
|
|---|
| 2508 | var result = buildPath(path, value, target[name], index);
|
|---|
| 2509 | if (result && utils$1.isArray(target[name])) {
|
|---|
| 2510 | target[name] = arrayToObject(target[name]);
|
|---|
| 2511 | }
|
|---|
| 2512 | return !isNumericKey;
|
|---|
| 2513 | }
|
|---|
| 2514 | if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|---|
| 2515 | var obj = {};
|
|---|
| 2516 | utils$1.forEachEntry(formData, function (name, value) {
|
|---|
| 2517 | buildPath(parsePropPath(name), value, obj, 0);
|
|---|
| 2518 | });
|
|---|
| 2519 | return obj;
|
|---|
| 2520 | }
|
|---|
| 2521 | return null;
|
|---|
| 2522 | }
|
|---|
| 2523 |
|
|---|
| 2524 | var own = function own(obj, key) {
|
|---|
| 2525 | return obj != null && utils$1.hasOwnProp(obj, key) ? obj[key] : undefined;
|
|---|
| 2526 | };
|
|---|
| 2527 |
|
|---|
| 2528 | /**
|
|---|
| 2529 | * It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|---|
| 2530 | * of the input
|
|---|
| 2531 | *
|
|---|
| 2532 | * @param {any} rawValue - The value to be stringified.
|
|---|
| 2533 | * @param {Function} parser - A function that parses a string into a JavaScript object.
|
|---|
| 2534 | * @param {Function} encoder - A function that takes a value and returns a string.
|
|---|
| 2535 | *
|
|---|
| 2536 | * @returns {string} A stringified version of the rawValue.
|
|---|
| 2537 | */
|
|---|
| 2538 | function stringifySafely(rawValue, parser, encoder) {
|
|---|
| 2539 | if (utils$1.isString(rawValue)) {
|
|---|
| 2540 | try {
|
|---|
| 2541 | (parser || JSON.parse)(rawValue);
|
|---|
| 2542 | return utils$1.trim(rawValue);
|
|---|
| 2543 | } catch (e) {
|
|---|
| 2544 | if (e.name !== 'SyntaxError') {
|
|---|
| 2545 | throw e;
|
|---|
| 2546 | }
|
|---|
| 2547 | }
|
|---|
| 2548 | }
|
|---|
| 2549 | return (encoder || JSON.stringify)(rawValue);
|
|---|
| 2550 | }
|
|---|
| 2551 | var defaults = {
|
|---|
| 2552 | transitional: transitionalDefaults,
|
|---|
| 2553 | adapter: ['xhr', 'http', 'fetch'],
|
|---|
| 2554 | transformRequest: [function transformRequest(data, headers) {
|
|---|
| 2555 | var contentType = headers.getContentType() || '';
|
|---|
| 2556 | var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|---|
| 2557 | var isObjectPayload = utils$1.isObject(data);
|
|---|
| 2558 | if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|---|
| 2559 | data = new FormData(data);
|
|---|
| 2560 | }
|
|---|
| 2561 | var isFormData = utils$1.isFormData(data);
|
|---|
| 2562 | if (isFormData) {
|
|---|
| 2563 | return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|---|
| 2564 | }
|
|---|
| 2565 | if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
|
|---|
| 2566 | return data;
|
|---|
| 2567 | }
|
|---|
| 2568 | if (utils$1.isArrayBufferView(data)) {
|
|---|
| 2569 | return data.buffer;
|
|---|
| 2570 | }
|
|---|
| 2571 | if (utils$1.isURLSearchParams(data)) {
|
|---|
| 2572 | headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|---|
| 2573 | return data.toString();
|
|---|
| 2574 | }
|
|---|
| 2575 | var isFileList;
|
|---|
| 2576 | if (isObjectPayload) {
|
|---|
| 2577 | var formSerializer = own(this, 'formSerializer');
|
|---|
| 2578 | if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|---|
| 2579 | return toURLEncodedForm(data, formSerializer).toString();
|
|---|
| 2580 | }
|
|---|
| 2581 | if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|---|
| 2582 | var env = own(this, 'env');
|
|---|
| 2583 | var _FormData = env && env.FormData;
|
|---|
| 2584 | return toFormData(isFileList ? {
|
|---|
| 2585 | 'files[]': data
|
|---|
| 2586 | } : data, _FormData && new _FormData(), formSerializer);
|
|---|
| 2587 | }
|
|---|
| 2588 | }
|
|---|
| 2589 | if (isObjectPayload || hasJSONContentType) {
|
|---|
| 2590 | headers.setContentType('application/json', false);
|
|---|
| 2591 | return stringifySafely(data);
|
|---|
| 2592 | }
|
|---|
| 2593 | return data;
|
|---|
| 2594 | }],
|
|---|
| 2595 | transformResponse: [function transformResponse(data) {
|
|---|
| 2596 | var transitional = own(this, 'transitional') || defaults.transitional;
|
|---|
| 2597 | var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|---|
| 2598 | var responseType = own(this, 'responseType');
|
|---|
| 2599 | var JSONRequested = responseType === 'json';
|
|---|
| 2600 | if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|---|
| 2601 | return data;
|
|---|
| 2602 | }
|
|---|
| 2603 | if (data && utils$1.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
|
|---|
| 2604 | var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|---|
| 2605 | var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|---|
| 2606 | try {
|
|---|
| 2607 | return JSON.parse(data, own(this, 'parseReviver'));
|
|---|
| 2608 | } catch (e) {
|
|---|
| 2609 | if (strictJSONParsing) {
|
|---|
| 2610 | if (e.name === 'SyntaxError') {
|
|---|
| 2611 | throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, own(this, 'response'));
|
|---|
| 2612 | }
|
|---|
| 2613 | throw e;
|
|---|
| 2614 | }
|
|---|
| 2615 | }
|
|---|
| 2616 | }
|
|---|
| 2617 | return data;
|
|---|
| 2618 | }],
|
|---|
| 2619 | /**
|
|---|
| 2620 | * A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|---|
| 2621 | * timeout is not created.
|
|---|
| 2622 | */
|
|---|
| 2623 | timeout: 0,
|
|---|
| 2624 | xsrfCookieName: 'XSRF-TOKEN',
|
|---|
| 2625 | xsrfHeaderName: 'X-XSRF-TOKEN',
|
|---|
| 2626 | maxContentLength: -1,
|
|---|
| 2627 | maxBodyLength: -1,
|
|---|
| 2628 | env: {
|
|---|
| 2629 | FormData: platform.classes.FormData,
|
|---|
| 2630 | Blob: platform.classes.Blob
|
|---|
| 2631 | },
|
|---|
| 2632 | validateStatus: function validateStatus(status) {
|
|---|
| 2633 | return status >= 200 && status < 300;
|
|---|
| 2634 | },
|
|---|
| 2635 | headers: {
|
|---|
| 2636 | common: {
|
|---|
| 2637 | Accept: 'application/json, text/plain, */*',
|
|---|
| 2638 | 'Content-Type': undefined
|
|---|
| 2639 | }
|
|---|
| 2640 | }
|
|---|
| 2641 | };
|
|---|
| 2642 | utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query'], function (method) {
|
|---|
| 2643 | defaults.headers[method] = {};
|
|---|
| 2644 | });
|
|---|
| 2645 |
|
|---|
| 2646 | /**
|
|---|
| 2647 | * Transform the data for a request or a response
|
|---|
| 2648 | *
|
|---|
| 2649 | * @param {Array|Function} fns A single function or Array of functions
|
|---|
| 2650 | * @param {?Object} response The response object
|
|---|
| 2651 | *
|
|---|
| 2652 | * @returns {*} The resulting transformed data
|
|---|
| 2653 | */
|
|---|
| 2654 | function transformData(fns, response) {
|
|---|
| 2655 | var config = this || defaults;
|
|---|
| 2656 | var context = response || config;
|
|---|
| 2657 | var headers = AxiosHeaders.from(context.headers);
|
|---|
| 2658 | var data = context.data;
|
|---|
| 2659 | utils$1.forEach(fns, function transform(fn) {
|
|---|
| 2660 | data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|---|
| 2661 | });
|
|---|
| 2662 | headers.normalize();
|
|---|
| 2663 | return data;
|
|---|
| 2664 | }
|
|---|
| 2665 |
|
|---|
| 2666 | function isCancel(value) {
|
|---|
| 2667 | return !!(value && value.__CANCEL__);
|
|---|
| 2668 | }
|
|---|
| 2669 |
|
|---|
| 2670 | var CanceledError = /*#__PURE__*/function (_AxiosError) {
|
|---|
| 2671 | /**
|
|---|
| 2672 | * A `CanceledError` is an object that is thrown when an operation is canceled.
|
|---|
| 2673 | *
|
|---|
| 2674 | * @param {string=} message The message.
|
|---|
| 2675 | * @param {Object=} config The config.
|
|---|
| 2676 | * @param {Object=} request The request.
|
|---|
| 2677 | *
|
|---|
| 2678 | * @returns {CanceledError} The created error.
|
|---|
| 2679 | */
|
|---|
| 2680 | function CanceledError(message, config, request) {
|
|---|
| 2681 | var _this;
|
|---|
| 2682 | _classCallCheck(this, CanceledError);
|
|---|
| 2683 | _this = _callSuper(this, CanceledError, [message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request]);
|
|---|
| 2684 | _this.name = 'CanceledError';
|
|---|
| 2685 | _this.__CANCEL__ = true;
|
|---|
| 2686 | return _this;
|
|---|
| 2687 | }
|
|---|
| 2688 | _inherits(CanceledError, _AxiosError);
|
|---|
| 2689 | return _createClass(CanceledError);
|
|---|
| 2690 | }(AxiosError);
|
|---|
| 2691 |
|
|---|
| 2692 | /**
|
|---|
| 2693 | * Resolve or reject a Promise based on response status.
|
|---|
| 2694 | *
|
|---|
| 2695 | * @param {Function} resolve A function that resolves the promise.
|
|---|
| 2696 | * @param {Function} reject A function that rejects the promise.
|
|---|
| 2697 | * @param {object} response The response.
|
|---|
| 2698 | *
|
|---|
| 2699 | * @returns {object} The response.
|
|---|
| 2700 | */
|
|---|
| 2701 | function settle(resolve, reject, response) {
|
|---|
| 2702 | var validateStatus = response.config.validateStatus;
|
|---|
| 2703 | if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|---|
| 2704 | resolve(response);
|
|---|
| 2705 | } else {
|
|---|
| 2706 | reject(new AxiosError('Request failed with status code ' + response.status, response.status >= 400 && response.status < 500 ? AxiosError.ERR_BAD_REQUEST : AxiosError.ERR_BAD_RESPONSE, response.config, response.request, response));
|
|---|
| 2707 | }
|
|---|
| 2708 | }
|
|---|
| 2709 |
|
|---|
| 2710 | function parseProtocol(url) {
|
|---|
| 2711 | var match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
|
|---|
| 2712 | return match && match[1] || '';
|
|---|
| 2713 | }
|
|---|
| 2714 |
|
|---|
| 2715 | /**
|
|---|
| 2716 | * Calculate data maxRate
|
|---|
| 2717 | * @param {Number} [samplesCount= 10]
|
|---|
| 2718 | * @param {Number} [min= 1000]
|
|---|
| 2719 | * @returns {Function}
|
|---|
| 2720 | */
|
|---|
| 2721 | function speedometer(samplesCount, min) {
|
|---|
| 2722 | samplesCount = samplesCount || 10;
|
|---|
| 2723 | var bytes = new Array(samplesCount);
|
|---|
| 2724 | var timestamps = new Array(samplesCount);
|
|---|
| 2725 | var head = 0;
|
|---|
| 2726 | var tail = 0;
|
|---|
| 2727 | var firstSampleTS;
|
|---|
| 2728 | min = min !== undefined ? min : 1000;
|
|---|
| 2729 | return function push(chunkLength) {
|
|---|
| 2730 | var now = Date.now();
|
|---|
| 2731 | var startedAt = timestamps[tail];
|
|---|
| 2732 | if (!firstSampleTS) {
|
|---|
| 2733 | firstSampleTS = now;
|
|---|
| 2734 | }
|
|---|
| 2735 | bytes[head] = chunkLength;
|
|---|
| 2736 | timestamps[head] = now;
|
|---|
| 2737 | var i = tail;
|
|---|
| 2738 | var bytesCount = 0;
|
|---|
| 2739 | while (i !== head) {
|
|---|
| 2740 | bytesCount += bytes[i++];
|
|---|
| 2741 | i = i % samplesCount;
|
|---|
| 2742 | }
|
|---|
| 2743 | head = (head + 1) % samplesCount;
|
|---|
| 2744 | if (head === tail) {
|
|---|
| 2745 | tail = (tail + 1) % samplesCount;
|
|---|
| 2746 | }
|
|---|
| 2747 | if (now - firstSampleTS < min) {
|
|---|
| 2748 | return;
|
|---|
| 2749 | }
|
|---|
| 2750 | var passed = startedAt && now - startedAt;
|
|---|
| 2751 | return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
|---|
| 2752 | };
|
|---|
| 2753 | }
|
|---|
| 2754 |
|
|---|
| 2755 | /**
|
|---|
| 2756 | * Throttle decorator
|
|---|
| 2757 | * @param {Function} fn
|
|---|
| 2758 | * @param {Number} freq
|
|---|
| 2759 | * @return {Function}
|
|---|
| 2760 | */
|
|---|
| 2761 | function throttle(fn, freq) {
|
|---|
| 2762 | var timestamp = 0;
|
|---|
| 2763 | var threshold = 1000 / freq;
|
|---|
| 2764 | var lastArgs;
|
|---|
| 2765 | var timer;
|
|---|
| 2766 | var invoke = function invoke(args) {
|
|---|
| 2767 | var now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|---|
| 2768 | timestamp = now;
|
|---|
| 2769 | lastArgs = null;
|
|---|
| 2770 | if (timer) {
|
|---|
| 2771 | clearTimeout(timer);
|
|---|
| 2772 | timer = null;
|
|---|
| 2773 | }
|
|---|
| 2774 | fn.apply(void 0, _toConsumableArray(args));
|
|---|
| 2775 | };
|
|---|
| 2776 | var throttled = function throttled() {
|
|---|
| 2777 | var now = Date.now();
|
|---|
| 2778 | var passed = now - timestamp;
|
|---|
| 2779 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|---|
| 2780 | args[_key] = arguments[_key];
|
|---|
| 2781 | }
|
|---|
| 2782 | if (passed >= threshold) {
|
|---|
| 2783 | invoke(args, now);
|
|---|
| 2784 | } else {
|
|---|
| 2785 | lastArgs = args;
|
|---|
| 2786 | if (!timer) {
|
|---|
| 2787 | timer = setTimeout(function () {
|
|---|
| 2788 | timer = null;
|
|---|
| 2789 | invoke(lastArgs);
|
|---|
| 2790 | }, threshold - passed);
|
|---|
| 2791 | }
|
|---|
| 2792 | }
|
|---|
| 2793 | };
|
|---|
| 2794 | var flush = function flush() {
|
|---|
| 2795 | return lastArgs && invoke(lastArgs);
|
|---|
| 2796 | };
|
|---|
| 2797 | return [throttled, flush];
|
|---|
| 2798 | }
|
|---|
| 2799 |
|
|---|
| 2800 | var progressEventReducer = function progressEventReducer(listener, isDownloadStream) {
|
|---|
| 2801 | var freq = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 3;
|
|---|
| 2802 | var bytesNotified = 0;
|
|---|
| 2803 | var _speedometer = speedometer(50, 250);
|
|---|
| 2804 | return throttle(function (e) {
|
|---|
| 2805 | if (!e || typeof e.loaded !== 'number') {
|
|---|
| 2806 | return;
|
|---|
| 2807 | }
|
|---|
| 2808 | var rawLoaded = e.loaded;
|
|---|
| 2809 | var total = e.lengthComputable ? e.total : undefined;
|
|---|
| 2810 | var loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|---|
| 2811 | var progressBytes = Math.max(0, loaded - bytesNotified);
|
|---|
| 2812 | var rate = _speedometer(progressBytes);
|
|---|
| 2813 | bytesNotified = Math.max(bytesNotified, loaded);
|
|---|
| 2814 | var data = _defineProperty({
|
|---|
| 2815 | loaded: loaded,
|
|---|
| 2816 | total: total,
|
|---|
| 2817 | progress: total ? loaded / total : undefined,
|
|---|
| 2818 | bytes: progressBytes,
|
|---|
| 2819 | rate: rate ? rate : undefined,
|
|---|
| 2820 | estimated: rate && total ? (total - loaded) / rate : undefined,
|
|---|
| 2821 | event: e,
|
|---|
| 2822 | lengthComputable: total != null
|
|---|
| 2823 | }, isDownloadStream ? 'download' : 'upload', true);
|
|---|
| 2824 | listener(data);
|
|---|
| 2825 | }, freq);
|
|---|
| 2826 | };
|
|---|
| 2827 | var progressEventDecorator = function progressEventDecorator(total, throttled) {
|
|---|
| 2828 | var lengthComputable = total != null;
|
|---|
| 2829 | return [function (loaded) {
|
|---|
| 2830 | return throttled[0]({
|
|---|
| 2831 | lengthComputable: lengthComputable,
|
|---|
| 2832 | total: total,
|
|---|
| 2833 | loaded: loaded
|
|---|
| 2834 | });
|
|---|
| 2835 | }, throttled[1]];
|
|---|
| 2836 | };
|
|---|
| 2837 | var asyncDecorator = function asyncDecorator(fn) {
|
|---|
| 2838 | return function () {
|
|---|
| 2839 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|---|
| 2840 | args[_key] = arguments[_key];
|
|---|
| 2841 | }
|
|---|
| 2842 | return utils$1.asap(function () {
|
|---|
| 2843 | return fn.apply(void 0, args);
|
|---|
| 2844 | });
|
|---|
| 2845 | };
|
|---|
| 2846 | };
|
|---|
| 2847 |
|
|---|
| 2848 | var isURLSameOrigin = platform.hasStandardBrowserEnv ? function (origin, isMSIE) {
|
|---|
| 2849 | return function (url) {
|
|---|
| 2850 | url = new URL(url, platform.origin);
|
|---|
| 2851 | return origin.protocol === url.protocol && origin.host === url.host && (isMSIE || origin.port === url.port);
|
|---|
| 2852 | };
|
|---|
| 2853 | }(new URL(platform.origin), platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)) : function () {
|
|---|
| 2854 | return true;
|
|---|
| 2855 | };
|
|---|
| 2856 |
|
|---|
| 2857 | var cookies = platform.hasStandardBrowserEnv ?
|
|---|
| 2858 | // Standard browser envs support document.cookie
|
|---|
| 2859 | {
|
|---|
| 2860 | write: function write(name, value, expires, path, domain, secure, sameSite) {
|
|---|
| 2861 | if (typeof document === 'undefined') return;
|
|---|
| 2862 | var cookie = ["".concat(name, "=").concat(encodeURIComponent(value))];
|
|---|
| 2863 | if (utils$1.isNumber(expires)) {
|
|---|
| 2864 | cookie.push("expires=".concat(new Date(expires).toUTCString()));
|
|---|
| 2865 | }
|
|---|
| 2866 | if (utils$1.isString(path)) {
|
|---|
| 2867 | cookie.push("path=".concat(path));
|
|---|
| 2868 | }
|
|---|
| 2869 | if (utils$1.isString(domain)) {
|
|---|
| 2870 | cookie.push("domain=".concat(domain));
|
|---|
| 2871 | }
|
|---|
| 2872 | if (secure === true) {
|
|---|
| 2873 | cookie.push('secure');
|
|---|
| 2874 | }
|
|---|
| 2875 | if (utils$1.isString(sameSite)) {
|
|---|
| 2876 | cookie.push("SameSite=".concat(sameSite));
|
|---|
| 2877 | }
|
|---|
| 2878 | document.cookie = cookie.join('; ');
|
|---|
| 2879 | },
|
|---|
| 2880 | read: function read(name) {
|
|---|
| 2881 | if (typeof document === 'undefined') return null;
|
|---|
| 2882 | // Match name=value by splitting on the semicolon separator instead of building a
|
|---|
| 2883 | // RegExp from `name` — interpolating an unescaped string into a RegExp would let
|
|---|
| 2884 | // metacharacters (e.g. `.+?` in an attacker-influenced cookie name) cause ReDoS or
|
|---|
| 2885 | // match the wrong cookie. Browsers may serialize cookie pairs as either ";" or
|
|---|
| 2886 | // "; ", so ignore optional whitespace before each cookie name.
|
|---|
| 2887 | var cookies = document.cookie.split(';');
|
|---|
| 2888 | for (var i = 0; i < cookies.length; i++) {
|
|---|
| 2889 | var cookie = cookies[i].replace(/^\s+/, '');
|
|---|
| 2890 | var eq = cookie.indexOf('=');
|
|---|
| 2891 | if (eq !== -1 && cookie.slice(0, eq) === name) {
|
|---|
| 2892 | return decodeURIComponent(cookie.slice(eq + 1));
|
|---|
| 2893 | }
|
|---|
| 2894 | }
|
|---|
| 2895 | return null;
|
|---|
| 2896 | },
|
|---|
| 2897 | remove: function remove(name) {
|
|---|
| 2898 | this.write(name, '', Date.now() - 86400000, '/');
|
|---|
| 2899 | }
|
|---|
| 2900 | } :
|
|---|
| 2901 | // Non-standard browser env (web workers, react-native) lack needed support.
|
|---|
| 2902 | {
|
|---|
| 2903 | write: function write() {},
|
|---|
| 2904 | read: function read() {
|
|---|
| 2905 | return null;
|
|---|
| 2906 | },
|
|---|
| 2907 | remove: function remove() {}
|
|---|
| 2908 | };
|
|---|
| 2909 |
|
|---|
| 2910 | /**
|
|---|
| 2911 | * Determines whether the specified URL is absolute
|
|---|
| 2912 | *
|
|---|
| 2913 | * @param {string} url The URL to test
|
|---|
| 2914 | *
|
|---|
| 2915 | * @returns {boolean} True if the specified URL is absolute, otherwise false
|
|---|
| 2916 | */
|
|---|
| 2917 | function isAbsoluteURL(url) {
|
|---|
| 2918 | // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|---|
| 2919 | // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|---|
| 2920 | // by any combination of letters, digits, plus, period, or hyphen.
|
|---|
| 2921 | if (typeof url !== 'string') {
|
|---|
| 2922 | return false;
|
|---|
| 2923 | }
|
|---|
| 2924 | return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|---|
| 2925 | }
|
|---|
| 2926 |
|
|---|
| 2927 | /**
|
|---|
| 2928 | * Creates a new URL by combining the specified URLs
|
|---|
| 2929 | *
|
|---|
| 2930 | * @param {string} baseURL The base URL
|
|---|
| 2931 | * @param {string} relativeURL The relative URL
|
|---|
| 2932 | *
|
|---|
| 2933 | * @returns {string} The combined URL
|
|---|
| 2934 | */
|
|---|
| 2935 | function combineURLs(baseURL, relativeURL) {
|
|---|
| 2936 | return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
|---|
| 2937 | }
|
|---|
| 2938 |
|
|---|
| 2939 | /**
|
|---|
| 2940 | * Creates a new URL by combining the baseURL with the requestedURL,
|
|---|
| 2941 | * only when the requestedURL is not already an absolute URL.
|
|---|
| 2942 | * If the requestURL is absolute, this function returns the requestedURL untouched.
|
|---|
| 2943 | *
|
|---|
| 2944 | * @param {string} baseURL The base URL
|
|---|
| 2945 | * @param {string} requestedURL Absolute or relative URL to combine
|
|---|
| 2946 | *
|
|---|
| 2947 | * @returns {string} The combined full path
|
|---|
| 2948 | */
|
|---|
| 2949 | function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|---|
| 2950 | var isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|---|
| 2951 | if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
|
|---|
| 2952 | return combineURLs(baseURL, requestedURL);
|
|---|
| 2953 | }
|
|---|
| 2954 | return requestedURL;
|
|---|
| 2955 | }
|
|---|
| 2956 |
|
|---|
| 2957 | var headersToObject = function headersToObject(thing) {
|
|---|
| 2958 | return thing instanceof AxiosHeaders ? _objectSpread2({}, thing) : thing;
|
|---|
| 2959 | };
|
|---|
| 2960 |
|
|---|
| 2961 | /**
|
|---|
| 2962 | * Config-specific merge-function which creates a new config-object
|
|---|
| 2963 | * by merging two configuration objects together.
|
|---|
| 2964 | *
|
|---|
| 2965 | * @param {Object} config1
|
|---|
| 2966 | * @param {Object} config2
|
|---|
| 2967 | *
|
|---|
| 2968 | * @returns {Object} New object resulting from merging config2 to config1
|
|---|
| 2969 | */
|
|---|
| 2970 | function mergeConfig(config1, config2) {
|
|---|
| 2971 | // eslint-disable-next-line no-param-reassign
|
|---|
| 2972 | config2 = config2 || {};
|
|---|
| 2973 |
|
|---|
| 2974 | // Use a null-prototype object so that downstream reads such as `config.auth`
|
|---|
| 2975 | // or `config.baseURL` cannot inherit polluted values from Object.prototype.
|
|---|
| 2976 | // `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|---|
| 2977 | // ergonomics for user code that relies on it.
|
|---|
| 2978 | var config = Object.create(null);
|
|---|
| 2979 | Object.defineProperty(config, 'hasOwnProperty', {
|
|---|
| 2980 | // Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|---|
| 2981 | // this data descriptor into an accessor descriptor on the way in.
|
|---|
| 2982 | __proto__: null,
|
|---|
| 2983 | value: Object.prototype.hasOwnProperty,
|
|---|
| 2984 | enumerable: false,
|
|---|
| 2985 | writable: true,
|
|---|
| 2986 | configurable: true
|
|---|
| 2987 | });
|
|---|
| 2988 | function getMergedValue(target, source, prop, caseless) {
|
|---|
| 2989 | if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|---|
| 2990 | return utils$1.merge.call({
|
|---|
| 2991 | caseless: caseless
|
|---|
| 2992 | }, target, source);
|
|---|
| 2993 | } else if (utils$1.isPlainObject(source)) {
|
|---|
| 2994 | return utils$1.merge({}, source);
|
|---|
| 2995 | } else if (utils$1.isArray(source)) {
|
|---|
| 2996 | return source.slice();
|
|---|
| 2997 | }
|
|---|
| 2998 | return source;
|
|---|
| 2999 | }
|
|---|
| 3000 | function mergeDeepProperties(a, b, prop, caseless) {
|
|---|
| 3001 | if (!utils$1.isUndefined(b)) {
|
|---|
| 3002 | return getMergedValue(a, b, prop, caseless);
|
|---|
| 3003 | } else if (!utils$1.isUndefined(a)) {
|
|---|
| 3004 | return getMergedValue(undefined, a, prop, caseless);
|
|---|
| 3005 | }
|
|---|
| 3006 | }
|
|---|
| 3007 |
|
|---|
| 3008 | // eslint-disable-next-line consistent-return
|
|---|
| 3009 | function valueFromConfig2(a, b) {
|
|---|
| 3010 | if (!utils$1.isUndefined(b)) {
|
|---|
| 3011 | return getMergedValue(undefined, b);
|
|---|
| 3012 | }
|
|---|
| 3013 | }
|
|---|
| 3014 |
|
|---|
| 3015 | // eslint-disable-next-line consistent-return
|
|---|
| 3016 | function defaultToConfig2(a, b) {
|
|---|
| 3017 | if (!utils$1.isUndefined(b)) {
|
|---|
| 3018 | return getMergedValue(undefined, b);
|
|---|
| 3019 | } else if (!utils$1.isUndefined(a)) {
|
|---|
| 3020 | return getMergedValue(undefined, a);
|
|---|
| 3021 | }
|
|---|
| 3022 | }
|
|---|
| 3023 |
|
|---|
| 3024 | // eslint-disable-next-line consistent-return
|
|---|
| 3025 | function mergeDirectKeys(a, b, prop) {
|
|---|
| 3026 | if (utils$1.hasOwnProp(config2, prop)) {
|
|---|
| 3027 | return getMergedValue(a, b);
|
|---|
| 3028 | } else if (utils$1.hasOwnProp(config1, prop)) {
|
|---|
| 3029 | return getMergedValue(undefined, a);
|
|---|
| 3030 | }
|
|---|
| 3031 | }
|
|---|
| 3032 | var mergeMap = {
|
|---|
| 3033 | url: valueFromConfig2,
|
|---|
| 3034 | method: valueFromConfig2,
|
|---|
| 3035 | data: valueFromConfig2,
|
|---|
| 3036 | baseURL: defaultToConfig2,
|
|---|
| 3037 | transformRequest: defaultToConfig2,
|
|---|
| 3038 | transformResponse: defaultToConfig2,
|
|---|
| 3039 | paramsSerializer: defaultToConfig2,
|
|---|
| 3040 | timeout: defaultToConfig2,
|
|---|
| 3041 | timeoutMessage: defaultToConfig2,
|
|---|
| 3042 | withCredentials: defaultToConfig2,
|
|---|
| 3043 | withXSRFToken: defaultToConfig2,
|
|---|
| 3044 | adapter: defaultToConfig2,
|
|---|
| 3045 | responseType: defaultToConfig2,
|
|---|
| 3046 | xsrfCookieName: defaultToConfig2,
|
|---|
| 3047 | xsrfHeaderName: defaultToConfig2,
|
|---|
| 3048 | onUploadProgress: defaultToConfig2,
|
|---|
| 3049 | onDownloadProgress: defaultToConfig2,
|
|---|
| 3050 | decompress: defaultToConfig2,
|
|---|
| 3051 | maxContentLength: defaultToConfig2,
|
|---|
| 3052 | maxBodyLength: defaultToConfig2,
|
|---|
| 3053 | beforeRedirect: defaultToConfig2,
|
|---|
| 3054 | transport: defaultToConfig2,
|
|---|
| 3055 | httpAgent: defaultToConfig2,
|
|---|
| 3056 | httpsAgent: defaultToConfig2,
|
|---|
| 3057 | cancelToken: defaultToConfig2,
|
|---|
| 3058 | socketPath: defaultToConfig2,
|
|---|
| 3059 | allowedSocketPaths: defaultToConfig2,
|
|---|
| 3060 | responseEncoding: defaultToConfig2,
|
|---|
| 3061 | validateStatus: mergeDirectKeys,
|
|---|
| 3062 | headers: function headers(a, b, prop) {
|
|---|
| 3063 | return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
|
|---|
| 3064 | }
|
|---|
| 3065 | };
|
|---|
| 3066 | utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
|
|---|
| 3067 | if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|---|
| 3068 | var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|---|
| 3069 | var a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|---|
| 3070 | var b = utils$1.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|---|
| 3071 | var configValue = merge(a, b, prop);
|
|---|
| 3072 | utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
|
|---|
| 3073 | });
|
|---|
| 3074 | return config;
|
|---|
| 3075 | }
|
|---|
| 3076 |
|
|---|
| 3077 | var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|---|
| 3078 | function setFormDataHeaders(headers, formHeaders, policy) {
|
|---|
| 3079 | if (policy !== 'content-only') {
|
|---|
| 3080 | headers.set(formHeaders);
|
|---|
| 3081 | return;
|
|---|
| 3082 | }
|
|---|
| 3083 | Object.entries(formHeaders).forEach(function (_ref) {
|
|---|
| 3084 | var _ref2 = _slicedToArray(_ref, 2),
|
|---|
| 3085 | key = _ref2[0],
|
|---|
| 3086 | val = _ref2[1];
|
|---|
| 3087 | if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|---|
| 3088 | headers.set(key, val);
|
|---|
| 3089 | }
|
|---|
| 3090 | });
|
|---|
| 3091 | }
|
|---|
| 3092 |
|
|---|
| 3093 | /**
|
|---|
| 3094 | * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|---|
| 3095 | * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|---|
| 3096 | *
|
|---|
| 3097 | * @param {string} str The string to encode
|
|---|
| 3098 | *
|
|---|
| 3099 | * @returns {string} UTF-8 bytes as a Latin-1 string
|
|---|
| 3100 | */
|
|---|
| 3101 | var encodeUTF8 = function encodeUTF8(str) {
|
|---|
| 3102 | return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
|
|---|
| 3103 | return String.fromCharCode(parseInt(hex, 16));
|
|---|
| 3104 | });
|
|---|
| 3105 | };
|
|---|
| 3106 | var resolveConfig = (function (config) {
|
|---|
| 3107 | var newConfig = mergeConfig({}, config);
|
|---|
| 3108 |
|
|---|
| 3109 | // Read only own properties to prevent prototype pollution gadgets
|
|---|
| 3110 | // (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|---|
| 3111 | var own = function own(key) {
|
|---|
| 3112 | return utils$1.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
|
|---|
| 3113 | };
|
|---|
| 3114 | var data = own('data');
|
|---|
| 3115 | var withXSRFToken = own('withXSRFToken');
|
|---|
| 3116 | var xsrfHeaderName = own('xsrfHeaderName');
|
|---|
| 3117 | var xsrfCookieName = own('xsrfCookieName');
|
|---|
| 3118 | var headers = own('headers');
|
|---|
| 3119 | var auth = own('auth');
|
|---|
| 3120 | var baseURL = own('baseURL');
|
|---|
| 3121 | var allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|---|
| 3122 | var url = own('url');
|
|---|
| 3123 | newConfig.headers = headers = AxiosHeaders.from(headers);
|
|---|
| 3124 | newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|---|
| 3125 |
|
|---|
| 3126 | // HTTP basic authentication
|
|---|
| 3127 | if (auth) {
|
|---|
| 3128 | headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
|
|---|
| 3129 | }
|
|---|
| 3130 | if (utils$1.isFormData(data)) {
|
|---|
| 3131 | if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|---|
| 3132 | headers.setContentType(undefined); // browser handles it
|
|---|
| 3133 | } else if (utils$1.isFunction(data.getHeaders)) {
|
|---|
| 3134 | // Node.js FormData (like form-data package)
|
|---|
| 3135 | setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|---|
| 3136 | }
|
|---|
| 3137 | }
|
|---|
| 3138 |
|
|---|
| 3139 | // Add xsrf header
|
|---|
| 3140 | // This is only done if running in a standard browser environment.
|
|---|
| 3141 | // Specifically not if we're in a web worker, or react-native.
|
|---|
| 3142 |
|
|---|
| 3143 | if (platform.hasStandardBrowserEnv) {
|
|---|
| 3144 | if (utils$1.isFunction(withXSRFToken)) {
|
|---|
| 3145 | withXSRFToken = withXSRFToken(newConfig);
|
|---|
| 3146 | }
|
|---|
| 3147 |
|
|---|
| 3148 | // Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|---|
| 3149 | // and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|---|
| 3150 | // the XSRF token cross-origin.
|
|---|
| 3151 | var shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin(newConfig.url);
|
|---|
| 3152 | if (shouldSendXSRF) {
|
|---|
| 3153 | var xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|---|
| 3154 | if (xsrfValue) {
|
|---|
| 3155 | headers.set(xsrfHeaderName, xsrfValue);
|
|---|
| 3156 | }
|
|---|
| 3157 | }
|
|---|
| 3158 | }
|
|---|
| 3159 | return newConfig;
|
|---|
| 3160 | });
|
|---|
| 3161 |
|
|---|
| 3162 | var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
|---|
| 3163 | var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|---|
| 3164 | return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|---|
| 3165 | var _config = resolveConfig(config);
|
|---|
| 3166 | var requestData = _config.data;
|
|---|
| 3167 | var requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|---|
| 3168 | var responseType = _config.responseType,
|
|---|
| 3169 | onUploadProgress = _config.onUploadProgress,
|
|---|
| 3170 | onDownloadProgress = _config.onDownloadProgress;
|
|---|
| 3171 | var onCanceled;
|
|---|
| 3172 | var uploadThrottled, downloadThrottled;
|
|---|
| 3173 | var flushUpload, flushDownload;
|
|---|
| 3174 | function done() {
|
|---|
| 3175 | flushUpload && flushUpload(); // flush events
|
|---|
| 3176 | flushDownload && flushDownload(); // flush events
|
|---|
| 3177 |
|
|---|
| 3178 | _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|---|
| 3179 | _config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|---|
| 3180 | }
|
|---|
| 3181 | var request = new XMLHttpRequest();
|
|---|
| 3182 | request.open(_config.method.toUpperCase(), _config.url, true);
|
|---|
| 3183 |
|
|---|
| 3184 | // Set the request timeout in MS
|
|---|
| 3185 | request.timeout = _config.timeout;
|
|---|
| 3186 | function onloadend() {
|
|---|
| 3187 | if (!request) {
|
|---|
| 3188 | return;
|
|---|
| 3189 | }
|
|---|
| 3190 | // Prepare the response
|
|---|
| 3191 | var responseHeaders = AxiosHeaders.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
|
|---|
| 3192 | var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
|
|---|
| 3193 | var response = {
|
|---|
| 3194 | data: responseData,
|
|---|
| 3195 | status: request.status,
|
|---|
| 3196 | statusText: request.statusText,
|
|---|
| 3197 | headers: responseHeaders,
|
|---|
| 3198 | config: config,
|
|---|
| 3199 | request: request
|
|---|
| 3200 | };
|
|---|
| 3201 | settle(function _resolve(value) {
|
|---|
| 3202 | resolve(value);
|
|---|
| 3203 | done();
|
|---|
| 3204 | }, function _reject(err) {
|
|---|
| 3205 | reject(err);
|
|---|
| 3206 | done();
|
|---|
| 3207 | }, response);
|
|---|
| 3208 |
|
|---|
| 3209 | // Clean up request
|
|---|
| 3210 | request = null;
|
|---|
| 3211 | }
|
|---|
| 3212 | if ('onloadend' in request) {
|
|---|
| 3213 | // Use onloadend if available
|
|---|
| 3214 | request.onloadend = onloadend;
|
|---|
| 3215 | } else {
|
|---|
| 3216 | // Listen for ready state to emulate onloadend
|
|---|
| 3217 | request.onreadystatechange = function handleLoad() {
|
|---|
| 3218 | if (!request || request.readyState !== 4) {
|
|---|
| 3219 | return;
|
|---|
| 3220 | }
|
|---|
| 3221 |
|
|---|
| 3222 | // The request errored out and we didn't get a response, this will be
|
|---|
| 3223 | // handled by onerror instead
|
|---|
| 3224 | // With one exception: request that using file: protocol, most browsers
|
|---|
| 3225 | // will return status as 0 even though it's a successful request
|
|---|
| 3226 | if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith('file:'))) {
|
|---|
| 3227 | return;
|
|---|
| 3228 | }
|
|---|
| 3229 | // readystate handler is calling before onerror or ontimeout handlers,
|
|---|
| 3230 | // so we should call onloadend on the next 'tick'
|
|---|
| 3231 | setTimeout(onloadend);
|
|---|
| 3232 | };
|
|---|
| 3233 | }
|
|---|
| 3234 |
|
|---|
| 3235 | // Handle browser request cancellation (as opposed to a manual cancellation)
|
|---|
| 3236 | request.onabort = function handleAbort() {
|
|---|
| 3237 | if (!request) {
|
|---|
| 3238 | return;
|
|---|
| 3239 | }
|
|---|
| 3240 | reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|---|
| 3241 | done();
|
|---|
| 3242 |
|
|---|
| 3243 | // Clean up request
|
|---|
| 3244 | request = null;
|
|---|
| 3245 | };
|
|---|
| 3246 |
|
|---|
| 3247 | // Handle low level network errors
|
|---|
| 3248 | request.onerror = function handleError(event) {
|
|---|
| 3249 | // Browsers deliver a ProgressEvent in XHR onerror
|
|---|
| 3250 | // (message may be empty; when present, surface it)
|
|---|
| 3251 | // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
|
|---|
| 3252 | var msg = event && event.message ? event.message : 'Network Error';
|
|---|
| 3253 | var err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
|
|---|
| 3254 | // attach the underlying event for consumers who want details
|
|---|
| 3255 | err.event = event || null;
|
|---|
| 3256 | reject(err);
|
|---|
| 3257 | done();
|
|---|
| 3258 | request = null;
|
|---|
| 3259 | };
|
|---|
| 3260 |
|
|---|
| 3261 | // Handle timeout
|
|---|
| 3262 | request.ontimeout = function handleTimeout() {
|
|---|
| 3263 | var timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
|
|---|
| 3264 | var transitional = _config.transitional || transitionalDefaults;
|
|---|
| 3265 | if (_config.timeoutErrorMessage) {
|
|---|
| 3266 | timeoutErrorMessage = _config.timeoutErrorMessage;
|
|---|
| 3267 | }
|
|---|
| 3268 | reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
|
|---|
| 3269 | done();
|
|---|
| 3270 |
|
|---|
| 3271 | // Clean up request
|
|---|
| 3272 | request = null;
|
|---|
| 3273 | };
|
|---|
| 3274 |
|
|---|
| 3275 | // Remove Content-Type if data is undefined
|
|---|
| 3276 | requestData === undefined && requestHeaders.setContentType(null);
|
|---|
| 3277 |
|
|---|
| 3278 | // Add headers to the request
|
|---|
| 3279 | if ('setRequestHeader' in request) {
|
|---|
| 3280 | utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|---|
| 3281 | request.setRequestHeader(key, val);
|
|---|
| 3282 | });
|
|---|
| 3283 | }
|
|---|
| 3284 |
|
|---|
| 3285 | // Add withCredentials to request if needed
|
|---|
| 3286 | if (!utils$1.isUndefined(_config.withCredentials)) {
|
|---|
| 3287 | request.withCredentials = !!_config.withCredentials;
|
|---|
| 3288 | }
|
|---|
| 3289 |
|
|---|
| 3290 | // Add responseType to request if needed
|
|---|
| 3291 | if (responseType && responseType !== 'json') {
|
|---|
| 3292 | request.responseType = _config.responseType;
|
|---|
| 3293 | }
|
|---|
| 3294 |
|
|---|
| 3295 | // Handle progress if needed
|
|---|
| 3296 | if (onDownloadProgress) {
|
|---|
| 3297 | var _progressEventReducer = progressEventReducer(onDownloadProgress, true);
|
|---|
| 3298 | var _progressEventReducer2 = _slicedToArray(_progressEventReducer, 2);
|
|---|
| 3299 | downloadThrottled = _progressEventReducer2[0];
|
|---|
| 3300 | flushDownload = _progressEventReducer2[1];
|
|---|
| 3301 | request.addEventListener('progress', downloadThrottled);
|
|---|
| 3302 | }
|
|---|
| 3303 |
|
|---|
| 3304 | // Not all browsers support upload events
|
|---|
| 3305 | if (onUploadProgress && request.upload) {
|
|---|
| 3306 | var _progressEventReducer3 = progressEventReducer(onUploadProgress);
|
|---|
| 3307 | var _progressEventReducer4 = _slicedToArray(_progressEventReducer3, 2);
|
|---|
| 3308 | uploadThrottled = _progressEventReducer4[0];
|
|---|
| 3309 | flushUpload = _progressEventReducer4[1];
|
|---|
| 3310 | request.upload.addEventListener('progress', uploadThrottled);
|
|---|
| 3311 | request.upload.addEventListener('loadend', flushUpload);
|
|---|
| 3312 | }
|
|---|
| 3313 | if (_config.cancelToken || _config.signal) {
|
|---|
| 3314 | // Handle cancellation
|
|---|
| 3315 | // eslint-disable-next-line func-names
|
|---|
| 3316 | onCanceled = function onCanceled(cancel) {
|
|---|
| 3317 | if (!request) {
|
|---|
| 3318 | return;
|
|---|
| 3319 | }
|
|---|
| 3320 | reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
|---|
| 3321 | request.abort();
|
|---|
| 3322 | done();
|
|---|
| 3323 | request = null;
|
|---|
| 3324 | };
|
|---|
| 3325 | _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|---|
| 3326 | if (_config.signal) {
|
|---|
| 3327 | _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
|
|---|
| 3328 | }
|
|---|
| 3329 | }
|
|---|
| 3330 | var protocol = parseProtocol(_config.url);
|
|---|
| 3331 | if (protocol && !platform.protocols.includes(protocol)) {
|
|---|
| 3332 | reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|---|
| 3333 | return;
|
|---|
| 3334 | }
|
|---|
| 3335 |
|
|---|
| 3336 | // Send the request
|
|---|
| 3337 | request.send(requestData || null);
|
|---|
| 3338 | });
|
|---|
| 3339 | };
|
|---|
| 3340 |
|
|---|
| 3341 | var composeSignals = function composeSignals(signals, timeout) {
|
|---|
| 3342 | signals = signals ? signals.filter(Boolean) : [];
|
|---|
| 3343 | if (!timeout && !signals.length) {
|
|---|
| 3344 | return;
|
|---|
| 3345 | }
|
|---|
| 3346 | var controller = new AbortController();
|
|---|
| 3347 | var aborted = false;
|
|---|
| 3348 | var onabort = function onabort(reason) {
|
|---|
| 3349 | if (!aborted) {
|
|---|
| 3350 | aborted = true;
|
|---|
| 3351 | unsubscribe();
|
|---|
| 3352 | var err = reason instanceof Error ? reason : this.reason;
|
|---|
| 3353 | controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|---|
| 3354 | }
|
|---|
| 3355 | };
|
|---|
| 3356 | var timer = timeout && setTimeout(function () {
|
|---|
| 3357 | timer = null;
|
|---|
| 3358 | onabort(new AxiosError("timeout of ".concat(timeout, "ms exceeded"), AxiosError.ETIMEDOUT));
|
|---|
| 3359 | }, timeout);
|
|---|
| 3360 | var unsubscribe = function unsubscribe() {
|
|---|
| 3361 | if (!signals) {
|
|---|
| 3362 | return;
|
|---|
| 3363 | }
|
|---|
| 3364 | timer && clearTimeout(timer);
|
|---|
| 3365 | timer = null;
|
|---|
| 3366 | signals.forEach(function (signal) {
|
|---|
| 3367 | signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|---|
| 3368 | });
|
|---|
| 3369 | signals = null;
|
|---|
| 3370 | };
|
|---|
| 3371 | signals.forEach(function (signal) {
|
|---|
| 3372 | return signal.addEventListener('abort', onabort);
|
|---|
| 3373 | });
|
|---|
| 3374 | var signal = controller.signal;
|
|---|
| 3375 | signal.unsubscribe = function () {
|
|---|
| 3376 | return utils$1.asap(unsubscribe);
|
|---|
| 3377 | };
|
|---|
| 3378 | return signal;
|
|---|
| 3379 | };
|
|---|
| 3380 |
|
|---|
| 3381 | var streamChunk = /*#__PURE__*/_regenerator().m(function streamChunk(chunk, chunkSize) {
|
|---|
| 3382 | var len, pos, end;
|
|---|
| 3383 | return _regenerator().w(function (_context) {
|
|---|
| 3384 | while (1) switch (_context.n) {
|
|---|
| 3385 | case 0:
|
|---|
| 3386 | len = chunk.byteLength;
|
|---|
| 3387 | if (!(!chunkSize || len < chunkSize)) {
|
|---|
| 3388 | _context.n = 2;
|
|---|
| 3389 | break;
|
|---|
| 3390 | }
|
|---|
| 3391 | _context.n = 1;
|
|---|
| 3392 | return chunk;
|
|---|
| 3393 | case 1:
|
|---|
| 3394 | return _context.a(2);
|
|---|
| 3395 | case 2:
|
|---|
| 3396 | pos = 0;
|
|---|
| 3397 | case 3:
|
|---|
| 3398 | if (!(pos < len)) {
|
|---|
| 3399 | _context.n = 5;
|
|---|
| 3400 | break;
|
|---|
| 3401 | }
|
|---|
| 3402 | end = pos + chunkSize;
|
|---|
| 3403 | _context.n = 4;
|
|---|
| 3404 | return chunk.slice(pos, end);
|
|---|
| 3405 | case 4:
|
|---|
| 3406 | pos = end;
|
|---|
| 3407 | _context.n = 3;
|
|---|
| 3408 | break;
|
|---|
| 3409 | case 5:
|
|---|
| 3410 | return _context.a(2);
|
|---|
| 3411 | }
|
|---|
| 3412 | }, streamChunk);
|
|---|
| 3413 | });
|
|---|
| 3414 | var readBytes = /*#__PURE__*/function () {
|
|---|
| 3415 | var _ref = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee(iterable, chunkSize) {
|
|---|
| 3416 | var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk, _t;
|
|---|
| 3417 | return _regenerator().w(function (_context2) {
|
|---|
| 3418 | while (1) switch (_context2.p = _context2.n) {
|
|---|
| 3419 | case 0:
|
|---|
| 3420 | _iteratorAbruptCompletion = false;
|
|---|
| 3421 | _didIteratorError = false;
|
|---|
| 3422 | _context2.p = 1;
|
|---|
| 3423 | _iterator = _asyncIterator(readStream(iterable));
|
|---|
| 3424 | case 2:
|
|---|
| 3425 | _context2.n = 3;
|
|---|
| 3426 | return _awaitAsyncGenerator(_iterator.next());
|
|---|
| 3427 | case 3:
|
|---|
| 3428 | if (!(_iteratorAbruptCompletion = !(_step = _context2.v).done)) {
|
|---|
| 3429 | _context2.n = 5;
|
|---|
| 3430 | break;
|
|---|
| 3431 | }
|
|---|
| 3432 | chunk = _step.value;
|
|---|
| 3433 | return _context2.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(streamChunk(chunk, chunkSize)))), 4);
|
|---|
| 3434 | case 4:
|
|---|
| 3435 | _iteratorAbruptCompletion = false;
|
|---|
| 3436 | _context2.n = 2;
|
|---|
| 3437 | break;
|
|---|
| 3438 | case 5:
|
|---|
| 3439 | _context2.n = 7;
|
|---|
| 3440 | break;
|
|---|
| 3441 | case 6:
|
|---|
| 3442 | _context2.p = 6;
|
|---|
| 3443 | _t = _context2.v;
|
|---|
| 3444 | _didIteratorError = true;
|
|---|
| 3445 | _iteratorError = _t;
|
|---|
| 3446 | case 7:
|
|---|
| 3447 | _context2.p = 7;
|
|---|
| 3448 | _context2.p = 8;
|
|---|
| 3449 | if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|---|
| 3450 | _context2.n = 9;
|
|---|
| 3451 | break;
|
|---|
| 3452 | }
|
|---|
| 3453 | _context2.n = 9;
|
|---|
| 3454 | return _awaitAsyncGenerator(_iterator["return"]());
|
|---|
| 3455 | case 9:
|
|---|
| 3456 | _context2.p = 9;
|
|---|
| 3457 | if (!_didIteratorError) {
|
|---|
| 3458 | _context2.n = 10;
|
|---|
| 3459 | break;
|
|---|
| 3460 | }
|
|---|
| 3461 | throw _iteratorError;
|
|---|
| 3462 | case 10:
|
|---|
| 3463 | return _context2.f(9);
|
|---|
| 3464 | case 11:
|
|---|
| 3465 | return _context2.f(7);
|
|---|
| 3466 | case 12:
|
|---|
| 3467 | return _context2.a(2);
|
|---|
| 3468 | }
|
|---|
| 3469 | }, _callee, null, [[8,, 9, 11], [1, 6, 7, 12]]);
|
|---|
| 3470 | }));
|
|---|
| 3471 | return function readBytes(_x, _x2) {
|
|---|
| 3472 | return _ref.apply(this, arguments);
|
|---|
| 3473 | };
|
|---|
| 3474 | }();
|
|---|
| 3475 | var readStream = /*#__PURE__*/function () {
|
|---|
| 3476 | var _ref2 = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2(stream) {
|
|---|
| 3477 | var reader, _yield$_awaitAsyncGen, done, value;
|
|---|
| 3478 | return _regenerator().w(function (_context3) {
|
|---|
| 3479 | while (1) switch (_context3.p = _context3.n) {
|
|---|
| 3480 | case 0:
|
|---|
| 3481 | if (!stream[Symbol.asyncIterator]) {
|
|---|
| 3482 | _context3.n = 2;
|
|---|
| 3483 | break;
|
|---|
| 3484 | }
|
|---|
| 3485 | return _context3.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(stream))), 1);
|
|---|
| 3486 | case 1:
|
|---|
| 3487 | return _context3.a(2);
|
|---|
| 3488 | case 2:
|
|---|
| 3489 | reader = stream.getReader();
|
|---|
| 3490 | _context3.p = 3;
|
|---|
| 3491 | case 4:
|
|---|
| 3492 | _context3.n = 5;
|
|---|
| 3493 | return _awaitAsyncGenerator(reader.read());
|
|---|
| 3494 | case 5:
|
|---|
| 3495 | _yield$_awaitAsyncGen = _context3.v;
|
|---|
| 3496 | done = _yield$_awaitAsyncGen.done;
|
|---|
| 3497 | value = _yield$_awaitAsyncGen.value;
|
|---|
| 3498 | if (!done) {
|
|---|
| 3499 | _context3.n = 6;
|
|---|
| 3500 | break;
|
|---|
| 3501 | }
|
|---|
| 3502 | return _context3.a(3, 8);
|
|---|
| 3503 | case 6:
|
|---|
| 3504 | _context3.n = 7;
|
|---|
| 3505 | return value;
|
|---|
| 3506 | case 7:
|
|---|
| 3507 | _context3.n = 4;
|
|---|
| 3508 | break;
|
|---|
| 3509 | case 8:
|
|---|
| 3510 | _context3.p = 8;
|
|---|
| 3511 | _context3.n = 9;
|
|---|
| 3512 | return _awaitAsyncGenerator(reader.cancel());
|
|---|
| 3513 | case 9:
|
|---|
| 3514 | return _context3.f(8);
|
|---|
| 3515 | case 10:
|
|---|
| 3516 | return _context3.a(2);
|
|---|
| 3517 | }
|
|---|
| 3518 | }, _callee2, null, [[3,, 8, 10]]);
|
|---|
| 3519 | }));
|
|---|
| 3520 | return function readStream(_x3) {
|
|---|
| 3521 | return _ref2.apply(this, arguments);
|
|---|
| 3522 | };
|
|---|
| 3523 | }();
|
|---|
| 3524 | var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
|
|---|
| 3525 | var iterator = readBytes(stream, chunkSize);
|
|---|
| 3526 | var bytes = 0;
|
|---|
| 3527 | var done;
|
|---|
| 3528 | var _onFinish = function _onFinish(e) {
|
|---|
| 3529 | if (!done) {
|
|---|
| 3530 | done = true;
|
|---|
| 3531 | onFinish && onFinish(e);
|
|---|
| 3532 | }
|
|---|
| 3533 | };
|
|---|
| 3534 | return new ReadableStream({
|
|---|
| 3535 | pull: function pull(controller) {
|
|---|
| 3536 | return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|---|
| 3537 | var _yield$iterator$next, _done, value, len, loadedBytes, _t2;
|
|---|
| 3538 | return _regenerator().w(function (_context4) {
|
|---|
| 3539 | while (1) switch (_context4.p = _context4.n) {
|
|---|
| 3540 | case 0:
|
|---|
| 3541 | _context4.p = 0;
|
|---|
| 3542 | _context4.n = 1;
|
|---|
| 3543 | return iterator.next();
|
|---|
| 3544 | case 1:
|
|---|
| 3545 | _yield$iterator$next = _context4.v;
|
|---|
| 3546 | _done = _yield$iterator$next.done;
|
|---|
| 3547 | value = _yield$iterator$next.value;
|
|---|
| 3548 | if (!_done) {
|
|---|
| 3549 | _context4.n = 2;
|
|---|
| 3550 | break;
|
|---|
| 3551 | }
|
|---|
| 3552 | _onFinish();
|
|---|
| 3553 | controller.close();
|
|---|
| 3554 | return _context4.a(2);
|
|---|
| 3555 | case 2:
|
|---|
| 3556 | len = value.byteLength;
|
|---|
| 3557 | if (onProgress) {
|
|---|
| 3558 | loadedBytes = bytes += len;
|
|---|
| 3559 | onProgress(loadedBytes);
|
|---|
| 3560 | }
|
|---|
| 3561 | controller.enqueue(new Uint8Array(value));
|
|---|
| 3562 | _context4.n = 4;
|
|---|
| 3563 | break;
|
|---|
| 3564 | case 3:
|
|---|
| 3565 | _context4.p = 3;
|
|---|
| 3566 | _t2 = _context4.v;
|
|---|
| 3567 | _onFinish(_t2);
|
|---|
| 3568 | throw _t2;
|
|---|
| 3569 | case 4:
|
|---|
| 3570 | return _context4.a(2);
|
|---|
| 3571 | }
|
|---|
| 3572 | }, _callee3, null, [[0, 3]]);
|
|---|
| 3573 | }))();
|
|---|
| 3574 | },
|
|---|
| 3575 | cancel: function cancel(reason) {
|
|---|
| 3576 | _onFinish(reason);
|
|---|
| 3577 | return iterator["return"]();
|
|---|
| 3578 | }
|
|---|
| 3579 | }, {
|
|---|
| 3580 | highWaterMark: 2
|
|---|
| 3581 | });
|
|---|
| 3582 | };
|
|---|
| 3583 |
|
|---|
| 3584 | /**
|
|---|
| 3585 | * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
|
|---|
| 3586 | * - For base64: compute exact decoded size using length and padding;
|
|---|
| 3587 | * handle %XX at the character-count level (no string allocation).
|
|---|
| 3588 | * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
|
|---|
| 3589 | *
|
|---|
| 3590 | * @param {string} url
|
|---|
| 3591 | * @returns {number}
|
|---|
| 3592 | */
|
|---|
| 3593 | function estimateDataURLDecodedBytes(url) {
|
|---|
| 3594 | if (!url || typeof url !== 'string') return 0;
|
|---|
| 3595 | if (!url.startsWith('data:')) return 0;
|
|---|
| 3596 | var comma = url.indexOf(',');
|
|---|
| 3597 | if (comma < 0) return 0;
|
|---|
| 3598 | var meta = url.slice(5, comma);
|
|---|
| 3599 | var body = url.slice(comma + 1);
|
|---|
| 3600 | var isBase64 = /;base64/i.test(meta);
|
|---|
| 3601 | if (isBase64) {
|
|---|
| 3602 | var effectiveLen = body.length;
|
|---|
| 3603 | var len = body.length; // cache length
|
|---|
| 3604 |
|
|---|
| 3605 | for (var i = 0; i < len; i++) {
|
|---|
| 3606 | if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
|
|---|
| 3607 | var a = body.charCodeAt(i + 1);
|
|---|
| 3608 | var b = body.charCodeAt(i + 2);
|
|---|
| 3609 | var isHex = (a >= 48 && a <= 57 || a >= 65 && a <= 70 || a >= 97 && a <= 102) && (b >= 48 && b <= 57 || b >= 65 && b <= 70 || b >= 97 && b <= 102);
|
|---|
| 3610 | if (isHex) {
|
|---|
| 3611 | effectiveLen -= 2;
|
|---|
| 3612 | i += 2;
|
|---|
| 3613 | }
|
|---|
| 3614 | }
|
|---|
| 3615 | }
|
|---|
| 3616 | var pad = 0;
|
|---|
| 3617 | var idx = len - 1;
|
|---|
| 3618 | var tailIsPct3D = function tailIsPct3D(j) {
|
|---|
| 3619 | return j >= 2 && body.charCodeAt(j - 2) === 37 &&
|
|---|
| 3620 | // '%'
|
|---|
| 3621 | body.charCodeAt(j - 1) === 51 && (
|
|---|
| 3622 | // '3'
|
|---|
| 3623 | body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
|
|---|
| 3624 | }; // 'D' or 'd'
|
|---|
| 3625 |
|
|---|
| 3626 | if (idx >= 0) {
|
|---|
| 3627 | if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|---|
| 3628 | pad++;
|
|---|
| 3629 | idx--;
|
|---|
| 3630 | } else if (tailIsPct3D(idx)) {
|
|---|
| 3631 | pad++;
|
|---|
| 3632 | idx -= 3;
|
|---|
| 3633 | }
|
|---|
| 3634 | }
|
|---|
| 3635 | if (pad === 1 && idx >= 0) {
|
|---|
| 3636 | if (body.charCodeAt(idx) === 61 /* '=' */) {
|
|---|
| 3637 | pad++;
|
|---|
| 3638 | } else if (tailIsPct3D(idx)) {
|
|---|
| 3639 | pad++;
|
|---|
| 3640 | }
|
|---|
| 3641 | }
|
|---|
| 3642 | var groups = Math.floor(effectiveLen / 4);
|
|---|
| 3643 | var _bytes = groups * 3 - (pad || 0);
|
|---|
| 3644 | return _bytes > 0 ? _bytes : 0;
|
|---|
| 3645 | }
|
|---|
| 3646 | if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
|
|---|
| 3647 | return Buffer.byteLength(body, 'utf8');
|
|---|
| 3648 | }
|
|---|
| 3649 |
|
|---|
| 3650 | // Compute UTF-8 byte length directly from UTF-16 code units without allocating
|
|---|
| 3651 | // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
|
|---|
| 3652 | // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
|
|---|
| 3653 | // but 3 UTF-8 bytes).
|
|---|
| 3654 | var bytes = 0;
|
|---|
| 3655 | for (var _i = 0, _len = body.length; _i < _len; _i++) {
|
|---|
| 3656 | var c = body.charCodeAt(_i);
|
|---|
| 3657 | if (c < 0x80) {
|
|---|
| 3658 | bytes += 1;
|
|---|
| 3659 | } else if (c < 0x800) {
|
|---|
| 3660 | bytes += 2;
|
|---|
| 3661 | } else if (c >= 0xd800 && c <= 0xdbff && _i + 1 < _len) {
|
|---|
| 3662 | var next = body.charCodeAt(_i + 1);
|
|---|
| 3663 | if (next >= 0xdc00 && next <= 0xdfff) {
|
|---|
| 3664 | bytes += 4;
|
|---|
| 3665 | _i++;
|
|---|
| 3666 | } else {
|
|---|
| 3667 | bytes += 3;
|
|---|
| 3668 | }
|
|---|
| 3669 | } else {
|
|---|
| 3670 | bytes += 3;
|
|---|
| 3671 | }
|
|---|
| 3672 | }
|
|---|
| 3673 | return bytes;
|
|---|
| 3674 | }
|
|---|
| 3675 |
|
|---|
| 3676 | var VERSION = "1.16.1";
|
|---|
| 3677 |
|
|---|
| 3678 | var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|---|
| 3679 | var isFunction = utils$1.isFunction;
|
|---|
| 3680 | var test = function test(fn) {
|
|---|
| 3681 | try {
|
|---|
| 3682 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|---|
| 3683 | args[_key - 1] = arguments[_key];
|
|---|
| 3684 | }
|
|---|
| 3685 | return !!fn.apply(void 0, args);
|
|---|
| 3686 | } catch (e) {
|
|---|
| 3687 | return false;
|
|---|
| 3688 | }
|
|---|
| 3689 | };
|
|---|
| 3690 | var factory = function factory(env) {
|
|---|
| 3691 | var globalObject = utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
|
|---|
| 3692 | var ReadableStream = globalObject.ReadableStream,
|
|---|
| 3693 | TextEncoder = globalObject.TextEncoder;
|
|---|
| 3694 | env = utils$1.merge.call({
|
|---|
| 3695 | skipUndefined: true
|
|---|
| 3696 | }, {
|
|---|
| 3697 | Request: globalObject.Request,
|
|---|
| 3698 | Response: globalObject.Response
|
|---|
| 3699 | }, env);
|
|---|
| 3700 | var _env = env,
|
|---|
| 3701 | envFetch = _env.fetch,
|
|---|
| 3702 | Request = _env.Request,
|
|---|
| 3703 | Response = _env.Response;
|
|---|
| 3704 | var isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
|
|---|
| 3705 | var isRequestSupported = isFunction(Request);
|
|---|
| 3706 | var isResponseSupported = isFunction(Response);
|
|---|
| 3707 | if (!isFetchSupported) {
|
|---|
| 3708 | return false;
|
|---|
| 3709 | }
|
|---|
| 3710 | var isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream);
|
|---|
| 3711 | var encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? function (encoder) {
|
|---|
| 3712 | return function (str) {
|
|---|
| 3713 | return encoder.encode(str);
|
|---|
| 3714 | };
|
|---|
| 3715 | }(new TextEncoder()) : (/*#__PURE__*/function () {
|
|---|
| 3716 | var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(str) {
|
|---|
| 3717 | var _t, _t2;
|
|---|
| 3718 | return _regenerator().w(function (_context) {
|
|---|
| 3719 | while (1) switch (_context.n) {
|
|---|
| 3720 | case 0:
|
|---|
| 3721 | _t = Uint8Array;
|
|---|
| 3722 | _context.n = 1;
|
|---|
| 3723 | return new Request(str).arrayBuffer();
|
|---|
| 3724 | case 1:
|
|---|
| 3725 | _t2 = _context.v;
|
|---|
| 3726 | return _context.a(2, new _t(_t2));
|
|---|
| 3727 | }
|
|---|
| 3728 | }, _callee);
|
|---|
| 3729 | }));
|
|---|
| 3730 | return function (_x) {
|
|---|
| 3731 | return _ref.apply(this, arguments);
|
|---|
| 3732 | };
|
|---|
| 3733 | }()));
|
|---|
| 3734 | var supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(function () {
|
|---|
| 3735 | var duplexAccessed = false;
|
|---|
| 3736 | var request = new Request(platform.origin, {
|
|---|
| 3737 | body: new ReadableStream(),
|
|---|
| 3738 | method: 'POST',
|
|---|
| 3739 | get duplex() {
|
|---|
| 3740 | duplexAccessed = true;
|
|---|
| 3741 | return 'half';
|
|---|
| 3742 | }
|
|---|
| 3743 | });
|
|---|
| 3744 | var hasContentType = request.headers.has('Content-Type');
|
|---|
| 3745 | if (request.body != null) {
|
|---|
| 3746 | request.body.cancel();
|
|---|
| 3747 | }
|
|---|
| 3748 | return duplexAccessed && !hasContentType;
|
|---|
| 3749 | });
|
|---|
| 3750 | var supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(function () {
|
|---|
| 3751 | return utils$1.isReadableStream(new Response('').body);
|
|---|
| 3752 | });
|
|---|
| 3753 | var resolvers = {
|
|---|
| 3754 | stream: supportsResponseStream && function (res) {
|
|---|
| 3755 | return res.body;
|
|---|
| 3756 | }
|
|---|
| 3757 | };
|
|---|
| 3758 | isFetchSupported && function () {
|
|---|
| 3759 | ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
|
|---|
| 3760 | !resolvers[type] && (resolvers[type] = function (res, config) {
|
|---|
| 3761 | var method = res && res[type];
|
|---|
| 3762 | if (method) {
|
|---|
| 3763 | return method.call(res);
|
|---|
| 3764 | }
|
|---|
| 3765 | throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
|
|---|
| 3766 | });
|
|---|
| 3767 | });
|
|---|
| 3768 | }();
|
|---|
| 3769 | var getBodyLength = /*#__PURE__*/function () {
|
|---|
| 3770 | var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(body) {
|
|---|
| 3771 | var _request;
|
|---|
| 3772 | return _regenerator().w(function (_context2) {
|
|---|
| 3773 | while (1) switch (_context2.n) {
|
|---|
| 3774 | case 0:
|
|---|
| 3775 | if (!(body == null)) {
|
|---|
| 3776 | _context2.n = 1;
|
|---|
| 3777 | break;
|
|---|
| 3778 | }
|
|---|
| 3779 | return _context2.a(2, 0);
|
|---|
| 3780 | case 1:
|
|---|
| 3781 | if (!utils$1.isBlob(body)) {
|
|---|
| 3782 | _context2.n = 2;
|
|---|
| 3783 | break;
|
|---|
| 3784 | }
|
|---|
| 3785 | return _context2.a(2, body.size);
|
|---|
| 3786 | case 2:
|
|---|
| 3787 | if (!utils$1.isSpecCompliantForm(body)) {
|
|---|
| 3788 | _context2.n = 4;
|
|---|
| 3789 | break;
|
|---|
| 3790 | }
|
|---|
| 3791 | _request = new Request(platform.origin, {
|
|---|
| 3792 | method: 'POST',
|
|---|
| 3793 | body: body
|
|---|
| 3794 | });
|
|---|
| 3795 | _context2.n = 3;
|
|---|
| 3796 | return _request.arrayBuffer();
|
|---|
| 3797 | case 3:
|
|---|
| 3798 | return _context2.a(2, _context2.v.byteLength);
|
|---|
| 3799 | case 4:
|
|---|
| 3800 | if (!(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body))) {
|
|---|
| 3801 | _context2.n = 5;
|
|---|
| 3802 | break;
|
|---|
| 3803 | }
|
|---|
| 3804 | return _context2.a(2, body.byteLength);
|
|---|
| 3805 | case 5:
|
|---|
| 3806 | if (utils$1.isURLSearchParams(body)) {
|
|---|
| 3807 | body = body + '';
|
|---|
| 3808 | }
|
|---|
| 3809 | if (!utils$1.isString(body)) {
|
|---|
| 3810 | _context2.n = 7;
|
|---|
| 3811 | break;
|
|---|
| 3812 | }
|
|---|
| 3813 | _context2.n = 6;
|
|---|
| 3814 | return encodeText(body);
|
|---|
| 3815 | case 6:
|
|---|
| 3816 | return _context2.a(2, _context2.v.byteLength);
|
|---|
| 3817 | case 7:
|
|---|
| 3818 | return _context2.a(2);
|
|---|
| 3819 | }
|
|---|
| 3820 | }, _callee2);
|
|---|
| 3821 | }));
|
|---|
| 3822 | return function getBodyLength(_x2) {
|
|---|
| 3823 | return _ref2.apply(this, arguments);
|
|---|
| 3824 | };
|
|---|
| 3825 | }();
|
|---|
| 3826 | var resolveBodyLength = /*#__PURE__*/function () {
|
|---|
| 3827 | var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(headers, body) {
|
|---|
| 3828 | var length;
|
|---|
| 3829 | return _regenerator().w(function (_context3) {
|
|---|
| 3830 | while (1) switch (_context3.n) {
|
|---|
| 3831 | case 0:
|
|---|
| 3832 | length = utils$1.toFiniteNumber(headers.getContentLength());
|
|---|
| 3833 | return _context3.a(2, length == null ? getBodyLength(body) : length);
|
|---|
| 3834 | }
|
|---|
| 3835 | }, _callee3);
|
|---|
| 3836 | }));
|
|---|
| 3837 | return function resolveBodyLength(_x3, _x4) {
|
|---|
| 3838 | return _ref3.apply(this, arguments);
|
|---|
| 3839 | };
|
|---|
| 3840 | }();
|
|---|
| 3841 | return /*#__PURE__*/function () {
|
|---|
| 3842 | var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
|
|---|
| 3843 | var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, _fetch, composedSignal, request, unsubscribe, requestContentLength, estimated, outboundLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, declaredLength, isStreamResponse, options, responseContentLength, _ref5, _ref6, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, _t3, _t4, _t5;
|
|---|
| 3844 | return _regenerator().w(function (_context4) {
|
|---|
| 3845 | while (1) switch (_context4.p = _context4.n) {
|
|---|
| 3846 | case 0:
|
|---|
| 3847 | _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions, maxContentLength = _resolveConfig.maxContentLength, maxBodyLength = _resolveConfig.maxBodyLength;
|
|---|
| 3848 | hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
|
|---|
| 3849 | hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|---|
| 3850 | _fetch = envFetch || fetch;
|
|---|
| 3851 | responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|---|
| 3852 | composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|---|
| 3853 | request = null;
|
|---|
| 3854 | unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
|
|---|
| 3855 | composedSignal.unsubscribe();
|
|---|
| 3856 | };
|
|---|
| 3857 | _context4.p = 1;
|
|---|
| 3858 | if (!(hasMaxContentLength && typeof url === 'string' && url.startsWith('data:'))) {
|
|---|
| 3859 | _context4.n = 2;
|
|---|
| 3860 | break;
|
|---|
| 3861 | }
|
|---|
| 3862 | estimated = estimateDataURLDecodedBytes(url);
|
|---|
| 3863 | if (!(estimated > maxContentLength)) {
|
|---|
| 3864 | _context4.n = 2;
|
|---|
| 3865 | break;
|
|---|
| 3866 | }
|
|---|
| 3867 | throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|---|
| 3868 | case 2:
|
|---|
| 3869 | if (!(hasMaxBodyLength && method !== 'get' && method !== 'head')) {
|
|---|
| 3870 | _context4.n = 4;
|
|---|
| 3871 | break;
|
|---|
| 3872 | }
|
|---|
| 3873 | _context4.n = 3;
|
|---|
| 3874 | return resolveBodyLength(headers, data);
|
|---|
| 3875 | case 3:
|
|---|
| 3876 | outboundLength = _context4.v;
|
|---|
| 3877 | if (!(typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength)) {
|
|---|
| 3878 | _context4.n = 4;
|
|---|
| 3879 | break;
|
|---|
| 3880 | }
|
|---|
| 3881 | throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
|
|---|
| 3882 | case 4:
|
|---|
| 3883 | _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
|---|
| 3884 | if (!_t3) {
|
|---|
| 3885 | _context4.n = 6;
|
|---|
| 3886 | break;
|
|---|
| 3887 | }
|
|---|
| 3888 | _context4.n = 5;
|
|---|
| 3889 | return resolveBodyLength(headers, data);
|
|---|
| 3890 | case 5:
|
|---|
| 3891 | _t4 = requestContentLength = _context4.v;
|
|---|
| 3892 | _t3 = _t4 !== 0;
|
|---|
| 3893 | case 6:
|
|---|
| 3894 | if (!_t3) {
|
|---|
| 3895 | _context4.n = 7;
|
|---|
| 3896 | break;
|
|---|
| 3897 | }
|
|---|
| 3898 | _request = new Request(url, {
|
|---|
| 3899 | method: 'POST',
|
|---|
| 3900 | body: data,
|
|---|
| 3901 | duplex: 'half'
|
|---|
| 3902 | });
|
|---|
| 3903 | if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|---|
| 3904 | headers.setContentType(contentTypeHeader);
|
|---|
| 3905 | }
|
|---|
| 3906 | if (_request.body) {
|
|---|
| 3907 | _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
|
|---|
| 3908 | data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|---|
| 3909 | }
|
|---|
| 3910 | case 7:
|
|---|
| 3911 | if (!utils$1.isString(withCredentials)) {
|
|---|
| 3912 | withCredentials = withCredentials ? 'include' : 'omit';
|
|---|
| 3913 | }
|
|---|
| 3914 |
|
|---|
| 3915 | // Cloudflare Workers throws when credentials are defined
|
|---|
| 3916 | // see https://github.com/cloudflare/workerd/issues/902
|
|---|
| 3917 | isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype; // If data is FormData and Content-Type is multipart/form-data without boundary,
|
|---|
| 3918 | // delete it so fetch can set it correctly with the boundary
|
|---|
| 3919 | if (utils$1.isFormData(data)) {
|
|---|
| 3920 | contentType = headers.getContentType();
|
|---|
| 3921 | if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
|
|---|
| 3922 | headers["delete"]('content-type');
|
|---|
| 3923 | }
|
|---|
| 3924 | }
|
|---|
| 3925 |
|
|---|
| 3926 | // Set User-Agent header if not already set (fetch defaults to 'node' in Node.js)
|
|---|
| 3927 | headers.set('User-Agent', 'axios/' + VERSION, false);
|
|---|
| 3928 | resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
|
|---|
| 3929 | signal: composedSignal,
|
|---|
| 3930 | method: method.toUpperCase(),
|
|---|
| 3931 | headers: toByteStringHeaderObject(headers.normalize()),
|
|---|
| 3932 | body: data,
|
|---|
| 3933 | duplex: 'half',
|
|---|
| 3934 | credentials: isCredentialsSupported ? withCredentials : undefined
|
|---|
| 3935 | });
|
|---|
| 3936 | request = isRequestSupported && new Request(url, resolvedOptions);
|
|---|
| 3937 | _context4.n = 8;
|
|---|
| 3938 | return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
|
|---|
| 3939 | case 8:
|
|---|
| 3940 | response = _context4.v;
|
|---|
| 3941 | if (!hasMaxContentLength) {
|
|---|
| 3942 | _context4.n = 9;
|
|---|
| 3943 | break;
|
|---|
| 3944 | }
|
|---|
| 3945 | declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|---|
| 3946 | if (!(declaredLength != null && declaredLength > maxContentLength)) {
|
|---|
| 3947 | _context4.n = 9;
|
|---|
| 3948 | break;
|
|---|
| 3949 | }
|
|---|
| 3950 | throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|---|
| 3951 | case 9:
|
|---|
| 3952 | isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|---|
| 3953 | if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
|
|---|
| 3954 | options = {};
|
|---|
| 3955 | ['status', 'statusText', 'headers'].forEach(function (prop) {
|
|---|
| 3956 | options[prop] = response[prop];
|
|---|
| 3957 | });
|
|---|
| 3958 | responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|---|
| 3959 | _ref5 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref6 = _slicedToArray(_ref5, 2), _onProgress = _ref6[0], _flush = _ref6[1];
|
|---|
| 3960 | bytesRead = 0;
|
|---|
| 3961 | onChunkProgress = function onChunkProgress(loadedBytes) {
|
|---|
| 3962 | if (hasMaxContentLength) {
|
|---|
| 3963 | bytesRead = loadedBytes;
|
|---|
| 3964 | if (bytesRead > maxContentLength) {
|
|---|
| 3965 | throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|---|
| 3966 | }
|
|---|
| 3967 | }
|
|---|
| 3968 | _onProgress && _onProgress(loadedBytes);
|
|---|
| 3969 | };
|
|---|
| 3970 | response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, function () {
|
|---|
| 3971 | _flush && _flush();
|
|---|
| 3972 | unsubscribe && unsubscribe();
|
|---|
| 3973 | }), options);
|
|---|
| 3974 | }
|
|---|
| 3975 | responseType = responseType || 'text';
|
|---|
| 3976 | _context4.n = 10;
|
|---|
| 3977 | return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|---|
| 3978 | case 10:
|
|---|
| 3979 | responseData = _context4.v;
|
|---|
| 3980 | if (!(hasMaxContentLength && !supportsResponseStream && !isStreamResponse)) {
|
|---|
| 3981 | _context4.n = 11;
|
|---|
| 3982 | break;
|
|---|
| 3983 | }
|
|---|
| 3984 | if (responseData != null) {
|
|---|
| 3985 | if (typeof responseData.byteLength === 'number') {
|
|---|
| 3986 | materializedSize = responseData.byteLength;
|
|---|
| 3987 | } else if (typeof responseData.size === 'number') {
|
|---|
| 3988 | materializedSize = responseData.size;
|
|---|
| 3989 | } else if (typeof responseData === 'string') {
|
|---|
| 3990 | materializedSize = typeof TextEncoder === 'function' ? new TextEncoder().encode(responseData).byteLength : responseData.length;
|
|---|
| 3991 | }
|
|---|
| 3992 | }
|
|---|
| 3993 | if (!(typeof materializedSize === 'number' && materializedSize > maxContentLength)) {
|
|---|
| 3994 | _context4.n = 11;
|
|---|
| 3995 | break;
|
|---|
| 3996 | }
|
|---|
| 3997 | throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
|
|---|
| 3998 | case 11:
|
|---|
| 3999 | !isStreamResponse && unsubscribe && unsubscribe();
|
|---|
| 4000 | _context4.n = 12;
|
|---|
| 4001 | return new Promise(function (resolve, reject) {
|
|---|
| 4002 | settle(resolve, reject, {
|
|---|
| 4003 | data: responseData,
|
|---|
| 4004 | headers: AxiosHeaders.from(response.headers),
|
|---|
| 4005 | status: response.status,
|
|---|
| 4006 | statusText: response.statusText,
|
|---|
| 4007 | config: config,
|
|---|
| 4008 | request: request
|
|---|
| 4009 | });
|
|---|
| 4010 | });
|
|---|
| 4011 | case 12:
|
|---|
| 4012 | return _context4.a(2, _context4.v);
|
|---|
| 4013 | case 13:
|
|---|
| 4014 | _context4.p = 13;
|
|---|
| 4015 | _t5 = _context4.v;
|
|---|
| 4016 | unsubscribe && unsubscribe();
|
|---|
| 4017 |
|
|---|
| 4018 | // Safari can surface fetch aborts as a DOMException-like object whose
|
|---|
| 4019 | // branded getters throw. Prefer our composed signal reason before reading
|
|---|
| 4020 | // the caught error, preserving timeout vs cancellation semantics.
|
|---|
| 4021 | if (!(composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError)) {
|
|---|
| 4022 | _context4.n = 14;
|
|---|
| 4023 | break;
|
|---|
| 4024 | }
|
|---|
| 4025 | canceledError = composedSignal.reason;
|
|---|
| 4026 | canceledError.config = config;
|
|---|
| 4027 | request && (canceledError.request = request);
|
|---|
| 4028 | _t5 !== canceledError && (canceledError.cause = _t5);
|
|---|
| 4029 | throw canceledError;
|
|---|
| 4030 | case 14:
|
|---|
| 4031 | if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
|
|---|
| 4032 | _context4.n = 15;
|
|---|
| 4033 | break;
|
|---|
| 4034 | }
|
|---|
| 4035 | throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t5 && _t5.response), {
|
|---|
| 4036 | cause: _t5.cause || _t5
|
|---|
| 4037 | });
|
|---|
| 4038 | case 15:
|
|---|
| 4039 | throw AxiosError.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
|
|---|
| 4040 | case 16:
|
|---|
| 4041 | return _context4.a(2);
|
|---|
| 4042 | }
|
|---|
| 4043 | }, _callee4, null, [[1, 13]]);
|
|---|
| 4044 | }));
|
|---|
| 4045 | return function (_x5) {
|
|---|
| 4046 | return _ref4.apply(this, arguments);
|
|---|
| 4047 | };
|
|---|
| 4048 | }();
|
|---|
| 4049 | };
|
|---|
| 4050 | var seedCache = new Map();
|
|---|
| 4051 | var getFetch = function getFetch(config) {
|
|---|
| 4052 | var env = config && config.env || {};
|
|---|
| 4053 | var fetch = env.fetch,
|
|---|
| 4054 | Request = env.Request,
|
|---|
| 4055 | Response = env.Response;
|
|---|
| 4056 | var seeds = [Request, Response, fetch];
|
|---|
| 4057 | var len = seeds.length,
|
|---|
| 4058 | i = len,
|
|---|
| 4059 | seed,
|
|---|
| 4060 | target,
|
|---|
| 4061 | map = seedCache;
|
|---|
| 4062 | while (i--) {
|
|---|
| 4063 | seed = seeds[i];
|
|---|
| 4064 | target = map.get(seed);
|
|---|
| 4065 | target === undefined && map.set(seed, target = i ? new Map() : factory(env));
|
|---|
| 4066 | map = target;
|
|---|
| 4067 | }
|
|---|
| 4068 | return target;
|
|---|
| 4069 | };
|
|---|
| 4070 | getFetch();
|
|---|
| 4071 |
|
|---|
| 4072 | /**
|
|---|
| 4073 | * Known adapters mapping.
|
|---|
| 4074 | * Provides environment-specific adapters for Axios:
|
|---|
| 4075 | * - `http` for Node.js
|
|---|
| 4076 | * - `xhr` for browsers
|
|---|
| 4077 | * - `fetch` for fetch API-based requests
|
|---|
| 4078 | *
|
|---|
| 4079 | * @type {Object<string, Function|Object>}
|
|---|
| 4080 | */
|
|---|
| 4081 | var knownAdapters = {
|
|---|
| 4082 | http: httpAdapter,
|
|---|
| 4083 | xhr: xhrAdapter,
|
|---|
| 4084 | fetch: {
|
|---|
| 4085 | get: getFetch
|
|---|
| 4086 | }
|
|---|
| 4087 | };
|
|---|
| 4088 |
|
|---|
| 4089 | // Assign adapter names for easier debugging and identification
|
|---|
| 4090 | utils$1.forEach(knownAdapters, function (fn, value) {
|
|---|
| 4091 | if (fn) {
|
|---|
| 4092 | try {
|
|---|
| 4093 | // Null-proto descriptors so a polluted Object.prototype.get cannot turn
|
|---|
| 4094 | // these data descriptors into accessor descriptors on the way in.
|
|---|
| 4095 | Object.defineProperty(fn, 'name', {
|
|---|
| 4096 | __proto__: null,
|
|---|
| 4097 | value: value
|
|---|
| 4098 | });
|
|---|
| 4099 | } catch (e) {
|
|---|
| 4100 | // eslint-disable-next-line no-empty
|
|---|
| 4101 | }
|
|---|
| 4102 | Object.defineProperty(fn, 'adapterName', {
|
|---|
| 4103 | __proto__: null,
|
|---|
| 4104 | value: value
|
|---|
| 4105 | });
|
|---|
| 4106 | }
|
|---|
| 4107 | });
|
|---|
| 4108 |
|
|---|
| 4109 | /**
|
|---|
| 4110 | * Render a rejection reason string for unknown or unsupported adapters
|
|---|
| 4111 | *
|
|---|
| 4112 | * @param {string} reason
|
|---|
| 4113 | * @returns {string}
|
|---|
| 4114 | */
|
|---|
| 4115 | var renderReason = function renderReason(reason) {
|
|---|
| 4116 | return "- ".concat(reason);
|
|---|
| 4117 | };
|
|---|
| 4118 |
|
|---|
| 4119 | /**
|
|---|
| 4120 | * Check if the adapter is resolved (function, null, or false)
|
|---|
| 4121 | *
|
|---|
| 4122 | * @param {Function|null|false} adapter
|
|---|
| 4123 | * @returns {boolean}
|
|---|
| 4124 | */
|
|---|
| 4125 | var isResolvedHandle = function isResolvedHandle(adapter) {
|
|---|
| 4126 | return utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|---|
| 4127 | };
|
|---|
| 4128 |
|
|---|
| 4129 | /**
|
|---|
| 4130 | * Get the first suitable adapter from the provided list.
|
|---|
| 4131 | * Tries each adapter in order until a supported one is found.
|
|---|
| 4132 | * Throws an AxiosError if no adapter is suitable.
|
|---|
| 4133 | *
|
|---|
| 4134 | * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
|
|---|
| 4135 | * @param {Object} config - Axios request configuration
|
|---|
| 4136 | * @throws {AxiosError} If no suitable adapter is available
|
|---|
| 4137 | * @returns {Function} The resolved adapter function
|
|---|
| 4138 | */
|
|---|
| 4139 | function getAdapter(adapters, config) {
|
|---|
| 4140 | adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|---|
| 4141 | var _adapters = adapters,
|
|---|
| 4142 | length = _adapters.length;
|
|---|
| 4143 | var nameOrAdapter;
|
|---|
| 4144 | var adapter;
|
|---|
| 4145 | var rejectedReasons = {};
|
|---|
| 4146 | for (var i = 0; i < length; i++) {
|
|---|
| 4147 | nameOrAdapter = adapters[i];
|
|---|
| 4148 | var id = void 0;
|
|---|
| 4149 | adapter = nameOrAdapter;
|
|---|
| 4150 | if (!isResolvedHandle(nameOrAdapter)) {
|
|---|
| 4151 | adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|---|
| 4152 | if (adapter === undefined) {
|
|---|
| 4153 | throw new AxiosError("Unknown adapter '".concat(id, "'"));
|
|---|
| 4154 | }
|
|---|
| 4155 | }
|
|---|
| 4156 | if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
|
|---|
| 4157 | break;
|
|---|
| 4158 | }
|
|---|
| 4159 | rejectedReasons[id || '#' + i] = adapter;
|
|---|
| 4160 | }
|
|---|
| 4161 | if (!adapter) {
|
|---|
| 4162 | var reasons = Object.entries(rejectedReasons).map(function (_ref) {
|
|---|
| 4163 | var _ref2 = _slicedToArray(_ref, 2),
|
|---|
| 4164 | id = _ref2[0],
|
|---|
| 4165 | state = _ref2[1];
|
|---|
| 4166 | return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
|
|---|
| 4167 | });
|
|---|
| 4168 | var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
|
|---|
| 4169 | throw new AxiosError("There is no suitable adapter to dispatch the request " + s, 'ERR_NOT_SUPPORT');
|
|---|
| 4170 | }
|
|---|
| 4171 | return adapter;
|
|---|
| 4172 | }
|
|---|
| 4173 |
|
|---|
| 4174 | /**
|
|---|
| 4175 | * Exports Axios adapters and utility to resolve an adapter
|
|---|
| 4176 | */
|
|---|
| 4177 | var adapters = {
|
|---|
| 4178 | /**
|
|---|
| 4179 | * Resolve an adapter from a list of adapter names or functions.
|
|---|
| 4180 | * @type {Function}
|
|---|
| 4181 | */
|
|---|
| 4182 | getAdapter: getAdapter,
|
|---|
| 4183 | /**
|
|---|
| 4184 | * Exposes all known adapters
|
|---|
| 4185 | * @type {Object<string, Function|Object>}
|
|---|
| 4186 | */
|
|---|
| 4187 | adapters: knownAdapters
|
|---|
| 4188 | };
|
|---|
| 4189 |
|
|---|
| 4190 | /**
|
|---|
| 4191 | * Throws a `CanceledError` if cancellation has been requested.
|
|---|
| 4192 | *
|
|---|
| 4193 | * @param {Object} config The config that is to be used for the request
|
|---|
| 4194 | *
|
|---|
| 4195 | * @returns {void}
|
|---|
| 4196 | */
|
|---|
| 4197 | function throwIfCancellationRequested(config) {
|
|---|
| 4198 | if (config.cancelToken) {
|
|---|
| 4199 | config.cancelToken.throwIfRequested();
|
|---|
| 4200 | }
|
|---|
| 4201 | if (config.signal && config.signal.aborted) {
|
|---|
| 4202 | throw new CanceledError(null, config);
|
|---|
| 4203 | }
|
|---|
| 4204 | }
|
|---|
| 4205 |
|
|---|
| 4206 | /**
|
|---|
| 4207 | * Dispatch a request to the server using the configured adapter.
|
|---|
| 4208 | *
|
|---|
| 4209 | * @param {object} config The config that is to be used for the request
|
|---|
| 4210 | *
|
|---|
| 4211 | * @returns {Promise} The Promise to be fulfilled
|
|---|
| 4212 | */
|
|---|
| 4213 | function dispatchRequest(config) {
|
|---|
| 4214 | throwIfCancellationRequested(config);
|
|---|
| 4215 | config.headers = AxiosHeaders.from(config.headers);
|
|---|
| 4216 |
|
|---|
| 4217 | // Transform request data
|
|---|
| 4218 | config.data = transformData.call(config, config.transformRequest);
|
|---|
| 4219 | if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
|---|
| 4220 | config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|---|
| 4221 | }
|
|---|
| 4222 | var adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|---|
| 4223 | return adapter(config).then(function onAdapterResolution(response) {
|
|---|
| 4224 | throwIfCancellationRequested(config);
|
|---|
| 4225 |
|
|---|
| 4226 | // Expose the current response on config so that transformResponse can
|
|---|
| 4227 | // attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|---|
| 4228 | // We clean it up afterwards to avoid polluting the config object.
|
|---|
| 4229 | config.response = response;
|
|---|
| 4230 | try {
|
|---|
| 4231 | response.data = transformData.call(config, config.transformResponse, response);
|
|---|
| 4232 | } finally {
|
|---|
| 4233 | delete config.response;
|
|---|
| 4234 | }
|
|---|
| 4235 | response.headers = AxiosHeaders.from(response.headers);
|
|---|
| 4236 | return response;
|
|---|
| 4237 | }, function onAdapterRejection(reason) {
|
|---|
| 4238 | if (!isCancel(reason)) {
|
|---|
| 4239 | throwIfCancellationRequested(config);
|
|---|
| 4240 |
|
|---|
| 4241 | // Transform response data
|
|---|
| 4242 | if (reason && reason.response) {
|
|---|
| 4243 | config.response = reason.response;
|
|---|
| 4244 | try {
|
|---|
| 4245 | reason.response.data = transformData.call(config, config.transformResponse, reason.response);
|
|---|
| 4246 | } finally {
|
|---|
| 4247 | delete config.response;
|
|---|
| 4248 | }
|
|---|
| 4249 | reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|---|
| 4250 | }
|
|---|
| 4251 | }
|
|---|
| 4252 | return Promise.reject(reason);
|
|---|
| 4253 | });
|
|---|
| 4254 | }
|
|---|
| 4255 |
|
|---|
| 4256 | var validators$1 = {};
|
|---|
| 4257 |
|
|---|
| 4258 | // eslint-disable-next-line func-names
|
|---|
| 4259 | ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
|
|---|
| 4260 | validators$1[type] = function validator(thing) {
|
|---|
| 4261 | return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|---|
| 4262 | };
|
|---|
| 4263 | });
|
|---|
| 4264 | var deprecatedWarnings = {};
|
|---|
| 4265 |
|
|---|
| 4266 | /**
|
|---|
| 4267 | * Transitional option validator
|
|---|
| 4268 | *
|
|---|
| 4269 | * @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|---|
| 4270 | * @param {string?} version - deprecated version / removed since version
|
|---|
| 4271 | * @param {string?} message - some message with additional info
|
|---|
| 4272 | *
|
|---|
| 4273 | * @returns {function}
|
|---|
| 4274 | */
|
|---|
| 4275 | validators$1.transitional = function transitional(validator, version, message) {
|
|---|
| 4276 | function formatMessage(opt, desc) {
|
|---|
| 4277 | return '[Axios v' + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? '. ' + message : '');
|
|---|
| 4278 | }
|
|---|
| 4279 |
|
|---|
| 4280 | // eslint-disable-next-line func-names
|
|---|
| 4281 | return function (value, opt, opts) {
|
|---|
| 4282 | if (validator === false) {
|
|---|
| 4283 | throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
|
|---|
| 4284 | }
|
|---|
| 4285 | if (version && !deprecatedWarnings[opt]) {
|
|---|
| 4286 | deprecatedWarnings[opt] = true;
|
|---|
| 4287 | // eslint-disable-next-line no-console
|
|---|
| 4288 | console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
|
|---|
| 4289 | }
|
|---|
| 4290 | return validator ? validator(value, opt, opts) : true;
|
|---|
| 4291 | };
|
|---|
| 4292 | };
|
|---|
| 4293 | validators$1.spelling = function spelling(correctSpelling) {
|
|---|
| 4294 | return function (value, opt) {
|
|---|
| 4295 | // eslint-disable-next-line no-console
|
|---|
| 4296 | console.warn("".concat(opt, " is likely a misspelling of ").concat(correctSpelling));
|
|---|
| 4297 | return true;
|
|---|
| 4298 | };
|
|---|
| 4299 | };
|
|---|
| 4300 |
|
|---|
| 4301 | /**
|
|---|
| 4302 | * Assert object's properties type
|
|---|
| 4303 | *
|
|---|
| 4304 | * @param {object} options
|
|---|
| 4305 | * @param {object} schema
|
|---|
| 4306 | * @param {boolean?} allowUnknown
|
|---|
| 4307 | *
|
|---|
| 4308 | * @returns {object}
|
|---|
| 4309 | */
|
|---|
| 4310 |
|
|---|
| 4311 | function assertOptions(options, schema, allowUnknown) {
|
|---|
| 4312 | if (_typeof(options) !== 'object') {
|
|---|
| 4313 | throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
|---|
| 4314 | }
|
|---|
| 4315 | var keys = Object.keys(options);
|
|---|
| 4316 | var i = keys.length;
|
|---|
| 4317 | while (i-- > 0) {
|
|---|
| 4318 | var opt = keys[i];
|
|---|
| 4319 | // Use hasOwnProperty so a polluted Object.prototype.<opt> cannot supply
|
|---|
| 4320 | // a non-function validator and cause a TypeError.
|
|---|
| 4321 | var validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
|
|---|
| 4322 | if (validator) {
|
|---|
| 4323 | var value = options[opt];
|
|---|
| 4324 | var result = value === undefined || validator(value, opt, options);
|
|---|
| 4325 | if (result !== true) {
|
|---|
| 4326 | throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|---|
| 4327 | }
|
|---|
| 4328 | continue;
|
|---|
| 4329 | }
|
|---|
| 4330 | if (allowUnknown !== true) {
|
|---|
| 4331 | throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
|---|
| 4332 | }
|
|---|
| 4333 | }
|
|---|
| 4334 | }
|
|---|
| 4335 | var validator = {
|
|---|
| 4336 | assertOptions: assertOptions,
|
|---|
| 4337 | validators: validators$1
|
|---|
| 4338 | };
|
|---|
| 4339 |
|
|---|
| 4340 | var validators = validator.validators;
|
|---|
| 4341 |
|
|---|
| 4342 | /**
|
|---|
| 4343 | * Create a new instance of Axios
|
|---|
| 4344 | *
|
|---|
| 4345 | * @param {Object} instanceConfig The default config for the instance
|
|---|
| 4346 | *
|
|---|
| 4347 | * @return {Axios} A new instance of Axios
|
|---|
| 4348 | */
|
|---|
| 4349 | var Axios = /*#__PURE__*/function () {
|
|---|
| 4350 | function Axios(instanceConfig) {
|
|---|
| 4351 | _classCallCheck(this, Axios);
|
|---|
| 4352 | this.defaults = instanceConfig || {};
|
|---|
| 4353 | this.interceptors = {
|
|---|
| 4354 | request: new InterceptorManager(),
|
|---|
| 4355 | response: new InterceptorManager()
|
|---|
| 4356 | };
|
|---|
| 4357 | }
|
|---|
| 4358 |
|
|---|
| 4359 | /**
|
|---|
| 4360 | * Dispatch a request
|
|---|
| 4361 | *
|
|---|
| 4362 | * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|---|
| 4363 | * @param {?Object} config
|
|---|
| 4364 | *
|
|---|
| 4365 | * @returns {Promise} The Promise to be fulfilled
|
|---|
| 4366 | */
|
|---|
| 4367 | return _createClass(Axios, [{
|
|---|
| 4368 | key: "request",
|
|---|
| 4369 | value: (function () {
|
|---|
| 4370 | var _request2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configOrUrl, config) {
|
|---|
| 4371 | var dummy, stack, firstNewlineIndex, secondNewlineIndex, stackWithoutTwoTopLines, _t;
|
|---|
| 4372 | return _regenerator().w(function (_context) {
|
|---|
| 4373 | while (1) switch (_context.p = _context.n) {
|
|---|
| 4374 | case 0:
|
|---|
| 4375 | _context.p = 0;
|
|---|
| 4376 | _context.n = 1;
|
|---|
| 4377 | return this._request(configOrUrl, config);
|
|---|
| 4378 | case 1:
|
|---|
| 4379 | return _context.a(2, _context.v);
|
|---|
| 4380 | case 2:
|
|---|
| 4381 | _context.p = 2;
|
|---|
| 4382 | _t = _context.v;
|
|---|
| 4383 | if (_t instanceof Error) {
|
|---|
| 4384 | dummy = {};
|
|---|
| 4385 | Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|---|
| 4386 |
|
|---|
| 4387 | // slice off the Error: ... line
|
|---|
| 4388 | stack = function () {
|
|---|
| 4389 | if (!dummy.stack) {
|
|---|
| 4390 | return '';
|
|---|
| 4391 | }
|
|---|
| 4392 | var firstNewlineIndex = dummy.stack.indexOf('\n');
|
|---|
| 4393 | return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
|
|---|
| 4394 | }();
|
|---|
| 4395 | try {
|
|---|
| 4396 | if (!_t.stack) {
|
|---|
| 4397 | _t.stack = stack;
|
|---|
| 4398 | // match without the 2 top stack lines
|
|---|
| 4399 | } else if (stack) {
|
|---|
| 4400 | firstNewlineIndex = stack.indexOf('\n');
|
|---|
| 4401 | secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
|
|---|
| 4402 | stackWithoutTwoTopLines = secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
|
|---|
| 4403 | if (!String(_t.stack).endsWith(stackWithoutTwoTopLines)) {
|
|---|
| 4404 | _t.stack += '\n' + stack;
|
|---|
| 4405 | }
|
|---|
| 4406 | }
|
|---|
| 4407 | } catch (e) {
|
|---|
| 4408 | // ignore the case where "stack" is an un-writable property
|
|---|
| 4409 | }
|
|---|
| 4410 | }
|
|---|
| 4411 | throw _t;
|
|---|
| 4412 | case 3:
|
|---|
| 4413 | return _context.a(2);
|
|---|
| 4414 | }
|
|---|
| 4415 | }, _callee, this, [[0, 2]]);
|
|---|
| 4416 | }));
|
|---|
| 4417 | function request(_x, _x2) {
|
|---|
| 4418 | return _request2.apply(this, arguments);
|
|---|
| 4419 | }
|
|---|
| 4420 | return request;
|
|---|
| 4421 | }())
|
|---|
| 4422 | }, {
|
|---|
| 4423 | key: "_request",
|
|---|
| 4424 | value: function _request(configOrUrl, config) {
|
|---|
| 4425 | /*eslint no-param-reassign:0*/
|
|---|
| 4426 | // Allow for axios('example/url'[, config]) a la fetch API
|
|---|
| 4427 | if (typeof configOrUrl === 'string') {
|
|---|
| 4428 | config = config || {};
|
|---|
| 4429 | config.url = configOrUrl;
|
|---|
| 4430 | } else {
|
|---|
| 4431 | config = configOrUrl || {};
|
|---|
| 4432 | }
|
|---|
| 4433 | config = mergeConfig(this.defaults, config);
|
|---|
| 4434 | var _config = config,
|
|---|
| 4435 | transitional = _config.transitional,
|
|---|
| 4436 | paramsSerializer = _config.paramsSerializer,
|
|---|
| 4437 | headers = _config.headers;
|
|---|
| 4438 | if (transitional !== undefined) {
|
|---|
| 4439 | validator.assertOptions(transitional, {
|
|---|
| 4440 | silentJSONParsing: validators.transitional(validators["boolean"]),
|
|---|
| 4441 | forcedJSONParsing: validators.transitional(validators["boolean"]),
|
|---|
| 4442 | clarifyTimeoutError: validators.transitional(validators["boolean"]),
|
|---|
| 4443 | legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"])
|
|---|
| 4444 | }, false);
|
|---|
| 4445 | }
|
|---|
| 4446 | if (paramsSerializer != null) {
|
|---|
| 4447 | if (utils$1.isFunction(paramsSerializer)) {
|
|---|
| 4448 | config.paramsSerializer = {
|
|---|
| 4449 | serialize: paramsSerializer
|
|---|
| 4450 | };
|
|---|
| 4451 | } else {
|
|---|
| 4452 | validator.assertOptions(paramsSerializer, {
|
|---|
| 4453 | encode: validators["function"],
|
|---|
| 4454 | serialize: validators["function"]
|
|---|
| 4455 | }, true);
|
|---|
| 4456 | }
|
|---|
| 4457 | }
|
|---|
| 4458 |
|
|---|
| 4459 | // Set config.allowAbsoluteUrls
|
|---|
| 4460 | if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
|
|---|
| 4461 | config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|---|
| 4462 | } else {
|
|---|
| 4463 | config.allowAbsoluteUrls = true;
|
|---|
| 4464 | }
|
|---|
| 4465 | validator.assertOptions(config, {
|
|---|
| 4466 | baseUrl: validators.spelling('baseURL'),
|
|---|
| 4467 | withXsrfToken: validators.spelling('withXSRFToken')
|
|---|
| 4468 | }, true);
|
|---|
| 4469 |
|
|---|
| 4470 | // Set config.method
|
|---|
| 4471 | config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|---|
| 4472 |
|
|---|
| 4473 | // Flatten headers
|
|---|
| 4474 | var contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
|
|---|
| 4475 | headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'query', 'common'], function (method) {
|
|---|
| 4476 | delete headers[method];
|
|---|
| 4477 | });
|
|---|
| 4478 | config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|---|
| 4479 |
|
|---|
| 4480 | // filter out skipped interceptors
|
|---|
| 4481 | var requestInterceptorChain = [];
|
|---|
| 4482 | var synchronousRequestInterceptors = true;
|
|---|
| 4483 | this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|---|
| 4484 | if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|---|
| 4485 | return;
|
|---|
| 4486 | }
|
|---|
| 4487 | synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|---|
| 4488 | var transitional = config.transitional || transitionalDefaults;
|
|---|
| 4489 | var legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
|
|---|
| 4490 | if (legacyInterceptorReqResOrdering) {
|
|---|
| 4491 | requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|---|
| 4492 | } else {
|
|---|
| 4493 | requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|---|
| 4494 | }
|
|---|
| 4495 | });
|
|---|
| 4496 | var responseInterceptorChain = [];
|
|---|
| 4497 | this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|---|
| 4498 | responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|---|
| 4499 | });
|
|---|
| 4500 | var promise;
|
|---|
| 4501 | var i = 0;
|
|---|
| 4502 | var len;
|
|---|
| 4503 | if (!synchronousRequestInterceptors) {
|
|---|
| 4504 | var chain = [dispatchRequest.bind(this), undefined];
|
|---|
| 4505 | chain.unshift.apply(chain, requestInterceptorChain);
|
|---|
| 4506 | chain.push.apply(chain, responseInterceptorChain);
|
|---|
| 4507 | len = chain.length;
|
|---|
| 4508 | promise = Promise.resolve(config);
|
|---|
| 4509 | while (i < len) {
|
|---|
| 4510 | promise = promise.then(chain[i++], chain[i++]);
|
|---|
| 4511 | }
|
|---|
| 4512 | return promise;
|
|---|
| 4513 | }
|
|---|
| 4514 | len = requestInterceptorChain.length;
|
|---|
| 4515 | var newConfig = config;
|
|---|
| 4516 | while (i < len) {
|
|---|
| 4517 | var onFulfilled = requestInterceptorChain[i++];
|
|---|
| 4518 | var onRejected = requestInterceptorChain[i++];
|
|---|
| 4519 | try {
|
|---|
| 4520 | newConfig = onFulfilled(newConfig);
|
|---|
| 4521 | } catch (error) {
|
|---|
| 4522 | onRejected.call(this, error);
|
|---|
| 4523 | break;
|
|---|
| 4524 | }
|
|---|
| 4525 | }
|
|---|
| 4526 | try {
|
|---|
| 4527 | promise = dispatchRequest.call(this, newConfig);
|
|---|
| 4528 | } catch (error) {
|
|---|
| 4529 | return Promise.reject(error);
|
|---|
| 4530 | }
|
|---|
| 4531 | i = 0;
|
|---|
| 4532 | len = responseInterceptorChain.length;
|
|---|
| 4533 | while (i < len) {
|
|---|
| 4534 | promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|---|
| 4535 | }
|
|---|
| 4536 | return promise;
|
|---|
| 4537 | }
|
|---|
| 4538 | }, {
|
|---|
| 4539 | key: "getUri",
|
|---|
| 4540 | value: function getUri(config) {
|
|---|
| 4541 | config = mergeConfig(this.defaults, config);
|
|---|
| 4542 | var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|---|
| 4543 | return buildURL(fullPath, config.params, config.paramsSerializer);
|
|---|
| 4544 | }
|
|---|
| 4545 | }]);
|
|---|
| 4546 | }(); // Provide aliases for supported request methods
|
|---|
| 4547 | utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|---|
| 4548 | /*eslint func-names:0*/
|
|---|
| 4549 | Axios.prototype[method] = function (url, config) {
|
|---|
| 4550 | return this.request(mergeConfig(config || {}, {
|
|---|
| 4551 | method: method,
|
|---|
| 4552 | url: url,
|
|---|
| 4553 | data: (config || {}).data
|
|---|
| 4554 | }));
|
|---|
| 4555 | };
|
|---|
| 4556 | });
|
|---|
| 4557 | utils$1.forEach(['post', 'put', 'patch', 'query'], function forEachMethodWithData(method) {
|
|---|
| 4558 | function generateHTTPMethod(isForm) {
|
|---|
| 4559 | return function httpMethod(url, data, config) {
|
|---|
| 4560 | return this.request(mergeConfig(config || {}, {
|
|---|
| 4561 | method: method,
|
|---|
| 4562 | headers: isForm ? {
|
|---|
| 4563 | 'Content-Type': 'multipart/form-data'
|
|---|
| 4564 | } : {},
|
|---|
| 4565 | url: url,
|
|---|
| 4566 | data: data
|
|---|
| 4567 | }));
|
|---|
| 4568 | };
|
|---|
| 4569 | }
|
|---|
| 4570 | Axios.prototype[method] = generateHTTPMethod();
|
|---|
| 4571 |
|
|---|
| 4572 | // QUERY is a safe/idempotent read method; multipart form bodies don't fit
|
|---|
| 4573 | // its semantics, so no queryForm shorthand is generated.
|
|---|
| 4574 | if (method !== 'query') {
|
|---|
| 4575 | Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|---|
| 4576 | }
|
|---|
| 4577 | });
|
|---|
| 4578 |
|
|---|
| 4579 | /**
|
|---|
| 4580 | * A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|---|
| 4581 | *
|
|---|
| 4582 | * @param {Function} executor The executor function.
|
|---|
| 4583 | *
|
|---|
| 4584 | * @returns {CancelToken}
|
|---|
| 4585 | */
|
|---|
| 4586 | var CancelToken = /*#__PURE__*/function () {
|
|---|
| 4587 | function CancelToken(executor) {
|
|---|
| 4588 | _classCallCheck(this, CancelToken);
|
|---|
| 4589 | if (typeof executor !== 'function') {
|
|---|
| 4590 | throw new TypeError('executor must be a function.');
|
|---|
| 4591 | }
|
|---|
| 4592 | var resolvePromise;
|
|---|
| 4593 | this.promise = new Promise(function promiseExecutor(resolve) {
|
|---|
| 4594 | resolvePromise = resolve;
|
|---|
| 4595 | });
|
|---|
| 4596 | var token = this;
|
|---|
| 4597 |
|
|---|
| 4598 | // eslint-disable-next-line func-names
|
|---|
| 4599 | this.promise.then(function (cancel) {
|
|---|
| 4600 | if (!token._listeners) return;
|
|---|
| 4601 | var i = token._listeners.length;
|
|---|
| 4602 | while (i-- > 0) {
|
|---|
| 4603 | token._listeners[i](cancel);
|
|---|
| 4604 | }
|
|---|
| 4605 | token._listeners = null;
|
|---|
| 4606 | });
|
|---|
| 4607 |
|
|---|
| 4608 | // eslint-disable-next-line func-names
|
|---|
| 4609 | this.promise.then = function (onfulfilled) {
|
|---|
| 4610 | var _resolve;
|
|---|
| 4611 | // eslint-disable-next-line func-names
|
|---|
| 4612 | var promise = new Promise(function (resolve) {
|
|---|
| 4613 | token.subscribe(resolve);
|
|---|
| 4614 | _resolve = resolve;
|
|---|
| 4615 | }).then(onfulfilled);
|
|---|
| 4616 | promise.cancel = function reject() {
|
|---|
| 4617 | token.unsubscribe(_resolve);
|
|---|
| 4618 | };
|
|---|
| 4619 | return promise;
|
|---|
| 4620 | };
|
|---|
| 4621 | executor(function cancel(message, config, request) {
|
|---|
| 4622 | if (token.reason) {
|
|---|
| 4623 | // Cancellation has already been requested
|
|---|
| 4624 | return;
|
|---|
| 4625 | }
|
|---|
| 4626 | token.reason = new CanceledError(message, config, request);
|
|---|
| 4627 | resolvePromise(token.reason);
|
|---|
| 4628 | });
|
|---|
| 4629 | }
|
|---|
| 4630 |
|
|---|
| 4631 | /**
|
|---|
| 4632 | * Throws a `CanceledError` if cancellation has been requested.
|
|---|
| 4633 | */
|
|---|
| 4634 | return _createClass(CancelToken, [{
|
|---|
| 4635 | key: "throwIfRequested",
|
|---|
| 4636 | value: function throwIfRequested() {
|
|---|
| 4637 | if (this.reason) {
|
|---|
| 4638 | throw this.reason;
|
|---|
| 4639 | }
|
|---|
| 4640 | }
|
|---|
| 4641 |
|
|---|
| 4642 | /**
|
|---|
| 4643 | * Subscribe to the cancel signal
|
|---|
| 4644 | */
|
|---|
| 4645 | }, {
|
|---|
| 4646 | key: "subscribe",
|
|---|
| 4647 | value: function subscribe(listener) {
|
|---|
| 4648 | if (this.reason) {
|
|---|
| 4649 | listener(this.reason);
|
|---|
| 4650 | return;
|
|---|
| 4651 | }
|
|---|
| 4652 | if (this._listeners) {
|
|---|
| 4653 | this._listeners.push(listener);
|
|---|
| 4654 | } else {
|
|---|
| 4655 | this._listeners = [listener];
|
|---|
| 4656 | }
|
|---|
| 4657 | }
|
|---|
| 4658 |
|
|---|
| 4659 | /**
|
|---|
| 4660 | * Unsubscribe from the cancel signal
|
|---|
| 4661 | */
|
|---|
| 4662 | }, {
|
|---|
| 4663 | key: "unsubscribe",
|
|---|
| 4664 | value: function unsubscribe(listener) {
|
|---|
| 4665 | if (!this._listeners) {
|
|---|
| 4666 | return;
|
|---|
| 4667 | }
|
|---|
| 4668 | var index = this._listeners.indexOf(listener);
|
|---|
| 4669 | if (index !== -1) {
|
|---|
| 4670 | this._listeners.splice(index, 1);
|
|---|
| 4671 | }
|
|---|
| 4672 | }
|
|---|
| 4673 | }, {
|
|---|
| 4674 | key: "toAbortSignal",
|
|---|
| 4675 | value: function toAbortSignal() {
|
|---|
| 4676 | var _this = this;
|
|---|
| 4677 | var controller = new AbortController();
|
|---|
| 4678 | var abort = function abort(err) {
|
|---|
| 4679 | controller.abort(err);
|
|---|
| 4680 | };
|
|---|
| 4681 | this.subscribe(abort);
|
|---|
| 4682 | controller.signal.unsubscribe = function () {
|
|---|
| 4683 | return _this.unsubscribe(abort);
|
|---|
| 4684 | };
|
|---|
| 4685 | return controller.signal;
|
|---|
| 4686 | }
|
|---|
| 4687 |
|
|---|
| 4688 | /**
|
|---|
| 4689 | * Returns an object that contains a new `CancelToken` and a function that, when called,
|
|---|
| 4690 | * cancels the `CancelToken`.
|
|---|
| 4691 | */
|
|---|
| 4692 | }], [{
|
|---|
| 4693 | key: "source",
|
|---|
| 4694 | value: function source() {
|
|---|
| 4695 | var cancel;
|
|---|
| 4696 | var token = new CancelToken(function executor(c) {
|
|---|
| 4697 | cancel = c;
|
|---|
| 4698 | });
|
|---|
| 4699 | return {
|
|---|
| 4700 | token: token,
|
|---|
| 4701 | cancel: cancel
|
|---|
| 4702 | };
|
|---|
| 4703 | }
|
|---|
| 4704 | }]);
|
|---|
| 4705 | }();
|
|---|
| 4706 |
|
|---|
| 4707 | /**
|
|---|
| 4708 | * Syntactic sugar for invoking a function and expanding an array for arguments.
|
|---|
| 4709 | *
|
|---|
| 4710 | * Common use case would be to use `Function.prototype.apply`.
|
|---|
| 4711 | *
|
|---|
| 4712 | * ```js
|
|---|
| 4713 | * function f(x, y, z) {}
|
|---|
| 4714 | * const args = [1, 2, 3];
|
|---|
| 4715 | * f.apply(null, args);
|
|---|
| 4716 | * ```
|
|---|
| 4717 | *
|
|---|
| 4718 | * With `spread` this example can be re-written.
|
|---|
| 4719 | *
|
|---|
| 4720 | * ```js
|
|---|
| 4721 | * spread(function(x, y, z) {})([1, 2, 3]);
|
|---|
| 4722 | * ```
|
|---|
| 4723 | *
|
|---|
| 4724 | * @param {Function} callback
|
|---|
| 4725 | *
|
|---|
| 4726 | * @returns {Function}
|
|---|
| 4727 | */
|
|---|
| 4728 | function spread(callback) {
|
|---|
| 4729 | return function wrap(arr) {
|
|---|
| 4730 | return callback.apply(null, arr);
|
|---|
| 4731 | };
|
|---|
| 4732 | }
|
|---|
| 4733 |
|
|---|
| 4734 | /**
|
|---|
| 4735 | * Determines whether the payload is an error thrown by Axios
|
|---|
| 4736 | *
|
|---|
| 4737 | * @param {*} payload The value to test
|
|---|
| 4738 | *
|
|---|
| 4739 | * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|---|
| 4740 | */
|
|---|
| 4741 | function isAxiosError(payload) {
|
|---|
| 4742 | return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|---|
| 4743 | }
|
|---|
| 4744 |
|
|---|
| 4745 | var HttpStatusCode = {
|
|---|
| 4746 | Continue: 100,
|
|---|
| 4747 | SwitchingProtocols: 101,
|
|---|
| 4748 | Processing: 102,
|
|---|
| 4749 | EarlyHints: 103,
|
|---|
| 4750 | Ok: 200,
|
|---|
| 4751 | Created: 201,
|
|---|
| 4752 | Accepted: 202,
|
|---|
| 4753 | NonAuthoritativeInformation: 203,
|
|---|
| 4754 | NoContent: 204,
|
|---|
| 4755 | ResetContent: 205,
|
|---|
| 4756 | PartialContent: 206,
|
|---|
| 4757 | MultiStatus: 207,
|
|---|
| 4758 | AlreadyReported: 208,
|
|---|
| 4759 | ImUsed: 226,
|
|---|
| 4760 | MultipleChoices: 300,
|
|---|
| 4761 | MovedPermanently: 301,
|
|---|
| 4762 | Found: 302,
|
|---|
| 4763 | SeeOther: 303,
|
|---|
| 4764 | NotModified: 304,
|
|---|
| 4765 | UseProxy: 305,
|
|---|
| 4766 | Unused: 306,
|
|---|
| 4767 | TemporaryRedirect: 307,
|
|---|
| 4768 | PermanentRedirect: 308,
|
|---|
| 4769 | BadRequest: 400,
|
|---|
| 4770 | Unauthorized: 401,
|
|---|
| 4771 | PaymentRequired: 402,
|
|---|
| 4772 | Forbidden: 403,
|
|---|
| 4773 | NotFound: 404,
|
|---|
| 4774 | MethodNotAllowed: 405,
|
|---|
| 4775 | NotAcceptable: 406,
|
|---|
| 4776 | ProxyAuthenticationRequired: 407,
|
|---|
| 4777 | RequestTimeout: 408,
|
|---|
| 4778 | Conflict: 409,
|
|---|
| 4779 | Gone: 410,
|
|---|
| 4780 | LengthRequired: 411,
|
|---|
| 4781 | PreconditionFailed: 412,
|
|---|
| 4782 | PayloadTooLarge: 413,
|
|---|
| 4783 | UriTooLong: 414,
|
|---|
| 4784 | UnsupportedMediaType: 415,
|
|---|
| 4785 | RangeNotSatisfiable: 416,
|
|---|
| 4786 | ExpectationFailed: 417,
|
|---|
| 4787 | ImATeapot: 418,
|
|---|
| 4788 | MisdirectedRequest: 421,
|
|---|
| 4789 | UnprocessableEntity: 422,
|
|---|
| 4790 | Locked: 423,
|
|---|
| 4791 | FailedDependency: 424,
|
|---|
| 4792 | TooEarly: 425,
|
|---|
| 4793 | UpgradeRequired: 426,
|
|---|
| 4794 | PreconditionRequired: 428,
|
|---|
| 4795 | TooManyRequests: 429,
|
|---|
| 4796 | RequestHeaderFieldsTooLarge: 431,
|
|---|
| 4797 | UnavailableForLegalReasons: 451,
|
|---|
| 4798 | InternalServerError: 500,
|
|---|
| 4799 | NotImplemented: 501,
|
|---|
| 4800 | BadGateway: 502,
|
|---|
| 4801 | ServiceUnavailable: 503,
|
|---|
| 4802 | GatewayTimeout: 504,
|
|---|
| 4803 | HttpVersionNotSupported: 505,
|
|---|
| 4804 | VariantAlsoNegotiates: 506,
|
|---|
| 4805 | InsufficientStorage: 507,
|
|---|
| 4806 | LoopDetected: 508,
|
|---|
| 4807 | NotExtended: 510,
|
|---|
| 4808 | NetworkAuthenticationRequired: 511,
|
|---|
| 4809 | WebServerIsDown: 521,
|
|---|
| 4810 | ConnectionTimedOut: 522,
|
|---|
| 4811 | OriginIsUnreachable: 523,
|
|---|
| 4812 | TimeoutOccurred: 524,
|
|---|
| 4813 | SslHandshakeFailed: 525,
|
|---|
| 4814 | InvalidSslCertificate: 526
|
|---|
| 4815 | };
|
|---|
| 4816 | Object.entries(HttpStatusCode).forEach(function (_ref) {
|
|---|
| 4817 | var _ref2 = _slicedToArray(_ref, 2),
|
|---|
| 4818 | key = _ref2[0],
|
|---|
| 4819 | value = _ref2[1];
|
|---|
| 4820 | HttpStatusCode[value] = key;
|
|---|
| 4821 | });
|
|---|
| 4822 |
|
|---|
| 4823 | /**
|
|---|
| 4824 | * Create an instance of Axios
|
|---|
| 4825 | *
|
|---|
| 4826 | * @param {Object} defaultConfig The default config for the instance
|
|---|
| 4827 | *
|
|---|
| 4828 | * @returns {Axios} A new instance of Axios
|
|---|
| 4829 | */
|
|---|
| 4830 | function createInstance(defaultConfig) {
|
|---|
| 4831 | var context = new Axios(defaultConfig);
|
|---|
| 4832 | var instance = bind(Axios.prototype.request, context);
|
|---|
| 4833 |
|
|---|
| 4834 | // Copy axios.prototype to instance
|
|---|
| 4835 | utils$1.extend(instance, Axios.prototype, context, {
|
|---|
| 4836 | allOwnKeys: true
|
|---|
| 4837 | });
|
|---|
| 4838 |
|
|---|
| 4839 | // Copy context to instance
|
|---|
| 4840 | utils$1.extend(instance, context, null, {
|
|---|
| 4841 | allOwnKeys: true
|
|---|
| 4842 | });
|
|---|
| 4843 |
|
|---|
| 4844 | // Factory for creating new instances
|
|---|
| 4845 | instance.create = function create(instanceConfig) {
|
|---|
| 4846 | return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|---|
| 4847 | };
|
|---|
| 4848 | return instance;
|
|---|
| 4849 | }
|
|---|
| 4850 |
|
|---|
| 4851 | // Create the default instance to be exported
|
|---|
| 4852 | var axios = createInstance(defaults);
|
|---|
| 4853 |
|
|---|
| 4854 | // Expose Axios class to allow class inheritance
|
|---|
| 4855 | axios.Axios = Axios;
|
|---|
| 4856 |
|
|---|
| 4857 | // Expose Cancel & CancelToken
|
|---|
| 4858 | axios.CanceledError = CanceledError;
|
|---|
| 4859 | axios.CancelToken = CancelToken;
|
|---|
| 4860 | axios.isCancel = isCancel;
|
|---|
| 4861 | axios.VERSION = VERSION;
|
|---|
| 4862 | axios.toFormData = toFormData;
|
|---|
| 4863 |
|
|---|
| 4864 | // Expose AxiosError class
|
|---|
| 4865 | axios.AxiosError = AxiosError;
|
|---|
| 4866 |
|
|---|
| 4867 | // alias for CanceledError for backward compatibility
|
|---|
| 4868 | axios.Cancel = axios.CanceledError;
|
|---|
| 4869 |
|
|---|
| 4870 | // Expose all/spread
|
|---|
| 4871 | axios.all = function all(promises) {
|
|---|
| 4872 | return Promise.all(promises);
|
|---|
| 4873 | };
|
|---|
| 4874 | axios.spread = spread;
|
|---|
| 4875 |
|
|---|
| 4876 | // Expose isAxiosError
|
|---|
| 4877 | axios.isAxiosError = isAxiosError;
|
|---|
| 4878 |
|
|---|
| 4879 | // Expose mergeConfig
|
|---|
| 4880 | axios.mergeConfig = mergeConfig;
|
|---|
| 4881 | axios.AxiosHeaders = AxiosHeaders;
|
|---|
| 4882 | axios.formToJSON = function (thing) {
|
|---|
| 4883 | return formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|---|
| 4884 | };
|
|---|
| 4885 | axios.getAdapter = adapters.getAdapter;
|
|---|
| 4886 | axios.HttpStatusCode = HttpStatusCode;
|
|---|
| 4887 | axios["default"] = axios;
|
|---|
| 4888 |
|
|---|
| 4889 | return axios;
|
|---|
| 4890 |
|
|---|
| 4891 | }));
|
|---|
| 4892 | //# sourceMappingURL=axios.js.map
|
|---|