UNPKG

@sgpinkus/my-vue-router

Version:
54 lines (53 loc) 1.78 kB
import { InjectionKey } from 'vue'; import { App } from '@vue/runtime-core'; import { match, compile } from 'path-to-regexp'; import { Route } from './types'; export type { Route, ComponentRoute, RedirectRoute } from './types'; export declare const RouterInjectionKey: InjectionKey<Router>; type CompiledRoute = Route & { _match: ReturnType<typeof match>; _compile: ReturnType<typeof compile>; _id: number; }; type RouterOptions = { installGlobalRef?: false | string; routeProp?: boolean; paramsToProps?: boolean; basePath?: string; }; export declare let router: Router | null; export declare function createRouter(routes: Route[], options?: RouterOptions): Router; export declare function getRouter(): Router; export declare class Router { currentRoute: import('vue').ShallowRef<CompiledRoute>; currentPath: import('vue').Ref<string, string>; currentRouteParams: import('vue').Ref<{}, {}>; routes: CompiledRoute[]; options: RouterOptions; constructor(routes: Route[], options?: RouterOptions); matchPath(path: string): { route: CompiledRoute | undefined; params: Record<string, any>; }; matchName(name: string, params?: Record<string, any>): { route: CompiledRoute | undefined; path: string; }; private setPath; private setName; currentRouteProp(): { params: {}; }; isActiveRoute(route: CompiledRoute): boolean; isCurrentPath(path: string): boolean; rebasePath(path: string): string; unBasePath(path: string): string; install(app: App): void; historyPopState(event: PopStateEvent): void; dispatch(target: { name: string; params?: Record<string, any>; } | { path: string; }): boolean | undefined; }