@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/index.cjs CHANGED
@@ -5367,6 +5367,8 @@ var Logger = class _Logger {
5367
5367
  options;
5368
5368
  transport;
5369
5369
  startTimes = {};
5370
+ /** Count at the first progress sample for each prefix (rate baseline). */
5371
+ startCounts = {};
5370
5372
  lastProgressTimes = {};
5371
5373
  constructor(context, options = {}) {
5372
5374
  this.context = context;
@@ -5502,15 +5504,17 @@ var Logger = class _Logger {
5502
5504
  total,
5503
5505
  prefix
5504
5506
  };
5505
- if (!this.startTimes[prefix ?? ""]) {
5506
- this.startTimes[prefix ?? ""] = Date.now();
5507
+ const key = prefix ?? "";
5508
+ if (this.startTimes[key] === void 0) {
5509
+ this.startTimes[key] = Date.now();
5510
+ this.startCounts[key] = count;
5507
5511
  }
5508
5512
  const wantTimes = this.options.progressTimes;
5509
5513
  const wantRate = this.options.progressRate;
5510
5514
  if (wantTimes || wantRate) {
5511
- const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
5512
- const intervals = count > 1 ? count - 1 : 0;
5513
- const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
5515
+ const elapsedSeconds = (Date.now() - this.startTimes[key]) / 1e3;
5516
+ const done = count - (this.startCounts[key] ?? count);
5517
+ const itemsPerSec = done > 0 && elapsedSeconds > 0 ? done / elapsedSeconds : -1;
5514
5518
  if (wantTimes) {
5515
5519
  let remaining = -1;
5516
5520
  if (itemsPerSec > 0) {
@@ -5524,8 +5528,9 @@ var Logger = class _Logger {
5524
5528
  }
5525
5529
  }
5526
5530
  if (count >= total) {
5527
- delete this.startTimes[prefix ?? ""];
5528
- delete this.lastProgressTimes[prefix ?? ""];
5531
+ delete this.startTimes[key];
5532
+ delete this.startCounts[key];
5533
+ delete this.lastProgressTimes[key];
5529
5534
  }
5530
5535
  if (this.shouldOutputProgress(prefix ?? "", count, total)) {
5531
5536
  this.out(payload);