import type { BaseBus, Command, CommandResult, Handler, ScopeOptions } from './command-bus'; import { type TabHearer } from './applied-remotely'; /** * The origins history does not record: what an undo or a redo dispatched, and * a change an app's sync layer mirrored. A reaction skips them too * (utilities.ts), so a redo does not run its follow-up twice. */ export declare const _unrecorded: (origin: string | undefined) => boolean; /** What the ledger needs from a bus: the two calls an undo and a redo make. */ export type LedgerBus = { getUndoHandler(action: string): Handler | undefined; /** The `canUndo` registered with the undo (register options), when any. */ getUndoCheck?(action: string): ((cmd: Command) => boolean) | undefined; dispatch(action: string, target: any, payload?: any): unknown; }; export type Ledger = { /** The undo stack, oldest first: the ledger's own array, `readonly`. A change after it was handed out writes a new one. */ readonly past: readonly Command[]; /** The redo stack, oldest first: the ledger's own array, `readonly`. A change after it was handed out writes a new one. */ readonly future: readonly Command[]; /** Record `cmd` if the rule keeps it. */ record(cmd: Command, result: CommandResult): void; /** Something to undo, and the top command's `canUndo` (when registered) says it can be. */ canUndo(): boolean; undo(): Command | undefined; redo(): Command | undefined; clear(): void; } & TabHearer; export declare function createLedger(options: ScopeOptions & { maxSize?: number; /** Also left out of the ledger (trigger actions, a paused view). */ skip?: (cmd: Command) => boolean; bus: LedgerBus; /** * After any change. The undo stack moves on every change; `futureMoved` * says whether the redo stack did, so a view can keep an identity it does * not need to renew. */ onChange?: (futureMoved: boolean) => void; }): Ledger; /** * The one recorder: an after-hook, installed past a seal, and a hearer of the * bus's stores across tabs. Returns its removal. */ export declare function recordOn(bus: BaseBus, ledger: Ledger): () => void; //# sourceMappingURL=ledger.d.ts.map