import { UseManualHistoryTravelAccessorReturn, UseManualHistoryTravelSignalReturn } from '../useManualHistoryTravel/index.js'; import { ConfigurableEventFilter, Fn } from '@solidjs-use/shared'; import { Accessor, Signal } from 'solid-js'; import { CloneFn } from '../useCloned/index.js'; import 'solid-js/types/reactive/signal'; interface UseHistoryTravelOptions extends ConfigurableEventFilter { /** * Maximum number of history to be kept. Default to unlimited. */ capacity?: number; /** * Clone when taking a snapshot, shortcut for dump: JSON.parse(JSON.stringify(value)). * Default to false * * @default false */ clone?: boolean | CloneFn; /** * Serialize data into the history */ dump?: (v: Raw) => Serialized; /** * Deserialize data from the history */ parse?: (v: Serialized) => Raw; } interface UseHistoryTravelBaseReturn { /** * A Accessor representing if the tracking is enabled */ isTracking: Accessor; /** * Pause change tracking */ pause: () => void; /** * Resume change tracking * * @param [commit] if true, a history record will be create after resuming */ resume: (commit?: boolean) => void; /** * A sugar for auto pause and auto resuming within a function scope * * @param fn */ batch: (fn: (cancel: Fn) => void) => void; /** * Clear the data and stop the watch */ dispose: () => void; } type UseHistoryTravelAccessorReturn = UseHistoryTravelBaseReturn & UseManualHistoryTravelAccessorReturn; type UseHistoryTravelSignalReturn = UseHistoryTravelBaseReturn & UseManualHistoryTravelSignalReturn; /** * Track the change history of a `Signal` or `Accessor`, when the parameter is a Signal, it provides undo and redo functionality. * * @see https://solidjs-use.github.io/solidjs-use/core/useHistoryTravel */ declare function useHistoryTravel(source: Accessor, options?: UseHistoryTravelOptions): UseHistoryTravelAccessorReturn; declare function useHistoryTravel(source: Signal, options?: UseHistoryTravelOptions): UseHistoryTravelSignalReturn; export { UseHistoryTravelAccessorReturn, UseHistoryTravelBaseReturn, UseHistoryTravelOptions, UseHistoryTravelSignalReturn, useHistoryTravel };