-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathindex.d.ts
112 lines (111 loc) · 3.35 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
export type Route = {
name: string;
path: string | RegExp;
handler: Handler;
hooks: RouteHooksStorage;
};
export type Handler = (match?: Match) => void;
export type Match = {
url: string;
queryString: string;
hashString: string;
route: Route;
data: { [key: string]: string } | null;
params: { [key: string]: string } | null;
};
export type BeforeHook = (done: Function, match: Match) => void;
export type AfterHook = (match: Match) => void;
export type LeaveHook = (done: Function, match: Match | Match[]) => void;
export type AlreadyHook = (match: Match) => void;
export type RouteHooks = {
before?: BeforeHook;
after?: AfterHook;
leave?: LeaveHook;
already?: AlreadyHook;
};
export type RouteHooksStorage = {
before?: BeforeHook[];
after?: AfterHook[];
leave?: LeaveHook[];
already?: AlreadyHook[];
};
export type NavigateOptions = {
title?: string;
stateObj?: Object;
historyAPIMethod?: string;
updateBrowserURL?: boolean;
callHandler?: boolean;
callHooks?: boolean;
updateState?: boolean;
force?: boolean;
resolveOptions?: ResolveOptions;
};
export type ResolveStrategy = "ONE" | "ALL";
export type ResolveOptions = {
strategy?: ResolveStrategy;
hash?: boolean;
noMatchWarning?: boolean;
};
export type QContext = {
currentLocationPath: string;
to: string;
instance: Navigo;
matches?: Match[];
match?: Match;
navigateOptions?: NavigateOptions;
resolveOptions?: ResolveOptions;
notFoundHandled?: boolean;
};
export type GenerateOptions = {
includeRoot: boolean;
};
export type RouterOptions = ResolveOptions & { linksSelector?: string };
declare class Navigo {
constructor(root: string, options?: RouterOptions);
root: string;
routes: Route[];
destroyed: boolean;
current: null | Match[];
lastResolved(): null | Match[];
on(f: Handler, hooks?: RouteHooks): Navigo;
on(map: Object, hooks?: RouteHooks): Navigo;
on(path: string | RegExp, f: Handler, hooks?: RouteHooks): Navigo;
off(path: string | RegExp): Navigo;
off(handler: Function): Navigo;
navigate(to: string, options?: NavigateOptions): void;
navigateByName(
name: string,
data?: Object,
options?: NavigateOptions
): boolean;
resolve(path?: string, resolveOptions?: ResolveOptions): false | Match;
destroy(): void;
notFound(handler: Function, hooks?: RouteHooks): Navigo;
updatePageLinks(): Navigo;
link(path: string): string;
generate(name: string, data?: Object, options?: GenerateOptions): string;
hooks(hooks: RouteHooks): Navigo;
getLinkPath(link: Object): string;
match(path: string): false | Match[];
matchLocation(
path: string | RegExp,
currentLocation?: string,
annotatePathWithRoot?: boolean
): false | Match;
getCurrentLocation(): Match;
addBeforeHook(route: Route | string, hookFunction: Function): Function;
addAfterHook(route: Route | string, hookFunction: Function): Function;
addAlreadyHook(route: Route | string, hookFunction: Function): Function;
addLeaveHook(route: Route | string, hookFunction: Function): Function;
getRoute(nameOrHandler: string | Function): Route | undefined;
_pathToMatchObject(path: string): Match;
_clean(path: string): string;
_setCurrent(current: Match[]): void;
_checkForAHash(path: string): string;
_notFoundRoute: Route;
__freezeListening: boolean;
__dirty: boolean;
__waiting: Function[];
__markAsClean: Function;
}
export default Navigo;