Skip to content

@loontail/minecraft-kit / ProgressSnapshot

Type Alias: ProgressSnapshot

ts
type ProgressSnapshot = {
  bytesDownloaded: number;
  currentFile?: string;
  overallBytesDownloaded: number;
  overallPercent: number;
  overallTotalBytes: number;
  stage: ProgressStage;
  stagePercent: number;
  totalBytes: number;
};

Defined in: src/install/progress-tracker.ts:69

Snapshot pushed to InstallProgressTracker subscribers.

Two matched byte pairs, so a ratio is always self-consistent: bytesDownloaded / totalBytes describe the current stage, overallBytesDownloaded / overallTotalBytes the whole run. Never divide across the pairs.

Example

ts
import type { ProgressSnapshot } from "@loontail/minecraft-kit";

const render = (s: ProgressSnapshot) => {
  console.log(`${s.stage} ${s.bytesDownloaded}/${s.totalBytes} bytes (${s.stagePercent.toFixed(0)}%)`);
  console.log(`overall ${s.overallBytesDownloaded}/${s.overallTotalBytes} (${s.overallPercent.toFixed(0)}%)`);
  if (s.currentFile) console.log(`  ${s.currentFile}`);
};

Properties

PropertyModifierTypeDescriptionDefined in
bytesDownloadedreadonlynumberBytes downloaded so far in the current stage. Denominator is totalBytes.src/install/progress-tracker.ts:74
currentFile?readonlystring-src/install/progress-tracker.ts:81
overallBytesDownloadedreadonlynumberBytes downloaded so far across every stage. Denominator is overallTotalBytes.src/install/progress-tracker.ts:78
overallPercentreadonlynumber-src/install/progress-tracker.ts:72
overallTotalBytesreadonlynumberExpected bytes of the whole run.src/install/progress-tracker.ts:80
stagereadonlyProgressStage-src/install/progress-tracker.ts:70
stagePercentreadonlynumber-src/install/progress-tracker.ts:71
totalBytesreadonlynumberExpected bytes of the current stage.src/install/progress-tracker.ts:76

MIT License