unika-components 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,4 @@
1
1
  import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, toDisplayString, createCommentVNode, Fragment, ref, watch, renderSlot, onMounted, onBeforeUnmount, createTextVNode, renderList, onUnmounted, withDirectives, vShow, watchEffect, nextTick, resolveComponent, createVNode, withModifiers, vModelText, provide, inject, vModelDynamic, vModelSelect, reactive, pushScopeId, popScopeId, createBlock, TransitionGroup, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from 'vue';
2
- import http from 'http';
3
- import https from 'https';
4
- import url from 'url';
5
- import require$$0 from 'stream';
6
- import assert from 'assert';
7
- import tty from 'tty';
8
- import util from 'util';
9
- import os from 'os';
10
- import zlib from 'zlib';
11
2
 
12
3
  if (typeof window !== 'undefined' && window.addEventListener) {
13
4
  window.addEventListener('resize', () => {
@@ -22494,15 +22485,15 @@ function baseGetTag(value) {
22494
22485
  function isObjectLike(value) {
22495
22486
  return value != null && typeof value == "object";
22496
22487
  }
22497
- var isArray$1 = Array.isArray;
22498
- var isArray$1$1 = isArray$1;
22499
- function isObject$1(value) {
22488
+ var isArray = Array.isArray;
22489
+ var isArray$1 = isArray;
22490
+ function isObject(value) {
22500
22491
  var type = typeof value;
22501
22492
  return value != null && (type == "object" || type == "function");
22502
22493
  }
22503
22494
  var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
22504
- function isFunction$2(value) {
22505
- if (!isObject$1(value)) {
22495
+ function isFunction(value) {
22496
+ if (!isObject(value)) {
22506
22497
  return false;
22507
22498
  }
22508
22499
  var tag = baseGetTag(value);
@@ -22539,10 +22530,10 @@ var funcToString = funcProto.toString;
22539
22530
  var hasOwnProperty$a = objectProto$c.hasOwnProperty;
22540
22531
  var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$a).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
22541
22532
  function baseIsNative(value) {
22542
- if (!isObject$1(value) || isMasked(value)) {
22533
+ if (!isObject(value) || isMasked(value)) {
22543
22534
  return false;
22544
22535
  }
22545
- var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
22536
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
22546
22537
  return pattern.test(toSource(value));
22547
22538
  }
22548
22539
  function getValue(object, key) {
@@ -22559,7 +22550,7 @@ var baseCreate = function() {
22559
22550
  function object() {
22560
22551
  }
22561
22552
  return function(proto) {
22562
- if (!isObject$1(proto)) {
22553
+ if (!isObject(proto)) {
22563
22554
  return {};
22564
22555
  }
22565
22556
  if (objectCreate) {
@@ -22651,7 +22642,7 @@ function isLength(value) {
22651
22642
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
22652
22643
  }
22653
22644
  function isArrayLike(value) {
22654
- return value != null && isLength(value.length) && !isFunction$2(value);
22645
+ return value != null && isLength(value.length) && !isFunction(value);
22655
22646
  }
22656
22647
  var objectProto$a = Object.prototype;
22657
22648
  function isPrototype(value) {
@@ -22686,8 +22677,8 @@ var freeModule$2 = freeExports$2 && typeof module == "object" && module && !modu
22686
22677
  var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
22687
22678
  var Buffer$1 = moduleExports$2 ? root$1.Buffer : void 0;
22688
22679
  var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : void 0;
22689
- var isBuffer$2 = nativeIsBuffer || stubFalse;
22690
- var isBuffer$1$1 = isBuffer$2;
22680
+ var isBuffer = nativeIsBuffer || stubFalse;
22681
+ var isBuffer$1 = isBuffer;
22691
22682
  var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", funcTag$1 = "[object Function]", mapTag$5 = "[object Map]", numberTag$3 = "[object Number]", objectTag$3 = "[object Object]", regexpTag$3 = "[object RegExp]", setTag$5 = "[object Set]", stringTag$3 = "[object String]", weakMapTag$2 = "[object WeakMap]";
22692
22683
  var arrayBufferTag$3 = "[object ArrayBuffer]", dataViewTag$4 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
22693
22684
  var typedArrayTags = {};
@@ -22722,7 +22713,7 @@ var isTypedArray$1 = isTypedArray;
22722
22713
  var objectProto$8 = Object.prototype;
22723
22714
  var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
22724
22715
  function arrayLikeKeys(value, inherited) {
22725
- var isArr = isArray$1$1(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
22716
+ var isArr = isArray$1(value), isArg = !isArr && isArguments$1(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
22726
22717
  for (var key in value) {
22727
22718
  if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) {
22728
22719
  result.push(key);
@@ -22766,7 +22757,7 @@ function nativeKeysIn(object) {
22766
22757
  var objectProto$6 = Object.prototype;
22767
22758
  var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
22768
22759
  function baseKeysIn(object) {
22769
- if (!isObject$1(object)) {
22760
+ if (!isObject(object)) {
22770
22761
  return nativeKeysIn(object);
22771
22762
  }
22772
22763
  var isProto = isPrototype(object), result = [];
@@ -23046,7 +23037,7 @@ function copySymbolsIn(source, object) {
23046
23037
  }
23047
23038
  function baseGetAllKeys(object, keysFunc, symbolsFunc) {
23048
23039
  var result = keysFunc(object);
23049
- return isArray$1$1(object) ? result : arrayPush(result, symbolsFunc(object));
23040
+ return isArray$1(object) ? result : arrayPush(result, symbolsFunc(object));
23050
23041
  }
23051
23042
  function getAllKeys(object) {
23052
23043
  return baseGetAllKeys(object, keys, getSymbols$1);
@@ -23186,10 +23177,10 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
23186
23177
  if (result !== void 0) {
23187
23178
  return result;
23188
23179
  }
23189
- if (!isObject$1(value)) {
23180
+ if (!isObject(value)) {
23190
23181
  return value;
23191
23182
  }
23192
- var isArr = isArray$1$1(value);
23183
+ var isArr = isArray$1(value);
23193
23184
  if (isArr) {
23194
23185
  result = initCloneArray(value);
23195
23186
  if (!isDeep) {
@@ -23197,7 +23188,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
23197
23188
  }
23198
23189
  } else {
23199
23190
  var tag = getTag$1(value), isFunc = tag == funcTag || tag == genTag;
23200
- if (isBuffer$1$1(value)) {
23191
+ if (isBuffer$1(value)) {
23201
23192
  return cloneBuffer(value, isDeep);
23202
23193
  }
23203
23194
  if (tag == objectTag$1 || tag == argsTag$1 || isFunc && !object) {
@@ -23430,12 +23421,12 @@ var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[o
23430
23421
  var objectProto = Object.prototype;
23431
23422
  var hasOwnProperty = objectProto.hasOwnProperty;
23432
23423
  function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
23433
- var objIsArr = isArray$1$1(object), othIsArr = isArray$1$1(other), objTag = objIsArr ? arrayTag : getTag$1(object), othTag = othIsArr ? arrayTag : getTag$1(other);
23424
+ var objIsArr = isArray$1(object), othIsArr = isArray$1(other), objTag = objIsArr ? arrayTag : getTag$1(object), othTag = othIsArr ? arrayTag : getTag$1(other);
23434
23425
  objTag = objTag == argsTag ? objectTag : objTag;
23435
23426
  othTag = othTag == argsTag ? objectTag : othTag;
23436
23427
  var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
23437
- if (isSameTag && isBuffer$1$1(object)) {
23438
- if (!isBuffer$1$1(other)) {
23428
+ if (isSameTag && isBuffer$1(object)) {
23429
+ if (!isBuffer$1(other)) {
23439
23430
  return false;
23440
23431
  }
23441
23432
  objIsArr = true;
@@ -24006,3691 +23997,20 @@ script$h.install = (app) => {
24006
23997
  app.component(script$h.name, script$h);
24007
23998
  };
24008
23999
 
24009
- var bind = function bind(fn, thisArg) {
24010
- return function wrap() {
24011
- var args = new Array(arguments.length);
24012
- for (var i = 0; i < args.length; i++) {
24013
- args[i] = arguments[i];
24014
- }
24015
- return fn.apply(thisArg, args);
24016
- };
24017
- };
24018
-
24019
- /*global toString:true*/
24020
-
24021
- // utils is a library of generic helper functions non-specific to axios
24022
-
24023
- var toString = Object.prototype.toString;
24024
-
24025
- /**
24026
- * Determine if a value is an Array
24027
- *
24028
- * @param {Object} val The value to test
24029
- * @returns {boolean} True if value is an Array, otherwise false
24030
- */
24031
- function isArray(val) {
24032
- return toString.call(val) === '[object Array]';
24033
- }
24034
-
24035
- /**
24036
- * Determine if a value is undefined
24037
- *
24038
- * @param {Object} val The value to test
24039
- * @returns {boolean} True if the value is undefined, otherwise false
24040
- */
24041
- function isUndefined(val) {
24042
- return typeof val === 'undefined';
24043
- }
24044
-
24045
- /**
24046
- * Determine if a value is a Buffer
24047
- *
24048
- * @param {Object} val The value to test
24049
- * @returns {boolean} True if value is a Buffer, otherwise false
24050
- */
24051
- function isBuffer$1(val) {
24052
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
24053
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
24054
- }
24055
-
24056
- /**
24057
- * Determine if a value is an ArrayBuffer
24058
- *
24059
- * @param {Object} val The value to test
24060
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
24061
- */
24062
- function isArrayBuffer(val) {
24063
- return toString.call(val) === '[object ArrayBuffer]';
24064
- }
24065
-
24066
- /**
24067
- * Determine if a value is a FormData
24068
- *
24069
- * @param {Object} val The value to test
24070
- * @returns {boolean} True if value is an FormData, otherwise false
24071
- */
24072
- function isFormData(val) {
24073
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
24074
- }
24075
-
24076
- /**
24077
- * Determine if a value is a view on an ArrayBuffer
24078
- *
24079
- * @param {Object} val The value to test
24080
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
24081
- */
24082
- function isArrayBufferView(val) {
24083
- var result;
24084
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
24085
- result = ArrayBuffer.isView(val);
24086
- } else {
24087
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
24088
- }
24089
- return result;
24090
- }
24091
-
24092
- /**
24093
- * Determine if a value is a String
24094
- *
24095
- * @param {Object} val The value to test
24096
- * @returns {boolean} True if value is a String, otherwise false
24097
- */
24098
- function isString$1(val) {
24099
- return typeof val === 'string';
24100
- }
24101
-
24102
- /**
24103
- * Determine if a value is a Number
24104
- *
24105
- * @param {Object} val The value to test
24106
- * @returns {boolean} True if value is a Number, otherwise false
24107
- */
24108
- function isNumber(val) {
24109
- return typeof val === 'number';
24110
- }
24111
-
24112
- /**
24113
- * Determine if a value is an Object
24114
- *
24115
- * @param {Object} val The value to test
24116
- * @returns {boolean} True if value is an Object, otherwise false
24117
- */
24118
- function isObject(val) {
24119
- return val !== null && typeof val === 'object';
24120
- }
24121
-
24122
- /**
24123
- * Determine if a value is a plain Object
24124
- *
24125
- * @param {Object} val The value to test
24126
- * @return {boolean} True if value is a plain Object, otherwise false
24127
- */
24128
- function isPlainObject(val) {
24129
- if (toString.call(val) !== '[object Object]') {
24130
- return false;
24131
- }
24132
-
24133
- var prototype = Object.getPrototypeOf(val);
24134
- return prototype === null || prototype === Object.prototype;
24135
- }
24136
-
24137
- /**
24138
- * Determine if a value is a Date
24139
- *
24140
- * @param {Object} val The value to test
24141
- * @returns {boolean} True if value is a Date, otherwise false
24142
- */
24143
- function isDate(val) {
24144
- return toString.call(val) === '[object Date]';
24145
- }
24146
-
24147
- /**
24148
- * Determine if a value is a File
24149
- *
24150
- * @param {Object} val The value to test
24151
- * @returns {boolean} True if value is a File, otherwise false
24152
- */
24153
- function isFile(val) {
24154
- return toString.call(val) === '[object File]';
24155
- }
24156
-
24157
- /**
24158
- * Determine if a value is a Blob
24159
- *
24160
- * @param {Object} val The value to test
24161
- * @returns {boolean} True if value is a Blob, otherwise false
24162
- */
24163
- function isBlob(val) {
24164
- return toString.call(val) === '[object Blob]';
24165
- }
24166
-
24167
- /**
24168
- * Determine if a value is a Function
24169
- *
24170
- * @param {Object} val The value to test
24171
- * @returns {boolean} True if value is a Function, otherwise false
24172
- */
24173
- function isFunction$1(val) {
24174
- return toString.call(val) === '[object Function]';
24175
- }
24176
-
24177
- /**
24178
- * Determine if a value is a Stream
24179
- *
24180
- * @param {Object} val The value to test
24181
- * @returns {boolean} True if value is a Stream, otherwise false
24182
- */
24183
- function isStream(val) {
24184
- return isObject(val) && isFunction$1(val.pipe);
24185
- }
24186
-
24187
- /**
24188
- * Determine if a value is a URLSearchParams object
24189
- *
24190
- * @param {Object} val The value to test
24191
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
24192
- */
24193
- function isURLSearchParams(val) {
24194
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
24195
- }
24196
-
24197
- /**
24198
- * Trim excess whitespace off the beginning and end of a string
24199
- *
24200
- * @param {String} str The String to trim
24201
- * @returns {String} The String freed of excess whitespace
24202
- */
24203
- function trim(str) {
24204
- return str.replace(/^\s*/, '').replace(/\s*$/, '');
24205
- }
24206
-
24207
- /**
24208
- * Determine if we're running in a standard browser environment
24209
- *
24210
- * This allows axios to run in a web worker, and react-native.
24211
- * Both environments support XMLHttpRequest, but not fully standard globals.
24212
- *
24213
- * web workers:
24214
- * typeof window -> undefined
24215
- * typeof document -> undefined
24216
- *
24217
- * react-native:
24218
- * navigator.product -> 'ReactNative'
24219
- * nativescript
24220
- * navigator.product -> 'NativeScript' or 'NS'
24221
- */
24222
- function isStandardBrowserEnv() {
24223
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
24224
- navigator.product === 'NativeScript' ||
24225
- navigator.product === 'NS')) {
24226
- return false;
24227
- }
24228
- return (
24229
- typeof window !== 'undefined' &&
24230
- typeof document !== 'undefined'
24231
- );
24232
- }
24233
-
24234
- /**
24235
- * Iterate over an Array or an Object invoking a function for each item.
24236
- *
24237
- * If `obj` is an Array callback will be called passing
24238
- * the value, index, and complete array for each item.
24239
- *
24240
- * If 'obj' is an Object callback will be called passing
24241
- * the value, key, and complete object for each property.
24242
- *
24243
- * @param {Object|Array} obj The object to iterate
24244
- * @param {Function} fn The callback to invoke for each item
24245
- */
24246
- function forEach(obj, fn) {
24247
- // Don't bother if no value provided
24248
- if (obj === null || typeof obj === 'undefined') {
24249
- return;
24250
- }
24251
-
24252
- // Force an array if not already something iterable
24253
- if (typeof obj !== 'object') {
24254
- /*eslint no-param-reassign:0*/
24255
- obj = [obj];
24256
- }
24257
-
24258
- if (isArray(obj)) {
24259
- // Iterate over array values
24260
- for (var i = 0, l = obj.length; i < l; i++) {
24261
- fn.call(null, obj[i], i, obj);
24262
- }
24263
- } else {
24264
- // Iterate over object keys
24265
- for (var key in obj) {
24266
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
24267
- fn.call(null, obj[key], key, obj);
24268
- }
24269
- }
24270
- }
24271
- }
24272
-
24273
- /**
24274
- * Accepts varargs expecting each argument to be an object, then
24275
- * immutably merges the properties of each object and returns result.
24276
- *
24277
- * When multiple objects contain the same key the later object in
24278
- * the arguments list will take precedence.
24279
- *
24280
- * Example:
24281
- *
24282
- * ```js
24283
- * var result = merge({foo: 123}, {foo: 456});
24284
- * console.log(result.foo); // outputs 456
24285
- * ```
24286
- *
24287
- * @param {Object} obj1 Object to merge
24288
- * @returns {Object} Result of all merge properties
24289
- */
24290
- function merge(/* obj1, obj2, obj3, ... */) {
24291
- var result = {};
24292
- function assignValue(val, key) {
24293
- if (isPlainObject(result[key]) && isPlainObject(val)) {
24294
- result[key] = merge(result[key], val);
24295
- } else if (isPlainObject(val)) {
24296
- result[key] = merge({}, val);
24297
- } else if (isArray(val)) {
24298
- result[key] = val.slice();
24299
- } else {
24300
- result[key] = val;
24301
- }
24302
- }
24303
-
24304
- for (var i = 0, l = arguments.length; i < l; i++) {
24305
- forEach(arguments[i], assignValue);
24306
- }
24307
- return result;
24308
- }
24309
-
24310
- /**
24311
- * Extends object a by mutably adding to it the properties of object b.
24312
- *
24313
- * @param {Object} a The object to be extended
24314
- * @param {Object} b The object to copy properties from
24315
- * @param {Object} thisArg The object to bind function to
24316
- * @return {Object} The resulting value of object a
24317
- */
24318
- function extend(a, b, thisArg) {
24319
- forEach(b, function assignValue(val, key) {
24320
- if (thisArg && typeof val === 'function') {
24321
- a[key] = bind(val, thisArg);
24322
- } else {
24323
- a[key] = val;
24324
- }
24325
- });
24326
- return a;
24327
- }
24328
-
24329
- /**
24330
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
24331
- *
24332
- * @param {string} content with BOM
24333
- * @return {string} content value without BOM
24334
- */
24335
- function stripBOM(content) {
24336
- if (content.charCodeAt(0) === 0xFEFF) {
24337
- content = content.slice(1);
24338
- }
24339
- return content;
24340
- }
24341
-
24342
- var utils = {
24343
- isArray: isArray,
24344
- isArrayBuffer: isArrayBuffer,
24345
- isBuffer: isBuffer$1,
24346
- isFormData: isFormData,
24347
- isArrayBufferView: isArrayBufferView,
24348
- isString: isString$1,
24349
- isNumber: isNumber,
24350
- isObject: isObject,
24351
- isPlainObject: isPlainObject,
24352
- isUndefined: isUndefined,
24353
- isDate: isDate,
24354
- isFile: isFile,
24355
- isBlob: isBlob,
24356
- isFunction: isFunction$1,
24357
- isStream: isStream,
24358
- isURLSearchParams: isURLSearchParams,
24359
- isStandardBrowserEnv: isStandardBrowserEnv,
24360
- forEach: forEach,
24361
- merge: merge,
24362
- extend: extend,
24363
- trim: trim,
24364
- stripBOM: stripBOM
24365
- };
24366
-
24367
- function encode(val) {
24368
- return encodeURIComponent(val).
24369
- replace(/%3A/gi, ':').
24370
- replace(/%24/g, '$').
24371
- replace(/%2C/gi, ',').
24372
- replace(/%20/g, '+').
24373
- replace(/%5B/gi, '[').
24374
- replace(/%5D/gi, ']');
24375
- }
24376
-
24377
- /**
24378
- * Build a URL by appending params to the end
24379
- *
24380
- * @param {string} url The base of the url (e.g., http://www.google.com)
24381
- * @param {object} [params] The params to be appended
24382
- * @returns {string} The formatted url
24383
- */
24384
- var buildURL = function buildURL(url, params, paramsSerializer) {
24385
- /*eslint no-param-reassign:0*/
24386
- if (!params) {
24387
- return url;
24388
- }
24389
-
24390
- var serializedParams;
24391
- if (paramsSerializer) {
24392
- serializedParams = paramsSerializer(params);
24393
- } else if (utils.isURLSearchParams(params)) {
24394
- serializedParams = params.toString();
24395
- } else {
24396
- var parts = [];
24397
-
24398
- utils.forEach(params, function serialize(val, key) {
24399
- if (val === null || typeof val === 'undefined') {
24400
- return;
24401
- }
24402
-
24403
- if (utils.isArray(val)) {
24404
- key = key + '[]';
24405
- } else {
24406
- val = [val];
24407
- }
24408
-
24409
- utils.forEach(val, function parseValue(v) {
24410
- if (utils.isDate(v)) {
24411
- v = v.toISOString();
24412
- } else if (utils.isObject(v)) {
24413
- v = JSON.stringify(v);
24414
- }
24415
- parts.push(encode(key) + '=' + encode(v));
24416
- });
24417
- });
24418
-
24419
- serializedParams = parts.join('&');
24420
- }
24421
-
24422
- if (serializedParams) {
24423
- var hashmarkIndex = url.indexOf('#');
24424
- if (hashmarkIndex !== -1) {
24425
- url = url.slice(0, hashmarkIndex);
24426
- }
24427
-
24428
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
24429
- }
24430
-
24431
- return url;
24432
- };
24433
-
24434
- function InterceptorManager() {
24435
- this.handlers = [];
24436
- }
24437
-
24438
- /**
24439
- * Add a new interceptor to the stack
24440
- *
24441
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
24442
- * @param {Function} rejected The function to handle `reject` for a `Promise`
24443
- *
24444
- * @return {Number} An ID used to remove interceptor later
24445
- */
24446
- InterceptorManager.prototype.use = function use(fulfilled, rejected) {
24447
- this.handlers.push({
24448
- fulfilled: fulfilled,
24449
- rejected: rejected
24450
- });
24451
- return this.handlers.length - 1;
24452
- };
24453
-
24454
- /**
24455
- * Remove an interceptor from the stack
24456
- *
24457
- * @param {Number} id The ID that was returned by `use`
24458
- */
24459
- InterceptorManager.prototype.eject = function eject(id) {
24460
- if (this.handlers[id]) {
24461
- this.handlers[id] = null;
24462
- }
24463
- };
24464
-
24465
- /**
24466
- * Iterate over all the registered interceptors
24467
- *
24468
- * This method is particularly useful for skipping over any
24469
- * interceptors that may have become `null` calling `eject`.
24470
- *
24471
- * @param {Function} fn The function to call for each interceptor
24472
- */
24473
- InterceptorManager.prototype.forEach = function forEach(fn) {
24474
- utils.forEach(this.handlers, function forEachHandler(h) {
24475
- if (h !== null) {
24476
- fn(h);
24477
- }
24478
- });
24479
- };
24480
-
24481
- var InterceptorManager_1 = InterceptorManager;
24482
-
24483
- /**
24484
- * Transform the data for a request or a response
24485
- *
24486
- * @param {Object|String} data The data to be transformed
24487
- * @param {Array} headers The headers for the request or response
24488
- * @param {Array|Function} fns A single function or Array of functions
24489
- * @returns {*} The resulting transformed data
24490
- */
24491
- var transformData = function transformData(data, headers, fns) {
24492
- /*eslint no-param-reassign:0*/
24493
- utils.forEach(fns, function transform(fn) {
24494
- data = fn(data, headers);
24495
- });
24496
-
24497
- return data;
24498
- };
24499
-
24500
- var isCancel = function isCancel(value) {
24501
- return !!(value && value.__CANCEL__);
24502
- };
24503
-
24504
- var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
24505
- utils.forEach(headers, function processHeader(value, name) {
24506
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
24507
- headers[normalizedName] = value;
24508
- delete headers[name];
24509
- }
24510
- });
24511
- };
24512
-
24513
- /**
24514
- * Update an Error with the specified config, error code, and response.
24515
- *
24516
- * @param {Error} error The error to update.
24517
- * @param {Object} config The config.
24518
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
24519
- * @param {Object} [request] The request.
24520
- * @param {Object} [response] The response.
24521
- * @returns {Error} The error.
24522
- */
24523
- var enhanceError = function enhanceError(error, config, code, request, response) {
24524
- error.config = config;
24525
- if (code) {
24526
- error.code = code;
24527
- }
24528
-
24529
- error.request = request;
24530
- error.response = response;
24531
- error.isAxiosError = true;
24532
-
24533
- error.toJSON = function toJSON() {
24534
- return {
24535
- // Standard
24536
- message: this.message,
24537
- name: this.name,
24538
- // Microsoft
24539
- description: this.description,
24540
- number: this.number,
24541
- // Mozilla
24542
- fileName: this.fileName,
24543
- lineNumber: this.lineNumber,
24544
- columnNumber: this.columnNumber,
24545
- stack: this.stack,
24546
- // Axios
24547
- config: this.config,
24548
- code: this.code
24549
- };
24550
- };
24551
- return error;
24552
- };
24553
-
24554
- /**
24555
- * Create an Error with the specified message, config, error code, request and response.
24556
- *
24557
- * @param {string} message The error message.
24558
- * @param {Object} config The config.
24559
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
24560
- * @param {Object} [request] The request.
24561
- * @param {Object} [response] The response.
24562
- * @returns {Error} The created error.
24563
- */
24564
- var createError = function createError(message, config, code, request, response) {
24565
- var error = new Error(message);
24566
- return enhanceError(error, config, code, request, response);
24567
- };
24568
-
24569
- /**
24570
- * Resolve or reject a Promise based on response status.
24571
- *
24572
- * @param {Function} resolve A function that resolves the promise.
24573
- * @param {Function} reject A function that rejects the promise.
24574
- * @param {object} response The response.
24575
- */
24576
- var settle = function settle(resolve, reject, response) {
24577
- var validateStatus = response.config.validateStatus;
24578
- if (!response.status || !validateStatus || validateStatus(response.status)) {
24579
- resolve(response);
24580
- } else {
24581
- reject(createError(
24582
- 'Request failed with status code ' + response.status,
24583
- response.config,
24584
- null,
24585
- response.request,
24586
- response
24587
- ));
24588
- }
24589
- };
24590
-
24591
- var cookies = (
24592
- utils.isStandardBrowserEnv() ?
24593
-
24594
- // Standard browser envs support document.cookie
24595
- (function standardBrowserEnv() {
24596
- return {
24597
- write: function write(name, value, expires, path, domain, secure) {
24598
- var cookie = [];
24599
- cookie.push(name + '=' + encodeURIComponent(value));
24600
-
24601
- if (utils.isNumber(expires)) {
24602
- cookie.push('expires=' + new Date(expires).toGMTString());
24603
- }
24604
-
24605
- if (utils.isString(path)) {
24606
- cookie.push('path=' + path);
24607
- }
24608
-
24609
- if (utils.isString(domain)) {
24610
- cookie.push('domain=' + domain);
24611
- }
24612
-
24613
- if (secure === true) {
24614
- cookie.push('secure');
24615
- }
24616
-
24617
- document.cookie = cookie.join('; ');
24618
- },
24619
-
24620
- read: function read(name) {
24621
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
24622
- return (match ? decodeURIComponent(match[3]) : null);
24623
- },
24624
-
24625
- remove: function remove(name) {
24626
- this.write(name, '', Date.now() - 86400000);
24627
- }
24628
- };
24629
- })() :
24630
-
24631
- // Non standard browser env (web workers, react-native) lack needed support.
24632
- (function nonStandardBrowserEnv() {
24633
- return {
24634
- write: function write() {},
24635
- read: function read() { return null; },
24636
- remove: function remove() {}
24637
- };
24638
- })()
24639
- );
24640
-
24641
- /**
24642
- * Determines whether the specified URL is absolute
24643
- *
24644
- * @param {string} url The URL to test
24645
- * @returns {boolean} True if the specified URL is absolute, otherwise false
24646
- */
24647
- var isAbsoluteURL = function isAbsoluteURL(url) {
24648
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
24649
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
24650
- // by any combination of letters, digits, plus, period, or hyphen.
24651
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
24652
- };
24653
-
24654
- /**
24655
- * Creates a new URL by combining the specified URLs
24656
- *
24657
- * @param {string} baseURL The base URL
24658
- * @param {string} relativeURL The relative URL
24659
- * @returns {string} The combined URL
24660
- */
24661
- var combineURLs = function combineURLs(baseURL, relativeURL) {
24662
- return relativeURL
24663
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
24664
- : baseURL;
24665
- };
24666
-
24667
- /**
24668
- * Creates a new URL by combining the baseURL with the requestedURL,
24669
- * only when the requestedURL is not already an absolute URL.
24670
- * If the requestURL is absolute, this function returns the requestedURL untouched.
24671
- *
24672
- * @param {string} baseURL The base URL
24673
- * @param {string} requestedURL Absolute or relative URL to combine
24674
- * @returns {string} The combined full path
24675
- */
24676
- var buildFullPath = function buildFullPath(baseURL, requestedURL) {
24677
- if (baseURL && !isAbsoluteURL(requestedURL)) {
24678
- return combineURLs(baseURL, requestedURL);
24679
- }
24680
- return requestedURL;
24681
- };
24682
-
24683
- // Headers whose duplicates are ignored by node
24684
- // c.f. https://nodejs.org/api/http.html#http_message_headers
24685
- var ignoreDuplicateOf = [
24686
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
24687
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
24688
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
24689
- 'referer', 'retry-after', 'user-agent'
24690
- ];
24691
-
24692
- /**
24693
- * Parse headers into an object
24694
- *
24695
- * ```
24696
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
24697
- * Content-Type: application/json
24698
- * Connection: keep-alive
24699
- * Transfer-Encoding: chunked
24700
- * ```
24701
- *
24702
- * @param {String} headers Headers needing to be parsed
24703
- * @returns {Object} Headers parsed into an object
24704
- */
24705
- var parseHeaders = function parseHeaders(headers) {
24706
- var parsed = {};
24707
- var key;
24708
- var val;
24709
- var i;
24710
-
24711
- if (!headers) { return parsed; }
24712
-
24713
- utils.forEach(headers.split('\n'), function parser(line) {
24714
- i = line.indexOf(':');
24715
- key = utils.trim(line.substr(0, i)).toLowerCase();
24716
- val = utils.trim(line.substr(i + 1));
24717
-
24718
- if (key) {
24719
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
24720
- return;
24721
- }
24722
- if (key === 'set-cookie') {
24723
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
24724
- } else {
24725
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
24726
- }
24727
- }
24728
- });
24729
-
24730
- return parsed;
24731
- };
24732
-
24733
- var isURLSameOrigin = (
24734
- utils.isStandardBrowserEnv() ?
24735
-
24736
- // Standard browser envs have full support of the APIs needed to test
24737
- // whether the request URL is of the same origin as current location.
24738
- (function standardBrowserEnv() {
24739
- var msie = /(msie|trident)/i.test(navigator.userAgent);
24740
- var urlParsingNode = document.createElement('a');
24741
- var originURL;
24742
-
24743
- /**
24744
- * Parse a URL to discover it's components
24745
- *
24746
- * @param {String} url The URL to be parsed
24747
- * @returns {Object}
24748
- */
24749
- function resolveURL(url) {
24750
- var href = url;
24751
-
24752
- if (msie) {
24753
- // IE needs attribute set twice to normalize properties
24754
- urlParsingNode.setAttribute('href', href);
24755
- href = urlParsingNode.href;
24756
- }
24757
-
24758
- urlParsingNode.setAttribute('href', href);
24759
-
24760
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
24761
- return {
24762
- href: urlParsingNode.href,
24763
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
24764
- host: urlParsingNode.host,
24765
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
24766
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
24767
- hostname: urlParsingNode.hostname,
24768
- port: urlParsingNode.port,
24769
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
24770
- urlParsingNode.pathname :
24771
- '/' + urlParsingNode.pathname
24772
- };
24773
- }
24774
-
24775
- originURL = resolveURL(window.location.href);
24776
-
24777
- /**
24778
- * Determine if a URL shares the same origin as the current location
24779
- *
24780
- * @param {String} requestURL The URL to test
24781
- * @returns {boolean} True if URL shares the same origin, otherwise false
24782
- */
24783
- return function isURLSameOrigin(requestURL) {
24784
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
24785
- return (parsed.protocol === originURL.protocol &&
24786
- parsed.host === originURL.host);
24787
- };
24788
- })() :
24789
-
24790
- // Non standard browser envs (web workers, react-native) lack needed support.
24791
- (function nonStandardBrowserEnv() {
24792
- return function isURLSameOrigin() {
24793
- return true;
24794
- };
24795
- })()
24796
- );
24797
-
24798
- var xhr = function xhrAdapter(config) {
24799
- return new Promise(function dispatchXhrRequest(resolve, reject) {
24800
- var requestData = config.data;
24801
- var requestHeaders = config.headers;
24802
-
24803
- if (utils.isFormData(requestData)) {
24804
- delete requestHeaders['Content-Type']; // Let the browser set it
24805
- }
24806
-
24807
- var request = new XMLHttpRequest();
24808
-
24809
- // HTTP basic authentication
24810
- if (config.auth) {
24811
- var username = config.auth.username || '';
24812
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
24813
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
24814
- }
24815
-
24816
- var fullPath = buildFullPath(config.baseURL, config.url);
24817
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
24818
-
24819
- // Set the request timeout in MS
24820
- request.timeout = config.timeout;
24821
-
24822
- // Listen for ready state
24823
- request.onreadystatechange = function handleLoad() {
24824
- if (!request || request.readyState !== 4) {
24825
- return;
24826
- }
24827
-
24828
- // The request errored out and we didn't get a response, this will be
24829
- // handled by onerror instead
24830
- // With one exception: request that using file: protocol, most browsers
24831
- // will return status as 0 even though it's a successful request
24832
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
24833
- return;
24834
- }
24835
-
24836
- // Prepare the response
24837
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
24838
- var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
24839
- var response = {
24840
- data: responseData,
24841
- status: request.status,
24842
- statusText: request.statusText,
24843
- headers: responseHeaders,
24844
- config: config,
24845
- request: request
24846
- };
24847
-
24848
- settle(resolve, reject, response);
24849
-
24850
- // Clean up request
24851
- request = null;
24852
- };
24853
-
24854
- // Handle browser request cancellation (as opposed to a manual cancellation)
24855
- request.onabort = function handleAbort() {
24856
- if (!request) {
24857
- return;
24858
- }
24859
-
24860
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
24861
-
24862
- // Clean up request
24863
- request = null;
24864
- };
24865
-
24866
- // Handle low level network errors
24867
- request.onerror = function handleError() {
24868
- // Real errors are hidden from us by the browser
24869
- // onerror should only fire if it's a network error
24870
- reject(createError('Network Error', config, null, request));
24871
-
24872
- // Clean up request
24873
- request = null;
24874
- };
24875
-
24876
- // Handle timeout
24877
- request.ontimeout = function handleTimeout() {
24878
- var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
24879
- if (config.timeoutErrorMessage) {
24880
- timeoutErrorMessage = config.timeoutErrorMessage;
24881
- }
24882
- reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
24883
- request));
24884
-
24885
- // Clean up request
24886
- request = null;
24887
- };
24888
-
24889
- // Add xsrf header
24890
- // This is only done if running in a standard browser environment.
24891
- // Specifically not if we're in a web worker, or react-native.
24892
- if (utils.isStandardBrowserEnv()) {
24893
- // Add xsrf header
24894
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
24895
- cookies.read(config.xsrfCookieName) :
24896
- undefined;
24897
-
24898
- if (xsrfValue) {
24899
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
24900
- }
24901
- }
24902
-
24903
- // Add headers to the request
24904
- if ('setRequestHeader' in request) {
24905
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
24906
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
24907
- // Remove Content-Type if data is undefined
24908
- delete requestHeaders[key];
24909
- } else {
24910
- // Otherwise add header to the request
24911
- request.setRequestHeader(key, val);
24912
- }
24913
- });
24914
- }
24915
-
24916
- // Add withCredentials to request if needed
24917
- if (!utils.isUndefined(config.withCredentials)) {
24918
- request.withCredentials = !!config.withCredentials;
24919
- }
24920
-
24921
- // Add responseType to request if needed
24922
- if (config.responseType) {
24923
- try {
24924
- request.responseType = config.responseType;
24925
- } catch (e) {
24926
- // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
24927
- // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
24928
- if (config.responseType !== 'json') {
24929
- throw e;
24930
- }
24931
- }
24932
- }
24933
-
24934
- // Handle progress if needed
24935
- if (typeof config.onDownloadProgress === 'function') {
24936
- request.addEventListener('progress', config.onDownloadProgress);
24937
- }
24938
-
24939
- // Not all browsers support upload events
24940
- if (typeof config.onUploadProgress === 'function' && request.upload) {
24941
- request.upload.addEventListener('progress', config.onUploadProgress);
24942
- }
24943
-
24944
- if (config.cancelToken) {
24945
- // Handle cancellation
24946
- config.cancelToken.promise.then(function onCanceled(cancel) {
24947
- if (!request) {
24948
- return;
24949
- }
24950
-
24951
- request.abort();
24952
- reject(cancel);
24953
- // Clean up request
24954
- request = null;
24955
- });
24956
- }
24957
-
24958
- if (!requestData) {
24959
- requestData = null;
24960
- }
24961
-
24962
- // Send the request
24963
- request.send(requestData);
24964
- });
24965
- };
24966
-
24967
- /**
24968
- * Helpers.
24969
- */
24970
-
24971
- var s = 1000;
24972
- var m = s * 60;
24973
- var h = m * 60;
24974
- var d = h * 24;
24975
- var w = d * 7;
24976
- var y = d * 365.25;
24977
-
24978
- /**
24979
- * Parse or format the given `val`.
24980
- *
24981
- * Options:
24982
- *
24983
- * - `long` verbose formatting [false]
24984
- *
24985
- * @param {String|Number} val
24986
- * @param {Object} [options]
24987
- * @throws {Error} throw an error if val is not a non-empty string or a number
24988
- * @return {String|Number}
24989
- * @api public
24990
- */
24991
-
24992
- var ms = function(val, options) {
24993
- options = options || {};
24994
- var type = typeof val;
24995
- if (type === 'string' && val.length > 0) {
24996
- return parse(val);
24997
- } else if (type === 'number' && isFinite(val)) {
24998
- return options.long ? fmtLong(val) : fmtShort(val);
24999
- }
25000
- throw new Error(
25001
- 'val is not a non-empty string or a valid number. val=' +
25002
- JSON.stringify(val)
25003
- );
25004
- };
25005
-
25006
- /**
25007
- * Parse the given `str` and return milliseconds.
25008
- *
25009
- * @param {String} str
25010
- * @return {Number}
25011
- * @api private
25012
- */
25013
-
25014
- function parse(str) {
25015
- str = String(str);
25016
- if (str.length > 100) {
25017
- return;
25018
- }
25019
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
25020
- str
25021
- );
25022
- if (!match) {
25023
- return;
25024
- }
25025
- var n = parseFloat(match[1]);
25026
- var type = (match[2] || 'ms').toLowerCase();
25027
- switch (type) {
25028
- case 'years':
25029
- case 'year':
25030
- case 'yrs':
25031
- case 'yr':
25032
- case 'y':
25033
- return n * y;
25034
- case 'weeks':
25035
- case 'week':
25036
- case 'w':
25037
- return n * w;
25038
- case 'days':
25039
- case 'day':
25040
- case 'd':
25041
- return n * d;
25042
- case 'hours':
25043
- case 'hour':
25044
- case 'hrs':
25045
- case 'hr':
25046
- case 'h':
25047
- return n * h;
25048
- case 'minutes':
25049
- case 'minute':
25050
- case 'mins':
25051
- case 'min':
25052
- case 'm':
25053
- return n * m;
25054
- case 'seconds':
25055
- case 'second':
25056
- case 'secs':
25057
- case 'sec':
25058
- case 's':
25059
- return n * s;
25060
- case 'milliseconds':
25061
- case 'millisecond':
25062
- case 'msecs':
25063
- case 'msec':
25064
- case 'ms':
25065
- return n;
25066
- default:
25067
- return undefined;
25068
- }
25069
- }
25070
-
25071
- /**
25072
- * Short format for `ms`.
25073
- *
25074
- * @param {Number} ms
25075
- * @return {String}
25076
- * @api private
25077
- */
25078
-
25079
- function fmtShort(ms) {
25080
- var msAbs = Math.abs(ms);
25081
- if (msAbs >= d) {
25082
- return Math.round(ms / d) + 'd';
25083
- }
25084
- if (msAbs >= h) {
25085
- return Math.round(ms / h) + 'h';
25086
- }
25087
- if (msAbs >= m) {
25088
- return Math.round(ms / m) + 'm';
25089
- }
25090
- if (msAbs >= s) {
25091
- return Math.round(ms / s) + 's';
25092
- }
25093
- return ms + 'ms';
25094
- }
25095
-
25096
- /**
25097
- * Long format for `ms`.
25098
- *
25099
- * @param {Number} ms
25100
- * @return {String}
25101
- * @api private
25102
- */
25103
-
25104
- function fmtLong(ms) {
25105
- var msAbs = Math.abs(ms);
25106
- if (msAbs >= d) {
25107
- return plural(ms, msAbs, d, 'day');
25108
- }
25109
- if (msAbs >= h) {
25110
- return plural(ms, msAbs, h, 'hour');
25111
- }
25112
- if (msAbs >= m) {
25113
- return plural(ms, msAbs, m, 'minute');
25114
- }
25115
- if (msAbs >= s) {
25116
- return plural(ms, msAbs, s, 'second');
25117
- }
25118
- return ms + ' ms';
25119
- }
25120
-
25121
- /**
25122
- * Pluralization helper.
25123
- */
25124
-
25125
- function plural(ms, msAbs, n, name) {
25126
- var isPlural = msAbs >= n * 1.5;
25127
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
25128
- }
25129
-
25130
- /**
25131
- * This is the common logic for both the Node.js and web browser
25132
- * implementations of `debug()`.
25133
- */
25134
-
25135
- function setup(env) {
25136
- createDebug.debug = createDebug;
25137
- createDebug.default = createDebug;
25138
- createDebug.coerce = coerce;
25139
- createDebug.disable = disable;
25140
- createDebug.enable = enable;
25141
- createDebug.enabled = enabled;
25142
- createDebug.humanize = ms;
25143
- createDebug.destroy = destroy;
25144
-
25145
- Object.keys(env).forEach(key => {
25146
- createDebug[key] = env[key];
25147
- });
25148
-
25149
- /**
25150
- * The currently active debug mode names, and names to skip.
25151
- */
25152
-
25153
- createDebug.names = [];
25154
- createDebug.skips = [];
25155
-
25156
- /**
25157
- * Map of special "%n" handling functions, for the debug "format" argument.
25158
- *
25159
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
25160
- */
25161
- createDebug.formatters = {};
25162
-
25163
- /**
25164
- * Selects a color for a debug namespace
25165
- * @param {String} namespace The namespace string for the debug instance to be colored
25166
- * @return {Number|String} An ANSI color code for the given namespace
25167
- * @api private
25168
- */
25169
- function selectColor(namespace) {
25170
- let hash = 0;
25171
-
25172
- for (let i = 0; i < namespace.length; i++) {
25173
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
25174
- hash |= 0; // Convert to 32bit integer
25175
- }
25176
-
25177
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
25178
- }
25179
- createDebug.selectColor = selectColor;
25180
-
25181
- /**
25182
- * Create a debugger with the given `namespace`.
25183
- *
25184
- * @param {String} namespace
25185
- * @return {Function}
25186
- * @api public
25187
- */
25188
- function createDebug(namespace) {
25189
- let prevTime;
25190
- let enableOverride = null;
25191
- let namespacesCache;
25192
- let enabledCache;
25193
-
25194
- function debug(...args) {
25195
- // Disabled?
25196
- if (!debug.enabled) {
25197
- return;
25198
- }
25199
-
25200
- const self = debug;
25201
-
25202
- // Set `diff` timestamp
25203
- const curr = Number(new Date());
25204
- const ms = curr - (prevTime || curr);
25205
- self.diff = ms;
25206
- self.prev = prevTime;
25207
- self.curr = curr;
25208
- prevTime = curr;
25209
-
25210
- args[0] = createDebug.coerce(args[0]);
25211
-
25212
- if (typeof args[0] !== 'string') {
25213
- // Anything else let's inspect with %O
25214
- args.unshift('%O');
25215
- }
25216
-
25217
- // Apply any `formatters` transformations
25218
- let index = 0;
25219
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
25220
- // If we encounter an escaped % then don't increase the array index
25221
- if (match === '%%') {
25222
- return '%';
25223
- }
25224
- index++;
25225
- const formatter = createDebug.formatters[format];
25226
- if (typeof formatter === 'function') {
25227
- const val = args[index];
25228
- match = formatter.call(self, val);
25229
-
25230
- // Now we need to remove `args[index]` since it's inlined in the `format`
25231
- args.splice(index, 1);
25232
- index--;
25233
- }
25234
- return match;
25235
- });
25236
-
25237
- // Apply env-specific formatting (colors, etc.)
25238
- createDebug.formatArgs.call(self, args);
25239
-
25240
- const logFn = self.log || createDebug.log;
25241
- logFn.apply(self, args);
25242
- }
25243
-
25244
- debug.namespace = namespace;
25245
- debug.useColors = createDebug.useColors();
25246
- debug.color = createDebug.selectColor(namespace);
25247
- debug.extend = extend;
25248
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
25249
-
25250
- Object.defineProperty(debug, 'enabled', {
25251
- enumerable: true,
25252
- configurable: false,
25253
- get: () => {
25254
- if (enableOverride !== null) {
25255
- return enableOverride;
25256
- }
25257
- if (namespacesCache !== createDebug.namespaces) {
25258
- namespacesCache = createDebug.namespaces;
25259
- enabledCache = createDebug.enabled(namespace);
25260
- }
25261
-
25262
- return enabledCache;
25263
- },
25264
- set: v => {
25265
- enableOverride = v;
25266
- }
25267
- });
25268
-
25269
- // Env-specific initialization logic for debug instances
25270
- if (typeof createDebug.init === 'function') {
25271
- createDebug.init(debug);
25272
- }
25273
-
25274
- return debug;
25275
- }
25276
-
25277
- function extend(namespace, delimiter) {
25278
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
25279
- newDebug.log = this.log;
25280
- return newDebug;
25281
- }
25282
-
25283
- /**
25284
- * Enables a debug mode by namespaces. This can include modes
25285
- * separated by a colon and wildcards.
25286
- *
25287
- * @param {String} namespaces
25288
- * @api public
25289
- */
25290
- function enable(namespaces) {
25291
- createDebug.save(namespaces);
25292
- createDebug.namespaces = namespaces;
25293
-
25294
- createDebug.names = [];
25295
- createDebug.skips = [];
25296
-
25297
- let i;
25298
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
25299
- const len = split.length;
25300
-
25301
- for (i = 0; i < len; i++) {
25302
- if (!split[i]) {
25303
- // ignore empty strings
25304
- continue;
25305
- }
25306
-
25307
- namespaces = split[i].replace(/\*/g, '.*?');
25308
-
25309
- if (namespaces[0] === '-') {
25310
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
25311
- } else {
25312
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
25313
- }
25314
- }
25315
- }
25316
-
25317
- /**
25318
- * Disable debug output.
25319
- *
25320
- * @return {String} namespaces
25321
- * @api public
25322
- */
25323
- function disable() {
25324
- const namespaces = [
25325
- ...createDebug.names.map(toNamespace),
25326
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
25327
- ].join(',');
25328
- createDebug.enable('');
25329
- return namespaces;
25330
- }
25331
-
25332
- /**
25333
- * Returns true if the given mode name is enabled, false otherwise.
25334
- *
25335
- * @param {String} name
25336
- * @return {Boolean}
25337
- * @api public
25338
- */
25339
- function enabled(name) {
25340
- if (name[name.length - 1] === '*') {
25341
- return true;
25342
- }
25343
-
25344
- let i;
25345
- let len;
25346
-
25347
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
25348
- if (createDebug.skips[i].test(name)) {
25349
- return false;
25350
- }
25351
- }
25352
-
25353
- for (i = 0, len = createDebug.names.length; i < len; i++) {
25354
- if (createDebug.names[i].test(name)) {
25355
- return true;
25356
- }
25357
- }
25358
-
25359
- return false;
25360
- }
25361
-
25362
- /**
25363
- * Convert regexp to namespace
25364
- *
25365
- * @param {RegExp} regxep
25366
- * @return {String} namespace
25367
- * @api private
25368
- */
25369
- function toNamespace(regexp) {
25370
- return regexp.toString()
25371
- .substring(2, regexp.toString().length - 2)
25372
- .replace(/\.\*\?$/, '*');
25373
- }
25374
-
25375
- /**
25376
- * Coerce `val`.
25377
- *
25378
- * @param {Mixed} val
25379
- * @return {Mixed}
25380
- * @api private
25381
- */
25382
- function coerce(val) {
25383
- if (val instanceof Error) {
25384
- return val.stack || val.message;
25385
- }
25386
- return val;
25387
- }
25388
-
25389
- /**
25390
- * XXX DO NOT USE. This is a temporary stub function.
25391
- * XXX It WILL be removed in the next major release.
25392
- */
25393
- function destroy() {
25394
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
25395
- }
25396
-
25397
- createDebug.enable(createDebug.load());
25398
-
25399
- return createDebug;
25400
- }
25401
-
25402
- var common = setup;
25403
-
25404
- var browser$1 = createCommonjsModule(function (module, exports) {
25405
- /* eslint-env browser */
25406
-
25407
- /**
25408
- * This is the web browser implementation of `debug()`.
25409
- */
25410
-
25411
- exports.formatArgs = formatArgs;
25412
- exports.save = save;
25413
- exports.load = load;
25414
- exports.useColors = useColors;
25415
- exports.storage = localstorage();
25416
- exports.destroy = (() => {
25417
- let warned = false;
25418
-
25419
- return () => {
25420
- if (!warned) {
25421
- warned = true;
25422
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
25423
- }
25424
- };
25425
- })();
25426
-
25427
- /**
25428
- * Colors.
25429
- */
25430
-
25431
- exports.colors = [
25432
- '#0000CC',
25433
- '#0000FF',
25434
- '#0033CC',
25435
- '#0033FF',
25436
- '#0066CC',
25437
- '#0066FF',
25438
- '#0099CC',
25439
- '#0099FF',
25440
- '#00CC00',
25441
- '#00CC33',
25442
- '#00CC66',
25443
- '#00CC99',
25444
- '#00CCCC',
25445
- '#00CCFF',
25446
- '#3300CC',
25447
- '#3300FF',
25448
- '#3333CC',
25449
- '#3333FF',
25450
- '#3366CC',
25451
- '#3366FF',
25452
- '#3399CC',
25453
- '#3399FF',
25454
- '#33CC00',
25455
- '#33CC33',
25456
- '#33CC66',
25457
- '#33CC99',
25458
- '#33CCCC',
25459
- '#33CCFF',
25460
- '#6600CC',
25461
- '#6600FF',
25462
- '#6633CC',
25463
- '#6633FF',
25464
- '#66CC00',
25465
- '#66CC33',
25466
- '#9900CC',
25467
- '#9900FF',
25468
- '#9933CC',
25469
- '#9933FF',
25470
- '#99CC00',
25471
- '#99CC33',
25472
- '#CC0000',
25473
- '#CC0033',
25474
- '#CC0066',
25475
- '#CC0099',
25476
- '#CC00CC',
25477
- '#CC00FF',
25478
- '#CC3300',
25479
- '#CC3333',
25480
- '#CC3366',
25481
- '#CC3399',
25482
- '#CC33CC',
25483
- '#CC33FF',
25484
- '#CC6600',
25485
- '#CC6633',
25486
- '#CC9900',
25487
- '#CC9933',
25488
- '#CCCC00',
25489
- '#CCCC33',
25490
- '#FF0000',
25491
- '#FF0033',
25492
- '#FF0066',
25493
- '#FF0099',
25494
- '#FF00CC',
25495
- '#FF00FF',
25496
- '#FF3300',
25497
- '#FF3333',
25498
- '#FF3366',
25499
- '#FF3399',
25500
- '#FF33CC',
25501
- '#FF33FF',
25502
- '#FF6600',
25503
- '#FF6633',
25504
- '#FF9900',
25505
- '#FF9933',
25506
- '#FFCC00',
25507
- '#FFCC33'
25508
- ];
25509
-
25510
- /**
25511
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
25512
- * and the Firebug extension (any Firefox version) are known
25513
- * to support "%c" CSS customizations.
25514
- *
25515
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
25516
- */
25517
-
25518
- // eslint-disable-next-line complexity
25519
- function useColors() {
25520
- // NB: In an Electron preload script, document will be defined but not fully
25521
- // initialized. Since we know we're in Chrome, we'll just detect this case
25522
- // explicitly
25523
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
25524
- return true;
25525
- }
25526
-
25527
- // Internet Explorer and Edge do not support colors.
25528
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
25529
- return false;
25530
- }
25531
-
25532
- // Is webkit? http://stackoverflow.com/a/16459606/376773
25533
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
25534
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
25535
- // Is firebug? http://stackoverflow.com/a/398120/376773
25536
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
25537
- // Is firefox >= v31?
25538
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
25539
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
25540
- // Double check webkit in userAgent just in case we are in a worker
25541
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
25542
- }
25543
-
25544
- /**
25545
- * Colorize log arguments if enabled.
25546
- *
25547
- * @api public
25548
- */
25549
-
25550
- function formatArgs(args) {
25551
- args[0] = (this.useColors ? '%c' : '') +
25552
- this.namespace +
25553
- (this.useColors ? ' %c' : ' ') +
25554
- args[0] +
25555
- (this.useColors ? '%c ' : ' ') +
25556
- '+' + module.exports.humanize(this.diff);
25557
-
25558
- if (!this.useColors) {
25559
- return;
25560
- }
25561
-
25562
- const c = 'color: ' + this.color;
25563
- args.splice(1, 0, c, 'color: inherit');
25564
-
25565
- // The final "%c" is somewhat tricky, because there could be other
25566
- // arguments passed either before or after the %c, so we need to
25567
- // figure out the correct index to insert the CSS into
25568
- let index = 0;
25569
- let lastC = 0;
25570
- args[0].replace(/%[a-zA-Z%]/g, match => {
25571
- if (match === '%%') {
25572
- return;
25573
- }
25574
- index++;
25575
- if (match === '%c') {
25576
- // We only are interested in the *last* %c
25577
- // (the user may have provided their own)
25578
- lastC = index;
25579
- }
25580
- });
25581
-
25582
- args.splice(lastC, 0, c);
25583
- }
25584
-
25585
- /**
25586
- * Invokes `console.debug()` when available.
25587
- * No-op when `console.debug` is not a "function".
25588
- * If `console.debug` is not available, falls back
25589
- * to `console.log`.
25590
- *
25591
- * @api public
25592
- */
25593
- exports.log = console.debug || console.log || (() => {});
25594
-
25595
- /**
25596
- * Save `namespaces`.
25597
- *
25598
- * @param {String} namespaces
25599
- * @api private
25600
- */
25601
- function save(namespaces) {
25602
- try {
25603
- if (namespaces) {
25604
- exports.storage.setItem('debug', namespaces);
25605
- } else {
25606
- exports.storage.removeItem('debug');
25607
- }
25608
- } catch (error) {
25609
- // Swallow
25610
- // XXX (@Qix-) should we be logging these?
25611
- }
25612
- }
25613
-
25614
- /**
25615
- * Load `namespaces`.
25616
- *
25617
- * @return {String} returns the previously persisted debug modes
25618
- * @api private
25619
- */
25620
- function load() {
25621
- let r;
25622
- try {
25623
- r = exports.storage.getItem('debug');
25624
- } catch (error) {
25625
- // Swallow
25626
- // XXX (@Qix-) should we be logging these?
25627
- }
25628
-
25629
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
25630
- if (!r && typeof process !== 'undefined' && 'env' in process) {
25631
- r = process.env.DEBUG;
25632
- }
25633
-
25634
- return r;
25635
- }
25636
-
25637
- /**
25638
- * Localstorage attempts to return the localstorage.
25639
- *
25640
- * This is necessary because safari throws
25641
- * when a user disables cookies/localstorage
25642
- * and you attempt to access it.
25643
- *
25644
- * @return {LocalStorage}
25645
- * @api private
25646
- */
25647
-
25648
- function localstorage() {
25649
- try {
25650
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
25651
- // The Browser also has localStorage in the global context.
25652
- return localStorage;
25653
- } catch (error) {
25654
- // Swallow
25655
- // XXX (@Qix-) should we be logging these?
25656
- }
25657
- }
25658
-
25659
- module.exports = common(exports);
25660
-
25661
- const {formatters} = module.exports;
25662
-
25663
- /**
25664
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
25665
- */
25666
-
25667
- formatters.j = function (v) {
25668
- try {
25669
- return JSON.stringify(v);
25670
- } catch (error) {
25671
- return '[UnexpectedJSONParseError]: ' + error.message;
25672
- }
25673
- };
25674
- });
25675
-
25676
- var hasFlag = (flag, argv = process.argv) => {
25677
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
25678
- const position = argv.indexOf(prefix + flag);
25679
- const terminatorPosition = argv.indexOf('--');
25680
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
25681
- };
25682
-
25683
- const {env} = process;
25684
-
25685
- let forceColor;
25686
- if (hasFlag('no-color') ||
25687
- hasFlag('no-colors') ||
25688
- hasFlag('color=false') ||
25689
- hasFlag('color=never')) {
25690
- forceColor = 0;
25691
- } else if (hasFlag('color') ||
25692
- hasFlag('colors') ||
25693
- hasFlag('color=true') ||
25694
- hasFlag('color=always')) {
25695
- forceColor = 1;
25696
- }
25697
-
25698
- if ('FORCE_COLOR' in env) {
25699
- if (env.FORCE_COLOR === 'true') {
25700
- forceColor = 1;
25701
- } else if (env.FORCE_COLOR === 'false') {
25702
- forceColor = 0;
25703
- } else {
25704
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
25705
- }
25706
- }
25707
-
25708
- function translateLevel(level) {
25709
- if (level === 0) {
25710
- return false;
25711
- }
25712
-
25713
- return {
25714
- level,
25715
- hasBasic: true,
25716
- has256: level >= 2,
25717
- has16m: level >= 3
25718
- };
25719
- }
25720
-
25721
- function supportsColor(haveStream, streamIsTTY) {
25722
- if (forceColor === 0) {
25723
- return 0;
25724
- }
25725
-
25726
- if (hasFlag('color=16m') ||
25727
- hasFlag('color=full') ||
25728
- hasFlag('color=truecolor')) {
25729
- return 3;
25730
- }
25731
-
25732
- if (hasFlag('color=256')) {
25733
- return 2;
25734
- }
25735
-
25736
- if (haveStream && !streamIsTTY && forceColor === undefined) {
25737
- return 0;
25738
- }
25739
-
25740
- const min = forceColor || 0;
25741
-
25742
- if (env.TERM === 'dumb') {
25743
- return min;
25744
- }
25745
-
25746
- if (process.platform === 'win32') {
25747
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
25748
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
25749
- const osRelease = os.release().split('.');
25750
- if (
25751
- Number(osRelease[0]) >= 10 &&
25752
- Number(osRelease[2]) >= 10586
25753
- ) {
25754
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
25755
- }
25756
-
25757
- return 1;
25758
- }
25759
-
25760
- if ('CI' in env) {
25761
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
25762
- return 1;
25763
- }
25764
-
25765
- return min;
25766
- }
25767
-
25768
- if ('TEAMCITY_VERSION' in env) {
25769
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
25770
- }
25771
-
25772
- if (env.COLORTERM === 'truecolor') {
25773
- return 3;
25774
- }
25775
-
25776
- if ('TERM_PROGRAM' in env) {
25777
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
25778
-
25779
- switch (env.TERM_PROGRAM) {
25780
- case 'iTerm.app':
25781
- return version >= 3 ? 3 : 2;
25782
- case 'Apple_Terminal':
25783
- return 2;
25784
- // No default
25785
- }
25786
- }
25787
-
25788
- if (/-256(color)?$/i.test(env.TERM)) {
25789
- return 2;
25790
- }
25791
-
25792
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
25793
- return 1;
25794
- }
25795
-
25796
- if ('COLORTERM' in env) {
25797
- return 1;
25798
- }
25799
-
25800
- return min;
25801
- }
25802
-
25803
- function getSupportLevel(stream) {
25804
- const level = supportsColor(stream, stream && stream.isTTY);
25805
- return translateLevel(level);
25806
- }
25807
-
25808
- var supportsColor_1 = {
25809
- supportsColor: getSupportLevel,
25810
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
25811
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
25812
- };
25813
-
25814
- var node = createCommonjsModule(function (module, exports) {
25815
- /**
25816
- * Module dependencies.
25817
- */
25818
-
25819
-
25820
-
25821
-
25822
- /**
25823
- * This is the Node.js implementation of `debug()`.
25824
- */
25825
-
25826
- exports.init = init;
25827
- exports.log = log;
25828
- exports.formatArgs = formatArgs;
25829
- exports.save = save;
25830
- exports.load = load;
25831
- exports.useColors = useColors;
25832
- exports.destroy = util.deprecate(
25833
- () => {},
25834
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
25835
- );
25836
-
25837
- /**
25838
- * Colors.
25839
- */
25840
-
25841
- exports.colors = [6, 2, 3, 4, 5, 1];
25842
-
25843
- try {
25844
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
25845
- // eslint-disable-next-line import/no-extraneous-dependencies
25846
- const supportsColor = supportsColor_1;
25847
-
25848
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
25849
- exports.colors = [
25850
- 20,
25851
- 21,
25852
- 26,
25853
- 27,
25854
- 32,
25855
- 33,
25856
- 38,
25857
- 39,
25858
- 40,
25859
- 41,
25860
- 42,
25861
- 43,
25862
- 44,
25863
- 45,
25864
- 56,
25865
- 57,
25866
- 62,
25867
- 63,
25868
- 68,
25869
- 69,
25870
- 74,
25871
- 75,
25872
- 76,
25873
- 77,
25874
- 78,
25875
- 79,
25876
- 80,
25877
- 81,
25878
- 92,
25879
- 93,
25880
- 98,
25881
- 99,
25882
- 112,
25883
- 113,
25884
- 128,
25885
- 129,
25886
- 134,
25887
- 135,
25888
- 148,
25889
- 149,
25890
- 160,
25891
- 161,
25892
- 162,
25893
- 163,
25894
- 164,
25895
- 165,
25896
- 166,
25897
- 167,
25898
- 168,
25899
- 169,
25900
- 170,
25901
- 171,
25902
- 172,
25903
- 173,
25904
- 178,
25905
- 179,
25906
- 184,
25907
- 185,
25908
- 196,
25909
- 197,
25910
- 198,
25911
- 199,
25912
- 200,
25913
- 201,
25914
- 202,
25915
- 203,
25916
- 204,
25917
- 205,
25918
- 206,
25919
- 207,
25920
- 208,
25921
- 209,
25922
- 214,
25923
- 215,
25924
- 220,
25925
- 221
25926
- ];
25927
- }
25928
- } catch (error) {
25929
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
25930
- }
25931
-
25932
- /**
25933
- * Build up the default `inspectOpts` object from the environment variables.
25934
- *
25935
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
25936
- */
25937
-
25938
- exports.inspectOpts = Object.keys(process.env).filter(key => {
25939
- return /^debug_/i.test(key);
25940
- }).reduce((obj, key) => {
25941
- // Camel-case
25942
- const prop = key
25943
- .substring(6)
25944
- .toLowerCase()
25945
- .replace(/_([a-z])/g, (_, k) => {
25946
- return k.toUpperCase();
25947
- });
25948
-
25949
- // Coerce string value into JS value
25950
- let val = process.env[key];
25951
- if (/^(yes|on|true|enabled)$/i.test(val)) {
25952
- val = true;
25953
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
25954
- val = false;
25955
- } else if (val === 'null') {
25956
- val = null;
25957
- } else {
25958
- val = Number(val);
25959
- }
25960
-
25961
- obj[prop] = val;
25962
- return obj;
25963
- }, {});
25964
-
25965
- /**
25966
- * Is stdout a TTY? Colored output is enabled when `true`.
25967
- */
25968
-
25969
- function useColors() {
25970
- return 'colors' in exports.inspectOpts ?
25971
- Boolean(exports.inspectOpts.colors) :
25972
- tty.isatty(process.stderr.fd);
25973
- }
25974
-
25975
- /**
25976
- * Adds ANSI color escape codes if enabled.
25977
- *
25978
- * @api public
25979
- */
25980
-
25981
- function formatArgs(args) {
25982
- const {namespace: name, useColors} = this;
25983
-
25984
- if (useColors) {
25985
- const c = this.color;
25986
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
25987
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
25988
-
25989
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
25990
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
25991
- } else {
25992
- args[0] = getDate() + name + ' ' + args[0];
25993
- }
25994
- }
25995
-
25996
- function getDate() {
25997
- if (exports.inspectOpts.hideDate) {
25998
- return '';
25999
- }
26000
- return new Date().toISOString() + ' ';
26001
- }
26002
-
26003
- /**
26004
- * Invokes `util.format()` with the specified arguments and writes to stderr.
26005
- */
26006
-
26007
- function log(...args) {
26008
- return process.stderr.write(util.format(...args) + '\n');
26009
- }
26010
-
26011
- /**
26012
- * Save `namespaces`.
26013
- *
26014
- * @param {String} namespaces
26015
- * @api private
26016
- */
26017
- function save(namespaces) {
26018
- if (namespaces) {
26019
- process.env.DEBUG = namespaces;
26020
- } else {
26021
- // If you set a process.env field to null or undefined, it gets cast to the
26022
- // string 'null' or 'undefined'. Just delete instead.
26023
- delete process.env.DEBUG;
26024
- }
26025
- }
26026
-
26027
- /**
26028
- * Load `namespaces`.
26029
- *
26030
- * @return {String} returns the previously persisted debug modes
26031
- * @api private
26032
- */
26033
-
26034
- function load() {
26035
- return process.env.DEBUG;
26036
- }
26037
-
26038
- /**
26039
- * Init logic for `debug` instances.
26040
- *
26041
- * Create a new `inspectOpts` object in case `useColors` is set
26042
- * differently for a particular `debug` instance.
26043
- */
26044
-
26045
- function init(debug) {
26046
- debug.inspectOpts = {};
26047
-
26048
- const keys = Object.keys(exports.inspectOpts);
26049
- for (let i = 0; i < keys.length; i++) {
26050
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
26051
- }
26052
- }
26053
-
26054
- module.exports = common(exports);
26055
-
26056
- const {formatters} = module.exports;
26057
-
26058
- /**
26059
- * Map %o to `util.inspect()`, all on a single line.
26060
- */
26061
-
26062
- formatters.o = function (v) {
26063
- this.inspectOpts.colors = this.useColors;
26064
- return util.inspect(v, this.inspectOpts)
26065
- .split('\n')
26066
- .map(str => str.trim())
26067
- .join(' ');
26068
- };
26069
-
26070
- /**
26071
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
26072
- */
26073
-
26074
- formatters.O = function (v) {
26075
- this.inspectOpts.colors = this.useColors;
26076
- return util.inspect(v, this.inspectOpts);
26077
- };
26078
- });
26079
-
26080
- var src = createCommonjsModule(function (module) {
26081
- /**
26082
- * Detect Electron renderer / nwjs process, which is node, but we should
26083
- * treat as a browser.
26084
- */
26085
-
26086
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
26087
- module.exports = browser$1;
26088
- } else {
26089
- module.exports = node;
26090
- }
26091
- });
26092
-
26093
- var debug;
26094
-
26095
- var debug_1 = function () {
26096
- if (!debug) {
26097
- try {
26098
- /* eslint global-require: off */
26099
- debug = src("follow-redirects");
26100
- }
26101
- catch (error) { /* */ }
26102
- if (typeof debug !== "function") {
26103
- debug = function () { /* */ };
26104
- }
26105
- }
26106
- debug.apply(null, arguments);
26107
- };
26108
-
26109
- var URL$1 = url.URL;
26110
-
26111
-
26112
- var Writable = require$$0.Writable;
26113
-
26114
-
26115
-
26116
- // Whether to use the native URL object or the legacy url module
26117
- var useNativeURL = false;
26118
- try {
26119
- assert(new URL$1());
26120
- }
26121
- catch (error) {
26122
- useNativeURL = error.code === "ERR_INVALID_URL";
26123
- }
26124
-
26125
- // URL fields to preserve in copy operations
26126
- var preservedUrlFields = [
26127
- "auth",
26128
- "host",
26129
- "hostname",
26130
- "href",
26131
- "path",
26132
- "pathname",
26133
- "port",
26134
- "protocol",
26135
- "query",
26136
- "search",
26137
- "hash",
26138
- ];
26139
-
26140
- // Create handlers that pass events from native requests
26141
- var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
26142
- var eventHandlers = Object.create(null);
26143
- events.forEach(function (event) {
26144
- eventHandlers[event] = function (arg1, arg2, arg3) {
26145
- this._redirectable.emit(event, arg1, arg2, arg3);
26146
- };
26147
- });
26148
-
26149
- // Error types with codes
26150
- var InvalidUrlError = createErrorType(
26151
- "ERR_INVALID_URL",
26152
- "Invalid URL",
26153
- TypeError
26154
- );
26155
- var RedirectionError = createErrorType(
26156
- "ERR_FR_REDIRECTION_FAILURE",
26157
- "Redirected request failed"
26158
- );
26159
- var TooManyRedirectsError = createErrorType(
26160
- "ERR_FR_TOO_MANY_REDIRECTS",
26161
- "Maximum number of redirects exceeded",
26162
- RedirectionError
26163
- );
26164
- var MaxBodyLengthExceededError = createErrorType(
26165
- "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
26166
- "Request body larger than maxBodyLength limit"
26167
- );
26168
- var WriteAfterEndError = createErrorType(
26169
- "ERR_STREAM_WRITE_AFTER_END",
26170
- "write after end"
26171
- );
26172
-
26173
- // istanbul ignore next
26174
- var destroy = Writable.prototype.destroy || noop;
26175
-
26176
- // An HTTP(S) request that can be redirected
26177
- function RedirectableRequest(options, responseCallback) {
26178
- // Initialize the request
26179
- Writable.call(this);
26180
- this._sanitizeOptions(options);
26181
- this._options = options;
26182
- this._ended = false;
26183
- this._ending = false;
26184
- this._redirectCount = 0;
26185
- this._redirects = [];
26186
- this._requestBodyLength = 0;
26187
- this._requestBodyBuffers = [];
26188
-
26189
- // Attach a callback if passed
26190
- if (responseCallback) {
26191
- this.on("response", responseCallback);
26192
- }
26193
-
26194
- // React to responses of native requests
26195
- var self = this;
26196
- this._onNativeResponse = function (response) {
26197
- try {
26198
- self._processResponse(response);
26199
- }
26200
- catch (cause) {
26201
- self.emit("error", cause instanceof RedirectionError ?
26202
- cause : new RedirectionError({ cause: cause }));
26203
- }
26204
- };
26205
-
26206
- // Perform the first request
26207
- this._performRequest();
26208
- }
26209
- RedirectableRequest.prototype = Object.create(Writable.prototype);
26210
-
26211
- RedirectableRequest.prototype.abort = function () {
26212
- destroyRequest(this._currentRequest);
26213
- this._currentRequest.abort();
26214
- this.emit("abort");
26215
- };
26216
-
26217
- RedirectableRequest.prototype.destroy = function (error) {
26218
- destroyRequest(this._currentRequest, error);
26219
- destroy.call(this, error);
26220
- return this;
26221
- };
26222
-
26223
- // Writes buffered data to the current native request
26224
- RedirectableRequest.prototype.write = function (data, encoding, callback) {
26225
- // Writing is not allowed if end has been called
26226
- if (this._ending) {
26227
- throw new WriteAfterEndError();
26228
- }
26229
-
26230
- // Validate input and shift parameters if necessary
26231
- if (!isString(data) && !isBuffer(data)) {
26232
- throw new TypeError("data should be a string, Buffer or Uint8Array");
26233
- }
26234
- if (isFunction(encoding)) {
26235
- callback = encoding;
26236
- encoding = null;
26237
- }
26238
-
26239
- // Ignore empty buffers, since writing them doesn't invoke the callback
26240
- // https://github.com/nodejs/node/issues/22066
26241
- if (data.length === 0) {
26242
- if (callback) {
26243
- callback();
26244
- }
26245
- return;
26246
- }
26247
- // Only write when we don't exceed the maximum body length
26248
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
26249
- this._requestBodyLength += data.length;
26250
- this._requestBodyBuffers.push({ data: data, encoding: encoding });
26251
- this._currentRequest.write(data, encoding, callback);
26252
- }
26253
- // Error when we exceed the maximum body length
26254
- else {
26255
- this.emit("error", new MaxBodyLengthExceededError());
26256
- this.abort();
26257
- }
26258
- };
26259
-
26260
- // Ends the current native request
26261
- RedirectableRequest.prototype.end = function (data, encoding, callback) {
26262
- // Shift parameters if necessary
26263
- if (isFunction(data)) {
26264
- callback = data;
26265
- data = encoding = null;
26266
- }
26267
- else if (isFunction(encoding)) {
26268
- callback = encoding;
26269
- encoding = null;
26270
- }
26271
-
26272
- // Write data if needed and end
26273
- if (!data) {
26274
- this._ended = this._ending = true;
26275
- this._currentRequest.end(null, null, callback);
26276
- }
26277
- else {
26278
- var self = this;
26279
- var currentRequest = this._currentRequest;
26280
- this.write(data, encoding, function () {
26281
- self._ended = true;
26282
- currentRequest.end(null, null, callback);
26283
- });
26284
- this._ending = true;
26285
- }
26286
- };
26287
-
26288
- // Sets a header value on the current native request
26289
- RedirectableRequest.prototype.setHeader = function (name, value) {
26290
- this._options.headers[name] = value;
26291
- this._currentRequest.setHeader(name, value);
26292
- };
26293
-
26294
- // Clears a header value on the current native request
26295
- RedirectableRequest.prototype.removeHeader = function (name) {
26296
- delete this._options.headers[name];
26297
- this._currentRequest.removeHeader(name);
26298
- };
26299
-
26300
- // Global timeout for all underlying requests
26301
- RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
26302
- var self = this;
26303
-
26304
- // Destroys the socket on timeout
26305
- function destroyOnTimeout(socket) {
26306
- socket.setTimeout(msecs);
26307
- socket.removeListener("timeout", socket.destroy);
26308
- socket.addListener("timeout", socket.destroy);
26309
- }
26310
-
26311
- // Sets up a timer to trigger a timeout event
26312
- function startTimer(socket) {
26313
- if (self._timeout) {
26314
- clearTimeout(self._timeout);
26315
- }
26316
- self._timeout = setTimeout(function () {
26317
- self.emit("timeout");
26318
- clearTimer();
26319
- }, msecs);
26320
- destroyOnTimeout(socket);
26321
- }
26322
-
26323
- // Stops a timeout from triggering
26324
- function clearTimer() {
26325
- // Clear the timeout
26326
- if (self._timeout) {
26327
- clearTimeout(self._timeout);
26328
- self._timeout = null;
26329
- }
26330
-
26331
- // Clean up all attached listeners
26332
- self.removeListener("abort", clearTimer);
26333
- self.removeListener("error", clearTimer);
26334
- self.removeListener("response", clearTimer);
26335
- self.removeListener("close", clearTimer);
26336
- if (callback) {
26337
- self.removeListener("timeout", callback);
26338
- }
26339
- if (!self.socket) {
26340
- self._currentRequest.removeListener("socket", startTimer);
26341
- }
26342
- }
26343
-
26344
- // Attach callback if passed
26345
- if (callback) {
26346
- this.on("timeout", callback);
26347
- }
26348
-
26349
- // Start the timer if or when the socket is opened
26350
- if (this.socket) {
26351
- startTimer(this.socket);
26352
- }
26353
- else {
26354
- this._currentRequest.once("socket", startTimer);
26355
- }
26356
-
26357
- // Clean up on events
26358
- this.on("socket", destroyOnTimeout);
26359
- this.on("abort", clearTimer);
26360
- this.on("error", clearTimer);
26361
- this.on("response", clearTimer);
26362
- this.on("close", clearTimer);
26363
-
26364
- return this;
26365
- };
26366
-
26367
- // Proxy all other public ClientRequest methods
26368
- [
26369
- "flushHeaders", "getHeader",
26370
- "setNoDelay", "setSocketKeepAlive",
26371
- ].forEach(function (method) {
26372
- RedirectableRequest.prototype[method] = function (a, b) {
26373
- return this._currentRequest[method](a, b);
26374
- };
26375
- });
26376
-
26377
- // Proxy all public ClientRequest properties
26378
- ["aborted", "connection", "socket"].forEach(function (property) {
26379
- Object.defineProperty(RedirectableRequest.prototype, property, {
26380
- get: function () { return this._currentRequest[property]; },
26381
- });
26382
- });
26383
-
26384
- RedirectableRequest.prototype._sanitizeOptions = function (options) {
26385
- // Ensure headers are always present
26386
- if (!options.headers) {
26387
- options.headers = {};
26388
- }
26389
-
26390
- // Since http.request treats host as an alias of hostname,
26391
- // but the url module interprets host as hostname plus port,
26392
- // eliminate the host property to avoid confusion.
26393
- if (options.host) {
26394
- // Use hostname if set, because it has precedence
26395
- if (!options.hostname) {
26396
- options.hostname = options.host;
26397
- }
26398
- delete options.host;
26399
- }
26400
-
26401
- // Complete the URL object when necessary
26402
- if (!options.pathname && options.path) {
26403
- var searchPos = options.path.indexOf("?");
26404
- if (searchPos < 0) {
26405
- options.pathname = options.path;
26406
- }
26407
- else {
26408
- options.pathname = options.path.substring(0, searchPos);
26409
- options.search = options.path.substring(searchPos);
26410
- }
26411
- }
26412
- };
26413
-
26414
-
26415
- // Executes the next native request (initial or redirect)
26416
- RedirectableRequest.prototype._performRequest = function () {
26417
- // Load the native protocol
26418
- var protocol = this._options.protocol;
26419
- var nativeProtocol = this._options.nativeProtocols[protocol];
26420
- if (!nativeProtocol) {
26421
- throw new TypeError("Unsupported protocol " + protocol);
26422
- }
26423
-
26424
- // If specified, use the agent corresponding to the protocol
26425
- // (HTTP and HTTPS use different types of agents)
26426
- if (this._options.agents) {
26427
- var scheme = protocol.slice(0, -1);
26428
- this._options.agent = this._options.agents[scheme];
26429
- }
26430
-
26431
- // Create the native request and set up its event handlers
26432
- var request = this._currentRequest =
26433
- nativeProtocol.request(this._options, this._onNativeResponse);
26434
- request._redirectable = this;
26435
- for (var event of events) {
26436
- request.on(event, eventHandlers[event]);
26437
- }
26438
-
26439
- // RFC7230§5.3.1: When making a request directly to an origin server, […]
26440
- // a client MUST send only the absolute path […] as the request-target.
26441
- this._currentUrl = /^\//.test(this._options.path) ?
26442
- url.format(this._options) :
26443
- // When making a request to a proxy, […]
26444
- // a client MUST send the target URI in absolute-form […].
26445
- this._options.path;
26446
-
26447
- // End a redirected request
26448
- // (The first request must be ended explicitly with RedirectableRequest#end)
26449
- if (this._isRedirect) {
26450
- // Write the request entity and end
26451
- var i = 0;
26452
- var self = this;
26453
- var buffers = this._requestBodyBuffers;
26454
- (function writeNext(error) {
26455
- // Only write if this request has not been redirected yet
26456
- /* istanbul ignore else */
26457
- if (request === self._currentRequest) {
26458
- // Report any write errors
26459
- /* istanbul ignore if */
26460
- if (error) {
26461
- self.emit("error", error);
26462
- }
26463
- // Write the next buffer if there are still left
26464
- else if (i < buffers.length) {
26465
- var buffer = buffers[i++];
26466
- /* istanbul ignore else */
26467
- if (!request.finished) {
26468
- request.write(buffer.data, buffer.encoding, writeNext);
26469
- }
26470
- }
26471
- // End the request if `end` has been called on us
26472
- else if (self._ended) {
26473
- request.end();
26474
- }
26475
- }
26476
- }());
26477
- }
26478
- };
26479
-
26480
- // Processes a response from the current native request
26481
- RedirectableRequest.prototype._processResponse = function (response) {
26482
- // Store the redirected response
26483
- var statusCode = response.statusCode;
26484
- if (this._options.trackRedirects) {
26485
- this._redirects.push({
26486
- url: this._currentUrl,
26487
- headers: response.headers,
26488
- statusCode: statusCode,
26489
- });
26490
- }
26491
-
26492
- // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
26493
- // that further action needs to be taken by the user agent in order to
26494
- // fulfill the request. If a Location header field is provided,
26495
- // the user agent MAY automatically redirect its request to the URI
26496
- // referenced by the Location field value,
26497
- // even if the specific status code is not understood.
26498
-
26499
- // If the response is not a redirect; return it as-is
26500
- var location = response.headers.location;
26501
- if (!location || this._options.followRedirects === false ||
26502
- statusCode < 300 || statusCode >= 400) {
26503
- response.responseUrl = this._currentUrl;
26504
- response.redirects = this._redirects;
26505
- this.emit("response", response);
26506
-
26507
- // Clean up
26508
- this._requestBodyBuffers = [];
26509
- return;
26510
- }
26511
-
26512
- // The response is a redirect, so abort the current request
26513
- destroyRequest(this._currentRequest);
26514
- // Discard the remainder of the response to avoid waiting for data
26515
- response.destroy();
26516
-
26517
- // RFC7231§6.4: A client SHOULD detect and intervene
26518
- // in cyclical redirections (i.e., "infinite" redirection loops).
26519
- if (++this._redirectCount > this._options.maxRedirects) {
26520
- throw new TooManyRedirectsError();
26521
- }
26522
-
26523
- // Store the request headers if applicable
26524
- var requestHeaders;
26525
- var beforeRedirect = this._options.beforeRedirect;
26526
- if (beforeRedirect) {
26527
- requestHeaders = Object.assign({
26528
- // The Host header was set by nativeProtocol.request
26529
- Host: response.req.getHeader("host"),
26530
- }, this._options.headers);
26531
- }
26532
-
26533
- // RFC7231§6.4: Automatic redirection needs to done with
26534
- // care for methods not known to be safe, […]
26535
- // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
26536
- // the request method from POST to GET for the subsequent request.
26537
- var method = this._options.method;
26538
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
26539
- // RFC7231§6.4.4: The 303 (See Other) status code indicates that
26540
- // the server is redirecting the user agent to a different resource […]
26541
- // A user agent can perform a retrieval request targeting that URI
26542
- // (a GET or HEAD request if using HTTP) […]
26543
- (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
26544
- this._options.method = "GET";
26545
- // Drop a possible entity and headers related to it
26546
- this._requestBodyBuffers = [];
26547
- removeMatchingHeaders(/^content-/i, this._options.headers);
26548
- }
26549
-
26550
- // Drop the Host header, as the redirect might lead to a different host
26551
- var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
26552
-
26553
- // If the redirect is relative, carry over the host of the last request
26554
- var currentUrlParts = parseUrl(this._currentUrl);
26555
- var currentHost = currentHostHeader || currentUrlParts.host;
26556
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
26557
- url.format(Object.assign(currentUrlParts, { host: currentHost }));
26558
-
26559
- // Create the redirected request
26560
- var redirectUrl = resolveUrl(location, currentUrl);
26561
- debug_1("redirecting to", redirectUrl.href);
26562
- this._isRedirect = true;
26563
- spreadUrlObject(redirectUrl, this._options);
26564
-
26565
- // Drop confidential headers when redirecting to a less secure protocol
26566
- // or to a different domain that is not a superdomain
26567
- if (redirectUrl.protocol !== currentUrlParts.protocol &&
26568
- redirectUrl.protocol !== "https:" ||
26569
- redirectUrl.host !== currentHost &&
26570
- !isSubdomain(redirectUrl.host, currentHost)) {
26571
- removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
26572
- }
26573
-
26574
- // Evaluate the beforeRedirect callback
26575
- if (isFunction(beforeRedirect)) {
26576
- var responseDetails = {
26577
- headers: response.headers,
26578
- statusCode: statusCode,
26579
- };
26580
- var requestDetails = {
26581
- url: currentUrl,
26582
- method: method,
26583
- headers: requestHeaders,
26584
- };
26585
- beforeRedirect(this._options, responseDetails, requestDetails);
26586
- this._sanitizeOptions(this._options);
26587
- }
26588
-
26589
- // Perform the redirected request
26590
- this._performRequest();
26591
- };
26592
-
26593
- // Wraps the key/value object of protocols with redirect functionality
26594
- function wrap(protocols) {
26595
- // Default settings
26596
- var exports = {
26597
- maxRedirects: 21,
26598
- maxBodyLength: 10 * 1024 * 1024,
26599
- };
26600
-
26601
- // Wrap each protocol
26602
- var nativeProtocols = {};
26603
- Object.keys(protocols).forEach(function (scheme) {
26604
- var protocol = scheme + ":";
26605
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
26606
- var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
26607
-
26608
- // Executes a request, following redirects
26609
- function request(input, options, callback) {
26610
- // Parse parameters, ensuring that input is an object
26611
- if (isURL(input)) {
26612
- input = spreadUrlObject(input);
26613
- }
26614
- else if (isString(input)) {
26615
- input = spreadUrlObject(parseUrl(input));
26616
- }
26617
- else {
26618
- callback = options;
26619
- options = validateUrl(input);
26620
- input = { protocol: protocol };
26621
- }
26622
- if (isFunction(options)) {
26623
- callback = options;
26624
- options = null;
26625
- }
26626
-
26627
- // Set defaults
26628
- options = Object.assign({
26629
- maxRedirects: exports.maxRedirects,
26630
- maxBodyLength: exports.maxBodyLength,
26631
- }, input, options);
26632
- options.nativeProtocols = nativeProtocols;
26633
- if (!isString(options.host) && !isString(options.hostname)) {
26634
- options.hostname = "::1";
26635
- }
26636
-
26637
- assert.equal(options.protocol, protocol, "protocol mismatch");
26638
- debug_1("options", options);
26639
- return new RedirectableRequest(options, callback);
26640
- }
26641
-
26642
- // Executes a GET request, following redirects
26643
- function get(input, options, callback) {
26644
- var wrappedRequest = wrappedProtocol.request(input, options, callback);
26645
- wrappedRequest.end();
26646
- return wrappedRequest;
26647
- }
26648
-
26649
- // Expose the properties on the wrapped protocol
26650
- Object.defineProperties(wrappedProtocol, {
26651
- request: { value: request, configurable: true, enumerable: true, writable: true },
26652
- get: { value: get, configurable: true, enumerable: true, writable: true },
26653
- });
26654
- });
26655
- return exports;
26656
- }
26657
-
26658
- function noop() { /* empty */ }
26659
-
26660
- function parseUrl(input) {
26661
- var parsed;
26662
- /* istanbul ignore else */
26663
- if (useNativeURL) {
26664
- parsed = new URL$1(input);
26665
- }
26666
- else {
26667
- // Ensure the URL is valid and absolute
26668
- parsed = validateUrl(url.parse(input));
26669
- if (!isString(parsed.protocol)) {
26670
- throw new InvalidUrlError({ input });
26671
- }
26672
- }
26673
- return parsed;
26674
- }
26675
-
26676
- function resolveUrl(relative, base) {
26677
- /* istanbul ignore next */
26678
- return useNativeURL ? new URL$1(relative, base) : parseUrl(url.resolve(base, relative));
26679
- }
26680
-
26681
- function validateUrl(input) {
26682
- if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
26683
- throw new InvalidUrlError({ input: input.href || input });
26684
- }
26685
- if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
26686
- throw new InvalidUrlError({ input: input.href || input });
26687
- }
26688
- return input;
26689
- }
26690
-
26691
- function spreadUrlObject(urlObject, target) {
26692
- var spread = target || {};
26693
- for (var key of preservedUrlFields) {
26694
- spread[key] = urlObject[key];
26695
- }
26696
-
26697
- // Fix IPv6 hostname
26698
- if (spread.hostname.startsWith("[")) {
26699
- spread.hostname = spread.hostname.slice(1, -1);
26700
- }
26701
- // Ensure port is a number
26702
- if (spread.port !== "") {
26703
- spread.port = Number(spread.port);
26704
- }
26705
- // Concatenate path
26706
- spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
26707
-
26708
- return spread;
26709
- }
26710
-
26711
- function removeMatchingHeaders(regex, headers) {
26712
- var lastValue;
26713
- for (var header in headers) {
26714
- if (regex.test(header)) {
26715
- lastValue = headers[header];
26716
- delete headers[header];
26717
- }
26718
- }
26719
- return (lastValue === null || typeof lastValue === "undefined") ?
26720
- undefined : String(lastValue).trim();
26721
- }
26722
-
26723
- function createErrorType(code, message, baseClass) {
26724
- // Create constructor
26725
- function CustomError(properties) {
26726
- Error.captureStackTrace(this, this.constructor);
26727
- Object.assign(this, properties || {});
26728
- this.code = code;
26729
- this.message = this.cause ? message + ": " + this.cause.message : message;
26730
- }
26731
-
26732
- // Attach constructor and set default properties
26733
- CustomError.prototype = new (baseClass || Error)();
26734
- Object.defineProperties(CustomError.prototype, {
26735
- constructor: {
26736
- value: CustomError,
26737
- enumerable: false,
26738
- },
26739
- name: {
26740
- value: "Error [" + code + "]",
26741
- enumerable: false,
26742
- },
26743
- });
26744
- return CustomError;
26745
- }
26746
-
26747
- function destroyRequest(request, error) {
26748
- for (var event of events) {
26749
- request.removeListener(event, eventHandlers[event]);
26750
- }
26751
- request.on("error", noop);
26752
- request.destroy(error);
26753
- }
26754
-
26755
- function isSubdomain(subdomain, domain) {
26756
- assert(isString(subdomain) && isString(domain));
26757
- var dot = subdomain.length - domain.length - 1;
26758
- return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
26759
- }
26760
-
26761
- function isString(value) {
26762
- return typeof value === "string" || value instanceof String;
26763
- }
26764
-
26765
- function isFunction(value) {
26766
- return typeof value === "function";
26767
- }
26768
-
26769
- function isBuffer(value) {
26770
- return typeof value === "object" && ("length" in value);
26771
- }
26772
-
26773
- function isURL(value) {
26774
- return URL$1 && value instanceof URL$1;
26775
- }
26776
-
26777
- // Exports
26778
- var followRedirects = wrap({ http: http, https: https });
26779
- var wrap_1 = wrap;
26780
- followRedirects.wrap = wrap_1;
26781
-
26782
- var _from = "axios@0.21.0";
26783
- var _id = "axios@0.21.0";
26784
- var _inBundle = false;
26785
- var _integrity = "sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==";
26786
- var _location = "/axios";
26787
- var _phantomChildren = {
26788
- };
26789
- var _requested = {
26790
- type: "version",
26791
- registry: true,
26792
- raw: "axios@0.21.0",
26793
- name: "axios",
26794
- escapedName: "axios",
26795
- rawSpec: "0.21.0",
26796
- saveSpec: null,
26797
- fetchSpec: "0.21.0"
26798
- };
26799
- var _requiredBy = [
26800
- "#DEV:/",
26801
- "#USER"
26802
- ];
26803
- var _resolved = "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz";
26804
- var _shasum = "26df088803a2350dff2c27f96fef99fe49442aca";
26805
- var _spec = "axios@0.21.0";
26806
- var _where = "/Users/jingtongyu/Downloads/unika/unika-components";
26807
- var author = {
26808
- name: "Matt Zabriskie"
26809
- };
26810
- var browser = {
26811
- "./lib/adapters/http.js": "./lib/adapters/xhr.js"
26812
- };
26813
- var bugs = {
26814
- url: "https://github.com/axios/axios/issues"
26815
- };
26816
- var bundleDependencies = false;
26817
- var bundlesize = [
26818
- {
26819
- path: "./dist/axios.min.js",
26820
- threshold: "5kB"
26821
- }
26822
- ];
26823
- var dependencies = {
26824
- "follow-redirects": "^1.10.0"
26825
- };
26826
- var deprecated = "Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410";
26827
- var description = "Promise based HTTP client for the browser and node.js";
26828
- var devDependencies = {
26829
- bundlesize: "^0.17.0",
26830
- coveralls: "^3.0.0",
26831
- "es6-promise": "^4.2.4",
26832
- grunt: "^1.0.2",
26833
- "grunt-banner": "^0.6.0",
26834
- "grunt-cli": "^1.2.0",
26835
- "grunt-contrib-clean": "^1.1.0",
26836
- "grunt-contrib-watch": "^1.0.0",
26837
- "grunt-eslint": "^20.1.0",
26838
- "grunt-karma": "^2.0.0",
26839
- "grunt-mocha-test": "^0.13.3",
26840
- "grunt-ts": "^6.0.0-beta.19",
26841
- "grunt-webpack": "^1.0.18",
26842
- "istanbul-instrumenter-loader": "^1.0.0",
26843
- "jasmine-core": "^2.4.1",
26844
- karma: "^1.3.0",
26845
- "karma-chrome-launcher": "^2.2.0",
26846
- "karma-coverage": "^1.1.1",
26847
- "karma-firefox-launcher": "^1.1.0",
26848
- "karma-jasmine": "^1.1.1",
26849
- "karma-jasmine-ajax": "^0.1.13",
26850
- "karma-opera-launcher": "^1.0.0",
26851
- "karma-safari-launcher": "^1.0.0",
26852
- "karma-sauce-launcher": "^1.2.0",
26853
- "karma-sinon": "^1.0.5",
26854
- "karma-sourcemap-loader": "^0.3.7",
26855
- "karma-webpack": "^1.7.0",
26856
- "load-grunt-tasks": "^3.5.2",
26857
- minimist: "^1.2.0",
26858
- mocha: "^5.2.0",
26859
- sinon: "^4.5.0",
26860
- typescript: "^2.8.1",
26861
- "url-search-params": "^0.10.0",
26862
- webpack: "^1.13.1",
26863
- "webpack-dev-server": "^1.14.1"
26864
- };
26865
- var homepage = "https://github.com/axios/axios";
26866
- var jsdelivr = "dist/axios.min.js";
26867
- var keywords = [
26868
- "xhr",
26869
- "http",
26870
- "ajax",
26871
- "promise",
26872
- "node"
26873
- ];
26874
- var license = "MIT";
26875
- var main = "index.js";
26876
- var name = "axios";
26877
- var repository = {
26878
- type: "git",
26879
- url: "git+https://github.com/axios/axios.git"
26880
- };
26881
- var scripts = {
26882
- build: "NODE_ENV=production grunt build",
26883
- coveralls: "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
26884
- examples: "node ./examples/server.js",
26885
- fix: "eslint --fix lib/**/*.js",
26886
- postversion: "git push && git push --tags",
26887
- preversion: "npm test",
26888
- start: "node ./sandbox/server.js",
26889
- test: "grunt test && bundlesize",
26890
- version: "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json"
26891
- };
26892
- var typings = "./index.d.ts";
26893
- var unpkg = "dist/axios.min.js";
26894
- var version = "0.21.0";
26895
- var pkg = {
26896
- _from: _from,
26897
- _id: _id,
26898
- _inBundle: _inBundle,
26899
- _integrity: _integrity,
26900
- _location: _location,
26901
- _phantomChildren: _phantomChildren,
26902
- _requested: _requested,
26903
- _requiredBy: _requiredBy,
26904
- _resolved: _resolved,
26905
- _shasum: _shasum,
26906
- _spec: _spec,
26907
- _where: _where,
26908
- author: author,
26909
- browser: browser,
26910
- bugs: bugs,
26911
- bundleDependencies: bundleDependencies,
26912
- bundlesize: bundlesize,
26913
- dependencies: dependencies,
26914
- deprecated: deprecated,
26915
- description: description,
26916
- devDependencies: devDependencies,
26917
- homepage: homepage,
26918
- jsdelivr: jsdelivr,
26919
- keywords: keywords,
26920
- license: license,
26921
- main: main,
26922
- name: name,
26923
- repository: repository,
26924
- scripts: scripts,
26925
- typings: typings,
26926
- unpkg: unpkg,
26927
- version: version
26928
- };
26929
-
26930
- var httpFollow = followRedirects.http;
26931
- var httpsFollow = followRedirects.https;
26932
-
26933
-
26934
-
26935
-
26936
-
26937
-
26938
- var isHttps = /https:?/;
26939
-
26940
- /*eslint consistent-return:0*/
26941
- var http_1 = function httpAdapter(config) {
26942
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
26943
- var resolve = function resolve(value) {
26944
- resolvePromise(value);
26945
- };
26946
- var reject = function reject(value) {
26947
- rejectPromise(value);
26948
- };
26949
- var data = config.data;
26950
- var headers = config.headers;
26951
-
26952
- // Set User-Agent (required by some servers)
26953
- // Only set header if it hasn't been set in config
26954
- // See https://github.com/axios/axios/issues/69
26955
- if (!headers['User-Agent'] && !headers['user-agent']) {
26956
- headers['User-Agent'] = 'axios/' + pkg.version;
26957
- }
26958
-
26959
- if (data && !utils.isStream(data)) {
26960
- if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
26961
- data = Buffer.from(new Uint8Array(data));
26962
- } else if (utils.isString(data)) {
26963
- data = Buffer.from(data, 'utf-8');
26964
- } else {
26965
- return reject(createError(
26966
- 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
26967
- config
26968
- ));
26969
- }
26970
-
26971
- // Add Content-Length header if data exists
26972
- headers['Content-Length'] = data.length;
26973
- }
26974
-
26975
- // HTTP basic authentication
26976
- var auth = undefined;
26977
- if (config.auth) {
26978
- var username = config.auth.username || '';
26979
- var password = config.auth.password || '';
26980
- auth = username + ':' + password;
26981
- }
26982
-
26983
- // Parse url
26984
- var fullPath = buildFullPath(config.baseURL, config.url);
26985
- var parsed = url.parse(fullPath);
26986
- var protocol = parsed.protocol || 'http:';
26987
-
26988
- if (!auth && parsed.auth) {
26989
- var urlAuth = parsed.auth.split(':');
26990
- var urlUsername = urlAuth[0] || '';
26991
- var urlPassword = urlAuth[1] || '';
26992
- auth = urlUsername + ':' + urlPassword;
26993
- }
26994
-
26995
- if (auth) {
26996
- delete headers.Authorization;
26997
- }
26998
-
26999
- var isHttpsRequest = isHttps.test(protocol);
27000
- var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
27001
-
27002
- var options = {
27003
- path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
27004
- method: config.method.toUpperCase(),
27005
- headers: headers,
27006
- agent: agent,
27007
- agents: { http: config.httpAgent, https: config.httpsAgent },
27008
- auth: auth
27009
- };
27010
-
27011
- if (config.socketPath) {
27012
- options.socketPath = config.socketPath;
27013
- } else {
27014
- options.hostname = parsed.hostname;
27015
- options.port = parsed.port;
27016
- }
27017
-
27018
- var proxy = config.proxy;
27019
- if (!proxy && proxy !== false) {
27020
- var proxyEnv = protocol.slice(0, -1) + '_proxy';
27021
- var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
27022
- if (proxyUrl) {
27023
- var parsedProxyUrl = url.parse(proxyUrl);
27024
- var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
27025
- var shouldProxy = true;
27026
-
27027
- if (noProxyEnv) {
27028
- var noProxy = noProxyEnv.split(',').map(function trim(s) {
27029
- return s.trim();
27030
- });
27031
-
27032
- shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
27033
- if (!proxyElement) {
27034
- return false;
27035
- }
27036
- if (proxyElement === '*') {
27037
- return true;
27038
- }
27039
- if (proxyElement[0] === '.' &&
27040
- parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
27041
- return true;
27042
- }
27043
-
27044
- return parsed.hostname === proxyElement;
27045
- });
27046
- }
27047
-
27048
-
27049
- if (shouldProxy) {
27050
- proxy = {
27051
- host: parsedProxyUrl.hostname,
27052
- port: parsedProxyUrl.port
27053
- };
27054
-
27055
- if (parsedProxyUrl.auth) {
27056
- var proxyUrlAuth = parsedProxyUrl.auth.split(':');
27057
- proxy.auth = {
27058
- username: proxyUrlAuth[0],
27059
- password: proxyUrlAuth[1]
27060
- };
27061
- }
27062
- }
27063
- }
27064
- }
27065
-
27066
- if (proxy) {
27067
- options.hostname = proxy.host;
27068
- options.host = proxy.host;
27069
- options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
27070
- options.port = proxy.port;
27071
- options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
27072
-
27073
- // Basic proxy authorization
27074
- if (proxy.auth) {
27075
- var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
27076
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
27077
- }
27078
- }
27079
-
27080
- var transport;
27081
- var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
27082
- if (config.transport) {
27083
- transport = config.transport;
27084
- } else if (config.maxRedirects === 0) {
27085
- transport = isHttpsProxy ? https : http;
27086
- } else {
27087
- if (config.maxRedirects) {
27088
- options.maxRedirects = config.maxRedirects;
27089
- }
27090
- transport = isHttpsProxy ? httpsFollow : httpFollow;
27091
- }
27092
-
27093
- if (config.maxBodyLength > -1) {
27094
- options.maxBodyLength = config.maxBodyLength;
27095
- }
27096
-
27097
- // Create the request
27098
- var req = transport.request(options, function handleResponse(res) {
27099
- if (req.aborted) return;
27100
-
27101
- // uncompress the response body transparently if required
27102
- var stream = res;
27103
-
27104
- // return the last request in case of redirects
27105
- var lastRequest = res.req || req;
27106
-
27107
-
27108
- // if no content, is HEAD request or decompress disabled we should not decompress
27109
- if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
27110
- switch (res.headers['content-encoding']) {
27111
- /*eslint default-case:0*/
27112
- case 'gzip':
27113
- case 'compress':
27114
- case 'deflate':
27115
- // add the unzipper to the body stream processing pipeline
27116
- stream = stream.pipe(zlib.createUnzip());
27117
-
27118
- // remove the content-encoding in order to not confuse downstream operations
27119
- delete res.headers['content-encoding'];
27120
- break;
27121
- }
27122
- }
27123
-
27124
- var response = {
27125
- status: res.statusCode,
27126
- statusText: res.statusMessage,
27127
- headers: res.headers,
27128
- config: config,
27129
- request: lastRequest
27130
- };
27131
-
27132
- if (config.responseType === 'stream') {
27133
- response.data = stream;
27134
- settle(resolve, reject, response);
27135
- } else {
27136
- var responseBuffer = [];
27137
- stream.on('data', function handleStreamData(chunk) {
27138
- responseBuffer.push(chunk);
27139
-
27140
- // make sure the content length is not over the maxContentLength if specified
27141
- if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
27142
- stream.destroy();
27143
- reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
27144
- config, null, lastRequest));
27145
- }
27146
- });
27147
-
27148
- stream.on('error', function handleStreamError(err) {
27149
- if (req.aborted) return;
27150
- reject(enhanceError(err, config, null, lastRequest));
27151
- });
27152
-
27153
- stream.on('end', function handleStreamEnd() {
27154
- var responseData = Buffer.concat(responseBuffer);
27155
- if (config.responseType !== 'arraybuffer') {
27156
- responseData = responseData.toString(config.responseEncoding);
27157
- if (!config.responseEncoding || config.responseEncoding === 'utf8') {
27158
- responseData = utils.stripBOM(responseData);
27159
- }
27160
- }
27161
-
27162
- response.data = responseData;
27163
- settle(resolve, reject, response);
27164
- });
27165
- }
27166
- });
27167
-
27168
- // Handle errors
27169
- req.on('error', function handleRequestError(err) {
27170
- if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
27171
- reject(enhanceError(err, config, null, req));
27172
- });
27173
-
27174
- // Handle request timeout
27175
- if (config.timeout) {
27176
- // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
27177
- // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
27178
- // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
27179
- // And then these socket which be hang up will devoring CPU little by little.
27180
- // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
27181
- req.setTimeout(config.timeout, function handleRequestTimeout() {
27182
- req.abort();
27183
- reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
27184
- });
27185
- }
27186
-
27187
- if (config.cancelToken) {
27188
- // Handle cancellation
27189
- config.cancelToken.promise.then(function onCanceled(cancel) {
27190
- if (req.aborted) return;
27191
-
27192
- req.abort();
27193
- reject(cancel);
27194
- });
27195
- }
27196
-
27197
- // Send the request
27198
- if (utils.isStream(data)) {
27199
- data.on('error', function handleStreamError(err) {
27200
- reject(enhanceError(err, config, null, req));
27201
- }).pipe(req);
27202
- } else {
27203
- req.end(data);
27204
- }
27205
- });
27206
- };
27207
-
27208
- var DEFAULT_CONTENT_TYPE = {
27209
- 'Content-Type': 'application/x-www-form-urlencoded'
27210
- };
27211
-
27212
- function setContentTypeIfUnset(headers, value) {
27213
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
27214
- headers['Content-Type'] = value;
27215
- }
27216
- }
27217
-
27218
- function getDefaultAdapter() {
27219
- var adapter;
27220
- if (typeof XMLHttpRequest !== 'undefined') {
27221
- // For browsers use XHR adapter
27222
- adapter = xhr;
27223
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
27224
- // For node use HTTP adapter
27225
- adapter = http_1;
27226
- }
27227
- return adapter;
27228
- }
27229
-
27230
- var defaults = {
27231
- adapter: getDefaultAdapter(),
27232
-
27233
- transformRequest: [function transformRequest(data, headers) {
27234
- normalizeHeaderName(headers, 'Accept');
27235
- normalizeHeaderName(headers, 'Content-Type');
27236
- if (utils.isFormData(data) ||
27237
- utils.isArrayBuffer(data) ||
27238
- utils.isBuffer(data) ||
27239
- utils.isStream(data) ||
27240
- utils.isFile(data) ||
27241
- utils.isBlob(data)
27242
- ) {
27243
- return data;
27244
- }
27245
- if (utils.isArrayBufferView(data)) {
27246
- return data.buffer;
27247
- }
27248
- if (utils.isURLSearchParams(data)) {
27249
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
27250
- return data.toString();
27251
- }
27252
- if (utils.isObject(data)) {
27253
- setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
27254
- return JSON.stringify(data);
27255
- }
27256
- return data;
27257
- }],
27258
-
27259
- transformResponse: [function transformResponse(data) {
27260
- /*eslint no-param-reassign:0*/
27261
- if (typeof data === 'string') {
27262
- try {
27263
- data = JSON.parse(data);
27264
- } catch (e) { /* Ignore */ }
27265
- }
27266
- return data;
27267
- }],
27268
-
27269
- /**
27270
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
27271
- * timeout is not created.
27272
- */
27273
- timeout: 0,
27274
-
27275
- xsrfCookieName: 'XSRF-TOKEN',
27276
- xsrfHeaderName: 'X-XSRF-TOKEN',
27277
-
27278
- maxContentLength: -1,
27279
- maxBodyLength: -1,
27280
-
27281
- validateStatus: function validateStatus(status) {
27282
- return status >= 200 && status < 300;
27283
- }
27284
- };
27285
-
27286
- defaults.headers = {
27287
- common: {
27288
- 'Accept': 'application/json, text/plain, */*'
27289
- }
27290
- };
27291
-
27292
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
27293
- defaults.headers[method] = {};
27294
- });
27295
-
27296
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
27297
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
27298
- });
27299
-
27300
- var defaults_1 = defaults;
27301
-
27302
- /**
27303
- * Throws a `Cancel` if cancellation has been requested.
27304
- */
27305
- function throwIfCancellationRequested(config) {
27306
- if (config.cancelToken) {
27307
- config.cancelToken.throwIfRequested();
27308
- }
27309
- }
27310
-
27311
- /**
27312
- * Dispatch a request to the server using the configured adapter.
27313
- *
27314
- * @param {object} config The config that is to be used for the request
27315
- * @returns {Promise} The Promise to be fulfilled
27316
- */
27317
- var dispatchRequest = function dispatchRequest(config) {
27318
- throwIfCancellationRequested(config);
27319
-
27320
- // Ensure headers exist
27321
- config.headers = config.headers || {};
27322
-
27323
- // Transform request data
27324
- config.data = transformData(
27325
- config.data,
27326
- config.headers,
27327
- config.transformRequest
27328
- );
27329
-
27330
- // Flatten headers
27331
- config.headers = utils.merge(
27332
- config.headers.common || {},
27333
- config.headers[config.method] || {},
27334
- config.headers
27335
- );
27336
-
27337
- utils.forEach(
27338
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
27339
- function cleanHeaderConfig(method) {
27340
- delete config.headers[method];
27341
- }
27342
- );
27343
-
27344
- var adapter = config.adapter || defaults_1.adapter;
27345
-
27346
- return adapter(config).then(function onAdapterResolution(response) {
27347
- throwIfCancellationRequested(config);
27348
-
27349
- // Transform response data
27350
- response.data = transformData(
27351
- response.data,
27352
- response.headers,
27353
- config.transformResponse
27354
- );
27355
-
27356
- return response;
27357
- }, function onAdapterRejection(reason) {
27358
- if (!isCancel(reason)) {
27359
- throwIfCancellationRequested(config);
27360
-
27361
- // Transform response data
27362
- if (reason && reason.response) {
27363
- reason.response.data = transformData(
27364
- reason.response.data,
27365
- reason.response.headers,
27366
- config.transformResponse
27367
- );
27368
- }
27369
- }
27370
-
27371
- return Promise.reject(reason);
27372
- });
27373
- };
27374
-
27375
- /**
27376
- * Config-specific merge-function which creates a new config-object
27377
- * by merging two configuration objects together.
27378
- *
27379
- * @param {Object} config1
27380
- * @param {Object} config2
27381
- * @returns {Object} New object resulting from merging config2 to config1
27382
- */
27383
- var mergeConfig = function mergeConfig(config1, config2) {
27384
- // eslint-disable-next-line no-param-reassign
27385
- config2 = config2 || {};
27386
- var config = {};
27387
-
27388
- var valueFromConfig2Keys = ['url', 'method', 'data'];
27389
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
27390
- var defaultToConfig2Keys = [
27391
- 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
27392
- 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
27393
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
27394
- 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
27395
- 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
27396
- ];
27397
- var directMergeKeys = ['validateStatus'];
27398
-
27399
- function getMergedValue(target, source) {
27400
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
27401
- return utils.merge(target, source);
27402
- } else if (utils.isPlainObject(source)) {
27403
- return utils.merge({}, source);
27404
- } else if (utils.isArray(source)) {
27405
- return source.slice();
27406
- }
27407
- return source;
27408
- }
27409
-
27410
- function mergeDeepProperties(prop) {
27411
- if (!utils.isUndefined(config2[prop])) {
27412
- config[prop] = getMergedValue(config1[prop], config2[prop]);
27413
- } else if (!utils.isUndefined(config1[prop])) {
27414
- config[prop] = getMergedValue(undefined, config1[prop]);
27415
- }
27416
- }
27417
-
27418
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
27419
- if (!utils.isUndefined(config2[prop])) {
27420
- config[prop] = getMergedValue(undefined, config2[prop]);
27421
- }
27422
- });
27423
-
27424
- utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
27425
-
27426
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
27427
- if (!utils.isUndefined(config2[prop])) {
27428
- config[prop] = getMergedValue(undefined, config2[prop]);
27429
- } else if (!utils.isUndefined(config1[prop])) {
27430
- config[prop] = getMergedValue(undefined, config1[prop]);
27431
- }
27432
- });
27433
-
27434
- utils.forEach(directMergeKeys, function merge(prop) {
27435
- if (prop in config2) {
27436
- config[prop] = getMergedValue(config1[prop], config2[prop]);
27437
- } else if (prop in config1) {
27438
- config[prop] = getMergedValue(undefined, config1[prop]);
27439
- }
27440
- });
27441
-
27442
- var axiosKeys = valueFromConfig2Keys
27443
- .concat(mergeDeepPropertiesKeys)
27444
- .concat(defaultToConfig2Keys)
27445
- .concat(directMergeKeys);
27446
-
27447
- var otherKeys = Object
27448
- .keys(config1)
27449
- .concat(Object.keys(config2))
27450
- .filter(function filterAxiosKeys(key) {
27451
- return axiosKeys.indexOf(key) === -1;
27452
- });
27453
-
27454
- utils.forEach(otherKeys, mergeDeepProperties);
27455
-
27456
- return config;
27457
- };
27458
-
27459
- /**
27460
- * Create a new instance of Axios
27461
- *
27462
- * @param {Object} instanceConfig The default config for the instance
27463
- */
27464
- function Axios(instanceConfig) {
27465
- this.defaults = instanceConfig;
27466
- this.interceptors = {
27467
- request: new InterceptorManager_1(),
27468
- response: new InterceptorManager_1()
27469
- };
27470
- }
27471
-
27472
- /**
27473
- * Dispatch a request
27474
- *
27475
- * @param {Object} config The config specific for this request (merged with this.defaults)
27476
- */
27477
- Axios.prototype.request = function request(config) {
27478
- /*eslint no-param-reassign:0*/
27479
- // Allow for axios('example/url'[, config]) a la fetch API
27480
- if (typeof config === 'string') {
27481
- config = arguments[1] || {};
27482
- config.url = arguments[0];
27483
- } else {
27484
- config = config || {};
27485
- }
27486
-
27487
- config = mergeConfig(this.defaults, config);
27488
-
27489
- // Set config.method
27490
- if (config.method) {
27491
- config.method = config.method.toLowerCase();
27492
- } else if (this.defaults.method) {
27493
- config.method = this.defaults.method.toLowerCase();
27494
- } else {
27495
- config.method = 'get';
27496
- }
27497
-
27498
- // Hook up interceptors middleware
27499
- var chain = [dispatchRequest, undefined];
27500
- var promise = Promise.resolve(config);
27501
-
27502
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
27503
- chain.unshift(interceptor.fulfilled, interceptor.rejected);
27504
- });
27505
-
27506
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
27507
- chain.push(interceptor.fulfilled, interceptor.rejected);
27508
- });
27509
-
27510
- while (chain.length) {
27511
- promise = promise.then(chain.shift(), chain.shift());
27512
- }
27513
-
27514
- return promise;
27515
- };
27516
-
27517
- Axios.prototype.getUri = function getUri(config) {
27518
- config = mergeConfig(this.defaults, config);
27519
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
27520
- };
27521
-
27522
- // Provide aliases for supported request methods
27523
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
27524
- /*eslint func-names:0*/
27525
- Axios.prototype[method] = function(url, config) {
27526
- return this.request(mergeConfig(config || {}, {
27527
- method: method,
27528
- url: url,
27529
- data: (config || {}).data
27530
- }));
27531
- };
27532
- });
27533
-
27534
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
27535
- /*eslint func-names:0*/
27536
- Axios.prototype[method] = function(url, data, config) {
27537
- return this.request(mergeConfig(config || {}, {
27538
- method: method,
27539
- url: url,
27540
- data: data
27541
- }));
27542
- };
27543
- });
27544
-
27545
- var Axios_1 = Axios;
27546
-
27547
- /**
27548
- * A `Cancel` is an object that is thrown when an operation is canceled.
27549
- *
27550
- * @class
27551
- * @param {string=} message The message.
27552
- */
27553
- function Cancel(message) {
27554
- this.message = message;
27555
- }
27556
-
27557
- Cancel.prototype.toString = function toString() {
27558
- return 'Cancel' + (this.message ? ': ' + this.message : '');
27559
- };
27560
-
27561
- Cancel.prototype.__CANCEL__ = true;
27562
-
27563
- var Cancel_1 = Cancel;
27564
-
27565
- /**
27566
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
27567
- *
27568
- * @class
27569
- * @param {Function} executor The executor function.
27570
- */
27571
- function CancelToken(executor) {
27572
- if (typeof executor !== 'function') {
27573
- throw new TypeError('executor must be a function.');
27574
- }
27575
-
27576
- var resolvePromise;
27577
- this.promise = new Promise(function promiseExecutor(resolve) {
27578
- resolvePromise = resolve;
27579
- });
27580
-
27581
- var token = this;
27582
- executor(function cancel(message) {
27583
- if (token.reason) {
27584
- // Cancellation has already been requested
27585
- return;
27586
- }
27587
-
27588
- token.reason = new Cancel_1(message);
27589
- resolvePromise(token.reason);
27590
- });
27591
- }
27592
-
27593
- /**
27594
- * Throws a `Cancel` if cancellation has been requested.
27595
- */
27596
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
27597
- if (this.reason) {
27598
- throw this.reason;
27599
- }
27600
- };
27601
-
27602
- /**
27603
- * Returns an object that contains a new `CancelToken` and a function that, when called,
27604
- * cancels the `CancelToken`.
27605
- */
27606
- CancelToken.source = function source() {
27607
- var cancel;
27608
- var token = new CancelToken(function executor(c) {
27609
- cancel = c;
27610
- });
27611
- return {
27612
- token: token,
27613
- cancel: cancel
27614
- };
27615
- };
27616
-
27617
- var CancelToken_1 = CancelToken;
27618
-
27619
- /**
27620
- * Syntactic sugar for invoking a function and expanding an array for arguments.
27621
- *
27622
- * Common use case would be to use `Function.prototype.apply`.
27623
- *
27624
- * ```js
27625
- * function f(x, y, z) {}
27626
- * var args = [1, 2, 3];
27627
- * f.apply(null, args);
27628
- * ```
27629
- *
27630
- * With `spread` this example can be re-written.
27631
- *
27632
- * ```js
27633
- * spread(function(x, y, z) {})([1, 2, 3]);
27634
- * ```
27635
- *
27636
- * @param {Function} callback
27637
- * @returns {Function}
27638
- */
27639
- var spread = function spread(callback) {
27640
- return function wrap(arr) {
27641
- return callback.apply(null, arr);
27642
- };
27643
- };
27644
-
27645
- /**
27646
- * Create an instance of Axios
27647
- *
27648
- * @param {Object} defaultConfig The default config for the instance
27649
- * @return {Axios} A new instance of Axios
27650
- */
27651
- function createInstance(defaultConfig) {
27652
- var context = new Axios_1(defaultConfig);
27653
- var instance = bind(Axios_1.prototype.request, context);
27654
-
27655
- // Copy axios.prototype to instance
27656
- utils.extend(instance, Axios_1.prototype, context);
27657
-
27658
- // Copy context to instance
27659
- utils.extend(instance, context);
27660
-
27661
- return instance;
27662
- }
27663
-
27664
- // Create the default instance to be exported
27665
- var axios$1 = createInstance(defaults_1);
27666
-
27667
- // Expose Axios class to allow class inheritance
27668
- axios$1.Axios = Axios_1;
27669
-
27670
- // Factory for creating new instances
27671
- axios$1.create = function create(instanceConfig) {
27672
- return createInstance(mergeConfig(axios$1.defaults, instanceConfig));
27673
- };
27674
-
27675
- // Expose Cancel & CancelToken
27676
- axios$1.Cancel = Cancel_1;
27677
- axios$1.CancelToken = CancelToken_1;
27678
- axios$1.isCancel = isCancel;
27679
-
27680
- // Expose all/spread
27681
- axios$1.all = function all(promises) {
27682
- return Promise.all(promises);
27683
- };
27684
- axios$1.spread = spread;
27685
-
27686
- var axios_1 = axios$1;
27687
-
27688
- // Allow use of default import syntax in TypeScript
27689
- var _default = axios$1;
27690
- axios_1.default = _default;
27691
-
27692
- var axios = axios_1;
27693
-
24000
+ async function requestJson(url, init) {
24001
+ const timeout = init?.timeout ?? 8000;
24002
+ const controller = new AbortController();
24003
+ const timer = window.setTimeout(() => controller.abort(), timeout);
24004
+ const { timeout: _timeout, ...fetchInit } = init ?? {};
24005
+ try {
24006
+ const res = await fetch(url, { ...fetchInit, signal: controller.signal });
24007
+ const data = (await res.json());
24008
+ return { status: res.status, data };
24009
+ }
24010
+ finally {
24011
+ window.clearTimeout(timer);
24012
+ }
24013
+ }
27694
24014
  var script$g = defineComponent({
27695
24015
  name: 'uni-barrage',
27696
24016
  props: {
@@ -27756,7 +24076,7 @@ var script$g = defineComponent({
27756
24076
  });
27757
24077
  const initBullets = async () => {
27758
24078
  try {
27759
- const res = await axios.get(host + '/api/barrage/' + props.global.sceneId);
24079
+ const res = await requestJson(host + '/api/barrage/' + props.global.sceneId);
27760
24080
  if (res.status === 200 && res.data.error === 0) {
27761
24081
  praiseCount.value = res.data.data[0] && res.data.data[0].praiseCount ? res.data.data[0].praiseCount : 0;
27762
24082
  bulletList.value.push(...res.data.data[0].barrageContents.map((bullet, index) => ({
@@ -27873,11 +24193,14 @@ var script$g = defineComponent({
27873
24193
  praiseCount.value += 1;
27874
24194
  isPraised.value = true;
27875
24195
  }
27876
- await axios.post(host + '/api/praiseCount/', { sceneId: props.global.sceneId, praiseCount: praiseCount.value }, {
27877
- headers: {
27878
- 'Content-Type': 'application/json'
27879
- },
27880
- timeout: 8000 // 设置超时时间为8秒
24196
+ await requestJson(host + '/api/praiseCount/', {
24197
+ method: 'POST',
24198
+ headers: { 'Content-Type': 'application/json' },
24199
+ body: JSON.stringify({
24200
+ sceneId: props.global.sceneId,
24201
+ praiseCount: praiseCount.value,
24202
+ }),
24203
+ timeout: 8000,
27881
24204
  });
27882
24205
  };
27883
24206
  const submitBlessing = async () => {
@@ -27892,11 +24215,15 @@ var script$g = defineComponent({
27892
24215
  return;
27893
24216
  }
27894
24217
  try {
27895
- const res = await axios.post(host + '/api/barrage/', { sceneId: props.global.sceneId, name: trimmedName, content: trimmedMessage }, {
27896
- headers: {
27897
- 'Content-Type': 'application/json'
27898
- },
27899
- timeout: 8000 // 设置超时时间为8秒
24218
+ const res = await requestJson(host + '/api/barrage/', {
24219
+ method: 'POST',
24220
+ headers: { 'Content-Type': 'application/json' },
24221
+ body: JSON.stringify({
24222
+ sceneId: props.global.sceneId,
24223
+ name: trimmedName,
24224
+ content: trimmedMessage,
24225
+ }),
24226
+ timeout: 8000,
27900
24227
  });
27901
24228
  if (res.status === 200 && res.data.error === 0) {
27902
24229
  addBullet(trimmedName, trimmedMessage);