@kitbag/router 0.10.0 → 0.11.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.
@@ -1,6 +1,7 @@
1
1
  import { AsyncComponentLoader } from 'vue';
2
2
  import { Component } from 'vue';
3
3
  import { ComponentOptionsMixin } from 'vue';
4
+ import { ComputedRef } from 'vue';
4
5
  import { DefineComponent } from 'vue';
5
6
  import { ExtractPropTypes } from 'vue';
6
7
  import { FunctionalComponent } from 'vue';
@@ -238,6 +239,7 @@ export declare type CreateRouteOptions<TName extends string | undefined = string
238
239
  * The Route properties originally provided to `createRoute`. The only change is normalizing meta to always default to an empty object.
239
240
  */
240
241
  declare type CreateRouteOptionsMatched = CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
242
+ id: string;
241
243
  meta: RouteMeta;
242
244
  };
243
245
 
@@ -556,6 +558,11 @@ declare type PrefetchConfigOptions = {
556
558
  * @default true
557
559
  */
558
560
  components?: boolean;
561
+ /**
562
+ * When true any props for routes will be prefetched
563
+ * @default false
564
+ */
565
+ props?: boolean;
559
566
  };
560
567
 
561
568
  declare type Query<TQuery extends string = string, TQueryParams extends QueryParamsWithParamNameExtracted<TQuery> = Record<string, Param | undefined>> = {
@@ -665,6 +672,10 @@ declare type RemoveLeadingQuestionMarkFromKeys<T extends Record<string, unknown>
665
672
  * @template TRoute - Underlying Route that has been resolved.
666
673
  */
667
674
  declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
675
+ /**
676
+ * Unique identifier for the route, generated by router.
677
+ */
678
+ id: TRoute['id'];
668
679
  /**
669
680
  * The specific route properties that were matched in the current route.
670
681
  */
@@ -708,6 +719,10 @@ declare type ResolvedRouteQuery = {
708
719
  * @template TQuery - The type or structure of the query parameters associated with the route.
709
720
  */
710
721
  export declare type Route<TName extends string = string, THost extends Host = Host, TPath extends Path = Path, TQuery extends Query = Query, THash extends Hash = Hash, TMeta extends RouteMeta = RouteMeta, TState extends Record<string, Param> = Record<string, Param>> = {
722
+ /**
723
+ * Unique identifier for the route, generated by router.
724
+ */
725
+ id: string;
711
726
  /**
712
727
  * The specific route properties that were matched in the current route.
713
728
  */
@@ -718,7 +733,7 @@ export declare type Route<TName extends string = string, THost extends Host = Ho
718
733
  */
719
734
  matches: CreateRouteOptionsMatched[];
720
735
  /**
721
- * Unique identifier for the route. Name is used for routing and for matching.
736
+ * Identifier for the route as defined by user. Name must be unique among named routes. Name is used for routing and for matching.
722
737
  */
723
738
  name: TName;
724
739
  /**
@@ -897,10 +912,6 @@ export declare type Router<TRoutes extends Routes = any, __TOptions extends Rout
897
912
  * Registers a hook to be called after a route is updated.
898
913
  */
899
914
  onAfterRouteUpdate: AddAfterRouteHook;
900
- /**
901
- * A promise that resolves when the router is fully initialized.
902
- */
903
- initialized: Promise<void>;
904
915
  /**
905
916
  * Given a URL, returns true if host does not match host stored on router instance
906
917
  */
@@ -909,6 +920,10 @@ export declare type Router<TRoutes extends Routes = any, __TOptions extends Rout
909
920
  * Determines what assets are prefetched.
910
921
  */
911
922
  prefetch?: PrefetchConfig;
923
+ /**
924
+ * Initializes the router based on the initial route. Automatically called when the router is installed. Calling this more than once has no effect.
925
+ */
926
+ start: () => Promise<void>;
912
927
  };
913
928
 
914
929
  declare type RouterFind<TRoutes extends Routes> = {
@@ -1042,6 +1057,7 @@ declare type RouterResolveOptions = {
1042
1057
  };
1043
1058
 
1044
1059
  declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Readonly<{
1060
+ id: TRoute['id'];
1045
1061
  name: TRoute['name'];
1046
1062
  matched: TRoute['matched'];
1047
1063
  matches: TRoute['matches'];
@@ -1066,11 +1082,14 @@ name?: string | undefined;
1066
1082
  }>>>, {}, {}>, Readonly<{
1067
1083
  default?: ((props: {
1068
1084
  route: Readonly<{
1085
+ id: string;
1069
1086
  name: string;
1070
1087
  matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
1088
+ id: string;
1071
1089
  meta: Record<string, unknown>;
1072
1090
  };
1073
1091
  matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
1092
+ id: string;
1074
1093
  meta: Record<string, unknown>;
1075
1094
  })[];
1076
1095
  state: {
@@ -1102,11 +1121,14 @@ name?: string | undefined;
1102
1121
  }> & {
1103
1122
  default?: ((props: {
1104
1123
  route: Readonly<{
1124
+ id: string;
1105
1125
  name: string;
1106
1126
  matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
1127
+ id: string;
1107
1128
  meta: Record<string, unknown>;
1108
1129
  };
1109
1130
  matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
1131
+ id: string;
1110
1132
  meta: Record<string, unknown>;
1111
1133
  })[];
1112
1134
  state: {
@@ -1178,19 +1200,23 @@ export declare type UseLink = {
1178
1200
  /**
1179
1201
  * ResolvedRoute if matched. Same value as `router.find`
1180
1202
  */
1181
- route: Ref<ResolvedRoute | undefined>;
1203
+ route: ComputedRef<ResolvedRoute | undefined>;
1182
1204
  /**
1183
1205
  * Resolved URL with params interpolated and query applied. Same value as `router.resolve`.
1184
1206
  */
1185
- href: Ref<string>;
1207
+ href: ComputedRef<string>;
1186
1208
  /**
1187
1209
  * True if route matches current URL or is ancestor of route that matches current URL
1188
1210
  */
1189
- isMatch: Ref<boolean>;
1211
+ isMatch: ComputedRef<boolean>;
1190
1212
  /**
1191
1213
  * True if route matches current URL. Route is the same as what's currently stored at `router.route`.
1192
1214
  */
1193
- isExactMatch: Ref<boolean>;
1215
+ isExactMatch: ComputedRef<boolean>;
1216
+ /**
1217
+ *
1218
+ */
1219
+ isExternal: ComputedRef<boolean>;
1194
1220
  /**
1195
1221
  * Convenience method for executing `router.push` with route context passed in.
1196
1222
  */