/** * The sequential phases of a model load, matching the phase split already * measured by Statistics (parseTime / geometryTime) and the CI perf harness * (perf.csv) so a progress report, a CLI run and a CI perf row are directly * comparable. See conway issue #301. * * The heavy interiors of 'geometry' (per-face tessellation, CSG, weld) are * single opaque wasm calls with no interior progress — ticks happen at the * per-product TS loop, so a hang localizes to one product. */ export type ProgressPhase = 'headerParse' | 'dataParse' | 'geometry' | 'sceneBuild' | 'serialize'; export type ProgressUnit = 'bytes' | 'elements' | 'products' | 'meshes' | 'chunks'; /** * A single progress report during a model load. * * When total is present the phase is determinate and a real progress bar can * be rendered; when absent only activity (a heartbeat) is being reported. */ export interface ProgressEvent { readonly phase: ProgressPhase; /** Units completed so far in this phase (monotonic within the phase). */ readonly completed: number; /** Units total for this phase, when cheaply knowable up front. */ readonly total?: number; readonly unit: ProgressUnit; /** Milliseconds since the tracker (i.e. the load) started. */ readonly elapsedMs: number; /** Coarse used-JS-heap sample in MB, when the environment exposes one. */ readonly memoryMb?: number; } export type ProgressCallback = (event: ProgressEvent) => void; /** * Primitive (completed, total) progress callback used by extraction loops, * keeping them decoupled from the ProgressEvent contract — a ProgressTracker * maps these into events at the loader layer. */ export type CountProgressCallback = (completed: number, total: number) => void; /** Default minimum milliseconds between emitted progress events. */ export declare const DEFAULT_PROGRESS_INTERVAL_MS = 100; /** * Resolves in a macrotask, letting the event loop breathe so browsers can * repaint progress UI and timers (e.g. stall watchdogs) can fire. Used by the * *Async load variants between progress ticks. * * @return {Promise} A promise resolved on the next timer turn. */ export declare function yieldToEventLoop(): Promise; /** * Throttled fan-in point for progress ticks during a load. * * Hot loops call update() as often as they like (it is cheap); events are * only materialized and forwarded at most once per minIntervalMs, plus * unthrottled events at phase begin/end so consumers always see phase * boundaries. Memory is sampled only when an event is actually emitted. */ export declare class ProgressTracker { private readonly onProgress; private readonly minIntervalMs; private readonly startTime; private lastEmitTime; private phase_; private unit_; private total_; /** * Construct this with the callback progress events are forwarded to. * * @param onProgress The consumer callback. * @param minIntervalMs Minimum milliseconds between throttled events. */ constructor(onProgress: ProgressCallback, minIntervalMs?: number); /** * The currently reporting phase, if any. * * @return {ProgressPhase | undefined} The current phase. */ get phase(): ProgressPhase | undefined; /** * Begin a phase, emitting an unthrottled zero-progress event. * * @param phase The phase being entered. * @param unit The unit completed/total are measured in for this phase. * @param total The total units for this phase, when known up front. */ beginPhase(phase: ProgressPhase, unit: ProgressUnit, total?: number): void; /** * Set/replace the current phase's total once it becomes known * (e.g. product count discovered inside geometry extraction). * * @param total The total units for the current phase. */ setPhaseTotal(total: number): void; /** * Report progress within the current phase; throttled. * * @param completed Units completed so far. */ update(completed: number): void; /** * End the current phase, emitting an unthrottled final event with * completed === total when a total is known. * * @param completed Final completed units (defaults to the phase total). */ endPhase(completed?: number): void; /** * Materialize and forward an event now, bypassing the throttle. * * @param completed Units completed so far. * @param now Current time in ms (defaults to Date.now()). */ private emit; } //# sourceMappingURL=progress.d.ts.map