@kitbag/router 0.16.1 → 0.17.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 +64 -25
- package/dist/kitbag-router.js +1325 -1052
- package/dist/kitbag-router.umd.cjs +4 -1
- package/package.json +12 -6
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -11,6 +11,34 @@ import { PublicProps } from 'vue';
|
|
|
11
11
|
import { Ref } from 'vue';
|
|
12
12
|
import { UnwrapRef } from 'vue';
|
|
13
13
|
import { VNode } from 'vue';
|
|
14
|
+
import { ZodSchema } from 'zod';
|
|
15
|
+
|
|
16
|
+
declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
|
|
18
|
+
declare type __VLS_Props = {
|
|
19
|
+
name?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare function __VLS_template(): {
|
|
23
|
+
attrs: Partial<{}>;
|
|
24
|
+
slots: Readonly<{
|
|
25
|
+
default?: (props: {
|
|
26
|
+
route: RouterRoute;
|
|
27
|
+
component: Component;
|
|
28
|
+
rejection: UnwrapRef<RouterRejection>;
|
|
29
|
+
}) => VNode;
|
|
30
|
+
}> & {
|
|
31
|
+
default?: (props: {
|
|
32
|
+
route: RouterRoute;
|
|
33
|
+
component: Component;
|
|
34
|
+
rejection: UnwrapRef<RouterRejection>;
|
|
35
|
+
}) => VNode;
|
|
36
|
+
};
|
|
37
|
+
refs: {};
|
|
38
|
+
rootEl: any;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
14
42
|
|
|
15
43
|
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
16
44
|
new (): {
|
|
@@ -81,6 +109,8 @@ export declare type AfterRouteHookResponse = CallbackSuccessResponse | CallbackP
|
|
|
81
109
|
|
|
82
110
|
declare type AllPropertiesAreOptional<T> = Record<string, unknown> extends T ? true : IsEmptyObject<OnlyRequiredProperties<T>>;
|
|
83
111
|
|
|
112
|
+
export declare function arrayOf<const T extends Param[]>(...params: T): ParamGetSet<ExtractParamType<T[number]>[]>;
|
|
113
|
+
|
|
84
114
|
declare type AsNamedRoute<T extends Route> = IsRouteUnnamed<T> extends true ? never : T;
|
|
85
115
|
|
|
86
116
|
/**
|
|
@@ -353,7 +383,7 @@ declare type ExtractParamsFromPathString<TPath extends string, TParams extends R
|
|
|
353
383
|
* @template TParam - The parameter type.
|
|
354
384
|
* @returns The extracted type, or 'string' as a fallback.
|
|
355
385
|
*/
|
|
356
|
-
declare type ExtractParamType<TParam extends Param, TParamKey extends PropertyKey = string> = TParam extends ParamGetSet
|
|
386
|
+
declare type ExtractParamType<TParam extends Param, TParamKey extends PropertyKey = string> = TParam extends Required<ParamGetSet> ? Exclude<ExtractParamTypeWithoutLosingOptional<TParam, TParamKey>, undefined> : ExtractParamTypeWithoutLosingOptional<TParam, TParamKey>;
|
|
357
387
|
|
|
358
388
|
/**
|
|
359
389
|
* Transforms a record of parameter types into a type with optional properties where the original type allows undefined.
|
|
@@ -368,7 +398,7 @@ declare type ExtractParamTypesWithoutLosingOptional<TParams extends Record<strin
|
|
|
368
398
|
[K in keyof TParams as ExtractParamName<K>]: ExtractParamTypeWithoutLosingOptional<TParams[K], K>;
|
|
369
399
|
}>>;
|
|
370
400
|
|
|
371
|
-
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> : TParamKey extends `?${string}` ? string | undefined : string;
|
|
401
|
+
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;
|
|
372
402
|
|
|
373
403
|
/**
|
|
374
404
|
* Determines the type of a path parameter from a record of parameter types, considering optional parameters.
|
|
@@ -418,6 +448,10 @@ declare type ExtractStateParams<TRoute> = TRoute extends {
|
|
|
418
448
|
state: infer TState extends Record<string, Param>;
|
|
419
449
|
} ? ExtractParamTypes<TState> : Record<string, unknown>;
|
|
420
450
|
|
|
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
|
+
[K in keyof TParent['matched']['props']]: ReturnType<TParent['matched']['props'][K]>;
|
|
453
|
+
} : undefined : undefined;
|
|
454
|
+
|
|
421
455
|
declare type Hash<THash extends string | undefined = string | undefined> = {
|
|
422
456
|
value: THash;
|
|
423
457
|
};
|
|
@@ -519,6 +553,8 @@ declare type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
|
519
553
|
|
|
520
554
|
declare type LastInArray<T, TFallback = never> = T extends [...any[], infer Last] ? Last : TFallback;
|
|
521
555
|
|
|
556
|
+
export declare type LiteralParam = string | number | boolean;
|
|
557
|
+
|
|
522
558
|
declare type MakeOptional<T> = {
|
|
523
559
|
[P in WithOptionalProperties<T>]?: T[P];
|
|
524
560
|
} & {
|
|
@@ -582,7 +618,7 @@ declare type OnlyRequiredProperties<T> = {
|
|
|
582
618
|
[K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
|
|
583
619
|
};
|
|
584
620
|
|
|
585
|
-
export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON;
|
|
621
|
+
export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON | ZodSchema | LiteralParam;
|
|
586
622
|
|
|
587
623
|
declare type ParamEnd = typeof paramEnd;
|
|
588
624
|
|
|
@@ -634,7 +670,7 @@ declare type Path<TPath extends string = string, TParams extends PathParamsWithP
|
|
|
634
670
|
* })
|
|
635
671
|
* ```
|
|
636
672
|
*/
|
|
637
|
-
export declare function path<TPath extends string, TParams extends PathParamsWithParamNameExtracted<TPath>>(value: TPath, params:
|
|
673
|
+
export declare function path<const TPath extends string, const TParams extends PathParamsWithParamNameExtracted<TPath>>(value: TPath, params: TParams): Path<TPath, TParams>;
|
|
638
674
|
|
|
639
675
|
declare type PathParamsWithParamNameExtracted<TPath extends string> = {
|
|
640
676
|
[K in keyof ExtractParamsFromPathString<TPath> as ExtractParamName<K>]?: Param;
|
|
@@ -668,13 +704,22 @@ export declare type PrefetchStrategy = 'eager' | 'lazy' | 'intent';
|
|
|
668
704
|
/**
|
|
669
705
|
* Context provided to props callback functions
|
|
670
706
|
*/
|
|
671
|
-
export declare type PropsCallbackContext = {
|
|
707
|
+
export declare type PropsCallbackContext<TParent extends Route | undefined = Route | undefined> = {
|
|
672
708
|
push: CallbackContext['push'];
|
|
673
709
|
replace: CallbackContext['replace'];
|
|
674
710
|
reject: CallbackContext['reject'];
|
|
711
|
+
parent: PropsCallbackParent<TParent>;
|
|
675
712
|
};
|
|
676
713
|
|
|
677
|
-
declare type
|
|
714
|
+
declare type PropsCallbackParent<TParent extends Route | undefined = Route | undefined> = Route | undefined extends TParent ? undefined | {
|
|
715
|
+
name: string;
|
|
716
|
+
props: unknown;
|
|
717
|
+
} : TParent extends Route ? {
|
|
718
|
+
name: TParent['name'];
|
|
719
|
+
props: GetParentPropsReturnType<TParent>;
|
|
720
|
+
} : undefined;
|
|
721
|
+
|
|
722
|
+
declare type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions, undefined>>, context: PropsCallbackContext<TOptions['parent']>) => MaybePromise<ComponentProps<TComponent>>;
|
|
678
723
|
|
|
679
724
|
declare type Query<TQuery extends string = string, TQueryParams extends QueryParamsWithParamNameExtracted<TQuery> = Record<string, Param | undefined>> = {
|
|
680
725
|
value: TQuery;
|
|
@@ -702,7 +747,7 @@ declare type Query<TQuery extends string = string, TQueryParams extends QueryPar
|
|
|
702
747
|
* })
|
|
703
748
|
* ```
|
|
704
749
|
*/
|
|
705
|
-
export declare function query<TQuery extends string, TParams extends QueryParamsWithParamNameExtracted<TQuery>>(value: TQuery, params:
|
|
750
|
+
export declare function query<const TQuery extends string, const TParams extends QueryParamsWithParamNameExtracted<TQuery>>(value: TQuery, params: TParams): Query<TQuery, TParams>;
|
|
706
751
|
|
|
707
752
|
declare type QueryParamsWithParamNameExtracted<T extends string> = {
|
|
708
753
|
[K in keyof ExtractQueryParamsFromQueryString<T> as ExtractParamName<K>]?: Param;
|
|
@@ -1056,7 +1101,9 @@ to: Url | ResolvedRoute | ToCallback;
|
|
|
1056
1101
|
prefetch?: PrefetchConfig;
|
|
1057
1102
|
} & RouterPushOptions> & Readonly<{}>, {
|
|
1058
1103
|
prefetch: PrefetchConfig;
|
|
1059
|
-
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
1104
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {
|
|
1105
|
+
element: HTMLAnchorElement;
|
|
1106
|
+
}, HTMLAnchorElement>, Readonly<{
|
|
1060
1107
|
default?: (props: {
|
|
1061
1108
|
route: ResolvedRoute | undefined;
|
|
1062
1109
|
isMatch: boolean;
|
|
@@ -1201,23 +1248,7 @@ export declare type RouterRoutes<TRoutes extends Routes> = {
|
|
|
1201
1248
|
[K in keyof TRoutes]: RouterRoute<ResolvedRoute<TRoutes[K]>>;
|
|
1202
1249
|
}[number];
|
|
1203
1250
|
|
|
1204
|
-
export declare const RouterView: __VLS_WithTemplateSlots<
|
|
1205
|
-
name?: string;
|
|
1206
|
-
}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
|
|
1207
|
-
name?: string;
|
|
1208
|
-
}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, Readonly<{
|
|
1209
|
-
default?: (props: {
|
|
1210
|
-
route: RouterRoute;
|
|
1211
|
-
component: Component;
|
|
1212
|
-
rejection: UnwrapRef<RouterRejection>;
|
|
1213
|
-
}) => VNode;
|
|
1214
|
-
}> & {
|
|
1215
|
-
default?: (props: {
|
|
1216
|
-
route: RouterRoute;
|
|
1217
|
-
component: Component;
|
|
1218
|
-
rejection: UnwrapRef<RouterRejection>;
|
|
1219
|
-
}) => VNode;
|
|
1220
|
-
}>;
|
|
1251
|
+
export declare const RouterView: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
1221
1252
|
|
|
1222
1253
|
/**
|
|
1223
1254
|
* Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
|
|
@@ -1273,6 +1304,14 @@ declare type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateR
|
|
|
1273
1304
|
|
|
1274
1305
|
declare type ToState<TState extends Record<string, Param> | undefined> = TState extends undefined ? Record<string, Param> : unknown extends TState ? {} : TState;
|
|
1275
1306
|
|
|
1307
|
+
declare type TupleOf<T extends Param[]> = {
|
|
1308
|
+
[K in keyof T]: ExtractParamType<T[K]>;
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
export declare function tupleOf<const T extends Param[]>(...params: T): ParamGetSet<TupleOf<T>>;
|
|
1312
|
+
|
|
1313
|
+
export declare function unionOf<const T extends Param[]>(...params: T): ParamGetSet<ExtractParamType<T[number]>>;
|
|
1314
|
+
|
|
1276
1315
|
export declare type Url = `http://${string}` | `https://${string}` | `/${string}`;
|
|
1277
1316
|
|
|
1278
1317
|
export declare type UrlParts = {
|