@kitbag/router 0.2.0 → 0.4.0

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/README.md CHANGED
@@ -2,14 +2,18 @@
2
2
 
3
3
  Type safe router for Vue.js
4
4
 
5
- [![Npm Version](https://img.shields.io/npm/v/@kitbag/router.svg)](https://www.npmjs.org/package/@kitbag/router)
6
- [![Netlify Status](https://api.netlify.com/api/v1/badges/c12f79b8-49f9-4529-bc23-f8ffca8919a3/deploy-status)](https://app.netlify.com/sites/kitbag-router/deploys)
5
+ [![NPM Version][npm-badge]][npm-url]
6
+ [![Netlify Status][netlify-badge]][netlify-url]
7
+ [![Discord chat][discord-badge]][discord-url]
8
+ [![Open in StackBlitz][stackblitz-badge]][stackblitz-url]
7
9
 
8
- Get started with the [documentation](https://kitbag-router.netlify.app/)
10
+ <img src="https://kitbag.dev/kitbag-logo.svg" width="20%" />
9
11
 
10
- ## Installation
12
+ ## Getting Started
13
+
14
+ Get Started with our [documentation](https://kitbag-router.netlify.app/)
11
15
 
12
- Install Kitbag Router with your favorite package manager
16
+ ## Installation
13
17
 
14
18
  ```bash
15
19
  # bun
@@ -152,3 +156,12 @@ Use RouterLink for navigating between routes.
152
156
  ```
153
157
 
154
158
  This component gives the router the power to change the URL without reloading the page.
159
+
160
+ [npm-badge]: https://img.shields.io/npm/v/@kitbag/router.svg
161
+ [npm-url]: https://www.npmjs.org/package/@kitbag/router
162
+ [netlify-badge]: https://api.netlify.com/api/v1/badges/c12f79b8-49f9-4529-bc23-f8ffca8919a3/deploy-status
163
+ [netlify-url]: https://app.netlify.com/sites/kitbag-router/deploys
164
+ [discord-badge]: https://img.shields.io/discord/1079625926024900739?logo=discord&label=Discord
165
+ [discord-url]: https://discord.gg/UT7JrAxU
166
+ [stackblitz-badge]: https://developer.stackblitz.com/img/open_in_stackblitz_small.svg
167
+ [stackblitz-url]: https://stackblitz.com/~/github.com/kitbagjs/router-preview
@@ -6,13 +6,19 @@ import { DefineComponent } from 'vue';
6
6
  import { ExtractPropTypes } from 'vue';
7
7
  import { FunctionalComponent } from 'vue';
8
8
  import { InjectionKey } from 'vue';
9
+ import { MaybeRefOrGetter } from 'vue';
9
10
  import { Plugin as Plugin_2 } from 'vue';
10
11
  import { PropType } from 'vue';
11
12
  import { PublicProps } from 'vue';
12
13
  import { Ref } from 'vue';
14
+ import { RendererElement } from 'vue';
15
+ import { RendererNode } from 'vue';
16
+ import { VNode } from 'vue';
13
17
 
14
18
  declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
19
 
20
+ declare type __VLS_NonUndefinedable_2<T> = T extends undefined ? never : T;
21
+
16
22
  declare type __VLS_TypePropsToRuntimeProps<T> = {
17
23
  [K in keyof T]-?: {} extends Pick<T, K> ? {
18
24
  type: PropType<__VLS_NonUndefinedable<T[K]>>;
@@ -22,6 +28,15 @@ declare type __VLS_TypePropsToRuntimeProps<T> = {
22
28
  };
23
29
  };
24
30
 
31
+ declare type __VLS_TypePropsToRuntimeProps_2<T> = {
32
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
33
+ type: PropType<__VLS_NonUndefinedable_2<T[K]>>;
34
+ } : {
35
+ type: PropType<T[K]>;
36
+ required: true;
37
+ };
38
+ };
39
+
25
40
  declare type __VLS_WithTemplateSlots<T, S> = T & {
26
41
  new (): {
27
42
  $slots: S;
@@ -128,7 +143,7 @@ declare type BuiltInRejectionType = typeof builtInRejections[number];
128
143
  /**
129
144
  * Represents properties for child routes, including required component, name, and path.
130
145
  */
131
- export declare type ChildRouteProps = WithHooks & {
146
+ export declare type ChildRouteProps = (WithComponent | WithComponents) & WithHooks & {
132
147
  /**
133
148
  * Name for route, used to create route keys and in navigation.
134
149
  */
@@ -145,10 +160,6 @@ export declare type ChildRouteProps = WithHooks & {
145
160
  * Query (aka search) part of URL.
146
161
  */
147
162
  query?: string | Query;
148
- /**
149
- * A Vue component, which can be either synchronous or asynchronous components.
150
- */
151
- component: Component;
152
163
  /**
153
164
  * Represents additional metadata associated with a route, customizable via declaration merging.
154
165
  */
@@ -259,27 +270,34 @@ declare type ExtractParamsFromPathString<TPath extends string, TParams extends R
259
270
 
260
271
  /**
261
272
  * Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
273
+ * This type also is responsible for narrowing possibly undefined values when the param has a default value.
262
274
  * @template TParam - The parameter type.
263
275
  * @returns The extracted type, or 'string' as a fallback.
264
276
  */
265
- export declare type ExtractParamType<TParam extends Param | undefined> = TParam extends ParamGetSet<infer Type> ? undefined extends TParam ? Type | undefined : Type : TParam extends ParamGetter ? undefined extends TParam ? ReturnType<TParam> | undefined : ReturnType<TParam> : undefined extends TParam ? undefined : string;
277
+ export declare type ExtractParamType<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? TParam extends IsOptionalParam ? TParam extends ParamWithDefault ? Type : Type | undefined : Type : TParam extends ParamGetter ? ReturnType<TParam> : string;
266
278
 
267
279
  /**
268
280
  * Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
269
281
  * @template TParams - The record of parameter types, possibly including undefined.
270
282
  * @returns A new type with the appropriate properties marked as optional.
271
283
  */
272
- export declare type ExtractParamTypes<TParams extends Record<string, Param | undefined>> = Identity<MakeOptional<{
284
+ export declare type ExtractParamTypes<TParams extends Record<string, Param>> = Identity<MakeOptional<{
273
285
  [K in keyof TParams]: ExtractParamType<TParams[K]>;
274
286
  }>>;
275
287
 
288
+ declare type ExtractParamTypesWithoutLosingOptional<TParams extends Record<string, Param>> = Identity<MakeOptional<{
289
+ [K in keyof TParams]: ExtractParamTypeWithoutLosingOptional<TParams[K]>;
290
+ }>>;
291
+
292
+ declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? TParam extends IsOptionalParam ? Type | undefined : Type : TParam extends ParamGetter ? ReturnType<TParam> : string;
293
+
276
294
  /**
277
295
  * Determines the type of a path parameter from a record of parameter types, considering optional parameters.
278
296
  * @template TParam - The parameter name string.
279
297
  * @template TParams - The record object mapping parameter names to their types.
280
298
  * @returns The type associated with the parameter, or StringConstructor if unspecified; may be undefined for optional parameters.
281
299
  */
282
- export declare type ExtractPathParamType<TParam extends string, TParams extends Record<string, Param | undefined>> = TParam extends `?${infer OptionalParam}` ? OptionalParam extends keyof TParams ? TParams[OptionalParam] | undefined : StringConstructor | undefined : TParam extends keyof TParams ? TParams[TParam] : StringConstructor;
300
+ export declare type ExtractPathParamType<TParam extends string, TParams extends Record<string, Param | undefined>> = TParam extends `?${infer OptionalParam}` ? OptionalParam extends keyof TParams ? TParams[OptionalParam] extends Param ? OptionalParamGetSet<TParams[OptionalParam]> : OptionalParamGetSet<StringConstructor> : OptionalParamGetSet<StringConstructor> : TParam extends keyof TParams ? TParams[TParam] : StringConstructor;
283
301
 
284
302
  declare type ExtractQueryParamsFromQueryString<TQuery extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TQuery extends `${string}=${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? MergeParams<{
285
303
  [P in ExtractParamName<Param>]: ExtractPathParamType<Param, TParams>;
@@ -289,24 +307,27 @@ declare type ExtractRouteChildren<TRoute extends RouteProps> = TRoute extends Pa
289
307
 
290
308
  /**
291
309
  * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
310
+ * This parameter object type represents the expected type when accessing params from router.route or useRoute.
292
311
  * @template TRoute - The route type from which to extract and merge parameter types.
293
312
  * @returns A record of parameter names to their respective types, extracted and merged from both path and query parameters.
294
313
  */
295
- export declare type ExtractRouteParamTypes<TRoute extends {
314
+ export declare type ExtractRouteParamTypes<TRoute> = TRoute extends {
296
315
  path: {
297
- params: Record<string, unknown>;
316
+ params: infer PathParams extends Record<string, Param>;
298
317
  };
299
318
  query: {
300
- params: Record<string, unknown>;
319
+ params: infer QueryParams extends Record<string, Param>;
301
320
  };
302
- }> = TRoute extends {
321
+ } ? ExtractParamTypes<MergeParams<PathParams, QueryParams>> : Record<string, unknown>;
322
+
323
+ declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extends {
303
324
  path: {
304
- params: infer PathParams extends Record<string, Param | undefined>;
325
+ params: infer PathParams extends Record<string, Param>;
305
326
  };
306
327
  query: {
307
- params: infer QueryParams extends Record<string, Param | undefined>;
328
+ params: infer QueryParams extends Record<string, Param>;
308
329
  };
309
- } ? ExtractParamTypes<MergeParams<PathParams, QueryParams>> : Record<string, unknown>;
330
+ } ? ExtractParamTypesWithoutLosingOptional<MergeParams<PathParams, QueryParams>> : Record<string, unknown>;
310
331
 
311
332
  declare type Flatten<T extends any[]> = T extends [infer First, ...infer Rest] ? First extends unknown[] ? Flatten<[...First, ...Flatten<Rest>]> : [First, ...Flatten<Rest>] : [];
312
333
 
@@ -329,6 +350,10 @@ declare type Identity<T> = T extends object ? {} & {
329
350
 
330
351
  declare type IsEmptyObject<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false;
331
352
 
353
+ declare type IsOptionalParam = {
354
+ [optionalParamKey]: true;
355
+ };
356
+
332
357
  /**
333
358
  * Type guard to check if a value conforms to the ParamGetSet type.
334
359
  * @param value - The value to check.
@@ -343,6 +368,8 @@ export declare function isParamGetSet(value: Param): value is ParamGetSet;
343
368
  */
344
369
  export declare function isParamGetter(value: Param): value is ParamGetter;
345
370
 
371
+ export declare function isParamWithDefault(param: Param): param is ParamWithDefault;
372
+
346
373
  /**
347
374
  * Type guard function to determine if a given route configuration is a parent route, based on the presence of children.
348
375
  * @param value - The route configuration to check.
@@ -350,6 +377,30 @@ export declare function isParamGetter(value: Param): value is ParamGetter;
350
377
  */
351
378
  export declare function isParentRoute(value: RouteProps): value is ParentRouteProps;
352
379
 
380
+ export declare function isParentRouteWithoutComponent(value: RouteProps): value is Omit<ParentRouteProps, 'component' | 'components'>;
381
+
382
+ export declare function isRoute(route: unknown): route is RouterRoute;
383
+
384
+ export declare function isRoute<TRouteKey extends RegisteredRoutesKey>(route: unknown, routeKey: TRouteKey, options?: IsRouteOptions): route is RouterRoute<ResolvedRoute<RegisteredRouteMap[TRouteKey]>>;
385
+
386
+ declare type IsRouteOptions = {
387
+ exact?: boolean;
388
+ };
389
+
390
+ declare const isRouterRouteSymbol: unique symbol;
391
+
392
+ export declare function isRouteWithComponent(value: RouteProps): value is RouteProps & WithComponent;
393
+
394
+ export declare function isRouteWithComponent(value: Readonly<RouteProps>): value is Readonly<RouteProps & WithComponent>;
395
+
396
+ export declare function isRouteWithComponent(value: DeepReadonly<RouteProps>): value is DeepReadonly<RouteProps & WithComponent>;
397
+
398
+ export declare function isRouteWithComponents(value: RouteProps): value is RouteProps & WithComponents;
399
+
400
+ export declare function isRouteWithComponents(value: Readonly<RouteProps>): value is Readonly<RouteProps & WithComponents>;
401
+
402
+ export declare function isRouteWithComponents(value: DeepReadonly<RouteProps>): value is DeepReadonly<RouteProps & WithComponents>;
403
+
353
404
  declare type MakeOptional<T> = {
354
405
  [P in WithOptionalProperties<T>]?: T[P];
355
406
  } & {
@@ -421,6 +472,10 @@ declare type OnlyRequiredProperties<T> = {
421
472
  [K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
422
473
  };
423
474
 
475
+ declare type OptionalParamGetSet<TParam extends Param> = TParam extends ParamGetSet ? TParam & IsOptionalParam : ParamGetSet<ExtractParamType<TParam>> & IsOptionalParam;
476
+
477
+ declare const optionalParamKey: unique symbol;
478
+
424
479
  export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON;
425
480
 
426
481
  export declare type ParamEnd = typeof paramEnd;
@@ -434,6 +489,7 @@ export declare type ParamExtras = {
434
489
  export declare type ParamGetSet<T = any> = {
435
490
  get: ParamGetter<T>;
436
491
  set: ParamSetter<T>;
492
+ defaultValue?: T;
437
493
  };
438
494
 
439
495
  export declare type ParamGetter<T = any> = (value: string, extras: ParamExtras) => T;
@@ -444,10 +500,12 @@ export declare type ParamStart = typeof paramStart;
444
500
 
445
501
  export declare const paramStart = "[";
446
502
 
503
+ export declare type ParamWithDefault<TParam extends Param = Param> = Required<ParamGetSet<ExtractParamType<TParam>>>;
504
+
447
505
  /**
448
506
  * Represents properties common to parent routes in a route configuration, including hooks, path, and optional query parameters.
449
507
  */
450
- export declare type ParentRouteProps = WithHooks & {
508
+ export declare type ParentRouteProps = Partial<WithComponent | WithComponents> & WithHooks & {
451
509
  /**
452
510
  * Name for route, used to create route keys and in navigation.
453
511
  */
@@ -468,19 +526,15 @@ export declare type ParentRouteProps = WithHooks & {
468
526
  * Children routes, expected type comes from `createRoutes()`
469
527
  */
470
528
  children: Routes;
471
- /**
472
- * A Vue component, which can be either synchronous or asynchronous components.
473
- */
474
- component?: Component;
475
529
  /**
476
530
  * Represents additional metadata associated with a route, customizable via declaration merging.
477
531
  */
478
532
  meta?: RouteMeta;
479
533
  };
480
534
 
481
- declare type Path<TPath extends string = any, TParams extends PathParams<TPath> = any> = {
535
+ declare type Path<TPath extends string = string, TParams extends PathParams<TPath> = Record<string, Param | undefined>> = {
482
536
  path: TPath;
483
- params: Identity<ExtractParamsFromPathString<TPath, TParams>>;
537
+ params: string extends TPath ? Record<string, Param> : Identity<ExtractParamsFromPathString<TPath, TParams>>;
484
538
  toString: () => string;
485
539
  };
486
540
 
@@ -517,9 +571,9 @@ declare type Props<TComponent extends Component> = TComponent extends Constructo
517
571
 
518
572
  declare type PropsGetter<TComponent extends Component> = () => MaybePromise<Props<TComponent>>;
519
573
 
520
- declare type Query<T extends string = any, P extends QueryParams<T> = any> = {
521
- query: T;
522
- params: Identity<ExtractQueryParamsFromQueryString<T, P>>;
574
+ declare type Query<TQuery extends string = string, TQueryParams extends QueryParams<TQuery> = Record<string, Param | undefined>> = {
575
+ query: TQuery;
576
+ params: string extends TQuery ? Record<string, Param> : Identity<ExtractQueryParamsFromQueryString<TQuery, TQueryParams>>;
523
577
  toString: () => string;
524
578
  };
525
579
 
@@ -629,7 +683,7 @@ declare type ResolvedRoute<TRoute extends Route = BaseResolvedRoute> = DeepReado
629
683
  * The specific route properties that were matched in the current route, including any ancestors.
630
684
  * Order of routes will be from greatest ancestor to narrowest matched.
631
685
  */
632
- matches: RouteProps[];
686
+ matches: TRoute['matches'];
633
687
  /**
634
688
  * Unique identifier for the route, generated by joining route `name` by period. Key is used for routing and for matching.
635
689
  */
@@ -641,7 +695,7 @@ declare type ResolvedRoute<TRoute extends Route = BaseResolvedRoute> = DeepReado
641
695
  /**
642
696
  * Key value pair for route params, values will be the user provided value from current browser location.
643
697
  */
644
- params: ExtractRouteParamTypes<TRoute>;
698
+ params: BaseResolvedRoute extends TRoute ? Record<string, unknown> : ExtractRouteParamTypes<TRoute>;
645
699
  }>;
646
700
 
647
701
  declare type ResolvedRouteQuery = {
@@ -768,7 +822,7 @@ declare type RouteHookSuccessResponse = {
768
822
  export declare interface RouteMeta extends Record<string, unknown> {
769
823
  }
770
824
 
771
- declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypes<RouteGetByKey<TRoutes, TKey>>;
825
+ declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithoutLosingOptional<RouteGetByKey<TRoutes, TKey>>;
772
826
 
773
827
  /**
774
828
  * Unifies the properties of both parent and child routes, ensuring type safety and consistency across route configurations.
@@ -864,22 +918,22 @@ declare type RouterHistoryMode = 'auto' | 'browser' | 'memory' | 'hash';
864
918
 
865
919
  export declare const routerInjectionKey: InjectionKey<RegisteredRouter>;
866
920
 
867
- export declare const RouterLink: __VLS_WithTemplateSlots_2<DefineComponent<__VLS_TypePropsToRuntimeProps<{
921
+ export declare const RouterLink: __VLS_WithTemplateSlots_2<DefineComponent<__VLS_TypePropsToRuntimeProps_2<{
868
922
  to: Url | ToCallback;
869
- } & RouterPushOptions>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
923
+ } & RouterPushOptions>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps_2<{
870
924
  to: Url | ToCallback;
871
925
  } & RouterPushOptions>>>, {}, {}>, Readonly<{
872
926
  default?: ((props: {
873
927
  resolved: string;
874
- match: boolean;
875
- exactMatch: boolean;
928
+ isMatch: boolean;
929
+ isExactMatch: boolean;
876
930
  isExternal: boolean;
877
931
  }) => unknown) | undefined;
878
932
  }> & {
879
933
  default?: ((props: {
880
934
  resolved: string;
881
- match: boolean;
882
- exactMatch: boolean;
935
+ isMatch: boolean;
936
+ isExactMatch: boolean;
883
937
  isExternal: boolean;
884
938
  }) => unknown) | undefined;
885
939
  }>;
@@ -957,18 +1011,35 @@ declare type RouterResolveOptions = {
957
1011
  declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Omit<ResolvedRoute, 'params'> & Readonly<{
958
1012
  params: Writable<TRoute['params']>;
959
1013
  update: RouteUpdate<TRoute>;
1014
+ [isRouterRouteSymbol]: true;
960
1015
  }>;
961
1016
 
962
- export declare const RouterView: __VLS_WithTemplateSlots<DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {}>>, {}, {}>, Readonly<{
1017
+ export declare const RouterView: __VLS_WithTemplateSlots<DefineComponent<__VLS_TypePropsToRuntimeProps<{
1018
+ name?: string | undefined;
1019
+ }>, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
1020
+ name?: string | undefined;
1021
+ }>>>, {}, {}>, Readonly<{
963
1022
  default?: ((props: {
964
1023
  route: RouterRoute;
965
1024
  component: Component;
966
- }) => unknown) | undefined;
1025
+ rejection: {
1026
+ type: "NotFound";
1027
+ component: Component;
1028
+ } | null;
1029
+ }) => VNode<RendererNode, RendererElement, {
1030
+ [key: string]: any;
1031
+ }>) | undefined;
967
1032
  }> & {
968
1033
  default?: ((props: {
969
1034
  route: RouterRoute;
970
1035
  component: Component;
971
- }) => unknown) | undefined;
1036
+ rejection: {
1037
+ type: "NotFound";
1038
+ component: Component;
1039
+ } | null;
1040
+ }) => VNode<RendererNode, RendererElement, {
1041
+ [key: string]: any;
1042
+ }>) | undefined;
972
1043
  }>;
973
1044
 
974
1045
  /**
@@ -999,6 +1070,50 @@ declare type ToQuery<T extends string | Query | undefined> = T extends string ?
999
1070
 
1000
1071
  declare type Url = `http://${string}` | `https://${string}` | `/${string}` | '/';
1001
1072
 
1073
+ export declare type UseLink = {
1074
+ /**
1075
+ * ResolvedRoute if matched. Same value as `router.find`
1076
+ */
1077
+ route: Ref<ResolvedRoute | undefined>;
1078
+ /**
1079
+ * Resolved URL with params interpolated and query applied. Same value as `router.resolve`.
1080
+ */
1081
+ href: Ref<string>;
1082
+ /**
1083
+ * True if route matches current URL or is ancestor of route that matches current URL
1084
+ */
1085
+ isMatch: Ref<boolean>;
1086
+ /**
1087
+ * True if route matches current URL. Route is the same as what's currently stored at `router.route`.
1088
+ */
1089
+ isExactMatch: Ref<boolean>;
1090
+ /**
1091
+ * Convenience method for executing `router.push` with route context passed in.
1092
+ */
1093
+ push: (options?: RouterPushOptions) => Promise<void>;
1094
+ /**
1095
+ * Convenience method for executing `router.replace` with route context passed in.
1096
+ */
1097
+ replace: (options?: RouterReplaceOptions) => Promise<void>;
1098
+ };
1099
+
1100
+ /**
1101
+ * A composition to export much of the functionality that drives RouterLink component. Can be given route details to discover resolved URL,
1102
+ * or resolved URL to discover route details. Also exports some useful context about routes relationship to current URL and convenience methods
1103
+ * for navigating.
1104
+ *
1105
+ * @param source - The key of the route or the URL value.
1106
+ * @param params - If providing route key, this argument will expect corresponding params.
1107
+ * @param options - {@link RouterResolveOptions}Same options as router resolve.
1108
+ * @returns {UseLink} Reactive context values for as well as navigation methods.
1109
+ *
1110
+ */
1111
+ export declare function useLink<TRouteKey extends string & keyof RegisteredRouteMap>(routeKey: MaybeRefOrGetter<TRouteKey>, ...args: UseLinkArgs<TRouteKey>): UseLink;
1112
+
1113
+ export declare function useLink(url: MaybeRefOrGetter<Url>): UseLink;
1114
+
1115
+ declare type UseLinkArgs<TSource extends string & keyof RegisteredRouteMap, TParams = RouteParamsByKey<RegisteredRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<RouterResolveOptions>] : [params: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<RouterResolveOptions>];
1116
+
1002
1117
  /**
1003
1118
  * A composition to access the router's rejection state.
1004
1119
  *
@@ -1023,7 +1138,7 @@ export declare function useRejection(): RouterRejection;
1023
1138
  * The function also sets up a reactive watcher on the route object from the router to continually check the validity of the route key
1024
1139
  * if provided, throwing an error if the validation fails at any point during the component's lifecycle.
1025
1140
  */
1026
- export declare function useRoute<TRouteKey extends string & keyof RegisteredRouteMap>(routeKey: TRouteKey): RouterRoute<ResolvedRoute<RegisteredRouteMap[TRouteKey]>>;
1141
+ export declare function useRoute<TRouteKey extends string & keyof RegisteredRouteMap>(routeKey: TRouteKey, options?: UseRouteOptions): RouterRoute<ResolvedRoute<RegisteredRouteMap[TRouteKey]>>;
1027
1142
 
1028
1143
  export declare function useRoute(): RouterRoute;
1029
1144
 
@@ -1040,6 +1155,10 @@ export declare class UseRouteInvalidError extends Error {
1040
1155
  constructor(routeName: string, actualRouteName: string);
1041
1156
  }
1042
1157
 
1158
+ export declare type UseRouteOptions = {
1159
+ exact?: boolean;
1160
+ };
1161
+
1043
1162
  /**
1044
1163
  * A composition to access the registered router instance within a Vue component.
1045
1164
  *
@@ -1049,6 +1168,22 @@ export declare class UseRouteInvalidError extends Error {
1049
1168
  */
1050
1169
  export declare function useRouter(): RegisteredRouter;
1051
1170
 
1171
+ declare type WithComponent = {
1172
+ /**
1173
+ * A Vue component, which can be either synchronous or asynchronous components.
1174
+ */
1175
+ component: Component;
1176
+ };
1177
+
1178
+ declare type WithComponents = {
1179
+ /**
1180
+ * Multiple components for named views, which can be either synchronous or asynchronous components.
1181
+ */
1182
+ components: Record<string, Component>;
1183
+ };
1184
+
1185
+ export declare function withDefault<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
1186
+
1052
1187
  /**
1053
1188
  * Defines route hooks that can be applied before entering, updating, or leaving a route, as well as after these events.
1054
1189
  */