/// import { EventEmitter } from "events"; type Status = "processing" | "waiting" | "success" | "error"; /** * Format of the progress * e.g. * - "number" (e.g. 3/10) * - "bytes" (e.g. 3.5MB/10MB) */ type FormatProgress = "number" | "bytes"; export interface ProgressTask { status: Status; title: string; subject?: string; progress?: { actual: number; total?: number; format: FormatProgress; }; error?: string; } /** Key-value pairs of stats */ export interface ProgressStats { [key: string]: number; } export declare interface Progress { on(event: "progress", listener: (tasks: ProgressTask[], stats: ProgressStats) => void): this; } /** * Tracks the progress of the generation. * * It stores two things: * - a stack of tasks and its status and progress * - key-value pairs of stats (e.g. files processed, messages processed, etc.) * * Every time progress is updated, it emits a "progress" event with the updated tasks and stats. * * The lifecycle of a task is: * - `new()` * - `progress()` (optional) * - ... * - `progress()` (optional) * - `success()` or `error()` * * Note: there is an undocumented and untested `waiting` state, which allows multiple `new` calls (unused) */ export declare class Progress extends EventEmitter { /** All the tasks */ private tasks; /** Currently active task. Next calls to `progress` will update this task. */ private active?; /** Stats (global) */ private keys; /** Whether a task errored */ private errored; /** Adds a new task */ new(title: string, subject?: string): void; /** Updates the progress of the current task */ progress(format: FormatProgress, actual: number, total?: number): void; /** Marks the last task as finished and removes it from the stack */ success(): void; /** Marks the last task as failed */ error(info: string): void; /** Set a stat value */ stat(key: string, value: number): void; private lastCount; private lastTs; /** * Emits a "progress" event if progress advanced at least 1% or 15ms has passed since the last update. * * @param force whether to force the update */ private update; } export {};