@kitbag/router 0.8.0 → 0.9.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/dist/kitbag-router.d.ts +24 -17
- package/dist/kitbag-router.js +318 -312
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -254,9 +254,9 @@ declare type CreateRouteOptionsMatched = CreateRouteOptions & WithHooks & (WithH
|
|
|
254
254
|
* const router = createRouter(routes)
|
|
255
255
|
* ```
|
|
256
256
|
*/
|
|
257
|
-
export declare function createRouter<const
|
|
257
|
+
export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions>(routes: TRoutes, options?: TOptions): Router<TRoutes, TOptions>;
|
|
258
258
|
|
|
259
|
-
export declare function createRouter<const
|
|
259
|
+
export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions>(arrayOfRoutes: TRoutes[], options?: TOptions): Router<TRoutes, TOptions>;
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
262
|
* An error thrown when duplicate parameters are detected in a route.
|
|
@@ -576,7 +576,7 @@ declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
|
576
576
|
};
|
|
577
577
|
|
|
578
578
|
/**
|
|
579
|
-
* Represents the state of currently registered router,
|
|
579
|
+
* Represents the state of currently registered router, and route meta. Used to provide correct type context for
|
|
580
580
|
* components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
|
|
581
581
|
*
|
|
582
582
|
* @example
|
|
@@ -584,7 +584,6 @@ declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
|
584
584
|
* declare module '@kitbag/router' {
|
|
585
585
|
* interface Register {
|
|
586
586
|
* router: typeof router
|
|
587
|
-
* rejections: ["NotAuthorized"],
|
|
588
587
|
* routeMeta: { public?: boolean }
|
|
589
588
|
* }
|
|
590
589
|
* }
|
|
@@ -597,8 +596,8 @@ export declare interface Register {
|
|
|
597
596
|
* Represents the possible Rejections registered within {@link Register}
|
|
598
597
|
*/
|
|
599
598
|
export declare type RegisteredRejectionType = Register extends {
|
|
600
|
-
|
|
601
|
-
} ?
|
|
599
|
+
router: Router<Routes, infer TOptions extends RouterOptions>;
|
|
600
|
+
} ? keyof TOptions['rejections'] | BuiltInRejectionType : BuiltInRejectionType;
|
|
602
601
|
|
|
603
602
|
/**
|
|
604
603
|
* Represents the a map of all possible route names with corresponding Route registered within {@link Register}
|
|
@@ -667,6 +666,10 @@ declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
667
666
|
* Accessor for query string values from user in the current browser location.
|
|
668
667
|
*/
|
|
669
668
|
query: ResolvedRouteQuery;
|
|
669
|
+
/**
|
|
670
|
+
* Hash value of the route.
|
|
671
|
+
*/
|
|
672
|
+
hash?: string;
|
|
670
673
|
/**
|
|
671
674
|
* Key value pair for route params, values will be the user provided value from current browser location.
|
|
672
675
|
*/
|
|
@@ -777,7 +780,7 @@ declare type RouteHookPushResponse<T extends Routes> = {
|
|
|
777
780
|
*/
|
|
778
781
|
declare type RouteHookRejectResponse = {
|
|
779
782
|
status: 'REJECT';
|
|
780
|
-
type:
|
|
783
|
+
type: RegisteredRejectionType;
|
|
781
784
|
};
|
|
782
785
|
|
|
783
786
|
/**
|
|
@@ -809,7 +812,7 @@ declare type RouteParams<TPath extends string | Path | undefined, TQuery extends
|
|
|
809
812
|
|
|
810
813
|
declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = ExtractRouteParamTypesWithoutLosingOptional<RouteGetByKey<TRoutes, TKey>>;
|
|
811
814
|
|
|
812
|
-
export declare type Router<TRoutes extends Routes = any> = Plugin_2 & {
|
|
815
|
+
export declare type Router<TRoutes extends Routes = any, __TOptions extends RouterOptions = any> = Plugin_2 & {
|
|
813
816
|
/**
|
|
814
817
|
* Manages the current route state.
|
|
815
818
|
*/
|
|
@@ -964,7 +967,11 @@ export declare type RouterOptions = {
|
|
|
964
967
|
* Determines what assets are prefetched when router-link is rendered for a specific route
|
|
965
968
|
*/
|
|
966
969
|
prefetch?: PrefetchConfig;
|
|
967
|
-
|
|
970
|
+
/**
|
|
971
|
+
* Components assigned to each type of rejection your router supports.
|
|
972
|
+
*/
|
|
973
|
+
rejections?: Partial<Record<string, Component>>;
|
|
974
|
+
};
|
|
968
975
|
|
|
969
976
|
declare type RouterPush<TRoutes extends Routes = any> = {
|
|
970
977
|
<TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterPushArgs<TRoutes, TSource>): Promise<void>;
|
|
@@ -975,25 +982,20 @@ declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesName<T
|
|
|
975
982
|
|
|
976
983
|
declare type RouterPushOptions<TState = unknown> = {
|
|
977
984
|
query?: Record<string, string>;
|
|
985
|
+
hash?: string;
|
|
978
986
|
replace?: boolean;
|
|
979
987
|
state?: Partial<TState>;
|
|
980
988
|
};
|
|
981
989
|
|
|
982
|
-
export declare type RouterReject = (type:
|
|
990
|
+
export declare type RouterReject = (type: RegisteredRejectionType) => void;
|
|
983
991
|
|
|
984
992
|
declare type RouterRejection = Ref<null | {
|
|
985
|
-
type:
|
|
993
|
+
type: RegisteredRejectionType;
|
|
986
994
|
component: Component;
|
|
987
995
|
}>;
|
|
988
996
|
|
|
989
|
-
declare type RouterRejectionComponents = {
|
|
990
|
-
rejections?: Partial<Record<RouterRejectionType, Component>>;
|
|
991
|
-
};
|
|
992
|
-
|
|
993
997
|
export declare const routerRejectionKey: InjectionKey<RouterRejection>;
|
|
994
998
|
|
|
995
|
-
declare type RouterRejectionType = BuiltInRejectionType | RegisteredRejectionType;
|
|
996
|
-
|
|
997
999
|
declare type RouterReplace<TRoutes extends Routes> = {
|
|
998
1000
|
<TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterReplaceArgs<TRoutes, TSource>): Promise<void>;
|
|
999
1001
|
(url: Url, options?: RouterReplaceOptions): Promise<void>;
|
|
@@ -1003,6 +1005,7 @@ declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesNam
|
|
|
1003
1005
|
|
|
1004
1006
|
declare type RouterReplaceOptions<TState = unknown> = {
|
|
1005
1007
|
query?: Record<string, string>;
|
|
1008
|
+
hash?: string;
|
|
1006
1009
|
state?: Partial<TState>;
|
|
1007
1010
|
};
|
|
1008
1011
|
|
|
@@ -1015,6 +1018,7 @@ declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesNam
|
|
|
1015
1018
|
|
|
1016
1019
|
declare type RouterResolveOptions = {
|
|
1017
1020
|
query?: Record<string, string>;
|
|
1021
|
+
hash?: string;
|
|
1018
1022
|
};
|
|
1019
1023
|
|
|
1020
1024
|
declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Readonly<{
|
|
@@ -1023,6 +1027,7 @@ declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Readonl
|
|
|
1023
1027
|
matches: TRoute['matches'];
|
|
1024
1028
|
state: TRoute['state'];
|
|
1025
1029
|
query: ResolvedRouteQuery;
|
|
1030
|
+
hash: TRoute['hash'];
|
|
1026
1031
|
params: Writable<TRoute['params']>;
|
|
1027
1032
|
update: RouteUpdate<TRoute>;
|
|
1028
1033
|
}>;
|
|
@@ -1053,6 +1058,7 @@ name?: string | undefined;
|
|
|
1053
1058
|
[x: number]: any;
|
|
1054
1059
|
};
|
|
1055
1060
|
query: ResolvedRouteQuery;
|
|
1061
|
+
hash: string | undefined;
|
|
1056
1062
|
params: Writable< {
|
|
1057
1063
|
[x: string]: any;
|
|
1058
1064
|
[x: number]: any;
|
|
@@ -1088,6 +1094,7 @@ name?: string | undefined;
|
|
|
1088
1094
|
[x: number]: any;
|
|
1089
1095
|
};
|
|
1090
1096
|
query: ResolvedRouteQuery;
|
|
1097
|
+
hash: string | undefined;
|
|
1091
1098
|
params: Writable< {
|
|
1092
1099
|
[x: string]: any;
|
|
1093
1100
|
[x: number]: any;
|