/** * Scroll Restoration Module * * Provides scroll position persistence across navigations, following React Router v7 patterns: * - Saves scroll positions to sessionStorage keyed by unique history entry key * - Restores scroll on back/forward navigation * - Scrolls to top on new navigation (unless scroll: false) * - Supports hash link scrolling */ /** * Custom getKey function for determining scroll restoration key */ type GetScrollKeyFunction = (location: { pathname: string; search: string; hash: string; key: string; }) => string; /** * Generate a unique key for the current history entry. * Uses history.state.key if available, otherwise generates and stores a new one. */ export declare function getHistoryStateKey(): string; /** * Get the scroll restoration key for a location. * Uses custom getKey function if set, otherwise uses history state key. */ export declare function getScrollKey(): string; /** * Initialize scroll restoration. * Sets manual scroll restoration mode and loads saved positions from sessionStorage. */ export declare function initScrollRestoration(options?: { getKey?: GetScrollKeyFunction; }): () => void; /** * Save the current scroll position for the current history entry. * Maintains bounded size by evicting oldest entries when the limit is exceeded. */ export declare function saveCurrentScrollPosition(): void; /** * Get the saved scroll position for a history key */ export declare function getSavedScrollPosition(key?: string): number | undefined; /** * Cancel any pending scroll restoration polling */ export declare function cancelScrollRestorationPolling(): void; /** * Restore scroll position for the current history entry. * Returns true if position was fully restored, false otherwise. * * @param options.retryIfStreaming - If true, poll while streaming until we can scroll to target * @param options.isStreaming - Function to check if streaming is in progress */ export declare function restoreScrollPosition(options?: { retryIfStreaming?: boolean; isStreaming?: () => boolean; }): boolean; /** * Handle hash link scrolling. * Scrolls to element with matching ID if hash is present. * Returns true if scrolled to element, false otherwise. */ export declare function scrollToHash(): boolean; /** * Scroll to top of page */ export declare function scrollToTop(): void; /** * Handle scroll for a new navigation. * - Saves current position before navigating * - Ensures new history entry has a key */ export declare function handleNavigationStart(): void; /** * Handle scroll after navigation completes. * @param options.restore - If true, restore saved position (for popstate) * @param options.scroll - If false, don't scroll at all * @param options.isStreaming - Function to check if streaming is in progress (for retry logic) */ export declare function handleNavigationEnd(options: { restore?: boolean; scroll?: boolean; isStreaming?: () => boolean; }): void; /** * Update the history state key after pushState/replaceState. * Call this after changing history to ensure new entry has a key. */ export declare function ensureHistoryKey(): void; export {}; //# sourceMappingURL=scroll-restoration.d.ts.map