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