@bigbinary/neeto-playwright-reporter 1.4.1 → 1.5.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.
package/index.cjs.js CHANGED
@@ -4,16 +4,16 @@ var crypto = require('crypto');
4
4
  var neetoCist = require('@bigbinary/neeto-cist');
5
5
  var require$$1 = require('util');
6
6
  var stream = require('stream');
7
- var require$$1$1 = require('path');
7
+ var path$1 = require('path');
8
8
  var require$$3 = require('http');
9
9
  var require$$4 = require('https');
10
10
  var require$$0$1 = require('url');
11
11
  var require$$6 = require('fs');
12
12
  var require$$4$1 = require('assert');
13
- var require$$1$2 = require('tty');
13
+ var require$$1$1 = require('tty');
14
14
  var require$$0$2 = require('os');
15
15
  var zlib = require('zlib');
16
- var EventEmitter = require('events');
16
+ var events$1 = require('events');
17
17
  var ramda = require('ramda');
18
18
  var childProcess = require('child_process');
19
19
 
@@ -22,16 +22,15 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
22
22
  var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
23
23
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
24
24
  var stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
25
- var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
25
+ var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
26
26
  var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
27
27
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
28
28
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
29
29
  var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
30
30
  var require$$4__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$4$1);
31
- var require$$1__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
31
+ var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
32
32
  var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
33
33
  var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
34
- var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
35
34
  var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess);
36
35
 
37
36
  const ERRORS = {
@@ -344,6 +343,8 @@ const isFormData = (thing) => {
344
343
  */
345
344
  const isURLSearchParams = kindOfTest('URLSearchParams');
346
345
 
346
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
347
+
347
348
  /**
348
349
  * Trim excess whitespace off the beginning and end of a string
349
350
  *
@@ -732,8 +733,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
732
733
  const noop$1 = () => {};
733
734
 
734
735
  const toFiniteNumber = (value, defaultValue) => {
735
- value = +value;
736
- return Number.isFinite(value) ? value : defaultValue;
736
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
737
737
  };
738
738
 
739
739
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -803,6 +803,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
803
803
  const isThenable = (thing) =>
804
804
  thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
805
805
 
806
+ // original code
807
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
808
+
809
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
810
+ if (setImmediateSupported) {
811
+ return setImmediate;
812
+ }
813
+
814
+ return postMessageSupported ? ((token, callbacks) => {
815
+ _global.addEventListener("message", ({source, data}) => {
816
+ if (source === _global && data === token) {
817
+ callbacks.length && callbacks.shift()();
818
+ }
819
+ }, false);
820
+
821
+ return (cb) => {
822
+ callbacks.push(cb);
823
+ _global.postMessage(token, "*");
824
+ }
825
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
826
+ })(
827
+ typeof setImmediate === 'function',
828
+ isFunction$1(_global.postMessage)
829
+ );
830
+
831
+ const asap = typeof queueMicrotask !== 'undefined' ?
832
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
833
+
834
+ // *********************
835
+
806
836
  var utils$1 = {
807
837
  isArray,
808
838
  isArrayBuffer,
@@ -814,6 +844,10 @@ var utils$1 = {
814
844
  isBoolean,
815
845
  isObject,
816
846
  isPlainObject,
847
+ isReadableStream,
848
+ isRequest,
849
+ isResponse,
850
+ isHeaders,
817
851
  isUndefined,
818
852
  isDate,
819
853
  isFile,
@@ -854,7 +888,9 @@ var utils$1 = {
854
888
  isSpecCompliantForm,
855
889
  toJSONObject,
856
890
  isAsyncFn,
857
- isThenable
891
+ isThenable,
892
+ setImmediate: _setImmediate,
893
+ asap
858
894
  };
859
895
 
860
896
  /**
@@ -12006,7 +12042,7 @@ var require$$0 = {
12006
12042
  */
12007
12043
 
12008
12044
  var db = mimeDb.exports;
12009
- var extname = require$$1__default$1["default"].extname;
12045
+ var extname = path__default["default"].extname;
12010
12046
 
12011
12047
  /**
12012
12048
  * Module variables.
@@ -12577,7 +12613,7 @@ var populate$1 = function(dst, src) {
12577
12613
 
12578
12614
  var CombinedStream = combined_stream;
12579
12615
  var util = require$$1__default["default"];
12580
- var path = require$$1__default$1["default"];
12616
+ var path = path__default["default"];
12581
12617
  var http$1 = require$$3__default["default"];
12582
12618
  var https$1 = require$$4__default["default"];
12583
12619
  var parseUrl$2 = require$$0__default["default"].parse;
@@ -13526,11 +13562,14 @@ const hasStandardBrowserWebWorkerEnv = (() => {
13526
13562
  );
13527
13563
  })();
13528
13564
 
13565
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
13566
+
13529
13567
  var utils = /*#__PURE__*/Object.freeze({
13530
13568
  __proto__: null,
13531
13569
  hasBrowserEnv: hasBrowserEnv,
13532
13570
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
13533
- hasStandardBrowserEnv: hasStandardBrowserEnv
13571
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
13572
+ origin: origin
13534
13573
  });
13535
13574
 
13536
13575
  var platform = {
@@ -13670,7 +13709,7 @@ const defaults = {
13670
13709
 
13671
13710
  transitional: transitionalDefaults,
13672
13711
 
13673
- adapter: ['xhr', 'http'],
13712
+ adapter: ['xhr', 'http', 'fetch'],
13674
13713
 
13675
13714
  transformRequest: [function transformRequest(data, headers) {
13676
13715
  const contentType = headers.getContentType() || '';
@@ -13691,7 +13730,8 @@ const defaults = {
13691
13730
  utils$1.isBuffer(data) ||
13692
13731
  utils$1.isStream(data) ||
13693
13732
  utils$1.isFile(data) ||
13694
- utils$1.isBlob(data)
13733
+ utils$1.isBlob(data) ||
13734
+ utils$1.isReadableStream(data)
13695
13735
  ) {
13696
13736
  return data;
13697
13737
  }
@@ -13734,6 +13774,10 @@ const defaults = {
13734
13774
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
13735
13775
  const JSONRequested = this.responseType === 'json';
13736
13776
 
13777
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
13778
+ return data;
13779
+ }
13780
+
13737
13781
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
13738
13782
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
13739
13783
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -13935,6 +13979,10 @@ class AxiosHeaders {
13935
13979
  setHeaders(header, valueOrRewrite);
13936
13980
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
13937
13981
  setHeaders(parseHeaders(header), valueOrRewrite);
13982
+ } else if (utils$1.isHeaders(header)) {
13983
+ for (const [key, value] of header.entries()) {
13984
+ setHeader(value, key, rewrite);
13985
+ }
13938
13986
  } else {
13939
13987
  header != null && setHeader(valueOrRewrite, header, rewrite);
13940
13988
  }
@@ -15115,7 +15163,7 @@ function requireSupportsColor () {
15115
15163
  if (hasRequiredSupportsColor) return supportsColor_1;
15116
15164
  hasRequiredSupportsColor = 1;
15117
15165
  const os = require$$0__default$1["default"];
15118
- const tty = require$$1__default$2["default"];
15166
+ const tty = require$$1__default$1["default"];
15119
15167
  const hasFlag = requireHasFlag();
15120
15168
 
15121
15169
  const {env} = process;
@@ -15261,7 +15309,7 @@ function requireNode () {
15261
15309
  if (hasRequiredNode) return node.exports;
15262
15310
  hasRequiredNode = 1;
15263
15311
  (function (module, exports) {
15264
- const tty = require$$1__default$2["default"];
15312
+ const tty = require$$1__default$1["default"];
15265
15313
  const util = require$$1__default["default"];
15266
15314
 
15267
15315
  /**
@@ -16233,7 +16281,7 @@ function isURL(value) {
16233
16281
  followRedirects.exports = wrap({ http: http, https: https });
16234
16282
  followRedirects.exports.wrap = wrap;
16235
16283
 
16236
- const VERSION = "1.6.7";
16284
+ const VERSION = "1.7.4";
16237
16285
 
16238
16286
  function parseProtocol(url) {
16239
16287
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -16288,88 +16336,6 @@ function fromDataURI(uri, asBlob, options) {
16288
16336
  throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
16289
16337
  }
16290
16338
 
16291
- /**
16292
- * Throttle decorator
16293
- * @param {Function} fn
16294
- * @param {Number} freq
16295
- * @return {Function}
16296
- */
16297
- function throttle(fn, freq) {
16298
- let timestamp = 0;
16299
- const threshold = 1000 / freq;
16300
- let timer = null;
16301
- return function throttled(force, args) {
16302
- const now = Date.now();
16303
- if (force || now - timestamp > threshold) {
16304
- if (timer) {
16305
- clearTimeout(timer);
16306
- timer = null;
16307
- }
16308
- timestamp = now;
16309
- return fn.apply(null, args);
16310
- }
16311
- if (!timer) {
16312
- timer = setTimeout(() => {
16313
- timer = null;
16314
- timestamp = Date.now();
16315
- return fn.apply(null, args);
16316
- }, threshold - (now - timestamp));
16317
- }
16318
- };
16319
- }
16320
-
16321
- /**
16322
- * Calculate data maxRate
16323
- * @param {Number} [samplesCount= 10]
16324
- * @param {Number} [min= 1000]
16325
- * @returns {Function}
16326
- */
16327
- function speedometer(samplesCount, min) {
16328
- samplesCount = samplesCount || 10;
16329
- const bytes = new Array(samplesCount);
16330
- const timestamps = new Array(samplesCount);
16331
- let head = 0;
16332
- let tail = 0;
16333
- let firstSampleTS;
16334
-
16335
- min = min !== undefined ? min : 1000;
16336
-
16337
- return function push(chunkLength) {
16338
- const now = Date.now();
16339
-
16340
- const startedAt = timestamps[tail];
16341
-
16342
- if (!firstSampleTS) {
16343
- firstSampleTS = now;
16344
- }
16345
-
16346
- bytes[head] = chunkLength;
16347
- timestamps[head] = now;
16348
-
16349
- let i = tail;
16350
- let bytesCount = 0;
16351
-
16352
- while (i !== head) {
16353
- bytesCount += bytes[i++];
16354
- i = i % samplesCount;
16355
- }
16356
-
16357
- head = (head + 1) % samplesCount;
16358
-
16359
- if (head === tail) {
16360
- tail = (tail + 1) % samplesCount;
16361
- }
16362
-
16363
- if (now - firstSampleTS < min) {
16364
- return;
16365
- }
16366
-
16367
- const passed = startedAt && now - startedAt;
16368
-
16369
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
16370
- };
16371
- }
16372
-
16373
16339
  const kInternals = Symbol('internals');
16374
16340
 
16375
16341
  class AxiosTransformStream extends stream__default["default"].Transform{
@@ -16389,12 +16355,8 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16389
16355
  readableHighWaterMark: options.chunkSize
16390
16356
  });
16391
16357
 
16392
- const self = this;
16393
-
16394
16358
  const internals = this[kInternals] = {
16395
- length: options.length,
16396
16359
  timeWindow: options.timeWindow,
16397
- ticksRate: options.ticksRate,
16398
16360
  chunkSize: options.chunkSize,
16399
16361
  maxRate: options.maxRate,
16400
16362
  minChunkSize: options.minChunkSize,
@@ -16406,8 +16368,6 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16406
16368
  onReadCallback: null
16407
16369
  };
16408
16370
 
16409
- const _speedometer = speedometer(internals.ticksRate * options.samplesCount, internals.timeWindow);
16410
-
16411
16371
  this.on('newListener', event => {
16412
16372
  if (event === 'progress') {
16413
16373
  if (!internals.isCaptured) {
@@ -16415,38 +16375,6 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16415
16375
  }
16416
16376
  }
16417
16377
  });
16418
-
16419
- let bytesNotified = 0;
16420
-
16421
- internals.updateProgress = throttle(function throttledHandler() {
16422
- const totalBytes = internals.length;
16423
- const bytesTransferred = internals.bytesSeen;
16424
- const progressBytes = bytesTransferred - bytesNotified;
16425
- if (!progressBytes || self.destroyed) return;
16426
-
16427
- const rate = _speedometer(progressBytes);
16428
-
16429
- bytesNotified = bytesTransferred;
16430
-
16431
- process.nextTick(() => {
16432
- self.emit('progress', {
16433
- 'loaded': bytesTransferred,
16434
- 'total': totalBytes,
16435
- 'progress': totalBytes ? (bytesTransferred / totalBytes) : undefined,
16436
- 'bytes': progressBytes,
16437
- 'rate': rate ? rate : undefined,
16438
- 'estimated': rate && totalBytes && bytesTransferred <= totalBytes ?
16439
- (totalBytes - bytesTransferred) / rate : undefined
16440
- });
16441
- });
16442
- }, internals.ticksRate);
16443
-
16444
- const onFinish = () => {
16445
- internals.updateProgress(true);
16446
- };
16447
-
16448
- this.once('end', onFinish);
16449
- this.once('error', onFinish);
16450
16378
  }
16451
16379
 
16452
16380
  _read(size) {
@@ -16460,7 +16388,6 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16460
16388
  }
16461
16389
 
16462
16390
  _transform(chunk, encoding, callback) {
16463
- const self = this;
16464
16391
  const internals = this[kInternals];
16465
16392
  const maxRate = internals.maxRate;
16466
16393
 
@@ -16472,16 +16399,14 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16472
16399
  const bytesThreshold = (maxRate / divider);
16473
16400
  const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
16474
16401
 
16475
- function pushChunk(_chunk, _callback) {
16402
+ const pushChunk = (_chunk, _callback) => {
16476
16403
  const bytes = Buffer.byteLength(_chunk);
16477
16404
  internals.bytesSeen += bytes;
16478
16405
  internals.bytes += bytes;
16479
16406
 
16480
- if (internals.isCaptured) {
16481
- internals.updateProgress();
16482
- }
16407
+ internals.isCaptured && this.emit('progress', internals.bytesSeen);
16483
16408
 
16484
- if (self.push(_chunk)) {
16409
+ if (this.push(_chunk)) {
16485
16410
  process.nextTick(_callback);
16486
16411
  } else {
16487
16412
  internals.onReadCallback = () => {
@@ -16489,7 +16414,7 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16489
16414
  process.nextTick(_callback);
16490
16415
  };
16491
16416
  }
16492
- }
16417
+ };
16493
16418
 
16494
16419
  const transformChunk = (_chunk, _callback) => {
16495
16420
  const chunkSize = Buffer.byteLength(_chunk);
@@ -16546,11 +16471,6 @@ class AxiosTransformStream extends stream__default["default"].Transform{
16546
16471
  }
16547
16472
  });
16548
16473
  }
16549
-
16550
- setLength(length) {
16551
- this[kInternals].length = +length;
16552
- return this;
16553
- }
16554
16474
  }
16555
16475
 
16556
16476
  const {asyncIterator} = Symbol;
@@ -16708,6 +16628,142 @@ const callbackify = (fn, reducer) => {
16708
16628
  } : fn;
16709
16629
  };
16710
16630
 
16631
+ /**
16632
+ * Calculate data maxRate
16633
+ * @param {Number} [samplesCount= 10]
16634
+ * @param {Number} [min= 1000]
16635
+ * @returns {Function}
16636
+ */
16637
+ function speedometer(samplesCount, min) {
16638
+ samplesCount = samplesCount || 10;
16639
+ const bytes = new Array(samplesCount);
16640
+ const timestamps = new Array(samplesCount);
16641
+ let head = 0;
16642
+ let tail = 0;
16643
+ let firstSampleTS;
16644
+
16645
+ min = min !== undefined ? min : 1000;
16646
+
16647
+ return function push(chunkLength) {
16648
+ const now = Date.now();
16649
+
16650
+ const startedAt = timestamps[tail];
16651
+
16652
+ if (!firstSampleTS) {
16653
+ firstSampleTS = now;
16654
+ }
16655
+
16656
+ bytes[head] = chunkLength;
16657
+ timestamps[head] = now;
16658
+
16659
+ let i = tail;
16660
+ let bytesCount = 0;
16661
+
16662
+ while (i !== head) {
16663
+ bytesCount += bytes[i++];
16664
+ i = i % samplesCount;
16665
+ }
16666
+
16667
+ head = (head + 1) % samplesCount;
16668
+
16669
+ if (head === tail) {
16670
+ tail = (tail + 1) % samplesCount;
16671
+ }
16672
+
16673
+ if (now - firstSampleTS < min) {
16674
+ return;
16675
+ }
16676
+
16677
+ const passed = startedAt && now - startedAt;
16678
+
16679
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
16680
+ };
16681
+ }
16682
+
16683
+ /**
16684
+ * Throttle decorator
16685
+ * @param {Function} fn
16686
+ * @param {Number} freq
16687
+ * @return {Function}
16688
+ */
16689
+ function throttle(fn, freq) {
16690
+ let timestamp = 0;
16691
+ let threshold = 1000 / freq;
16692
+ let lastArgs;
16693
+ let timer;
16694
+
16695
+ const invoke = (args, now = Date.now()) => {
16696
+ timestamp = now;
16697
+ lastArgs = null;
16698
+ if (timer) {
16699
+ clearTimeout(timer);
16700
+ timer = null;
16701
+ }
16702
+ fn.apply(null, args);
16703
+ };
16704
+
16705
+ const throttled = (...args) => {
16706
+ const now = Date.now();
16707
+ const passed = now - timestamp;
16708
+ if ( passed >= threshold) {
16709
+ invoke(args, now);
16710
+ } else {
16711
+ lastArgs = args;
16712
+ if (!timer) {
16713
+ timer = setTimeout(() => {
16714
+ timer = null;
16715
+ invoke(lastArgs);
16716
+ }, threshold - passed);
16717
+ }
16718
+ }
16719
+ };
16720
+
16721
+ const flush = () => lastArgs && invoke(lastArgs);
16722
+
16723
+ return [throttled, flush];
16724
+ }
16725
+
16726
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
16727
+ let bytesNotified = 0;
16728
+ const _speedometer = speedometer(50, 250);
16729
+
16730
+ return throttle(e => {
16731
+ const loaded = e.loaded;
16732
+ const total = e.lengthComputable ? e.total : undefined;
16733
+ const progressBytes = loaded - bytesNotified;
16734
+ const rate = _speedometer(progressBytes);
16735
+ const inRange = loaded <= total;
16736
+
16737
+ bytesNotified = loaded;
16738
+
16739
+ const data = {
16740
+ loaded,
16741
+ total,
16742
+ progress: total ? (loaded / total) : undefined,
16743
+ bytes: progressBytes,
16744
+ rate: rate ? rate : undefined,
16745
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
16746
+ event: e,
16747
+ lengthComputable: total != null,
16748
+ [isDownloadStream ? 'download' : 'upload']: true
16749
+ };
16750
+
16751
+ listener(data);
16752
+ }, freq);
16753
+ };
16754
+
16755
+ const progressEventDecorator = (total, throttled) => {
16756
+ const lengthComputable = total != null;
16757
+
16758
+ return [(loaded) => throttled[0]({
16759
+ lengthComputable,
16760
+ total,
16761
+ loaded
16762
+ }), throttled[1]];
16763
+ };
16764
+
16765
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
16766
+
16711
16767
  const zlibOptions = {
16712
16768
  flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
16713
16769
  finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
@@ -16728,6 +16784,14 @@ const supportedProtocols = platform.protocols.map(protocol => {
16728
16784
  return protocol + ':';
16729
16785
  });
16730
16786
 
16787
+ const flushOnFinish = (stream, [throttled, flush]) => {
16788
+ stream
16789
+ .on('end', flush)
16790
+ .on('error', flush);
16791
+
16792
+ return throttled;
16793
+ };
16794
+
16731
16795
  /**
16732
16796
  * If the proxy or config beforeRedirects functions are defined, call them with the options
16733
16797
  * object.
@@ -16866,7 +16930,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
16866
16930
  }
16867
16931
 
16868
16932
  // temporary internal emitter until the AxiosRequest class will be implemented
16869
- const emitter = new EventEmitter__default["default"]();
16933
+ const emitter = new events$1.EventEmitter();
16870
16934
 
16871
16935
  const onFinished = () => {
16872
16936
  if (config.cancelToken) {
@@ -16903,7 +16967,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
16903
16967
 
16904
16968
  // Parse url
16905
16969
  const fullPath = buildFullPath(config.baseURL, config.url);
16906
- const parsed = new URL(fullPath, 'http://localhost');
16970
+ const parsed = new URL(fullPath, utils$1.hasBrowserEnv ? platform.origin : undefined);
16907
16971
  const protocol = parsed.protocol || supportedProtocols[0];
16908
16972
 
16909
16973
  if (protocol === 'data:') {
@@ -16961,8 +17025,7 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
16961
17025
  // Only set header if it hasn't been set in config
16962
17026
  headers.set('User-Agent', 'axios/' + VERSION, false);
16963
17027
 
16964
- const onDownloadProgress = config.onDownloadProgress;
16965
- const onUploadProgress = config.onUploadProgress;
17028
+ const {onUploadProgress, onDownloadProgress} = config;
16966
17029
  const maxRate = config.maxRate;
16967
17030
  let maxUploadRate = undefined;
16968
17031
  let maxDownloadRate = undefined;
@@ -17033,15 +17096,16 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17033
17096
  }
17034
17097
 
17035
17098
  data = stream__default["default"].pipeline([data, new AxiosTransformStream({
17036
- length: contentLength,
17037
17099
  maxRate: utils$1.toFiniteNumber(maxUploadRate)
17038
17100
  })], utils$1.noop);
17039
17101
 
17040
- onUploadProgress && data.on('progress', progress => {
17041
- onUploadProgress(Object.assign(progress, {
17042
- upload: true
17043
- }));
17044
- });
17102
+ onUploadProgress && data.on('progress', flushOnFinish(
17103
+ data,
17104
+ progressEventDecorator(
17105
+ contentLength,
17106
+ progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
17107
+ )
17108
+ ));
17045
17109
  }
17046
17110
 
17047
17111
  // HTTP basic authentication
@@ -17140,17 +17204,18 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17140
17204
 
17141
17205
  const responseLength = +res.headers['content-length'];
17142
17206
 
17143
- if (onDownloadProgress) {
17207
+ if (onDownloadProgress || maxDownloadRate) {
17144
17208
  const transformStream = new AxiosTransformStream({
17145
- length: utils$1.toFiniteNumber(responseLength),
17146
17209
  maxRate: utils$1.toFiniteNumber(maxDownloadRate)
17147
17210
  });
17148
17211
 
17149
- onDownloadProgress && transformStream.on('progress', progress => {
17150
- onDownloadProgress(Object.assign(progress, {
17151
- download: true
17152
- }));
17153
- });
17212
+ onDownloadProgress && transformStream.on('progress', flushOnFinish(
17213
+ transformStream,
17214
+ progressEventDecorator(
17215
+ responseLength,
17216
+ progressEventReducer(asyncDecorator(onDownloadProgress), true, 3)
17217
+ )
17218
+ ));
17154
17219
 
17155
17220
  streams.push(transformStream);
17156
17221
  }
@@ -17363,45 +17428,6 @@ var httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
17363
17428
  });
17364
17429
  };
17365
17430
 
17366
- var cookies = platform.hasStandardBrowserEnv ?
17367
-
17368
- // Standard browser envs support document.cookie
17369
- {
17370
- write(name, value, expires, path, domain, secure) {
17371
- const cookie = [name + '=' + encodeURIComponent(value)];
17372
-
17373
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
17374
-
17375
- utils$1.isString(path) && cookie.push('path=' + path);
17376
-
17377
- utils$1.isString(domain) && cookie.push('domain=' + domain);
17378
-
17379
- secure === true && cookie.push('secure');
17380
-
17381
- document.cookie = cookie.join('; ');
17382
- },
17383
-
17384
- read(name) {
17385
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
17386
- return (match ? decodeURIComponent(match[3]) : null);
17387
- },
17388
-
17389
- remove(name) {
17390
- this.write(name, '', Date.now() - 86400000);
17391
- }
17392
- }
17393
-
17394
- :
17395
-
17396
- // Non-standard browser env (web workers, react-native) lack needed support.
17397
- {
17398
- write() {},
17399
- read() {
17400
- return null;
17401
- },
17402
- remove() {}
17403
- };
17404
-
17405
17431
  var isURLSameOrigin = platform.hasStandardBrowserEnv ?
17406
17432
 
17407
17433
  // Standard browser envs have full support of the APIs needed to test
@@ -17465,80 +17491,222 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
17465
17491
  };
17466
17492
  })();
17467
17493
 
17468
- function progressEventReducer(listener, isDownloadStream) {
17469
- let bytesNotified = 0;
17470
- const _speedometer = speedometer(50, 250);
17494
+ var cookies = platform.hasStandardBrowserEnv ?
17471
17495
 
17472
- return e => {
17473
- const loaded = e.loaded;
17474
- const total = e.lengthComputable ? e.total : undefined;
17475
- const progressBytes = loaded - bytesNotified;
17476
- const rate = _speedometer(progressBytes);
17477
- const inRange = loaded <= total;
17496
+ // Standard browser envs support document.cookie
17497
+ {
17498
+ write(name, value, expires, path, domain, secure) {
17499
+ const cookie = [name + '=' + encodeURIComponent(value)];
17478
17500
 
17479
- bytesNotified = loaded;
17501
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
17480
17502
 
17481
- const data = {
17482
- loaded,
17483
- total,
17484
- progress: total ? (loaded / total) : undefined,
17485
- bytes: progressBytes,
17486
- rate: rate ? rate : undefined,
17487
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
17488
- event: e
17489
- };
17503
+ utils$1.isString(path) && cookie.push('path=' + path);
17490
17504
 
17491
- data[isDownloadStream ? 'download' : 'upload'] = true;
17505
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
17492
17506
 
17493
- listener(data);
17507
+ secure === true && cookie.push('secure');
17508
+
17509
+ document.cookie = cookie.join('; ');
17510
+ },
17511
+
17512
+ read(name) {
17513
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
17514
+ return (match ? decodeURIComponent(match[3]) : null);
17515
+ },
17516
+
17517
+ remove(name) {
17518
+ this.write(name, '', Date.now() - 86400000);
17519
+ }
17520
+ }
17521
+
17522
+ :
17523
+
17524
+ // Non-standard browser env (web workers, react-native) lack needed support.
17525
+ {
17526
+ write() {},
17527
+ read() {
17528
+ return null;
17529
+ },
17530
+ remove() {}
17531
+ };
17532
+
17533
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
17534
+
17535
+ /**
17536
+ * Config-specific merge-function which creates a new config-object
17537
+ * by merging two configuration objects together.
17538
+ *
17539
+ * @param {Object} config1
17540
+ * @param {Object} config2
17541
+ *
17542
+ * @returns {Object} New object resulting from merging config2 to config1
17543
+ */
17544
+ function mergeConfig(config1, config2) {
17545
+ // eslint-disable-next-line no-param-reassign
17546
+ config2 = config2 || {};
17547
+ const config = {};
17548
+
17549
+ function getMergedValue(target, source, caseless) {
17550
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
17551
+ return utils$1.merge.call({caseless}, target, source);
17552
+ } else if (utils$1.isPlainObject(source)) {
17553
+ return utils$1.merge({}, source);
17554
+ } else if (utils$1.isArray(source)) {
17555
+ return source.slice();
17556
+ }
17557
+ return source;
17558
+ }
17559
+
17560
+ // eslint-disable-next-line consistent-return
17561
+ function mergeDeepProperties(a, b, caseless) {
17562
+ if (!utils$1.isUndefined(b)) {
17563
+ return getMergedValue(a, b, caseless);
17564
+ } else if (!utils$1.isUndefined(a)) {
17565
+ return getMergedValue(undefined, a, caseless);
17566
+ }
17567
+ }
17568
+
17569
+ // eslint-disable-next-line consistent-return
17570
+ function valueFromConfig2(a, b) {
17571
+ if (!utils$1.isUndefined(b)) {
17572
+ return getMergedValue(undefined, b);
17573
+ }
17574
+ }
17575
+
17576
+ // eslint-disable-next-line consistent-return
17577
+ function defaultToConfig2(a, b) {
17578
+ if (!utils$1.isUndefined(b)) {
17579
+ return getMergedValue(undefined, b);
17580
+ } else if (!utils$1.isUndefined(a)) {
17581
+ return getMergedValue(undefined, a);
17582
+ }
17583
+ }
17584
+
17585
+ // eslint-disable-next-line consistent-return
17586
+ function mergeDirectKeys(a, b, prop) {
17587
+ if (prop in config2) {
17588
+ return getMergedValue(a, b);
17589
+ } else if (prop in config1) {
17590
+ return getMergedValue(undefined, a);
17591
+ }
17592
+ }
17593
+
17594
+ const mergeMap = {
17595
+ url: valueFromConfig2,
17596
+ method: valueFromConfig2,
17597
+ data: valueFromConfig2,
17598
+ baseURL: defaultToConfig2,
17599
+ transformRequest: defaultToConfig2,
17600
+ transformResponse: defaultToConfig2,
17601
+ paramsSerializer: defaultToConfig2,
17602
+ timeout: defaultToConfig2,
17603
+ timeoutMessage: defaultToConfig2,
17604
+ withCredentials: defaultToConfig2,
17605
+ withXSRFToken: defaultToConfig2,
17606
+ adapter: defaultToConfig2,
17607
+ responseType: defaultToConfig2,
17608
+ xsrfCookieName: defaultToConfig2,
17609
+ xsrfHeaderName: defaultToConfig2,
17610
+ onUploadProgress: defaultToConfig2,
17611
+ onDownloadProgress: defaultToConfig2,
17612
+ decompress: defaultToConfig2,
17613
+ maxContentLength: defaultToConfig2,
17614
+ maxBodyLength: defaultToConfig2,
17615
+ beforeRedirect: defaultToConfig2,
17616
+ transport: defaultToConfig2,
17617
+ httpAgent: defaultToConfig2,
17618
+ httpsAgent: defaultToConfig2,
17619
+ cancelToken: defaultToConfig2,
17620
+ socketPath: defaultToConfig2,
17621
+ responseEncoding: defaultToConfig2,
17622
+ validateStatus: mergeDirectKeys,
17623
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
17494
17624
  };
17625
+
17626
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
17627
+ const merge = mergeMap[prop] || mergeDeepProperties;
17628
+ const configValue = merge(config1[prop], config2[prop], prop);
17629
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
17630
+ });
17631
+
17632
+ return config;
17495
17633
  }
17496
17634
 
17497
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
17635
+ var resolveConfig = (config) => {
17636
+ const newConfig = mergeConfig({}, config);
17498
17637
 
17499
- var xhrAdapter = isXHRAdapterSupported && function (config) {
17500
- return new Promise(function dispatchXhrRequest(resolve, reject) {
17501
- let requestData = config.data;
17502
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
17503
- let {responseType, withXSRFToken} = config;
17504
- let onCanceled;
17505
- function done() {
17506
- if (config.cancelToken) {
17507
- config.cancelToken.unsubscribe(onCanceled);
17508
- }
17638
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
17509
17639
 
17510
- if (config.signal) {
17511
- config.signal.removeEventListener('abort', onCanceled);
17512
- }
17640
+ newConfig.headers = headers = AxiosHeaders.from(headers);
17641
+
17642
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
17643
+
17644
+ // HTTP basic authentication
17645
+ if (auth) {
17646
+ headers.set('Authorization', 'Basic ' +
17647
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
17648
+ );
17649
+ }
17650
+
17651
+ let contentType;
17652
+
17653
+ if (utils$1.isFormData(data)) {
17654
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
17655
+ headers.setContentType(undefined); // Let the browser set it
17656
+ } else if ((contentType = headers.getContentType()) !== false) {
17657
+ // fix semicolon duplication issue for ReactNative FormData implementation
17658
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
17659
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
17513
17660
  }
17661
+ }
17662
+
17663
+ // Add xsrf header
17664
+ // This is only done if running in a standard browser environment.
17665
+ // Specifically not if we're in a web worker, or react-native.
17514
17666
 
17515
- let contentType;
17667
+ if (platform.hasStandardBrowserEnv) {
17668
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
17516
17669
 
17517
- if (utils$1.isFormData(requestData)) {
17518
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
17519
- requestHeaders.setContentType(false); // Let the browser set it
17520
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
17521
- // fix semicolon duplication issue for ReactNative FormData implementation
17522
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
17523
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
17670
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
17671
+ // Add xsrf header
17672
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
17673
+
17674
+ if (xsrfValue) {
17675
+ headers.set(xsrfHeaderName, xsrfValue);
17524
17676
  }
17525
17677
  }
17678
+ }
17526
17679
 
17527
- let request = new XMLHttpRequest();
17680
+ return newConfig;
17681
+ };
17528
17682
 
17529
- // HTTP basic authentication
17530
- if (config.auth) {
17531
- const username = config.auth.username || '';
17532
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
17533
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
17683
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
17684
+
17685
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
17686
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
17687
+ const _config = resolveConfig(config);
17688
+ let requestData = _config.data;
17689
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
17690
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
17691
+ let onCanceled;
17692
+ let uploadThrottled, downloadThrottled;
17693
+ let flushUpload, flushDownload;
17694
+
17695
+ function done() {
17696
+ flushUpload && flushUpload(); // flush events
17697
+ flushDownload && flushDownload(); // flush events
17698
+
17699
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
17700
+
17701
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
17534
17702
  }
17535
17703
 
17536
- const fullPath = buildFullPath(config.baseURL, config.url);
17704
+ let request = new XMLHttpRequest();
17537
17705
 
17538
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
17706
+ request.open(_config.method.toUpperCase(), _config.url, true);
17539
17707
 
17540
17708
  // Set the request timeout in MS
17541
- request.timeout = config.timeout;
17709
+ request.timeout = _config.timeout;
17542
17710
 
17543
17711
  function onloadend() {
17544
17712
  if (!request) {
@@ -17618,10 +17786,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
17618
17786
 
17619
17787
  // Handle timeout
17620
17788
  request.ontimeout = function handleTimeout() {
17621
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
17622
- const transitional = config.transitional || transitionalDefaults;
17623
- if (config.timeoutErrorMessage) {
17624
- timeoutErrorMessage = config.timeoutErrorMessage;
17789
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
17790
+ const transitional = _config.transitional || transitionalDefaults;
17791
+ if (_config.timeoutErrorMessage) {
17792
+ timeoutErrorMessage = _config.timeoutErrorMessage;
17625
17793
  }
17626
17794
  reject(new AxiosError(
17627
17795
  timeoutErrorMessage,
@@ -17633,22 +17801,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
17633
17801
  request = null;
17634
17802
  };
17635
17803
 
17636
- // Add xsrf header
17637
- // This is only done if running in a standard browser environment.
17638
- // Specifically not if we're in a web worker, or react-native.
17639
- if(platform.hasStandardBrowserEnv) {
17640
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
17641
-
17642
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
17643
- // Add xsrf header
17644
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
17645
-
17646
- if (xsrfValue) {
17647
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
17648
- }
17649
- }
17650
- }
17651
-
17652
17804
  // Remove Content-Type if data is undefined
17653
17805
  requestData === undefined && requestHeaders.setContentType(null);
17654
17806
 
@@ -17660,26 +17812,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
17660
17812
  }
17661
17813
 
17662
17814
  // Add withCredentials to request if needed
17663
- if (!utils$1.isUndefined(config.withCredentials)) {
17664
- request.withCredentials = !!config.withCredentials;
17815
+ if (!utils$1.isUndefined(_config.withCredentials)) {
17816
+ request.withCredentials = !!_config.withCredentials;
17665
17817
  }
17666
17818
 
17667
17819
  // Add responseType to request if needed
17668
17820
  if (responseType && responseType !== 'json') {
17669
- request.responseType = config.responseType;
17821
+ request.responseType = _config.responseType;
17670
17822
  }
17671
17823
 
17672
17824
  // Handle progress if needed
17673
- if (typeof config.onDownloadProgress === 'function') {
17674
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
17825
+ if (onDownloadProgress) {
17826
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
17827
+ request.addEventListener('progress', downloadThrottled);
17675
17828
  }
17676
17829
 
17677
17830
  // Not all browsers support upload events
17678
- if (typeof config.onUploadProgress === 'function' && request.upload) {
17679
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
17831
+ if (onUploadProgress && request.upload) {
17832
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
17833
+
17834
+ request.upload.addEventListener('progress', uploadThrottled);
17835
+
17836
+ request.upload.addEventListener('loadend', flushUpload);
17680
17837
  }
17681
17838
 
17682
- if (config.cancelToken || config.signal) {
17839
+ if (_config.cancelToken || _config.signal) {
17683
17840
  // Handle cancellation
17684
17841
  // eslint-disable-next-line func-names
17685
17842
  onCanceled = cancel => {
@@ -17691,13 +17848,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
17691
17848
  request = null;
17692
17849
  };
17693
17850
 
17694
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
17695
- if (config.signal) {
17696
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
17851
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
17852
+ if (_config.signal) {
17853
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
17697
17854
  }
17698
17855
  }
17699
17856
 
17700
- const protocol = parseProtocol(fullPath);
17857
+ const protocol = parseProtocol(_config.url);
17701
17858
 
17702
17859
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
17703
17860
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
@@ -17710,9 +17867,337 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
17710
17867
  });
17711
17868
  };
17712
17869
 
17870
+ const composeSignals = (signals, timeout) => {
17871
+ let controller = new AbortController();
17872
+
17873
+ let aborted;
17874
+
17875
+ const onabort = function (cancel) {
17876
+ if (!aborted) {
17877
+ aborted = true;
17878
+ unsubscribe();
17879
+ const err = cancel instanceof Error ? cancel : this.reason;
17880
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
17881
+ }
17882
+ };
17883
+
17884
+ let timer = timeout && setTimeout(() => {
17885
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
17886
+ }, timeout);
17887
+
17888
+ const unsubscribe = () => {
17889
+ if (signals) {
17890
+ timer && clearTimeout(timer);
17891
+ timer = null;
17892
+ signals.forEach(signal => {
17893
+ signal &&
17894
+ (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
17895
+ });
17896
+ signals = null;
17897
+ }
17898
+ };
17899
+
17900
+ signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
17901
+
17902
+ const {signal} = controller;
17903
+
17904
+ signal.unsubscribe = unsubscribe;
17905
+
17906
+ return [signal, () => {
17907
+ timer && clearTimeout(timer);
17908
+ timer = null;
17909
+ }];
17910
+ };
17911
+
17912
+ const streamChunk = function* (chunk, chunkSize) {
17913
+ let len = chunk.byteLength;
17914
+
17915
+ if (!chunkSize || len < chunkSize) {
17916
+ yield chunk;
17917
+ return;
17918
+ }
17919
+
17920
+ let pos = 0;
17921
+ let end;
17922
+
17923
+ while (pos < len) {
17924
+ end = pos + chunkSize;
17925
+ yield chunk.slice(pos, end);
17926
+ pos = end;
17927
+ }
17928
+ };
17929
+
17930
+ const readBytes = async function* (iterable, chunkSize, encode) {
17931
+ for await (const chunk of iterable) {
17932
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
17933
+ }
17934
+ };
17935
+
17936
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
17937
+ const iterator = readBytes(stream, chunkSize, encode);
17938
+
17939
+ let bytes = 0;
17940
+ let done;
17941
+ let _onFinish = (e) => {
17942
+ if (!done) {
17943
+ done = true;
17944
+ onFinish && onFinish(e);
17945
+ }
17946
+ };
17947
+
17948
+ return new ReadableStream({
17949
+ async pull(controller) {
17950
+ try {
17951
+ const {done, value} = await iterator.next();
17952
+
17953
+ if (done) {
17954
+ _onFinish();
17955
+ controller.close();
17956
+ return;
17957
+ }
17958
+
17959
+ let len = value.byteLength;
17960
+ if (onProgress) {
17961
+ let loadedBytes = bytes += len;
17962
+ onProgress(loadedBytes);
17963
+ }
17964
+ controller.enqueue(new Uint8Array(value));
17965
+ } catch (err) {
17966
+ _onFinish(err);
17967
+ throw err;
17968
+ }
17969
+ },
17970
+ cancel(reason) {
17971
+ _onFinish(reason);
17972
+ return iterator.return();
17973
+ }
17974
+ }, {
17975
+ highWaterMark: 2
17976
+ })
17977
+ };
17978
+
17979
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
17980
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
17981
+
17982
+ // used only inside the fetch adapter
17983
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
17984
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
17985
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
17986
+ );
17987
+
17988
+ const test = (fn, ...args) => {
17989
+ try {
17990
+ return !!fn(...args);
17991
+ } catch (e) {
17992
+ return false
17993
+ }
17994
+ };
17995
+
17996
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
17997
+ let duplexAccessed = false;
17998
+
17999
+ const hasContentType = new Request(platform.origin, {
18000
+ body: new ReadableStream(),
18001
+ method: 'POST',
18002
+ get duplex() {
18003
+ duplexAccessed = true;
18004
+ return 'half';
18005
+ },
18006
+ }).headers.has('Content-Type');
18007
+
18008
+ return duplexAccessed && !hasContentType;
18009
+ });
18010
+
18011
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
18012
+
18013
+ const supportsResponseStream = isReadableStreamSupported &&
18014
+ test(() => utils$1.isReadableStream(new Response('').body));
18015
+
18016
+
18017
+ const resolvers = {
18018
+ stream: supportsResponseStream && ((res) => res.body)
18019
+ };
18020
+
18021
+ isFetchSupported && (((res) => {
18022
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
18023
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
18024
+ (_, config) => {
18025
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
18026
+ });
18027
+ });
18028
+ })(new Response));
18029
+
18030
+ const getBodyLength = async (body) => {
18031
+ if (body == null) {
18032
+ return 0;
18033
+ }
18034
+
18035
+ if(utils$1.isBlob(body)) {
18036
+ return body.size;
18037
+ }
18038
+
18039
+ if(utils$1.isSpecCompliantForm(body)) {
18040
+ return (await new Request(body).arrayBuffer()).byteLength;
18041
+ }
18042
+
18043
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
18044
+ return body.byteLength;
18045
+ }
18046
+
18047
+ if(utils$1.isURLSearchParams(body)) {
18048
+ body = body + '';
18049
+ }
18050
+
18051
+ if(utils$1.isString(body)) {
18052
+ return (await encodeText(body)).byteLength;
18053
+ }
18054
+ };
18055
+
18056
+ const resolveBodyLength = async (headers, body) => {
18057
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
18058
+
18059
+ return length == null ? getBodyLength(body) : length;
18060
+ };
18061
+
18062
+ var fetchAdapter = isFetchSupported && (async (config) => {
18063
+ let {
18064
+ url,
18065
+ method,
18066
+ data,
18067
+ signal,
18068
+ cancelToken,
18069
+ timeout,
18070
+ onDownloadProgress,
18071
+ onUploadProgress,
18072
+ responseType,
18073
+ headers,
18074
+ withCredentials = 'same-origin',
18075
+ fetchOptions
18076
+ } = resolveConfig(config);
18077
+
18078
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
18079
+
18080
+ let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
18081
+ composeSignals([signal, cancelToken], timeout) : [];
18082
+
18083
+ let finished, request;
18084
+
18085
+ const onFinish = () => {
18086
+ !finished && setTimeout(() => {
18087
+ composedSignal && composedSignal.unsubscribe();
18088
+ });
18089
+
18090
+ finished = true;
18091
+ };
18092
+
18093
+ let requestContentLength;
18094
+
18095
+ try {
18096
+ if (
18097
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
18098
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
18099
+ ) {
18100
+ let _request = new Request(url, {
18101
+ method: 'POST',
18102
+ body: data,
18103
+ duplex: "half"
18104
+ });
18105
+
18106
+ let contentTypeHeader;
18107
+
18108
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
18109
+ headers.setContentType(contentTypeHeader);
18110
+ }
18111
+
18112
+ if (_request.body) {
18113
+ const [onProgress, flush] = progressEventDecorator(
18114
+ requestContentLength,
18115
+ progressEventReducer(asyncDecorator(onUploadProgress))
18116
+ );
18117
+
18118
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
18119
+ }
18120
+ }
18121
+
18122
+ if (!utils$1.isString(withCredentials)) {
18123
+ withCredentials = withCredentials ? 'include' : 'omit';
18124
+ }
18125
+
18126
+ request = new Request(url, {
18127
+ ...fetchOptions,
18128
+ signal: composedSignal,
18129
+ method: method.toUpperCase(),
18130
+ headers: headers.normalize().toJSON(),
18131
+ body: data,
18132
+ duplex: "half",
18133
+ credentials: withCredentials
18134
+ });
18135
+
18136
+ let response = await fetch(request);
18137
+
18138
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
18139
+
18140
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
18141
+ const options = {};
18142
+
18143
+ ['status', 'statusText', 'headers'].forEach(prop => {
18144
+ options[prop] = response[prop];
18145
+ });
18146
+
18147
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
18148
+
18149
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
18150
+ responseContentLength,
18151
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
18152
+ ) || [];
18153
+
18154
+ response = new Response(
18155
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
18156
+ flush && flush();
18157
+ isStreamResponse && onFinish();
18158
+ }, encodeText),
18159
+ options
18160
+ );
18161
+ }
18162
+
18163
+ responseType = responseType || 'text';
18164
+
18165
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
18166
+
18167
+ !isStreamResponse && onFinish();
18168
+
18169
+ stopTimeout && stopTimeout();
18170
+
18171
+ return await new Promise((resolve, reject) => {
18172
+ settle(resolve, reject, {
18173
+ data: responseData,
18174
+ headers: AxiosHeaders.from(response.headers),
18175
+ status: response.status,
18176
+ statusText: response.statusText,
18177
+ config,
18178
+ request
18179
+ });
18180
+ })
18181
+ } catch (err) {
18182
+ onFinish();
18183
+
18184
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
18185
+ throw Object.assign(
18186
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
18187
+ {
18188
+ cause: err.cause || err
18189
+ }
18190
+ )
18191
+ }
18192
+
18193
+ throw AxiosError.from(err, err && err.code, config, request);
18194
+ }
18195
+ });
18196
+
17713
18197
  const knownAdapters = {
17714
18198
  http: httpAdapter,
17715
- xhr: xhrAdapter
18199
+ xhr: xhrAdapter,
18200
+ fetch: fetchAdapter
17716
18201
  };
17717
18202
 
17718
18203
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -17856,108 +18341,6 @@ function dispatchRequest(config) {
17856
18341
  });
17857
18342
  }
17858
18343
 
17859
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing;
17860
-
17861
- /**
17862
- * Config-specific merge-function which creates a new config-object
17863
- * by merging two configuration objects together.
17864
- *
17865
- * @param {Object} config1
17866
- * @param {Object} config2
17867
- *
17868
- * @returns {Object} New object resulting from merging config2 to config1
17869
- */
17870
- function mergeConfig(config1, config2) {
17871
- // eslint-disable-next-line no-param-reassign
17872
- config2 = config2 || {};
17873
- const config = {};
17874
-
17875
- function getMergedValue(target, source, caseless) {
17876
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
17877
- return utils$1.merge.call({caseless}, target, source);
17878
- } else if (utils$1.isPlainObject(source)) {
17879
- return utils$1.merge({}, source);
17880
- } else if (utils$1.isArray(source)) {
17881
- return source.slice();
17882
- }
17883
- return source;
17884
- }
17885
-
17886
- // eslint-disable-next-line consistent-return
17887
- function mergeDeepProperties(a, b, caseless) {
17888
- if (!utils$1.isUndefined(b)) {
17889
- return getMergedValue(a, b, caseless);
17890
- } else if (!utils$1.isUndefined(a)) {
17891
- return getMergedValue(undefined, a, caseless);
17892
- }
17893
- }
17894
-
17895
- // eslint-disable-next-line consistent-return
17896
- function valueFromConfig2(a, b) {
17897
- if (!utils$1.isUndefined(b)) {
17898
- return getMergedValue(undefined, b);
17899
- }
17900
- }
17901
-
17902
- // eslint-disable-next-line consistent-return
17903
- function defaultToConfig2(a, b) {
17904
- if (!utils$1.isUndefined(b)) {
17905
- return getMergedValue(undefined, b);
17906
- } else if (!utils$1.isUndefined(a)) {
17907
- return getMergedValue(undefined, a);
17908
- }
17909
- }
17910
-
17911
- // eslint-disable-next-line consistent-return
17912
- function mergeDirectKeys(a, b, prop) {
17913
- if (prop in config2) {
17914
- return getMergedValue(a, b);
17915
- } else if (prop in config1) {
17916
- return getMergedValue(undefined, a);
17917
- }
17918
- }
17919
-
17920
- const mergeMap = {
17921
- url: valueFromConfig2,
17922
- method: valueFromConfig2,
17923
- data: valueFromConfig2,
17924
- baseURL: defaultToConfig2,
17925
- transformRequest: defaultToConfig2,
17926
- transformResponse: defaultToConfig2,
17927
- paramsSerializer: defaultToConfig2,
17928
- timeout: defaultToConfig2,
17929
- timeoutMessage: defaultToConfig2,
17930
- withCredentials: defaultToConfig2,
17931
- withXSRFToken: defaultToConfig2,
17932
- adapter: defaultToConfig2,
17933
- responseType: defaultToConfig2,
17934
- xsrfCookieName: defaultToConfig2,
17935
- xsrfHeaderName: defaultToConfig2,
17936
- onUploadProgress: defaultToConfig2,
17937
- onDownloadProgress: defaultToConfig2,
17938
- decompress: defaultToConfig2,
17939
- maxContentLength: defaultToConfig2,
17940
- maxBodyLength: defaultToConfig2,
17941
- beforeRedirect: defaultToConfig2,
17942
- transport: defaultToConfig2,
17943
- httpAgent: defaultToConfig2,
17944
- httpsAgent: defaultToConfig2,
17945
- cancelToken: defaultToConfig2,
17946
- socketPath: defaultToConfig2,
17947
- responseEncoding: defaultToConfig2,
17948
- validateStatus: mergeDirectKeys,
17949
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
17950
- };
17951
-
17952
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
17953
- const merge = mergeMap[prop] || mergeDeepProperties;
17954
- const configValue = merge(config1[prop], config2[prop], prop);
17955
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
17956
- });
17957
-
17958
- return config;
17959
- }
17960
-
17961
18344
  const validators$1 = {};
17962
18345
 
17963
18346
  // eslint-disable-next-line func-names
@@ -18082,12 +18465,15 @@ class Axios {
18082
18465
 
18083
18466
  // slice off the Error: ... line
18084
18467
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
18085
-
18086
- if (!err.stack) {
18087
- err.stack = stack;
18088
- // match without the 2 top stack lines
18089
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
18090
- err.stack += '\n' + stack;
18468
+ try {
18469
+ if (!err.stack) {
18470
+ err.stack = stack;
18471
+ // match without the 2 top stack lines
18472
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
18473
+ err.stack += '\n' + stack;
18474
+ }
18475
+ } catch (e) {
18476
+ // ignore the case where "stack" is an un-writable property
18091
18477
  }
18092
18478
  }
18093
18479
 
@@ -18603,7 +18989,10 @@ const executeCommandLine = ({ command, messageOnError, shouldThrowError = false,
18603
18989
  }
18604
18990
  };
18605
18991
 
18606
- const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
18992
+ const getDescribePath = ({ titlePath, title, project, rootDir, file, }) => titlePath.filter((item, index) => index !== 0 &&
18993
+ item !== title &&
18994
+ item !== project &&
18995
+ item !== path__default["default"].relative(rootDir, file));
18607
18996
  const getCurrentCommitSha = () => executeCommandLine({
18608
18997
  command: "git rev-parse HEAD",
18609
18998
  messageOnError: ERRORS.onBegin.failedToGetCommitSha,
@@ -18625,8 +19014,14 @@ const getTestData = (test, rootDir) => {
18625
19014
  const { title, parent, location: { file }, } = test;
18626
19015
  const titlePath = test.titlePath();
18627
19016
  const project = (_a = parent.project()) === null || _a === void 0 ? void 0 : _a.name;
18628
- const spec = file.replace(`${rootDir}/`, "");
18629
- const describe = getDescribePath({ titlePath, title, spec, project });
19017
+ const spec = path__default["default"].relative(rootDir, file);
19018
+ const describe = getDescribePath({
19019
+ titlePath,
19020
+ title,
19021
+ project,
19022
+ rootDir,
19023
+ file,
19024
+ });
18630
19025
  const historyId = generateHistoryId(project !== null && project !== void 0 ? project : "", spec, describe, title);
18631
19026
  return { title, describe, project, spec, historyId };
18632
19027
  };