import { ActivityEvent, ProgressHandle, ProgressOptions, SpinnerHandle } from "../schema/activity.mjs"; import { WriteFn } from "./writer.mjs"; //#region src/core/output/activity.d.ts /** * Noop spinner handle singleton. * * All methods are no-ops. Used when spinners should produce no output * at all — `jsonMode`, or non-TTY with `fallback: 'silent'` (default). * * @internal */ declare const noopSpinnerHandle: SpinnerHandle; /** * Noop progress handle singleton. * * All methods are no-ops. Used when progress bars should produce no * output at all — `jsonMode`, or non-TTY with `fallback: 'silent'`. * * @internal */ declare const noopProgressHandle: ProgressHandle; /** * Static spinner handle — emits plain text at lifecycle boundaries. * * Used in non-TTY environments with `fallback: 'static'`. No animation, * no ANSI codes. Emits text on start and terminal events only. * * Terminal methods are idempotent — calling after stop is a no-op. * * @internal */ declare class StaticSpinnerHandle implements SpinnerHandle { private readonly write; /** Whether the handle has been stopped (terminal state reached). */ private stopped; constructor(text: string, write: WriteFn); update(_text: string): void; succeed(text?: string): void; fail(text?: string): void; stop(): void; wrap(promise: Promise, options?: { readonly succeed?: string; readonly fail?: string; }): Promise; } /** * Static progress handle — emits plain text at lifecycle boundaries. * * Used in non-TTY environments with `fallback: 'static'`. No animation, * no progress bar rendering. Emits label on start, text on done/fail. * * Terminal methods are idempotent — calling after stop is a no-op. * * @internal */ declare class StaticProgressHandle implements ProgressHandle { private readonly write; /** Whether the handle has been stopped (terminal state reached). */ private stopped; constructor(label: string | undefined, write: WriteFn); increment(_n?: number): void; update(_value: number): void; done(text?: string): void; fail(text?: string): void; } /** * TTY spinner handle — animated braille frames with ANSI line overwrite. * * Used in TTY environments (non-JSON mode). Renders a spinning indicator * with configurable text, using `\r` + erase-line to overwrite in place. * Hides the cursor during animation and restores it on any terminal method. * * Terminal methods (`succeed`, `fail`, `stop`) are idempotent — calling any * of them after the handle is already stopped is a no-op. * * **Note:** If the process exits abnormally (e.g. `SIGKILL`) while a spinner * is active, the cursor may remain hidden. Use {@link SpinnerHandle.wrap} to * ensure cleanup on both success and failure paths. * * @internal */ declare class TTYSpinnerHandle implements SpinnerHandle { private readonly write; /** Whether the handle has been stopped (terminal state reached). */ private stopped; /** Animation timer handle — cleared on any terminal method. */ private timer; /** Current position in the braille frame sequence. */ private frameIndex; /** Current spinner text (mutable via `update()`). */ private text; constructor(text: string, write: WriteFn); /** Render the current frame + text, overwriting the current line. */ private render; /** Clear the animation timer, erase the line, and restore the cursor. */ private cleanup; update(text: string): void; succeed(text?: string): void; fail(text?: string): void; stop(): void; wrap(promise: Promise, options?: { readonly succeed?: string; readonly fail?: string; }): Promise; } /** * TTY progress handle — bar rendering with ANSI line overwrite. * * Supports two modes: * - **Determinate** (`total` provided) — renders `[████░░░░░░] 40% label`, * re-rendered on each `increment()` / `update()` call. No timer. * - **Indeterminate** (`total` omitted) — renders a pulsing highlight that * bounces across the bar via `setInterval`. * * Terminal methods (`done`, `fail`) are idempotent — calling any of them * after the handle is already stopped is a no-op. * * @internal */ declare class TTYProgressHandle implements ProgressHandle { private readonly write; /** Whether the handle has been stopped (terminal state reached). */ private stopped; /** Animation timer for indeterminate mode — `undefined` in determinate mode. */ private timer; /** Current progress value (units completed). */ private current; /** Total units of work (`undefined` = indeterminate mode). */ private readonly total; /** Label displayed alongside the bar. */ private readonly label; /** Pulse position for indeterminate animation (bouncing highlight). */ private pulsePos; /** Pulse direction: 1 = forward, -1 = backward (for bounce). */ private pulseDir; constructor(opts: ProgressOptions, write: WriteFn); /** Advance the indeterminate pulse position with bounce logic. */ private advancePulse; /** Render the progress bar, overwriting the current line. */ private render; /** Render a determinate bar: `[████░░░░░░] 40%`. */ private renderDeterminate; /** Render an indeterminate bar: pulsing highlight bouncing across empty segments. */ private renderIndeterminate; /** Clear the animation timer, erase the line, and restore the cursor. */ private cleanup; increment(n?: number): void; update(value: number): void; done(text?: string): void; fail(text?: string): void; } /** * Spinner handle that records lifecycle events to a shared `ActivityEvent[]`. * * Used by `createCaptureOutput()` so testkit can assert on spinner behaviour * without polluting stdout/stderr arrays. Terminal methods are idempotent. * * @internal */ declare class CaptureSpinnerHandle implements SpinnerHandle { private readonly events; /** Whether the handle has been stopped (terminal state reached). */ private stopped; constructor(text: string, events: ActivityEvent[]); update(text: string): void; succeed(text?: string): void; fail(text?: string): void; stop(): void; wrap(promise: Promise, options?: { readonly succeed?: string; readonly fail?: string; }): Promise; } /** * Progress handle that records lifecycle events to a shared `ActivityEvent[]`. * * Used by `createCaptureOutput()` so testkit can assert on progress behaviour * without polluting stdout/stderr arrays. Terminal methods are idempotent. * * @internal */ declare class CaptureProgressHandle implements ProgressHandle { private readonly events; /** Whether the handle has been stopped (terminal state reached). */ private stopped; constructor(opts: ProgressOptions, events: ActivityEvent[]); increment(n?: number): void; update(value: number): void; done(text?: string): void; fail(text?: string): void; } //#endregion export { CaptureProgressHandle, CaptureSpinnerHandle, StaticProgressHandle, StaticSpinnerHandle, TTYProgressHandle, TTYSpinnerHandle, noopProgressHandle, noopSpinnerHandle };