@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.js CHANGED
@@ -5181,6 +5181,8 @@ var Logger = class _Logger {
5181
5181
  options;
5182
5182
  transport;
5183
5183
  startTimes = {};
5184
+ /** Count at the first progress sample for each prefix (rate baseline). */
5185
+ startCounts = {};
5184
5186
  lastProgressTimes = {};
5185
5187
  constructor(context, options = {}) {
5186
5188
  this.context = context;
@@ -5316,15 +5318,17 @@ var Logger = class _Logger {
5316
5318
  total,
5317
5319
  prefix
5318
5320
  };
5319
- if (!this.startTimes[prefix ?? ""]) {
5320
- this.startTimes[prefix ?? ""] = Date.now();
5321
+ const key = prefix ?? "";
5322
+ if (this.startTimes[key] === void 0) {
5323
+ this.startTimes[key] = Date.now();
5324
+ this.startCounts[key] = count;
5321
5325
  }
5322
5326
  const wantTimes = this.options.progressTimes;
5323
5327
  const wantRate = this.options.progressRate;
5324
5328
  if (wantTimes || wantRate) {
5325
- const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
5326
- const intervals = count > 1 ? count - 1 : 0;
5327
- const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
5329
+ const elapsedSeconds = (Date.now() - this.startTimes[key]) / 1e3;
5330
+ const done = count - (this.startCounts[key] ?? count);
5331
+ const itemsPerSec = done > 0 && elapsedSeconds > 0 ? done / elapsedSeconds : -1;
5328
5332
  if (wantTimes) {
5329
5333
  let remaining = -1;
5330
5334
  if (itemsPerSec > 0) {
@@ -5338,8 +5342,9 @@ var Logger = class _Logger {
5338
5342
  }
5339
5343
  }
5340
5344
  if (count >= total) {
5341
- delete this.startTimes[prefix ?? ""];
5342
- delete this.lastProgressTimes[prefix ?? ""];
5345
+ delete this.startTimes[key];
5346
+ delete this.startCounts[key];
5347
+ delete this.lastProgressTimes[key];
5343
5348
  }
5344
5349
  if (this.shouldOutputProgress(prefix ?? "", count, total)) {
5345
5350
  this.out(payload);