@kitbag/router 0.11.0 → 0.11.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.
- package/dist/kitbag-router.d.ts +11 -15
- package/dist/kitbag-router.js +233 -226
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +4 -3
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -290,13 +290,9 @@ export declare class DuplicateParamsError extends Error {
|
|
|
290
290
|
*/
|
|
291
291
|
declare type ExtractParamName<TParam extends PropertyKey> = TParam extends `?${infer Param}` ? Param extends '' ? never : Param : TParam extends '' ? never : TParam;
|
|
292
292
|
|
|
293
|
-
declare type ExtractParamsFromHostString<THost extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = THost extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ?
|
|
294
|
-
[P in Param]: ExtractPathParamType<Param, TParams>;
|
|
295
|
-
} & ExtractParamsFromHostString<Rest, TParams> : Record<never, never>;
|
|
293
|
+
declare type ExtractParamsFromHostString<THost extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = THost extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? Record<Param, ExtractPathParamType<Param, TParams>> & ExtractParamsFromHostString<Rest, TParams> : Record<never, never>;
|
|
296
294
|
|
|
297
|
-
declare type ExtractParamsFromPathString<TPath extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TPath extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ?
|
|
298
|
-
[P in Param]: ExtractPathParamType<Param, TParams>;
|
|
299
|
-
} & ExtractParamsFromPathString<Rest, TParams> : Record<never, never>;
|
|
295
|
+
declare type ExtractParamsFromPathString<TPath extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TPath extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? Record<Param, ExtractPathParamType<Param, TParams>> & ExtractParamsFromPathString<Rest, TParams> : Record<never, never>;
|
|
300
296
|
|
|
301
297
|
/**
|
|
302
298
|
* Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
|
|
@@ -329,9 +325,7 @@ declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param, TParamK
|
|
|
329
325
|
*/
|
|
330
326
|
declare type ExtractPathParamType<TParam extends string, TParams extends Record<string, Param | undefined>> = TParam extends `?${infer OptionalParam}` ? OptionalParam extends keyof TParams ? TParams[OptionalParam] : StringConstructor : TParam extends keyof TParams ? TParams[TParam] : StringConstructor;
|
|
331
327
|
|
|
332
|
-
declare type ExtractQueryParamsFromQueryString<TQuery extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TQuery extends `${string}=${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ?
|
|
333
|
-
[P in Param]: ExtractPathParamType<Param, TParams>;
|
|
334
|
-
} & ExtractQueryParamsFromQueryString<Rest, TParams> : Record<never, never>;
|
|
328
|
+
declare type ExtractQueryParamsFromQueryString<TQuery extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TQuery extends `${string}=${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? Record<Param, ExtractPathParamType<Param, TParams>> & ExtractQueryParamsFromQueryString<Rest, TParams> : Record<never, never>;
|
|
335
329
|
|
|
336
330
|
/**
|
|
337
331
|
* Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
|
|
@@ -425,6 +419,8 @@ declare type IsRouteOptions = {
|
|
|
425
419
|
|
|
426
420
|
declare type IsRouteUnnamed<T extends Route> = StringHasValue<T['name']> extends true ? false : true;
|
|
427
421
|
|
|
422
|
+
export declare function isUrl(value: unknown): value is Url;
|
|
423
|
+
|
|
428
424
|
declare type MakeOptional<T> = {
|
|
429
425
|
[P in WithOptionalProperties<T>]?: T[P];
|
|
430
426
|
} & {
|
|
@@ -1084,11 +1080,11 @@ name?: string | undefined;
|
|
|
1084
1080
|
route: Readonly<{
|
|
1085
1081
|
id: string;
|
|
1086
1082
|
name: string;
|
|
1087
|
-
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (
|
|
1083
|
+
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1088
1084
|
id: string;
|
|
1089
1085
|
meta: Record<string, unknown>;
|
|
1090
1086
|
};
|
|
1091
|
-
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (
|
|
1087
|
+
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1092
1088
|
id: string;
|
|
1093
1089
|
meta: Record<string, unknown>;
|
|
1094
1090
|
})[];
|
|
@@ -1123,11 +1119,11 @@ name?: string | undefined;
|
|
|
1123
1119
|
route: Readonly<{
|
|
1124
1120
|
id: string;
|
|
1125
1121
|
name: string;
|
|
1126
|
-
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (
|
|
1122
|
+
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1127
1123
|
id: string;
|
|
1128
1124
|
meta: Record<string, unknown>;
|
|
1129
1125
|
};
|
|
1130
|
-
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (
|
|
1126
|
+
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
1131
1127
|
id: string;
|
|
1132
1128
|
meta: Record<string, unknown>;
|
|
1133
1129
|
})[];
|
|
@@ -1162,7 +1158,7 @@ name?: string | undefined;
|
|
|
1162
1158
|
/**
|
|
1163
1159
|
* Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
|
|
1164
1160
|
*/
|
|
1165
|
-
export declare type Routes =
|
|
1161
|
+
export declare type Routes = readonly Route[];
|
|
1166
1162
|
|
|
1167
1163
|
declare type RoutesMap<TRoutes extends Routes = []> = {
|
|
1168
1164
|
[K in TRoutes[number] as AsNamedRoute<K>['name']]: AsNamedRoute<K>;
|
|
@@ -1194,7 +1190,7 @@ declare type ToPath<T extends string | Path | undefined> = T extends string ? Pa
|
|
|
1194
1190
|
|
|
1195
1191
|
declare type ToQuery<T extends string | Query | undefined> = T extends string ? Query<T, {}> : T extends undefined ? Query<'', {}> : unknown extends T ? Query<'', {}> : T;
|
|
1196
1192
|
|
|
1197
|
-
declare type Url = `http://${string}` | `https://${string}` | `/${string}` | '/';
|
|
1193
|
+
export declare type Url = `http://${string}` | `https://${string}` | `/${string}` | '/';
|
|
1198
1194
|
|
|
1199
1195
|
export declare type UseLink = {
|
|
1200
1196
|
/**
|