import type { CloneFn } from "../use-cloned-state/index.js"; import type { UseDebouncedFnOptions } from "../use-debounced-fn/index.js"; import type { UseThrottledFnOptions } from "../use-throttled-fn/index.js"; export interface UseRefHistoryRecord { /** * The serialized snapshot */ snapshot: T; /** * The timestamp */ timestamp: number; } export interface UseManualStateHistoryOptions { /** * The capacity of the history records * * @defaultValue Number.POSITIVE_INFINITY */ capacity?: number; /** * Whether to clone the source state * * @defaultValue false */ clone?: boolean | CloneFn; /** * The throttle options * * @defaultValue undefined */ throttle?: number | UseThrottledFnOptions; /** * The debounce options * * @defaultValue undefined */ debounce?: number | UseDebouncedFnOptions; /** * The dump function to serialize the source state * * @defaultValue (v) => v */ dump?: (v: Raw) => Serialized; /** * The parse function to deserialize the serialized state * * @defaultValue (v) => v */ parse?: (v: Serialized) => Raw; } export interface UseManualStateHistoryReturns { /** * The source state */ source: Raw; /** * The history records */ history: UseRefHistoryRecord[]; /** * The last history record */ last: UseRefHistoryRecord; /** * The undo stack */ undoStack: UseRefHistoryRecord[]; /** * The redo stack */ redoStack: UseRefHistoryRecord[]; /** * Whether can undo or redo */ canUndo: boolean; /** * Whether can redo or undo */ canRedo: boolean; /** * Undo the last change */ undo(): void; /** * Redo the last change */ redo(): void; /** * Clear all history records */ clear(): void; /** * Commit the current source state to history */ commit(): void; } /** * A React Hook that allows you to manage the state history manually. */ export declare function useManualStateHistory(source: Raw, options?: UseManualStateHistoryOptions): UseManualStateHistoryReturns;