-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.d.ts
108 lines (98 loc) · 2.26 KB
/
types.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
import Router from './index';
export type ObjectLike<T extends any> = Record<string, T>;
export interface Component {
new(...args: any[]): Component;
[key: string]: any;
}
export interface RouteTransition {
to: RouteInstance;
from?: RouteInstance;
}
export interface Hooks {
already?(route: RouteInstance): void;
after?(transition: RouteTransition): void;
leave?(transition: RouteTransition): void;
before?(transition: RouteTransition, next: () => void): void;
}
export interface Route {
name?: string;
hooks?: Hooks;
view?: string;
children?: Route[];
component: Component;
path?: string | RegExp;
state?: ObjectLike<any>;
attrs?: ObjectLike<any>;
}
export interface InternalRoute extends Route {
_path: string;
_params: string[];
_hasNext?: boolean;
_parent?: Component;
_instance?: Component;
_root?: InternalRoute;
_route?: RouteInstance;
_component(route: RouteInstance, next?: (error: Error | string) => void): void;
}
export interface RouterOptions {
hash?: string;
root?: string;
routes: Route[];
ignoreCase?: boolean;
mode?: 'hash' | 'history';
}
export interface NavigateParam {
name: string;
query?: ObjectLike<string>;
params?: ObjectLike<string>;
}
export interface RouteInstance {
/**
* The router instance
*/
router: Router;
/**
* The name of route
*/
name: string | null;
/**
* The url of route
*/
path: string | null;
/**
* State object
*/
state: ObjectLike<any>;
/**
* Params object
*/
params: ObjectLike<string>;
/**
* Query object
*/
query: ObjectLike<string>;
/**
* Return value passed using, in order params, query and default_value if provided
* @param {string} key Key of the value to retrieve
* @param {any} defaultValue Default value if nothing found. Default to nothing
* @return {string}
*/
get(key: string, defaultValue?: any): string;
/**
* Navigate to the given path
* @param {string|object} path
*/
go(path: string | number | NavigateParam): void;
/**
* Navigate to previous path
*/
back(): void;
/**
* Navigate to next path
*/
forward(): void;
}
declare module "*.esm" {
const moduleValue: Component;
export default moduleValue;
}