File size: 661 Bytes
ef4c36f
 
 
 
 
 
e162630
 
 
 
 
ef4c36f
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import type { RenderProgress } from "@/types";

const progressMap = new Map<string, RenderProgress>();

export function setProgress(id: string, progress: RenderProgress) {
  progressMap.set(id, progress);
  // ponytail: every pipeline stage already routes through here, so one line here
  // logs the whole run instead of scattering console.log across the pipeline
  console.log(
    `[reel ${id.slice(0, 8)}] ${progress.percent}% ${progress.stage}${progress.message}`,
  );
}

export function getProgress(id: string): RenderProgress | null {
  return progressMap.get(id) ?? null;
}

export function clearProgress(id: string) {
  progressMap.delete(id);
}