@kitbag/router 0.14.0 → 0.14.2

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.
@@ -253,7 +253,7 @@ declare type CreateRouteOptionsMatched<TName extends string | undefined = string
253
253
  * export const routes = [
254
254
  * createRoute({ name: 'home', path: '/', component: Home }),
255
255
  * createRoute({ name: 'path', path: '/about', component: About }),
256
- * ]
256
+ * ] as const
257
257
  *
258
258
  * const router = createRouter(routes)
259
259
  * ```
@@ -672,7 +672,7 @@ export declare interface Register {
672
672
  * Represents the possible Rejections registered within {@link Register}
673
673
  */
674
674
  export declare type RegisteredRejectionType = Register extends {
675
- router: Router<Routes, infer TOptions extends RouterOptions>;
675
+ router: Router<infer __TRoutes extends Routes, infer TOptions extends RouterOptions>;
676
676
  } ? keyof TOptions['rejections'] | BuiltInRejectionType : BuiltInRejectionType;
677
677
 
678
678
  /**
@@ -750,11 +750,11 @@ export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
750
750
  /**
751
751
  * Accessor for query string values from user in the current browser location.
752
752
  */
753
- query: ResolvedRouteQuery;
753
+ query: URLSearchParams;
754
754
  /**
755
755
  * Hash value of the route.
756
756
  */
757
- hash?: string;
757
+ hash: string;
758
758
  /**
759
759
  * Key value pair for route params, values will be the user provided value from current browser location.
760
760
  */
@@ -769,20 +769,6 @@ export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
769
769
  href: Url;
770
770
  }>;
771
771
 
772
- declare type ResolvedRouteQuery = {
773
- append: URLSearchParams['append'];
774
- delete: URLSearchParams['delete'];
775
- entries: URLSearchParams['entries'];
776
- forEach: URLSearchParams['forEach'];
777
- get: URLSearchParams['get'];
778
- getAll: URLSearchParams['getAll'];
779
- has: URLSearchParams['has'];
780
- keys: URLSearchParams['keys'];
781
- set: URLSearchParams['set'];
782
- toString: URLSearchParams['toString'];
783
- values: URLSearchParams['values'];
784
- };
785
-
786
772
  /**
787
773
  * Represents the structure of a route within the application. Return value of `createRoute`
788
774
  * @template TName - Represents the unique name identifying the route, typically a string.
@@ -886,9 +872,13 @@ export declare type Router<TRoutes extends Routes = any, __TOptions extends Rout
886
872
  */
887
873
  route: RouterRoutes<TRoutes>;
888
874
  /**
889
- * Resolves a URL to a route object.
875
+ * Creates a ResolvedRoute record for a given route name and params.
890
876
  */
891
877
  resolve: RouterResolve<TRoutes>;
878
+ /**
879
+ * Creates a ResolvedRoute record for a given URL.
880
+ */
881
+ find: (url: string, options?: RouterResolveOptions) => ResolvedRoute | undefined;
892
882
  /**
893
883
  * Navigates to a specified path or route object in the history stack, adding a new entry.
894
884
  */
@@ -1037,6 +1027,7 @@ export declare type RouterOptions = {
1037
1027
 
1038
1028
  declare type RouterPush<TRoutes extends Routes = any> = {
1039
1029
  <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterPushArgs<TRoutes, TSource>): Promise<void>;
1030
+ (route: ResolvedRoute, options?: RouterPushOptions): Promise<void>;
1040
1031
  (url: Url, options?: RouterPushOptions): Promise<void>;
1041
1032
  };
1042
1033
 
@@ -1058,6 +1049,7 @@ declare type RouterRejection = Ref<null | {
1058
1049
 
1059
1050
  declare type RouterReplace<TRoutes extends Routes> = {
1060
1051
  <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterReplaceArgs<TRoutes, TSource>): Promise<void>;
1052
+ (route: ResolvedRoute, options?: RouterReplaceOptions): Promise<void>;
1061
1053
  (url: Url, options?: RouterReplaceOptions): Promise<void>;
1062
1054
  };
1063
1055
 
@@ -1069,10 +1061,7 @@ declare type RouterReplaceOptions<TState = unknown> = {
1069
1061
  state?: Partial<TState>;
1070
1062
  };
1071
1063
 
1072
- declare type RouterResolve<TRoutes extends Routes> = {
1073
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): ResolvedRoute | undefined;
1074
- (url: Url, options?: RouterResolveOptions): ResolvedRoute | undefined;
1075
- };
1064
+ declare type RouterResolve<TRoutes extends Routes> = <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>) => ResolvedRoute;
1076
1065
 
1077
1066
  declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>];
1078
1067
 
@@ -1092,7 +1081,7 @@ declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
1092
1081
  readonly href: TRoute['href'];
1093
1082
  params: TRoute['params'];
1094
1083
  state: TRoute['state'];
1095
- get query(): ResolvedRouteQuery;
1084
+ get query(): URLSearchParams;
1096
1085
  set query(value: QuerySource);
1097
1086
  };
1098
1087
 
@@ -1167,7 +1156,7 @@ export declare type UrlParts = {
1167
1156
  protocol?: string;
1168
1157
  host?: string;
1169
1158
  pathname: string;
1170
- searchParams: URLSearchParams;
1159
+ searchParams: QuerySource;
1171
1160
  search: string;
1172
1161
  hash: string;
1173
1162
  };
@@ -1228,7 +1217,7 @@ export declare function useLink(source: MaybeRefOrGetter<string | ResolvedRoute
1228
1217
 
1229
1218
  declare type UseLinkArgs<TSource extends RegisteredRoutesName, TParams = RouteParamsByKey<RegisteredRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>] : [params: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>];
1230
1219
 
1231
- export declare type UseLinkOptions = RouterResolveOptions & {
1220
+ export declare type UseLinkOptions = RouterPushOptions & {
1232
1221
  prefetch?: PrefetchConfig;
1233
1222
  };
1234
1223