@kitbag/router 0.23.0 → 0.23.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/dist/components/routerLink.d.ts +2 -3
- package/dist/kitbag-router.js +1573 -1524
- package/dist/kitbag-router.umd.cjs +3 -3
- package/dist/main.d.ts +2 -0
- package/dist/services/createRoute.d.ts +2 -1
- package/dist/services/getMatchesForUrl.d.ts +3 -2
- package/dist/services/queryParamFilter.d.ts +2 -0
- package/dist/services/queryParamFilter.spec.d.ts +1 -0
- package/dist/types/createRouteOptions.d.ts +2 -1
- package/dist/types/hooks.d.ts +15 -0
- package/dist/types/resolved.d.ts +0 -7
- package/dist/types/route.d.ts +0 -7
- package/dist/types/routerRoute.d.ts +0 -5
- package/dist/types/titles.browser.spec.d.ts +1 -0
- package/dist/types/titles.d.ts +26 -0
- package/dist/utilities/setDocumentTitle.d.ts +2 -0
- package/dist/utilities/testHelpers.d.ts +1636 -252
- package/package.json +2 -2
package/dist/main.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export * from './types/paramTypes';
|
|
|
6
6
|
export * from './types/prefetch';
|
|
7
7
|
export * from './types/props';
|
|
8
8
|
export * from './types/querySource';
|
|
9
|
+
export type { RouteRedirects } from './types/redirects';
|
|
9
10
|
export * from './types/register';
|
|
11
|
+
export type { Rejection, RejectionType, Rejections } from './types/rejection';
|
|
10
12
|
export * from './types/resolved';
|
|
11
13
|
export * from './types/route';
|
|
12
14
|
export * from './types/router';
|
|
@@ -2,6 +2,7 @@ import { CreateRouteOptions, PropsGetter, CreateRouteProps, ToRoute, RouterViewP
|
|
|
2
2
|
import { InternalRouteHooks } from '../types/hooks';
|
|
3
3
|
import { ExtractRouteContext } from '../types/routeContext';
|
|
4
4
|
import { RouteRedirects } from '../types/redirects';
|
|
5
|
+
import { RouteSetTitle } from '../types/titles';
|
|
5
6
|
type CreateRouteWithProps<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions>> = CreateRouteProps<TOptions> extends RouterViewPropsGetter<TOptions> ? [props?: RouterViewPropsGetter<TOptions>] : CreateRouteProps<TOptions> extends PropsGetter<TOptions> ? Partial<ReturnType<CreateRouteProps<TOptions>>> extends ReturnType<CreateRouteProps<TOptions>> ? [props?: TProps] : [props: TProps] : Partial<CreateRouteProps<TOptions>> extends CreateRouteProps<TOptions> ? [props?: TProps] : [props: TProps];
|
|
6
|
-
export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): ToRoute<TOptions, TProps> & InternalRouteHooks<ToRoute<TOptions>, ExtractRouteContext<TOptions>> & RouteRedirects<ToRoute<TOptions>>;
|
|
7
|
+
export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): ToRoute<TOptions, TProps> & InternalRouteHooks<ToRoute<TOptions>, ExtractRouteContext<TOptions>> & RouteRedirects<ToRoute<TOptions>> & RouteSetTitle<ToRoute<TOptions>>;
|
|
7
8
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ResolvedRoute } from '../types/resolved';
|
|
2
2
|
import { Routes } from '../types/route';
|
|
3
|
-
import { RouterResolveOptions } from '../types/routerResolve';
|
|
4
3
|
import { ParseUrlOptions } from '../types/url';
|
|
5
|
-
type MatchOptions =
|
|
4
|
+
type MatchOptions = {
|
|
5
|
+
state?: Partial<unknown>;
|
|
6
|
+
} & ParseUrlOptions;
|
|
6
7
|
export declare function getMatchForUrl(routes: Routes, url: string, options?: MatchOptions): ResolvedRoute | undefined;
|
|
7
8
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
2
|
import { CombineMeta } from '../services/combineMeta';
|
|
3
3
|
import { CombineState } from '../services/combineState';
|
|
4
|
+
import { WithHooks } from './hooks';
|
|
4
5
|
import { Param } from './paramTypes';
|
|
5
6
|
import { PrefetchConfig } from './prefetch';
|
|
6
7
|
import { RouteMeta } from './register';
|
|
@@ -128,5 +129,5 @@ export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRo
|
|
|
128
129
|
...ToRouteContext<TParent['context']>,
|
|
129
130
|
...ToRouteContext<TOptions['context']>
|
|
130
131
|
]> : Route<ToName<TOptions['name']>, ToUrl<Identity<TOptions & WithoutComponents>>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, ToRouteContext<TOptions['context']>>;
|
|
131
|
-
export declare function combineRoutes(parent: Route, child: Route): Route;
|
|
132
|
+
export declare function combineRoutes(parent: Route, child: Route): Route & WithHooks;
|
|
132
133
|
export {};
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -10,6 +10,21 @@ import { RouteContext, RouteContextToRejection, RouteContextToRoute } from './ro
|
|
|
10
10
|
import { RouterAbort } from './routerAbort';
|
|
11
11
|
import { CallbackContextAbort, CallbackContextPush, CallbackContextReject, CallbackContextSuccess } from './callbackContext';
|
|
12
12
|
import { RouteUpdate } from './routeUpdate';
|
|
13
|
+
/**
|
|
14
|
+
* The stores for routes including ancestors.
|
|
15
|
+
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export type WithHooks = {
|
|
19
|
+
hooks: Hooks[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to assert that a route has hooks.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function isWithHooks<T extends Record<string, unknown>>(route: T): route is T & WithHooks;
|
|
26
|
+
export declare function getHooks(route: Record<string, unknown> | undefined | null): Hooks[];
|
|
27
|
+
export declare function combineHooks(parent: Route, child: Route): Hooks[];
|
|
13
28
|
export type InternalRouteHooks<TRoute extends Route = Route, TContext extends RouteContext[] = []> = {
|
|
14
29
|
/**
|
|
15
30
|
* Registers a route hook to be called before the route is entered.
|
package/dist/types/resolved.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Hooks } from '../models/hooks';
|
|
2
1
|
import { Route, Routes } from './route';
|
|
3
2
|
import { ExtractRouteStateParamsAsOptional } from './state';
|
|
4
3
|
import { UrlString } from './urlString';
|
|
@@ -45,12 +44,6 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
45
44
|
* Hash value of the route.
|
|
46
45
|
*/
|
|
47
46
|
hash: string;
|
|
48
|
-
/**
|
|
49
|
-
* The stores for routes including ancestors.
|
|
50
|
-
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
hooks: Hooks[];
|
|
54
47
|
}>;
|
|
55
48
|
/**
|
|
56
49
|
* This type is the same as `ResolvedRoute<TRoutes[number]>` while remaining distributive
|
package/dist/types/route.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { PrefetchConfig } from './prefetch';
|
|
|
3
3
|
import { RouteMeta } from './register';
|
|
4
4
|
import { LastInArray } from './utilities';
|
|
5
5
|
import { CreateRouteOptions } from './createRouteOptions';
|
|
6
|
-
import { Hooks } from '../models/hooks';
|
|
7
6
|
import { RouteContext } from './routeContext';
|
|
8
7
|
import { Url } from './url';
|
|
9
8
|
/**
|
|
@@ -57,12 +56,6 @@ export type Route<TName extends string = string, TUrl extends Url = Url, TMeta e
|
|
|
57
56
|
* Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
|
|
58
57
|
*/
|
|
59
58
|
context: TContext;
|
|
60
|
-
/**
|
|
61
|
-
* The stores for routes including ancestors.
|
|
62
|
-
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
hooks: Hooks[];
|
|
66
59
|
/**
|
|
67
60
|
* A value that represents how many parents a route has. Used for route matching
|
|
68
61
|
* @internal
|
|
@@ -19,11 +19,6 @@ export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
|
|
|
19
19
|
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
20
20
|
*/
|
|
21
21
|
readonly matches: TRoute['matches'];
|
|
22
|
-
/**
|
|
23
|
-
* The stores for routes including ancestors.
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
readonly hooks: TRoute['hooks'];
|
|
27
22
|
/**
|
|
28
23
|
* Hash value of the route.
|
|
29
24
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResolvedRoute, ResolvedRouteUnion } from './resolved';
|
|
2
|
+
import { Route } from './route';
|
|
3
|
+
import { MaybePromise } from './utilities';
|
|
4
|
+
export type SetTitleContext = {
|
|
5
|
+
from: ResolvedRoute;
|
|
6
|
+
getParentTitle: () => Promise<string | undefined>;
|
|
7
|
+
};
|
|
8
|
+
export type SetTitleCallback<TRoute extends Route = Route> = (to: ResolvedRouteUnion<TRoute>, context: SetTitleContext) => MaybePromise<string>;
|
|
9
|
+
export type GetTitle<TRoute extends Route = Route> = (to: ResolvedRouteUnion<TRoute>) => Promise<string | undefined>;
|
|
10
|
+
export type SetTitle<TRoute extends Route = Route> = (callback: SetTitleCallback<TRoute>) => void;
|
|
11
|
+
export type RouteSetTitle<TRoute extends Route = Route> = {
|
|
12
|
+
/**
|
|
13
|
+
* Adds a callback to set the document title for the route.
|
|
14
|
+
*/
|
|
15
|
+
setTitle: SetTitle<TRoute>;
|
|
16
|
+
};
|
|
17
|
+
export type RouteGetTitle<TRoute extends Route = Route> = {
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* Gets the title for the route.
|
|
21
|
+
*/
|
|
22
|
+
getTitle: GetTitle<TRoute>;
|
|
23
|
+
};
|
|
24
|
+
export declare function isRouteWithTitleSetter<T extends Route | ResolvedRoute>(route: T): route is T & RouteSetTitle;
|
|
25
|
+
export declare function isRouteWithTitleGetter<T extends Route | ResolvedRoute>(route: T): route is T & RouteGetTitle;
|
|
26
|
+
export declare function createRouteTitle(parent: Route | undefined): RouteGetTitle & RouteSetTitle;
|