Files
SnowLuma/.pnpm-store/v11/files/eb/c87bcf4946915997cd1dff9c7d458f93a3b43578e63acd07652f7bb1b6d95aabc34e956b27ec5b844c113055c9435c5c2bd6a4b686d63ce95e862ef55b39a9
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

39 lines
1.6 KiB
Plaintext

import { AnyRouter } from './router.js';
import { ParsedLocation } from './location.js';
import { NonNullableUpdater } from './utils.js';
export type ScrollRestorationEntry = {
scrollX: number;
scrollY: number;
};
type ScrollRestorationByElement = Record<string, ScrollRestorationEntry>;
type ScrollRestorationByKey = Record<string, ScrollRestorationByElement>;
type ScrollRestorationCache = {
readonly state: ScrollRestorationByKey;
set: (updater: NonNullableUpdater<ScrollRestorationByKey>) => void;
persist: () => void;
};
export type ScrollRestorationOptions = {
getKey?: (location: ParsedLocation) => string;
scrollBehavior?: ScrollToOptions['behavior'];
};
export declare const storageKey = "tsr-scroll-restoration-v1_3";
export declare const scrollRestorationCache: ScrollRestorationCache | null;
/**
* The default `getKey` function for `useScrollRestoration`.
* It returns the `key` from the location state or the `href` of the location.
*
* The `location.href` is used as a fallback to support the use case where the location state is not available like the initial render.
*/
export declare const defaultGetScrollRestorationKey: (location: ParsedLocation) => string;
export declare function getElementScrollRestorationEntry(router: AnyRouter, options: ({
id: string;
getElement?: () => Window | Element | undefined | null;
} | {
id?: string;
getElement: () => Window | Element | undefined | null;
}) & {
getKey?: (location: ParsedLocation) => string;
}): ScrollRestorationEntry | undefined;
export declare function setupScrollRestoration(router: AnyRouter, force?: boolean): void;
export {};