import type { NavigationStore, ResolvedSegment } from "./types.js"; /** * Options for generating a history key */ export interface HistoryKeyOptions { /** If true, append :intercept suffix to differentiate intercept entries */ intercept?: boolean; } /** * Generate a cache key from a URL. * Uses pathname + search (query params) directly as the key. * Hash fragments (#) are excluded since they don't affect server data. * * For intercept routes, append `:intercept` suffix to cache them separately * from non-intercept versions of the same URL. */ export declare function generateHistoryKey(url?: string, options?: HistoryKeyOptions): string; /** * Configuration for creating a navigation store */ export interface NavigationStoreConfig { initialLocation?: { href: string; }; initialSegmentIds?: string[]; initialHistoryKey?: string; initialSegments?: ResolvedSegment[]; /** * Maximum number of history entries to cache (default: 20) * Older entries are evicted when limit is reached */ cacheSize?: number; /** * Enable cross-tab cache invalidation via BroadcastChannel (default: true) * When cache is cleared (via server actions or useClientCache().clear()), * other tabs will also clear their cache */ crossTabSync?: boolean; /** * Auto-refresh when another tab mutates data on the same path (default: true) * Triggered when cache is cleared via server actions or useClientCache().clear() * Requires crossTabSync to be enabled */ crossTabAutoRefresh?: boolean; /** * Callback to invoke when cross-tab refresh is triggered * Called when another tab invalidates the cache for a related route */ onCrossTabRefresh?: () => void; } /** * Create a navigation store for managing browser-side navigation state * * The store manages two types of state: * - NavigationState: Public state exposed via useNavigation hook * - SegmentState: Internal segment management for partial RSC updates * * @param config - Initial configuration * @returns NavigationStore instance * * @example * ```typescript * const store = createNavigationStore({ * initialLocation: window.location, * initialSegmentIds: [], * }); * * // Subscribe to state changes (for useNavigation hook) * const unsubscribe = store.subscribe(() => { * const state = store.getState(); * console.log('Navigation state:', state); * }); * * // Update state * store.setState({ state: 'loading' }); * * // Subscribe to UI updates (for re-rendering) * store.onUpdate((update) => { * console.log('New root:', update.root); * }); * ``` */ export declare function createNavigationStore(config?: NavigationStoreConfig): NavigationStore; /** * Initialize the global navigation store * * Should be called once during app initialization. * Subsequent calls return the existing instance. */ export declare function initNavigationStore(config?: NavigationStoreConfig): NavigationStore; /** * Get the global navigation store * * Throws if store hasn't been initialized. */ export declare function getNavigationStore(): NavigationStore; /** * Reset the store instance (for testing) */ export declare function resetNavigationStore(): void; //# sourceMappingURL=navigation-store.d.ts.map