@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.
@@ -2542,6 +2542,8 @@ var Logger = class _Logger {
2542
2542
  options;
2543
2543
  transport;
2544
2544
  startTimes = {};
2545
+ /** Count at the first progress sample for each prefix (rate baseline). */
2546
+ startCounts = {};
2545
2547
  lastProgressTimes = {};
2546
2548
  constructor(context, options = {}) {
2547
2549
  this.context = context;
@@ -2677,15 +2679,17 @@ var Logger = class _Logger {
2677
2679
  total,
2678
2680
  prefix
2679
2681
  };
2680
- if (!this.startTimes[prefix ?? ""]) {
2681
- this.startTimes[prefix ?? ""] = Date.now();
2682
+ const key = prefix ?? "";
2683
+ if (this.startTimes[key] === void 0) {
2684
+ this.startTimes[key] = Date.now();
2685
+ this.startCounts[key] = count;
2682
2686
  }
2683
2687
  const wantTimes = this.options.progressTimes;
2684
2688
  const wantRate = this.options.progressRate;
2685
2689
  if (wantTimes || wantRate) {
2686
- const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
2687
- const intervals = count > 1 ? count - 1 : 0;
2688
- const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
2690
+ const elapsedSeconds = (Date.now() - this.startTimes[key]) / 1e3;
2691
+ const done = count - (this.startCounts[key] ?? count);
2692
+ const itemsPerSec = done > 0 && elapsedSeconds > 0 ? done / elapsedSeconds : -1;
2689
2693
  if (wantTimes) {
2690
2694
  let remaining = -1;
2691
2695
  if (itemsPerSec > 0) {
@@ -2699,8 +2703,9 @@ var Logger = class _Logger {
2699
2703
  }
2700
2704
  }
2701
2705
  if (count >= total) {
2702
- delete this.startTimes[prefix ?? ""];
2703
- delete this.lastProgressTimes[prefix ?? ""];
2706
+ delete this.startTimes[key];
2707
+ delete this.startCounts[key];
2708
+ delete this.lastProgressTimes[key];
2704
2709
  }
2705
2710
  if (this.shouldOutputProgress(prefix ?? "", count, total)) {
2706
2711
  this.out(payload);