@kitbag/router 0.11.2 → 0.11.3

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.
@@ -101,6 +101,8 @@ declare type AllPropertiesAreOptional<T> = Record<string, unknown> extends T ? t
101
101
 
102
102
  declare type AsNamedRoute<T extends Route> = IsRouteUnnamed<T> extends true ? never : T;
103
103
 
104
+ export declare function asUrl(value: string): Url;
105
+
104
106
  /**
105
107
  * Represents a function called before a route change, potentially altering the routing operation.
106
108
  * @param to - {@link ResolvedRoute} The resolved route the router is navigating to.
@@ -367,14 +369,11 @@ declare type ExtractStateParams<TRoute> = TRoute extends {
367
369
 
368
370
  declare type Hash<THash extends string | undefined = string | undefined> = {
369
371
  value: THash;
370
- hasValue: () => boolean;
371
- toString: () => string;
372
372
  };
373
373
 
374
374
  declare type Host<THost extends string = string, TParams extends HostParamsWithParamNameExtracted<THost> = Record<string, Param | undefined>> = {
375
375
  value: THost;
376
376
  params: string extends THost ? Record<string, Param> : Identity<ExtractParamsFromHostString<THost, TParams>>;
377
- toString: () => string;
378
377
  };
379
378
 
380
379
  declare type HostParamsWithParamNameExtracted<THost extends string> = {
@@ -513,7 +512,6 @@ declare type ParentQuery<TParent extends Route | undefined> = TParent extends Ro
513
512
  declare type Path<TPath extends string = string, TParams extends PathParamsWithParamNameExtracted<TPath> = Record<string, Param | undefined>> = {
514
513
  value: TPath;
515
514
  params: string extends TPath ? Record<string, Param> : Identity<ExtractParamsFromPathString<TPath, TParams>>;
516
- toString: () => string;
517
515
  };
518
516
 
519
517
  /**
@@ -564,7 +562,6 @@ declare type PrefetchConfigOptions = {
564
562
  declare type Query<TQuery extends string = string, TQueryParams extends QueryParamsWithParamNameExtracted<TQuery> = Record<string, Param | undefined>> = {
565
563
  value: TQuery;
566
564
  params: string extends TQuery ? Record<string, Param> : Identity<ExtractQueryParamsFromQueryString<TQuery, TQueryParams>>;
567
- toString: () => string;
568
565
  };
569
566
 
570
567
  /**
@@ -594,6 +591,8 @@ declare type QueryParamsWithParamNameExtracted<T extends string> = {
594
591
  [K in keyof ExtractQueryParamsFromQueryString<T> as ExtractParamName<K>]?: Param;
595
592
  };
596
593
 
594
+ declare type QuerySource = ConstructorParameters<typeof URLSearchParams>[0];
595
+
597
596
  /**
598
597
  * Represents the state of currently registered router, and route meta. Used to provide correct type context for
599
598
  * components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
@@ -704,8 +703,17 @@ declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
704
703
  }>;
705
704
 
706
705
  declare type ResolvedRouteQuery = {
707
- get: (key: string) => string | null;
708
- getAll: (key: string) => string[];
706
+ append: URLSearchParams['append'];
707
+ delete: URLSearchParams['delete'];
708
+ entries: URLSearchParams['entries'];
709
+ forEach: URLSearchParams['forEach'];
710
+ get: URLSearchParams['get'];
711
+ getAll: URLSearchParams['getAll'];
712
+ has: URLSearchParams['has'];
713
+ keys: URLSearchParams['keys'];
714
+ set: URLSearchParams['set'];
715
+ toString: URLSearchParams['toString'];
716
+ values: URLSearchParams['values'];
709
717
  };
710
718
 
711
719
  /**
@@ -1012,7 +1020,7 @@ declare type RouterPush<TRoutes extends Routes = any> = {
1012
1020
  declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByName<TRoutes, TSource>>];
1013
1021
 
1014
1022
  declare type RouterPushOptions<TState = unknown> = {
1015
- query?: Record<string, string>;
1023
+ query?: QuerySource;
1016
1024
  hash?: string;
1017
1025
  replace?: boolean;
1018
1026
  state?: Partial<TState>;
@@ -1035,20 +1043,20 @@ declare type RouterReplace<TRoutes extends Routes> = {
1035
1043
  declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>] : [params: TParams, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>];
1036
1044
 
1037
1045
  declare type RouterReplaceOptions<TState = unknown> = {
1038
- query?: Record<string, string>;
1046
+ query?: QuerySource;
1039
1047
  hash?: string;
1040
1048
  state?: Partial<TState>;
1041
1049
  };
1042
1050
 
1043
1051
  declare type RouterResolve<TRoutes extends Routes> = {
1044
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): string;
1045
- (url: Url, options?: RouterResolveOptions): string;
1052
+ <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): Url;
1053
+ (url: Url, options?: RouterResolveOptions): Url;
1046
1054
  };
1047
1055
 
1048
1056
  declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterResolveOptions] : [params: TParams, options?: RouterResolveOptions];
1049
1057
 
1050
1058
  declare type RouterResolveOptions = {
1051
- query?: Record<string, string>;
1059
+ query?: QuerySource;
1052
1060
  hash?: string;
1053
1061
  };
1054
1062
 
@@ -1178,7 +1186,7 @@ declare type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = Resolve
1178
1186
 
1179
1187
  declare type StringHasValue<T> = string extends T ? true : '' extends T ? false : T extends string ? true : false;
1180
1188
 
1181
- declare type ToCallback = (resolve: RegisteredRouter['resolve']) => string;
1189
+ declare type ToCallback = (resolve: RegisteredRouter['resolve']) => Url;
1182
1190
 
1183
1191
  declare type ToHash<T extends string | Hash | undefined> = T extends string ? Hash<T> : T extends undefined ? Hash<''> : unknown extends T ? Hash<''> : T;
1184
1192
 
@@ -1190,7 +1198,16 @@ declare type ToPath<T extends string | Path | undefined> = T extends string ? Pa
1190
1198
 
1191
1199
  declare type ToQuery<T extends string | Query | undefined> = T extends string ? Query<T, {}> : T extends undefined ? Query<'', {}> : unknown extends T ? Query<'', {}> : T;
1192
1200
 
1193
- export declare type Url = `http://${string}` | `https://${string}` | `/${string}` | '/';
1201
+ export declare type Url = `http://${string}` | `https://${string}` | `/${string}`;
1202
+
1203
+ export declare type UrlParts = {
1204
+ protocol?: string;
1205
+ host?: string;
1206
+ pathname: string;
1207
+ searchParams: URLSearchParams;
1208
+ search: string;
1209
+ hash: string;
1210
+ };
1194
1211
 
1195
1212
  export declare type UseLink = {
1196
1213
  /**