@kitbag/router 0.20.8 → 0.20.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.d.ts +13 -150
- package/dist/services/createRouterAssets.d.ts +1 -2
- package/package.json +2 -2
package/dist/main.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { withParams } from './services/withParams';
|
|
2
|
+
import { RouterAssets } from './services/createRouterAssets';
|
|
3
|
+
import { RegisteredRouter } from './types/register';
|
|
2
4
|
export * from './types/createRouteOptions';
|
|
3
5
|
export * from './types/hooks';
|
|
4
6
|
export * from './types/paramTypes';
|
|
@@ -59,7 +61,7 @@ export declare const query: typeof withParams;
|
|
|
59
61
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
60
62
|
* @group Hooks
|
|
61
63
|
*/
|
|
62
|
-
export declare const onBeforeRouteLeave:
|
|
64
|
+
export declare const onBeforeRouteLeave: RouterAssets<RegisteredRouter>['onBeforeRouteLeave'];
|
|
63
65
|
/**
|
|
64
66
|
* Registers a hook that is called before a route is updated. Must be called from setup.
|
|
65
67
|
* This is particularly useful for handling changes in route parameters or query while staying within the same component.
|
|
@@ -68,7 +70,7 @@ export declare const onBeforeRouteLeave: import('./main').AddRouterBeforeRouteHo
|
|
|
68
70
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
69
71
|
* @group Hooks
|
|
70
72
|
*/
|
|
71
|
-
export declare const onBeforeRouteUpdate:
|
|
73
|
+
export declare const onBeforeRouteUpdate: RouterAssets<RegisteredRouter>['onBeforeRouteUpdate'];
|
|
72
74
|
/**
|
|
73
75
|
* Registers a hook that is called after a route has been left. Must be called during setup.
|
|
74
76
|
* This can be used for cleanup actions after the component is no longer active, ensuring proper resource management.
|
|
@@ -77,7 +79,7 @@ export declare const onBeforeRouteUpdate: import('./main').AddRouterBeforeRouteH
|
|
|
77
79
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
78
80
|
* @group Hooks
|
|
79
81
|
*/
|
|
80
|
-
export declare const onAfterRouteLeave:
|
|
82
|
+
export declare const onAfterRouteLeave: RouterAssets<RegisteredRouter>['onAfterRouteLeave'];
|
|
81
83
|
/**
|
|
82
84
|
* Registers a hook that is called after a route has been updated. Must be called during setup.
|
|
83
85
|
* This is ideal for responding to updates within the same route, such as parameter changes, without full component reloads.
|
|
@@ -86,7 +88,7 @@ export declare const onAfterRouteLeave: import('./main').AddRouterAfterRouteHook
|
|
|
86
88
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
87
89
|
* @group Hooks
|
|
88
90
|
*/
|
|
89
|
-
export declare const onAfterRouteUpdate:
|
|
91
|
+
export declare const onAfterRouteUpdate: RouterAssets<RegisteredRouter>['onAfterRouteUpdate'];
|
|
90
92
|
/**
|
|
91
93
|
* A guard to verify if a route or unknown value matches a given route name.
|
|
92
94
|
*
|
|
@@ -94,44 +96,7 @@ export declare const onAfterRouteUpdate: import('./main').AddRouterAfterRouteHoo
|
|
|
94
96
|
* @returns True if the current route matches the given route name, false otherwise.
|
|
95
97
|
* @group Type Guards
|
|
96
98
|
*/
|
|
97
|
-
export declare const isRoute:
|
|
98
|
-
(route: unknown): route is import('./main').RouterRoute;
|
|
99
|
-
<TRoute extends import('./main').RouterRoute<Readonly<{
|
|
100
|
-
id: any;
|
|
101
|
-
matched: any;
|
|
102
|
-
matches: any;
|
|
103
|
-
name: any;
|
|
104
|
-
query: URLSearchParams;
|
|
105
|
-
hash: string;
|
|
106
|
-
params: {
|
|
107
|
-
[x: string]: unknown;
|
|
108
|
-
[x: number]: unknown;
|
|
109
|
-
[x: symbol]: unknown;
|
|
110
|
-
};
|
|
111
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<any>;
|
|
112
|
-
href: import('./main').Url;
|
|
113
|
-
}>>, TRouteName extends any>(route: TRoute, routeName: TRouteName, options: import('./guards/routes').IsRouteOptions & {
|
|
114
|
-
exact: true;
|
|
115
|
-
}): route is TRoute & {
|
|
116
|
-
name: TRouteName;
|
|
117
|
-
};
|
|
118
|
-
<TRoute extends import('./main').RouterRoute<Readonly<{
|
|
119
|
-
id: any;
|
|
120
|
-
matched: any;
|
|
121
|
-
matches: any;
|
|
122
|
-
name: any;
|
|
123
|
-
query: URLSearchParams;
|
|
124
|
-
hash: string;
|
|
125
|
-
params: {
|
|
126
|
-
[x: string]: unknown;
|
|
127
|
-
[x: number]: unknown;
|
|
128
|
-
[x: symbol]: unknown;
|
|
129
|
-
};
|
|
130
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<any>;
|
|
131
|
-
href: import('./main').Url;
|
|
132
|
-
}>>, TRouteName extends TRoute["name"]>(route: TRoute, routeName: TRouteName, options?: import('./guards/routes').IsRouteOptions): route is TRoute extends import('./main').RouterRoute ? TRouteName extends TRoute["matches"][number]["name"] ? TRoute : never : never;
|
|
133
|
-
(route: unknown, routeName?: string, options?: import('./guards/routes').IsRouteOptions): boolean;
|
|
134
|
-
};
|
|
99
|
+
export declare const isRoute: RouterAssets<RegisteredRouter>['isRoute'];
|
|
135
100
|
/**
|
|
136
101
|
* A component to render the current route's component.
|
|
137
102
|
*
|
|
@@ -139,17 +104,7 @@ export declare const isRoute: {
|
|
|
139
104
|
* @returns The router view component.
|
|
140
105
|
* @group Components
|
|
141
106
|
*/
|
|
142
|
-
export declare const RouterView:
|
|
143
|
-
default?: (props: {
|
|
144
|
-
route: import('./main').RouterRoute;
|
|
145
|
-
component: import('vue').Component;
|
|
146
|
-
rejection: import('vue').UnwrapRef<import('./services/createRouterReject').RouterRejection>;
|
|
147
|
-
}) => import('vue').VNode;
|
|
148
|
-
}>, import('./components/routerView').RouterViewProps & ({
|
|
149
|
-
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
150
|
-
} | {
|
|
151
|
-
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
|
152
|
-
}), import('vue').PublicProps>;
|
|
107
|
+
export declare const RouterView: RouterAssets<RegisteredRouter>['RouterView'];
|
|
153
108
|
/**
|
|
154
109
|
* A component to render a link to a route or any url.
|
|
155
110
|
*
|
|
@@ -157,35 +112,7 @@ export declare const RouterView: import('vue').DefineSetupFnComponent<import('./
|
|
|
157
112
|
* @returns The router link component.
|
|
158
113
|
* @group Components
|
|
159
114
|
*/
|
|
160
|
-
export declare const RouterLink:
|
|
161
|
-
default?: (props: {
|
|
162
|
-
route: import('./main').ResolvedRoute | undefined;
|
|
163
|
-
isMatch: boolean;
|
|
164
|
-
isExactMatch: boolean;
|
|
165
|
-
isActive: boolean;
|
|
166
|
-
isExactActive: boolean;
|
|
167
|
-
isExternal: boolean;
|
|
168
|
-
}) => import('vue').VNode[];
|
|
169
|
-
}>, import('./main').RouterPushOptions & ({
|
|
170
|
-
to: import('./main').Url | Readonly<{
|
|
171
|
-
id: string;
|
|
172
|
-
matched: import('./main').CreatedRouteOptions;
|
|
173
|
-
matches: import('./main').CreatedRouteOptions[];
|
|
174
|
-
name: string;
|
|
175
|
-
query: URLSearchParams;
|
|
176
|
-
hash: string;
|
|
177
|
-
params: {
|
|
178
|
-
[x: string]: unknown;
|
|
179
|
-
};
|
|
180
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<Record<string, import('./main').Param>>;
|
|
181
|
-
href: import('./main').Url;
|
|
182
|
-
}> | import('./main').ToCallback<import('./main').Router>;
|
|
183
|
-
prefetch?: import('./main').PrefetchConfig;
|
|
184
|
-
} & ({
|
|
185
|
-
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
186
|
-
} | {
|
|
187
|
-
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
|
188
|
-
})), import('vue').PublicProps>;
|
|
115
|
+
export declare const RouterLink: RouterAssets<RegisteredRouter>['RouterLink'];
|
|
189
116
|
/**
|
|
190
117
|
* A composition to access the current route or verify a specific route name within a Vue component.
|
|
191
118
|
* This function provides two overloads:
|
|
@@ -201,59 +128,7 @@ export declare const RouterLink: import('vue').DefineSetupFnComponent<import('./
|
|
|
201
128
|
* @throws {UseRouteInvalidError} Throws an error if the provided route name is not valid or does not match the current route.
|
|
202
129
|
* @group Compositions
|
|
203
130
|
*/
|
|
204
|
-
export declare const useRoute:
|
|
205
|
-
(): import('./main').RouterRoute<Readonly<{
|
|
206
|
-
id: any;
|
|
207
|
-
matched: any;
|
|
208
|
-
matches: any;
|
|
209
|
-
name: any;
|
|
210
|
-
query: URLSearchParams;
|
|
211
|
-
hash: string;
|
|
212
|
-
params: {
|
|
213
|
-
[x: string]: unknown;
|
|
214
|
-
[x: number]: unknown;
|
|
215
|
-
[x: symbol]: unknown;
|
|
216
|
-
};
|
|
217
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<any>;
|
|
218
|
-
href: import('./main').Url;
|
|
219
|
-
}>>;
|
|
220
|
-
<TRouteName extends any>(routeName: TRouteName, options: import('./guards/routes').IsRouteOptions & {
|
|
221
|
-
exact: true;
|
|
222
|
-
}): import('./main').RouterRoute<Readonly<{
|
|
223
|
-
id: any;
|
|
224
|
-
matched: any;
|
|
225
|
-
matches: any;
|
|
226
|
-
name: any;
|
|
227
|
-
query: URLSearchParams;
|
|
228
|
-
hash: string;
|
|
229
|
-
params: {
|
|
230
|
-
[x: string]: unknown;
|
|
231
|
-
[x: number]: unknown;
|
|
232
|
-
[x: symbol]: unknown;
|
|
233
|
-
};
|
|
234
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<any>;
|
|
235
|
-
href: import('./main').Url;
|
|
236
|
-
}>> & {
|
|
237
|
-
name: TRouteName;
|
|
238
|
-
};
|
|
239
|
-
<TRouteName extends any>(routeName: TRouteName, options?: import('./guards/routes').IsRouteOptions): import('./main').RouterRoute<Readonly<{
|
|
240
|
-
id: any;
|
|
241
|
-
matched: any;
|
|
242
|
-
matches: any;
|
|
243
|
-
name: any;
|
|
244
|
-
query: URLSearchParams;
|
|
245
|
-
hash: string;
|
|
246
|
-
params: {
|
|
247
|
-
[x: string]: unknown;
|
|
248
|
-
[x: number]: unknown;
|
|
249
|
-
[x: symbol]: unknown;
|
|
250
|
-
};
|
|
251
|
-
state: import('./types/state').ExtractRouteStateParamsAsOptional<any>;
|
|
252
|
-
href: import('./main').Url;
|
|
253
|
-
}>> & {
|
|
254
|
-
name: `${TRouteName}${string}`;
|
|
255
|
-
};
|
|
256
|
-
};
|
|
131
|
+
export declare const useRoute: RouterAssets<RegisteredRouter>['useRoute'];
|
|
257
132
|
/**
|
|
258
133
|
* A composition to access the installed router instance within a Vue component.
|
|
259
134
|
*
|
|
@@ -262,17 +137,14 @@ export declare const useRoute: {
|
|
|
262
137
|
* ensuring the component does not operate without routing functionality.
|
|
263
138
|
* @group Compositions
|
|
264
139
|
*/
|
|
265
|
-
export declare const useRouter:
|
|
140
|
+
export declare const useRouter: RouterAssets<RegisteredRouter>['useRouter'];
|
|
266
141
|
/**
|
|
267
142
|
* A composition to access a specific query value from the current route.
|
|
268
143
|
*
|
|
269
144
|
* @returns The query value from the router.
|
|
270
145
|
* @group Compositions
|
|
271
146
|
*/
|
|
272
|
-
export declare const useQueryValue:
|
|
273
|
-
(key: import('vue').MaybeRefOrGetter<string>): import('./compositions/useQueryValue').UseQueryValue<string>;
|
|
274
|
-
<TParam extends import('./main').Param>(key: import('vue').MaybeRefOrGetter<string>, param: TParam): import('./compositions/useQueryValue').UseQueryValue<import('./types/params').ExtractParamType<TParam>>;
|
|
275
|
-
};
|
|
147
|
+
export declare const useQueryValue: RouterAssets<RegisteredRouter>['useQueryValue'];
|
|
276
148
|
/**
|
|
277
149
|
* A composition to export much of the functionality that drives RouterLink component.
|
|
278
150
|
* Also exports some useful context about routes relationship to current URL and convenience methods
|
|
@@ -284,16 +156,7 @@ export declare const useQueryValue: {
|
|
|
284
156
|
* @returns {UseLink} Reactive context values for as well as navigation methods.
|
|
285
157
|
* @group Compositions
|
|
286
158
|
*/
|
|
287
|
-
export declare const useLink:
|
|
288
|
-
<TRouteKey extends any>(name: import('vue').MaybeRefOrGetter<TRouteKey>, params?: import('vue').MaybeRefOrGetter<Record<string, unknown> | {
|
|
289
|
-
[x: string]: unknown;
|
|
290
|
-
[x: number]: unknown;
|
|
291
|
-
[x: symbol]: unknown;
|
|
292
|
-
}> | undefined, options?: import('vue').MaybeRefOrGetter<import('./main').UseLinkOptions> | undefined): import('./main').UseLink;
|
|
293
|
-
(url: import('vue').MaybeRefOrGetter<import('./main').Url>, options?: import('vue').MaybeRefOrGetter<import('./main').UseLinkOptions>): import('./main').UseLink;
|
|
294
|
-
(resolvedRoute: import('vue').MaybeRefOrGetter<import('./main').ResolvedRoute | undefined>, options?: import('vue').MaybeRefOrGetter<import('./main').UseLinkOptions>): import('./main').UseLink;
|
|
295
|
-
(source: import('vue').MaybeRefOrGetter<string | import('./main').ResolvedRoute | undefined>, paramsOrOptions?: import('vue').MaybeRefOrGetter<Record<PropertyKey, unknown> | import('./main').UseLinkOptions>, maybeOptions?: import('vue').MaybeRefOrGetter<import('./main').UseLinkOptions>): import('./main').UseLink;
|
|
296
|
-
};
|
|
159
|
+
export declare const useLink: RouterAssets<RegisteredRouter>['useLink'];
|
|
297
160
|
declare module 'vue' {
|
|
298
161
|
interface GlobalComponents {
|
|
299
162
|
RouterView: typeof RouterView;
|
|
@@ -7,7 +7,7 @@ import { createUseRouter } from '../compositions/useRouter';
|
|
|
7
7
|
import { createUseQueryValue } from '../compositions/useQueryValue';
|
|
8
8
|
import { createUseLink } from '../compositions/useLink';
|
|
9
9
|
import { createIsRoute } from '../guards/routes';
|
|
10
|
-
type RouterAssets<TRouter extends Router> = {
|
|
10
|
+
export type RouterAssets<TRouter extends Router> = {
|
|
11
11
|
/**
|
|
12
12
|
* Registers a hook that is called before a route is left. Must be called from setup.
|
|
13
13
|
* This is useful for performing actions or cleanups before navigating away from a route component.
|
|
@@ -115,4 +115,3 @@ type RouterAssets<TRouter extends Router> = {
|
|
|
115
115
|
};
|
|
116
116
|
export declare function createRouterAssets<TRouter extends Router>(router: TRouter): RouterAssets<TRouter>;
|
|
117
117
|
export declare function createRouterAssets<TRouter extends Router>(routerKey: InjectionKey<TRouter>): RouterAssets<TRouter>;
|
|
118
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitbag/router",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.20.
|
|
4
|
+
"version": "0.20.9",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/kitbagjs/router/issues"
|
|
7
7
|
},
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "vite build",
|
|
19
19
|
"build:watch": "vite build --watch --minify=false",
|
|
20
|
-
"test": "vitest
|
|
20
|
+
"test": "vitest",
|
|
21
21
|
"lint": "eslint ./src",
|
|
22
22
|
"lint:fix": "eslint ./src --fix",
|
|
23
23
|
"types": "vue-tsc --noEmit",
|