@tinijs/router
Version:
The router module for the TiniJS framework.
37 lines (36 loc) • 1.49 kB
TypeScript
import type { Route, RouterOptions, FragmentManager, FragmentActivationOptions, FragmentItem, MatchResult, ActivatedRoute } from './types.js';
export declare class Router {
readonly routes: Route[];
readonly options: RouterOptions;
private readonly NOT_FOUND_PATH;
private readonly registry;
private readonly cache;
private callback?;
indicatorSchedule: number | null;
fragmentManager: FragmentManager | null;
constructor(routes: Route[], options?: RouterOptions);
init(): Router;
setCallback(cb: (result: MatchResult) => void): Router;
renewFragments(container: HTMLElement, activation?: false | FragmentActivationOptions): Router;
retrieveFragments(symbolOrExtractor?: string | ((element: HTMLElement) => string)): FragmentItem[];
setState(key: string, state: string): Router;
getState(key: string): string | null;
go(to: string, replace?: boolean): boolean;
goFragment(to: string, options?: Omit<FragmentActivationOptions, 'delay'>): boolean;
redirect(to: string): boolean;
back(): boolean;
forward(): boolean;
requestChange(): boolean;
getActiveRoute(): ActivatedRoute;
getParams(): Record<string, any>;
getQuery(): Record<string, any>;
getFragment(): string;
match(url: URL): MatchResult;
private extractParams;
private registerOutlet;
private registerTriggers;
private onRouteChanges;
private getAnchorOrigin;
private decodeParam;
private buildRegistry;
}