@azuro-org/images-generator 1.1.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) 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.png +0 -0
  14. package/dist/templates/trendle-social/images/business.png +0 -0
  15. package/dist/templates/trendle-social/images/crypto.png +0 -0
  16. package/dist/templates/trendle-social/images/culture.png +0 -0
  17. package/dist/templates/trendle-social/images/fomo.png +0 -0
  18. package/dist/templates/trendle-social/images/logo.png +0 -0
  19. package/dist/templates/trendle-social/images/politics.png +0 -0
  20. package/dist/templates/trendle-social/index.d.ts +35 -0
  21. package/dist/templates/trendle-social/index.html +217 -0
  22. package/dist/templates/trendle-social/index.js +57 -0
  23. package/dist/templates/trendle-trading/images/arrow-down.png +0 -0
  24. package/dist/templates/trendle-trading/images/arrow-up.png +0 -0
  25. package/dist/templates/trendle-trading/images/logo.png +0 -0
  26. package/dist/templates/trendle-trading/images/loss.png +0 -0
  27. package/dist/templates/trendle-trading/images/profit.png +0 -0
  28. package/dist/templates/trendle-trading/index.d.ts +15 -0
  29. package/dist/templates/trendle-trading/index.html +233 -0
  30. package/dist/templates/trendle-trading/index.js +47 -0
  31. package/dist/utils/generateImage.d.ts +4 -8
  32. package/dist/utils/types.d.ts +2 -2
  33. package/lib/index-de0b52f4.js +19637 -0
  34. package/lib/index.js +1 -4
  35. package/lib/templates/_template/index.d.ts +1 -1
  36. package/lib/templates/bet-nft/index.d.ts +1 -1
  37. package/lib/templates/bet-nft/index.html +0 -1
  38. package/lib/templates/bet-nft/index.js +1 -1
  39. package/lib/templates/bet-og/index.d.ts +1 -1
  40. package/lib/templates/bet-og/index.js +2 -2
  41. package/lib/templates/combo-bet-og/index.d.ts +1 -1
  42. package/lib/templates/combo-bet-og/index.js +1 -1
  43. package/lib/templates/freebet/index.d.ts +1 -1
  44. package/lib/templates/freebet/index.js +1 -1
  45. package/lib/templates/trendle-social/images/bg.png +0 -0
  46. package/lib/templates/trendle-social/images/business.png +0 -0
  47. package/lib/templates/trendle-social/images/crypto.png +0 -0
  48. package/lib/templates/trendle-social/images/culture.png +0 -0
  49. package/lib/templates/trendle-social/images/fomo.png +0 -0
  50. package/lib/templates/trendle-social/images/logo.png +0 -0
  51. package/lib/templates/trendle-social/images/politics.png +0 -0
  52. package/lib/templates/trendle-social/index.d.ts +35 -0
  53. package/lib/templates/trendle-social/index.html +217 -0
  54. package/lib/templates/trendle-social/index.js +57 -0
  55. package/lib/templates/trendle-trading/images/arrow-down.png +0 -0
  56. package/lib/templates/trendle-trading/images/arrow-up.png +0 -0
  57. package/lib/templates/trendle-trading/images/logo.png +0 -0
  58. package/lib/templates/trendle-trading/images/loss.png +0 -0
  59. package/lib/templates/trendle-trading/images/profit.png +0 -0
  60. package/lib/templates/trendle-trading/index.d.ts +15 -0
  61. package/lib/templates/trendle-trading/index.html +233 -0
  62. package/lib/templates/trendle-trading/index.js +47 -0
  63. package/lib/utils/generateImage.d.ts +4 -8
  64. package/lib/utils/types.d.ts +2 -2
  65. package/package.json +5 -4
  66. package/tsconfig.json +3 -0
  67. package/dist/index-401c8546.js +0 -4195
  68. package/lib/index-7f0cb09b.js +0 -4195
@@ -1,4195 +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
- let i;
1480
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1481
- const len = split.length;
1482
-
1483
- for (i = 0; i < len; i++) {
1484
- if (!split[i]) {
1485
- // ignore empty strings
1486
- continue;
1487
- }
1488
-
1489
- namespaces = split[i].replace(/\*/g, '.*?');
1490
-
1491
- if (namespaces[0] === '-') {
1492
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
1493
- } else {
1494
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
1495
- }
1496
- }
1497
- }
1498
-
1499
- /**
1500
- * Disable debug output.
1501
- *
1502
- * @return {String} namespaces
1503
- * @api public
1504
- */
1505
- function disable() {
1506
- const namespaces = [
1507
- ...createDebug.names.map(toNamespace),
1508
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
1509
- ].join(',');
1510
- createDebug.enable('');
1511
- return namespaces;
1512
- }
1513
-
1514
- /**
1515
- * Returns true if the given mode name is enabled, false otherwise.
1516
- *
1517
- * @param {String} name
1518
- * @return {Boolean}
1519
- * @api public
1520
- */
1521
- function enabled(name) {
1522
- if (name[name.length - 1] === '*') {
1523
- return true;
1524
- }
1525
-
1526
- let i;
1527
- let len;
1528
-
1529
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
1530
- if (createDebug.skips[i].test(name)) {
1531
- return false;
1532
- }
1533
- }
1534
-
1535
- for (i = 0, len = createDebug.names.length; i < len; i++) {
1536
- if (createDebug.names[i].test(name)) {
1537
- return true;
1538
- }
1539
- }
1540
-
1541
- return false;
1542
- }
1543
-
1544
- /**
1545
- * Convert regexp to namespace
1546
- *
1547
- * @param {RegExp} regxep
1548
- * @return {String} namespace
1549
- * @api private
1550
- */
1551
- function toNamespace(regexp) {
1552
- return regexp.toString()
1553
- .substring(2, regexp.toString().length - 2)
1554
- .replace(/\.\*\?$/, '*');
1555
- }
1556
-
1557
- /**
1558
- * Coerce `val`.
1559
- *
1560
- * @param {Mixed} val
1561
- * @return {Mixed}
1562
- * @api private
1563
- */
1564
- function coerce(val) {
1565
- if (val instanceof Error) {
1566
- return val.stack || val.message;
1567
- }
1568
- return val;
1569
- }
1570
-
1571
- /**
1572
- * XXX DO NOT USE. This is a temporary stub function.
1573
- * XXX It WILL be removed in the next major release.
1574
- */
1575
- function destroy() {
1576
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1577
- }
1578
-
1579
- createDebug.enable(createDebug.load());
1580
-
1581
- return createDebug;
1582
- }
1583
-
1584
- common = setup;
1585
- return common;
1586
- }/* eslint-env browser */
1587
-
1588
- var hasRequiredBrowser;
1589
-
1590
- function requireBrowser () {
1591
- if (hasRequiredBrowser) return browser.exports;
1592
- hasRequiredBrowser = 1;
1593
- (function (module, exports) {
1594
- /**
1595
- * This is the web browser implementation of `debug()`.
1596
- */
1597
-
1598
- exports.formatArgs = formatArgs;
1599
- exports.save = save;
1600
- exports.load = load;
1601
- exports.useColors = useColors;
1602
- exports.storage = localstorage();
1603
- exports.destroy = (() => {
1604
- let warned = false;
1605
-
1606
- return () => {
1607
- if (!warned) {
1608
- warned = true;
1609
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1610
- }
1611
- };
1612
- })();
1613
-
1614
- /**
1615
- * Colors.
1616
- */
1617
-
1618
- exports.colors = [
1619
- '#0000CC',
1620
- '#0000FF',
1621
- '#0033CC',
1622
- '#0033FF',
1623
- '#0066CC',
1624
- '#0066FF',
1625
- '#0099CC',
1626
- '#0099FF',
1627
- '#00CC00',
1628
- '#00CC33',
1629
- '#00CC66',
1630
- '#00CC99',
1631
- '#00CCCC',
1632
- '#00CCFF',
1633
- '#3300CC',
1634
- '#3300FF',
1635
- '#3333CC',
1636
- '#3333FF',
1637
- '#3366CC',
1638
- '#3366FF',
1639
- '#3399CC',
1640
- '#3399FF',
1641
- '#33CC00',
1642
- '#33CC33',
1643
- '#33CC66',
1644
- '#33CC99',
1645
- '#33CCCC',
1646
- '#33CCFF',
1647
- '#6600CC',
1648
- '#6600FF',
1649
- '#6633CC',
1650
- '#6633FF',
1651
- '#66CC00',
1652
- '#66CC33',
1653
- '#9900CC',
1654
- '#9900FF',
1655
- '#9933CC',
1656
- '#9933FF',
1657
- '#99CC00',
1658
- '#99CC33',
1659
- '#CC0000',
1660
- '#CC0033',
1661
- '#CC0066',
1662
- '#CC0099',
1663
- '#CC00CC',
1664
- '#CC00FF',
1665
- '#CC3300',
1666
- '#CC3333',
1667
- '#CC3366',
1668
- '#CC3399',
1669
- '#CC33CC',
1670
- '#CC33FF',
1671
- '#CC6600',
1672
- '#CC6633',
1673
- '#CC9900',
1674
- '#CC9933',
1675
- '#CCCC00',
1676
- '#CCCC33',
1677
- '#FF0000',
1678
- '#FF0033',
1679
- '#FF0066',
1680
- '#FF0099',
1681
- '#FF00CC',
1682
- '#FF00FF',
1683
- '#FF3300',
1684
- '#FF3333',
1685
- '#FF3366',
1686
- '#FF3399',
1687
- '#FF33CC',
1688
- '#FF33FF',
1689
- '#FF6600',
1690
- '#FF6633',
1691
- '#FF9900',
1692
- '#FF9933',
1693
- '#FFCC00',
1694
- '#FFCC33'
1695
- ];
1696
-
1697
- /**
1698
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1699
- * and the Firebug extension (any Firefox version) are known
1700
- * to support "%c" CSS customizations.
1701
- *
1702
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
1703
- */
1704
-
1705
- // eslint-disable-next-line complexity
1706
- function useColors() {
1707
- // NB: In an Electron preload script, document will be defined but not fully
1708
- // initialized. Since we know we're in Chrome, we'll just detect this case
1709
- // explicitly
1710
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1711
- return true;
1712
- }
1713
-
1714
- // Internet Explorer and Edge do not support colors.
1715
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1716
- return false;
1717
- }
1718
-
1719
- // Is webkit? http://stackoverflow.com/a/16459606/376773
1720
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1721
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1722
- // Is firebug? http://stackoverflow.com/a/398120/376773
1723
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1724
- // Is firefox >= v31?
1725
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1726
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
1727
- // Double check webkit in userAgent just in case we are in a worker
1728
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1729
- }
1730
-
1731
- /**
1732
- * Colorize log arguments if enabled.
1733
- *
1734
- * @api public
1735
- */
1736
-
1737
- function formatArgs(args) {
1738
- args[0] = (this.useColors ? '%c' : '') +
1739
- this.namespace +
1740
- (this.useColors ? ' %c' : ' ') +
1741
- args[0] +
1742
- (this.useColors ? '%c ' : ' ') +
1743
- '+' + module.exports.humanize(this.diff);
1744
-
1745
- if (!this.useColors) {
1746
- return;
1747
- }
1748
-
1749
- const c = 'color: ' + this.color;
1750
- args.splice(1, 0, c, 'color: inherit');
1751
-
1752
- // The final "%c" is somewhat tricky, because there could be other
1753
- // arguments passed either before or after the %c, so we need to
1754
- // figure out the correct index to insert the CSS into
1755
- let index = 0;
1756
- let lastC = 0;
1757
- args[0].replace(/%[a-zA-Z%]/g, match => {
1758
- if (match === '%%') {
1759
- return;
1760
- }
1761
- index++;
1762
- if (match === '%c') {
1763
- // We only are interested in the *last* %c
1764
- // (the user may have provided their own)
1765
- lastC = index;
1766
- }
1767
- });
1768
-
1769
- args.splice(lastC, 0, c);
1770
- }
1771
-
1772
- /**
1773
- * Invokes `console.debug()` when available.
1774
- * No-op when `console.debug` is not a "function".
1775
- * If `console.debug` is not available, falls back
1776
- * to `console.log`.
1777
- *
1778
- * @api public
1779
- */
1780
- exports.log = console.debug || console.log || (() => {});
1781
-
1782
- /**
1783
- * Save `namespaces`.
1784
- *
1785
- * @param {String} namespaces
1786
- * @api private
1787
- */
1788
- function save(namespaces) {
1789
- try {
1790
- if (namespaces) {
1791
- exports.storage.setItem('debug', namespaces);
1792
- } else {
1793
- exports.storage.removeItem('debug');
1794
- }
1795
- } catch (error) {
1796
- // Swallow
1797
- // XXX (@Qix-) should we be logging these?
1798
- }
1799
- }
1800
-
1801
- /**
1802
- * Load `namespaces`.
1803
- *
1804
- * @return {String} returns the previously persisted debug modes
1805
- * @api private
1806
- */
1807
- function load() {
1808
- let r;
1809
- try {
1810
- r = exports.storage.getItem('debug');
1811
- } catch (error) {
1812
- // Swallow
1813
- // XXX (@Qix-) should we be logging these?
1814
- }
1815
-
1816
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1817
- if (!r && typeof process !== 'undefined' && 'env' in process) {
1818
- r = process.env.DEBUG;
1819
- }
1820
-
1821
- return r;
1822
- }
1823
-
1824
- /**
1825
- * Localstorage attempts to return the localstorage.
1826
- *
1827
- * This is necessary because safari throws
1828
- * when a user disables cookies/localstorage
1829
- * and you attempt to access it.
1830
- *
1831
- * @return {LocalStorage}
1832
- * @api private
1833
- */
1834
-
1835
- function localstorage() {
1836
- try {
1837
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1838
- // The Browser also has localStorage in the global context.
1839
- return localStorage;
1840
- } catch (error) {
1841
- // Swallow
1842
- // XXX (@Qix-) should we be logging these?
1843
- }
1844
- }
1845
-
1846
- module.exports = requireCommon()(exports);
1847
-
1848
- const {formatters} = module.exports;
1849
-
1850
- /**
1851
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1852
- */
1853
-
1854
- formatters.j = function (v) {
1855
- try {
1856
- return JSON.stringify(v);
1857
- } catch (error) {
1858
- return '[UnexpectedJSONParseError]: ' + error.message;
1859
- }
1860
- };
1861
- } (browser, browser.exports));
1862
- return browser.exports;
1863
- }var node = {exports: {}};var hasFlag;
1864
- var hasRequiredHasFlag;
1865
-
1866
- function requireHasFlag () {
1867
- if (hasRequiredHasFlag) return hasFlag;
1868
- hasRequiredHasFlag = 1;
1869
- hasFlag = (flag, argv) => {
1870
- argv = argv || process.argv;
1871
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
1872
- const pos = argv.indexOf(prefix + flag);
1873
- const terminatorPos = argv.indexOf('--');
1874
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1875
- };
1876
- return hasFlag;
1877
- }var supportsColor_1;
1878
- var hasRequiredSupportsColor;
1879
-
1880
- function requireSupportsColor () {
1881
- if (hasRequiredSupportsColor) return supportsColor_1;
1882
- hasRequiredSupportsColor = 1;
1883
- const os = require$$0;
1884
- const hasFlag = requireHasFlag();
1885
-
1886
- const env = process.env;
1887
-
1888
- let forceColor;
1889
- if (hasFlag('no-color') ||
1890
- hasFlag('no-colors') ||
1891
- hasFlag('color=false')) {
1892
- forceColor = false;
1893
- } else if (hasFlag('color') ||
1894
- hasFlag('colors') ||
1895
- hasFlag('color=true') ||
1896
- hasFlag('color=always')) {
1897
- forceColor = true;
1898
- }
1899
- if ('FORCE_COLOR' in env) {
1900
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
1901
- }
1902
-
1903
- function translateLevel(level) {
1904
- if (level === 0) {
1905
- return false;
1906
- }
1907
-
1908
- return {
1909
- level,
1910
- hasBasic: true,
1911
- has256: level >= 2,
1912
- has16m: level >= 3
1913
- };
1914
- }
1915
-
1916
- function supportsColor(stream) {
1917
- if (forceColor === false) {
1918
- return 0;
1919
- }
1920
-
1921
- if (hasFlag('color=16m') ||
1922
- hasFlag('color=full') ||
1923
- hasFlag('color=truecolor')) {
1924
- return 3;
1925
- }
1926
-
1927
- if (hasFlag('color=256')) {
1928
- return 2;
1929
- }
1930
-
1931
- if (stream && !stream.isTTY && forceColor !== true) {
1932
- return 0;
1933
- }
1934
-
1935
- const min = forceColor ? 1 : 0;
1936
-
1937
- if (process.platform === 'win32') {
1938
- // Node.js 7.5.0 is the first version of Node.js to include a patch to
1939
- // libuv that enables 256 color output on Windows. Anything earlier and it
1940
- // won't work. However, here we target Node.js 8 at minimum as it is an LTS
1941
- // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
1942
- // release that supports 256 colors. Windows 10 build 14931 is the first release
1943
- // that supports 16m/TrueColor.
1944
- const osRelease = os.release().split('.');
1945
- if (
1946
- Number(process.versions.node.split('.')[0]) >= 8 &&
1947
- Number(osRelease[0]) >= 10 &&
1948
- Number(osRelease[2]) >= 10586
1949
- ) {
1950
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1951
- }
1952
-
1953
- return 1;
1954
- }
1955
-
1956
- if ('CI' in env) {
1957
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
1958
- return 1;
1959
- }
1960
-
1961
- return min;
1962
- }
1963
-
1964
- if ('TEAMCITY_VERSION' in env) {
1965
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1966
- }
1967
-
1968
- if (env.COLORTERM === 'truecolor') {
1969
- return 3;
1970
- }
1971
-
1972
- if ('TERM_PROGRAM' in env) {
1973
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
1974
-
1975
- switch (env.TERM_PROGRAM) {
1976
- case 'iTerm.app':
1977
- return version >= 3 ? 3 : 2;
1978
- case 'Apple_Terminal':
1979
- return 2;
1980
- // No default
1981
- }
1982
- }
1983
-
1984
- if (/-256(color)?$/i.test(env.TERM)) {
1985
- return 2;
1986
- }
1987
-
1988
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1989
- return 1;
1990
- }
1991
-
1992
- if ('COLORTERM' in env) {
1993
- return 1;
1994
- }
1995
-
1996
- if (env.TERM === 'dumb') {
1997
- return min;
1998
- }
1999
-
2000
- return min;
2001
- }
2002
-
2003
- function getSupportLevel(stream) {
2004
- const level = supportsColor(stream);
2005
- return translateLevel(level);
2006
- }
2007
-
2008
- supportsColor_1 = {
2009
- supportsColor: getSupportLevel,
2010
- stdout: getSupportLevel(process.stdout),
2011
- stderr: getSupportLevel(process.stderr)
2012
- };
2013
- return supportsColor_1;
2014
- }/**
2015
- * Module dependencies.
2016
- */
2017
-
2018
- var hasRequiredNode;
2019
-
2020
- function requireNode () {
2021
- if (hasRequiredNode) return node.exports;
2022
- hasRequiredNode = 1;
2023
- (function (module, exports) {
2024
- const tty = require$$0$1;
2025
- const util = require$$1;
2026
-
2027
- /**
2028
- * This is the Node.js implementation of `debug()`.
2029
- */
2030
-
2031
- exports.init = init;
2032
- exports.log = log;
2033
- exports.formatArgs = formatArgs;
2034
- exports.save = save;
2035
- exports.load = load;
2036
- exports.useColors = useColors;
2037
- exports.destroy = util.deprecate(
2038
- () => {},
2039
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
2040
- );
2041
-
2042
- /**
2043
- * Colors.
2044
- */
2045
-
2046
- exports.colors = [6, 2, 3, 4, 5, 1];
2047
-
2048
- try {
2049
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
2050
- // eslint-disable-next-line import/no-extraneous-dependencies
2051
- const supportsColor = requireSupportsColor();
2052
-
2053
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
2054
- exports.colors = [
2055
- 20,
2056
- 21,
2057
- 26,
2058
- 27,
2059
- 32,
2060
- 33,
2061
- 38,
2062
- 39,
2063
- 40,
2064
- 41,
2065
- 42,
2066
- 43,
2067
- 44,
2068
- 45,
2069
- 56,
2070
- 57,
2071
- 62,
2072
- 63,
2073
- 68,
2074
- 69,
2075
- 74,
2076
- 75,
2077
- 76,
2078
- 77,
2079
- 78,
2080
- 79,
2081
- 80,
2082
- 81,
2083
- 92,
2084
- 93,
2085
- 98,
2086
- 99,
2087
- 112,
2088
- 113,
2089
- 128,
2090
- 129,
2091
- 134,
2092
- 135,
2093
- 148,
2094
- 149,
2095
- 160,
2096
- 161,
2097
- 162,
2098
- 163,
2099
- 164,
2100
- 165,
2101
- 166,
2102
- 167,
2103
- 168,
2104
- 169,
2105
- 170,
2106
- 171,
2107
- 172,
2108
- 173,
2109
- 178,
2110
- 179,
2111
- 184,
2112
- 185,
2113
- 196,
2114
- 197,
2115
- 198,
2116
- 199,
2117
- 200,
2118
- 201,
2119
- 202,
2120
- 203,
2121
- 204,
2122
- 205,
2123
- 206,
2124
- 207,
2125
- 208,
2126
- 209,
2127
- 214,
2128
- 215,
2129
- 220,
2130
- 221
2131
- ];
2132
- }
2133
- } catch (error) {
2134
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
2135
- }
2136
-
2137
- /**
2138
- * Build up the default `inspectOpts` object from the environment variables.
2139
- *
2140
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
2141
- */
2142
-
2143
- exports.inspectOpts = Object.keys(process.env).filter(key => {
2144
- return /^debug_/i.test(key);
2145
- }).reduce((obj, key) => {
2146
- // Camel-case
2147
- const prop = key
2148
- .substring(6)
2149
- .toLowerCase()
2150
- .replace(/_([a-z])/g, (_, k) => {
2151
- return k.toUpperCase();
2152
- });
2153
-
2154
- // Coerce string value into JS value
2155
- let val = process.env[key];
2156
- if (/^(yes|on|true|enabled)$/i.test(val)) {
2157
- val = true;
2158
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
2159
- val = false;
2160
- } else if (val === 'null') {
2161
- val = null;
2162
- } else {
2163
- val = Number(val);
2164
- }
2165
-
2166
- obj[prop] = val;
2167
- return obj;
2168
- }, {});
2169
-
2170
- /**
2171
- * Is stdout a TTY? Colored output is enabled when `true`.
2172
- */
2173
-
2174
- function useColors() {
2175
- return 'colors' in exports.inspectOpts ?
2176
- Boolean(exports.inspectOpts.colors) :
2177
- tty.isatty(process.stderr.fd);
2178
- }
2179
-
2180
- /**
2181
- * Adds ANSI color escape codes if enabled.
2182
- *
2183
- * @api public
2184
- */
2185
-
2186
- function formatArgs(args) {
2187
- const {namespace: name, useColors} = this;
2188
-
2189
- if (useColors) {
2190
- const c = this.color;
2191
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
2192
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
2193
-
2194
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
2195
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
2196
- } else {
2197
- args[0] = getDate() + name + ' ' + args[0];
2198
- }
2199
- }
2200
-
2201
- function getDate() {
2202
- if (exports.inspectOpts.hideDate) {
2203
- return '';
2204
- }
2205
- return new Date().toISOString() + ' ';
2206
- }
2207
-
2208
- /**
2209
- * Invokes `util.format()` with the specified arguments and writes to stderr.
2210
- */
2211
-
2212
- function log(...args) {
2213
- return process.stderr.write(util.format(...args) + '\n');
2214
- }
2215
-
2216
- /**
2217
- * Save `namespaces`.
2218
- *
2219
- * @param {String} namespaces
2220
- * @api private
2221
- */
2222
- function save(namespaces) {
2223
- if (namespaces) {
2224
- process.env.DEBUG = namespaces;
2225
- } else {
2226
- // If you set a process.env field to null or undefined, it gets cast to the
2227
- // string 'null' or 'undefined'. Just delete instead.
2228
- delete process.env.DEBUG;
2229
- }
2230
- }
2231
-
2232
- /**
2233
- * Load `namespaces`.
2234
- *
2235
- * @return {String} returns the previously persisted debug modes
2236
- * @api private
2237
- */
2238
-
2239
- function load() {
2240
- return process.env.DEBUG;
2241
- }
2242
-
2243
- /**
2244
- * Init logic for `debug` instances.
2245
- *
2246
- * Create a new `inspectOpts` object in case `useColors` is set
2247
- * differently for a particular `debug` instance.
2248
- */
2249
-
2250
- function init(debug) {
2251
- debug.inspectOpts = {};
2252
-
2253
- const keys = Object.keys(exports.inspectOpts);
2254
- for (let i = 0; i < keys.length; i++) {
2255
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
2256
- }
2257
- }
2258
-
2259
- module.exports = requireCommon()(exports);
2260
-
2261
- const {formatters} = module.exports;
2262
-
2263
- /**
2264
- * Map %o to `util.inspect()`, all on a single line.
2265
- */
2266
-
2267
- formatters.o = function (v) {
2268
- this.inspectOpts.colors = this.useColors;
2269
- return util.inspect(v, this.inspectOpts)
2270
- .split('\n')
2271
- .map(str => str.trim())
2272
- .join(' ');
2273
- };
2274
-
2275
- /**
2276
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
2277
- */
2278
-
2279
- formatters.O = function (v) {
2280
- this.inspectOpts.colors = this.useColors;
2281
- return util.inspect(v, this.inspectOpts);
2282
- };
2283
- } (node, node.exports));
2284
- return node.exports;
2285
- }/**
2286
- * Detect Electron renderer / nwjs process, which is node, but we should
2287
- * treat as a browser.
2288
- */
2289
-
2290
- var hasRequiredSrc;
2291
-
2292
- function requireSrc () {
2293
- if (hasRequiredSrc) return src.exports;
2294
- hasRequiredSrc = 1;
2295
- (function (module) {
2296
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
2297
- module.exports = requireBrowser();
2298
- } else {
2299
- module.exports = requireNode();
2300
- }
2301
- } (src));
2302
- return src.exports;
2303
- }var debug_1;
2304
- var hasRequiredDebug;
2305
-
2306
- function requireDebug () {
2307
- if (hasRequiredDebug) return debug_1;
2308
- hasRequiredDebug = 1;
2309
- var debug;
2310
-
2311
- debug_1 = function () {
2312
- if (!debug) {
2313
- try {
2314
- /* eslint global-require: off */
2315
- debug = requireSrc()("follow-redirects");
2316
- }
2317
- catch (error) { /* */ }
2318
- if (typeof debug !== "function") {
2319
- debug = function () { /* */ };
2320
- }
2321
- }
2322
- debug.apply(null, arguments);
2323
- };
2324
- return debug_1;
2325
- }var hasRequiredFollowRedirects;
2326
-
2327
- function requireFollowRedirects () {
2328
- if (hasRequiredFollowRedirects) return followRedirects.exports;
2329
- hasRequiredFollowRedirects = 1;
2330
- var url = require$$0$2;
2331
- var URL = url.URL;
2332
- var http = require$$1$1;
2333
- var https = require$$2;
2334
- var Writable = require$$3.Writable;
2335
- var assert = require$$4;
2336
- var debug = requireDebug();
2337
-
2338
- // Create handlers that pass events from native requests
2339
- var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
2340
- var eventHandlers = Object.create(null);
2341
- events.forEach(function (event) {
2342
- eventHandlers[event] = function (arg1, arg2, arg3) {
2343
- this._redirectable.emit(event, arg1, arg2, arg3);
2344
- };
2345
- });
2346
-
2347
- var InvalidUrlError = createErrorType(
2348
- "ERR_INVALID_URL",
2349
- "Invalid URL",
2350
- TypeError
2351
- );
2352
- // Error types with codes
2353
- var RedirectionError = createErrorType(
2354
- "ERR_FR_REDIRECTION_FAILURE",
2355
- "Redirected request failed"
2356
- );
2357
- var TooManyRedirectsError = createErrorType(
2358
- "ERR_FR_TOO_MANY_REDIRECTS",
2359
- "Maximum number of redirects exceeded"
2360
- );
2361
- var MaxBodyLengthExceededError = createErrorType(
2362
- "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
2363
- "Request body larger than maxBodyLength limit"
2364
- );
2365
- var WriteAfterEndError = createErrorType(
2366
- "ERR_STREAM_WRITE_AFTER_END",
2367
- "write after end"
2368
- );
2369
-
2370
- // An HTTP(S) request that can be redirected
2371
- function RedirectableRequest(options, responseCallback) {
2372
- // Initialize the request
2373
- Writable.call(this);
2374
- this._sanitizeOptions(options);
2375
- this._options = options;
2376
- this._ended = false;
2377
- this._ending = false;
2378
- this._redirectCount = 0;
2379
- this._redirects = [];
2380
- this._requestBodyLength = 0;
2381
- this._requestBodyBuffers = [];
2382
-
2383
- // Attach a callback if passed
2384
- if (responseCallback) {
2385
- this.on("response", responseCallback);
2386
- }
2387
-
2388
- // React to responses of native requests
2389
- var self = this;
2390
- this._onNativeResponse = function (response) {
2391
- self._processResponse(response);
2392
- };
2393
-
2394
- // Perform the first request
2395
- this._performRequest();
2396
- }
2397
- RedirectableRequest.prototype = Object.create(Writable.prototype);
2398
-
2399
- RedirectableRequest.prototype.abort = function () {
2400
- abortRequest(this._currentRequest);
2401
- this.emit("abort");
2402
- };
2403
-
2404
- // Writes buffered data to the current native request
2405
- RedirectableRequest.prototype.write = function (data, encoding, callback) {
2406
- // Writing is not allowed if end has been called
2407
- if (this._ending) {
2408
- throw new WriteAfterEndError();
2409
- }
2410
-
2411
- // Validate input and shift parameters if necessary
2412
- if (!isString(data) && !isBuffer(data)) {
2413
- throw new TypeError("data should be a string, Buffer or Uint8Array");
2414
- }
2415
- if (isFunction(encoding)) {
2416
- callback = encoding;
2417
- encoding = null;
2418
- }
2419
-
2420
- // Ignore empty buffers, since writing them doesn't invoke the callback
2421
- // https://github.com/nodejs/node/issues/22066
2422
- if (data.length === 0) {
2423
- if (callback) {
2424
- callback();
2425
- }
2426
- return;
2427
- }
2428
- // Only write when we don't exceed the maximum body length
2429
- if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
2430
- this._requestBodyLength += data.length;
2431
- this._requestBodyBuffers.push({ data: data, encoding: encoding });
2432
- this._currentRequest.write(data, encoding, callback);
2433
- }
2434
- // Error when we exceed the maximum body length
2435
- else {
2436
- this.emit("error", new MaxBodyLengthExceededError());
2437
- this.abort();
2438
- }
2439
- };
2440
-
2441
- // Ends the current native request
2442
- RedirectableRequest.prototype.end = function (data, encoding, callback) {
2443
- // Shift parameters if necessary
2444
- if (isFunction(data)) {
2445
- callback = data;
2446
- data = encoding = null;
2447
- }
2448
- else if (isFunction(encoding)) {
2449
- callback = encoding;
2450
- encoding = null;
2451
- }
2452
-
2453
- // Write data if needed and end
2454
- if (!data) {
2455
- this._ended = this._ending = true;
2456
- this._currentRequest.end(null, null, callback);
2457
- }
2458
- else {
2459
- var self = this;
2460
- var currentRequest = this._currentRequest;
2461
- this.write(data, encoding, function () {
2462
- self._ended = true;
2463
- currentRequest.end(null, null, callback);
2464
- });
2465
- this._ending = true;
2466
- }
2467
- };
2468
-
2469
- // Sets a header value on the current native request
2470
- RedirectableRequest.prototype.setHeader = function (name, value) {
2471
- this._options.headers[name] = value;
2472
- this._currentRequest.setHeader(name, value);
2473
- };
2474
-
2475
- // Clears a header value on the current native request
2476
- RedirectableRequest.prototype.removeHeader = function (name) {
2477
- delete this._options.headers[name];
2478
- this._currentRequest.removeHeader(name);
2479
- };
2480
-
2481
- // Global timeout for all underlying requests
2482
- RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
2483
- var self = this;
2484
-
2485
- // Destroys the socket on timeout
2486
- function destroyOnTimeout(socket) {
2487
- socket.setTimeout(msecs);
2488
- socket.removeListener("timeout", socket.destroy);
2489
- socket.addListener("timeout", socket.destroy);
2490
- }
2491
-
2492
- // Sets up a timer to trigger a timeout event
2493
- function startTimer(socket) {
2494
- if (self._timeout) {
2495
- clearTimeout(self._timeout);
2496
- }
2497
- self._timeout = setTimeout(function () {
2498
- self.emit("timeout");
2499
- clearTimer();
2500
- }, msecs);
2501
- destroyOnTimeout(socket);
2502
- }
2503
-
2504
- // Stops a timeout from triggering
2505
- function clearTimer() {
2506
- // Clear the timeout
2507
- if (self._timeout) {
2508
- clearTimeout(self._timeout);
2509
- self._timeout = null;
2510
- }
2511
-
2512
- // Clean up all attached listeners
2513
- self.removeListener("abort", clearTimer);
2514
- self.removeListener("error", clearTimer);
2515
- self.removeListener("response", clearTimer);
2516
- if (callback) {
2517
- self.removeListener("timeout", callback);
2518
- }
2519
- if (!self.socket) {
2520
- self._currentRequest.removeListener("socket", startTimer);
2521
- }
2522
- }
2523
-
2524
- // Attach callback if passed
2525
- if (callback) {
2526
- this.on("timeout", callback);
2527
- }
2528
-
2529
- // Start the timer if or when the socket is opened
2530
- if (this.socket) {
2531
- startTimer(this.socket);
2532
- }
2533
- else {
2534
- this._currentRequest.once("socket", startTimer);
2535
- }
2536
-
2537
- // Clean up on events
2538
- this.on("socket", destroyOnTimeout);
2539
- this.on("abort", clearTimer);
2540
- this.on("error", clearTimer);
2541
- this.on("response", clearTimer);
2542
-
2543
- return this;
2544
- };
2545
-
2546
- // Proxy all other public ClientRequest methods
2547
- [
2548
- "flushHeaders", "getHeader",
2549
- "setNoDelay", "setSocketKeepAlive",
2550
- ].forEach(function (method) {
2551
- RedirectableRequest.prototype[method] = function (a, b) {
2552
- return this._currentRequest[method](a, b);
2553
- };
2554
- });
2555
-
2556
- // Proxy all public ClientRequest properties
2557
- ["aborted", "connection", "socket"].forEach(function (property) {
2558
- Object.defineProperty(RedirectableRequest.prototype, property, {
2559
- get: function () { return this._currentRequest[property]; },
2560
- });
2561
- });
2562
-
2563
- RedirectableRequest.prototype._sanitizeOptions = function (options) {
2564
- // Ensure headers are always present
2565
- if (!options.headers) {
2566
- options.headers = {};
2567
- }
2568
-
2569
- // Since http.request treats host as an alias of hostname,
2570
- // but the url module interprets host as hostname plus port,
2571
- // eliminate the host property to avoid confusion.
2572
- if (options.host) {
2573
- // Use hostname if set, because it has precedence
2574
- if (!options.hostname) {
2575
- options.hostname = options.host;
2576
- }
2577
- delete options.host;
2578
- }
2579
-
2580
- // Complete the URL object when necessary
2581
- if (!options.pathname && options.path) {
2582
- var searchPos = options.path.indexOf("?");
2583
- if (searchPos < 0) {
2584
- options.pathname = options.path;
2585
- }
2586
- else {
2587
- options.pathname = options.path.substring(0, searchPos);
2588
- options.search = options.path.substring(searchPos);
2589
- }
2590
- }
2591
- };
2592
-
2593
-
2594
- // Executes the next native request (initial or redirect)
2595
- RedirectableRequest.prototype._performRequest = function () {
2596
- // Load the native protocol
2597
- var protocol = this._options.protocol;
2598
- var nativeProtocol = this._options.nativeProtocols[protocol];
2599
- if (!nativeProtocol) {
2600
- this.emit("error", new TypeError("Unsupported protocol " + protocol));
2601
- return;
2602
- }
2603
-
2604
- // If specified, use the agent corresponding to the protocol
2605
- // (HTTP and HTTPS use different types of agents)
2606
- if (this._options.agents) {
2607
- var scheme = protocol.slice(0, -1);
2608
- this._options.agent = this._options.agents[scheme];
2609
- }
2610
-
2611
- // Create the native request and set up its event handlers
2612
- var request = this._currentRequest =
2613
- nativeProtocol.request(this._options, this._onNativeResponse);
2614
- request._redirectable = this;
2615
- for (var event of events) {
2616
- request.on(event, eventHandlers[event]);
2617
- }
2618
-
2619
- // RFC7230§5.3.1: When making a request directly to an origin server, […]
2620
- // a client MUST send only the absolute path […] as the request-target.
2621
- this._currentUrl = /^\//.test(this._options.path) ?
2622
- url.format(this._options) :
2623
- // When making a request to a proxy, […]
2624
- // a client MUST send the target URI in absolute-form […].
2625
- this._options.path;
2626
-
2627
- // End a redirected request
2628
- // (The first request must be ended explicitly with RedirectableRequest#end)
2629
- if (this._isRedirect) {
2630
- // Write the request entity and end
2631
- var i = 0;
2632
- var self = this;
2633
- var buffers = this._requestBodyBuffers;
2634
- (function writeNext(error) {
2635
- // Only write if this request has not been redirected yet
2636
- /* istanbul ignore else */
2637
- if (request === self._currentRequest) {
2638
- // Report any write errors
2639
- /* istanbul ignore if */
2640
- if (error) {
2641
- self.emit("error", error);
2642
- }
2643
- // Write the next buffer if there are still left
2644
- else if (i < buffers.length) {
2645
- var buffer = buffers[i++];
2646
- /* istanbul ignore else */
2647
- if (!request.finished) {
2648
- request.write(buffer.data, buffer.encoding, writeNext);
2649
- }
2650
- }
2651
- // End the request if `end` has been called on us
2652
- else if (self._ended) {
2653
- request.end();
2654
- }
2655
- }
2656
- }());
2657
- }
2658
- };
2659
-
2660
- // Processes a response from the current native request
2661
- RedirectableRequest.prototype._processResponse = function (response) {
2662
- // Store the redirected response
2663
- var statusCode = response.statusCode;
2664
- if (this._options.trackRedirects) {
2665
- this._redirects.push({
2666
- url: this._currentUrl,
2667
- headers: response.headers,
2668
- statusCode: statusCode,
2669
- });
2670
- }
2671
-
2672
- // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
2673
- // that further action needs to be taken by the user agent in order to
2674
- // fulfill the request. If a Location header field is provided,
2675
- // the user agent MAY automatically redirect its request to the URI
2676
- // referenced by the Location field value,
2677
- // even if the specific status code is not understood.
2678
-
2679
- // If the response is not a redirect; return it as-is
2680
- var location = response.headers.location;
2681
- if (!location || this._options.followRedirects === false ||
2682
- statusCode < 300 || statusCode >= 400) {
2683
- response.responseUrl = this._currentUrl;
2684
- response.redirects = this._redirects;
2685
- this.emit("response", response);
2686
-
2687
- // Clean up
2688
- this._requestBodyBuffers = [];
2689
- return;
2690
- }
2691
-
2692
- // The response is a redirect, so abort the current request
2693
- abortRequest(this._currentRequest);
2694
- // Discard the remainder of the response to avoid waiting for data
2695
- response.destroy();
2696
-
2697
- // RFC7231§6.4: A client SHOULD detect and intervene
2698
- // in cyclical redirections (i.e., "infinite" redirection loops).
2699
- if (++this._redirectCount > this._options.maxRedirects) {
2700
- this.emit("error", new TooManyRedirectsError());
2701
- return;
2702
- }
2703
-
2704
- // Store the request headers if applicable
2705
- var requestHeaders;
2706
- var beforeRedirect = this._options.beforeRedirect;
2707
- if (beforeRedirect) {
2708
- requestHeaders = Object.assign({
2709
- // The Host header was set by nativeProtocol.request
2710
- Host: response.req.getHeader("host"),
2711
- }, this._options.headers);
2712
- }
2713
-
2714
- // RFC7231§6.4: Automatic redirection needs to done with
2715
- // care for methods not known to be safe, […]
2716
- // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
2717
- // the request method from POST to GET for the subsequent request.
2718
- var method = this._options.method;
2719
- if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
2720
- // RFC7231§6.4.4: The 303 (See Other) status code indicates that
2721
- // the server is redirecting the user agent to a different resource […]
2722
- // A user agent can perform a retrieval request targeting that URI
2723
- // (a GET or HEAD request if using HTTP) […]
2724
- (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
2725
- this._options.method = "GET";
2726
- // Drop a possible entity and headers related to it
2727
- this._requestBodyBuffers = [];
2728
- removeMatchingHeaders(/^content-/i, this._options.headers);
2729
- }
2730
-
2731
- // Drop the Host header, as the redirect might lead to a different host
2732
- var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
2733
-
2734
- // If the redirect is relative, carry over the host of the last request
2735
- var currentUrlParts = url.parse(this._currentUrl);
2736
- var currentHost = currentHostHeader || currentUrlParts.host;
2737
- var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
2738
- url.format(Object.assign(currentUrlParts, { host: currentHost }));
2739
-
2740
- // Determine the URL of the redirection
2741
- var redirectUrl;
2742
- try {
2743
- redirectUrl = url.resolve(currentUrl, location);
2744
- }
2745
- catch (cause) {
2746
- this.emit("error", new RedirectionError({ cause: cause }));
2747
- return;
2748
- }
2749
-
2750
- // Create the redirected request
2751
- debug("redirecting to", redirectUrl);
2752
- this._isRedirect = true;
2753
- var redirectUrlParts = url.parse(redirectUrl);
2754
- Object.assign(this._options, redirectUrlParts);
2755
-
2756
- // Drop confidential headers when redirecting to a less secure protocol
2757
- // or to a different domain that is not a superdomain
2758
- if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
2759
- redirectUrlParts.protocol !== "https:" ||
2760
- redirectUrlParts.host !== currentHost &&
2761
- !isSubdomain(redirectUrlParts.host, currentHost)) {
2762
- removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
2763
- }
2764
-
2765
- // Evaluate the beforeRedirect callback
2766
- if (isFunction(beforeRedirect)) {
2767
- var responseDetails = {
2768
- headers: response.headers,
2769
- statusCode: statusCode,
2770
- };
2771
- var requestDetails = {
2772
- url: currentUrl,
2773
- method: method,
2774
- headers: requestHeaders,
2775
- };
2776
- try {
2777
- beforeRedirect(this._options, responseDetails, requestDetails);
2778
- }
2779
- catch (err) {
2780
- this.emit("error", err);
2781
- return;
2782
- }
2783
- this._sanitizeOptions(this._options);
2784
- }
2785
-
2786
- // Perform the redirected request
2787
- try {
2788
- this._performRequest();
2789
- }
2790
- catch (cause) {
2791
- this.emit("error", new RedirectionError({ cause: cause }));
2792
- }
2793
- };
2794
-
2795
- // Wraps the key/value object of protocols with redirect functionality
2796
- function wrap(protocols) {
2797
- // Default settings
2798
- var exports = {
2799
- maxRedirects: 21,
2800
- maxBodyLength: 10 * 1024 * 1024,
2801
- };
2802
-
2803
- // Wrap each protocol
2804
- var nativeProtocols = {};
2805
- Object.keys(protocols).forEach(function (scheme) {
2806
- var protocol = scheme + ":";
2807
- var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
2808
- var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
2809
-
2810
- // Executes a request, following redirects
2811
- function request(input, options, callback) {
2812
- // Parse parameters
2813
- if (isString(input)) {
2814
- var parsed;
2815
- try {
2816
- parsed = urlToOptions(new URL(input));
2817
- }
2818
- catch (err) {
2819
- /* istanbul ignore next */
2820
- parsed = url.parse(input);
2821
- }
2822
- if (!isString(parsed.protocol)) {
2823
- throw new InvalidUrlError({ input });
2824
- }
2825
- input = parsed;
2826
- }
2827
- else if (URL && (input instanceof URL)) {
2828
- input = urlToOptions(input);
2829
- }
2830
- else {
2831
- callback = options;
2832
- options = input;
2833
- input = { protocol: protocol };
2834
- }
2835
- if (isFunction(options)) {
2836
- callback = options;
2837
- options = null;
2838
- }
2839
-
2840
- // Set defaults
2841
- options = Object.assign({
2842
- maxRedirects: exports.maxRedirects,
2843
- maxBodyLength: exports.maxBodyLength,
2844
- }, input, options);
2845
- options.nativeProtocols = nativeProtocols;
2846
- if (!isString(options.host) && !isString(options.hostname)) {
2847
- options.hostname = "::1";
2848
- }
2849
-
2850
- assert.equal(options.protocol, protocol, "protocol mismatch");
2851
- debug("options", options);
2852
- return new RedirectableRequest(options, callback);
2853
- }
2854
-
2855
- // Executes a GET request, following redirects
2856
- function get(input, options, callback) {
2857
- var wrappedRequest = wrappedProtocol.request(input, options, callback);
2858
- wrappedRequest.end();
2859
- return wrappedRequest;
2860
- }
2861
-
2862
- // Expose the properties on the wrapped protocol
2863
- Object.defineProperties(wrappedProtocol, {
2864
- request: { value: request, configurable: true, enumerable: true, writable: true },
2865
- get: { value: get, configurable: true, enumerable: true, writable: true },
2866
- });
2867
- });
2868
- return exports;
2869
- }
2870
-
2871
- /* istanbul ignore next */
2872
- function noop() { /* empty */ }
2873
-
2874
- // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
2875
- function urlToOptions(urlObject) {
2876
- var options = {
2877
- protocol: urlObject.protocol,
2878
- hostname: urlObject.hostname.startsWith("[") ?
2879
- /* istanbul ignore next */
2880
- urlObject.hostname.slice(1, -1) :
2881
- urlObject.hostname,
2882
- hash: urlObject.hash,
2883
- search: urlObject.search,
2884
- pathname: urlObject.pathname,
2885
- path: urlObject.pathname + urlObject.search,
2886
- href: urlObject.href,
2887
- };
2888
- if (urlObject.port !== "") {
2889
- options.port = Number(urlObject.port);
2890
- }
2891
- return options;
2892
- }
2893
-
2894
- function removeMatchingHeaders(regex, headers) {
2895
- var lastValue;
2896
- for (var header in headers) {
2897
- if (regex.test(header)) {
2898
- lastValue = headers[header];
2899
- delete headers[header];
2900
- }
2901
- }
2902
- return (lastValue === null || typeof lastValue === "undefined") ?
2903
- undefined : String(lastValue).trim();
2904
- }
2905
-
2906
- function createErrorType(code, message, baseClass) {
2907
- // Create constructor
2908
- function CustomError(properties) {
2909
- Error.captureStackTrace(this, this.constructor);
2910
- Object.assign(this, properties || {});
2911
- this.code = code;
2912
- this.message = this.cause ? message + ": " + this.cause.message : message;
2913
- }
2914
-
2915
- // Attach constructor and set default properties
2916
- CustomError.prototype = new (baseClass || Error)();
2917
- CustomError.prototype.constructor = CustomError;
2918
- CustomError.prototype.name = "Error [" + code + "]";
2919
- return CustomError;
2920
- }
2921
-
2922
- function abortRequest(request) {
2923
- for (var event of events) {
2924
- request.removeListener(event, eventHandlers[event]);
2925
- }
2926
- request.on("error", noop);
2927
- request.abort();
2928
- }
2929
-
2930
- function isSubdomain(subdomain, domain) {
2931
- assert(isString(subdomain) && isString(domain));
2932
- var dot = subdomain.length - domain.length - 1;
2933
- return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
2934
- }
2935
-
2936
- function isString(value) {
2937
- return typeof value === "string" || value instanceof String;
2938
- }
2939
-
2940
- function isFunction(value) {
2941
- return typeof value === "function";
2942
- }
2943
-
2944
- function isBuffer(value) {
2945
- return typeof value === "object" && ("length" in value);
2946
- }
2947
-
2948
- // Exports
2949
- followRedirects.exports = wrap({ http: http, https: https });
2950
- followRedirects.exports.wrap = wrap;
2951
- return followRedirects.exports;
2952
- }var data;
2953
- var hasRequiredData;
2954
-
2955
- function requireData () {
2956
- if (hasRequiredData) return data;
2957
- hasRequiredData = 1;
2958
- data = {
2959
- "version": "0.26.1"
2960
- };
2961
- return data;
2962
- }var http_1;
2963
- var hasRequiredHttp;
2964
-
2965
- function requireHttp () {
2966
- if (hasRequiredHttp) return http_1;
2967
- hasRequiredHttp = 1;
2968
-
2969
- var utils = utils$9;
2970
- var settle = requireSettle();
2971
- var buildFullPath = requireBuildFullPath();
2972
- var buildURL = buildURL$1;
2973
- var http = require$$1$1;
2974
- var https = require$$2;
2975
- var httpFollow = requireFollowRedirects().http;
2976
- var httpsFollow = requireFollowRedirects().https;
2977
- var url = require$$0$2;
2978
- var zlib = require$$8;
2979
- var VERSION = requireData().version;
2980
- var createError = requireCreateError();
2981
- var enhanceError = enhanceError$1;
2982
- var transitionalDefaults = transitional;
2983
- var Cancel = requireCancel();
2984
-
2985
- var isHttps = /https:?/;
2986
-
2987
- /**
2988
- *
2989
- * @param {http.ClientRequestArgs} options
2990
- * @param {AxiosProxyConfig} proxy
2991
- * @param {string} location
2992
- */
2993
- function setProxy(options, proxy, location) {
2994
- options.hostname = proxy.host;
2995
- options.host = proxy.host;
2996
- options.port = proxy.port;
2997
- options.path = location;
2998
-
2999
- // Basic proxy authorization
3000
- if (proxy.auth) {
3001
- var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
3002
- options.headers['Proxy-Authorization'] = 'Basic ' + base64;
3003
- }
3004
-
3005
- // If a proxy is used, any redirects must also pass through the proxy
3006
- options.beforeRedirect = function beforeRedirect(redirection) {
3007
- redirection.headers.host = redirection.host;
3008
- setProxy(redirection, proxy, redirection.href);
3009
- };
3010
- }
3011
-
3012
- /*eslint consistent-return:0*/
3013
- http_1 = function httpAdapter(config) {
3014
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
3015
- var onCanceled;
3016
- function done() {
3017
- if (config.cancelToken) {
3018
- config.cancelToken.unsubscribe(onCanceled);
3019
- }
3020
-
3021
- if (config.signal) {
3022
- config.signal.removeEventListener('abort', onCanceled);
3023
- }
3024
- }
3025
- var resolve = function resolve(value) {
3026
- done();
3027
- resolvePromise(value);
3028
- };
3029
- var rejected = false;
3030
- var reject = function reject(value) {
3031
- done();
3032
- rejected = true;
3033
- rejectPromise(value);
3034
- };
3035
- var data = config.data;
3036
- var headers = config.headers;
3037
- var headerNames = {};
3038
-
3039
- Object.keys(headers).forEach(function storeLowerName(name) {
3040
- headerNames[name.toLowerCase()] = name;
3041
- });
3042
-
3043
- // Set User-Agent (required by some servers)
3044
- // See https://github.com/axios/axios/issues/69
3045
- if ('user-agent' in headerNames) {
3046
- // User-Agent is specified; handle case where no UA header is desired
3047
- if (!headers[headerNames['user-agent']]) {
3048
- delete headers[headerNames['user-agent']];
3049
- }
3050
- // Otherwise, use specified value
3051
- } else {
3052
- // Only set header if it hasn't been set in config
3053
- headers['User-Agent'] = 'axios/' + VERSION;
3054
- }
3055
-
3056
- if (data && !utils.isStream(data)) {
3057
- if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
3058
- data = Buffer.from(new Uint8Array(data));
3059
- } else if (utils.isString(data)) {
3060
- data = Buffer.from(data, 'utf-8');
3061
- } else {
3062
- return reject(createError(
3063
- 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
3064
- config
3065
- ));
3066
- }
3067
-
3068
- if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
3069
- return reject(createError('Request body larger than maxBodyLength limit', config));
3070
- }
3071
-
3072
- // Add Content-Length header if data exists
3073
- if (!headerNames['content-length']) {
3074
- headers['Content-Length'] = data.length;
3075
- }
3076
- }
3077
-
3078
- // HTTP basic authentication
3079
- var auth = undefined;
3080
- if (config.auth) {
3081
- var username = config.auth.username || '';
3082
- var password = config.auth.password || '';
3083
- auth = username + ':' + password;
3084
- }
3085
-
3086
- // Parse url
3087
- var fullPath = buildFullPath(config.baseURL, config.url);
3088
- var parsed = url.parse(fullPath);
3089
- var protocol = parsed.protocol || 'http:';
3090
-
3091
- if (!auth && parsed.auth) {
3092
- var urlAuth = parsed.auth.split(':');
3093
- var urlUsername = urlAuth[0] || '';
3094
- var urlPassword = urlAuth[1] || '';
3095
- auth = urlUsername + ':' + urlPassword;
3096
- }
3097
-
3098
- if (auth && headerNames.authorization) {
3099
- delete headers[headerNames.authorization];
3100
- }
3101
-
3102
- var isHttpsRequest = isHttps.test(protocol);
3103
- var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
3104
-
3105
- try {
3106
- buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
3107
- } catch (err) {
3108
- var customErr = new Error(err.message);
3109
- customErr.config = config;
3110
- customErr.url = config.url;
3111
- customErr.exists = true;
3112
- reject(customErr);
3113
- }
3114
-
3115
- var options = {
3116
- path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
3117
- method: config.method.toUpperCase(),
3118
- headers: headers,
3119
- agent: agent,
3120
- agents: { http: config.httpAgent, https: config.httpsAgent },
3121
- auth: auth
3122
- };
3123
-
3124
- if (config.socketPath) {
3125
- options.socketPath = config.socketPath;
3126
- } else {
3127
- options.hostname = parsed.hostname;
3128
- options.port = parsed.port;
3129
- }
3130
-
3131
- var proxy = config.proxy;
3132
- if (!proxy && proxy !== false) {
3133
- var proxyEnv = protocol.slice(0, -1) + '_proxy';
3134
- var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
3135
- if (proxyUrl) {
3136
- var parsedProxyUrl = url.parse(proxyUrl);
3137
- var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
3138
- var shouldProxy = true;
3139
-
3140
- if (noProxyEnv) {
3141
- var noProxy = noProxyEnv.split(',').map(function trim(s) {
3142
- return s.trim();
3143
- });
3144
-
3145
- shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
3146
- if (!proxyElement) {
3147
- return false;
3148
- }
3149
- if (proxyElement === '*') {
3150
- return true;
3151
- }
3152
- if (proxyElement[0] === '.' &&
3153
- parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
3154
- return true;
3155
- }
3156
-
3157
- return parsed.hostname === proxyElement;
3158
- });
3159
- }
3160
-
3161
- if (shouldProxy) {
3162
- proxy = {
3163
- host: parsedProxyUrl.hostname,
3164
- port: parsedProxyUrl.port,
3165
- protocol: parsedProxyUrl.protocol
3166
- };
3167
-
3168
- if (parsedProxyUrl.auth) {
3169
- var proxyUrlAuth = parsedProxyUrl.auth.split(':');
3170
- proxy.auth = {
3171
- username: proxyUrlAuth[0],
3172
- password: proxyUrlAuth[1]
3173
- };
3174
- }
3175
- }
3176
- }
3177
- }
3178
-
3179
- if (proxy) {
3180
- options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
3181
- setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
3182
- }
3183
-
3184
- var transport;
3185
- var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
3186
- if (config.transport) {
3187
- transport = config.transport;
3188
- } else if (config.maxRedirects === 0) {
3189
- transport = isHttpsProxy ? https : http;
3190
- } else {
3191
- if (config.maxRedirects) {
3192
- options.maxRedirects = config.maxRedirects;
3193
- }
3194
- transport = isHttpsProxy ? httpsFollow : httpFollow;
3195
- }
3196
-
3197
- if (config.maxBodyLength > -1) {
3198
- options.maxBodyLength = config.maxBodyLength;
3199
- }
3200
-
3201
- if (config.insecureHTTPParser) {
3202
- options.insecureHTTPParser = config.insecureHTTPParser;
3203
- }
3204
-
3205
- // Create the request
3206
- var req = transport.request(options, function handleResponse(res) {
3207
- if (req.aborted) return;
3208
-
3209
- // uncompress the response body transparently if required
3210
- var stream = res;
3211
-
3212
- // return the last request in case of redirects
3213
- var lastRequest = res.req || req;
3214
-
3215
-
3216
- // if no content, is HEAD request or decompress disabled we should not decompress
3217
- if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
3218
- switch (res.headers['content-encoding']) {
3219
- /*eslint default-case:0*/
3220
- case 'gzip':
3221
- case 'compress':
3222
- case 'deflate':
3223
- // add the unzipper to the body stream processing pipeline
3224
- stream = stream.pipe(zlib.createUnzip());
3225
-
3226
- // remove the content-encoding in order to not confuse downstream operations
3227
- delete res.headers['content-encoding'];
3228
- break;
3229
- }
3230
- }
3231
-
3232
- var response = {
3233
- status: res.statusCode,
3234
- statusText: res.statusMessage,
3235
- headers: res.headers,
3236
- config: config,
3237
- request: lastRequest
3238
- };
3239
-
3240
- if (config.responseType === 'stream') {
3241
- response.data = stream;
3242
- settle(resolve, reject, response);
3243
- } else {
3244
- var responseBuffer = [];
3245
- var totalResponseBytes = 0;
3246
- stream.on('data', function handleStreamData(chunk) {
3247
- responseBuffer.push(chunk);
3248
- totalResponseBytes += chunk.length;
3249
-
3250
- // make sure the content length is not over the maxContentLength if specified
3251
- if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
3252
- // stream.destoy() emit aborted event before calling reject() on Node.js v16
3253
- rejected = true;
3254
- stream.destroy();
3255
- reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3256
- config, null, lastRequest));
3257
- }
3258
- });
3259
-
3260
- stream.on('aborted', function handlerStreamAborted() {
3261
- if (rejected) {
3262
- return;
3263
- }
3264
- stream.destroy();
3265
- reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
3266
- });
3267
-
3268
- stream.on('error', function handleStreamError(err) {
3269
- if (req.aborted) return;
3270
- reject(enhanceError(err, config, null, lastRequest));
3271
- });
3272
-
3273
- stream.on('end', function handleStreamEnd() {
3274
- try {
3275
- var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
3276
- if (config.responseType !== 'arraybuffer') {
3277
- responseData = responseData.toString(config.responseEncoding);
3278
- if (!config.responseEncoding || config.responseEncoding === 'utf8') {
3279
- responseData = utils.stripBOM(responseData);
3280
- }
3281
- }
3282
- response.data = responseData;
3283
- } catch (err) {
3284
- reject(enhanceError(err, config, err.code, response.request, response));
3285
- }
3286
- settle(resolve, reject, response);
3287
- });
3288
- }
3289
- });
3290
-
3291
- // Handle errors
3292
- req.on('error', function handleRequestError(err) {
3293
- if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
3294
- reject(enhanceError(err, config, null, req));
3295
- });
3296
-
3297
- // set tcp keep alive to prevent drop connection by peer
3298
- req.on('socket', function handleRequestSocket(socket) {
3299
- // default interval of sending ack packet is 1 minute
3300
- socket.setKeepAlive(true, 1000 * 60);
3301
- });
3302
-
3303
- // Handle request timeout
3304
- if (config.timeout) {
3305
- // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
3306
- var timeout = parseInt(config.timeout, 10);
3307
-
3308
- if (isNaN(timeout)) {
3309
- reject(createError(
3310
- 'error trying to parse `config.timeout` to int',
3311
- config,
3312
- 'ERR_PARSE_TIMEOUT',
3313
- req
3314
- ));
3315
-
3316
- return;
3317
- }
3318
-
3319
- // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
3320
- // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
3321
- // 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.
3322
- // And then these socket which be hang up will devoring CPU little by little.
3323
- // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
3324
- req.setTimeout(timeout, function handleRequestTimeout() {
3325
- req.abort();
3326
- var timeoutErrorMessage = '';
3327
- if (config.timeoutErrorMessage) {
3328
- timeoutErrorMessage = config.timeoutErrorMessage;
3329
- } else {
3330
- timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
3331
- }
3332
- var transitional = config.transitional || transitionalDefaults;
3333
- reject(createError(
3334
- timeoutErrorMessage,
3335
- config,
3336
- transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
3337
- req
3338
- ));
3339
- });
3340
- }
3341
-
3342
- if (config.cancelToken || config.signal) {
3343
- // Handle cancellation
3344
- // eslint-disable-next-line func-names
3345
- onCanceled = function(cancel) {
3346
- if (req.aborted) return;
3347
-
3348
- req.abort();
3349
- reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
3350
- };
3351
-
3352
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
3353
- if (config.signal) {
3354
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
3355
- }
3356
- }
3357
-
3358
-
3359
- // Send the request
3360
- if (utils.isStream(data)) {
3361
- data.on('error', function handleStreamError(err) {
3362
- reject(enhanceError(err, config, null, req));
3363
- }).pipe(req);
3364
- } else {
3365
- req.end(data);
3366
- }
3367
- });
3368
- };
3369
- return http_1;
3370
- }var utils$5 = utils$9;
3371
- var normalizeHeaderName = normalizeHeaderName$1;
3372
- var enhanceError = enhanceError$1;
3373
- var transitionalDefaults = transitional;
3374
-
3375
- var DEFAULT_CONTENT_TYPE = {
3376
- 'Content-Type': 'application/x-www-form-urlencoded'
3377
- };
3378
-
3379
- function setContentTypeIfUnset(headers, value) {
3380
- if (!utils$5.isUndefined(headers) && utils$5.isUndefined(headers['Content-Type'])) {
3381
- headers['Content-Type'] = value;
3382
- }
3383
- }
3384
-
3385
- function getDefaultAdapter() {
3386
- var adapter;
3387
- if (typeof XMLHttpRequest !== 'undefined') {
3388
- // For browsers use XHR adapter
3389
- adapter = requireXhr();
3390
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
3391
- // For node use HTTP adapter
3392
- adapter = requireHttp();
3393
- }
3394
- return adapter;
3395
- }
3396
-
3397
- function stringifySafely(rawValue, parser, encoder) {
3398
- if (utils$5.isString(rawValue)) {
3399
- try {
3400
- (parser || JSON.parse)(rawValue);
3401
- return utils$5.trim(rawValue);
3402
- } catch (e) {
3403
- if (e.name !== 'SyntaxError') {
3404
- throw e;
3405
- }
3406
- }
3407
- }
3408
-
3409
- return (encoder || JSON.stringify)(rawValue);
3410
- }
3411
-
3412
- var defaults$3 = {
3413
-
3414
- transitional: transitionalDefaults,
3415
-
3416
- adapter: getDefaultAdapter(),
3417
-
3418
- transformRequest: [function transformRequest(data, headers) {
3419
- normalizeHeaderName(headers, 'Accept');
3420
- normalizeHeaderName(headers, 'Content-Type');
3421
-
3422
- if (utils$5.isFormData(data) ||
3423
- utils$5.isArrayBuffer(data) ||
3424
- utils$5.isBuffer(data) ||
3425
- utils$5.isStream(data) ||
3426
- utils$5.isFile(data) ||
3427
- utils$5.isBlob(data)
3428
- ) {
3429
- return data;
3430
- }
3431
- if (utils$5.isArrayBufferView(data)) {
3432
- return data.buffer;
3433
- }
3434
- if (utils$5.isURLSearchParams(data)) {
3435
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
3436
- return data.toString();
3437
- }
3438
- if (utils$5.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
3439
- setContentTypeIfUnset(headers, 'application/json');
3440
- return stringifySafely(data);
3441
- }
3442
- return data;
3443
- }],
3444
-
3445
- transformResponse: [function transformResponse(data) {
3446
- var transitional = this.transitional || defaults$3.transitional;
3447
- var silentJSONParsing = transitional && transitional.silentJSONParsing;
3448
- var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
3449
- var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
3450
-
3451
- if (strictJSONParsing || (forcedJSONParsing && utils$5.isString(data) && data.length)) {
3452
- try {
3453
- return JSON.parse(data);
3454
- } catch (e) {
3455
- if (strictJSONParsing) {
3456
- if (e.name === 'SyntaxError') {
3457
- throw enhanceError(e, this, 'E_JSON_PARSE');
3458
- }
3459
- throw e;
3460
- }
3461
- }
3462
- }
3463
-
3464
- return data;
3465
- }],
3466
-
3467
- /**
3468
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
3469
- * timeout is not created.
3470
- */
3471
- timeout: 0,
3472
-
3473
- xsrfCookieName: 'XSRF-TOKEN',
3474
- xsrfHeaderName: 'X-XSRF-TOKEN',
3475
-
3476
- maxContentLength: -1,
3477
- maxBodyLength: -1,
3478
-
3479
- validateStatus: function validateStatus(status) {
3480
- return status >= 200 && status < 300;
3481
- },
3482
-
3483
- headers: {
3484
- common: {
3485
- 'Accept': 'application/json, text/plain, */*'
3486
- }
3487
- }
3488
- };
3489
-
3490
- utils$5.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
3491
- defaults$3.headers[method] = {};
3492
- });
3493
-
3494
- utils$5.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3495
- defaults$3.headers[method] = utils$5.merge(DEFAULT_CONTENT_TYPE);
3496
- });
3497
-
3498
- var defaults_1 = defaults$3;var utils$4 = utils$9;
3499
- var defaults$2 = defaults_1;
3500
-
3501
- /**
3502
- * Transform the data for a request or a response
3503
- *
3504
- * @param {Object|String} data The data to be transformed
3505
- * @param {Array} headers The headers for the request or response
3506
- * @param {Array|Function} fns A single function or Array of functions
3507
- * @returns {*} The resulting transformed data
3508
- */
3509
- var transformData$1 = function transformData(data, headers, fns) {
3510
- var context = this || defaults$2;
3511
- /*eslint no-param-reassign:0*/
3512
- utils$4.forEach(fns, function transform(fn) {
3513
- data = fn.call(context, data, headers);
3514
- });
3515
-
3516
- return data;
3517
- };var isCancel$1;
3518
- var hasRequiredIsCancel;
3519
-
3520
- function requireIsCancel () {
3521
- if (hasRequiredIsCancel) return isCancel$1;
3522
- hasRequiredIsCancel = 1;
3523
-
3524
- isCancel$1 = function isCancel(value) {
3525
- return !!(value && value.__CANCEL__);
3526
- };
3527
- return isCancel$1;
3528
- }var utils$3 = utils$9;
3529
- var transformData = transformData$1;
3530
- var isCancel = requireIsCancel();
3531
- var defaults$1 = defaults_1;
3532
- var Cancel = requireCancel();
3533
-
3534
- /**
3535
- * Throws a `Cancel` if cancellation has been requested.
3536
- */
3537
- function throwIfCancellationRequested(config) {
3538
- if (config.cancelToken) {
3539
- config.cancelToken.throwIfRequested();
3540
- }
3541
-
3542
- if (config.signal && config.signal.aborted) {
3543
- throw new Cancel('canceled');
3544
- }
3545
- }
3546
-
3547
- /**
3548
- * Dispatch a request to the server using the configured adapter.
3549
- *
3550
- * @param {object} config The config that is to be used for the request
3551
- * @returns {Promise} The Promise to be fulfilled
3552
- */
3553
- var dispatchRequest$1 = function dispatchRequest(config) {
3554
- throwIfCancellationRequested(config);
3555
-
3556
- // Ensure headers exist
3557
- config.headers = config.headers || {};
3558
-
3559
- // Transform request data
3560
- config.data = transformData.call(
3561
- config,
3562
- config.data,
3563
- config.headers,
3564
- config.transformRequest
3565
- );
3566
-
3567
- // Flatten headers
3568
- config.headers = utils$3.merge(
3569
- config.headers.common || {},
3570
- config.headers[config.method] || {},
3571
- config.headers
3572
- );
3573
-
3574
- utils$3.forEach(
3575
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3576
- function cleanHeaderConfig(method) {
3577
- delete config.headers[method];
3578
- }
3579
- );
3580
-
3581
- var adapter = config.adapter || defaults$1.adapter;
3582
-
3583
- return adapter(config).then(function onAdapterResolution(response) {
3584
- throwIfCancellationRequested(config);
3585
-
3586
- // Transform response data
3587
- response.data = transformData.call(
3588
- config,
3589
- response.data,
3590
- response.headers,
3591
- config.transformResponse
3592
- );
3593
-
3594
- return response;
3595
- }, function onAdapterRejection(reason) {
3596
- if (!isCancel(reason)) {
3597
- throwIfCancellationRequested(config);
3598
-
3599
- // Transform response data
3600
- if (reason && reason.response) {
3601
- reason.response.data = transformData.call(
3602
- config,
3603
- reason.response.data,
3604
- reason.response.headers,
3605
- config.transformResponse
3606
- );
3607
- }
3608
- }
3609
-
3610
- return Promise.reject(reason);
3611
- });
3612
- };var utils$2 = utils$9;
3613
-
3614
- /**
3615
- * Config-specific merge-function which creates a new config-object
3616
- * by merging two configuration objects together.
3617
- *
3618
- * @param {Object} config1
3619
- * @param {Object} config2
3620
- * @returns {Object} New object resulting from merging config2 to config1
3621
- */
3622
- var mergeConfig$2 = function mergeConfig(config1, config2) {
3623
- // eslint-disable-next-line no-param-reassign
3624
- config2 = config2 || {};
3625
- var config = {};
3626
-
3627
- function getMergedValue(target, source) {
3628
- if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
3629
- return utils$2.merge(target, source);
3630
- } else if (utils$2.isPlainObject(source)) {
3631
- return utils$2.merge({}, source);
3632
- } else if (utils$2.isArray(source)) {
3633
- return source.slice();
3634
- }
3635
- return source;
3636
- }
3637
-
3638
- // eslint-disable-next-line consistent-return
3639
- function mergeDeepProperties(prop) {
3640
- if (!utils$2.isUndefined(config2[prop])) {
3641
- return getMergedValue(config1[prop], config2[prop]);
3642
- } else if (!utils$2.isUndefined(config1[prop])) {
3643
- return getMergedValue(undefined, config1[prop]);
3644
- }
3645
- }
3646
-
3647
- // eslint-disable-next-line consistent-return
3648
- function valueFromConfig2(prop) {
3649
- if (!utils$2.isUndefined(config2[prop])) {
3650
- return getMergedValue(undefined, config2[prop]);
3651
- }
3652
- }
3653
-
3654
- // eslint-disable-next-line consistent-return
3655
- function defaultToConfig2(prop) {
3656
- if (!utils$2.isUndefined(config2[prop])) {
3657
- return getMergedValue(undefined, config2[prop]);
3658
- } else if (!utils$2.isUndefined(config1[prop])) {
3659
- return getMergedValue(undefined, config1[prop]);
3660
- }
3661
- }
3662
-
3663
- // eslint-disable-next-line consistent-return
3664
- function mergeDirectKeys(prop) {
3665
- if (prop in config2) {
3666
- return getMergedValue(config1[prop], config2[prop]);
3667
- } else if (prop in config1) {
3668
- return getMergedValue(undefined, config1[prop]);
3669
- }
3670
- }
3671
-
3672
- var mergeMap = {
3673
- 'url': valueFromConfig2,
3674
- 'method': valueFromConfig2,
3675
- 'data': valueFromConfig2,
3676
- 'baseURL': defaultToConfig2,
3677
- 'transformRequest': defaultToConfig2,
3678
- 'transformResponse': defaultToConfig2,
3679
- 'paramsSerializer': defaultToConfig2,
3680
- 'timeout': defaultToConfig2,
3681
- 'timeoutMessage': defaultToConfig2,
3682
- 'withCredentials': defaultToConfig2,
3683
- 'adapter': defaultToConfig2,
3684
- 'responseType': defaultToConfig2,
3685
- 'xsrfCookieName': defaultToConfig2,
3686
- 'xsrfHeaderName': defaultToConfig2,
3687
- 'onUploadProgress': defaultToConfig2,
3688
- 'onDownloadProgress': defaultToConfig2,
3689
- 'decompress': defaultToConfig2,
3690
- 'maxContentLength': defaultToConfig2,
3691
- 'maxBodyLength': defaultToConfig2,
3692
- 'transport': defaultToConfig2,
3693
- 'httpAgent': defaultToConfig2,
3694
- 'httpsAgent': defaultToConfig2,
3695
- 'cancelToken': defaultToConfig2,
3696
- 'socketPath': defaultToConfig2,
3697
- 'responseEncoding': defaultToConfig2,
3698
- 'validateStatus': mergeDirectKeys
3699
- };
3700
-
3701
- utils$2.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3702
- var merge = mergeMap[prop] || mergeDeepProperties;
3703
- var configValue = merge(prop);
3704
- (utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
3705
- });
3706
-
3707
- return config;
3708
- };var VERSION = requireData().version;
3709
-
3710
- var validators$1 = {};
3711
-
3712
- // eslint-disable-next-line func-names
3713
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
3714
- validators$1[type] = function validator(thing) {
3715
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3716
- };
3717
- });
3718
-
3719
- var deprecatedWarnings = {};
3720
-
3721
- /**
3722
- * Transitional option validator
3723
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
3724
- * @param {string?} version - deprecated version / removed since version
3725
- * @param {string?} message - some message with additional info
3726
- * @returns {function}
3727
- */
3728
- validators$1.transitional = function transitional(validator, version, message) {
3729
- function formatMessage(opt, desc) {
3730
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3731
- }
3732
-
3733
- // eslint-disable-next-line func-names
3734
- return function(value, opt, opts) {
3735
- if (validator === false) {
3736
- throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
3737
- }
3738
-
3739
- if (version && !deprecatedWarnings[opt]) {
3740
- deprecatedWarnings[opt] = true;
3741
- // eslint-disable-next-line no-console
3742
- console.warn(
3743
- formatMessage(
3744
- opt,
3745
- ' has been deprecated since v' + version + ' and will be removed in the near future'
3746
- )
3747
- );
3748
- }
3749
-
3750
- return validator ? validator(value, opt, opts) : true;
3751
- };
3752
- };
3753
-
3754
- /**
3755
- * Assert object's properties type
3756
- * @param {object} options
3757
- * @param {object} schema
3758
- * @param {boolean?} allowUnknown
3759
- */
3760
-
3761
- function assertOptions(options, schema, allowUnknown) {
3762
- if (typeof options !== 'object') {
3763
- throw new TypeError('options must be an object');
3764
- }
3765
- var keys = Object.keys(options);
3766
- var i = keys.length;
3767
- while (i-- > 0) {
3768
- var opt = keys[i];
3769
- var validator = schema[opt];
3770
- if (validator) {
3771
- var value = options[opt];
3772
- var result = value === undefined || validator(value, opt, options);
3773
- if (result !== true) {
3774
- throw new TypeError('option ' + opt + ' must be ' + result);
3775
- }
3776
- continue;
3777
- }
3778
- if (allowUnknown !== true) {
3779
- throw Error('Unknown option ' + opt);
3780
- }
3781
- }
3782
- }
3783
-
3784
- var validator$1 = {
3785
- assertOptions: assertOptions,
3786
- validators: validators$1
3787
- };var utils$1 = utils$9;
3788
- var buildURL = buildURL$1;
3789
- var InterceptorManager = InterceptorManager_1;
3790
- var dispatchRequest = dispatchRequest$1;
3791
- var mergeConfig$1 = mergeConfig$2;
3792
- var validator = validator$1;
3793
-
3794
- var validators = validator.validators;
3795
- /**
3796
- * Create a new instance of Axios
3797
- *
3798
- * @param {Object} instanceConfig The default config for the instance
3799
- */
3800
- function Axios$1(instanceConfig) {
3801
- this.defaults = instanceConfig;
3802
- this.interceptors = {
3803
- request: new InterceptorManager(),
3804
- response: new InterceptorManager()
3805
- };
3806
- }
3807
-
3808
- /**
3809
- * Dispatch a request
3810
- *
3811
- * @param {Object} config The config specific for this request (merged with this.defaults)
3812
- */
3813
- Axios$1.prototype.request = function request(configOrUrl, config) {
3814
- /*eslint no-param-reassign:0*/
3815
- // Allow for axios('example/url'[, config]) a la fetch API
3816
- if (typeof configOrUrl === 'string') {
3817
- config = config || {};
3818
- config.url = configOrUrl;
3819
- } else {
3820
- config = configOrUrl || {};
3821
- }
3822
-
3823
- config = mergeConfig$1(this.defaults, config);
3824
-
3825
- // Set config.method
3826
- if (config.method) {
3827
- config.method = config.method.toLowerCase();
3828
- } else if (this.defaults.method) {
3829
- config.method = this.defaults.method.toLowerCase();
3830
- } else {
3831
- config.method = 'get';
3832
- }
3833
-
3834
- var transitional = config.transitional;
3835
-
3836
- if (transitional !== undefined) {
3837
- validator.assertOptions(transitional, {
3838
- silentJSONParsing: validators.transitional(validators.boolean),
3839
- forcedJSONParsing: validators.transitional(validators.boolean),
3840
- clarifyTimeoutError: validators.transitional(validators.boolean)
3841
- }, false);
3842
- }
3843
-
3844
- // filter out skipped interceptors
3845
- var requestInterceptorChain = [];
3846
- var synchronousRequestInterceptors = true;
3847
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3848
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3849
- return;
3850
- }
3851
-
3852
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3853
-
3854
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3855
- });
3856
-
3857
- var responseInterceptorChain = [];
3858
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3859
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3860
- });
3861
-
3862
- var promise;
3863
-
3864
- if (!synchronousRequestInterceptors) {
3865
- var chain = [dispatchRequest, undefined];
3866
-
3867
- Array.prototype.unshift.apply(chain, requestInterceptorChain);
3868
- chain = chain.concat(responseInterceptorChain);
3869
-
3870
- promise = Promise.resolve(config);
3871
- while (chain.length) {
3872
- promise = promise.then(chain.shift(), chain.shift());
3873
- }
3874
-
3875
- return promise;
3876
- }
3877
-
3878
-
3879
- var newConfig = config;
3880
- while (requestInterceptorChain.length) {
3881
- var onFulfilled = requestInterceptorChain.shift();
3882
- var onRejected = requestInterceptorChain.shift();
3883
- try {
3884
- newConfig = onFulfilled(newConfig);
3885
- } catch (error) {
3886
- onRejected(error);
3887
- break;
3888
- }
3889
- }
3890
-
3891
- try {
3892
- promise = dispatchRequest(newConfig);
3893
- } catch (error) {
3894
- return Promise.reject(error);
3895
- }
3896
-
3897
- while (responseInterceptorChain.length) {
3898
- promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
3899
- }
3900
-
3901
- return promise;
3902
- };
3903
-
3904
- Axios$1.prototype.getUri = function getUri(config) {
3905
- config = mergeConfig$1(this.defaults, config);
3906
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
3907
- };
3908
-
3909
- // Provide aliases for supported request methods
3910
- utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3911
- /*eslint func-names:0*/
3912
- Axios$1.prototype[method] = function(url, config) {
3913
- return this.request(mergeConfig$1(config || {}, {
3914
- method: method,
3915
- url: url,
3916
- data: (config || {}).data
3917
- }));
3918
- };
3919
- });
3920
-
3921
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3922
- /*eslint func-names:0*/
3923
- Axios$1.prototype[method] = function(url, data, config) {
3924
- return this.request(mergeConfig$1(config || {}, {
3925
- method: method,
3926
- url: url,
3927
- data: data
3928
- }));
3929
- };
3930
- });
3931
-
3932
- var Axios_1 = Axios$1;var CancelToken_1;
3933
- var hasRequiredCancelToken;
3934
-
3935
- function requireCancelToken () {
3936
- if (hasRequiredCancelToken) return CancelToken_1;
3937
- hasRequiredCancelToken = 1;
3938
-
3939
- var Cancel = requireCancel();
3940
-
3941
- /**
3942
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
3943
- *
3944
- * @class
3945
- * @param {Function} executor The executor function.
3946
- */
3947
- function CancelToken(executor) {
3948
- if (typeof executor !== 'function') {
3949
- throw new TypeError('executor must be a function.');
3950
- }
3951
-
3952
- var resolvePromise;
3953
-
3954
- this.promise = new Promise(function promiseExecutor(resolve) {
3955
- resolvePromise = resolve;
3956
- });
3957
-
3958
- var token = this;
3959
-
3960
- // eslint-disable-next-line func-names
3961
- this.promise.then(function(cancel) {
3962
- if (!token._listeners) return;
3963
-
3964
- var i;
3965
- var l = token._listeners.length;
3966
-
3967
- for (i = 0; i < l; i++) {
3968
- token._listeners[i](cancel);
3969
- }
3970
- token._listeners = null;
3971
- });
3972
-
3973
- // eslint-disable-next-line func-names
3974
- this.promise.then = function(onfulfilled) {
3975
- var _resolve;
3976
- // eslint-disable-next-line func-names
3977
- var promise = new Promise(function(resolve) {
3978
- token.subscribe(resolve);
3979
- _resolve = resolve;
3980
- }).then(onfulfilled);
3981
-
3982
- promise.cancel = function reject() {
3983
- token.unsubscribe(_resolve);
3984
- };
3985
-
3986
- return promise;
3987
- };
3988
-
3989
- executor(function cancel(message) {
3990
- if (token.reason) {
3991
- // Cancellation has already been requested
3992
- return;
3993
- }
3994
-
3995
- token.reason = new Cancel(message);
3996
- resolvePromise(token.reason);
3997
- });
3998
- }
3999
-
4000
- /**
4001
- * Throws a `Cancel` if cancellation has been requested.
4002
- */
4003
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
4004
- if (this.reason) {
4005
- throw this.reason;
4006
- }
4007
- };
4008
-
4009
- /**
4010
- * Subscribe to the cancel signal
4011
- */
4012
-
4013
- CancelToken.prototype.subscribe = function subscribe(listener) {
4014
- if (this.reason) {
4015
- listener(this.reason);
4016
- return;
4017
- }
4018
-
4019
- if (this._listeners) {
4020
- this._listeners.push(listener);
4021
- } else {
4022
- this._listeners = [listener];
4023
- }
4024
- };
4025
-
4026
- /**
4027
- * Unsubscribe from the cancel signal
4028
- */
4029
-
4030
- CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
4031
- if (!this._listeners) {
4032
- return;
4033
- }
4034
- var index = this._listeners.indexOf(listener);
4035
- if (index !== -1) {
4036
- this._listeners.splice(index, 1);
4037
- }
4038
- };
4039
-
4040
- /**
4041
- * Returns an object that contains a new `CancelToken` and a function that, when called,
4042
- * cancels the `CancelToken`.
4043
- */
4044
- CancelToken.source = function source() {
4045
- var cancel;
4046
- var token = new CancelToken(function executor(c) {
4047
- cancel = c;
4048
- });
4049
- return {
4050
- token: token,
4051
- cancel: cancel
4052
- };
4053
- };
4054
-
4055
- CancelToken_1 = CancelToken;
4056
- return CancelToken_1;
4057
- }var spread;
4058
- var hasRequiredSpread;
4059
-
4060
- function requireSpread () {
4061
- if (hasRequiredSpread) return spread;
4062
- hasRequiredSpread = 1;
4063
-
4064
- /**
4065
- * Syntactic sugar for invoking a function and expanding an array for arguments.
4066
- *
4067
- * Common use case would be to use `Function.prototype.apply`.
4068
- *
4069
- * ```js
4070
- * function f(x, y, z) {}
4071
- * var args = [1, 2, 3];
4072
- * f.apply(null, args);
4073
- * ```
4074
- *
4075
- * With `spread` this example can be re-written.
4076
- *
4077
- * ```js
4078
- * spread(function(x, y, z) {})([1, 2, 3]);
4079
- * ```
4080
- *
4081
- * @param {Function} callback
4082
- * @returns {Function}
4083
- */
4084
- spread = function spread(callback) {
4085
- return function wrap(arr) {
4086
- return callback.apply(null, arr);
4087
- };
4088
- };
4089
- return spread;
4090
- }var isAxiosError;
4091
- var hasRequiredIsAxiosError;
4092
-
4093
- function requireIsAxiosError () {
4094
- if (hasRequiredIsAxiosError) return isAxiosError;
4095
- hasRequiredIsAxiosError = 1;
4096
-
4097
- var utils = utils$9;
4098
-
4099
- /**
4100
- * Determines whether the payload is an error thrown by Axios
4101
- *
4102
- * @param {*} payload The value to test
4103
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4104
- */
4105
- isAxiosError = function isAxiosError(payload) {
4106
- return utils.isObject(payload) && (payload.isAxiosError === true);
4107
- };
4108
- return isAxiosError;
4109
- }var utils = utils$9;
4110
- var bind = bind$2;
4111
- var Axios = Axios_1;
4112
- var mergeConfig = mergeConfig$2;
4113
- var defaults = defaults_1;
4114
-
4115
- /**
4116
- * Create an instance of Axios
4117
- *
4118
- * @param {Object} defaultConfig The default config for the instance
4119
- * @return {Axios} A new instance of Axios
4120
- */
4121
- function createInstance(defaultConfig) {
4122
- var context = new Axios(defaultConfig);
4123
- var instance = bind(Axios.prototype.request, context);
4124
-
4125
- // Copy axios.prototype to instance
4126
- utils.extend(instance, Axios.prototype, context);
4127
-
4128
- // Copy context to instance
4129
- utils.extend(instance, context);
4130
-
4131
- // Factory for creating new instances
4132
- instance.create = function create(instanceConfig) {
4133
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
4134
- };
4135
-
4136
- return instance;
4137
- }
4138
-
4139
- // Create the default instance to be exported
4140
- var axios$1 = createInstance(defaults);
4141
-
4142
- // Expose Axios class to allow class inheritance
4143
- axios$1.Axios = Axios;
4144
-
4145
- // Expose Cancel & CancelToken
4146
- axios$1.Cancel = requireCancel();
4147
- axios$1.CancelToken = requireCancelToken();
4148
- axios$1.isCancel = requireIsCancel();
4149
- axios$1.VERSION = requireData().version;
4150
-
4151
- // Expose all/spread
4152
- axios$1.all = function all(promises) {
4153
- return Promise.all(promises);
4154
- };
4155
- axios$1.spread = requireSpread();
4156
-
4157
- // Expose isAxiosError
4158
- axios$1.isAxiosError = requireIsAxiosError();
4159
-
4160
- axios$2.exports = axios$1;
4161
-
4162
- // Allow use of default import syntax in TypeScript
4163
- axios$2.exports.default = axios$1;(function (module) {
4164
- module.exports = axios$2.exports;
4165
- } (axios$3));
4166
-
4167
- var axios = /*@__PURE__*/getDefaultExportFromCjs(axios$3.exports);var getFile = function (filePath) {
4168
- return fs.readFileSync(filePath, 'utf8');
4169
- };
4170
- var getBase64Image = function (filePath) {
4171
- return "data:image/png;base64,".concat(fs.readFileSync(filePath).toString('base64'));
4172
- };
4173
- var downloadImage = function (url) { return __awaiter(void 0, void 0, void 0, function () {
4174
- var base64, response, buffer, err_1;
4175
- return __generator(this, function (_a) {
4176
- switch (_a.label) {
4177
- case 0:
4178
- base64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
4179
- _a.label = 1;
4180
- case 1:
4181
- _a.trys.push([1, 3, , 4]);
4182
- return [4 /*yield*/, axios.get(url, { responseType: 'arraybuffer' })];
4183
- case 2:
4184
- response = _a.sent();
4185
- buffer = Buffer.from(response.data, 'utf-8');
4186
- base64 = buffer.toString('base64');
4187
- return [3 /*break*/, 4];
4188
- case 3:
4189
- err_1 = _a.sent();
4190
- console.error(err_1);
4191
- return [3 /*break*/, 4];
4192
- case 4: return [2 /*return*/, "data:image/png;base64,".concat(base64)];
4193
- }
4194
- });
4195
- }); };export{__awaiter as _,__generator as a,getBase64Image as b,commonjsGlobal as c,downloadImage as d,getFile as g};