import type { FieldValues } from './path'; import type { State, ValueState } from './types'; export { createMemoryStore, type MemoryStore, useMemoryStore }; /** * A component local store with React bindings. * * - Dot-path addressing for nested values (e.g. "state.ui.theme"). * - Immutable partial updates with automatic object/array creation. * - Fine-grained subscriptions built on useSyncExternalStore. * - Type-safe paths using FieldPath. * - Dynamic deep access via Proxy for ergonomic usage like `state.a.b.c.use()` and `state.a.b.c.set(v)`. */ type MemoryStore = ValueState & { [K in keyof T]-?: State; }; /** * React hook that creates a component-scoped memory store. * * Unlike `createStore`, this store is not persisted to localStorage and is * unique to each component instance. Useful for complex local state that * benefits from the store's path-based API without persistence. * * @param defaultValue - Initial state shape * @returns A proxy providing dynamic path access to the store * * @example * type SearchState = { * query: string * filters: { category: string } * results: { id: number; name: string }[] * } * * function ProductSearch() { * const state = useMemoryStore({ * query: '', * filters: { category: 'all' }, * results: [] * }) * * return ( * <> * * * * ) * } * * function SearchInput({ state }: { state: MemoryStore }) { * const query = state.query.use() * return state.query.set(e.target.value)} /> * } */ declare function useMemoryStore(defaultValue: T): MemoryStore; declare function createMemoryStore(namespace: string, defaultValue: T): MemoryStore;