UNPKG

histoire

Version:

A fast story book powered by Vite

52 lines • 2.71 kB
import type { WatchSetArgs, WatchStateDto } from '@histoire/cli/protocol/watch'; import type { AffectedSelector } from '../affected/selector.js'; import type { TestsService } from '../tests/service.js'; import type { CollectionBarrierOptions } from './barrier.js'; /** Inputs of one per-generation watch scheduler. */ export interface WatchSchedulerOptions { /** Affected-story classification and selection (slice 09); the scheduler never reimplements either. */ selector: Pick<AffectedSelector, 'onChange' | 'select' | 'refresh' | 'attach' | 'detach'>; /** Terminal test service; every run goes through its scoped lane owner. */ tests: Pick<TestsService, 'run' | 'runAffected' | 'cancel'>; /** Canonical catalog of the generation. */ catalog: CollectionBarrierOptions['catalog']; /** Collection observations of the generation. */ onCollection: CollectionBarrierOptions['onCollection']; /** Receives every state change (dropped by the adapter once the generation retires). */ emit: (state: WatchStateDto) => void; /** Aborted when the generation is released: everything stops and nothing is rescheduled. */ signal: AbortSignal; /** Quiet period after the last edit before a run is admitted. */ settleMs?: number; /** Backoff bounds for a full execution queue. */ retryMs?: { initial: number; max: number; }; } /** * Affected-story watch of one runtime generation. It combines classified edits * (09), the collection barrier and the terminal test service (07): * - an edit joins the pending set; an owned stale run is cancelled, its * unvalidated targets go back into the set, and a successor is admitted only * after the lane confirmed cleanup, collection is usable and edits settled; * - admission claims the set atomically and restores it if refused; * - failures pause (never retried in a loop, never broadened to another scope); * - disabling or releasing the generation bumps `session`/`dead` first, so a * late completion can never reschedule. * It never awaits a test run inside a collection handler. * @param options Generation-scoped capabilities. */ export declare function createWatchScheduler(options: WatchSchedulerOptions): { /** * Enables, retargets or disables watching. An unchanged request is a no-op; * a new scope cancels owned work, resets the pending set and runs the new scope once. * @param args Desired state. */ set(args: WatchSetArgs): WatchStateDto; /** Current snapshot. */ state: () => WatchStateDto; }; /** Per-generation scheduler. */ export type WatchScheduler = ReturnType<typeof createWatchScheduler>; //# sourceMappingURL=scheduler.d.ts.map