@kitbag/router 0.17.2 → 0.17.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 +56 -111
- package/dist/kitbag-router.js +1726 -1709
- package/dist/kitbag-router.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -209,29 +209,27 @@ declare type CallbackSuccessResponse = {
|
|
|
209
209
|
status: 'SUCCESS';
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
declare type CombineHash<TParent extends
|
|
213
|
-
value: infer TParentHash extends string;
|
|
214
|
-
} ? ToHash<TChild> extends {
|
|
215
|
-
value: infer ChildHash extends string;
|
|
216
|
-
} ? Hash<`${TParentHash}${ChildHash}`> : TParent : Hash;
|
|
212
|
+
declare type CombineHash<TParent extends WithParams, TChild extends WithParams> = CombinePath<TParent, TChild>;
|
|
217
213
|
|
|
218
214
|
declare type CombineMeta<TParent extends Record<string, unknown>, TChild extends Record<string, unknown>> = TParent & TChild;
|
|
219
215
|
|
|
220
|
-
declare type CombinePath<TParent extends
|
|
216
|
+
declare type CombinePath<TParent extends WithParams, TChild extends WithParams> = ToWithParams<TParent> extends {
|
|
221
217
|
value: infer TParentPath extends string;
|
|
222
218
|
params: infer TParentParams extends Record<string, unknown>;
|
|
223
|
-
} ?
|
|
219
|
+
} ? ToWithParams<TChild> extends {
|
|
224
220
|
value: infer TChildPath extends string;
|
|
225
221
|
params: infer TChildParams extends Record<string, unknown>;
|
|
226
|
-
} ? RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams> extends
|
|
222
|
+
} ? RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams> extends ParamsWithParamNameExtracted<CombinePathString<TParentPath, TChildPath>> ? WithParams<CombinePathString<TParentPath, TChildPath>, RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams>> : WithParams<'', {}> : WithParams<'', {}> : WithParams<'', {}>;
|
|
227
223
|
|
|
228
|
-
declare type
|
|
224
|
+
declare type CombinePathString<TParent extends string, TChild extends string> = `${TParent}${TChild}`;
|
|
225
|
+
|
|
226
|
+
declare type CombineQuery<TParent extends WithParams, TChild extends WithParams> = ToWithParams<TParent> extends {
|
|
229
227
|
value: infer TParentQuery extends string;
|
|
230
228
|
params: infer TParentParams extends Record<string, unknown>;
|
|
231
|
-
} ?
|
|
229
|
+
} ? ToWithParams<TChild> extends {
|
|
232
230
|
value: infer TChildQuery extends string;
|
|
233
231
|
params: infer TChildParams extends Record<string, unknown>;
|
|
234
|
-
} ? RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams> extends
|
|
232
|
+
} ? RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams> extends ParamsWithParamNameExtracted<CombineQueryString<TParentQuery, TChildQuery>> ? WithParams<CombineQueryString<TParentQuery, TChildQuery>, RemoveLeadingQuestionMarkFromKeys<TParentParams> & RemoveLeadingQuestionMarkFromKeys<TChildParams>> : WithParams<'', {}> : WithParams<'', {}> : WithParams<'', {}>;
|
|
235
233
|
|
|
236
234
|
declare type CombineQueryString<TParent extends string | undefined, TChild extends string | undefined> = StringHasValue<TParent> extends true ? StringHasValue<TChild> extends true ? `${TParent}&${TChild}` : TParent : TChild;
|
|
237
235
|
|
|
@@ -251,19 +249,19 @@ export declare type CreatedRouteOptions = Omit<CreateRouteOptions, 'props'> & Wi
|
|
|
251
249
|
props?: unknown;
|
|
252
250
|
};
|
|
253
251
|
|
|
254
|
-
export declare function createExternalRoute<const THost extends string |
|
|
252
|
+
export declare function createExternalRoute<const THost extends string | WithParams, const TName extends string | undefined = undefined, const TPath extends string | WithParams | undefined = undefined, const TQuery extends string | WithParams | undefined = undefined, const THash extends string | WithParams | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery> & WithHost<THost> & WithoutParent): Route<ToName<TName>, ToWithParams<THost>, ToWithParams<TPath>, ToWithParams<TQuery>, ToWithParams<THash>, TMeta>;
|
|
255
253
|
|
|
256
|
-
export declare function createExternalRoute<const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string |
|
|
254
|
+
export declare function createExternalRoute<const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | WithParams | undefined = undefined, const TQuery extends string | WithParams | undefined = undefined, const THash extends string | WithParams | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery> & WithoutHost & WithParent<TParent>): Route<ToName<TName>, WithParams<'', {}>, CombinePath<TParent['path'], ToWithParams<TPath>>, CombineQuery<TParent['query'], ToWithParams<TQuery>>, CombineHash<TParent['hash'], ToWithParams<THash>>, CombineMeta<TMeta, TParent['meta']>>;
|
|
257
255
|
|
|
258
256
|
export declare function createParam<TParam extends ParamWithDefault>(param: TParam): TParam;
|
|
259
257
|
|
|
260
258
|
export declare function createParam<TParam extends Param>(param: TParam): ParamGetSet<ExtractParamType<TParam>>;
|
|
261
259
|
|
|
262
|
-
export declare function createParam<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam
|
|
260
|
+
export declare function createParam<TParam extends Param>(param: TParam, defaultValue: NoInfer<ExtractParamType<TParam>>): ParamWithDefault<TParam>;
|
|
263
261
|
|
|
264
262
|
export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): ToRoute<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>;
|
|
265
263
|
|
|
266
|
-
export declare type CreateRouteOptions<TName extends string | undefined = string | undefined, TPath extends string |
|
|
264
|
+
export declare type CreateRouteOptions<TName extends string | undefined = string | undefined, TPath extends string | WithParams | undefined = string | WithParams | undefined, TQuery extends string | WithParams | undefined = string | WithParams | undefined, THash extends string | WithParams | undefined = string | WithParams | undefined, TMeta extends RouteMeta = RouteMeta> = WithHooks & {
|
|
267
265
|
/**
|
|
268
266
|
* Name for route, used to create route keys and in navigation.
|
|
269
267
|
*/
|
|
@@ -373,9 +371,7 @@ declare type EmptyRouterPlugin = {
|
|
|
373
371
|
*/
|
|
374
372
|
declare type ExtractParamName<TParam extends PropertyKey> = TParam extends `?${infer Param}` ? Param extends '' ? never : Param : TParam extends '' ? never : TParam;
|
|
375
373
|
|
|
376
|
-
declare type
|
|
377
|
-
|
|
378
|
-
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>;
|
|
374
|
+
declare type ExtractParamsFromString<TValue extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TValue extends `${string}${ParamStart}${infer Param}${ParamEnd}${infer Rest}` ? Record<Param, ExtractWithParamsParamType<Param, TParams>> & ExtractParamsFromString<Rest, TParams> : Record<never, never>;
|
|
379
375
|
|
|
380
376
|
/**
|
|
381
377
|
* Extracts the actual type from a parameter type, handling getters, setters, and potential undefined values.
|
|
@@ -400,16 +396,6 @@ declare type ExtractParamTypesWithoutLosingOptional<TParams extends Record<strin
|
|
|
400
396
|
|
|
401
397
|
declare type ExtractParamTypeWithoutLosingOptional<TParam extends Param, TParamKey extends PropertyKey> = TParam extends ParamGetSet<infer Type> ? TParamKey extends `?${string}` ? Type | undefined : Type : TParam extends ParamGetter ? TParamKey extends `?${string}` ? ReturnType<TParam> | undefined : ReturnType<TParam> : TParam extends ZodSchema<infer Type> ? TParamKey extends `?${string}` ? Type | undefined : Type : TParam extends LiteralParam ? TParamKey extends `?${string}` ? TParam | undefined : TParam : TParamKey extends `?${string}` ? string | undefined : string;
|
|
402
398
|
|
|
403
|
-
/**
|
|
404
|
-
* Determines the type of a path parameter from a record of parameter types, considering optional parameters.
|
|
405
|
-
* @template TParam - The parameter name string.
|
|
406
|
-
* @template TParams - The record object mapping parameter names to their types.
|
|
407
|
-
* @returns The type associated with the parameter, or StringConstructor if unspecified; may be undefined for optional parameters.
|
|
408
|
-
*/
|
|
409
|
-
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;
|
|
410
|
-
|
|
411
|
-
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>;
|
|
412
|
-
|
|
413
399
|
/**
|
|
414
400
|
* Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
|
|
415
401
|
* This parameter object type represents the expected type when accessing params from router.route or useRoute.
|
|
@@ -426,7 +412,10 @@ declare type ExtractRouteParamTypes<TRoute> = TRoute extends {
|
|
|
426
412
|
host: {
|
|
427
413
|
params: infer HostParams extends Record<string, Param>;
|
|
428
414
|
};
|
|
429
|
-
|
|
415
|
+
hash: {
|
|
416
|
+
params: infer HashParams extends Record<string, Param>;
|
|
417
|
+
};
|
|
418
|
+
} ? ExtractParamTypes<HostParams & PathParams & QueryParams & HashParams> : {};
|
|
430
419
|
|
|
431
420
|
declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extends {
|
|
432
421
|
host: {
|
|
@@ -438,7 +427,10 @@ declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extend
|
|
|
438
427
|
query: {
|
|
439
428
|
params: infer QueryParams extends Record<string, Param>;
|
|
440
429
|
};
|
|
441
|
-
|
|
430
|
+
hash: {
|
|
431
|
+
params: infer HashParams extends Record<string, Param>;
|
|
432
|
+
};
|
|
433
|
+
} ? ExtractParamTypesWithoutLosingOptional<HostParams & PathParams & QueryParams & HashParams> : Record<string, unknown>;
|
|
442
434
|
|
|
443
435
|
declare type ExtractRouteStateParamsAsOptional<T extends Record<string, Param>> = ExtractParamTypes<{
|
|
444
436
|
[K in keyof T as K extends string ? `?${K}` : never]: T[K];
|
|
@@ -448,22 +440,22 @@ declare type ExtractStateParams<TRoute> = TRoute extends {
|
|
|
448
440
|
state: infer TState extends Record<string, Param>;
|
|
449
441
|
} ? ExtractParamTypes<TState> : Record<string, unknown>;
|
|
450
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Determines the type of a path parameter from a record of parameter types, considering optional parameters.
|
|
445
|
+
* @template TParam - The parameter name string.
|
|
446
|
+
* @template TParams - The record object mapping parameter names to their types.
|
|
447
|
+
* @returns The type associated with the parameter, or StringConstructor if unspecified; may be undefined for optional parameters.
|
|
448
|
+
*/
|
|
449
|
+
declare type ExtractWithParamsParamType<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;
|
|
450
|
+
|
|
451
451
|
declare type GetParentPropsReturnType<TParent extends Route | undefined = Route | undefined> = TParent extends Route ? TParent['matched']['props'] extends PropsGetter ? ReturnType<TParent['matched']['props']> : TParent['matched']['props'] extends Record<string, PropsGetter> ? {
|
|
452
452
|
[K in keyof TParent['matched']['props']]: ReturnType<TParent['matched']['props'][K]>;
|
|
453
453
|
} : undefined : undefined;
|
|
454
454
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
declare type Host<THost extends string = string, TParams extends HostParamsWithParamNameExtracted<THost> = Record<string, Param | undefined>> = {
|
|
460
|
-
value: THost;
|
|
461
|
-
params: string extends THost ? Record<string, Param> : Identity<ExtractParamsFromHostString<THost, TParams>>;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
declare type HostParamsWithParamNameExtracted<THost extends string> = {
|
|
465
|
-
[K in keyof ExtractParamsFromHostString<THost> as ExtractParamName<K>]?: Param;
|
|
466
|
-
};
|
|
455
|
+
/**
|
|
456
|
+
* @deprecated use `withParams` instead
|
|
457
|
+
*/
|
|
458
|
+
export declare const host: typeof withParams;
|
|
467
459
|
|
|
468
460
|
declare type Identity<T> = T extends object ? {} & {
|
|
469
461
|
[P in keyof T as T[P] extends never ? never : P]: T[P];
|
|
@@ -642,39 +634,16 @@ declare type ParamStart = typeof paramStart;
|
|
|
642
634
|
|
|
643
635
|
declare const paramStart = "[";
|
|
644
636
|
|
|
645
|
-
declare type
|
|
646
|
-
|
|
647
|
-
declare type Path<TPath extends string = string, TParams extends PathParamsWithParamNameExtracted<TPath> = Record<string, Param | undefined>> = {
|
|
648
|
-
value: TPath;
|
|
649
|
-
params: string extends TPath ? Record<string, Param> : Identity<ExtractParamsFromPathString<TPath, TParams>>;
|
|
637
|
+
declare type ParamsWithParamNameExtracted<TValue extends string> = {
|
|
638
|
+
[K in keyof ExtractParamsFromString<TValue> as ExtractParamName<K>]?: Param;
|
|
650
639
|
};
|
|
651
640
|
|
|
641
|
+
declare type ParamWithDefault<TParam extends Param = Param> = Required<ParamGetSet<ExtractParamType<TParam>>>;
|
|
642
|
+
|
|
652
643
|
/**
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* @template TPath - The string literal type that represents the path.
|
|
656
|
-
* @template TParams - The type of the path parameters associated with the path.
|
|
657
|
-
* @param value - The path string.
|
|
658
|
-
* @param params - The parameters associated with the path, typically as key-value pairs.
|
|
659
|
-
* @returns An object representing the path which includes the path string, its parameters,
|
|
660
|
-
* and a toString method for getting the path as a string.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* ```ts
|
|
664
|
-
* import { createRoute, path } from '@kitbag/router'
|
|
665
|
-
*
|
|
666
|
-
* export const routes = createRoute({
|
|
667
|
-
* name: 'home',
|
|
668
|
-
* path: path('/[foo]', { foo: Number }),
|
|
669
|
-
* component: Home
|
|
670
|
-
* })
|
|
671
|
-
* ```
|
|
644
|
+
* @deprecated use `withParams` instead
|
|
672
645
|
*/
|
|
673
|
-
export declare
|
|
674
|
-
|
|
675
|
-
declare type PathParamsWithParamNameExtracted<TPath extends string> = {
|
|
676
|
-
[K in keyof ExtractParamsFromPathString<TPath> as ExtractParamName<K>]?: Param;
|
|
677
|
-
};
|
|
646
|
+
export declare const path: typeof withParams;
|
|
678
647
|
|
|
679
648
|
/**
|
|
680
649
|
* Determines what assets are prefetched. A boolean enables or disables all prefetching.
|
|
@@ -721,37 +690,10 @@ declare type PropsCallbackParent<TParent extends Route | undefined = Route | und
|
|
|
721
690
|
|
|
722
691
|
declare type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions, undefined>>, context: PropsCallbackContext<TOptions['parent']>) => MaybePromise<ComponentProps<TComponent>>;
|
|
723
692
|
|
|
724
|
-
declare type Query<TQuery extends string = string, TQueryParams extends QueryParamsWithParamNameExtracted<TQuery> = Record<string, Param | undefined>> = {
|
|
725
|
-
value: TQuery;
|
|
726
|
-
params: string extends TQuery ? Record<string, Param> : Identity<ExtractQueryParamsFromQueryString<TQuery, TQueryParams>>;
|
|
727
|
-
};
|
|
728
|
-
|
|
729
693
|
/**
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
* @template TQuery - The string literal type that represents the query.
|
|
733
|
-
* @template TParams - The type of the query parameters associated with the query.
|
|
734
|
-
* @param value - The query string.
|
|
735
|
-
* @param params - The parameters associated with the query, typically as key-value pairs.
|
|
736
|
-
* @returns An object representing the query which includes the query string, its parameters,
|
|
737
|
-
* and a toString method for getting the query as a string.
|
|
738
|
-
*
|
|
739
|
-
* @example
|
|
740
|
-
* ```ts
|
|
741
|
-
* import { createRoute, query } from '@kitbag/router'
|
|
742
|
-
*
|
|
743
|
-
* export const routes = createRoute({
|
|
744
|
-
* name: 'home',
|
|
745
|
-
* query: query('bar=[bar]', { bar: Boolean }),
|
|
746
|
-
* component: Home
|
|
747
|
-
* })
|
|
748
|
-
* ```
|
|
694
|
+
* @deprecated use `withParams` instead
|
|
749
695
|
*/
|
|
750
|
-
export declare
|
|
751
|
-
|
|
752
|
-
declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
753
|
-
[K in keyof ExtractQueryParamsFromQueryString<T> as ExtractParamName<K>]?: Param;
|
|
754
|
-
};
|
|
696
|
+
export declare const query: typeof withParams;
|
|
755
697
|
|
|
756
698
|
export declare type QuerySource = ConstructorParameters<typeof URLSearchParams>[0];
|
|
757
699
|
|
|
@@ -879,7 +821,7 @@ export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
879
821
|
* @template TPath - The type or structure of the route's path.
|
|
880
822
|
* @template TQuery - The type or structure of the query parameters associated with the route.
|
|
881
823
|
*/
|
|
882
|
-
export declare type Route<TName extends string = string, THost extends
|
|
824
|
+
export declare type Route<TName extends string = string, THost extends WithParams = WithParams, TPath extends WithParams = WithParams, TQuery extends WithParams = WithParams, THash extends WithParams = WithParams, TMeta extends RouteMeta = RouteMeta, TState extends Record<string, Param> = Record<string, Param>, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = {
|
|
883
825
|
/**
|
|
884
826
|
* Unique identifier for the route, generated by router.
|
|
885
827
|
*/
|
|
@@ -1277,10 +1219,6 @@ declare type StringHasValue<T> = string extends T ? true : '' extends T ? false
|
|
|
1277
1219
|
|
|
1278
1220
|
export declare type ToCallback = (resolve: RegisteredRouter['resolve']) => ResolvedRoute | Url | undefined;
|
|
1279
1221
|
|
|
1280
|
-
declare type ToHash<T extends string | Hash | undefined> = T extends string ? Hash<T> : T extends undefined ? Hash<''> : unknown extends T ? Hash<''> : T;
|
|
1281
|
-
|
|
1282
|
-
declare type ToHost<T extends string | Host | undefined> = T extends string ? Host<T, {}> : T extends undefined ? Host<'', {}> : unknown extends T ? Host<'', {}> : T;
|
|
1283
|
-
|
|
1284
1222
|
declare type ToMatch<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = Omit<TOptions, 'props'> & {
|
|
1285
1223
|
id: string;
|
|
1286
1224
|
props: TProps;
|
|
@@ -1294,16 +1232,14 @@ declare type ToMeta<TMeta extends RouteMeta | undefined> = TMeta extends undefin
|
|
|
1294
1232
|
|
|
1295
1233
|
declare type ToName<T extends string | undefined> = T extends string ? T : '';
|
|
1296
1234
|
|
|
1297
|
-
declare type ToPath<T extends string | Path | undefined> = T extends string ? Path<T, {}> : T extends undefined ? Path<'', {}> : unknown extends T ? Path<'', {}> : T;
|
|
1298
|
-
|
|
1299
|
-
declare type ToQuery<T extends string | Query | undefined> = T extends string ? Query<T, {}> : T extends undefined ? Query<'', {}> : unknown extends T ? Query<'', {}> : T;
|
|
1300
|
-
|
|
1301
1235
|
declare type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = CreateRouteOptions extends TOptions ? Route : TOptions extends {
|
|
1302
1236
|
parent: infer TParent extends Route;
|
|
1303
|
-
} ? Route<ToName<TOptions['name']>,
|
|
1237
|
+
} ? Route<ToName<TOptions['name']>, WithParams<'', {}>, CombinePath<ToWithParams<TParent['path']>, ToWithParams<TOptions['path']>>, CombineQuery<ToWithParams<TParent['query']>, ToWithParams<TOptions['query']>>, CombineHash<ToWithParams<TParent['hash']>, ToWithParams<TOptions['hash']>>, CombineMeta<ToMeta<TParent['meta']>, ToMeta<TOptions['meta']>>, CombineState<ToState<TParent['state']>, ToState<TOptions['state']>>, ToMatches<TOptions, TProps>> : Route<ToName<TOptions['name']>, WithParams<'', {}>, ToWithParams<TOptions['path']>, ToWithParams<TOptions['query']>, ToWithParams<TOptions['hash']>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, TProps>>;
|
|
1304
1238
|
|
|
1305
1239
|
declare type ToState<TState extends Record<string, Param> | undefined> = TState extends undefined ? Record<string, Param> : unknown extends TState ? {} : TState;
|
|
1306
1240
|
|
|
1241
|
+
declare type ToWithParams<T extends string | WithParams | undefined> = T extends string ? WithParams<T, {}> : T extends undefined ? WithParams<'', {}> : unknown extends T ? WithParams<'', {}> : T;
|
|
1242
|
+
|
|
1307
1243
|
declare type TupleOf<T extends Param[]> = {
|
|
1308
1244
|
[K in keyof T]: ExtractParamType<T[K]>;
|
|
1309
1245
|
};
|
|
@@ -1448,7 +1384,7 @@ export declare type WithHooks = {
|
|
|
1448
1384
|
onAfterRouteLeave?: MaybeArray<AfterRouteHook>;
|
|
1449
1385
|
};
|
|
1450
1386
|
|
|
1451
|
-
declare type WithHost<THost extends string |
|
|
1387
|
+
declare type WithHost<THost extends string | WithParams = string | WithParams> = {
|
|
1452
1388
|
/**
|
|
1453
1389
|
* Host part of URL.
|
|
1454
1390
|
*/
|
|
@@ -1467,6 +1403,15 @@ declare type WithoutParent = {
|
|
|
1467
1403
|
parent?: never;
|
|
1468
1404
|
};
|
|
1469
1405
|
|
|
1406
|
+
declare type WithParams<TValue extends string = string, TParams extends ParamsWithParamNameExtracted<TValue> = Record<string, Param | undefined>> = {
|
|
1407
|
+
value: TValue;
|
|
1408
|
+
params: string extends TValue ? Record<string, Param> : Identity<ExtractParamsFromString<TValue, TParams>>;
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
export declare function withParams<const TValue extends string, const TParams extends ParamsWithParamNameExtracted<TValue>>(value: TValue, params: TParams): WithParams<TValue, TParams>;
|
|
1412
|
+
|
|
1413
|
+
export declare function withParams(): WithParams<'', {}>;
|
|
1414
|
+
|
|
1470
1415
|
declare type WithParent<TParent extends Route = Route> = {
|
|
1471
1416
|
parent: TParent;
|
|
1472
1417
|
};
|