@azuro-org/images-generator 1.2.0 → 1.3.1

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.
Files changed (92) hide show
  1. package/dist/index-82868da9.js +19637 -0
  2. package/dist/index.es.js +1 -4
  3. package/dist/templates/_template/index.d.ts +1 -1
  4. package/dist/templates/bet-nft/index.d.ts +1 -1
  5. package/dist/templates/bet-nft/index.html +0 -1
  6. package/dist/templates/bet-nft/index.js +1 -1
  7. package/dist/templates/bet-og/index.d.ts +1 -1
  8. package/dist/templates/bet-og/index.js +1 -1
  9. package/dist/templates/combo-bet-og/index.d.ts +1 -1
  10. package/dist/templates/combo-bet-og/index.js +1 -1
  11. package/dist/templates/freebet/index.d.ts +1 -1
  12. package/dist/templates/freebet/index.js +1 -1
  13. package/dist/templates/trendle-social/images/bg-business.png +0 -0
  14. package/dist/templates/trendle-social/images/bg-crypto.png +0 -0
  15. package/dist/templates/trendle-social/images/bg-culture.png +0 -0
  16. package/dist/templates/trendle-social/images/bg-fomo.png +0 -0
  17. package/dist/templates/trendle-social/images/bg-politics.png +0 -0
  18. package/dist/templates/trendle-social/images/business.png +0 -0
  19. package/dist/templates/trendle-social/images/crypto.png +0 -0
  20. package/dist/templates/trendle-social/images/culture.png +0 -0
  21. package/dist/templates/trendle-social/images/fomo.png +0 -0
  22. package/dist/templates/trendle-social/images/politics.png +0 -0
  23. package/dist/templates/trendle-social/images/stamp.png +0 -0
  24. package/dist/templates/trendle-social/index.d.ts +30 -0
  25. package/dist/templates/trendle-social/index.html +209 -0
  26. package/dist/templates/trendle-social/index.js +50 -0
  27. package/dist/templates/trendle-trading/images/arrow-down.png +0 -0
  28. package/dist/templates/trendle-trading/images/arrow-up.png +0 -0
  29. package/dist/templates/trendle-trading/images/bg.png +0 -0
  30. package/dist/templates/trendle-trading/images/crash.png +0 -0
  31. package/dist/templates/trendle-trading/images/drake.png +0 -0
  32. package/dist/templates/trendle-trading/images/elon.png +0 -0
  33. package/dist/templates/trendle-trading/images/lewis.png +0 -0
  34. package/dist/templates/trendle-trading/images/logo.png +0 -0
  35. package/dist/templates/trendle-trading/images/loss.png +0 -0
  36. package/dist/templates/trendle-trading/images/mark.png +0 -0
  37. package/dist/templates/trendle-trading/images/obama.png +0 -0
  38. package/dist/templates/trendle-trading/images/profit.png +0 -0
  39. package/dist/templates/trendle-trading/images/tramp.png +0 -0
  40. package/dist/templates/trendle-trading/index.d.ts +16 -0
  41. package/dist/templates/trendle-trading/index.html +249 -0
  42. package/dist/templates/trendle-trading/index.js +51 -0
  43. package/dist/utils/generateImage.d.ts +4 -8
  44. package/dist/utils/types.d.ts +2 -2
  45. package/lib/index-de0b52f4.js +19637 -0
  46. package/lib/index.js +1 -4
  47. package/lib/templates/_template/index.d.ts +1 -1
  48. package/lib/templates/bet-nft/index.d.ts +1 -1
  49. package/lib/templates/bet-nft/index.html +0 -1
  50. package/lib/templates/bet-nft/index.js +1 -1
  51. package/lib/templates/bet-og/index.d.ts +1 -1
  52. package/lib/templates/bet-og/index.js +2 -2
  53. package/lib/templates/combo-bet-og/index.d.ts +1 -1
  54. package/lib/templates/combo-bet-og/index.js +1 -1
  55. package/lib/templates/freebet/index.d.ts +1 -1
  56. package/lib/templates/freebet/index.js +1 -1
  57. package/lib/templates/trendle-social/images/bg-business.png +0 -0
  58. package/lib/templates/trendle-social/images/bg-crypto.png +0 -0
  59. package/lib/templates/trendle-social/images/bg-culture.png +0 -0
  60. package/lib/templates/trendle-social/images/bg-fomo.png +0 -0
  61. package/lib/templates/trendle-social/images/bg-politics.png +0 -0
  62. package/lib/templates/trendle-social/images/business.png +0 -0
  63. package/lib/templates/trendle-social/images/crypto.png +0 -0
  64. package/lib/templates/trendle-social/images/culture.png +0 -0
  65. package/lib/templates/trendle-social/images/fomo.png +0 -0
  66. package/lib/templates/trendle-social/images/politics.png +0 -0
  67. package/lib/templates/trendle-social/images/stamp.png +0 -0
  68. package/lib/templates/trendle-social/index.d.ts +30 -0
  69. package/lib/templates/trendle-social/index.html +209 -0
  70. package/lib/templates/trendle-social/index.js +50 -0
  71. package/lib/templates/trendle-trading/images/arrow-down.png +0 -0
  72. package/lib/templates/trendle-trading/images/arrow-up.png +0 -0
  73. package/lib/templates/trendle-trading/images/bg.png +0 -0
  74. package/lib/templates/trendle-trading/images/crash.png +0 -0
  75. package/lib/templates/trendle-trading/images/drake.png +0 -0
  76. package/lib/templates/trendle-trading/images/elon.png +0 -0
  77. package/lib/templates/trendle-trading/images/lewis.png +0 -0
  78. package/lib/templates/trendle-trading/images/logo.png +0 -0
  79. package/lib/templates/trendle-trading/images/loss.png +0 -0
  80. package/lib/templates/trendle-trading/images/mark.png +0 -0
  81. package/lib/templates/trendle-trading/images/obama.png +0 -0
  82. package/lib/templates/trendle-trading/images/profit.png +0 -0
  83. package/lib/templates/trendle-trading/images/tramp.png +0 -0
  84. package/lib/templates/trendle-trading/index.d.ts +16 -0
  85. package/lib/templates/trendle-trading/index.html +249 -0
  86. package/lib/templates/trendle-trading/index.js +51 -0
  87. package/lib/utils/generateImage.d.ts +4 -8
  88. package/lib/utils/types.d.ts +2 -2
  89. package/package.json +4 -3
  90. package/tsconfig.json +3 -0
  91. package/dist/index-cd3884c7.js +0 -4216
  92. package/lib/index-9642de53.js +0 -4216
@@ -1,4216 +0,0 @@
1
- import fs from'fs';import require$$1$1 from'http';import require$$2 from'https';import require$$0$2 from'url';import require$$3 from'stream';import require$$4 from'assert';import require$$0$1 from'tty';import require$$1 from'util';import require$$0 from'os';import require$$8 from'zlib';/******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- function __awaiter(thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- }
25
-
26
- function __generator(thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- }var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
53
-
54
- function getDefaultExportFromCjs (x) {
55
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
56
- }var axios$3 = {exports: {}};var axios$2 = {exports: {}};var bind$2 = function bind(fn, thisArg) {
57
- return function wrap() {
58
- var args = new Array(arguments.length);
59
- for (var i = 0; i < args.length; i++) {
60
- args[i] = arguments[i];
61
- }
62
- return fn.apply(thisArg, args);
63
- };
64
- };var bind$1 = bind$2;
65
-
66
- // utils is a library of generic helper functions non-specific to axios
67
-
68
- var toString = Object.prototype.toString;
69
-
70
- /**
71
- * Determine if a value is an Array
72
- *
73
- * @param {Object} val The value to test
74
- * @returns {boolean} True if value is an Array, otherwise false
75
- */
76
- function isArray(val) {
77
- return Array.isArray(val);
78
- }
79
-
80
- /**
81
- * Determine if a value is undefined
82
- *
83
- * @param {Object} val The value to test
84
- * @returns {boolean} True if the value is undefined, otherwise false
85
- */
86
- function isUndefined(val) {
87
- return typeof val === 'undefined';
88
- }
89
-
90
- /**
91
- * Determine if a value is a Buffer
92
- *
93
- * @param {Object} val The value to test
94
- * @returns {boolean} True if value is a Buffer, otherwise false
95
- */
96
- function isBuffer(val) {
97
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
98
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
99
- }
100
-
101
- /**
102
- * Determine if a value is an ArrayBuffer
103
- *
104
- * @param {Object} val The value to test
105
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
106
- */
107
- function isArrayBuffer(val) {
108
- return toString.call(val) === '[object ArrayBuffer]';
109
- }
110
-
111
- /**
112
- * Determine if a value is a FormData
113
- *
114
- * @param {Object} val The value to test
115
- * @returns {boolean} True if value is an FormData, otherwise false
116
- */
117
- function isFormData(val) {
118
- return toString.call(val) === '[object FormData]';
119
- }
120
-
121
- /**
122
- * Determine if a value is a view on an ArrayBuffer
123
- *
124
- * @param {Object} val The value to test
125
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
126
- */
127
- function isArrayBufferView(val) {
128
- var result;
129
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
130
- result = ArrayBuffer.isView(val);
131
- } else {
132
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
133
- }
134
- return result;
135
- }
136
-
137
- /**
138
- * Determine if a value is a String
139
- *
140
- * @param {Object} val The value to test
141
- * @returns {boolean} True if value is a String, otherwise false
142
- */
143
- function isString(val) {
144
- return typeof val === 'string';
145
- }
146
-
147
- /**
148
- * Determine if a value is a Number
149
- *
150
- * @param {Object} val The value to test
151
- * @returns {boolean} True if value is a Number, otherwise false
152
- */
153
- function isNumber(val) {
154
- return typeof val === 'number';
155
- }
156
-
157
- /**
158
- * Determine if a value is an Object
159
- *
160
- * @param {Object} val The value to test
161
- * @returns {boolean} True if value is an Object, otherwise false
162
- */
163
- function isObject(val) {
164
- return val !== null && typeof val === 'object';
165
- }
166
-
167
- /**
168
- * Determine if a value is a plain Object
169
- *
170
- * @param {Object} val The value to test
171
- * @return {boolean} True if value is a plain Object, otherwise false
172
- */
173
- function isPlainObject(val) {
174
- if (toString.call(val) !== '[object Object]') {
175
- return false;
176
- }
177
-
178
- var prototype = Object.getPrototypeOf(val);
179
- return prototype === null || prototype === Object.prototype;
180
- }
181
-
182
- /**
183
- * Determine if a value is a Date
184
- *
185
- * @param {Object} val The value to test
186
- * @returns {boolean} True if value is a Date, otherwise false
187
- */
188
- function isDate(val) {
189
- return toString.call(val) === '[object Date]';
190
- }
191
-
192
- /**
193
- * Determine if a value is a File
194
- *
195
- * @param {Object} val The value to test
196
- * @returns {boolean} True if value is a File, otherwise false
197
- */
198
- function isFile(val) {
199
- return toString.call(val) === '[object File]';
200
- }
201
-
202
- /**
203
- * Determine if a value is a Blob
204
- *
205
- * @param {Object} val The value to test
206
- * @returns {boolean} True if value is a Blob, otherwise false
207
- */
208
- function isBlob(val) {
209
- return toString.call(val) === '[object Blob]';
210
- }
211
-
212
- /**
213
- * Determine if a value is a Function
214
- *
215
- * @param {Object} val The value to test
216
- * @returns {boolean} True if value is a Function, otherwise false
217
- */
218
- function isFunction(val) {
219
- return toString.call(val) === '[object Function]';
220
- }
221
-
222
- /**
223
- * Determine if a value is a Stream
224
- *
225
- * @param {Object} val The value to test
226
- * @returns {boolean} True if value is a Stream, otherwise false
227
- */
228
- function isStream(val) {
229
- return isObject(val) && isFunction(val.pipe);
230
- }
231
-
232
- /**
233
- * Determine if a value is a URLSearchParams object
234
- *
235
- * @param {Object} val The value to test
236
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
237
- */
238
- function isURLSearchParams(val) {
239
- return toString.call(val) === '[object URLSearchParams]';
240
- }
241
-
242
- /**
243
- * Trim excess whitespace off the beginning and end of a string
244
- *
245
- * @param {String} str The String to trim
246
- * @returns {String} The String freed of excess whitespace
247
- */
248
- function trim(str) {
249
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
250
- }
251
-
252
- /**
253
- * Determine if we're running in a standard browser environment
254
- *
255
- * This allows axios to run in a web worker, and react-native.
256
- * Both environments support XMLHttpRequest, but not fully standard globals.
257
- *
258
- * web workers:
259
- * typeof window -> undefined
260
- * typeof document -> undefined
261
- *
262
- * react-native:
263
- * navigator.product -> 'ReactNative'
264
- * nativescript
265
- * navigator.product -> 'NativeScript' or 'NS'
266
- */
267
- function isStandardBrowserEnv() {
268
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
269
- navigator.product === 'NativeScript' ||
270
- navigator.product === 'NS')) {
271
- return false;
272
- }
273
- return (
274
- typeof window !== 'undefined' &&
275
- typeof document !== 'undefined'
276
- );
277
- }
278
-
279
- /**
280
- * Iterate over an Array or an Object invoking a function for each item.
281
- *
282
- * If `obj` is an Array callback will be called passing
283
- * the value, index, and complete array for each item.
284
- *
285
- * If 'obj' is an Object callback will be called passing
286
- * the value, key, and complete object for each property.
287
- *
288
- * @param {Object|Array} obj The object to iterate
289
- * @param {Function} fn The callback to invoke for each item
290
- */
291
- function forEach(obj, fn) {
292
- // Don't bother if no value provided
293
- if (obj === null || typeof obj === 'undefined') {
294
- return;
295
- }
296
-
297
- // Force an array if not already something iterable
298
- if (typeof obj !== 'object') {
299
- /*eslint no-param-reassign:0*/
300
- obj = [obj];
301
- }
302
-
303
- if (isArray(obj)) {
304
- // Iterate over array values
305
- for (var i = 0, l = obj.length; i < l; i++) {
306
- fn.call(null, obj[i], i, obj);
307
- }
308
- } else {
309
- // Iterate over object keys
310
- for (var key in obj) {
311
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
312
- fn.call(null, obj[key], key, obj);
313
- }
314
- }
315
- }
316
- }
317
-
318
- /**
319
- * Accepts varargs expecting each argument to be an object, then
320
- * immutably merges the properties of each object and returns result.
321
- *
322
- * When multiple objects contain the same key the later object in
323
- * the arguments list will take precedence.
324
- *
325
- * Example:
326
- *
327
- * ```js
328
- * var result = merge({foo: 123}, {foo: 456});
329
- * console.log(result.foo); // outputs 456
330
- * ```
331
- *
332
- * @param {Object} obj1 Object to merge
333
- * @returns {Object} Result of all merge properties
334
- */
335
- function merge(/* obj1, obj2, obj3, ... */) {
336
- var result = {};
337
- function assignValue(val, key) {
338
- if (isPlainObject(result[key]) && isPlainObject(val)) {
339
- result[key] = merge(result[key], val);
340
- } else if (isPlainObject(val)) {
341
- result[key] = merge({}, val);
342
- } else if (isArray(val)) {
343
- result[key] = val.slice();
344
- } else {
345
- result[key] = val;
346
- }
347
- }
348
-
349
- for (var i = 0, l = arguments.length; i < l; i++) {
350
- forEach(arguments[i], assignValue);
351
- }
352
- return result;
353
- }
354
-
355
- /**
356
- * Extends object a by mutably adding to it the properties of object b.
357
- *
358
- * @param {Object} a The object to be extended
359
- * @param {Object} b The object to copy properties from
360
- * @param {Object} thisArg The object to bind function to
361
- * @return {Object} The resulting value of object a
362
- */
363
- function extend(a, b, thisArg) {
364
- forEach(b, function assignValue(val, key) {
365
- if (thisArg && typeof val === 'function') {
366
- a[key] = bind$1(val, thisArg);
367
- } else {
368
- a[key] = val;
369
- }
370
- });
371
- return a;
372
- }
373
-
374
- /**
375
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
376
- *
377
- * @param {string} content with BOM
378
- * @return {string} content value without BOM
379
- */
380
- function stripBOM(content) {
381
- if (content.charCodeAt(0) === 0xFEFF) {
382
- content = content.slice(1);
383
- }
384
- return content;
385
- }
386
-
387
- var utils$9 = {
388
- isArray: isArray,
389
- isArrayBuffer: isArrayBuffer,
390
- isBuffer: isBuffer,
391
- isFormData: isFormData,
392
- isArrayBufferView: isArrayBufferView,
393
- isString: isString,
394
- isNumber: isNumber,
395
- isObject: isObject,
396
- isPlainObject: isPlainObject,
397
- isUndefined: isUndefined,
398
- isDate: isDate,
399
- isFile: isFile,
400
- isBlob: isBlob,
401
- isFunction: isFunction,
402
- isStream: isStream,
403
- isURLSearchParams: isURLSearchParams,
404
- isStandardBrowserEnv: isStandardBrowserEnv,
405
- forEach: forEach,
406
- merge: merge,
407
- extend: extend,
408
- trim: trim,
409
- stripBOM: stripBOM
410
- };var utils$8 = utils$9;
411
-
412
- function encode(val) {
413
- return encodeURIComponent(val).
414
- replace(/%3A/gi, ':').
415
- replace(/%24/g, '$').
416
- replace(/%2C/gi, ',').
417
- replace(/%20/g, '+').
418
- replace(/%5B/gi, '[').
419
- replace(/%5D/gi, ']');
420
- }
421
-
422
- /**
423
- * Build a URL by appending params to the end
424
- *
425
- * @param {string} url The base of the url (e.g., http://www.google.com)
426
- * @param {object} [params] The params to be appended
427
- * @returns {string} The formatted url
428
- */
429
- var buildURL$1 = function buildURL(url, params, paramsSerializer) {
430
- /*eslint no-param-reassign:0*/
431
- if (!params) {
432
- return url;
433
- }
434
-
435
- var serializedParams;
436
- if (paramsSerializer) {
437
- serializedParams = paramsSerializer(params);
438
- } else if (utils$8.isURLSearchParams(params)) {
439
- serializedParams = params.toString();
440
- } else {
441
- var parts = [];
442
-
443
- utils$8.forEach(params, function serialize(val, key) {
444
- if (val === null || typeof val === 'undefined') {
445
- return;
446
- }
447
-
448
- if (utils$8.isArray(val)) {
449
- key = key + '[]';
450
- } else {
451
- val = [val];
452
- }
453
-
454
- utils$8.forEach(val, function parseValue(v) {
455
- if (utils$8.isDate(v)) {
456
- v = v.toISOString();
457
- } else if (utils$8.isObject(v)) {
458
- v = JSON.stringify(v);
459
- }
460
- parts.push(encode(key) + '=' + encode(v));
461
- });
462
- });
463
-
464
- serializedParams = parts.join('&');
465
- }
466
-
467
- if (serializedParams) {
468
- var hashmarkIndex = url.indexOf('#');
469
- if (hashmarkIndex !== -1) {
470
- url = url.slice(0, hashmarkIndex);
471
- }
472
-
473
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
474
- }
475
-
476
- return url;
477
- };var utils$7 = utils$9;
478
-
479
- function InterceptorManager$1() {
480
- this.handlers = [];
481
- }
482
-
483
- /**
484
- * Add a new interceptor to the stack
485
- *
486
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
487
- * @param {Function} rejected The function to handle `reject` for a `Promise`
488
- *
489
- * @return {Number} An ID used to remove interceptor later
490
- */
491
- InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
492
- this.handlers.push({
493
- fulfilled: fulfilled,
494
- rejected: rejected,
495
- synchronous: options ? options.synchronous : false,
496
- runWhen: options ? options.runWhen : null
497
- });
498
- return this.handlers.length - 1;
499
- };
500
-
501
- /**
502
- * Remove an interceptor from the stack
503
- *
504
- * @param {Number} id The ID that was returned by `use`
505
- */
506
- InterceptorManager$1.prototype.eject = function eject(id) {
507
- if (this.handlers[id]) {
508
- this.handlers[id] = null;
509
- }
510
- };
511
-
512
- /**
513
- * Iterate over all the registered interceptors
514
- *
515
- * This method is particularly useful for skipping over any
516
- * interceptors that may have become `null` calling `eject`.
517
- *
518
- * @param {Function} fn The function to call for each interceptor
519
- */
520
- InterceptorManager$1.prototype.forEach = function forEach(fn) {
521
- utils$7.forEach(this.handlers, function forEachHandler(h) {
522
- if (h !== null) {
523
- fn(h);
524
- }
525
- });
526
- };
527
-
528
- var InterceptorManager_1 = InterceptorManager$1;var utils$6 = utils$9;
529
-
530
- var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
531
- utils$6.forEach(headers, function processHeader(value, name) {
532
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
533
- headers[normalizedName] = value;
534
- delete headers[name];
535
- }
536
- });
537
- };/**
538
- * Update an Error with the specified config, error code, and response.
539
- *
540
- * @param {Error} error The error to update.
541
- * @param {Object} config The config.
542
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
543
- * @param {Object} [request] The request.
544
- * @param {Object} [response] The response.
545
- * @returns {Error} The error.
546
- */
547
- var enhanceError$1 = function enhanceError(error, config, code, request, response) {
548
- error.config = config;
549
- if (code) {
550
- error.code = code;
551
- }
552
-
553
- error.request = request;
554
- error.response = response;
555
- error.isAxiosError = true;
556
-
557
- error.toJSON = function toJSON() {
558
- return {
559
- // Standard
560
- message: this.message,
561
- name: this.name,
562
- // Microsoft
563
- description: this.description,
564
- number: this.number,
565
- // Mozilla
566
- fileName: this.fileName,
567
- lineNumber: this.lineNumber,
568
- columnNumber: this.columnNumber,
569
- stack: this.stack,
570
- // Axios
571
- config: this.config,
572
- code: this.code,
573
- status: this.response && this.response.status ? this.response.status : null
574
- };
575
- };
576
- return error;
577
- };var transitional = {
578
- silentJSONParsing: true,
579
- forcedJSONParsing: true,
580
- clarifyTimeoutError: false
581
- };var createError;
582
- var hasRequiredCreateError;
583
-
584
- function requireCreateError () {
585
- if (hasRequiredCreateError) return createError;
586
- hasRequiredCreateError = 1;
587
-
588
- var enhanceError = enhanceError$1;
589
-
590
- /**
591
- * Create an Error with the specified message, config, error code, request and response.
592
- *
593
- * @param {string} message The error message.
594
- * @param {Object} config The config.
595
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
596
- * @param {Object} [request] The request.
597
- * @param {Object} [response] The response.
598
- * @returns {Error} The created error.
599
- */
600
- createError = function createError(message, config, code, request, response) {
601
- var error = new Error(message);
602
- return enhanceError(error, config, code, request, response);
603
- };
604
- return createError;
605
- }var settle;
606
- var hasRequiredSettle;
607
-
608
- function requireSettle () {
609
- if (hasRequiredSettle) return settle;
610
- hasRequiredSettle = 1;
611
-
612
- var createError = requireCreateError();
613
-
614
- /**
615
- * Resolve or reject a Promise based on response status.
616
- *
617
- * @param {Function} resolve A function that resolves the promise.
618
- * @param {Function} reject A function that rejects the promise.
619
- * @param {object} response The response.
620
- */
621
- settle = function settle(resolve, reject, response) {
622
- var validateStatus = response.config.validateStatus;
623
- if (!response.status || !validateStatus || validateStatus(response.status)) {
624
- resolve(response);
625
- } else {
626
- reject(createError(
627
- 'Request failed with status code ' + response.status,
628
- response.config,
629
- null,
630
- response.request,
631
- response
632
- ));
633
- }
634
- };
635
- return settle;
636
- }var cookies;
637
- var hasRequiredCookies;
638
-
639
- function requireCookies () {
640
- if (hasRequiredCookies) return cookies;
641
- hasRequiredCookies = 1;
642
-
643
- var utils = utils$9;
644
-
645
- cookies = (
646
- utils.isStandardBrowserEnv() ?
647
-
648
- // Standard browser envs support document.cookie
649
- (function standardBrowserEnv() {
650
- return {
651
- write: function write(name, value, expires, path, domain, secure) {
652
- var cookie = [];
653
- cookie.push(name + '=' + encodeURIComponent(value));
654
-
655
- if (utils.isNumber(expires)) {
656
- cookie.push('expires=' + new Date(expires).toGMTString());
657
- }
658
-
659
- if (utils.isString(path)) {
660
- cookie.push('path=' + path);
661
- }
662
-
663
- if (utils.isString(domain)) {
664
- cookie.push('domain=' + domain);
665
- }
666
-
667
- if (secure === true) {
668
- cookie.push('secure');
669
- }
670
-
671
- document.cookie = cookie.join('; ');
672
- },
673
-
674
- read: function read(name) {
675
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
676
- return (match ? decodeURIComponent(match[3]) : null);
677
- },
678
-
679
- remove: function remove(name) {
680
- this.write(name, '', Date.now() - 86400000);
681
- }
682
- };
683
- })() :
684
-
685
- // Non standard browser env (web workers, react-native) lack needed support.
686
- (function nonStandardBrowserEnv() {
687
- return {
688
- write: function write() {},
689
- read: function read() { return null; },
690
- remove: function remove() {}
691
- };
692
- })()
693
- );
694
- return cookies;
695
- }var isAbsoluteURL;
696
- var hasRequiredIsAbsoluteURL;
697
-
698
- function requireIsAbsoluteURL () {
699
- if (hasRequiredIsAbsoluteURL) return isAbsoluteURL;
700
- hasRequiredIsAbsoluteURL = 1;
701
-
702
- /**
703
- * Determines whether the specified URL is absolute
704
- *
705
- * @param {string} url The URL to test
706
- * @returns {boolean} True if the specified URL is absolute, otherwise false
707
- */
708
- isAbsoluteURL = function isAbsoluteURL(url) {
709
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
710
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
711
- // by any combination of letters, digits, plus, period, or hyphen.
712
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
713
- };
714
- return isAbsoluteURL;
715
- }var combineURLs;
716
- var hasRequiredCombineURLs;
717
-
718
- function requireCombineURLs () {
719
- if (hasRequiredCombineURLs) return combineURLs;
720
- hasRequiredCombineURLs = 1;
721
-
722
- /**
723
- * Creates a new URL by combining the specified URLs
724
- *
725
- * @param {string} baseURL The base URL
726
- * @param {string} relativeURL The relative URL
727
- * @returns {string} The combined URL
728
- */
729
- combineURLs = function combineURLs(baseURL, relativeURL) {
730
- return relativeURL
731
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
732
- : baseURL;
733
- };
734
- return combineURLs;
735
- }var buildFullPath;
736
- var hasRequiredBuildFullPath;
737
-
738
- function requireBuildFullPath () {
739
- if (hasRequiredBuildFullPath) return buildFullPath;
740
- hasRequiredBuildFullPath = 1;
741
-
742
- var isAbsoluteURL = requireIsAbsoluteURL();
743
- var combineURLs = requireCombineURLs();
744
-
745
- /**
746
- * Creates a new URL by combining the baseURL with the requestedURL,
747
- * only when the requestedURL is not already an absolute URL.
748
- * If the requestURL is absolute, this function returns the requestedURL untouched.
749
- *
750
- * @param {string} baseURL The base URL
751
- * @param {string} requestedURL Absolute or relative URL to combine
752
- * @returns {string} The combined full path
753
- */
754
- buildFullPath = function buildFullPath(baseURL, requestedURL) {
755
- if (baseURL && !isAbsoluteURL(requestedURL)) {
756
- return combineURLs(baseURL, requestedURL);
757
- }
758
- return requestedURL;
759
- };
760
- return buildFullPath;
761
- }var parseHeaders;
762
- var hasRequiredParseHeaders;
763
-
764
- function requireParseHeaders () {
765
- if (hasRequiredParseHeaders) return parseHeaders;
766
- hasRequiredParseHeaders = 1;
767
-
768
- var utils = utils$9;
769
-
770
- // Headers whose duplicates are ignored by node
771
- // c.f. https://nodejs.org/api/http.html#http_message_headers
772
- var ignoreDuplicateOf = [
773
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
774
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
775
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
776
- 'referer', 'retry-after', 'user-agent'
777
- ];
778
-
779
- /**
780
- * Parse headers into an object
781
- *
782
- * ```
783
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
784
- * Content-Type: application/json
785
- * Connection: keep-alive
786
- * Transfer-Encoding: chunked
787
- * ```
788
- *
789
- * @param {String} headers Headers needing to be parsed
790
- * @returns {Object} Headers parsed into an object
791
- */
792
- parseHeaders = function parseHeaders(headers) {
793
- var parsed = {};
794
- var key;
795
- var val;
796
- var i;
797
-
798
- if (!headers) { return parsed; }
799
-
800
- utils.forEach(headers.split('\n'), function parser(line) {
801
- i = line.indexOf(':');
802
- key = utils.trim(line.substr(0, i)).toLowerCase();
803
- val = utils.trim(line.substr(i + 1));
804
-
805
- if (key) {
806
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
807
- return;
808
- }
809
- if (key === 'set-cookie') {
810
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
811
- } else {
812
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
813
- }
814
- }
815
- });
816
-
817
- return parsed;
818
- };
819
- return parseHeaders;
820
- }var isURLSameOrigin;
821
- var hasRequiredIsURLSameOrigin;
822
-
823
- function requireIsURLSameOrigin () {
824
- if (hasRequiredIsURLSameOrigin) return isURLSameOrigin;
825
- hasRequiredIsURLSameOrigin = 1;
826
-
827
- var utils = utils$9;
828
-
829
- isURLSameOrigin = (
830
- utils.isStandardBrowserEnv() ?
831
-
832
- // Standard browser envs have full support of the APIs needed to test
833
- // whether the request URL is of the same origin as current location.
834
- (function standardBrowserEnv() {
835
- var msie = /(msie|trident)/i.test(navigator.userAgent);
836
- var urlParsingNode = document.createElement('a');
837
- var originURL;
838
-
839
- /**
840
- * Parse a URL to discover it's components
841
- *
842
- * @param {String} url The URL to be parsed
843
- * @returns {Object}
844
- */
845
- function resolveURL(url) {
846
- var href = url;
847
-
848
- if (msie) {
849
- // IE needs attribute set twice to normalize properties
850
- urlParsingNode.setAttribute('href', href);
851
- href = urlParsingNode.href;
852
- }
853
-
854
- urlParsingNode.setAttribute('href', href);
855
-
856
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
857
- return {
858
- href: urlParsingNode.href,
859
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
860
- host: urlParsingNode.host,
861
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
862
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
863
- hostname: urlParsingNode.hostname,
864
- port: urlParsingNode.port,
865
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
866
- urlParsingNode.pathname :
867
- '/' + urlParsingNode.pathname
868
- };
869
- }
870
-
871
- originURL = resolveURL(window.location.href);
872
-
873
- /**
874
- * Determine if a URL shares the same origin as the current location
875
- *
876
- * @param {String} requestURL The URL to test
877
- * @returns {boolean} True if URL shares the same origin, otherwise false
878
- */
879
- return function isURLSameOrigin(requestURL) {
880
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
881
- return (parsed.protocol === originURL.protocol &&
882
- parsed.host === originURL.host);
883
- };
884
- })() :
885
-
886
- // Non standard browser envs (web workers, react-native) lack needed support.
887
- (function nonStandardBrowserEnv() {
888
- return function isURLSameOrigin() {
889
- return true;
890
- };
891
- })()
892
- );
893
- return isURLSameOrigin;
894
- }var Cancel_1;
895
- var hasRequiredCancel;
896
-
897
- function requireCancel () {
898
- if (hasRequiredCancel) return Cancel_1;
899
- hasRequiredCancel = 1;
900
-
901
- /**
902
- * A `Cancel` is an object that is thrown when an operation is canceled.
903
- *
904
- * @class
905
- * @param {string=} message The message.
906
- */
907
- function Cancel(message) {
908
- this.message = message;
909
- }
910
-
911
- Cancel.prototype.toString = function toString() {
912
- return 'Cancel' + (this.message ? ': ' + this.message : '');
913
- };
914
-
915
- Cancel.prototype.__CANCEL__ = true;
916
-
917
- Cancel_1 = Cancel;
918
- return Cancel_1;
919
- }var xhr;
920
- var hasRequiredXhr;
921
-
922
- function requireXhr () {
923
- if (hasRequiredXhr) return xhr;
924
- hasRequiredXhr = 1;
925
-
926
- var utils = utils$9;
927
- var settle = requireSettle();
928
- var cookies = requireCookies();
929
- var buildURL = buildURL$1;
930
- var buildFullPath = requireBuildFullPath();
931
- var parseHeaders = requireParseHeaders();
932
- var isURLSameOrigin = requireIsURLSameOrigin();
933
- var createError = requireCreateError();
934
- var transitionalDefaults = transitional;
935
- var Cancel = requireCancel();
936
-
937
- xhr = function xhrAdapter(config) {
938
- return new Promise(function dispatchXhrRequest(resolve, reject) {
939
- var requestData = config.data;
940
- var requestHeaders = config.headers;
941
- var responseType = config.responseType;
942
- var onCanceled;
943
- function done() {
944
- if (config.cancelToken) {
945
- config.cancelToken.unsubscribe(onCanceled);
946
- }
947
-
948
- if (config.signal) {
949
- config.signal.removeEventListener('abort', onCanceled);
950
- }
951
- }
952
-
953
- if (utils.isFormData(requestData)) {
954
- delete requestHeaders['Content-Type']; // Let the browser set it
955
- }
956
-
957
- var request = new XMLHttpRequest();
958
-
959
- // HTTP basic authentication
960
- if (config.auth) {
961
- var username = config.auth.username || '';
962
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
963
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
964
- }
965
-
966
- var fullPath = buildFullPath(config.baseURL, config.url);
967
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
968
-
969
- // Set the request timeout in MS
970
- request.timeout = config.timeout;
971
-
972
- function onloadend() {
973
- if (!request) {
974
- return;
975
- }
976
- // Prepare the response
977
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
978
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
979
- request.responseText : request.response;
980
- var response = {
981
- data: responseData,
982
- status: request.status,
983
- statusText: request.statusText,
984
- headers: responseHeaders,
985
- config: config,
986
- request: request
987
- };
988
-
989
- settle(function _resolve(value) {
990
- resolve(value);
991
- done();
992
- }, function _reject(err) {
993
- reject(err);
994
- done();
995
- }, response);
996
-
997
- // Clean up request
998
- request = null;
999
- }
1000
-
1001
- if ('onloadend' in request) {
1002
- // Use onloadend if available
1003
- request.onloadend = onloadend;
1004
- } else {
1005
- // Listen for ready state to emulate onloadend
1006
- request.onreadystatechange = function handleLoad() {
1007
- if (!request || request.readyState !== 4) {
1008
- return;
1009
- }
1010
-
1011
- // The request errored out and we didn't get a response, this will be
1012
- // handled by onerror instead
1013
- // With one exception: request that using file: protocol, most browsers
1014
- // will return status as 0 even though it's a successful request
1015
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1016
- return;
1017
- }
1018
- // readystate handler is calling before onerror or ontimeout handlers,
1019
- // so we should call onloadend on the next 'tick'
1020
- setTimeout(onloadend);
1021
- };
1022
- }
1023
-
1024
- // Handle browser request cancellation (as opposed to a manual cancellation)
1025
- request.onabort = function handleAbort() {
1026
- if (!request) {
1027
- return;
1028
- }
1029
-
1030
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
1031
-
1032
- // Clean up request
1033
- request = null;
1034
- };
1035
-
1036
- // Handle low level network errors
1037
- request.onerror = function handleError() {
1038
- // Real errors are hidden from us by the browser
1039
- // onerror should only fire if it's a network error
1040
- reject(createError('Network Error', config, null, request));
1041
-
1042
- // Clean up request
1043
- request = null;
1044
- };
1045
-
1046
- // Handle timeout
1047
- request.ontimeout = function handleTimeout() {
1048
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1049
- var transitional = config.transitional || transitionalDefaults;
1050
- if (config.timeoutErrorMessage) {
1051
- timeoutErrorMessage = config.timeoutErrorMessage;
1052
- }
1053
- reject(createError(
1054
- timeoutErrorMessage,
1055
- config,
1056
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
1057
- request));
1058
-
1059
- // Clean up request
1060
- request = null;
1061
- };
1062
-
1063
- // Add xsrf header
1064
- // This is only done if running in a standard browser environment.
1065
- // Specifically not if we're in a web worker, or react-native.
1066
- if (utils.isStandardBrowserEnv()) {
1067
- // Add xsrf header
1068
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
1069
- cookies.read(config.xsrfCookieName) :
1070
- undefined;
1071
-
1072
- if (xsrfValue) {
1073
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
1074
- }
1075
- }
1076
-
1077
- // Add headers to the request
1078
- if ('setRequestHeader' in request) {
1079
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1080
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1081
- // Remove Content-Type if data is undefined
1082
- delete requestHeaders[key];
1083
- } else {
1084
- // Otherwise add header to the request
1085
- request.setRequestHeader(key, val);
1086
- }
1087
- });
1088
- }
1089
-
1090
- // Add withCredentials to request if needed
1091
- if (!utils.isUndefined(config.withCredentials)) {
1092
- request.withCredentials = !!config.withCredentials;
1093
- }
1094
-
1095
- // Add responseType to request if needed
1096
- if (responseType && responseType !== 'json') {
1097
- request.responseType = config.responseType;
1098
- }
1099
-
1100
- // Handle progress if needed
1101
- if (typeof config.onDownloadProgress === 'function') {
1102
- request.addEventListener('progress', config.onDownloadProgress);
1103
- }
1104
-
1105
- // Not all browsers support upload events
1106
- if (typeof config.onUploadProgress === 'function' && request.upload) {
1107
- request.upload.addEventListener('progress', config.onUploadProgress);
1108
- }
1109
-
1110
- if (config.cancelToken || config.signal) {
1111
- // Handle cancellation
1112
- // eslint-disable-next-line func-names
1113
- onCanceled = function(cancel) {
1114
- if (!request) {
1115
- return;
1116
- }
1117
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
1118
- request.abort();
1119
- request = null;
1120
- };
1121
-
1122
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
1123
- if (config.signal) {
1124
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1125
- }
1126
- }
1127
-
1128
- if (!requestData) {
1129
- requestData = null;
1130
- }
1131
-
1132
- // Send the request
1133
- request.send(requestData);
1134
- });
1135
- };
1136
- return xhr;
1137
- }var followRedirects = {exports: {}};var src = {exports: {}};var browser = {exports: {}};/**
1138
- * Helpers.
1139
- */
1140
-
1141
- var ms;
1142
- var hasRequiredMs;
1143
-
1144
- function requireMs () {
1145
- if (hasRequiredMs) return ms;
1146
- hasRequiredMs = 1;
1147
- var s = 1000;
1148
- var m = s * 60;
1149
- var h = m * 60;
1150
- var d = h * 24;
1151
- var w = d * 7;
1152
- var y = d * 365.25;
1153
-
1154
- /**
1155
- * Parse or format the given `val`.
1156
- *
1157
- * Options:
1158
- *
1159
- * - `long` verbose formatting [false]
1160
- *
1161
- * @param {String|Number} val
1162
- * @param {Object} [options]
1163
- * @throws {Error} throw an error if val is not a non-empty string or a number
1164
- * @return {String|Number}
1165
- * @api public
1166
- */
1167
-
1168
- ms = function (val, options) {
1169
- options = options || {};
1170
- var type = typeof val;
1171
- if (type === 'string' && val.length > 0) {
1172
- return parse(val);
1173
- } else if (type === 'number' && isFinite(val)) {
1174
- return options.long ? fmtLong(val) : fmtShort(val);
1175
- }
1176
- throw new Error(
1177
- 'val is not a non-empty string or a valid number. val=' +
1178
- JSON.stringify(val)
1179
- );
1180
- };
1181
-
1182
- /**
1183
- * Parse the given `str` and return milliseconds.
1184
- *
1185
- * @param {String} str
1186
- * @return {Number}
1187
- * @api private
1188
- */
1189
-
1190
- function parse(str) {
1191
- str = String(str);
1192
- if (str.length > 100) {
1193
- return;
1194
- }
1195
- 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(
1196
- str
1197
- );
1198
- if (!match) {
1199
- return;
1200
- }
1201
- var n = parseFloat(match[1]);
1202
- var type = (match[2] || 'ms').toLowerCase();
1203
- switch (type) {
1204
- case 'years':
1205
- case 'year':
1206
- case 'yrs':
1207
- case 'yr':
1208
- case 'y':
1209
- return n * y;
1210
- case 'weeks':
1211
- case 'week':
1212
- case 'w':
1213
- return n * w;
1214
- case 'days':
1215
- case 'day':
1216
- case 'd':
1217
- return n * d;
1218
- case 'hours':
1219
- case 'hour':
1220
- case 'hrs':
1221
- case 'hr':
1222
- case 'h':
1223
- return n * h;
1224
- case 'minutes':
1225
- case 'minute':
1226
- case 'mins':
1227
- case 'min':
1228
- case 'm':
1229
- return n * m;
1230
- case 'seconds':
1231
- case 'second':
1232
- case 'secs':
1233
- case 'sec':
1234
- case 's':
1235
- return n * s;
1236
- case 'milliseconds':
1237
- case 'millisecond':
1238
- case 'msecs':
1239
- case 'msec':
1240
- case 'ms':
1241
- return n;
1242
- default:
1243
- return undefined;
1244
- }
1245
- }
1246
-
1247
- /**
1248
- * Short format for `ms`.
1249
- *
1250
- * @param {Number} ms
1251
- * @return {String}
1252
- * @api private
1253
- */
1254
-
1255
- function fmtShort(ms) {
1256
- var msAbs = Math.abs(ms);
1257
- if (msAbs >= d) {
1258
- return Math.round(ms / d) + 'd';
1259
- }
1260
- if (msAbs >= h) {
1261
- return Math.round(ms / h) + 'h';
1262
- }
1263
- if (msAbs >= m) {
1264
- return Math.round(ms / m) + 'm';
1265
- }
1266
- if (msAbs >= s) {
1267
- return Math.round(ms / s) + 's';
1268
- }
1269
- return ms + 'ms';
1270
- }
1271
-
1272
- /**
1273
- * Long format for `ms`.
1274
- *
1275
- * @param {Number} ms
1276
- * @return {String}
1277
- * @api private
1278
- */
1279
-
1280
- function fmtLong(ms) {
1281
- var msAbs = Math.abs(ms);
1282
- if (msAbs >= d) {
1283
- return plural(ms, msAbs, d, 'day');
1284
- }
1285
- if (msAbs >= h) {
1286
- return plural(ms, msAbs, h, 'hour');
1287
- }
1288
- if (msAbs >= m) {
1289
- return plural(ms, msAbs, m, 'minute');
1290
- }
1291
- if (msAbs >= s) {
1292
- return plural(ms, msAbs, s, 'second');
1293
- }
1294
- return ms + ' ms';
1295
- }
1296
-
1297
- /**
1298
- * Pluralization helper.
1299
- */
1300
-
1301
- function plural(ms, msAbs, n, name) {
1302
- var isPlural = msAbs >= n * 1.5;
1303
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1304
- }
1305
- return ms;
1306
- }var common;
1307
- var hasRequiredCommon;
1308
-
1309
- function requireCommon () {
1310
- if (hasRequiredCommon) return common;
1311
- hasRequiredCommon = 1;
1312
- /**
1313
- * This is the common logic for both the Node.js and web browser
1314
- * implementations of `debug()`.
1315
- */
1316
-
1317
- function setup(env) {
1318
- createDebug.debug = createDebug;
1319
- createDebug.default = createDebug;
1320
- createDebug.coerce = coerce;
1321
- createDebug.disable = disable;
1322
- createDebug.enable = enable;
1323
- createDebug.enabled = enabled;
1324
- createDebug.humanize = requireMs();
1325
- createDebug.destroy = destroy;
1326
-
1327
- Object.keys(env).forEach(key => {
1328
- createDebug[key] = env[key];
1329
- });
1330
-
1331
- /**
1332
- * The currently active debug mode names, and names to skip.
1333
- */
1334
-
1335
- createDebug.names = [];
1336
- createDebug.skips = [];
1337
-
1338
- /**
1339
- * Map of special "%n" handling functions, for the debug "format" argument.
1340
- *
1341
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
1342
- */
1343
- createDebug.formatters = {};
1344
-
1345
- /**
1346
- * Selects a color for a debug namespace
1347
- * @param {String} namespace The namespace string for the debug instance to be colored
1348
- * @return {Number|String} An ANSI color code for the given namespace
1349
- * @api private
1350
- */
1351
- function selectColor(namespace) {
1352
- let hash = 0;
1353
-
1354
- for (let i = 0; i < namespace.length; i++) {
1355
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
1356
- hash |= 0; // Convert to 32bit integer
1357
- }
1358
-
1359
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1360
- }
1361
- createDebug.selectColor = selectColor;
1362
-
1363
- /**
1364
- * Create a debugger with the given `namespace`.
1365
- *
1366
- * @param {String} namespace
1367
- * @return {Function}
1368
- * @api public
1369
- */
1370
- function createDebug(namespace) {
1371
- let prevTime;
1372
- let enableOverride = null;
1373
- let namespacesCache;
1374
- let enabledCache;
1375
-
1376
- function debug(...args) {
1377
- // Disabled?
1378
- if (!debug.enabled) {
1379
- return;
1380
- }
1381
-
1382
- const self = debug;
1383
-
1384
- // Set `diff` timestamp
1385
- const curr = Number(new Date());
1386
- const ms = curr - (prevTime || curr);
1387
- self.diff = ms;
1388
- self.prev = prevTime;
1389
- self.curr = curr;
1390
- prevTime = curr;
1391
-
1392
- args[0] = createDebug.coerce(args[0]);
1393
-
1394
- if (typeof args[0] !== 'string') {
1395
- // Anything else let's inspect with %O
1396
- args.unshift('%O');
1397
- }
1398
-
1399
- // Apply any `formatters` transformations
1400
- let index = 0;
1401
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1402
- // If we encounter an escaped % then don't increase the array index
1403
- if (match === '%%') {
1404
- return '%';
1405
- }
1406
- index++;
1407
- const formatter = createDebug.formatters[format];
1408
- if (typeof formatter === 'function') {
1409
- const val = args[index];
1410
- match = formatter.call(self, val);
1411
-
1412
- // Now we need to remove `args[index]` since it's inlined in the `format`
1413
- args.splice(index, 1);
1414
- index--;
1415
- }
1416
- return match;
1417
- });
1418
-
1419
- // Apply env-specific formatting (colors, etc.)
1420
- createDebug.formatArgs.call(self, args);
1421
-
1422
- const logFn = self.log || createDebug.log;
1423
- logFn.apply(self, args);
1424
- }
1425
-
1426
- debug.namespace = namespace;
1427
- debug.useColors = createDebug.useColors();
1428
- debug.color = createDebug.selectColor(namespace);
1429
- debug.extend = extend;
1430
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
1431
-
1432
- Object.defineProperty(debug, 'enabled', {
1433
- enumerable: true,
1434
- configurable: false,
1435
- get: () => {
1436
- if (enableOverride !== null) {
1437
- return enableOverride;
1438
- }
1439
- if (namespacesCache !== createDebug.namespaces) {
1440
- namespacesCache = createDebug.namespaces;
1441
- enabledCache = createDebug.enabled(namespace);
1442
- }
1443
-
1444
- return enabledCache;
1445
- },
1446
- set: v => {
1447
- enableOverride = v;
1448
- }
1449
- });
1450
-
1451
- // Env-specific initialization logic for debug instances
1452
- if (typeof createDebug.init === 'function') {
1453
- createDebug.init(debug);
1454
- }
1455
-
1456
- return debug;
1457
- }
1458
-
1459
- function extend(namespace, delimiter) {
1460
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1461
- newDebug.log = this.log;
1462
- return newDebug;
1463
- }
1464
-
1465
- /**
1466
- * Enables a debug mode by namespaces. This can include modes
1467
- * separated by a colon and wildcards.
1468
- *
1469
- * @param {String} namespaces
1470
- * @api public
1471
- */
1472
- function enable(namespaces) {
1473
- createDebug.save(namespaces);
1474
- createDebug.namespaces = namespaces;
1475
-
1476
- createDebug.names = [];
1477
- createDebug.skips = [];
1478
-
1479
- const split = (typeof namespaces === 'string' ? namespaces : '')
1480
- .trim()
1481
- .replace(' ', ',')
1482
- .split(',')
1483
- .filter(Boolean);
1484
-
1485
- for (const ns of split) {
1486
- if (ns[0] === '-') {
1487
- createDebug.skips.push(ns.slice(1));
1488
- } else {
1489
- createDebug.names.push(ns);
1490
- }
1491
- }
1492
- }
1493
-
1494
- /**
1495
- * Checks if the given string matches a namespace template, honoring
1496
- * asterisks as wildcards.
1497
- *
1498
- * @param {String} search
1499
- * @param {String} template
1500
- * @return {Boolean}
1501
- */
1502
- function matchesTemplate(search, template) {
1503
- let searchIndex = 0;
1504
- let templateIndex = 0;
1505
- let starIndex = -1;
1506
- let matchIndex = 0;
1507
-
1508
- while (searchIndex < search.length) {
1509
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
1510
- // Match character or proceed with wildcard
1511
- if (template[templateIndex] === '*') {
1512
- starIndex = templateIndex;
1513
- matchIndex = searchIndex;
1514
- templateIndex++; // Skip the '*'
1515
- } else {
1516
- searchIndex++;
1517
- templateIndex++;
1518
- }
1519
- } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
1520
- // Backtrack to the last '*' and try to match more characters
1521
- templateIndex = starIndex + 1;
1522
- matchIndex++;
1523
- searchIndex = matchIndex;
1524
- } else {
1525
- return false; // No match
1526
- }
1527
- }
1528
-
1529
- // Handle trailing '*' in template
1530
- while (templateIndex < template.length && template[templateIndex] === '*') {
1531
- templateIndex++;
1532
- }
1533
-
1534
- return templateIndex === template.length;
1535
- }
1536
-
1537
- /**
1538
- * Disable debug output.
1539
- *
1540
- * @return {String} namespaces
1541
- * @api public
1542
- */
1543
- function disable() {
1544
- const namespaces = [
1545
- ...createDebug.names,
1546
- ...createDebug.skips.map(namespace => '-' + namespace)
1547
- ].join(',');
1548
- createDebug.enable('');
1549
- return namespaces;
1550
- }
1551
-
1552
- /**
1553
- * Returns true if the given mode name is enabled, false otherwise.
1554
- *
1555
- * @param {String} name
1556
- * @return {Boolean}
1557
- * @api public
1558
- */
1559
- function enabled(name) {
1560
- for (const skip of createDebug.skips) {
1561
- if (matchesTemplate(name, skip)) {
1562
- return false;
1563
- }
1564
- }
1565
-
1566
- for (const ns of createDebug.names) {
1567
- if (matchesTemplate(name, ns)) {
1568
- return true;
1569
- }
1570
- }
1571
-
1572
- return false;
1573
- }
1574
-
1575
- /**
1576
- * Coerce `val`.
1577
- *
1578
- * @param {Mixed} val
1579
- * @return {Mixed}
1580
- * @api private
1581
- */
1582
- function coerce(val) {
1583
- if (val instanceof Error) {
1584
- return val.stack || val.message;
1585
- }
1586
- return val;
1587
- }
1588
-
1589
- /**
1590
- * XXX DO NOT USE. This is a temporary stub function.
1591
- * XXX It WILL be removed in the next major release.
1592
- */
1593
- function destroy() {
1594
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1595
- }
1596
-
1597
- createDebug.enable(createDebug.load());
1598
-
1599
- return createDebug;
1600
- }
1601
-
1602
- common = setup;
1603
- return common;
1604
- }/* eslint-env browser */
1605
-
1606
- var hasRequiredBrowser;
1607
-
1608
- function requireBrowser () {
1609
- if (hasRequiredBrowser) return browser.exports;
1610
- hasRequiredBrowser = 1;
1611
- (function (module, exports) {
1612
- /**
1613
- * This is the web browser implementation of `debug()`.
1614
- */
1615
-
1616
- exports.formatArgs = formatArgs;
1617
- exports.save = save;
1618
- exports.load = load;
1619
- exports.useColors = useColors;
1620
- exports.storage = localstorage();
1621
- exports.destroy = (() => {
1622
- let warned = false;
1623
-
1624
- return () => {
1625
- if (!warned) {
1626
- warned = true;
1627
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1628
- }
1629
- };
1630
- })();
1631
-
1632
- /**
1633
- * Colors.
1634
- */
1635
-
1636
- exports.colors = [
1637
- '#0000CC',
1638
- '#0000FF',
1639
- '#0033CC',
1640
- '#0033FF',
1641
- '#0066CC',
1642
- '#0066FF',
1643
- '#0099CC',
1644
- '#0099FF',
1645
- '#00CC00',
1646
- '#00CC33',
1647
- '#00CC66',
1648
- '#00CC99',
1649
- '#00CCCC',
1650
- '#00CCFF',
1651
- '#3300CC',
1652
- '#3300FF',
1653
- '#3333CC',
1654
- '#3333FF',
1655
- '#3366CC',
1656
- '#3366FF',
1657
- '#3399CC',
1658
- '#3399FF',
1659
- '#33CC00',
1660
- '#33CC33',
1661
- '#33CC66',
1662
- '#33CC99',
1663
- '#33CCCC',
1664
- '#33CCFF',
1665
- '#6600CC',
1666
- '#6600FF',
1667
- '#6633CC',
1668
- '#6633FF',
1669
- '#66CC00',
1670
- '#66CC33',
1671
- '#9900CC',
1672
- '#9900FF',
1673
- '#9933CC',
1674
- '#9933FF',
1675
- '#99CC00',
1676
- '#99CC33',
1677
- '#CC0000',
1678
- '#CC0033',
1679
- '#CC0066',
1680
- '#CC0099',
1681
- '#CC00CC',
1682
- '#CC00FF',
1683
- '#CC3300',
1684
- '#CC3333',
1685
- '#CC3366',
1686
- '#CC3399',
1687
- '#CC33CC',
1688
- '#CC33FF',
1689
- '#CC6600',
1690
- '#CC6633',
1691
- '#CC9900',
1692
- '#CC9933',
1693
- '#CCCC00',
1694
- '#CCCC33',
1695
- '#FF0000',
1696
- '#FF0033',
1697
- '#FF0066',
1698
- '#FF0099',
1699
- '#FF00CC',
1700
- '#FF00FF',
1701
- '#FF3300',
1702
- '#FF3333',
1703
- '#FF3366',
1704
- '#FF3399',
1705
- '#FF33CC',
1706
- '#FF33FF',
1707
- '#FF6600',
1708
- '#FF6633',
1709
- '#FF9900',
1710
- '#FF9933',
1711
- '#FFCC00',
1712
- '#FFCC33'
1713
- ];
1714
-
1715
- /**
1716
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1717
- * and the Firebug extension (any Firefox version) are known
1718
- * to support "%c" CSS customizations.
1719
- *
1720
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
1721
- */
1722
-
1723
- // eslint-disable-next-line complexity
1724
- function useColors() {
1725
- // NB: In an Electron preload script, document will be defined but not fully
1726
- // initialized. Since we know we're in Chrome, we'll just detect this case
1727
- // explicitly
1728
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1729
- return true;
1730
- }
1731
-
1732
- // Internet Explorer and Edge do not support colors.
1733
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1734
- return false;
1735
- }
1736
-
1737
- let m;
1738
-
1739
- // Is webkit? http://stackoverflow.com/a/16459606/376773
1740
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1741
- // eslint-disable-next-line no-return-assign
1742
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1743
- // Is firebug? http://stackoverflow.com/a/398120/376773
1744
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1745
- // Is firefox >= v31?
1746
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1747
- (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
1748
- // Double check webkit in userAgent just in case we are in a worker
1749
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1750
- }
1751
-
1752
- /**
1753
- * Colorize log arguments if enabled.
1754
- *
1755
- * @api public
1756
- */
1757
-
1758
- function formatArgs(args) {
1759
- args[0] = (this.useColors ? '%c' : '') +
1760
- this.namespace +
1761
- (this.useColors ? ' %c' : ' ') +
1762
- args[0] +
1763
- (this.useColors ? '%c ' : ' ') +
1764
- '+' + module.exports.humanize(this.diff);
1765
-
1766
- if (!this.useColors) {
1767
- return;
1768
- }
1769
-
1770
- const c = 'color: ' + this.color;
1771
- args.splice(1, 0, c, 'color: inherit');
1772
-
1773
- // The final "%c" is somewhat tricky, because there could be other
1774
- // arguments passed either before or after the %c, so we need to
1775
- // figure out the correct index to insert the CSS into
1776
- let index = 0;
1777
- let lastC = 0;
1778
- args[0].replace(/%[a-zA-Z%]/g, match => {
1779
- if (match === '%%') {
1780
- return;
1781
- }
1782
- index++;
1783
- if (match === '%c') {
1784
- // We only are interested in the *last* %c
1785
- // (the user may have provided their own)
1786
- lastC = index;
1787
- }
1788
- });
1789
-
1790
- args.splice(lastC, 0, c);
1791
- }
1792
-
1793
- /**
1794
- * Invokes `console.debug()` when available.
1795
- * No-op when `console.debug` is not a "function".
1796
- * If `console.debug` is not available, falls back
1797
- * to `console.log`.
1798
- *
1799
- * @api public
1800
- */
1801
- exports.log = console.debug || console.log || (() => {});
1802
-
1803
- /**
1804
- * Save `namespaces`.
1805
- *
1806
- * @param {String} namespaces
1807
- * @api private
1808
- */
1809
- function save(namespaces) {
1810
- try {
1811
- if (namespaces) {
1812
- exports.storage.setItem('debug', namespaces);
1813
- } else {
1814
- exports.storage.removeItem('debug');
1815
- }
1816
- } catch (error) {
1817
- // Swallow
1818
- // XXX (@Qix-) should we be logging these?
1819
- }
1820
- }
1821
-
1822
- /**
1823
- * Load `namespaces`.
1824
- *
1825
- * @return {String} returns the previously persisted debug modes
1826
- * @api private
1827
- */
1828
- function load() {
1829
- let r;
1830
- try {
1831
- r = exports.storage.getItem('debug');
1832
- } catch (error) {
1833
- // Swallow
1834
- // XXX (@Qix-) should we be logging these?
1835
- }
1836
-
1837
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1838
- if (!r && typeof process !== 'undefined' && 'env' in process) {
1839
- r = process.env.DEBUG;
1840
- }
1841
-
1842
- return r;
1843
- }
1844
-
1845
- /**
1846
- * Localstorage attempts to return the localstorage.
1847
- *
1848
- * This is necessary because safari throws
1849
- * when a user disables cookies/localstorage
1850
- * and you attempt to access it.
1851
- *
1852
- * @return {LocalStorage}
1853
- * @api private
1854
- */
1855
-
1856
- function localstorage() {
1857
- try {
1858
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1859
- // The Browser also has localStorage in the global context.
1860
- return localStorage;
1861
- } catch (error) {
1862
- // Swallow
1863
- // XXX (@Qix-) should we be logging these?
1864
- }
1865
- }
1866
-
1867
- module.exports = requireCommon()(exports);
1868
-
1869
- const {formatters} = module.exports;
1870
-
1871
- /**
1872
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1873
- */
1874
-
1875
- formatters.j = function (v) {
1876
- try {
1877
- return JSON.stringify(v);
1878
- } catch (error) {
1879
- return '[UnexpectedJSONParseError]: ' + error.message;
1880
- }
1881
- };
1882
- } (browser, browser.exports));
1883
- return browser.exports;
1884
- }var node = {exports: {}};var hasFlag;
1885
- var hasRequiredHasFlag;
1886
-
1887
- function requireHasFlag () {
1888
- if (hasRequiredHasFlag) return hasFlag;
1889
- hasRequiredHasFlag = 1;
1890
- hasFlag = (flag, argv) => {
1891
- argv = argv || process.argv;
1892
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
1893
- const pos = argv.indexOf(prefix + flag);
1894
- const terminatorPos = argv.indexOf('--');
1895
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1896
- };
1897
- return hasFlag;
1898
- }var supportsColor_1;
1899
- var hasRequiredSupportsColor;
1900
-
1901
- function requireSupportsColor () {
1902
- if (hasRequiredSupportsColor) return supportsColor_1;
1903
- hasRequiredSupportsColor = 1;
1904
- const os = require$$0;
1905
- const hasFlag = requireHasFlag();
1906
-
1907
- const env = process.env;
1908
-
1909
- let forceColor;
1910
- if (hasFlag('no-color') ||
1911
- hasFlag('no-colors') ||
1912
- hasFlag('color=false')) {
1913
- forceColor = false;
1914
- } else if (hasFlag('color') ||
1915
- hasFlag('colors') ||
1916
- hasFlag('color=true') ||
1917
- hasFlag('color=always')) {
1918
- forceColor = true;
1919
- }
1920
- if ('FORCE_COLOR' in env) {
1921
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
1922
- }
1923
-
1924
- function translateLevel(level) {
1925
- if (level === 0) {
1926
- return false;
1927
- }
1928
-
1929
- return {
1930
- level,
1931
- hasBasic: true,
1932
- has256: level >= 2,
1933
- has16m: level >= 3
1934
- };
1935
- }
1936
-
1937
- function supportsColor(stream) {
1938
- if (forceColor === false) {
1939
- return 0;
1940
- }
1941
-
1942
- if (hasFlag('color=16m') ||
1943
- hasFlag('color=full') ||
1944
- hasFlag('color=truecolor')) {
1945
- return 3;
1946
- }
1947
-
1948
- if (hasFlag('color=256')) {
1949
- return 2;
1950
- }
1951
-
1952
- if (stream && !stream.isTTY && forceColor !== true) {
1953
- return 0;
1954
- }
1955
-
1956
- const min = forceColor ? 1 : 0;
1957
-
1958
- if (process.platform === 'win32') {
1959
- // Node.js 7.5.0 is the first version of Node.js to include a patch to
1960
- // libuv that enables 256 color output on Windows. Anything earlier and it
1961
- // won't work. However, here we target Node.js 8 at minimum as it is an LTS
1962
- // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
1963
- // release that supports 256 colors. Windows 10 build 14931 is the first release
1964
- // that supports 16m/TrueColor.
1965
- const osRelease = os.release().split('.');
1966
- if (
1967
- Number(process.versions.node.split('.')[0]) >= 8 &&
1968
- Number(osRelease[0]) >= 10 &&
1969
- Number(osRelease[2]) >= 10586
1970
- ) {
1971
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1972
- }
1973
-
1974
- return 1;
1975
- }
1976
-
1977
- if ('CI' in env) {
1978
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
1979
- return 1;
1980
- }
1981
-
1982
- return min;
1983
- }
1984
-
1985
- if ('TEAMCITY_VERSION' in env) {
1986
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1987
- }
1988
-
1989
- if (env.COLORTERM === 'truecolor') {
1990
- return 3;
1991
- }
1992
-
1993
- if ('TERM_PROGRAM' in env) {
1994
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1995
-
1996
- switch (env.TERM_PROGRAM) {
1997
- case 'iTerm.app':
1998
- return version >= 3 ? 3 : 2;
1999
- case 'Apple_Terminal':
2000
- return 2;
2001
- // No default
2002
- }
2003
- }
2004
-
2005
- if (/-256(color)?$/i.test(env.TERM)) {
2006
- return 2;
2007
- }
2008
-
2009
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2010
- return 1;
2011
- }
2012
-
2013
- if ('COLORTERM' in env) {
2014
- return 1;
2015
- }
2016
-
2017
- if (env.TERM === 'dumb') {
2018
- return min;
2019
- }
2020
-
2021
- return min;
2022
- }
2023
-
2024
- function getSupportLevel(stream) {
2025
- const level = supportsColor(stream);
2026
- return translateLevel(level);
2027
- }
2028
-
2029
- supportsColor_1 = {
2030
- supportsColor: getSupportLevel,
2031
- stdout: getSupportLevel(process.stdout),
2032
- stderr: getSupportLevel(process.stderr)
2033
- };
2034
- return supportsColor_1;
2035
- }/**
2036
- * Module dependencies.
2037
- */
2038
-
2039
- var hasRequiredNode;
2040
-
2041
- function requireNode () {
2042
- if (hasRequiredNode) return node.exports;
2043
- hasRequiredNode = 1;
2044
- (function (module, exports) {
2045
- const tty = require$$0$1;
2046
- const util = require$$1;
2047
-
2048
- /**
2049
- * This is the Node.js implementation of `debug()`.
2050
- */
2051
-
2052
- exports.init = init;
2053
- exports.log = log;
2054
- exports.formatArgs = formatArgs;
2055
- exports.save = save;
2056
- exports.load = load;
2057
- exports.useColors = useColors;
2058
- exports.destroy = util.deprecate(
2059
- () => {},
2060
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
2061
- );
2062
-
2063
- /**
2064
- * Colors.
2065
- */
2066
-
2067
- exports.colors = [6, 2, 3, 4, 5, 1];
2068
-
2069
- try {
2070
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
2071
- // eslint-disable-next-line import/no-extraneous-dependencies
2072
- const supportsColor = requireSupportsColor();
2073
-
2074
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
2075
- exports.colors = [
2076
- 20,
2077
- 21,
2078
- 26,
2079
- 27,
2080
- 32,
2081
- 33,
2082
- 38,
2083
- 39,
2084
- 40,
2085
- 41,
2086
- 42,
2087
- 43,
2088
- 44,
2089
- 45,
2090
- 56,
2091
- 57,
2092
- 62,
2093
- 63,
2094
- 68,
2095
- 69,
2096
- 74,
2097
- 75,
2098
- 76,
2099
- 77,
2100
- 78,
2101
- 79,
2102
- 80,
2103
- 81,
2104
- 92,
2105
- 93,
2106
- 98,
2107
- 99,
2108
- 112,
2109
- 113,
2110
- 128,
2111
- 129,
2112
- 134,
2113
- 135,
2114
- 148,
2115
- 149,
2116
- 160,
2117
- 161,
2118
- 162,
2119
- 163,
2120
- 164,
2121
- 165,
2122
- 166,
2123
- 167,
2124
- 168,
2125
- 169,
2126
- 170,
2127
- 171,
2128
- 172,
2129
- 173,
2130
- 178,
2131
- 179,
2132
- 184,
2133
- 185,
2134
- 196,
2135
- 197,
2136
- 198,
2137
- 199,
2138
- 200,
2139
- 201,
2140
- 202,
2141
- 203,
2142
- 204,
2143
- 205,
2144
- 206,
2145
- 207,
2146
- 208,
2147
- 209,
2148
- 214,
2149
- 215,
2150
- 220,
2151
- 221
2152
- ];
2153
- }
2154
- } catch (error) {
2155
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
2156
- }
2157
-
2158
- /**
2159
- * Build up the default `inspectOpts` object from the environment variables.
2160
- *
2161
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
2162
- */
2163
-
2164
- exports.inspectOpts = Object.keys(process.env).filter(key => {
2165
- return /^debug_/i.test(key);
2166
- }).reduce((obj, key) => {
2167
- // Camel-case
2168
- const prop = key
2169
- .substring(6)
2170
- .toLowerCase()
2171
- .replace(/_([a-z])/g, (_, k) => {
2172
- return k.toUpperCase();
2173
- });
2174
-
2175
- // Coerce string value into JS value
2176
- let val = process.env[key];
2177
- if (/^(yes|on|true|enabled)$/i.test(val)) {
2178
- val = true;
2179
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
2180
- val = false;
2181
- } else if (val === 'null') {
2182
- val = null;
2183
- } else {
2184
- val = Number(val);
2185
- }
2186
-
2187
- obj[prop] = val;
2188
- return obj;
2189
- }, {});
2190
-
2191
- /**
2192
- * Is stdout a TTY? Colored output is enabled when `true`.
2193
- */
2194
-
2195
- function useColors() {
2196
- return 'colors' in exports.inspectOpts ?
2197
- Boolean(exports.inspectOpts.colors) :
2198
- tty.isatty(process.stderr.fd);
2199
- }
2200
-
2201
- /**
2202
- * Adds ANSI color escape codes if enabled.
2203
- *
2204
- * @api public
2205
- */
2206
-
2207
- function formatArgs(args) {
2208
- const {namespace: name, useColors} = this;
2209
-
2210
- if (useColors) {
2211
- const c = this.color;
2212
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
2213
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
2214
-
2215
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
2216
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
2217
- } else {
2218
- args[0] = getDate() + name + ' ' + args[0];
2219
- }
2220
- }
2221
-
2222
- function getDate() {
2223
- if (exports.inspectOpts.hideDate) {
2224
- return '';
2225
- }
2226
- return new Date().toISOString() + ' ';
2227
- }
2228
-
2229
- /**
2230
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
2231
- */
2232
-
2233
- function log(...args) {
2234
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
2235
- }
2236
-
2237
- /**
2238
- * Save `namespaces`.
2239
- *
2240
- * @param {String} namespaces
2241
- * @api private
2242
- */
2243
- function save(namespaces) {
2244
- if (namespaces) {
2245
- process.env.DEBUG = namespaces;
2246
- } else {
2247
- // If you set a process.env field to null or undefined, it gets cast to the
2248
- // string 'null' or 'undefined'. Just delete instead.
2249
- delete process.env.DEBUG;
2250
- }
2251
- }
2252
-
2253
- /**
2254
- * Load `namespaces`.
2255
- *
2256
- * @return {String} returns the previously persisted debug modes
2257
- * @api private
2258
- */
2259
-
2260
- function load() {
2261
- return process.env.DEBUG;
2262
- }
2263
-
2264
- /**
2265
- * Init logic for `debug` instances.
2266
- *
2267
- * Create a new `inspectOpts` object in case `useColors` is set
2268
- * differently for a particular `debug` instance.
2269
- */
2270
-
2271
- function init(debug) {
2272
- debug.inspectOpts = {};
2273
-
2274
- const keys = Object.keys(exports.inspectOpts);
2275
- for (let i = 0; i < keys.length; i++) {
2276
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
2277
- }
2278
- }
2279
-
2280
- module.exports = requireCommon()(exports);
2281
-
2282
- const {formatters} = module.exports;
2283
-
2284
- /**
2285
- * Map %o to `util.inspect()`, all on a single line.
2286
- */
2287
-
2288
- formatters.o = function (v) {
2289
- this.inspectOpts.colors = this.useColors;
2290
- return util.inspect(v, this.inspectOpts)
2291
- .split('\n')
2292
- .map(str => str.trim())
2293
- .join(' ');
2294
- };
2295
-
2296
- /**
2297
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
2298
- */
2299
-
2300
- formatters.O = function (v) {
2301
- this.inspectOpts.colors = this.useColors;
2302
- return util.inspect(v, this.inspectOpts);
2303
- };
2304
- } (node, node.exports));
2305
- return node.exports;
2306
- }/**
2307
- * Detect Electron renderer / nwjs process, which is node, but we should
2308
- * treat as a browser.
2309
- */
2310
-
2311
- var hasRequiredSrc;
2312
-
2313
- function requireSrc () {
2314
- if (hasRequiredSrc) return src.exports;
2315
- hasRequiredSrc = 1;
2316
- (function (module) {
2317
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
2318
- module.exports = requireBrowser();
2319
- } else {
2320
- module.exports = requireNode();
2321
- }
2322
- } (src));
2323
- return src.exports;
2324
- }var debug_1;
2325
- var hasRequiredDebug;
2326
-
2327
- function requireDebug () {
2328
- if (hasRequiredDebug) return debug_1;
2329
- hasRequiredDebug = 1;
2330
- var debug;
2331
-
2332
- debug_1 = function () {
2333
- if (!debug) {
2334
- try {
2335
- /* eslint global-require: off */
2336
- debug = requireSrc()("follow-redirects");
2337
- }
2338
- catch (error) { /* */ }
2339
- if (typeof debug !== "function") {
2340
- debug = function () { /* */ };
2341
- }
2342
- }
2343
- debug.apply(null, arguments);
2344
- };
2345
- return debug_1;
2346
- }var hasRequiredFollowRedirects;
2347
-
2348
- function requireFollowRedirects () {
2349
- if (hasRequiredFollowRedirects) return followRedirects.exports;
2350
- hasRequiredFollowRedirects = 1;
2351
- var url = require$$0$2;
2352
- var URL = url.URL;
2353
- var http = require$$1$1;
2354
- var https = require$$2;
2355
- var Writable = require$$3.Writable;
2356
- var assert = require$$4;
2357
- var debug = requireDebug();
2358
-
2359
- // Create handlers that pass events from native requests
2360
- var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
2361
- var eventHandlers = Object.create(null);
2362
- events.forEach(function (event) {
2363
- eventHandlers[event] = function (arg1, arg2, arg3) {
2364
- this._redirectable.emit(event, arg1, arg2, arg3);
2365
- };
2366
- });
2367
-
2368
- var InvalidUrlError = createErrorType(
2369
- "ERR_INVALID_URL",
2370
- "Invalid URL",
2371
- TypeError
2372
- );
2373
- // Error types with codes
2374
- var RedirectionError = createErrorType(
2375
- "ERR_FR_REDIRECTION_FAILURE",
2376
- "Redirected request failed"
2377
- );
2378
- var TooManyRedirectsError = createErrorType(
2379
- "ERR_FR_TOO_MANY_REDIRECTS",
2380
- "Maximum number of redirects exceeded"
2381
- );
2382
- var MaxBodyLengthExceededError = createErrorType(
2383
- "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
2384
- "Request body larger than maxBodyLength limit"
2385
- );
2386
- var WriteAfterEndError = createErrorType(
2387
- "ERR_STREAM_WRITE_AFTER_END",
2388
- "write after end"
2389
- );
2390
-
2391
- // An HTTP(S) request that can be redirected
2392
- function RedirectableRequest(options, responseCallback) {
2393
- // Initialize the request
2394
- Writable.call(this);
2395
- this._sanitizeOptions(options);
2396
- this._options = options;
2397
- this._ended = false;
2398
- this._ending = false;
2399
- this._redirectCount = 0;
2400
- this._redirects = [];
2401
- this._requestBodyLength = 0;
2402
- this._requestBodyBuffers = [];
2403
-
2404
- // Attach a callback if passed
2405
- if (responseCallback) {
2406
- this.on("response", responseCallback);
2407
- }
2408
-
2409
- // React to responses of native requests
2410
- var self = this;
2411
- this._onNativeResponse = function (response) {
2412
- self._processResponse(response);
2413
- };
2414
-
2415
- // Perform the first request
2416
- this._performRequest();
2417
- }
2418
- RedirectableRequest.prototype = Object.create(Writable.prototype);
2419
-
2420
- RedirectableRequest.prototype.abort = function () {
2421
- abortRequest(this._currentRequest);
2422
- this.emit("abort");
2423
- };
2424
-
2425
- // Writes buffered data to the current native request
2426
- RedirectableRequest.prototype.write = function (data, encoding, callback) {
2427
- // Writing is not allowed if end has been called
2428
- if (this._ending) {
2429
- throw new WriteAfterEndError();
2430
- }
2431
-
2432
- // Validate input and shift parameters if necessary
2433
- if (!isString(data) && !isBuffer(data)) {
2434
- throw new TypeError("data should be a string, Buffer or Uint8Array");
2435
- }
2436
- if (isFunction(encoding)) {
2437
- callback = encoding;
2438
- encoding = null;
2439
- }
2440
-
2441
- // Ignore empty buffers, since writing them doesn't invoke the callback
2442
- // https://github.com/nodejs/node/issues/22066
2443
- if (data.length === 0) {
2444
- if (callback) {
2445
- callback();
2446
- }
2447
- return;
2448
- }
2449
- // Only write when we don't exceed the maximum body length
2450
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
2451
- this._requestBodyLength += data.length;
2452
- this._requestBodyBuffers.push({ data: data, encoding: encoding });
2453
- this._currentRequest.write(data, encoding, callback);
2454
- }
2455
- // Error when we exceed the maximum body length
2456
- else {
2457
- this.emit("error", new MaxBodyLengthExceededError());
2458
- this.abort();
2459
- }
2460
- };
2461
-
2462
- // Ends the current native request
2463
- RedirectableRequest.prototype.end = function (data, encoding, callback) {
2464
- // Shift parameters if necessary
2465
- if (isFunction(data)) {
2466
- callback = data;
2467
- data = encoding = null;
2468
- }
2469
- else if (isFunction(encoding)) {
2470
- callback = encoding;
2471
- encoding = null;
2472
- }
2473
-
2474
- // Write data if needed and end
2475
- if (!data) {
2476
- this._ended = this._ending = true;
2477
- this._currentRequest.end(null, null, callback);
2478
- }
2479
- else {
2480
- var self = this;
2481
- var currentRequest = this._currentRequest;
2482
- this.write(data, encoding, function () {
2483
- self._ended = true;
2484
- currentRequest.end(null, null, callback);
2485
- });
2486
- this._ending = true;
2487
- }
2488
- };
2489
-
2490
- // Sets a header value on the current native request
2491
- RedirectableRequest.prototype.setHeader = function (name, value) {
2492
- this._options.headers[name] = value;
2493
- this._currentRequest.setHeader(name, value);
2494
- };
2495
-
2496
- // Clears a header value on the current native request
2497
- RedirectableRequest.prototype.removeHeader = function (name) {
2498
- delete this._options.headers[name];
2499
- this._currentRequest.removeHeader(name);
2500
- };
2501
-
2502
- // Global timeout for all underlying requests
2503
- RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
2504
- var self = this;
2505
-
2506
- // Destroys the socket on timeout
2507
- function destroyOnTimeout(socket) {
2508
- socket.setTimeout(msecs);
2509
- socket.removeListener("timeout", socket.destroy);
2510
- socket.addListener("timeout", socket.destroy);
2511
- }
2512
-
2513
- // Sets up a timer to trigger a timeout event
2514
- function startTimer(socket) {
2515
- if (self._timeout) {
2516
- clearTimeout(self._timeout);
2517
- }
2518
- self._timeout = setTimeout(function () {
2519
- self.emit("timeout");
2520
- clearTimer();
2521
- }, msecs);
2522
- destroyOnTimeout(socket);
2523
- }
2524
-
2525
- // Stops a timeout from triggering
2526
- function clearTimer() {
2527
- // Clear the timeout
2528
- if (self._timeout) {
2529
- clearTimeout(self._timeout);
2530
- self._timeout = null;
2531
- }
2532
-
2533
- // Clean up all attached listeners
2534
- self.removeListener("abort", clearTimer);
2535
- self.removeListener("error", clearTimer);
2536
- self.removeListener("response", clearTimer);
2537
- if (callback) {
2538
- self.removeListener("timeout", callback);
2539
- }
2540
- if (!self.socket) {
2541
- self._currentRequest.removeListener("socket", startTimer);
2542
- }
2543
- }
2544
-
2545
- // Attach callback if passed
2546
- if (callback) {
2547
- this.on("timeout", callback);
2548
- }
2549
-
2550
- // Start the timer if or when the socket is opened
2551
- if (this.socket) {
2552
- startTimer(this.socket);
2553
- }
2554
- else {
2555
- this._currentRequest.once("socket", startTimer);
2556
- }
2557
-
2558
- // Clean up on events
2559
- this.on("socket", destroyOnTimeout);
2560
- this.on("abort", clearTimer);
2561
- this.on("error", clearTimer);
2562
- this.on("response", clearTimer);
2563
-
2564
- return this;
2565
- };
2566
-
2567
- // Proxy all other public ClientRequest methods
2568
- [
2569
- "flushHeaders", "getHeader",
2570
- "setNoDelay", "setSocketKeepAlive",
2571
- ].forEach(function (method) {
2572
- RedirectableRequest.prototype[method] = function (a, b) {
2573
- return this._currentRequest[method](a, b);
2574
- };
2575
- });
2576
-
2577
- // Proxy all public ClientRequest properties
2578
- ["aborted", "connection", "socket"].forEach(function (property) {
2579
- Object.defineProperty(RedirectableRequest.prototype, property, {
2580
- get: function () { return this._currentRequest[property]; },
2581
- });
2582
- });
2583
-
2584
- RedirectableRequest.prototype._sanitizeOptions = function (options) {
2585
- // Ensure headers are always present
2586
- if (!options.headers) {
2587
- options.headers = {};
2588
- }
2589
-
2590
- // Since http.request treats host as an alias of hostname,
2591
- // but the url module interprets host as hostname plus port,
2592
- // eliminate the host property to avoid confusion.
2593
- if (options.host) {
2594
- // Use hostname if set, because it has precedence
2595
- if (!options.hostname) {
2596
- options.hostname = options.host;
2597
- }
2598
- delete options.host;
2599
- }
2600
-
2601
- // Complete the URL object when necessary
2602
- if (!options.pathname && options.path) {
2603
- var searchPos = options.path.indexOf("?");
2604
- if (searchPos < 0) {
2605
- options.pathname = options.path;
2606
- }
2607
- else {
2608
- options.pathname = options.path.substring(0, searchPos);
2609
- options.search = options.path.substring(searchPos);
2610
- }
2611
- }
2612
- };
2613
-
2614
-
2615
- // Executes the next native request (initial or redirect)
2616
- RedirectableRequest.prototype._performRequest = function () {
2617
- // Load the native protocol
2618
- var protocol = this._options.protocol;
2619
- var nativeProtocol = this._options.nativeProtocols[protocol];
2620
- if (!nativeProtocol) {
2621
- this.emit("error", new TypeError("Unsupported protocol " + protocol));
2622
- return;
2623
- }
2624
-
2625
- // If specified, use the agent corresponding to the protocol
2626
- // (HTTP and HTTPS use different types of agents)
2627
- if (this._options.agents) {
2628
- var scheme = protocol.slice(0, -1);
2629
- this._options.agent = this._options.agents[scheme];
2630
- }
2631
-
2632
- // Create the native request and set up its event handlers
2633
- var request = this._currentRequest =
2634
- nativeProtocol.request(this._options, this._onNativeResponse);
2635
- request._redirectable = this;
2636
- for (var event of events) {
2637
- request.on(event, eventHandlers[event]);
2638
- }
2639
-
2640
- // RFC7230§5.3.1: When making a request directly to an origin server, […]
2641
- // a client MUST send only the absolute path […] as the request-target.
2642
- this._currentUrl = /^\//.test(this._options.path) ?
2643
- url.format(this._options) :
2644
- // When making a request to a proxy, […]
2645
- // a client MUST send the target URI in absolute-form […].
2646
- this._options.path;
2647
-
2648
- // End a redirected request
2649
- // (The first request must be ended explicitly with RedirectableRequest#end)
2650
- if (this._isRedirect) {
2651
- // Write the request entity and end
2652
- var i = 0;
2653
- var self = this;
2654
- var buffers = this._requestBodyBuffers;
2655
- (function writeNext(error) {
2656
- // Only write if this request has not been redirected yet
2657
- /* istanbul ignore else */
2658
- if (request === self._currentRequest) {
2659
- // Report any write errors
2660
- /* istanbul ignore if */
2661
- if (error) {
2662
- self.emit("error", error);
2663
- }
2664
- // Write the next buffer if there are still left
2665
- else if (i < buffers.length) {
2666
- var buffer = buffers[i++];
2667
- /* istanbul ignore else */
2668
- if (!request.finished) {
2669
- request.write(buffer.data, buffer.encoding, writeNext);
2670
- }
2671
- }
2672
- // End the request if `end` has been called on us
2673
- else if (self._ended) {
2674
- request.end();
2675
- }
2676
- }
2677
- }());
2678
- }
2679
- };
2680
-
2681
- // Processes a response from the current native request
2682
- RedirectableRequest.prototype._processResponse = function (response) {
2683
- // Store the redirected response
2684
- var statusCode = response.statusCode;
2685
- if (this._options.trackRedirects) {
2686
- this._redirects.push({
2687
- url: this._currentUrl,
2688
- headers: response.headers,
2689
- statusCode: statusCode,
2690
- });
2691
- }
2692
-
2693
- // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
2694
- // that further action needs to be taken by the user agent in order to
2695
- // fulfill the request. If a Location header field is provided,
2696
- // the user agent MAY automatically redirect its request to the URI
2697
- // referenced by the Location field value,
2698
- // even if the specific status code is not understood.
2699
-
2700
- // If the response is not a redirect; return it as-is
2701
- var location = response.headers.location;
2702
- if (!location || this._options.followRedirects === false ||
2703
- statusCode < 300 || statusCode >= 400) {
2704
- response.responseUrl = this._currentUrl;
2705
- response.redirects = this._redirects;
2706
- this.emit("response", response);
2707
-
2708
- // Clean up
2709
- this._requestBodyBuffers = [];
2710
- return;
2711
- }
2712
-
2713
- // The response is a redirect, so abort the current request
2714
- abortRequest(this._currentRequest);
2715
- // Discard the remainder of the response to avoid waiting for data
2716
- response.destroy();
2717
-
2718
- // RFC7231§6.4: A client SHOULD detect and intervene
2719
- // in cyclical redirections (i.e., "infinite" redirection loops).
2720
- if (++this._redirectCount > this._options.maxRedirects) {
2721
- this.emit("error", new TooManyRedirectsError());
2722
- return;
2723
- }
2724
-
2725
- // Store the request headers if applicable
2726
- var requestHeaders;
2727
- var beforeRedirect = this._options.beforeRedirect;
2728
- if (beforeRedirect) {
2729
- requestHeaders = Object.assign({
2730
- // The Host header was set by nativeProtocol.request
2731
- Host: response.req.getHeader("host"),
2732
- }, this._options.headers);
2733
- }
2734
-
2735
- // RFC7231§6.4: Automatic redirection needs to done with
2736
- // care for methods not known to be safe, […]
2737
- // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
2738
- // the request method from POST to GET for the subsequent request.
2739
- var method = this._options.method;
2740
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
2741
- // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2742
- // the server is redirecting the user agent to a different resource […]
2743
- // A user agent can perform a retrieval request targeting that URI
2744
- // (a GET or HEAD request if using HTTP) […]
2745
- (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2746
- this._options.method = "GET";
2747
- // Drop a possible entity and headers related to it
2748
- this._requestBodyBuffers = [];
2749
- removeMatchingHeaders(/^content-/i, this._options.headers);
2750
- }
2751
-
2752
- // Drop the Host header, as the redirect might lead to a different host
2753
- var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
2754
-
2755
- // If the redirect is relative, carry over the host of the last request
2756
- var currentUrlParts = url.parse(this._currentUrl);
2757
- var currentHost = currentHostHeader || currentUrlParts.host;
2758
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
2759
- url.format(Object.assign(currentUrlParts, { host: currentHost }));
2760
-
2761
- // Determine the URL of the redirection
2762
- var redirectUrl;
2763
- try {
2764
- redirectUrl = url.resolve(currentUrl, location);
2765
- }
2766
- catch (cause) {
2767
- this.emit("error", new RedirectionError({ cause: cause }));
2768
- return;
2769
- }
2770
-
2771
- // Create the redirected request
2772
- debug("redirecting to", redirectUrl);
2773
- this._isRedirect = true;
2774
- var redirectUrlParts = url.parse(redirectUrl);
2775
- Object.assign(this._options, redirectUrlParts);
2776
-
2777
- // Drop confidential headers when redirecting to a less secure protocol
2778
- // or to a different domain that is not a superdomain
2779
- if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
2780
- redirectUrlParts.protocol !== "https:" ||
2781
- redirectUrlParts.host !== currentHost &&
2782
- !isSubdomain(redirectUrlParts.host, currentHost)) {
2783
- removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
2784
- }
2785
-
2786
- // Evaluate the beforeRedirect callback
2787
- if (isFunction(beforeRedirect)) {
2788
- var responseDetails = {
2789
- headers: response.headers,
2790
- statusCode: statusCode,
2791
- };
2792
- var requestDetails = {
2793
- url: currentUrl,
2794
- method: method,
2795
- headers: requestHeaders,
2796
- };
2797
- try {
2798
- beforeRedirect(this._options, responseDetails, requestDetails);
2799
- }
2800
- catch (err) {
2801
- this.emit("error", err);
2802
- return;
2803
- }
2804
- this._sanitizeOptions(this._options);
2805
- }
2806
-
2807
- // Perform the redirected request
2808
- try {
2809
- this._performRequest();
2810
- }
2811
- catch (cause) {
2812
- this.emit("error", new RedirectionError({ cause: cause }));
2813
- }
2814
- };
2815
-
2816
- // Wraps the key/value object of protocols with redirect functionality
2817
- function wrap(protocols) {
2818
- // Default settings
2819
- var exports = {
2820
- maxRedirects: 21,
2821
- maxBodyLength: 10 * 1024 * 1024,
2822
- };
2823
-
2824
- // Wrap each protocol
2825
- var nativeProtocols = {};
2826
- Object.keys(protocols).forEach(function (scheme) {
2827
- var protocol = scheme + ":";
2828
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
2829
- var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
2830
-
2831
- // Executes a request, following redirects
2832
- function request(input, options, callback) {
2833
- // Parse parameters
2834
- if (isString(input)) {
2835
- var parsed;
2836
- try {
2837
- parsed = urlToOptions(new URL(input));
2838
- }
2839
- catch (err) {
2840
- /* istanbul ignore next */
2841
- parsed = url.parse(input);
2842
- }
2843
- if (!isString(parsed.protocol)) {
2844
- throw new InvalidUrlError({ input });
2845
- }
2846
- input = parsed;
2847
- }
2848
- else if (URL && (input instanceof URL)) {
2849
- input = urlToOptions(input);
2850
- }
2851
- else {
2852
- callback = options;
2853
- options = input;
2854
- input = { protocol: protocol };
2855
- }
2856
- if (isFunction(options)) {
2857
- callback = options;
2858
- options = null;
2859
- }
2860
-
2861
- // Set defaults
2862
- options = Object.assign({
2863
- maxRedirects: exports.maxRedirects,
2864
- maxBodyLength: exports.maxBodyLength,
2865
- }, input, options);
2866
- options.nativeProtocols = nativeProtocols;
2867
- if (!isString(options.host) && !isString(options.hostname)) {
2868
- options.hostname = "::1";
2869
- }
2870
-
2871
- assert.equal(options.protocol, protocol, "protocol mismatch");
2872
- debug("options", options);
2873
- return new RedirectableRequest(options, callback);
2874
- }
2875
-
2876
- // Executes a GET request, following redirects
2877
- function get(input, options, callback) {
2878
- var wrappedRequest = wrappedProtocol.request(input, options, callback);
2879
- wrappedRequest.end();
2880
- return wrappedRequest;
2881
- }
2882
-
2883
- // Expose the properties on the wrapped protocol
2884
- Object.defineProperties(wrappedProtocol, {
2885
- request: { value: request, configurable: true, enumerable: true, writable: true },
2886
- get: { value: get, configurable: true, enumerable: true, writable: true },
2887
- });
2888
- });
2889
- return exports;
2890
- }
2891
-
2892
- /* istanbul ignore next */
2893
- function noop() { /* empty */ }
2894
-
2895
- // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
2896
- function urlToOptions(urlObject) {
2897
- var options = {
2898
- protocol: urlObject.protocol,
2899
- hostname: urlObject.hostname.startsWith("[") ?
2900
- /* istanbul ignore next */
2901
- urlObject.hostname.slice(1, -1) :
2902
- urlObject.hostname,
2903
- hash: urlObject.hash,
2904
- search: urlObject.search,
2905
- pathname: urlObject.pathname,
2906
- path: urlObject.pathname + urlObject.search,
2907
- href: urlObject.href,
2908
- };
2909
- if (urlObject.port !== "") {
2910
- options.port = Number(urlObject.port);
2911
- }
2912
- return options;
2913
- }
2914
-
2915
- function removeMatchingHeaders(regex, headers) {
2916
- var lastValue;
2917
- for (var header in headers) {
2918
- if (regex.test(header)) {
2919
- lastValue = headers[header];
2920
- delete headers[header];
2921
- }
2922
- }
2923
- return (lastValue === null || typeof lastValue === "undefined") ?
2924
- undefined : String(lastValue).trim();
2925
- }
2926
-
2927
- function createErrorType(code, message, baseClass) {
2928
- // Create constructor
2929
- function CustomError(properties) {
2930
- Error.captureStackTrace(this, this.constructor);
2931
- Object.assign(this, properties || {});
2932
- this.code = code;
2933
- this.message = this.cause ? message + ": " + this.cause.message : message;
2934
- }
2935
-
2936
- // Attach constructor and set default properties
2937
- CustomError.prototype = new (baseClass || Error)();
2938
- CustomError.prototype.constructor = CustomError;
2939
- CustomError.prototype.name = "Error [" + code + "]";
2940
- return CustomError;
2941
- }
2942
-
2943
- function abortRequest(request) {
2944
- for (var event of events) {
2945
- request.removeListener(event, eventHandlers[event]);
2946
- }
2947
- request.on("error", noop);
2948
- request.abort();
2949
- }
2950
-
2951
- function isSubdomain(subdomain, domain) {
2952
- assert(isString(subdomain) && isString(domain));
2953
- var dot = subdomain.length - domain.length - 1;
2954
- return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
2955
- }
2956
-
2957
- function isString(value) {
2958
- return typeof value === "string" || value instanceof String;
2959
- }
2960
-
2961
- function isFunction(value) {
2962
- return typeof value === "function";
2963
- }
2964
-
2965
- function isBuffer(value) {
2966
- return typeof value === "object" && ("length" in value);
2967
- }
2968
-
2969
- // Exports
2970
- followRedirects.exports = wrap({ http: http, https: https });
2971
- followRedirects.exports.wrap = wrap;
2972
- return followRedirects.exports;
2973
- }var data;
2974
- var hasRequiredData;
2975
-
2976
- function requireData () {
2977
- if (hasRequiredData) return data;
2978
- hasRequiredData = 1;
2979
- data = {
2980
- "version": "0.26.1"
2981
- };
2982
- return data;
2983
- }var http_1;
2984
- var hasRequiredHttp;
2985
-
2986
- function requireHttp () {
2987
- if (hasRequiredHttp) return http_1;
2988
- hasRequiredHttp = 1;
2989
-
2990
- var utils = utils$9;
2991
- var settle = requireSettle();
2992
- var buildFullPath = requireBuildFullPath();
2993
- var buildURL = buildURL$1;
2994
- var http = require$$1$1;
2995
- var https = require$$2;
2996
- var httpFollow = requireFollowRedirects().http;
2997
- var httpsFollow = requireFollowRedirects().https;
2998
- var url = require$$0$2;
2999
- var zlib = require$$8;
3000
- var VERSION = requireData().version;
3001
- var createError = requireCreateError();
3002
- var enhanceError = enhanceError$1;
3003
- var transitionalDefaults = transitional;
3004
- var Cancel = requireCancel();
3005
-
3006
- var isHttps = /https:?/;
3007
-
3008
- /**
3009
- *
3010
- * @param {http.ClientRequestArgs} options
3011
- * @param {AxiosProxyConfig} proxy
3012
- * @param {string} location
3013
- */
3014
- function setProxy(options, proxy, location) {
3015
- options.hostname = proxy.host;
3016
- options.host = proxy.host;
3017
- options.port = proxy.port;
3018
- options.path = location;
3019
-
3020
- // Basic proxy authorization
3021
- if (proxy.auth) {
3022
- var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
3023
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
3024
- }
3025
-
3026
- // If a proxy is used, any redirects must also pass through the proxy
3027
- options.beforeRedirect = function beforeRedirect(redirection) {
3028
- redirection.headers.host = redirection.host;
3029
- setProxy(redirection, proxy, redirection.href);
3030
- };
3031
- }
3032
-
3033
- /*eslint consistent-return:0*/
3034
- http_1 = function httpAdapter(config) {
3035
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
3036
- var onCanceled;
3037
- function done() {
3038
- if (config.cancelToken) {
3039
- config.cancelToken.unsubscribe(onCanceled);
3040
- }
3041
-
3042
- if (config.signal) {
3043
- config.signal.removeEventListener('abort', onCanceled);
3044
- }
3045
- }
3046
- var resolve = function resolve(value) {
3047
- done();
3048
- resolvePromise(value);
3049
- };
3050
- var rejected = false;
3051
- var reject = function reject(value) {
3052
- done();
3053
- rejected = true;
3054
- rejectPromise(value);
3055
- };
3056
- var data = config.data;
3057
- var headers = config.headers;
3058
- var headerNames = {};
3059
-
3060
- Object.keys(headers).forEach(function storeLowerName(name) {
3061
- headerNames[name.toLowerCase()] = name;
3062
- });
3063
-
3064
- // Set User-Agent (required by some servers)
3065
- // See https://github.com/axios/axios/issues/69
3066
- if ('user-agent' in headerNames) {
3067
- // User-Agent is specified; handle case where no UA header is desired
3068
- if (!headers[headerNames['user-agent']]) {
3069
- delete headers[headerNames['user-agent']];
3070
- }
3071
- // Otherwise, use specified value
3072
- } else {
3073
- // Only set header if it hasn't been set in config
3074
- headers['User-Agent'] = 'axios/' + VERSION;
3075
- }
3076
-
3077
- if (data && !utils.isStream(data)) {
3078
- if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
3079
- data = Buffer.from(new Uint8Array(data));
3080
- } else if (utils.isString(data)) {
3081
- data = Buffer.from(data, 'utf-8');
3082
- } else {
3083
- return reject(createError(
3084
- 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
3085
- config
3086
- ));
3087
- }
3088
-
3089
- if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
3090
- return reject(createError('Request body larger than maxBodyLength limit', config));
3091
- }
3092
-
3093
- // Add Content-Length header if data exists
3094
- if (!headerNames['content-length']) {
3095
- headers['Content-Length'] = data.length;
3096
- }
3097
- }
3098
-
3099
- // HTTP basic authentication
3100
- var auth = undefined;
3101
- if (config.auth) {
3102
- var username = config.auth.username || '';
3103
- var password = config.auth.password || '';
3104
- auth = username + ':' + password;
3105
- }
3106
-
3107
- // Parse url
3108
- var fullPath = buildFullPath(config.baseURL, config.url);
3109
- var parsed = url.parse(fullPath);
3110
- var protocol = parsed.protocol || 'http:';
3111
-
3112
- if (!auth && parsed.auth) {
3113
- var urlAuth = parsed.auth.split(':');
3114
- var urlUsername = urlAuth[0] || '';
3115
- var urlPassword = urlAuth[1] || '';
3116
- auth = urlUsername + ':' + urlPassword;
3117
- }
3118
-
3119
- if (auth && headerNames.authorization) {
3120
- delete headers[headerNames.authorization];
3121
- }
3122
-
3123
- var isHttpsRequest = isHttps.test(protocol);
3124
- var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
3125
-
3126
- try {
3127
- buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
3128
- } catch (err) {
3129
- var customErr = new Error(err.message);
3130
- customErr.config = config;
3131
- customErr.url = config.url;
3132
- customErr.exists = true;
3133
- reject(customErr);
3134
- }
3135
-
3136
- var options = {
3137
- path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
3138
- method: config.method.toUpperCase(),
3139
- headers: headers,
3140
- agent: agent,
3141
- agents: { http: config.httpAgent, https: config.httpsAgent },
3142
- auth: auth
3143
- };
3144
-
3145
- if (config.socketPath) {
3146
- options.socketPath = config.socketPath;
3147
- } else {
3148
- options.hostname = parsed.hostname;
3149
- options.port = parsed.port;
3150
- }
3151
-
3152
- var proxy = config.proxy;
3153
- if (!proxy && proxy !== false) {
3154
- var proxyEnv = protocol.slice(0, -1) + '_proxy';
3155
- var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
3156
- if (proxyUrl) {
3157
- var parsedProxyUrl = url.parse(proxyUrl);
3158
- var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
3159
- var shouldProxy = true;
3160
-
3161
- if (noProxyEnv) {
3162
- var noProxy = noProxyEnv.split(',').map(function trim(s) {
3163
- return s.trim();
3164
- });
3165
-
3166
- shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
3167
- if (!proxyElement) {
3168
- return false;
3169
- }
3170
- if (proxyElement === '*') {
3171
- return true;
3172
- }
3173
- if (proxyElement[0] === '.' &&
3174
- parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
3175
- return true;
3176
- }
3177
-
3178
- return parsed.hostname === proxyElement;
3179
- });
3180
- }
3181
-
3182
- if (shouldProxy) {
3183
- proxy = {
3184
- host: parsedProxyUrl.hostname,
3185
- port: parsedProxyUrl.port,
3186
- protocol: parsedProxyUrl.protocol
3187
- };
3188
-
3189
- if (parsedProxyUrl.auth) {
3190
- var proxyUrlAuth = parsedProxyUrl.auth.split(':');
3191
- proxy.auth = {
3192
- username: proxyUrlAuth[0],
3193
- password: proxyUrlAuth[1]
3194
- };
3195
- }
3196
- }
3197
- }
3198
- }
3199
-
3200
- if (proxy) {
3201
- options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
3202
- setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
3203
- }
3204
-
3205
- var transport;
3206
- var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
3207
- if (config.transport) {
3208
- transport = config.transport;
3209
- } else if (config.maxRedirects === 0) {
3210
- transport = isHttpsProxy ? https : http;
3211
- } else {
3212
- if (config.maxRedirects) {
3213
- options.maxRedirects = config.maxRedirects;
3214
- }
3215
- transport = isHttpsProxy ? httpsFollow : httpFollow;
3216
- }
3217
-
3218
- if (config.maxBodyLength > -1) {
3219
- options.maxBodyLength = config.maxBodyLength;
3220
- }
3221
-
3222
- if (config.insecureHTTPParser) {
3223
- options.insecureHTTPParser = config.insecureHTTPParser;
3224
- }
3225
-
3226
- // Create the request
3227
- var req = transport.request(options, function handleResponse(res) {
3228
- if (req.aborted) return;
3229
-
3230
- // uncompress the response body transparently if required
3231
- var stream = res;
3232
-
3233
- // return the last request in case of redirects
3234
- var lastRequest = res.req || req;
3235
-
3236
-
3237
- // if no content, is HEAD request or decompress disabled we should not decompress
3238
- if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
3239
- switch (res.headers['content-encoding']) {
3240
- /*eslint default-case:0*/
3241
- case 'gzip':
3242
- case 'compress':
3243
- case 'deflate':
3244
- // add the unzipper to the body stream processing pipeline
3245
- stream = stream.pipe(zlib.createUnzip());
3246
-
3247
- // remove the content-encoding in order to not confuse downstream operations
3248
- delete res.headers['content-encoding'];
3249
- break;
3250
- }
3251
- }
3252
-
3253
- var response = {
3254
- status: res.statusCode,
3255
- statusText: res.statusMessage,
3256
- headers: res.headers,
3257
- config: config,
3258
- request: lastRequest
3259
- };
3260
-
3261
- if (config.responseType === 'stream') {
3262
- response.data = stream;
3263
- settle(resolve, reject, response);
3264
- } else {
3265
- var responseBuffer = [];
3266
- var totalResponseBytes = 0;
3267
- stream.on('data', function handleStreamData(chunk) {
3268
- responseBuffer.push(chunk);
3269
- totalResponseBytes += chunk.length;
3270
-
3271
- // make sure the content length is not over the maxContentLength if specified
3272
- if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
3273
- // stream.destoy() emit aborted event before calling reject() on Node.js v16
3274
- rejected = true;
3275
- stream.destroy();
3276
- reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3277
- config, null, lastRequest));
3278
- }
3279
- });
3280
-
3281
- stream.on('aborted', function handlerStreamAborted() {
3282
- if (rejected) {
3283
- return;
3284
- }
3285
- stream.destroy();
3286
- reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
3287
- });
3288
-
3289
- stream.on('error', function handleStreamError(err) {
3290
- if (req.aborted) return;
3291
- reject(enhanceError(err, config, null, lastRequest));
3292
- });
3293
-
3294
- stream.on('end', function handleStreamEnd() {
3295
- try {
3296
- var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
3297
- if (config.responseType !== 'arraybuffer') {
3298
- responseData = responseData.toString(config.responseEncoding);
3299
- if (!config.responseEncoding || config.responseEncoding === 'utf8') {
3300
- responseData = utils.stripBOM(responseData);
3301
- }
3302
- }
3303
- response.data = responseData;
3304
- } catch (err) {
3305
- reject(enhanceError(err, config, err.code, response.request, response));
3306
- }
3307
- settle(resolve, reject, response);
3308
- });
3309
- }
3310
- });
3311
-
3312
- // Handle errors
3313
- req.on('error', function handleRequestError(err) {
3314
- if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
3315
- reject(enhanceError(err, config, null, req));
3316
- });
3317
-
3318
- // set tcp keep alive to prevent drop connection by peer
3319
- req.on('socket', function handleRequestSocket(socket) {
3320
- // default interval of sending ack packet is 1 minute
3321
- socket.setKeepAlive(true, 1000 * 60);
3322
- });
3323
-
3324
- // Handle request timeout
3325
- if (config.timeout) {
3326
- // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
3327
- var timeout = parseInt(config.timeout, 10);
3328
-
3329
- if (isNaN(timeout)) {
3330
- reject(createError(
3331
- 'error trying to parse `config.timeout` to int',
3332
- config,
3333
- 'ERR_PARSE_TIMEOUT',
3334
- req
3335
- ));
3336
-
3337
- return;
3338
- }
3339
-
3340
- // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
3341
- // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
3342
- // 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.
3343
- // And then these socket which be hang up will devoring CPU little by little.
3344
- // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
3345
- req.setTimeout(timeout, function handleRequestTimeout() {
3346
- req.abort();
3347
- var timeoutErrorMessage = '';
3348
- if (config.timeoutErrorMessage) {
3349
- timeoutErrorMessage = config.timeoutErrorMessage;
3350
- } else {
3351
- timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
3352
- }
3353
- var transitional = config.transitional || transitionalDefaults;
3354
- reject(createError(
3355
- timeoutErrorMessage,
3356
- config,
3357
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
3358
- req
3359
- ));
3360
- });
3361
- }
3362
-
3363
- if (config.cancelToken || config.signal) {
3364
- // Handle cancellation
3365
- // eslint-disable-next-line func-names
3366
- onCanceled = function(cancel) {
3367
- if (req.aborted) return;
3368
-
3369
- req.abort();
3370
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
3371
- };
3372
-
3373
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
3374
- if (config.signal) {
3375
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
3376
- }
3377
- }
3378
-
3379
-
3380
- // Send the request
3381
- if (utils.isStream(data)) {
3382
- data.on('error', function handleStreamError(err) {
3383
- reject(enhanceError(err, config, null, req));
3384
- }).pipe(req);
3385
- } else {
3386
- req.end(data);
3387
- }
3388
- });
3389
- };
3390
- return http_1;
3391
- }var utils$5 = utils$9;
3392
- var normalizeHeaderName = normalizeHeaderName$1;
3393
- var enhanceError = enhanceError$1;
3394
- var transitionalDefaults = transitional;
3395
-
3396
- var DEFAULT_CONTENT_TYPE = {
3397
- 'Content-Type': 'application/x-www-form-urlencoded'
3398
- };
3399
-
3400
- function setContentTypeIfUnset(headers, value) {
3401
- if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers['Content-Type'])) {
3402
- headers['Content-Type'] = value;
3403
- }
3404
- }
3405
-
3406
- function getDefaultAdapter() {
3407
- var adapter;
3408
- if (typeof XMLHttpRequest !== 'undefined') {
3409
- // For browsers use XHR adapter
3410
- adapter = requireXhr();
3411
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
3412
- // For node use HTTP adapter
3413
- adapter = requireHttp();
3414
- }
3415
- return adapter;
3416
- }
3417
-
3418
- function stringifySafely(rawValue, parser, encoder) {
3419
- if (utils$5.isString(rawValue)) {
3420
- try {
3421
- (parser || JSON.parse)(rawValue);
3422
- return utils$5.trim(rawValue);
3423
- } catch (e) {
3424
- if (e.name !== 'SyntaxError') {
3425
- throw e;
3426
- }
3427
- }
3428
- }
3429
-
3430
- return (encoder || JSON.stringify)(rawValue);
3431
- }
3432
-
3433
- var defaults$3 = {
3434
-
3435
- transitional: transitionalDefaults,
3436
-
3437
- adapter: getDefaultAdapter(),
3438
-
3439
- transformRequest: [function transformRequest(data, headers) {
3440
- normalizeHeaderName(headers, 'Accept');
3441
- normalizeHeaderName(headers, 'Content-Type');
3442
-
3443
- if (utils$5.isFormData(data) ||
3444
- utils$5.isArrayBuffer(data) ||
3445
- utils$5.isBuffer(data) ||
3446
- utils$5.isStream(data) ||
3447
- utils$5.isFile(data) ||
3448
- utils$5.isBlob(data)
3449
- ) {
3450
- return data;
3451
- }
3452
- if (utils$5.isArrayBufferView(data)) {
3453
- return data.buffer;
3454
- }
3455
- if (utils$5.isURLSearchParams(data)) {
3456
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
3457
- return data.toString();
3458
- }
3459
- if (utils$5.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
3460
- setContentTypeIfUnset(headers, 'application/json');
3461
- return stringifySafely(data);
3462
- }
3463
- return data;
3464
- }],
3465
-
3466
- transformResponse: [function transformResponse(data) {
3467
- var transitional = this.transitional || defaults$3.transitional;
3468
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
3469
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3470
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
3471
-
3472
- if (strictJSONParsing || (forcedJSONParsing && utils$5.isString(data) && data.length)) {
3473
- try {
3474
- return JSON.parse(data);
3475
- } catch (e) {
3476
- if (strictJSONParsing) {
3477
- if (e.name === 'SyntaxError') {
3478
- throw enhanceError(e, this, 'E_JSON_PARSE');
3479
- }
3480
- throw e;
3481
- }
3482
- }
3483
- }
3484
-
3485
- return data;
3486
- }],
3487
-
3488
- /**
3489
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
3490
- * timeout is not created.
3491
- */
3492
- timeout: 0,
3493
-
3494
- xsrfCookieName: 'XSRF-TOKEN',
3495
- xsrfHeaderName: 'X-XSRF-TOKEN',
3496
-
3497
- maxContentLength: -1,
3498
- maxBodyLength: -1,
3499
-
3500
- validateStatus: function validateStatus(status) {
3501
- return status >= 200 && status < 300;
3502
- },
3503
-
3504
- headers: {
3505
- common: {
3506
- 'Accept': 'application/json, text/plain, */*'
3507
- }
3508
- }
3509
- };
3510
-
3511
- utils$5.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3512
- defaults$3.headers[method] = {};
3513
- });
3514
-
3515
- utils$5.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3516
- defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
3517
- });
3518
-
3519
- var defaults_1 = defaults$3;var utils$4 = utils$9;
3520
- var defaults$2 = defaults_1;
3521
-
3522
- /**
3523
- * Transform the data for a request or a response
3524
- *
3525
- * @param {Object|String} data The data to be transformed
3526
- * @param {Array} headers The headers for the request or response
3527
- * @param {Array|Function} fns A single function or Array of functions
3528
- * @returns {*} The resulting transformed data
3529
- */
3530
- var transformData$1 = function transformData(data, headers, fns) {
3531
- var context = this || defaults$2;
3532
- /*eslint no-param-reassign:0*/
3533
- utils$4.forEach(fns, function transform(fn) {
3534
- data = fn.call(context, data, headers);
3535
- });
3536
-
3537
- return data;
3538
- };var isCancel$1;
3539
- var hasRequiredIsCancel;
3540
-
3541
- function requireIsCancel () {
3542
- if (hasRequiredIsCancel) return isCancel$1;
3543
- hasRequiredIsCancel = 1;
3544
-
3545
- isCancel$1 = function isCancel(value) {
3546
- return !!(value && value.__CANCEL__);
3547
- };
3548
- return isCancel$1;
3549
- }var utils$3 = utils$9;
3550
- var transformData = transformData$1;
3551
- var isCancel = requireIsCancel();
3552
- var defaults$1 = defaults_1;
3553
- var Cancel = requireCancel();
3554
-
3555
- /**
3556
- * Throws a `Cancel` if cancellation has been requested.
3557
- */
3558
- function throwIfCancellationRequested(config) {
3559
- if (config.cancelToken) {
3560
- config.cancelToken.throwIfRequested();
3561
- }
3562
-
3563
- if (config.signal && config.signal.aborted) {
3564
- throw new Cancel('canceled');
3565
- }
3566
- }
3567
-
3568
- /**
3569
- * Dispatch a request to the server using the configured adapter.
3570
- *
3571
- * @param {object} config The config that is to be used for the request
3572
- * @returns {Promise} The Promise to be fulfilled
3573
- */
3574
- var dispatchRequest$1 = function dispatchRequest(config) {
3575
- throwIfCancellationRequested(config);
3576
-
3577
- // Ensure headers exist
3578
- config.headers = config.headers || {};
3579
-
3580
- // Transform request data
3581
- config.data = transformData.call(
3582
- config,
3583
- config.data,
3584
- config.headers,
3585
- config.transformRequest
3586
- );
3587
-
3588
- // Flatten headers
3589
- config.headers = utils$3.merge(
3590
- config.headers.common || {},
3591
- config.headers[config.method] || {},
3592
- config.headers
3593
- );
3594
-
3595
- utils$3.forEach(
3596
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3597
- function cleanHeaderConfig(method) {
3598
- delete config.headers[method];
3599
- }
3600
- );
3601
-
3602
- var adapter = config.adapter || defaults$1.adapter;
3603
-
3604
- return adapter(config).then(function onAdapterResolution(response) {
3605
- throwIfCancellationRequested(config);
3606
-
3607
- // Transform response data
3608
- response.data = transformData.call(
3609
- config,
3610
- response.data,
3611
- response.headers,
3612
- config.transformResponse
3613
- );
3614
-
3615
- return response;
3616
- }, function onAdapterRejection(reason) {
3617
- if (!isCancel(reason)) {
3618
- throwIfCancellationRequested(config);
3619
-
3620
- // Transform response data
3621
- if (reason && reason.response) {
3622
- reason.response.data = transformData.call(
3623
- config,
3624
- reason.response.data,
3625
- reason.response.headers,
3626
- config.transformResponse
3627
- );
3628
- }
3629
- }
3630
-
3631
- return Promise.reject(reason);
3632
- });
3633
- };var utils$2 = utils$9;
3634
-
3635
- /**
3636
- * Config-specific merge-function which creates a new config-object
3637
- * by merging two configuration objects together.
3638
- *
3639
- * @param {Object} config1
3640
- * @param {Object} config2
3641
- * @returns {Object} New object resulting from merging config2 to config1
3642
- */
3643
- var mergeConfig$2 = function mergeConfig(config1, config2) {
3644
- // eslint-disable-next-line no-param-reassign
3645
- config2 = config2 || {};
3646
- var config = {};
3647
-
3648
- function getMergedValue(target, source) {
3649
- if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
3650
- return utils$2.merge(target, source);
3651
- } else if (utils$2.isPlainObject(source)) {
3652
- return utils$2.merge({}, source);
3653
- } else if (utils$2.isArray(source)) {
3654
- return source.slice();
3655
- }
3656
- return source;
3657
- }
3658
-
3659
- // eslint-disable-next-line consistent-return
3660
- function mergeDeepProperties(prop) {
3661
- if (!utils$2.isUndefined(config2[prop])) {
3662
- return getMergedValue(config1[prop], config2[prop]);
3663
- } else if (!utils$2.isUndefined(config1[prop])) {
3664
- return getMergedValue(undefined, config1[prop]);
3665
- }
3666
- }
3667
-
3668
- // eslint-disable-next-line consistent-return
3669
- function valueFromConfig2(prop) {
3670
- if (!utils$2.isUndefined(config2[prop])) {
3671
- return getMergedValue(undefined, config2[prop]);
3672
- }
3673
- }
3674
-
3675
- // eslint-disable-next-line consistent-return
3676
- function defaultToConfig2(prop) {
3677
- if (!utils$2.isUndefined(config2[prop])) {
3678
- return getMergedValue(undefined, config2[prop]);
3679
- } else if (!utils$2.isUndefined(config1[prop])) {
3680
- return getMergedValue(undefined, config1[prop]);
3681
- }
3682
- }
3683
-
3684
- // eslint-disable-next-line consistent-return
3685
- function mergeDirectKeys(prop) {
3686
- if (prop in config2) {
3687
- return getMergedValue(config1[prop], config2[prop]);
3688
- } else if (prop in config1) {
3689
- return getMergedValue(undefined, config1[prop]);
3690
- }
3691
- }
3692
-
3693
- var mergeMap = {
3694
- 'url': valueFromConfig2,
3695
- 'method': valueFromConfig2,
3696
- 'data': valueFromConfig2,
3697
- 'baseURL': defaultToConfig2,
3698
- 'transformRequest': defaultToConfig2,
3699
- 'transformResponse': defaultToConfig2,
3700
- 'paramsSerializer': defaultToConfig2,
3701
- 'timeout': defaultToConfig2,
3702
- 'timeoutMessage': defaultToConfig2,
3703
- 'withCredentials': defaultToConfig2,
3704
- 'adapter': defaultToConfig2,
3705
- 'responseType': defaultToConfig2,
3706
- 'xsrfCookieName': defaultToConfig2,
3707
- 'xsrfHeaderName': defaultToConfig2,
3708
- 'onUploadProgress': defaultToConfig2,
3709
- 'onDownloadProgress': defaultToConfig2,
3710
- 'decompress': defaultToConfig2,
3711
- 'maxContentLength': defaultToConfig2,
3712
- 'maxBodyLength': defaultToConfig2,
3713
- 'transport': defaultToConfig2,
3714
- 'httpAgent': defaultToConfig2,
3715
- 'httpsAgent': defaultToConfig2,
3716
- 'cancelToken': defaultToConfig2,
3717
- 'socketPath': defaultToConfig2,
3718
- 'responseEncoding': defaultToConfig2,
3719
- 'validateStatus': mergeDirectKeys
3720
- };
3721
-
3722
- utils$2.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3723
- var merge = mergeMap[prop] || mergeDeepProperties;
3724
- var configValue = merge(prop);
3725
- (utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3726
- });
3727
-
3728
- return config;
3729
- };var VERSION = requireData().version;
3730
-
3731
- var validators$1 = {};
3732
-
3733
- // eslint-disable-next-line func-names
3734
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
3735
- validators$1[type] = function validator(thing) {
3736
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3737
- };
3738
- });
3739
-
3740
- var deprecatedWarnings = {};
3741
-
3742
- /**
3743
- * Transitional option validator
3744
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
3745
- * @param {string?} version - deprecated version / removed since version
3746
- * @param {string?} message - some message with additional info
3747
- * @returns {function}
3748
- */
3749
- validators$1.transitional = function transitional(validator, version, message) {
3750
- function formatMessage(opt, desc) {
3751
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3752
- }
3753
-
3754
- // eslint-disable-next-line func-names
3755
- return function(value, opt, opts) {
3756
- if (validator === false) {
3757
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
3758
- }
3759
-
3760
- if (version && !deprecatedWarnings[opt]) {
3761
- deprecatedWarnings[opt] = true;
3762
- // eslint-disable-next-line no-console
3763
- console.warn(
3764
- formatMessage(
3765
- opt,
3766
- ' has been deprecated since v' + version + ' and will be removed in the near future'
3767
- )
3768
- );
3769
- }
3770
-
3771
- return validator ? validator(value, opt, opts) : true;
3772
- };
3773
- };
3774
-
3775
- /**
3776
- * Assert object's properties type
3777
- * @param {object} options
3778
- * @param {object} schema
3779
- * @param {boolean?} allowUnknown
3780
- */
3781
-
3782
- function assertOptions(options, schema, allowUnknown) {
3783
- if (typeof options !== 'object') {
3784
- throw new TypeError('options must be an object');
3785
- }
3786
- var keys = Object.keys(options);
3787
- var i = keys.length;
3788
- while (i-- > 0) {
3789
- var opt = keys[i];
3790
- var validator = schema[opt];
3791
- if (validator) {
3792
- var value = options[opt];
3793
- var result = value === undefined || validator(value, opt, options);
3794
- if (result !== true) {
3795
- throw new TypeError('option ' + opt + ' must be ' + result);
3796
- }
3797
- continue;
3798
- }
3799
- if (allowUnknown !== true) {
3800
- throw Error('Unknown option ' + opt);
3801
- }
3802
- }
3803
- }
3804
-
3805
- var validator$1 = {
3806
- assertOptions: assertOptions,
3807
- validators: validators$1
3808
- };var utils$1 = utils$9;
3809
- var buildURL = buildURL$1;
3810
- var InterceptorManager = InterceptorManager_1;
3811
- var dispatchRequest = dispatchRequest$1;
3812
- var mergeConfig$1 = mergeConfig$2;
3813
- var validator = validator$1;
3814
-
3815
- var validators = validator.validators;
3816
- /**
3817
- * Create a new instance of Axios
3818
- *
3819
- * @param {Object} instanceConfig The default config for the instance
3820
- */
3821
- function Axios$1(instanceConfig) {
3822
- this.defaults = instanceConfig;
3823
- this.interceptors = {
3824
- request: new InterceptorManager(),
3825
- response: new InterceptorManager()
3826
- };
3827
- }
3828
-
3829
- /**
3830
- * Dispatch a request
3831
- *
3832
- * @param {Object} config The config specific for this request (merged with this.defaults)
3833
- */
3834
- Axios$1.prototype.request = function request(configOrUrl, config) {
3835
- /*eslint no-param-reassign:0*/
3836
- // Allow for axios('example/url'[, config]) a la fetch API
3837
- if (typeof configOrUrl === 'string') {
3838
- config = config || {};
3839
- config.url = configOrUrl;
3840
- } else {
3841
- config = configOrUrl || {};
3842
- }
3843
-
3844
- config = mergeConfig$1(this.defaults, config);
3845
-
3846
- // Set config.method
3847
- if (config.method) {
3848
- config.method = config.method.toLowerCase();
3849
- } else if (this.defaults.method) {
3850
- config.method = this.defaults.method.toLowerCase();
3851
- } else {
3852
- config.method = 'get';
3853
- }
3854
-
3855
- var transitional = config.transitional;
3856
-
3857
- if (transitional !== undefined) {
3858
- validator.assertOptions(transitional, {
3859
- silentJSONParsing: validators.transitional(validators.boolean),
3860
- forcedJSONParsing: validators.transitional(validators.boolean),
3861
- clarifyTimeoutError: validators.transitional(validators.boolean)
3862
- }, false);
3863
- }
3864
-
3865
- // filter out skipped interceptors
3866
- var requestInterceptorChain = [];
3867
- var synchronousRequestInterceptors = true;
3868
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3869
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3870
- return;
3871
- }
3872
-
3873
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3874
-
3875
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3876
- });
3877
-
3878
- var responseInterceptorChain = [];
3879
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3880
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3881
- });
3882
-
3883
- var promise;
3884
-
3885
- if (!synchronousRequestInterceptors) {
3886
- var chain = [dispatchRequest, undefined];
3887
-
3888
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
3889
- chain = chain.concat(responseInterceptorChain);
3890
-
3891
- promise = Promise.resolve(config);
3892
- while (chain.length) {
3893
- promise = promise.then(chain.shift(), chain.shift());
3894
- }
3895
-
3896
- return promise;
3897
- }
3898
-
3899
-
3900
- var newConfig = config;
3901
- while (requestInterceptorChain.length) {
3902
- var onFulfilled = requestInterceptorChain.shift();
3903
- var onRejected = requestInterceptorChain.shift();
3904
- try {
3905
- newConfig = onFulfilled(newConfig);
3906
- } catch (error) {
3907
- onRejected(error);
3908
- break;
3909
- }
3910
- }
3911
-
3912
- try {
3913
- promise = dispatchRequest(newConfig);
3914
- } catch (error) {
3915
- return Promise.reject(error);
3916
- }
3917
-
3918
- while (responseInterceptorChain.length) {
3919
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
3920
- }
3921
-
3922
- return promise;
3923
- };
3924
-
3925
- Axios$1.prototype.getUri = function getUri(config) {
3926
- config = mergeConfig$1(this.defaults, config);
3927
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
3928
- };
3929
-
3930
- // Provide aliases for supported request methods
3931
- utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3932
- /*eslint func-names:0*/
3933
- Axios$1.prototype[method] = function(url, config) {
3934
- return this.request(mergeConfig$1(config || {}, {
3935
- method: method,
3936
- url: url,
3937
- data: (config || {}).data
3938
- }));
3939
- };
3940
- });
3941
-
3942
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3943
- /*eslint func-names:0*/
3944
- Axios$1.prototype[method] = function(url, data, config) {
3945
- return this.request(mergeConfig$1(config || {}, {
3946
- method: method,
3947
- url: url,
3948
- data: data
3949
- }));
3950
- };
3951
- });
3952
-
3953
- var Axios_1 = Axios$1;var CancelToken_1;
3954
- var hasRequiredCancelToken;
3955
-
3956
- function requireCancelToken () {
3957
- if (hasRequiredCancelToken) return CancelToken_1;
3958
- hasRequiredCancelToken = 1;
3959
-
3960
- var Cancel = requireCancel();
3961
-
3962
- /**
3963
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
3964
- *
3965
- * @class
3966
- * @param {Function} executor The executor function.
3967
- */
3968
- function CancelToken(executor) {
3969
- if (typeof executor !== 'function') {
3970
- throw new TypeError('executor must be a function.');
3971
- }
3972
-
3973
- var resolvePromise;
3974
-
3975
- this.promise = new Promise(function promiseExecutor(resolve) {
3976
- resolvePromise = resolve;
3977
- });
3978
-
3979
- var token = this;
3980
-
3981
- // eslint-disable-next-line func-names
3982
- this.promise.then(function(cancel) {
3983
- if (!token._listeners) return;
3984
-
3985
- var i;
3986
- var l = token._listeners.length;
3987
-
3988
- for (i = 0; i < l; i++) {
3989
- token._listeners[i](cancel);
3990
- }
3991
- token._listeners = null;
3992
- });
3993
-
3994
- // eslint-disable-next-line func-names
3995
- this.promise.then = function(onfulfilled) {
3996
- var _resolve;
3997
- // eslint-disable-next-line func-names
3998
- var promise = new Promise(function(resolve) {
3999
- token.subscribe(resolve);
4000
- _resolve = resolve;
4001
- }).then(onfulfilled);
4002
-
4003
- promise.cancel = function reject() {
4004
- token.unsubscribe(_resolve);
4005
- };
4006
-
4007
- return promise;
4008
- };
4009
-
4010
- executor(function cancel(message) {
4011
- if (token.reason) {
4012
- // Cancellation has already been requested
4013
- return;
4014
- }
4015
-
4016
- token.reason = new Cancel(message);
4017
- resolvePromise(token.reason);
4018
- });
4019
- }
4020
-
4021
- /**
4022
- * Throws a `Cancel` if cancellation has been requested.
4023
- */
4024
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
4025
- if (this.reason) {
4026
- throw this.reason;
4027
- }
4028
- };
4029
-
4030
- /**
4031
- * Subscribe to the cancel signal
4032
- */
4033
-
4034
- CancelToken.prototype.subscribe = function subscribe(listener) {
4035
- if (this.reason) {
4036
- listener(this.reason);
4037
- return;
4038
- }
4039
-
4040
- if (this._listeners) {
4041
- this._listeners.push(listener);
4042
- } else {
4043
- this._listeners = [listener];
4044
- }
4045
- };
4046
-
4047
- /**
4048
- * Unsubscribe from the cancel signal
4049
- */
4050
-
4051
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
4052
- if (!this._listeners) {
4053
- return;
4054
- }
4055
- var index = this._listeners.indexOf(listener);
4056
- if (index !== -1) {
4057
- this._listeners.splice(index, 1);
4058
- }
4059
- };
4060
-
4061
- /**
4062
- * Returns an object that contains a new `CancelToken` and a function that, when called,
4063
- * cancels the `CancelToken`.
4064
- */
4065
- CancelToken.source = function source() {
4066
- var cancel;
4067
- var token = new CancelToken(function executor(c) {
4068
- cancel = c;
4069
- });
4070
- return {
4071
- token: token,
4072
- cancel: cancel
4073
- };
4074
- };
4075
-
4076
- CancelToken_1 = CancelToken;
4077
- return CancelToken_1;
4078
- }var spread;
4079
- var hasRequiredSpread;
4080
-
4081
- function requireSpread () {
4082
- if (hasRequiredSpread) return spread;
4083
- hasRequiredSpread = 1;
4084
-
4085
- /**
4086
- * Syntactic sugar for invoking a function and expanding an array for arguments.
4087
- *
4088
- * Common use case would be to use `Function.prototype.apply`.
4089
- *
4090
- * ```js
4091
- * function f(x, y, z) {}
4092
- * var args = [1, 2, 3];
4093
- * f.apply(null, args);
4094
- * ```
4095
- *
4096
- * With `spread` this example can be re-written.
4097
- *
4098
- * ```js
4099
- * spread(function(x, y, z) {})([1, 2, 3]);
4100
- * ```
4101
- *
4102
- * @param {Function} callback
4103
- * @returns {Function}
4104
- */
4105
- spread = function spread(callback) {
4106
- return function wrap(arr) {
4107
- return callback.apply(null, arr);
4108
- };
4109
- };
4110
- return spread;
4111
- }var isAxiosError;
4112
- var hasRequiredIsAxiosError;
4113
-
4114
- function requireIsAxiosError () {
4115
- if (hasRequiredIsAxiosError) return isAxiosError;
4116
- hasRequiredIsAxiosError = 1;
4117
-
4118
- var utils = utils$9;
4119
-
4120
- /**
4121
- * Determines whether the payload is an error thrown by Axios
4122
- *
4123
- * @param {*} payload The value to test
4124
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4125
- */
4126
- isAxiosError = function isAxiosError(payload) {
4127
- return utils.isObject(payload) && (payload.isAxiosError === true);
4128
- };
4129
- return isAxiosError;
4130
- }var utils = utils$9;
4131
- var bind = bind$2;
4132
- var Axios = Axios_1;
4133
- var mergeConfig = mergeConfig$2;
4134
- var defaults = defaults_1;
4135
-
4136
- /**
4137
- * Create an instance of Axios
4138
- *
4139
- * @param {Object} defaultConfig The default config for the instance
4140
- * @return {Axios} A new instance of Axios
4141
- */
4142
- function createInstance(defaultConfig) {
4143
- var context = new Axios(defaultConfig);
4144
- var instance = bind(Axios.prototype.request, context);
4145
-
4146
- // Copy axios.prototype to instance
4147
- utils.extend(instance, Axios.prototype, context);
4148
-
4149
- // Copy context to instance
4150
- utils.extend(instance, context);
4151
-
4152
- // Factory for creating new instances
4153
- instance.create = function create(instanceConfig) {
4154
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
4155
- };
4156
-
4157
- return instance;
4158
- }
4159
-
4160
- // Create the default instance to be exported
4161
- var axios$1 = createInstance(defaults);
4162
-
4163
- // Expose Axios class to allow class inheritance
4164
- axios$1.Axios = Axios;
4165
-
4166
- // Expose Cancel & CancelToken
4167
- axios$1.Cancel = requireCancel();
4168
- axios$1.CancelToken = requireCancelToken();
4169
- axios$1.isCancel = requireIsCancel();
4170
- axios$1.VERSION = requireData().version;
4171
-
4172
- // Expose all/spread
4173
- axios$1.all = function all(promises) {
4174
- return Promise.all(promises);
4175
- };
4176
- axios$1.spread = requireSpread();
4177
-
4178
- // Expose isAxiosError
4179
- axios$1.isAxiosError = requireIsAxiosError();
4180
-
4181
- axios$2.exports = axios$1;
4182
-
4183
- // Allow use of default import syntax in TypeScript
4184
- axios$2.exports.default = axios$1;(function (module) {
4185
- module.exports = axios$2.exports;
4186
- } (axios$3));
4187
-
4188
- var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getFile = function (filePath) {
4189
- return fs.readFileSync(filePath, 'utf8');
4190
- };
4191
- var getBase64Image = function (filePath) {
4192
- return "data:image/png;base64,".concat(fs.readFileSync(filePath).toString('base64'));
4193
- };
4194
- var downloadImage = function (url) { return __awaiter(void 0, void 0, void 0, function () {
4195
- var base64, response, buffer, err_1;
4196
- return __generator(this, function (_a) {
4197
- switch (_a.label) {
4198
- case 0:
4199
- base64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
4200
- _a.label = 1;
4201
- case 1:
4202
- _a.trys.push([1, 3, , 4]);
4203
- return [4 /*yield*/, axios.get(url, { responseType: 'arraybuffer' })];
4204
- case 2:
4205
- response = _a.sent();
4206
- buffer = Buffer.from(response.data, 'utf-8');
4207
- base64 = buffer.toString('base64');
4208
- return [3 /*break*/, 4];
4209
- case 3:
4210
- err_1 = _a.sent();
4211
- console.error(err_1);
4212
- return [3 /*break*/, 4];
4213
- case 4: return [2 /*return*/, "data:image/png;base64,".concat(base64)];
4214
- }
4215
- });
4216
- }); };export{__awaiter as _,__generator as a,getBase64Image as b,commonjsGlobal as c,downloadImage as d,getFile as g};