-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.d.ts
122 lines (108 loc) · 2.96 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
113
114
115
116
117
118
119
120
121
122
interface TinroRoute {
url: string
from: string
path: string
query: Record<string, string>
hash: string
}
interface TinroBreadcrumb {
path: string
name: string
}
interface TinroRouteMeta {
url: string
from?: string
match: string
pattern: string
breadcrumbs?: Array<TinroBreadcrumb>
query: Record<string, string>
params: Record<string, string>
subscribe(handler: (meta: TinroRouteMeta) => void)
}
interface TinroRouterModeSwitcher {
/** Set HistoryAPI navigation method */
history(): ()=>void
/** Set hash navigation method */
hash(): ()=>void
/** Set memory navigation method */
memory(): ()=>void
}
interface TinroRouterLocationHash {
/** Get current hash value*/
get(): string
/** Set current hash value*/
set(value:string): void
/** Clear current hash value*/
clear(): void
}
interface TinroRouterLocationQuery {
/** Get the query object or a value from it by property name */
get(name?:string): Record<string, string>|string
/** Update or add a property in the query object */
set(name:string,value:string|number): void
/** Delete a property from the query object */
delete(name:string): void
/** Replace value of the query object */
replace(value: Record<string, string>): void
/** Clear the query object */
clear(): void
}
interface TinroRouterLocation {
hash: TinroRouterLocationHash
query: TinroRouterLocationQuery
}
declare interface TinroRouter {
/** Point browser to the URL */
goto(url: string, replace?: boolean): void
/** Get current route object on URL change */
subscribe(handler: (currentRoute: TinroRoute) => void)
/** Switch navigatin method */
mode: TinroRouterModeSwitcher
/** Location object methods */
location: TinroRouterLocation
/** Set base path for URL */
base(path: string): void
/** @deprecated Use meta().params instead */
params(): Record<string, string>
/** @deprecated Use router.mode.hash() instead*/
useHashNavigation(use?: boolean): void
/** @deprecated Import `meta` from `tinro` package directly */
meta(): TinroRouteMeta
}
export const active: any
export function meta(): TinroRouteMeta
export const router: TinroRouter
export class Route {
$$prop_def: {
/**
* Exact o relative path of the route
* @default "/*"
*/
path?: string;
/**
* Is route fallback
* @default false
*/
fallback?: boolean;
/**
* Redirect route to the specified path
*/
redirect?: string;
/**
* Will be show only first matched with URL nested route
* @default false
*/
firstmatch?: boolean;
/**
* Name of the route to use in breadcrumbs
* @default null
*/
breadcrumb?: string;
};
$$slot_def: { default: {
/** Current meta for the route */
meta: TinroRouteMeta
/** @deprecated Use meta.params instead */
params: Record<string, string>
} };
}