import { LimenError } from "./errors.mjs"; import { ReadableAtom } from "nanostores"; //#region src/data-store.d.ts type StoreState = { data: T; /** Writes do not set it — only loads. */ isPending: boolean; /** True once `data` is known — seeded by the app, or loaded successfully. */ settled: boolean; /** The last load failure, cleared on the next load or write. */ error: LimenError | null; }; type StoreLoader = () => Promise; type RefetchOptions = { /** Skip the load when the last one ran within this many milliseconds. */maxAgeMs?: number; /** Skip the load while `data` is `null`. */ skipWhenEmpty?: boolean; /** Start a load even when one is in flight: joining it would resolve with the state the write replaced. */ force?: boolean; }; type DataStore = { /** Subscribe or `get()` for UI — both mount the store, starting `fetchOnMount`. */readonly $state: ReadableAtom>; /** Snapshot without mounting — safe inside effects and non-UI reads. */ current(): StoreState; setData(data: T): void; refetch(options?: RefetchOptions): Promise; }; type CreateStoreOptions = { initial: T; /** Whether `initial` is a known value rather than a placeholder. */ settled?: boolean; loader?: StoreLoader; fetchOnMount?: boolean; onMount?: (store: DataStore) => (() => void) | void; }; declare function createStore(options: CreateStoreOptions): DataStore; //#endregion export { DataStore, RefetchOptions, StoreLoader, StoreState, createStore };