import { AnyAction } from '@dineug/r-html';
type Dispatch = (actions: AnyAction[]) => void;
export type Command = {
undo: (dispatch: Dispatch) => void;
redo: (dispatch: Dispatch) => void;
};
export type CommandKey = keyof Command;
export type History = {
readonly cursor: number;
readonly size: number;
hasUndo: () => boolean;
hasRedo: () => boolean;
undo: () => void;
redo: () => void;
push: (command: Command) => void;
clear: () => void;
setLimit: (limit: number) => void;
clone: (options: HistoryOptions) => History;
};
type HasHistory = {
hasRedo: boolean;
hasUndo: boolean;
};
export type HistoryOptions = {
notify: (has: HasHistory) => void;
dispatch: Dispatch;
};
type HistoryState = {
commands: Command[];
cursor: number;
limit: number;
};
export declare function createHistory({ notify, dispatch }: HistoryOptions, initialState?: HistoryState): History;
export {};