UNPKG

@joist/router

Version:
30 lines (29 loc) 957 B
import { State } from '@joist/component'; import { Path, MatchResult } from 'path-to-regexp'; export interface Route { path: Path; component: () => HTMLElement | CustomElementConstructor | Promise<HTMLElement | CustomElementConstructor>; } export declare class RouteCtx extends State<MatchResult<any>> { } export declare function normalize(path: Path): string; export declare function match(path: Path): import("path-to-regexp").MatchFunction<object>; export declare class Location { getPath(): string; goTo(path: string): void; onPopState(cb: Function): () => void; } export declare class RouterConfig { root: string; navigateEventName: string; } export declare class Router { private location; private config; detach: () => void; constructor(location: Location, config: RouterConfig); getFragment(): string; navigate(path: string): void; listen(cb: () => unknown): () => void; private notify; }