Files
SnowLuma/.pnpm-store/v11/files/3d/629e099da85ea46ecdc422ea76a8440eb1013d52848a1818b193948574bd63a0539090de552952992bb2f15e373f627caa3ec9f9cc25990d3f59f6df3edb80
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.cjs';
import { ParsedLocation } from './location.cjs';
import { NonNullableUpdater } from './utils.cjs';
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 {};