import type { FieldPath, FieldPathValue, FieldValues } from './path'; import { getStableKeys, setExternalKeyOrder } from './stable_keys'; export { getNestedValue, getSnapshot, getStableKeys, isClass, isEqual, isRecord, joinPath, notifyListeners, produce, rename, setExternalKeyOrder, setLeaf, setNestedValue, subscribe, testReset, updateSnapshot, useCompute, useDebounce, useObject }; declare function testReset(): void; declare function isClass(value: unknown): boolean; declare function isRecord(value: unknown): boolean; /** Compare two values for equality * @description * - react-fast-compare for non-class instances * - reference equality for class instances * @param a - The first value to compare * @param b - The second value to compare * @returns True if the values are equal, false otherwise */ declare function isEqual(a: unknown, b: unknown): boolean; /** * Joins a namespace and path into a full key string. * * @param namespace - The store namespace (root key) * @param path - Optional dot-separated path within the namespace * @returns Combined key string (e.g., "app.user.name") */ declare function joinPath(namespace: string, path?: string): string; /** Snapshot getter used by React's useSyncExternalStore. */ declare function getSnapshot(key: string, memoryOnly: boolean): unknown; /** Updates the snapshot of a key. */ declare function updateSnapshot(key: string, value: unknown, memoryOnly: boolean): void; /** Get a nested value from an object/array using a dot-separated path. */ declare function getNestedValue(obj: unknown, path: string): unknown; /** * Immutably sets or deletes a nested value using a dot-separated path. * * Creates intermediate objects or arrays as needed based on whether the next * path segment is numeric. When value is undefined, the key is deleted from * objects or the index is spliced from arrays. * * @param obj - The root object to update * @param path - Dot-separated path to the target location * @param value - The value to set, or undefined to delete * @returns A new root object with the change applied */ declare function setNestedValue(obj: unknown, path: string, value: unknown): unknown; /** * Notifies all relevant listeners when a value changes. * * Handles three types of listeners: * 1. Exact match - listeners subscribed to the exact changed path * 2. Root listeners - listeners on the namespace root (for full-store subscriptions) * 3. Child listeners - listeners on nested paths that may be affected by the change * * Child listeners are only notified if their specific value actually changed, * determined by deep equality comparison. */ declare function notifyListeners(key: string, oldValue: unknown, newValue: unknown, { skipRoot, skipChildren, forceNotify }?: { skipRoot?: boolean | undefined; skipChildren?: boolean | undefined; forceNotify?: boolean | undefined; }): void; /** * Subscribes to changes for a specific key. * * @param key - The full key path to subscribe to * @param listener - Callback invoked when the value changes * @returns An unsubscribe function to remove the listener */ declare function subscribe(key: string, listener: () => void): () => void; declare function useCompute(namespace: string, path: string | undefined, fn: (value: T) => R, deps?: readonly unknown[], memoryOnly?: boolean): R; /** * Core mutation function that updates the store and notifies listeners. * * Handles both setting and deleting values, with optimizations to skip * unnecessary updates when the value hasn't changed. * * @param key - The full key path to update * @param value - The new value, or undefined to delete * @param skipUpdate - When true, skips notifying listeners * @param memoryOnly - When true, skips localStorage persistence */ declare function produce(key: string, value: unknown, skipUpdate: boolean, memoryOnly: boolean): void; /** * Renames a key in an object. * * It trigger updates to * * - listeners to `path` (key is updated) * - listeners to `path.oldKey` (deleted) * - listeners to `path.newKey` (created) * * @param path - The full key path to rename * @param oldKey - The old key to rename * @param newKey - The new key to rename to */ declare function rename(path: string, oldKey: string, newKey: string, memoryOnly: boolean): void; /** * React hook that subscribes to and reads a value at a path. * * Uses useSyncExternalStore for tear-free reads and automatic re-rendering * when the subscribed value changes. * * @param key - The namespace or full key * @param path - Optional path within the namespace * @param memoryOnly - When true, skips localStorage persistence * @returns The current value at the path, or undefined if not set */ declare function useObject>(key: string, path: P | undefined, memoryOnly: boolean): FieldPathValue | undefined; /** * React hook that subscribes to a value with debounced updates. * * The returned value only updates after the specified delay has passed * since the last change, useful for expensive operations like search. * * @param key - The namespace or full key * @param path - Path within the namespace * @param delay - Debounce delay in milliseconds * @param memoryOnly - When true, skips localStorage persistence * @returns The debounced value at the path */ declare function useDebounce>(key: string, path: P, delay: number, memoryOnly: boolean): FieldPathValue | undefined; /** * Sets a value at a specific path within a namespace. * * @param key - The namespace * @param path - Path within the namespace * @param value - The value to set, or undefined to delete * @param skipUpdate - When true, skips notifying listeners * @param memoryOnly - When true, skips localStorage persistence */ declare function setLeaf>(key: string, path: P, value: FieldPathValue | undefined, skipUpdate?: boolean, memoryOnly?: boolean): void;