@kitbag/router 0.11.2 → 0.11.4
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 +45 -83
- package/dist/kitbag-router.js +1099 -1074
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +3 -4
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -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
|
-
|
|
708
|
-
|
|
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?:
|
|
1023
|
+
query?: QuerySource;
|
|
1016
1024
|
hash?: string;
|
|
1017
1025
|
replace?: boolean;
|
|
1018
1026
|
state?: Partial<TState>;
|
|
@@ -1035,34 +1043,35 @@ 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?:
|
|
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>):
|
|
1045
|
-
(url: Url, options?: RouterResolveOptions):
|
|
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?:
|
|
1059
|
+
query?: QuerySource;
|
|
1052
1060
|
hash?: string;
|
|
1053
1061
|
};
|
|
1054
1062
|
|
|
1055
|
-
declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> =
|
|
1056
|
-
id: TRoute['id'];
|
|
1057
|
-
name: TRoute['name'];
|
|
1058
|
-
matched: TRoute['matched'];
|
|
1059
|
-
matches: TRoute['matches'];
|
|
1060
|
-
state: TRoute['state'];
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1063
|
+
declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
|
|
1064
|
+
readonly id: TRoute['id'];
|
|
1065
|
+
readonly name: TRoute['name'];
|
|
1066
|
+
readonly matched: TRoute['matched'];
|
|
1067
|
+
readonly matches: TRoute['matches'];
|
|
1068
|
+
readonly state: TRoute['state'];
|
|
1069
|
+
readonly hash: TRoute['hash'];
|
|
1070
|
+
readonly params: Writable<TRoute['params']>;
|
|
1071
|
+
readonly update: RouteUpdate<TRoute>;
|
|
1072
|
+
get query(): ResolvedRouteQuery;
|
|
1073
|
+
set query(value: QuerySource);
|
|
1074
|
+
};
|
|
1066
1075
|
|
|
1067
1076
|
/**
|
|
1068
1077
|
* This type is the same as `RouterRoute<ResolvedRoute<TRoutes[number]>>` while remaining distributive
|
|
@@ -1077,35 +1086,7 @@ name?: string | undefined;
|
|
|
1077
1086
|
name?: string | undefined;
|
|
1078
1087
|
}>>>, {}, {}>, Readonly<{
|
|
1079
1088
|
default?: ((props: {
|
|
1080
|
-
route:
|
|
1081
|
-
id: string;
|
|
1082
|
-
name: string;
|
|
1083
|
-
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1084
|
-
id: string;
|
|
1085
|
-
meta: Record<string, unknown>;
|
|
1086
|
-
};
|
|
1087
|
-
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1088
|
-
id: string;
|
|
1089
|
-
meta: Record<string, unknown>;
|
|
1090
|
-
})[];
|
|
1091
|
-
state: {
|
|
1092
|
-
[x: string]: any;
|
|
1093
|
-
[x: number]: any;
|
|
1094
|
-
};
|
|
1095
|
-
query: ResolvedRouteQuery;
|
|
1096
|
-
hash: string | undefined;
|
|
1097
|
-
params: Writable< {
|
|
1098
|
-
[x: string]: any;
|
|
1099
|
-
[x: number]: any;
|
|
1100
|
-
}>;
|
|
1101
|
-
update: {
|
|
1102
|
-
(paramName: string, paramValue: unknown, options?: RouterPushOptions | undefined): Promise<void>;
|
|
1103
|
-
(params: Partial<{
|
|
1104
|
-
[x: string]: any;
|
|
1105
|
-
[x: number]: any;
|
|
1106
|
-
}>, options?: RouterPushOptions | undefined): Promise<void>;
|
|
1107
|
-
};
|
|
1108
|
-
}>;
|
|
1089
|
+
route: RouterRoute;
|
|
1109
1090
|
component: Component;
|
|
1110
1091
|
rejection: {
|
|
1111
1092
|
type: "NotFound";
|
|
@@ -1116,35 +1097,7 @@ name?: string | undefined;
|
|
|
1116
1097
|
}>) | undefined;
|
|
1117
1098
|
}> & {
|
|
1118
1099
|
default?: ((props: {
|
|
1119
|
-
route:
|
|
1120
|
-
id: string;
|
|
1121
|
-
name: string;
|
|
1122
|
-
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1123
|
-
id: string;
|
|
1124
|
-
meta: Record<string, unknown>;
|
|
1125
|
-
};
|
|
1126
|
-
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1127
|
-
id: string;
|
|
1128
|
-
meta: Record<string, unknown>;
|
|
1129
|
-
})[];
|
|
1130
|
-
state: {
|
|
1131
|
-
[x: string]: any;
|
|
1132
|
-
[x: number]: any;
|
|
1133
|
-
};
|
|
1134
|
-
query: ResolvedRouteQuery;
|
|
1135
|
-
hash: string | undefined;
|
|
1136
|
-
params: Writable< {
|
|
1137
|
-
[x: string]: any;
|
|
1138
|
-
[x: number]: any;
|
|
1139
|
-
}>;
|
|
1140
|
-
update: {
|
|
1141
|
-
(paramName: string, paramValue: unknown, options?: RouterPushOptions | undefined): Promise<void>;
|
|
1142
|
-
(params: Partial<{
|
|
1143
|
-
[x: string]: any;
|
|
1144
|
-
[x: number]: any;
|
|
1145
|
-
}>, options?: RouterPushOptions | undefined): Promise<void>;
|
|
1146
|
-
};
|
|
1147
|
-
}>;
|
|
1100
|
+
route: RouterRoute;
|
|
1148
1101
|
component: Component;
|
|
1149
1102
|
rejection: {
|
|
1150
1103
|
type: "NotFound";
|
|
@@ -1178,7 +1131,7 @@ declare type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = Resolve
|
|
|
1178
1131
|
|
|
1179
1132
|
declare type StringHasValue<T> = string extends T ? true : '' extends T ? false : T extends string ? true : false;
|
|
1180
1133
|
|
|
1181
|
-
declare type ToCallback = (resolve: RegisteredRouter['resolve']) =>
|
|
1134
|
+
declare type ToCallback = (resolve: RegisteredRouter['resolve']) => Url;
|
|
1182
1135
|
|
|
1183
1136
|
declare type ToHash<T extends string | Hash | undefined> = T extends string ? Hash<T> : T extends undefined ? Hash<''> : unknown extends T ? Hash<''> : T;
|
|
1184
1137
|
|
|
@@ -1190,7 +1143,16 @@ declare type ToPath<T extends string | Path | undefined> = T extends string ? Pa
|
|
|
1190
1143
|
|
|
1191
1144
|
declare type ToQuery<T extends string | Query | undefined> = T extends string ? Query<T, {}> : T extends undefined ? Query<'', {}> : unknown extends T ? Query<'', {}> : T;
|
|
1192
1145
|
|
|
1193
|
-
export declare type Url = `http://${string}` | `https://${string}` | `/${string}
|
|
1146
|
+
export declare type Url = `http://${string}` | `https://${string}` | `/${string}`;
|
|
1147
|
+
|
|
1148
|
+
export declare type UrlParts = {
|
|
1149
|
+
protocol?: string;
|
|
1150
|
+
host?: string;
|
|
1151
|
+
pathname: string;
|
|
1152
|
+
searchParams: URLSearchParams;
|
|
1153
|
+
search: string;
|
|
1154
|
+
hash: string;
|
|
1155
|
+
};
|
|
1194
1156
|
|
|
1195
1157
|
export declare type UseLink = {
|
|
1196
1158
|
/**
|