histoire
Version:
A fast story book powered by Vite
42 lines • 2.01 kB
TypeScript
import type { ProgressEvent, StartupPhaseId } from '@histoire/cli/protocol/progress';
/** Mutable detail a running phase can report. */
export interface ProgressPatch {
label?: string;
current?: number;
total?: number;
}
/**
* Producer of real startup work observations. Every method is inert once the
* generation is superseded, and absent observers cost nothing.
*/
export interface StartupProgress {
/**
* Starts a phase; restarting a running phase is ignored.
* @param phase Phase identifier.
* @param label Optional current detail.
* @param options.background Marks work that does not gate readiness.
*/
begin: (phase: StartupPhaseId, label?: string, options?: {
background?: boolean;
}) => void;
/** Reports a changed label or count of a running phase; ignored otherwise. */
update: (phase: StartupPhaseId, patch: ProgressPatch) => void;
/** Finishes a running phase successfully. */
complete: (phase: StartupPhaseId) => void;
/** Finishes a running phase with a failure. */
fail: (phase: StartupPhaseId, error: unknown) => void;
/** Records work that was deliberately not performed. */
skip: (phase: StartupPhaseId, label?: string) => void;
/** Runs `work` as one phase, completing or failing it with the outcome. */
track: <T>(phase: StartupPhaseId, work: () => T | Promise<T>, label?: string) => Promise<T>;
}
/** Observer that records nothing; used when no sink is supplied. */
export declare const inertProgress: StartupProgress;
/**
* Creates a progress producer.
* @param sink Receives each observation; faults are swallowed. Absent means inert.
* @param isActive Publication stops permanently the first time this returns false.
* @param now Monotonic clock in milliseconds; tests only.
*/
export declare function createStartupProgress(sink: ((event: ProgressEvent) => void) | undefined, isActive?: () => boolean, now?: () => number): StartupProgress;
//# sourceMappingURL=progress.d.ts.map