/** * A single shared watcher for SPA navigations. * * `history.pushState`/`replaceState` are patched exactly once, no matter how * many subscribers there are. Each feature patching them independently meant * the last one to install wrapped the others, so unsubscribing in a different * order than subscribing could restore a stale function and silently leave a * feature listening forever. */ export type UrlChangeSource = "pushstate" | "replacestate" | "popstate" | "hashchange"; export interface UrlChangeInfo { /** Which navigation signal fired. */ source: UrlChangeSource; /** Arguments passed to pushState/replaceState, empty for the events. */ args: any[]; } type Listener = (info: UrlChangeInfo) => void; /** * Run `fn` whenever the URL changes via the history API, back/forward * navigation, or a hash change. Returns an unsubscribe function; the patched * history methods are restored once the last subscriber leaves. */ export declare function onUrlChange(fn: Listener): () => void; /** True when `url` contains any of the given substrings. */ export declare function matchesAnyPattern(url: string, patterns: string[] | undefined | null): boolean; /** Drop all subscribers and restore native history methods. For tests. */ export declare function resetUrlWatch(): void; export {};