/** Default number of steps kept. Old steps fall off the bottom. */ export declare const DEFAULT_UNDO_LIMIT = 50; export interface UndoEntry { /** * Reverses the change. May be async; `undo()` awaits it, so a caller that * repaints the 3D view can return that work here. */ undo: () => void | Promise; /** * Re-applies the change after an undo. Optional: a step without one is still * undoable, but undoing it empties the redo stack, since redoing anything * above it would skip a step and land on a state that never existed. */ redo?: () => void | Promise; /** Short description of the change, for a tooltip or a log line. */ label?: string; } export interface UndoHistory { /** * Records how to reverse a change that has just happened, and discards * anything that was waiting to be redone. Ignored while an undo or redo is * running, so a replay cannot record itself as a new step. */ push: (entry: UndoEntry) => void; /** * Adjusts the step just recorded, without adding one. * * For coalescing: a slider drag records a step on its first tick, then amends * that step's `redo` as the value keeps changing, so the whole drag stays one * undo away and redo lands on where the drag finished. No-op on an empty stack. */ amendTop: (changes: Partial) => void; /** Reverses the most recent change. Resolves false when there is none. */ undo: () => Promise; /** Re-applies the most recently undone change. Resolves false when there is none. */ redo: () => Promise; /** Drops both stacks. */ clear: () => void; readonly canUndo: boolean; readonly canRedo: boolean; readonly depth: number; /** Label of the change `undo()` would reverse next. */ readonly nextLabel: string | undefined; /** Label of the change `redo()` would re-apply next. */ readonly nextRedoLabel: string | undefined; /** Subscribe to stack changes; returns the unsubscribe function. */ onChanged: (listener: () => void) => () => void; } /** * A plain undo/redo stack, deliberately free of React and of any BIM or map * types so anything in core can hold one. * * It stores *how to move between states* rather than snapshots, which suits both * styles: a feature that keeps immutable state closes over the old and new * values, and one that mutates pushes the inverse operation. * * ```ts * const history = createUndoHistory() * const previous = items * const next = [...items, added] * items = next * history.push({ * label: 'Add item', * undo: () => { items = previous }, * redo: () => { items = next }, * }) * ``` */ export declare function createUndoHistory(options?: { limit?: number; }): UndoHistory; //# sourceMappingURL=undoHistory.d.ts.map