export type RouteParams = Record; export type RouteHandler = (params: RouteParams) => unknown; export type RouteGuard = () => boolean | string | Promise; /** * Marks a string as trusted raw HTML for a route handler to return. The router * writes a plain string result as TEXT; wrap it in `rawHtml(...)` only when the * markup is trusted (not built from user input). This is the explicit, named * opt-in that replaces the old implicit innerHTML of every string result. */ export declare class RawHtml { readonly html: string; constructor(html: string); } export declare function rawHtml(html: string): RawHtml; export interface RouteConfig { guard?: RouteGuard; handler: RouteHandler; } interface RouterConfig { target: string; mode?: 'history' | 'hash'; } export type ChangeEvent = { path: string; params: RouteParams; pattern: string; durationMs: number; }; type ChangeListener = (event: ChangeEvent) => void; /** * Register a route. Pattern is ALWAYS the first argument. * * Patterns support `{param}` segments — extracted and passed to the handler. * Use `'*'` to match any path (catch-all / 404 route). * * @param pattern - URL pattern, e.g. `'/'`, `'/users/{id}'`, `'*'` * @param handlerOrConfig - Handler function or `{ handler, guard }` config. * * @example * route('/', () => html`

Home

`); * route('/users/{id}', ({ id }) => html`

User: ${id}

`); * route('*', () => html`

404

`); * * // With a guard: * route('/admin', { * guard: () => isLoggedIn.value || '/login', * handler: () => html``, * }); */ export declare function route(pattern: string, handlerOrConfig: RouteHandler | RouteConfig): void; /** * Programmatically navigate to a path. * * @param path - The path to navigate to. * @param opts - `{ replace: true }` uses `history.replaceState` instead of `pushState`. * * @example * navigate('/dashboard'); * navigate('/login', { replace: true }); // no back-button entry */ export declare function navigate(path: string, opts?: { replace?: boolean; }): void; export declare const router: { start(config: RouterConfig): void; on(event: "change", fn: ChangeListener): () => void; }; /** @internal Read-only access to registered routes (for debug overlay). */ export declare function _getRoutes(): ReadonlyArray<{ pattern: string; hasGuard: boolean; }>; /** @internal Reset router state (for tests only). */ export declare function _resetRouter(): void; export {}; //# sourceMappingURL=router.d.ts.map