import { Params, PluginFactory, State } from "@real-router/core"; import "@real-router/core/api"; //#region ../../shared/browser-env/types.d.ts interface HistoryBrowser { pushState: (state: unknown, path: string) => void; replaceState: (state: unknown, path: string) => void; addPopstateListener: (fn: (evt: PopStateEvent) => void) => () => void; /** * Subscribe to `hashchange`. Fired for same-document fragment navigations * that the plugin did NOT drive itself — native anchors (``), * manual address-bar hash edits, and `location.hash = ...` from app code. * `pushState`/`replaceState` (the plugin's own writes) never fire it, so it * is a clean external-change channel. Used by hash-plugin (`#` carries the * route) and by browser-plugin to keep its cached fragment fresh without a * per-navigation `location.hash` read (#532 forces a sync pushState commit). * (#759, #1019) */ addHashChangeListener: (fn: (evt: HashChangeEvent) => void) => () => void; getHash: () => string; /** * Reads the current `history.state`. Used on popstate success to detect when * the browser has already restored the exact `{name, params, path}` the * transition resolved to — in which case the plugin's own `replaceState` is a * value-level no-op and can be skipped, avoiding a redundant * `updateForSameDocumentNavigation` Blink event on back/forward (#1353). * * Optional so a custom `Browser` predating this method still type-checks; when * absent the plugin keeps the unconditional write (no skip, legacy behavior). * The default browser (`createSafeBrowser`) always provides it. */ getState?: () => unknown; } interface Browser extends HistoryBrowser { getLocation: () => string; } //#endregion //#region src/types.d.ts /** * Hash-based routing plugin configuration. * Uses URL hash fragment for navigation (e.g., example.com/#/path). */ interface HashPluginOptions { /** * Prefix for hash (e.g., "!" for "#!/path"). * * @default "" */ hashPrefix?: string; /** * Base path prepended before hash (e.g., "/app" → "/app#/path"). * * @default "" */ base?: string; /** * Force deactivation of current route even if canDeactivate returns false. * * @default true */ forceDeactivate?: boolean; } //#endregion //#region src/factory.d.ts declare function hashPluginFactory(opts?: Partial, browser?: Browser): PluginFactory; //#endregion //#region ../../shared/browser-env/state-guard.d.ts /** * Type guard for State. Performs the required-field check (`name` via * `isRouteName`, `path` is a string, `params` via `isParams`) — the "Strict" in * the name is historical: there is no deeper meta-field validation, and `meta.id` * is intentionally NOT type-checked (history.state restores serialize it as a * string). Re-exported as `isState` by the browser and hash plugins for * validating `history.state`. * * @param value - Value to check * @returns true if value has the required State fields with valid types * * @example * isStateStrict({ name: 'home', params: {}, path: '/' }); // true * isStateStrict({ name: 'home', params: 'invalid', path: '/' }); // false */ declare function isStateStrict

(value: unknown): value is State

; //#endregion //#region src/index.d.ts /** * Module augmentation for real-router. * Extends Router interface with hash plugin methods. * * NavigationOptions augmentation (#532) keeps the `hash` / `hashChange` keys * known to TypeScript even when only hash-plugin is installed — runtime * silently ignores them with a one-time warn. */ declare module "@real-router/core/types" { interface NavigationOptions { /** * URL fragment override (decoded, no leading "#"). Ignored by hash-plugin * (URL fragments are structurally incompatible with hash routing); see * `Router.buildUrl`. (#532) */ hash?: string; /** @internal — not used by hash-plugin. */ hashChange?: boolean; /** * @internal — transition origin tag. Set to `"popstate"` by the popstate * handler so `onTransitionSuccess` can gate the back/forward history-write * skip (#1353). Identical optional shape to browser-plugin's augmentation, * so the two merge cleanly when both are imported for typing. */ source?: string; } } declare module "@real-router/core" { interface Router { /** * Builds full URL for a route with base path and hash prefix. * Added by hash plugin. * * The optional `hash` option exists for typing parity with browser-plugin * and navigation-plugin (#532). hash-plugin uses `#` as the route * delimiter, so the option is silently ignored at runtime and a * one-time `console.warn` is emitted. */ buildUrl(name: string, params?: Params, options?: { hash?: string; }): string; /** * Matches URL and returns corresponding state. * Added by hash plugin. */ matchUrl(url: string): State | undefined; /** * Replaces current history state without triggering navigation. * Added by hash plugin. The optional `hash` option is ignored (see * `buildUrl`). */ replaceHistoryState(name: string, params?: Params, options?: { hash?: string; }): void; start(path?: string): Promise; } } //#endregion export { type Browser, type HashPluginOptions, hashPluginFactory, isStateStrict as isState }; //# sourceMappingURL=index.d.ts.map