/** * RouterUtils — Scope class for all router-related reactive state. * * Instantiate via MatesUtils (renderApp / WithScope). Child components * access router state via `useUtils()`. * * Mount **at most one** {@link Router} or {@link animatedRouter} per scope. * That outlet sets `patternsAtom`; `paramsAtom` is computed from * `pathAtom` + `patternsAtom`. Nest screens with conditionals on * `paramsAtom` / `qsAtom` / `pathAtom` — do not nest routers. * * Public `pathAtom` / `qsAtom` / `hashAtom` / `paramsAtom` `.set` / `.update` * go through `navigateTo` so history + atoms stay in sync. The optional second * argument is `replace` (path defaults to push; qs/hash/params default to * replace). Internal sync uses `originalSet`. * * @example * ```ts * ${Router([{ path: "/users/:id", component: UserPage }])()} * * // Nested UI without a second router: * const { paramsAtom } = useUtils(); * paramsAtom().photoId ? x(Photo) : x(Gallery); * ``` */ import type { AtomType } from "../Mutables/atom/atom"; import { type NavigableAtomType, type NavigableSuperAtomType } from "../Router/navigableAtom"; import type { NavigationRequestDetail, NavigationRequestEvent } from "../Router/navigationRequest"; export declare class RouterUtils { navigationLocked: AtomType; navigationRequestEvent: NavigationRequestEvent; historyStateAtom: AtomType; pathAtom: NavigableSuperAtomType; qsAtom: NavigableAtomType>; hashAtom: NavigableAtomType>; /** * Currently matched route pattern (set by Router / animatedRouter on match), * e.g. `"/users/:id"`. `null` when nothing is matched. */ patternsAtom: AtomType; /** * Computed route params from {@link pathAtom} + {@link patternsAtom}, * e.g. `{ id: "42" }`. Empty object when no match. */ paramsAtom: NavigableAtomType>; /** Which outlet currently owns `patternsAtom` (at most one). */ private _activeOutlet; private _navigateTo; constructor(); /** * Claim the single router outlet slot for this scope. Throws if another * Router / animatedRouter is already mounted. Call the returned release * from `onCleanup` when the outlet unmounts. */ claimRouterOutlet(kind: "Router" | "animatedRouter"): () => void; navigateTo(path: string, replace?: boolean, data?: any): void; lockNavigation(): void; unlockNavigation(): void; get location(): { readonly path: string; readonly hash: Record; readonly qsObj: Record; }; /** * Subscribe to navigation attempts. When any subscriber exists, `navigateTo` * defers commit until **every** subscriber calls `detail.next()` (AND). * Not calling `next()` cancels (sync and async). Prefer this for * confirm-to-leave; use `lockNavigation` for a hard block with no dialog. * Use `onNavigate` for post-commit side effects. */ onNavigationRequest(fn: (detail: NavigationRequestDetail) => void | Promise): void; } //# sourceMappingURL=RouterUtils.d.ts.map