import { ActionUnion, BoundActionCreators } from '../../utils/typedActions'; import { NodeEditorData } from '../../types/core'; /** * @file Context for managing undo/redo history with editor state snapshots */ import * as React from "react"; export type HistoryEntry = { id: string; timestamp: number; action: string; data: NodeEditorData; }; export type HistoryState = { entries: HistoryEntry[]; currentIndex: number; maxEntries: number; isRecording: boolean; }; export declare const historyActions: { readonly pushEntry: ((action: string, data: NodeEditorData) => { type: "PUSH_ENTRY"; payload: { action: string; data: NodeEditorData; }; }) & { readonly type: "PUSH_ENTRY"; }; readonly undo: (() => { type: "UNDO"; }) & { readonly type: "UNDO"; }; readonly redo: (() => { type: "REDO"; }) & { readonly type: "REDO"; }; readonly clearHistory: (() => { type: "CLEAR_HISTORY"; }) & { readonly type: "CLEAR_HISTORY"; }; readonly setRecording: ((isRecording: boolean) => { type: "SET_RECORDING"; payload: { isRecording: boolean; }; }) & { readonly type: "SET_RECORDING"; }; readonly setMaxEntries: ((maxEntries: number) => { type: "SET_MAX_ENTRIES"; payload: { maxEntries: number; }; }) & { readonly type: "SET_MAX_ENTRIES"; }; }; export type HistoryAction = ActionUnion; export declare const defaultHistoryState: HistoryState; export declare const historyReducer: (state: HistoryState, action: HistoryAction) => HistoryState; export type HistoryActionsValue = { dispatch: React.Dispatch; actions: BoundActionCreators; actionCreators: typeof historyActions; pushEntry: (action: string, data: NodeEditorData) => void; undo: () => HistoryEntry | null; redo: () => HistoryEntry | null; }; export type HistoryContextValue = HistoryActionsValue & { state: HistoryState; canUndo: boolean; canRedo: boolean; currentEntry: HistoryEntry | null; }; export declare const HistoryContext: React.Context; export type HistoryProviderProps = { children: React.ReactNode; initialState?: Partial; /** Preferred: pass max entries as a stable prop; internally memo-updated */ maxEntries?: number; }; export declare const HistoryProvider: React.FC; /** * Hook to access only the history state * Use this when you only need to read state and don't need actions */ export declare const useHistoryState: () => HistoryState; /** * Hook to access only the history actions * Use this when you only need to dispatch actions and don't need to re-render on state changes * The returned actions have stable references and won't cause re-renders */ export declare const useHistoryActions: () => HistoryActionsValue; /** * Hook to access both state and actions (backward compatible) * Prefer useHistoryState or useHistoryActions for better performance */ export declare const useHistory: () => HistoryContextValue;