Files
hermankwan-ComfyUI-Batch-Im…/web/progress_engine.js
T
Herman Kwan 82336a25be feat(core): release v0.2.0 major architecture refactor and UI overhaul
- Migrate frontend to modular ES modules (timer, progress, renderer)
- Rewrite batch tracking logic to support Sequential Image Loaders and native batches
- Introduce robust queue-empty fallback debounce to prevent infinite timers
- Decouple timer interactions from progress counters for absolute independence
- Redesign UI layout, fix node resizing conflicts, and add dynamic status colors
- Update README with new usage instructions and v0.2.0 changelog
2026-10-22 23:47:42 -07:00

49 lines
1.2 KiB
JavaScript

export class ProgressEngine {
constructor() {
this.current = 0;
this.total = 0;
this.status = "READY"; // READY | RUNNING | INTERRUPT | ERROR
this.isCompleted = false;
}
start(total = 1) {
this.current = 1;
this.total = total > 0 ? total : 1;
this.status = "RUNNING";
this.isCompleted = false;
}
update(data) {
if (this.status !== "RUNNING") return;
if (data.current != null) this.current = data.current;
if (data.total != null) this.total = data.total;
if (this.current > this.total) {
this.current = this.total;
}
}
markCompleted() {
if (this.status === "RUNNING" && this.current >= this.total) {
this.isCompleted = true;
}
}
resetAll() {
this.current = 0;
this.total = 0;
this.status = "READY";
this.isCompleted = false;
}
getDisplayText() {
switch (this.status) {
case "READY": return "READY";
case "ERROR": return "ERROR";
case "INTERRUPT": return "INTERRUPT";
case "RUNNING": return `${this.current} / ${this.total}`;
default: return "READY";
}
}
}