@kitbag/router 0.7.0 → 0.7.1
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/README.md +7 -6
- package/dist/kitbag-router.d.ts +80 -21
- package/dist/kitbag-router.js +924 -844
- package/dist/kitbag-router.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Type safe router for Vue.js
|
|
|
11
11
|
|
|
12
12
|
## Getting Started
|
|
13
13
|
|
|
14
|
-
Get Started with our [documentation](https://kitbag-router.netlify.app/)
|
|
14
|
+
Get Started with our [documentation](https://kitbag-router.netlify.app/) or our [intro video](https://kitbag-router.netlify.app/)
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -75,26 +75,27 @@ declare module '@kitbag/router' {
|
|
|
75
75
|
To navigate to another route, you can use `router.push`. This method will update the URL for the browser and also add the URL into the history so when a user uses the back button on their browser it will behave as expected.
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
|
+
import { defineAsyncComponent } from 'vue'
|
|
78
79
|
import { createRoute, useRouter } from '@kitbag/router'
|
|
79
80
|
|
|
80
81
|
const user = createRoute({
|
|
81
82
|
name: 'user',
|
|
82
83
|
path: '/user',
|
|
83
|
-
component:
|
|
84
|
+
component: defineAsyncComponent(() => import('./UserPage.vue')),
|
|
84
85
|
})
|
|
85
86
|
|
|
86
87
|
const profile = createRoute({
|
|
87
88
|
parent: user,
|
|
88
89
|
name: 'profile',
|
|
89
90
|
path: '/profile',
|
|
90
|
-
component:
|
|
91
|
+
component: defineAsyncComponent(() => import('./ProfilePage.vue')),
|
|
91
92
|
})
|
|
92
93
|
|
|
93
94
|
const settings = createRoute({
|
|
94
95
|
parent: user,
|
|
95
96
|
name: 'settings',
|
|
96
97
|
path: '/settings',
|
|
97
|
-
component:
|
|
98
|
+
component: defineAsyncComponent(() => import('./SettingsPage.vue')),
|
|
98
99
|
})
|
|
99
100
|
|
|
100
101
|
const router = useRouter([user, profile, settings])
|
|
@@ -116,7 +117,7 @@ This `source` argument is type safe, expecting either a Url or a valid route "ke
|
|
|
116
117
|
If you only wish to change the params on the current route you can use `router.route.update`.
|
|
117
118
|
|
|
118
119
|
```ts
|
|
119
|
-
router.route.update('myParam'
|
|
120
|
+
router.route.update('myParam', 123)
|
|
120
121
|
```
|
|
121
122
|
|
|
122
123
|
or for setting multiple params at once
|
|
@@ -162,6 +163,6 @@ This component gives the router the power to change the URL without reloading th
|
|
|
162
163
|
[netlify-badge]: https://api.netlify.com/api/v1/badges/c12f79b8-49f9-4529-bc23-f8ffca8919a3/deploy-status
|
|
163
164
|
[netlify-url]: https://app.netlify.com/sites/kitbag-router/deploys
|
|
164
165
|
[discord-badge]: https://img.shields.io/discord/1079625926024900739?logo=discord&label=Discord
|
|
165
|
-
[discord-url]: https://discord.gg/
|
|
166
|
+
[discord-url]: https://discord.gg/zw7dpcc5HV
|
|
166
167
|
[stackblitz-badge]: https://developer.stackblitz.com/img/open_in_stackblitz_small.svg
|
|
167
168
|
[stackblitz-url]: https://stackblitz.com/~/github.com/kitbagjs/router-preview
|
package/dist/kitbag-router.d.ts
CHANGED
|
@@ -123,6 +123,8 @@ declare type BuiltInRejectionType = typeof builtInRejections[number];
|
|
|
123
123
|
|
|
124
124
|
declare type CombineKey<TParentKey extends string | undefined, TChildKey extends string | undefined> = StringHasValue<TParentKey> extends true ? StringHasValue<TChildKey> extends true ? `${TParentKey}.${TChildKey}` : TParentKey : StringHasValue<TChildKey> extends true ? TChildKey : '';
|
|
125
125
|
|
|
126
|
+
declare type CombineMeta<TParent extends Record<string, unknown>, TChild extends Record<string, unknown>> = TParent & TChild;
|
|
127
|
+
|
|
126
128
|
declare type CombinePath<TParent extends Path, TChild extends Path> = ToPath<TParent> extends {
|
|
127
129
|
path: infer TParentPath extends string;
|
|
128
130
|
params: infer TParentParams extends Record<string, unknown>;
|
|
@@ -141,6 +143,8 @@ declare type CombineQuery<TParent extends Query, TChild extends Query> = ToQuery
|
|
|
141
143
|
|
|
142
144
|
declare type CombineQueryString<TParent extends string | undefined, TChild extends string | undefined> = StringHasValue<TParent> extends true ? StringHasValue<TChild> extends true ? `${TParent}&${TChild}` : TParent : TChild;
|
|
143
145
|
|
|
146
|
+
declare type CombineState<TParent extends Record<string, Param>, TChild extends Record<string, Param>> = TParent & TChild;
|
|
147
|
+
|
|
144
148
|
/**
|
|
145
149
|
* Creates a component wrapper which has no props itself but mounts another component within while binding its props
|
|
146
150
|
*
|
|
@@ -177,17 +181,17 @@ export declare function createParam<TParam extends Param>(param: TParam): ParamG
|
|
|
177
181
|
|
|
178
182
|
export declare function createParam<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
|
|
179
183
|
|
|
180
|
-
export declare function createRoute<const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithoutComponents & WithoutParent): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery
|
|
184
|
+
export declare function createRoute<const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithoutComponents & WithoutParent & (WithState<TState> | WithoutState)): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery>, TMeta, TState>;
|
|
181
185
|
|
|
182
|
-
export declare function createRoute<const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithoutComponents & WithParent<TParent>): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery
|
|
186
|
+
export declare function createRoute<const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithoutComponents & WithParent<TParent> & (WithState<TState> | WithoutState)): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery>>, CombineMeta<TMeta, TParent['meta']>, CombineState<TState, TParent['state']>>;
|
|
183
187
|
|
|
184
|
-
export declare function createRoute<TComponent extends Component, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponent<TComponent, RouteParams<TPath, TQuery>> & WithoutParent): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery
|
|
188
|
+
export declare function createRoute<TComponent extends Component, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponent<TComponent, RouteParams<TPath, TQuery>> & WithoutParent & (WithState<TState> | WithoutState)): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery>, TMeta, TState>;
|
|
185
189
|
|
|
186
|
-
export declare function createRoute<TComponent extends Component, const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponent<TComponent, RouteParams<TPath, TQuery, TParent>> & WithParent<TParent>): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery
|
|
190
|
+
export declare function createRoute<TComponent extends Component, const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponent<TComponent, RouteParams<TPath, TQuery, TParent>> & WithParent<TParent> & (WithState<TState> | WithoutState)): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery>>, CombineMeta<TMeta, TParent['meta']>, CombineState<TState, TParent['state']>>;
|
|
187
191
|
|
|
188
|
-
export declare function createRoute<TComponents extends Record<string, Component>, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponents<TComponents, RouteParams<TPath, TQuery>> & WithoutParent): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery
|
|
192
|
+
export declare function createRoute<TComponents extends Record<string, Component>, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponents<TComponents, RouteParams<TPath, TQuery>> & WithoutParent & (WithState<TState> | WithoutState)): Route<ToKey<TName>, Host<'', {}>, ToPath<TPath>, ToQuery<TQuery>, TMeta, TState>;
|
|
189
193
|
|
|
190
|
-
export declare function createRoute<TComponents extends Record<string, Component>, const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponents<TComponents, RouteParams<TPath, TQuery, TParent>> & WithParent<TParent>): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery
|
|
194
|
+
export declare function createRoute<TComponents extends Record<string, Component>, const TParent extends Route, const TName extends string | undefined = undefined, const TPath extends string | Path | undefined = undefined, const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record<string, Param> = Record<string, Param>>(options: CreateRouteOptions<TName, TPath, TQuery, TMeta> & WithHooks & WithComponents<TComponents, RouteParams<TPath, TQuery, TParent>> & WithParent<TParent> & (WithState<TState> | WithoutState)): Route<CombineKey<TParent['key'], ToKey<TName>>, Host<'', {}>, CombinePath<TParent['path'], ToPath<TPath>>, CombineQuery<TParent['query'], ToQuery<TQuery>>, CombineMeta<TMeta, TParent['meta']>, CombineState<TState, TParent['state']>>;
|
|
191
195
|
|
|
192
196
|
export declare type CreateRouteOptions<TName extends string | undefined = string | undefined, TPath extends string | Path | undefined = string | Path | undefined, TQuery extends string | Query | undefined = string | Query | undefined, TMeta extends RouteMeta = RouteMeta> = {
|
|
193
197
|
/**
|
|
@@ -211,7 +215,7 @@ export declare type CreateRouteOptions<TName extends string | undefined = string
|
|
|
211
215
|
/**
|
|
212
216
|
* The Route properties originally provided to `createRoute`. The only change is normalizing meta to always default to an empty object.
|
|
213
217
|
*/
|
|
214
|
-
|
|
218
|
+
declare type CreateRouteOptionsMatched = CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithComponent | WithComponents | WithoutComponents) & (WithParent | WithoutParent) & (WithState | WithoutState) & {
|
|
215
219
|
meta: RouteMeta;
|
|
216
220
|
};
|
|
217
221
|
|
|
@@ -335,6 +339,14 @@ declare type ExtractRouteParamTypesWithoutLosingOptional<TRoute> = TRoute extend
|
|
|
335
339
|
};
|
|
336
340
|
} ? ExtractParamTypesWithoutLosingOptional<HostParams & PathParams & QueryParams> : Record<string, unknown>;
|
|
337
341
|
|
|
342
|
+
declare type ExtractRouteStateParamsAsOptional<T extends Record<string, Param>> = ExtractParamTypes<{
|
|
343
|
+
[K in keyof T as K extends string ? `?${K}` : never]: T[K];
|
|
344
|
+
}>;
|
|
345
|
+
|
|
346
|
+
declare type ExtractStateParams<TRoute> = TRoute extends {
|
|
347
|
+
state: infer TState extends Record<string, Param>;
|
|
348
|
+
} ? ExtractParamTypes<TState> : Record<string, unknown>;
|
|
349
|
+
|
|
338
350
|
declare type Host<THost extends string = string, TParams extends HostParamsWithParamNameExtracted<THost> = Record<string, Param | undefined>> = {
|
|
339
351
|
host: THost;
|
|
340
352
|
params: string extends THost ? Record<string, Param> : Identity<ExtractParamsFromHostString<THost, TParams>>;
|
|
@@ -634,6 +646,10 @@ declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
634
646
|
* Key value pair for route params, values will be the user provided value from current browser location.
|
|
635
647
|
*/
|
|
636
648
|
params: ExtractRouteParamTypes<TRoute>;
|
|
649
|
+
/**
|
|
650
|
+
* Type for additional data intended to be stored in history state.
|
|
651
|
+
*/
|
|
652
|
+
state: ExtractRouteStateParamsAsOptional<TRoute['state']>;
|
|
637
653
|
}>;
|
|
638
654
|
|
|
639
655
|
declare type ResolvedRouteQuery = {
|
|
@@ -647,13 +663,11 @@ declare type ResolvedRouteQuery = {
|
|
|
647
663
|
* @template TPath - The type or structure of the route's path.
|
|
648
664
|
* @template TQuery - The type or structure of the query parameters associated with the route.
|
|
649
665
|
*/
|
|
650
|
-
export declare type Route<TKey extends string = string, THost extends Host = Host, TPath extends Path = Path, TQuery extends Query = Query, TMeta extends RouteMeta = RouteMeta> = {
|
|
666
|
+
export declare type Route<TKey extends string = string, THost extends Host = Host, TPath extends Path = Path, TQuery extends Query = Query, TMeta extends RouteMeta = RouteMeta, TState extends Record<string, Param> = Record<string, Param>> = {
|
|
651
667
|
/**
|
|
652
668
|
* The specific route properties that were matched in the current route.
|
|
653
669
|
*/
|
|
654
|
-
matched: CreateRouteOptionsMatched
|
|
655
|
-
meta: TMeta;
|
|
656
|
-
};
|
|
670
|
+
matched: CreateRouteOptionsMatched;
|
|
657
671
|
/**
|
|
658
672
|
* The specific route properties that were matched in the current route, including any ancestors.
|
|
659
673
|
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
@@ -675,6 +689,14 @@ export declare type Route<TKey extends string = string, THost extends Host = Hos
|
|
|
675
689
|
* Represents the structured query of the route, including query params.
|
|
676
690
|
*/
|
|
677
691
|
query: TQuery;
|
|
692
|
+
/**
|
|
693
|
+
* Represents additional metadata associated with a route, combined with any parents.
|
|
694
|
+
*/
|
|
695
|
+
meta: TMeta;
|
|
696
|
+
/**
|
|
697
|
+
* Represents the schema of the route state, combined with any parents.
|
|
698
|
+
*/
|
|
699
|
+
state: TState;
|
|
678
700
|
depth: number;
|
|
679
701
|
};
|
|
680
702
|
|
|
@@ -882,9 +904,16 @@ export declare type RouterOptions = {
|
|
|
882
904
|
*/
|
|
883
905
|
initialUrl?: string;
|
|
884
906
|
/**
|
|
885
|
-
* Specifies the history mode for the router, such as
|
|
907
|
+
* Specifies the history mode for the router, such as "browser", "memory", or "hash".
|
|
908
|
+
*
|
|
909
|
+
* @default "auto"
|
|
886
910
|
*/
|
|
887
911
|
historyMode?: RouterHistoryMode;
|
|
912
|
+
/**
|
|
913
|
+
* Base path to be prepended to any URL. Can be used for Vue applications that run in nested folder for domain.
|
|
914
|
+
* For example having `base` of `/foo` would assume all routes should start with `your.domain.com/foo`.
|
|
915
|
+
*/
|
|
916
|
+
base?: string;
|
|
888
917
|
} & RouterRejectionComponents;
|
|
889
918
|
|
|
890
919
|
declare type RouterPush<TRoutes extends Routes = any> = {
|
|
@@ -892,11 +921,12 @@ declare type RouterPush<TRoutes extends Routes = any> = {
|
|
|
892
921
|
(source: Url, options?: RouterPushOptions): Promise<void>;
|
|
893
922
|
};
|
|
894
923
|
|
|
895
|
-
declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes
|
|
924
|
+
declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByKey<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByKey<TRoutes, TSource>>];
|
|
896
925
|
|
|
897
|
-
declare type RouterPushOptions = {
|
|
926
|
+
declare type RouterPushOptions<TState = unknown> = {
|
|
898
927
|
query?: Record<string, string>;
|
|
899
928
|
replace?: boolean;
|
|
929
|
+
state?: Partial<TState>;
|
|
900
930
|
};
|
|
901
931
|
|
|
902
932
|
export declare type RouterReject = (type: RouterRejectionType) => void;
|
|
@@ -919,9 +949,12 @@ declare type RouterReplace<TRoutes extends Routes> = {
|
|
|
919
949
|
(source: Url, options?: RouterReplaceOptions): Promise<void>;
|
|
920
950
|
};
|
|
921
951
|
|
|
922
|
-
declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterReplaceOptions] : [params: TParams, options?: RouterReplaceOptions];
|
|
952
|
+
declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesKey<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterReplaceOptions<RouteStateByKey<TRoutes, TSource>>] : [params: TParams, options?: RouterReplaceOptions<RouteStateByKey<TRoutes, TSource>>];
|
|
923
953
|
|
|
924
|
-
declare type RouterReplaceOptions =
|
|
954
|
+
declare type RouterReplaceOptions<TState = unknown> = {
|
|
955
|
+
query?: Record<string, string>;
|
|
956
|
+
state?: Partial<TState>;
|
|
957
|
+
};
|
|
925
958
|
|
|
926
959
|
declare type RouterResolve<TRoutes extends Routes> = {
|
|
927
960
|
<TSource extends RoutesKey<TRoutes>>(source: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): string;
|
|
@@ -938,6 +971,7 @@ declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = Readonl
|
|
|
938
971
|
key: TRoute['key'];
|
|
939
972
|
matched: TRoute['matched'];
|
|
940
973
|
matches: TRoute['matches'];
|
|
974
|
+
state: TRoute['state'];
|
|
941
975
|
query: ResolvedRouteQuery;
|
|
942
976
|
params: Writable<TRoute['params']>;
|
|
943
977
|
update: RouteUpdate<TRoute>;
|
|
@@ -958,10 +992,16 @@ name?: string | undefined;
|
|
|
958
992
|
default?: ((props: {
|
|
959
993
|
route: Readonly<{
|
|
960
994
|
key: string;
|
|
961
|
-
matched:
|
|
995
|
+
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
|
|
962
996
|
meta: Record<string, unknown>;
|
|
963
997
|
};
|
|
964
|
-
matches:
|
|
998
|
+
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
|
|
999
|
+
meta: Record<string, unknown>;
|
|
1000
|
+
})[];
|
|
1001
|
+
state: {
|
|
1002
|
+
[x: string]: any;
|
|
1003
|
+
[x: number]: any;
|
|
1004
|
+
};
|
|
965
1005
|
query: ResolvedRouteQuery;
|
|
966
1006
|
params: Writable< {
|
|
967
1007
|
[x: string]: any;
|
|
@@ -987,10 +1027,16 @@ name?: string | undefined;
|
|
|
987
1027
|
default?: ((props: {
|
|
988
1028
|
route: Readonly<{
|
|
989
1029
|
key: string;
|
|
990
|
-
matched:
|
|
1030
|
+
matched: CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
|
|
1031
|
+
meta: Record<string, unknown>;
|
|
1032
|
+
};
|
|
1033
|
+
matches: (CreateRouteOptions & WithHooks & (WithHost | WithoutHost) & (WithoutComponents | WithComponent | WithComponents) & (WithoutParent | WithParent) & (WithoutState | WithState) & {
|
|
991
1034
|
meta: Record<string, unknown>;
|
|
1035
|
+
})[];
|
|
1036
|
+
state: {
|
|
1037
|
+
[x: string]: any;
|
|
1038
|
+
[x: number]: any;
|
|
992
1039
|
};
|
|
993
|
-
matches: CreateRouteOptionsMatched[];
|
|
994
1040
|
query: ResolvedRouteQuery;
|
|
995
1041
|
params: Writable< {
|
|
996
1042
|
[x: string]: any;
|
|
@@ -1025,6 +1071,8 @@ declare type RoutesMap<TRoutes extends Routes = []> = {
|
|
|
1025
1071
|
[K in TRoutes[number] as AsNamedRoute<K>['key']]: AsNamedRoute<K>;
|
|
1026
1072
|
};
|
|
1027
1073
|
|
|
1074
|
+
declare type RouteStateByKey<TRoutes extends Routes, TKey extends string> = ExtractStateParams<RouteGetByKey<TRoutes, TKey>>;
|
|
1075
|
+
|
|
1028
1076
|
declare type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = ResolvedRoute extends TRoute ? {
|
|
1029
1077
|
(key: string, value: unknown, options?: RouterPushOptions): Promise<void>;
|
|
1030
1078
|
(params: Partial<TRoute['params']>, options?: RouterPushOptions): Promise<void>;
|
|
@@ -1206,10 +1254,21 @@ declare type WithoutParent = {
|
|
|
1206
1254
|
parent?: never;
|
|
1207
1255
|
};
|
|
1208
1256
|
|
|
1257
|
+
declare type WithoutState = {
|
|
1258
|
+
state?: never;
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1209
1261
|
declare type WithParent<TParent extends Route = Route> = {
|
|
1210
1262
|
parent: TParent;
|
|
1211
1263
|
};
|
|
1212
1264
|
|
|
1265
|
+
declare type WithState<TState extends Record<string, Param> = Record<string, Param>> = {
|
|
1266
|
+
/**
|
|
1267
|
+
* Type params for additional data intended to be stored in history state, all keys will be optional unless a default is provided.
|
|
1268
|
+
*/
|
|
1269
|
+
state: TState;
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1213
1272
|
declare type Writable<T> = {
|
|
1214
1273
|
-readonly [P in keyof T]: T[P];
|
|
1215
1274
|
};
|
|
@@ -1217,7 +1276,7 @@ declare type Writable<T> = {
|
|
|
1217
1276
|
export { }
|
|
1218
1277
|
|
|
1219
1278
|
|
|
1220
|
-
declare module '
|
|
1279
|
+
declare module 'vue' {
|
|
1221
1280
|
interface GlobalComponents {
|
|
1222
1281
|
RouterView: typeof RouterView;
|
|
1223
1282
|
RouterLink: typeof RouterLink;
|