@kitbag/router 0.26.1 → 0.28.0
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/components/routerLink.d.ts +5 -4
- package/dist/components/routerProgress.d.ts +18 -0
- package/dist/components/routerProgressBar.d.ts +12 -0
- package/dist/components/viewTransition.browser.spec.d.ts +1 -0
- package/dist/components/viewTransition.d.ts +16 -0
- package/dist/components/viewTransition.spec-d.d.ts +1 -0
- package/dist/compositions/useLink.d.ts +2 -2
- package/dist/compositions/useLink.spec-d.d.ts +1 -0
- package/dist/compositions/useNavigation.browser.spec.d.ts +1 -0
- package/dist/compositions/useNavigation.d.ts +5 -0
- package/dist/compositions/useViewTransition.d.ts +5 -0
- package/dist/errors/contextRedirectError.d.ts +1 -2
- package/dist/errors/unreachableRouteError.d.ts +7 -0
- package/dist/kitbag-router.js +2449 -1826
- package/dist/kitbag-router.umd.cjs +2 -2
- package/dist/main.d.ts +37 -2
- package/dist/main.spec-d.d.ts +1 -0
- package/dist/services/addAlias.d.ts +19 -0
- package/dist/services/addAlias.spec-d.d.ts +1 -0
- package/dist/services/addAlias.spec.d.ts +1 -0
- package/dist/services/addView.d.ts +3 -3
- package/dist/services/createCanonicalUrl.d.ts +14 -0
- package/dist/services/createCanonicalUrl.spec.d.ts +1 -0
- package/dist/services/createDataStore.d.ts +4 -0
- package/dist/services/createNavigationProgress.d.ts +49 -0
- package/dist/services/createNavigationProgress.spec.d.ts +1 -0
- package/dist/services/createNavigationSignals.d.ts +17 -0
- package/dist/services/createNavigationSignals.spec.d.ts +1 -0
- package/dist/services/createResolvedRoute.d.ts +10 -1
- package/dist/services/createRoute.d.ts +2 -4
- package/dist/services/createRouteValueStore.d.ts +4 -0
- package/dist/services/createRouter.d.ts +2 -2
- package/dist/services/createRouterAssets.d.ts +30 -0
- package/dist/services/createRouterHistory.d.ts +10 -2
- package/dist/services/createRouterHooks.d.ts +7 -2
- package/dist/services/createUniqueIdSequence.d.ts +0 -1
- package/dist/services/createViewTransitions.browser.spec.d.ts +1 -0
- package/dist/services/createViewTransitions.d.ts +38 -0
- package/dist/services/getMatchesForUrl.d.ts +4 -0
- package/dist/services/getRoutesForRouter.d.ts +3 -2
- package/dist/services/history.d.ts +1 -0
- package/dist/services/routeRegex.d.ts +6 -1
- package/dist/services/routeViews.d.ts +7 -0
- package/dist/services/updateResolvedRoute.d.ts +7 -0
- package/dist/services/updateResolvedRoute.spec.d.ts +1 -0
- package/dist/services/withRouteMethods.d.ts +3 -3
- package/dist/tests/loaderPrefetch.browser.spec.d.ts +1 -0
- package/dist/tests/navigationBehavior.browser.spec.d.ts +1 -0
- package/dist/tests/navigationProgress.spec.d.ts +1 -0
- package/dist/tests/viewTransitions.browser.spec.d.ts +1 -0
- package/dist/types/addAlias.d.ts +79 -0
- package/dist/types/addView.d.ts +3 -4
- package/dist/types/callbackContext.d.ts +0 -5
- package/dist/types/createRouteOptions.d.ts +23 -63
- package/dist/types/hooks.d.ts +9 -5
- package/dist/types/navigation.d.ts +38 -0
- package/dist/types/prefetch.d.ts +6 -1
- package/dist/types/props.d.ts +0 -17
- package/dist/types/redirects.d.ts +4 -0
- package/dist/types/resolved.d.ts +22 -2
- package/dist/types/route.d.ts +4 -3
- package/dist/types/routeAlias.d.ts +41 -0
- package/dist/types/routeCallbackContext.d.ts +1 -0
- package/dist/types/routeViews.d.ts +5 -7
- package/dist/types/routeWithMethods.d.ts +3 -2
- package/dist/types/router.d.ts +13 -0
- package/dist/types/routerLink.d.ts +1 -1
- package/dist/types/routerNavigationInternal.d.ts +29 -0
- package/dist/types/routerPush.d.ts +8 -0
- package/dist/types/routerReplace.d.ts +3 -0
- package/dist/types/routerRoute.d.ts +5 -1
- package/dist/types/useLink.d.ts +5 -0
- package/dist/types/viewTransition.d.ts +49 -0
- package/dist/utilities/components.d.ts +6 -2
- package/dist/utilities/getRegexMatcher.d.ts +1 -0
- package/dist/utilities/getRegexMatcher.spec.d.ts +1 -0
- package/dist/utilities/navigation.d.ts +15 -0
- package/dist/utilities/percentEncoding.d.ts +10 -0
- package/dist/utilities/percentEncoding.spec.d.ts +1 -0
- package/dist/utilities/promises.d.ts +4 -0
- package/dist/utilities/promises.spec.d.ts +1 -0
- package/dist/utilities/testHelpers.d.ts +32 -100
- package/dist/utilities/viewTransition.d.ts +11 -0
- package/dist/utilities/viewTransition.spec.d.ts +1 -0
- package/package.json +9 -8
- package/dist/services/createNavigationIds.d.ts +0 -6
- package/dist/services/createRouteViews.d.ts +0 -16
- /package/dist/{services/createNavigationIds.spec.d.ts → components/routerProgress.browser.spec.d.ts} +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { UrlPart, UrlQueryPart } from '../services/withParams';
|
|
2
|
+
import { AliasTransform } from './routeAlias';
|
|
3
|
+
import { CreatedRouteOptions } from './route';
|
|
4
|
+
import { RouteWithMethods } from './routeWithMethods';
|
|
5
|
+
import { ToUrl, Url, UrlParamsReading, UrlParamsWriting } from './url';
|
|
6
|
+
import { LastInArray } from './utilities';
|
|
7
|
+
/**
|
|
8
|
+
* The url an alias matches, in the same shapes `createRoute` takes. An alias declares its whole url:
|
|
9
|
+
* nothing is taken from the route's own path, query, or hash.
|
|
10
|
+
*/
|
|
11
|
+
export type AddAliasOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* Path part of the alias.
|
|
14
|
+
*/
|
|
15
|
+
path?: string | UrlPart | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Query (aka search) part of the alias.
|
|
18
|
+
*/
|
|
19
|
+
query?: string | UrlQueryPart | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Hash part of the alias.
|
|
22
|
+
*/
|
|
23
|
+
hash?: string | UrlPart | undefined;
|
|
24
|
+
};
|
|
25
|
+
type PathPart = string | UrlPart | undefined;
|
|
26
|
+
type QueryPart = string | UrlQueryPart | undefined;
|
|
27
|
+
type SegmentPath<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
28
|
+
path: infer TPath extends PathPart;
|
|
29
|
+
} ? TPath : undefined;
|
|
30
|
+
type SegmentQuery<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
31
|
+
query: infer TQuery extends QueryPart;
|
|
32
|
+
} ? TQuery : undefined;
|
|
33
|
+
type SegmentHash<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
34
|
+
hash: infer THash extends PathPart;
|
|
35
|
+
} ? THash : undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The url of the route's own segment: its own path, query, and hash without any ancestors. An alias
|
|
38
|
+
* stands in for this segment, so its params are what an alias transform has to produce.
|
|
39
|
+
*/
|
|
40
|
+
type SegmentUrl<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? Url : ToUrl<{
|
|
41
|
+
path: SegmentPath<TMatches>;
|
|
42
|
+
query: SegmentQuery<TMatches>;
|
|
43
|
+
hash: SegmentHash<TMatches>;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* The params an alias parses from a url, as read.
|
|
47
|
+
*/
|
|
48
|
+
type AliasParams<TOptions extends AddAliasOptions> = UrlParamsReading<ToUrl<TOptions>>;
|
|
49
|
+
/**
|
|
50
|
+
* The params the route's own segment declares, as written. What an alias transform returns.
|
|
51
|
+
*/
|
|
52
|
+
type SegmentParams<TMatches extends CreatedRouteOptions[]> = UrlParamsWriting<SegmentUrl<TMatches>>;
|
|
53
|
+
/**
|
|
54
|
+
* The transform argument for `addAlias`. Optional only when the alias's params already satisfy the
|
|
55
|
+
* segment's, since matched values pass straight through then. A shape mismatch has to be resolved at
|
|
56
|
+
* declaration time: parsing walks the params declared on the pattern doing the parsing, so a mismatch
|
|
57
|
+
* would silently read a promised param as undefined instead of failing.
|
|
58
|
+
*/
|
|
59
|
+
type AddAliasArgs<TOptions extends AddAliasOptions, TMatches extends CreatedRouteOptions[]> = AliasParams<TOptions> extends SegmentParams<TMatches> ? [transform?: AliasTransform<AliasParams<TOptions>, SegmentParams<TMatches>>] : [transform: AliasTransform<AliasParams<TOptions>, SegmentParams<TMatches>>];
|
|
60
|
+
/**
|
|
61
|
+
* Adds an alias to a route. Chainable to register several.
|
|
62
|
+
*/
|
|
63
|
+
export type RouteAddAlias<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = {
|
|
64
|
+
/**
|
|
65
|
+
* Adds a url the route also matches. The address bar keeps the alias; the route resolves as if its own
|
|
66
|
+
* url had matched. Aliases only match inbound urls: links and navigation always target the route's own
|
|
67
|
+
* url.
|
|
68
|
+
*
|
|
69
|
+
* The alias stands in for this route's own path, query, and hash, and composes with any aliases of the
|
|
70
|
+
* route's ancestors. It declares its own params, typed the same way a route's are, and any param the
|
|
71
|
+
* route's own segment declares that the alias does not is the transform's to supply.
|
|
72
|
+
*
|
|
73
|
+
* @param options - The alias's `path`, `query`, and `hash`, each taking what `createRoute` does.
|
|
74
|
+
* @param transform - Maps the alias's params into the params this route's own segment declares.
|
|
75
|
+
* Required unless the alias's params already satisfy them.
|
|
76
|
+
*/
|
|
77
|
+
addAlias: <const TOptions extends AddAliasOptions>(options: TOptions, ...args: AddAliasArgs<TOptions, TMatches>) => RouteWithMethods<TUrl, TMatches>;
|
|
78
|
+
};
|
|
79
|
+
export {};
|
package/dist/types/addView.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { ComponentProps } from '../services/component';
|
|
3
|
-
import { ComponentPropsAreOptional, PropsGetter } from './createRouteOptions';
|
|
4
3
|
import { ResolvedRoute, WithData } from './resolved';
|
|
5
4
|
import { CreatedRouteOptions, Route } from './route';
|
|
6
5
|
import { RouteCallbackContext } from './routeCallbackContext';
|
|
@@ -11,8 +10,7 @@ import { RouteView, RouteViews } from './routeViews';
|
|
|
11
10
|
import { Url } from './url';
|
|
12
11
|
import { AnyFunction, Identity, LastInArray, MaybePromise } from './utilities';
|
|
13
12
|
/**
|
|
14
|
-
* The props getter for a view added via `addView`. Receives the
|
|
15
|
-
* `createRoute` props callback: the resolved route and a context object.
|
|
13
|
+
* The props getter for a view added via `addView`. Receives the resolved route and a context object.
|
|
16
14
|
*/
|
|
17
15
|
export type AddViewPropsGetter<TRoute extends Route, TComponent extends Component> = (route: ResolvedRoute<TRoute> & WithData<TRoute>, context: AddViewPropsCallbackContext<TRoute>) => MaybePromise<ComponentProps<TComponent>>;
|
|
18
16
|
/**
|
|
@@ -20,6 +18,7 @@ export type AddViewPropsGetter<TRoute extends Route, TComponent extends Componen
|
|
|
20
18
|
* callbacks attached to a route.
|
|
21
19
|
*/
|
|
22
20
|
export type AddViewPropsCallbackContext<TRoute extends Route> = RouteCallbackContext<TRoute>;
|
|
21
|
+
type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
|
|
23
22
|
/**
|
|
24
23
|
* When the getter is omitted the default type param resolves to the wide getter type, which then
|
|
25
24
|
* "extends" itself and collapses to undefined. When a getter is provided its return type is kept — the
|
|
@@ -32,7 +31,7 @@ type NewViewProps<TRoute extends Route, TComponent extends Component, TGetter ex
|
|
|
32
31
|
* @template TName - The view's name, inferred from the `name` option.
|
|
33
32
|
* @template TGetter - The view's props getter, inferred from the `props` option.
|
|
34
33
|
*/
|
|
35
|
-
export type AddViewOptions<TName extends string | undefined = string, TGetter =
|
|
34
|
+
export type AddViewOptions<TName extends string | undefined = string, TGetter = AddViewPropsGetter<Route, Component>> = TransformerOptions<PayloadValueOf<TGetter>> & {
|
|
36
35
|
/**
|
|
37
36
|
* The name of the view, rendered by `<router-view name="..." />`. Defaults to the unnamed view.
|
|
38
37
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { RedirectStatus } from './router';
|
|
2
1
|
import { RouterPush } from './routerPush';
|
|
3
2
|
export type CallbackContextSuccess = {
|
|
4
3
|
status: 'SUCCESS';
|
|
@@ -10,10 +9,6 @@ export type CallbackContextPush = {
|
|
|
10
9
|
export type CallbackContextRedirect = {
|
|
11
10
|
status: 'REDIRECT';
|
|
12
11
|
to: Parameters<RouterPush>;
|
|
13
|
-
/**
|
|
14
|
-
* The status the redirect declared, or undefined to use the router's `redirectStatus`.
|
|
15
|
-
*/
|
|
16
|
-
redirectStatus: RedirectStatus | undefined;
|
|
17
12
|
};
|
|
18
13
|
export type CallbackContextReject = {
|
|
19
14
|
status: 'REJECT';
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NavigationBehavior } from './navigation';
|
|
2
2
|
import { Param } from './paramTypes';
|
|
3
3
|
import { PrefetchConfig } from './prefetch';
|
|
4
|
+
import { ViewTransitionConfig } from './viewTransition';
|
|
4
5
|
import { RouteMeta } from './register';
|
|
5
|
-
import { Route } from './route';
|
|
6
|
-
import { ResolvedRoute, WithData } from './resolved';
|
|
7
|
-
import { ComponentProps } from '../services/component';
|
|
8
|
-
import { PropsCallbackContext } from './props';
|
|
9
|
-
import { AnyFunction, Identity, MaybePromise } from './utilities';
|
|
6
|
+
import { Route, RouteInternal } from './route';
|
|
10
7
|
import { ToMeta } from './meta';
|
|
11
8
|
import { ToName } from './name';
|
|
12
9
|
import { UrlPart, UrlQueryPart } from '../services/withParams';
|
|
13
10
|
import { RouteContext } from './routeContext';
|
|
14
|
-
import { RouterViewProps } from '../components/routerView';
|
|
15
11
|
import { ToUrl } from './url';
|
|
16
12
|
import { CombineUrl } from '../services/combineUrl';
|
|
17
|
-
import { RouteView } from './routeViews';
|
|
18
13
|
export type WithHost<THost extends string | UrlPart = string | UrlPart> = {
|
|
19
14
|
/**
|
|
20
15
|
* Host part of URL.
|
|
@@ -31,20 +26,6 @@ export declare function isWithParent<T extends Record<string, unknown>>(options:
|
|
|
31
26
|
export type WithoutParent = {
|
|
32
27
|
parent?: never;
|
|
33
28
|
};
|
|
34
|
-
/**
|
|
35
|
-
* This type is used to strip the component and components properties from the options object
|
|
36
|
-
* when creating a Route to simplify and minimize the output type.
|
|
37
|
-
*/
|
|
38
|
-
type WithoutComponents = {
|
|
39
|
-
component: never;
|
|
40
|
-
components: never;
|
|
41
|
-
};
|
|
42
|
-
export declare function isWithComponent<T extends Record<string, unknown>>(options: T): options is T & {
|
|
43
|
-
component: Component;
|
|
44
|
-
};
|
|
45
|
-
export declare function isWithComponents<T extends Record<string, unknown>>(options: T): options is T & {
|
|
46
|
-
components: Record<string, Component>;
|
|
47
|
-
};
|
|
48
29
|
export type CreateRouteOptions<TName extends string | undefined = string | undefined, TMeta extends RouteMeta = RouteMeta> = {
|
|
49
30
|
/**
|
|
50
31
|
* Name for route, used to create route keys and in navigation.
|
|
@@ -70,6 +51,12 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
70
51
|
* Determines what assets are prefetched when router-link is rendered for this route. Overrides router level prefetch.
|
|
71
52
|
*/
|
|
72
53
|
prefetch?: PrefetchConfig;
|
|
54
|
+
/** Overrides the parent route and router navigation behavior. */
|
|
55
|
+
navigation?: NavigationBehavior;
|
|
56
|
+
/**
|
|
57
|
+
* Animates navigations to this route with the View Transitions API. Overrides router level viewTransition.
|
|
58
|
+
*/
|
|
59
|
+
viewTransition?: ViewTransitionConfig;
|
|
73
60
|
/**
|
|
74
61
|
* Type params for additional data intended to be stored in history state, all keys will be optional unless a default is provided.
|
|
75
62
|
*/
|
|
@@ -78,19 +65,6 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
78
65
|
* An optional parent route to nest this route under.
|
|
79
66
|
*/
|
|
80
67
|
parent?: Route;
|
|
81
|
-
/**
|
|
82
|
-
* An optional component to render when this route is matched.
|
|
83
|
-
*
|
|
84
|
-
* @default RouterView
|
|
85
|
-
* @deprecated Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { props })`.
|
|
86
|
-
*/
|
|
87
|
-
component?: Component;
|
|
88
|
-
/**
|
|
89
|
-
* An object of named components to render using named views
|
|
90
|
-
*
|
|
91
|
-
* @deprecated Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { name, props })`.
|
|
92
|
-
*/
|
|
93
|
-
components?: Record<string, Component>;
|
|
94
68
|
/**
|
|
95
69
|
* Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
|
|
96
70
|
*/
|
|
@@ -100,16 +74,7 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
100
74
|
*/
|
|
101
75
|
hoist?: boolean;
|
|
102
76
|
};
|
|
103
|
-
|
|
104
|
-
export type RouterViewPropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions> = (route: ResolvedRoute<ToRoute<TOptions>> & WithData<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<RouterViewProps & Record<string, unknown>>;
|
|
105
|
-
export type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
|
|
106
|
-
type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponents extends Record<string, Component> = Record<string, Component>> = {
|
|
107
|
-
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends true ? K : never]?: PropsGetter<TOptions, TComponents[K]>;
|
|
108
|
-
} & {
|
|
109
|
-
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends false ? K : never]: PropsGetter<TOptions, TComponents[K]>;
|
|
110
|
-
};
|
|
111
|
-
export type CreateRouteProps<TOptions extends CreateRouteOptions = CreateRouteOptions> = TOptions['component'] extends Component ? PropsGetter<TOptions, TOptions['component']> : TOptions['components'] extends Record<string, Component> ? RoutePropsRecord<TOptions, TOptions['components']> : RouterViewPropsGetter<TOptions>;
|
|
112
|
-
type ToMatch<TOptions extends CreateRouteOptions, TProps = undefined> = Omit<TOptions, 'meta' | 'name' | 'component' | 'components' | 'parent'> & {
|
|
77
|
+
type ToMatch<TOptions extends CreateRouteOptions> = Omit<TOptions, 'meta' | 'name' | 'parent'> & {
|
|
113
78
|
id: string;
|
|
114
79
|
name: ToName<TOptions['name']>;
|
|
115
80
|
/**
|
|
@@ -117,9 +82,9 @@ type ToMatch<TOptions extends CreateRouteOptions, TProps = undefined> = Omit<TOp
|
|
|
117
82
|
*/
|
|
118
83
|
meta: ToMeta<TOptions['meta']>;
|
|
119
84
|
/**
|
|
120
|
-
* The views this route renders, keyed by view name.
|
|
85
|
+
* The views this route renders, keyed by view name. Added by `addView`.
|
|
121
86
|
*/
|
|
122
|
-
views:
|
|
87
|
+
views: {};
|
|
123
88
|
/**
|
|
124
89
|
* The loaders this route runs, keyed by loader name. Always empty here — loaders are only added via
|
|
125
90
|
* the route's `addLoader`.
|
|
@@ -130,28 +95,23 @@ type ToMatch<TOptions extends CreateRouteOptions, TProps = undefined> = Omit<TOp
|
|
|
130
95
|
* The matches for a route, from greatest ancestor to the route itself. Each carries its own views, so
|
|
131
96
|
* there is no second tuple to keep aligned with this one.
|
|
132
97
|
*/
|
|
133
|
-
type ToMatches<TOptions extends CreateRouteOptions
|
|
98
|
+
type ToMatches<TOptions extends CreateRouteOptions> = TOptions extends {
|
|
134
99
|
parent: infer TParent extends Route;
|
|
135
|
-
} ? [...TParent['matches'], ToMatch<TOptions
|
|
136
|
-
/**
|
|
137
|
-
* Builds a views record from the props argument, which is either a single getter for the unnamed view or
|
|
138
|
-
* a record of getters keyed by view name.
|
|
139
|
-
*/
|
|
140
|
-
type PropsToViews<TProps> = [TProps] extends [AnyFunction] ? {
|
|
141
|
-
default: RouteView<ReturnType<TProps>>;
|
|
142
|
-
} : [TProps] extends [Record<string, AnyFunction>] ? {
|
|
143
|
-
[K in keyof TProps]: RouteView<ReturnType<TProps[K]>>;
|
|
144
|
-
} : {};
|
|
100
|
+
} ? [...TParent['matches'], ToMatch<TOptions>] : [ToMatch<TOptions>];
|
|
145
101
|
/**
|
|
146
102
|
* The url a route resolves to, combined with its parent's unless the route is hoisted.
|
|
147
103
|
*/
|
|
148
104
|
export type ToRouteUrl<TOptions extends CreateRouteOptions> = TOptions extends {
|
|
149
105
|
parent: infer TParent extends Route;
|
|
150
|
-
} ? TOptions['hoist'] extends true ? ToUrl<TOptions
|
|
106
|
+
} ? TOptions['hoist'] extends true ? ToUrl<TOptions> : CombineUrl<TParent, ToUrl<TOptions>> : ToUrl<TOptions>;
|
|
107
|
+
/**
|
|
108
|
+
* The matches for a route, before any views or loaders are added.
|
|
109
|
+
*/
|
|
110
|
+
export type ToRouteMatches<TOptions extends CreateRouteOptions> = ToMatches<TOptions>;
|
|
111
|
+
export type ToRoute<TOptions extends CreateRouteOptions> = CreateRouteOptions extends TOptions ? Route : Route<ToRouteUrl<TOptions>, ToRouteMatches<TOptions>>;
|
|
151
112
|
/**
|
|
152
|
-
*
|
|
113
|
+
* Nests a route under its parent. A hoisted route keeps everything of its parent's except the url: its own
|
|
114
|
+
* url stands alone and it inherits none of the parent's aliases.
|
|
153
115
|
*/
|
|
154
|
-
export
|
|
155
|
-
export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined = undefined> = CreateRouteOptions extends TOptions ? Route : Route<ToRouteUrl<TOptions>, ToRouteMatches<TOptions, TProps>>;
|
|
156
|
-
export declare function combineRoutes(parent: Route, child: Route): Route;
|
|
116
|
+
export declare function combineRoutes(parent: Route, child: Route, hoisted?: boolean): Route & RouteInternal;
|
|
157
117
|
export {};
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { RouteContext, RouteContextToRejection, RouteContextToRoute } from './ro
|
|
|
10
10
|
import { RouterAbort } from './routerAbort';
|
|
11
11
|
import { CallbackContextAbort, CallbackContextPush, CallbackContextRedirect, CallbackContextReject, CallbackContextSuccess } from './callbackContext';
|
|
12
12
|
import { RouteUpdate } from './routeUpdate';
|
|
13
|
+
import { NavigationProgressTracker } from '../services/createNavigationProgress';
|
|
13
14
|
export declare function getHooks(value: Record<string, unknown> | undefined | null): Hooks[];
|
|
14
15
|
export declare function combineHooks(parent: Route, child: Route): Hooks[];
|
|
15
16
|
export type InternalRouteHooks<TRoute extends Route = Route, TContext extends RouteContext[] | undefined = undefined> = {
|
|
@@ -89,6 +90,7 @@ type AfterHookContext<TRoute extends Route, TRoutes extends Routes, TRejections
|
|
|
89
90
|
push: RouterPush<TRoutes>;
|
|
90
91
|
replace: RouterReplace<TRoutes>;
|
|
91
92
|
update: RouteUpdate<ResolvedRouteUnion<TRoute>>;
|
|
93
|
+
signal: AbortSignal;
|
|
92
94
|
};
|
|
93
95
|
type BeforeHookContext<TRouteTo extends Route, TRoutes extends Routes, TRejections extends Rejections> = {
|
|
94
96
|
reject: RouterReject<TRejections>;
|
|
@@ -96,6 +98,7 @@ type BeforeHookContext<TRouteTo extends Route, TRoutes extends Routes, TRejectio
|
|
|
96
98
|
replace: RouterReplace<TRoutes>;
|
|
97
99
|
update: RouteUpdate<ResolvedRouteUnion<TRouteTo>>;
|
|
98
100
|
abort: RouterAbort;
|
|
101
|
+
signal: AbortSignal;
|
|
99
102
|
};
|
|
100
103
|
export type BeforeEnterHookContext<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = BeforeHookContext<TRouteTo, TRoutes, TRejections> & {
|
|
101
104
|
from: ResolvedRouteUnion<TRouteFrom> | null;
|
|
@@ -129,14 +132,15 @@ export type AfterLeaveHook<TRoutes extends Routes = Routes, TRejections extends
|
|
|
129
132
|
export type AddAfterLeaveHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = (hook: AfterLeaveHook<TRoutes, TRejections, TRouteTo, TRouteFrom>) => HookRemove;
|
|
130
133
|
export type BeforeHookResponse = CallbackContextSuccess | CallbackContextPush | CallbackContextRedirect | CallbackContextReject | CallbackContextAbort;
|
|
131
134
|
export type AfterHookResponse = CallbackContextSuccess | CallbackContextPush | CallbackContextReject;
|
|
132
|
-
export type
|
|
135
|
+
export type HookRunnerContext<TRoutes extends Routes = Routes> = {
|
|
133
136
|
to: RouterResolvedRouteUnion<TRoutes> | null;
|
|
134
137
|
from: RouterResolvedRouteUnion<TRoutes> | null;
|
|
138
|
+
signal: AbortSignal;
|
|
139
|
+
};
|
|
140
|
+
export type BeforeHookRunner = <TRoutes extends Routes>(context: HookRunnerContext<TRoutes> & {
|
|
141
|
+
progress?: NavigationProgressTracker;
|
|
135
142
|
}) => Promise<BeforeHookResponse>;
|
|
136
|
-
export type AfterHookRunner = <TRoutes extends Routes>(context:
|
|
137
|
-
to: RouterResolvedRouteUnion<TRoutes> | null;
|
|
138
|
-
from: RouterResolvedRouteUnion<TRoutes> | null;
|
|
139
|
-
}) => Promise<AfterHookResponse>;
|
|
143
|
+
export type AfterHookRunner = <TRoutes extends Routes>(context: HookRunnerContext<TRoutes>) => Promise<AfterHookResponse>;
|
|
140
144
|
export type RejectionHookContext<TRoutes extends Routes = Routes, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = {
|
|
141
145
|
to: ResolvedRouteUnion<TRouteTo> | null;
|
|
142
146
|
from: ResolvedRouteUnion<TRouteFrom> | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { ResolvedRoute } from './resolved';
|
|
3
|
+
/** Whether navigation commits immediately or waits for its props, loaders, and components. */
|
|
4
|
+
export type NavigationBehavior = 'progressive' | 'blocking';
|
|
5
|
+
/**
|
|
6
|
+
* The navigation under way, if any, and how far it has come. A navigation is under way from the moment it
|
|
7
|
+
* is asked for until the route it leads to has everything it renders with, or it is rejected, aborted, or
|
|
8
|
+
* superseded. Its progress is counted in the units of work it waits on: its before hooks, its props getters
|
|
9
|
+
* and loaders, and the async components it renders. Every unit counts the same.
|
|
10
|
+
*/
|
|
11
|
+
export type UseNavigation = {
|
|
12
|
+
/**
|
|
13
|
+
* True while a navigation is under way.
|
|
14
|
+
*/
|
|
15
|
+
pending: ComputedRef<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* The route the navigation under way leads to. Null when idle, or when the url matches no route.
|
|
18
|
+
*/
|
|
19
|
+
to: ComputedRef<ResolvedRoute | null>;
|
|
20
|
+
/**
|
|
21
|
+
* The route the navigation under way leaves. Null when idle, or for the first navigation.
|
|
22
|
+
*/
|
|
23
|
+
from: ComputedRef<ResolvedRoute | null>;
|
|
24
|
+
/**
|
|
25
|
+
* How many units have settled so far. Equal to `total` once a navigation reaches its route, and zero
|
|
26
|
+
* once one ends by being rejected or aborted.
|
|
27
|
+
*/
|
|
28
|
+
settled: ComputedRef<number>;
|
|
29
|
+
/**
|
|
30
|
+
* How many units the navigation waits on in all. Known up front except for before hooks, which are
|
|
31
|
+
* added as they start.
|
|
32
|
+
*/
|
|
33
|
+
total: ComputedRef<number>;
|
|
34
|
+
/**
|
|
35
|
+
* The share of units settled, between 0 and 1. Zero while idle.
|
|
36
|
+
*/
|
|
37
|
+
progress: ComputedRef<number>;
|
|
38
|
+
};
|
package/dist/types/prefetch.d.ts
CHANGED
|
@@ -11,10 +11,15 @@ export type PrefetchConfigOptions = {
|
|
|
11
11
|
*/
|
|
12
12
|
components?: boolean | PrefetchStrategy;
|
|
13
13
|
/**
|
|
14
|
-
* When true
|
|
14
|
+
* When true route props will be prefetched
|
|
15
15
|
* @default false
|
|
16
16
|
*/
|
|
17
17
|
props?: boolean | PrefetchStrategy;
|
|
18
|
+
/**
|
|
19
|
+
* When true route loaders will be prefetched
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
loaders?: boolean | PrefetchStrategy;
|
|
18
23
|
};
|
|
19
24
|
/**
|
|
20
25
|
* Determines what assets are prefetched. A boolean enables or disables all prefetching.
|
package/dist/types/props.d.ts
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import { CreateRouteOptions } from './createRouteOptions';
|
|
2
1
|
import { Route } from './route';
|
|
3
|
-
import { RouterReject } from './routerReject';
|
|
4
|
-
import { RouterPush } from './routerPush';
|
|
5
|
-
import { RouterReplace } from './routerReplace';
|
|
6
|
-
import { ExtractRouteContextRejections, ExtractRouteContextRoutes } from './routeContext';
|
|
7
|
-
import { ResolvedRoute } from './resolved';
|
|
8
|
-
import { RouteUpdate } from './routeUpdate';
|
|
9
2
|
import { LoadersDataReturnType } from './routeLoaders';
|
|
10
3
|
import { ViewsPropsReturnType } from './routeViews';
|
|
11
4
|
import { LastInArray } from './utilities';
|
|
12
|
-
/**
|
|
13
|
-
* Context provided to props callback functions
|
|
14
|
-
*/
|
|
15
|
-
export type PropsCallbackContext<TRoute extends Route = Route, TOptions extends CreateRouteOptions = CreateRouteOptions> = {
|
|
16
|
-
reject: RouterReject<ExtractRouteContextRejections<TOptions>>;
|
|
17
|
-
push: RouterPush<[TRoute] | ExtractRouteContextRoutes<TOptions>>;
|
|
18
|
-
replace: RouterReplace<[TRoute] | ExtractRouteContextRoutes<TOptions>>;
|
|
19
|
-
update: RouteUpdate<ResolvedRoute<TRoute>>;
|
|
20
|
-
parent: PropsCallbackParent<TOptions['parent']>;
|
|
21
|
-
};
|
|
22
5
|
export type PropsCallbackParent<TParent extends Route | undefined = Route | undefined> = Route | undefined extends TParent ? undefined | {
|
|
23
6
|
name: string;
|
|
24
7
|
props: unknown;
|
|
@@ -16,6 +16,10 @@ export type RouteRedirects<TRoute extends Route = Route> = {
|
|
|
16
16
|
};
|
|
17
17
|
type RedirectHookContext<TRoutes extends Routes> = {
|
|
18
18
|
replace: RouterReplace<TRoutes>;
|
|
19
|
+
/**
|
|
20
|
+
* The router's status for a redirect that does not declare its own.
|
|
21
|
+
*/
|
|
22
|
+
redirectStatus: RedirectStatus;
|
|
19
23
|
};
|
|
20
24
|
export type RedirectHook<TRoutes extends Routes = Routes, TRouteTo extends Route = TRoutes[number]> = (to: ResolvedRouteUnion<TRouteTo>, context: RedirectHookContext<TRoutes>) => MaybePromise<void>;
|
|
21
25
|
export type RouteRedirectCallback<TRouteTo extends Route = Route, TRouteFrom extends Route = Route> = (params: UrlParamsReading<TRouteFrom>) => UrlParamsWriting<TRouteTo>;
|
package/dist/types/resolved.d.ts
CHANGED
|
@@ -3,11 +3,25 @@ import { LastInArray } from './utilities';
|
|
|
3
3
|
import { ExtractRouteStateParamsAsOptional } from './state';
|
|
4
4
|
import { UrlString } from './urlString';
|
|
5
5
|
import { UrlParamsReading } from './url';
|
|
6
|
-
import { GetTitleCallback } from './routeTitle';
|
|
6
|
+
import { GetRouteTitle, GetTitleCallback } from './routeTitle';
|
|
7
|
+
import { Hooks } from '../models/hooks';
|
|
7
8
|
/**
|
|
8
9
|
* The match a route resolved to, which is the last of its matches. Falls back to the wide match type when
|
|
9
10
|
* the matches are not a concrete tuple, so an unregistered router stays assignable.
|
|
10
11
|
*/
|
|
12
|
+
export declare const IS_RESOLVED_ROUTE_SYMBOL: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* A type guard for determining if a value is a ResolvedRoute.
|
|
15
|
+
* @param value - The value to check.
|
|
16
|
+
* @returns `true` if the value is a ResolvedRoute, otherwise `false`.
|
|
17
|
+
* @group Type Guards
|
|
18
|
+
*/
|
|
19
|
+
export declare function isResolvedRoute(value: unknown): value is ResolvedRoute & ResolvedRouteInternal;
|
|
20
|
+
export type ResolvedRouteInternal = {
|
|
21
|
+
[IS_RESOLVED_ROUTE_SYMBOL]: true;
|
|
22
|
+
hooks: Hooks[];
|
|
23
|
+
getRouteTitle: GetRouteTitle;
|
|
24
|
+
};
|
|
11
25
|
type MatchedRoute<TMatches> = LastInArray<TMatches, CreatedRouteOptions> extends infer TMatched ? unknown extends TMatched ? CreatedRouteOptions : TMatched : never;
|
|
12
26
|
/**
|
|
13
27
|
* Represents a route that the router has matched to current browser location.
|
|
@@ -40,9 +54,15 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
40
54
|
*/
|
|
41
55
|
state: ExtractRouteStateParamsAsOptional<TRoute['state']>;
|
|
42
56
|
/**
|
|
43
|
-
* String value of the resolved URL.
|
|
57
|
+
* String value of the resolved URL. When the route was matched through an alias this is the alias url,
|
|
58
|
+
* so navigating to it again stays where the user is.
|
|
44
59
|
*/
|
|
45
60
|
href: UrlString;
|
|
61
|
+
/**
|
|
62
|
+
* String value of the route's own URL, built from its path and the resolved params. The same as `href`
|
|
63
|
+
* unless the route was matched through an alias.
|
|
64
|
+
*/
|
|
65
|
+
canonical: UrlString;
|
|
46
66
|
/**
|
|
47
67
|
* Query value of the route.
|
|
48
68
|
*/
|
package/dist/types/route.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Hooks } from '../models/hooks';
|
|
|
12
12
|
import { RouteRedirect } from './redirects';
|
|
13
13
|
import { RouteViews } from './routeViews';
|
|
14
14
|
import { LoadersDataReturnType, RouteLoaders } from './routeLoaders';
|
|
15
|
+
import { RouteAlias } from './routeAlias';
|
|
15
16
|
export declare const IS_ROUTE_SYMBOL: unique symbol;
|
|
16
17
|
export declare function isRoute(value: unknown): value is Route & RouteInternal;
|
|
17
18
|
export type RouteInternal = {
|
|
@@ -20,6 +21,7 @@ export type RouteInternal = {
|
|
|
20
21
|
hooks: Hooks[];
|
|
21
22
|
redirect: RouteRedirect;
|
|
22
23
|
getTitle: GetRouteTitle;
|
|
24
|
+
aliases: RouteAlias[];
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
|
|
@@ -27,10 +29,9 @@ export type RouteInternal = {
|
|
|
27
29
|
export type Routes = readonly Route[];
|
|
28
30
|
/**
|
|
29
31
|
* The Route properties originally provided to `createRoute`, plus the views that route renders and the
|
|
30
|
-
* loaders it runs.
|
|
31
|
-
* {@link RouteViews}).
|
|
32
|
+
* loaders it runs.
|
|
32
33
|
*/
|
|
33
|
-
export type CreatedRouteOptions =
|
|
34
|
+
export type CreatedRouteOptions = CreateRouteOptions & {
|
|
34
35
|
id: string;
|
|
35
36
|
views: RouteViews;
|
|
36
37
|
loaders: RouteLoaders;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Url } from './url';
|
|
2
|
+
/**
|
|
3
|
+
* What an alias transform is given: the url that matched and the params the alias pattern parsed from it.
|
|
4
|
+
*
|
|
5
|
+
* @template TParams - The alias's own params, typed by the alias pattern.
|
|
6
|
+
*/
|
|
7
|
+
export type AliasTransformContext<TParams = Record<string, unknown>> = {
|
|
8
|
+
/**
|
|
9
|
+
* The url that matched the alias.
|
|
10
|
+
*/
|
|
11
|
+
url: string;
|
|
12
|
+
/**
|
|
13
|
+
* The params the alias pattern parsed from the url, typed by the alias's own params rather than the
|
|
14
|
+
* route's.
|
|
15
|
+
*/
|
|
16
|
+
params: TParams;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Maps what an alias matched into the params the route declares. Runs synchronously during matching. Any
|
|
20
|
+
* param the route declares that the alias pattern does not carry must be supplied here.
|
|
21
|
+
*
|
|
22
|
+
* @template TParams - The alias's own params.
|
|
23
|
+
* @template TRouteParams - The params of the route the alias belongs to.
|
|
24
|
+
*/
|
|
25
|
+
export type AliasTransform<TParams = Record<string, unknown>, TRouteParams = Record<string, unknown>> = (context: AliasTransformContext<TParams>) => TRouteParams;
|
|
26
|
+
/**
|
|
27
|
+
* An alias combined with every ancestor into a single url the router can match, plus the transform that
|
|
28
|
+
* maps everything that url parsed into the route's params. The transform is the composition of each
|
|
29
|
+
* level's own transform, so it stays local to the segment each level aliased.
|
|
30
|
+
*/
|
|
31
|
+
export type RouteAlias = {
|
|
32
|
+
url: Url;
|
|
33
|
+
transform: (url: string, params: Record<string, unknown>) => Record<string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* An alias a url matched and the params that alias parsed from it.
|
|
37
|
+
*/
|
|
38
|
+
export type RouteAliasMatch = {
|
|
39
|
+
url: RouteAlias['url'];
|
|
40
|
+
params: Record<string, unknown>;
|
|
41
|
+
};
|
|
@@ -16,6 +16,7 @@ export type RouteCallbackContext<TRoute extends Route> = {
|
|
|
16
16
|
push: RouterPush<[TRoute] | RouteContextToRoute<TRoute['context']>>;
|
|
17
17
|
replace: RouterReplace<[TRoute] | RouteContextToRoute<TRoute['context']>>;
|
|
18
18
|
update: RouteUpdate<ResolvedRoute<TRoute>>;
|
|
19
|
+
signal: AbortSignal;
|
|
19
20
|
parent: RouteCallbackParent<TRoute>;
|
|
20
21
|
};
|
|
21
22
|
/**
|
|
@@ -3,26 +3,24 @@ import { Component } from 'vue';
|
|
|
3
3
|
import { PrefetchConfig } from './prefetch';
|
|
4
4
|
import { AnyFunction } from './utilities';
|
|
5
5
|
/**
|
|
6
|
-
* A single view: what to render, how to get its props, and how to prefetch it.
|
|
7
|
-
* because a route can bind props to the nested RouterView it renders without declaring a component.
|
|
6
|
+
* A single view: what to render, how to get its props, and how to prefetch it.
|
|
8
7
|
*
|
|
9
8
|
* @template TProps - What this view's props getter returns, carried so parent props can be typed from it.
|
|
10
9
|
*/
|
|
11
10
|
export type RouteView<TProps = undefined> = {
|
|
12
|
-
component
|
|
11
|
+
component: Component;
|
|
13
12
|
props?: AnyFunction<TProps>;
|
|
14
13
|
prefetch?: PrefetchConfig;
|
|
15
14
|
transformer?: AnyPayloadTransformer;
|
|
16
15
|
};
|
|
17
16
|
/**
|
|
18
|
-
* The views for a single
|
|
19
|
-
* `route.
|
|
20
|
-
* comes from at a given depth.
|
|
17
|
+
* The views for a single match, keyed by view name (the unnamed view under 'default'). Each match in
|
|
18
|
+
* `route.matches` carries its own views.
|
|
21
19
|
*/
|
|
22
20
|
export type RouteViews = Record<string, RouteView<unknown>>;
|
|
23
21
|
/**
|
|
24
22
|
* The props a child sees for a parent's views. A lone unnamed view is given directly rather than under a
|
|
25
|
-
* 'default' key
|
|
23
|
+
* 'default' key. Each view's props are always a promise,
|
|
26
24
|
* since the parent's props may not have been computed when the child's getter runs.
|
|
27
25
|
*/
|
|
28
26
|
export type ViewsPropsReturnType<TViews> = keyof ViewsWithProps<TViews> extends never ? undefined : keyof ViewsWithProps<TViews> extends 'default' ? ParentViewProps<Extract<ViewsWithProps<TViews>, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RouteAddAlias } from './addAlias';
|
|
1
2
|
import { RouteAddLoader } from './addLoader';
|
|
2
3
|
import { RouteAddView } from './addView';
|
|
3
4
|
import { InternalRouteHooks } from './hooks';
|
|
@@ -6,11 +7,11 @@ import { CreatedRouteOptions, Route } from './route';
|
|
|
6
7
|
import { RouteSetTitle } from './routeTitle';
|
|
7
8
|
import { Url } from './url';
|
|
8
9
|
/**
|
|
9
|
-
* A route plus every chainable/available method: addView, addLoader, hooks, redirects, and title. The type
|
|
10
|
+
* A route plus every chainable/available method: addView, addLoader, addAlias, hooks, redirects, and title. The type
|
|
10
11
|
* level counterpart to `withRouteMethods`.
|
|
11
12
|
*
|
|
12
13
|
* Takes the url and matches rather than an assembled route so that adding a view or a loader can rebuild
|
|
13
14
|
* from them directly. Taking the route would mean re-deriving the url from it on every call, and that
|
|
14
15
|
* reference is what made chained calls nest one inside the last.
|
|
15
16
|
*/
|
|
16
|
-
export type RouteWithMethods<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = Route<TUrl, TMatches> & RouteAddView<TUrl, TMatches> & RouteAddLoader<TUrl, TMatches> & InternalRouteHooks<Route<TUrl, TMatches>, Route<TUrl, TMatches>['context']> & RouteRedirects<Route<TUrl, TMatches>> & RouteSetTitle<Route<TUrl, TMatches>>;
|
|
17
|
+
export type RouteWithMethods<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = Route<TUrl, TMatches> & RouteAddView<TUrl, TMatches> & RouteAddLoader<TUrl, TMatches> & RouteAddAlias<TUrl, TMatches> & InternalRouteHooks<Route<TUrl, TMatches>, Route<TUrl, TMatches>['context']> & RouteRedirects<Route<TUrl, TMatches>> & RouteSetTitle<Route<TUrl, TMatches>>;
|
package/dist/types/router.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NavigationBehavior } from './navigation';
|
|
1
2
|
import { App, InjectionKey, Ref } from 'vue';
|
|
2
3
|
import { RouterHistoryMode } from '../services/createRouterHistory';
|
|
3
4
|
import { TransformerOptions } from '../services/payload';
|
|
@@ -14,6 +15,7 @@ import { RouterPlugin } from './routerPlugin';
|
|
|
14
15
|
import { RoutesName } from './routesMap';
|
|
15
16
|
import { ExtractRejections, ExtractRejectionTypes, Rejections, BuiltInRejectionType } from './rejection';
|
|
16
17
|
import { PayloadValueError } from '../errors/payloadValueError';
|
|
18
|
+
import { ViewTransitionConfig } from './viewTransition';
|
|
17
19
|
/**
|
|
18
20
|
* Options to initialize a {@link Router} instance.
|
|
19
21
|
*/
|
|
@@ -44,6 +46,17 @@ export type RouterOptions = TransformerOptions & {
|
|
|
44
46
|
* Determines what assets are prefetched when router-link is rendered for a specific route
|
|
45
47
|
*/
|
|
46
48
|
prefetch?: PrefetchConfig;
|
|
49
|
+
/**
|
|
50
|
+
* Whether navigation waits for props, loaders, and components before committing.
|
|
51
|
+
* @default 'progressive'
|
|
52
|
+
*/
|
|
53
|
+
navigation?: NavigationBehavior;
|
|
54
|
+
/**
|
|
55
|
+
* Animates navigations with the View Transitions API. Overridden per route and per navigation.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
viewTransition?: ViewTransitionConfig;
|
|
47
60
|
/**
|
|
48
61
|
* Components assigned to each type of rejection your router supports.
|
|
49
62
|
*/
|
|
@@ -3,7 +3,7 @@ import { UrlString } from './urlString';
|
|
|
3
3
|
import { ResolvedRoute } from './resolved';
|
|
4
4
|
import { Router } from './router';
|
|
5
5
|
import { RouterPushOptions } from './routerPush';
|
|
6
|
-
export type ToCallback<TRouter extends Router> = (resolve: TRouter['resolve']) => ResolvedRoute | UrlString
|
|
6
|
+
export type ToCallback<TRouter extends Router> = (resolve: TRouter['resolve']) => ResolvedRoute | UrlString;
|
|
7
7
|
export type RouterLinkProps<TRouter extends Router> = RouterPushOptions & {
|
|
8
8
|
/**
|
|
9
9
|
* The url string to navigate to or a callback that returns a url string
|