@nmakarov/cli-toolkit 0.76.0 → 0.78.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.
@@ -2526,6 +2526,8 @@ var Logger = class _Logger {
2526
2526
  options;
2527
2527
  transport;
2528
2528
  startTimes = {};
2529
+ /** Count at the first progress sample for each prefix (rate baseline). */
2530
+ startCounts = {};
2529
2531
  lastProgressTimes = {};
2530
2532
  constructor(context, options = {}) {
2531
2533
  this.context = context;
@@ -2661,15 +2663,17 @@ var Logger = class _Logger {
2661
2663
  total,
2662
2664
  prefix
2663
2665
  };
2664
- if (!this.startTimes[prefix ?? ""]) {
2665
- this.startTimes[prefix ?? ""] = Date.now();
2666
+ const key = prefix ?? "";
2667
+ if (this.startTimes[key] === void 0) {
2668
+ this.startTimes[key] = Date.now();
2669
+ this.startCounts[key] = count;
2666
2670
  }
2667
2671
  const wantTimes = this.options.progressTimes;
2668
2672
  const wantRate = this.options.progressRate;
2669
2673
  if (wantTimes || wantRate) {
2670
- const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
2671
- const intervals = count > 1 ? count - 1 : 0;
2672
- const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
2674
+ const elapsedSeconds = (Date.now() - this.startTimes[key]) / 1e3;
2675
+ const done = count - (this.startCounts[key] ?? count);
2676
+ const itemsPerSec = done > 0 && elapsedSeconds > 0 ? done / elapsedSeconds : -1;
2673
2677
  if (wantTimes) {
2674
2678
  let remaining = -1;
2675
2679
  if (itemsPerSec > 0) {
@@ -2683,8 +2687,9 @@ var Logger = class _Logger {
2683
2687
  }
2684
2688
  }
2685
2689
  if (count >= total) {
2686
- delete this.startTimes[prefix ?? ""];
2687
- delete this.lastProgressTimes[prefix ?? ""];
2690
+ delete this.startTimes[key];
2691
+ delete this.startCounts[key];
2692
+ delete this.lastProgressTimes[key];
2688
2693
  }
2689
2694
  if (this.shouldOutputProgress(prefix ?? "", count, total)) {
2690
2695
  this.out(payload);