import { type QueryKey, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query'; /** * A versioned, scoped copy of a value in localStorage. Shell data that decides * the first paint (navigation, the org's menu layout, installed presets, * permissions) is read from here synchronously, so a reload paints the last * known state instead of a default that reorders when the network answers. * * The entry lives under `:v:`. Bump `version` when the * stored shape changes; old entries are simply never read again. `scope` keeps * one org or user from seeing another's copy on a shared browser. */ export interface PersistedSnapshotOptions { key: string; version: number; /** Entries older than this are ignored (default: 30 days). */ maxAgeMs?: number; } export interface PersistedEntry { data: T; /** When the data was fetched (ms epoch). */ ts: number; } export interface PersistedSnapshot { read(scope: string): PersistedEntry | undefined; write(scope: string, data: T, meta?: { ts?: number; }): void; clear(scope: string): void; } export declare function createPersistedSnapshot({ key, version, maxAgeMs, }: PersistedSnapshotOptions): PersistedSnapshot; export type UsePersistedQueryOptions = UseQueryOptions & { persist: { snapshot: PersistedSnapshot; /** * Org/user the data belongs to. Without a scope nothing is read or * written (e.g. before sign-in). */ scope: string | null | undefined; }; }; /** * `useQuery` seeded from a {@link PersistedSnapshot}: the first render already * has the last fetched value (stale-while-revalidate), and every later value — * a refetch, or a `setQueryData` from a mutation — is written back. The seed is * stale from the start: every page load revalidates it once in the background, * so a change made elsewhere (a plantilla applied, an addon installed, * permissions edited) shows on the next load even inside `staleTime`. * * Persist the raw server payload and derive UI shapes with `select`; the * snapshot must be JSON. */ export declare function usePersistedQuery(options: UsePersistedQueryOptions): UseQueryResult; //# sourceMappingURL=use-persisted-query.d.ts.map