@kitbag/router 0.20.12 → 0.22.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/README.md +38 -87
- package/dist/components/routerLink.d.ts +5 -5
- package/dist/compositions/useLink.d.ts +2 -2
- package/dist/devtools/createRouterDevtools.d.ts +13 -0
- package/dist/devtools/filters.d.ts +12 -0
- package/dist/devtools/getDevtoolsLabel.d.ts +13 -0
- package/dist/devtools/types.d.ts +10 -0
- package/dist/errors/contextAbortError.d.ts +2 -2
- package/dist/errors/contextPushError.d.ts +2 -2
- package/dist/errors/contextRejectionError.d.ts +2 -2
- package/dist/errors/invalidRouteRedirectError.d.ts +11 -0
- package/dist/errors/multipleRouteRedirectsError.d.ts +13 -0
- package/dist/keys.d.ts +1 -3
- package/dist/kitbag-router.js +4927 -1741
- package/dist/kitbag-router.umd.cjs +3 -3
- package/dist/main.d.ts +1 -17
- package/dist/models/hooks.d.ts +12 -0
- package/dist/services/createComponentHooks.d.ts +7 -7
- package/dist/services/createExternalRoute.d.ts +4 -2
- package/dist/services/createPropStore.d.ts +2 -2
- package/dist/services/createRoute.d.ts +3 -1
- package/dist/services/createRouteHooks.d.ts +12 -10
- package/dist/services/createRouteRedirects.d.ts +10 -0
- package/dist/services/createRouterAssets.d.ts +5 -5
- package/dist/services/createRouterCallbackContext.d.ts +8 -6
- package/dist/services/createRouterHooks.d.ts +13 -14
- package/dist/services/createRouterPlugin.d.ts +2 -2
- package/dist/services/getGlobalHooksForRouter.d.ts +2 -3
- package/dist/services/getGlobalRouteHooks.d.ts +3 -3
- package/dist/services/getRouteHooks.d.ts +3 -3
- package/dist/services/hooks.d.ts +2 -2
- package/dist/services/insertBaseRoute.d.ts +2 -2
- package/dist/services/routeMatchRules.d.ts +0 -1
- package/dist/services/routeMatchScore.d.ts +1 -1
- package/dist/services/routeRegex.d.ts +1 -0
- package/dist/services/urlAssembly.d.ts +2 -2
- package/dist/services/urlCombine.d.ts +2 -2
- package/dist/services/urlCreator.d.ts +2 -2
- package/dist/services/urlParser.d.ts +1 -1
- package/dist/types/callbackContext.d.ts +15 -0
- package/dist/types/createRouteOptions.d.ts +6 -13
- package/dist/types/hooks.d.ts +85 -137
- package/dist/types/props.d.ts +8 -8
- package/dist/types/redirects.d.ts +40 -0
- package/dist/types/register.d.ts +1 -41
- package/dist/types/rejection.d.ts +6 -2
- package/dist/types/resolved.d.ts +14 -4
- package/dist/types/route.d.ts +3 -4
- package/dist/types/routeContext.d.ts +11 -5
- package/dist/types/router.d.ts +16 -11
- package/dist/types/routerAbort.d.ts +1 -0
- package/dist/types/routerLink.d.ts +3 -3
- package/dist/types/routerPlugin.d.ts +17 -41
- package/dist/types/routerPush.d.ts +2 -2
- package/dist/types/routerReject.d.ts +2 -2
- package/dist/types/routerReplace.d.ts +2 -2
- package/dist/types/{url.d.ts → urlString.d.ts} +3 -3
- package/dist/types/useLink.d.ts +2 -2
- package/dist/utilities/checkDuplicateParams.spec.d.ts +1 -0
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/isNamedRoute.d.ts +4 -0
- package/dist/utilities/testHelpers.d.ts +722 -22
- package/package.json +10 -8
- package/dist/errors/missingRouteContextError.d.ts +0 -10
- package/dist/models/RouteHooks.d.ts +0 -12
- package/dist/models/RouterRouteHooks.d.ts +0 -10
- package/dist/services/createCallbackContext.d.ts +0 -44
- package/dist/services/getRouteHooksDeprecated.d.ts +0 -10
- package/dist/utilities/checkMissingContext.d.ts +0 -2
- /package/dist/{utilities/checkDuplicateKeys.spec.d.ts → services/createRouteRedirects.spec.d.ts} +0 -0
- /package/dist/{utilities/checkMissingContext.spec copy.d.ts → types/redirects.spec-d.d.ts} +0 -0
- /package/dist/utilities/{checkDuplicateKeys.d.ts → checkDuplicateParams.d.ts} +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook } from '../types/hooks';
|
|
2
2
|
import { Routes } from '../types/route';
|
|
3
|
-
import {
|
|
3
|
+
import { Hooks } from '../models/hooks';
|
|
4
4
|
import { Rejection } from '../types/rejection';
|
|
5
|
+
import { RouteRedirect } from '../types/redirects';
|
|
5
6
|
export type RouteHooks<TRoutes extends Routes = Routes, TRejections extends Rejection[] = Rejection[]> = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
redirect: RouteRedirect;
|
|
8
|
+
onBeforeRouteEnter: AddBeforeEnterHook<TRoutes, TRejections>;
|
|
9
|
+
onBeforeRouteUpdate: AddBeforeUpdateHook<TRoutes, TRejections>;
|
|
10
|
+
onBeforeRouteLeave: AddBeforeLeaveHook<TRoutes, TRejections>;
|
|
11
|
+
onAfterRouteEnter: AddAfterEnterHook<TRoutes, TRejections>;
|
|
12
|
+
onAfterRouteUpdate: AddAfterUpdateHook<TRoutes, TRejections>;
|
|
13
|
+
onAfterRouteLeave: AddAfterLeaveHook<TRoutes, TRejections>;
|
|
14
|
+
onError: AddErrorHook<TRoutes[number], TRoutes, TRejections>;
|
|
15
|
+
store: Hooks;
|
|
14
16
|
};
|
|
15
17
|
export declare function createRouteHooks(): RouteHooks;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RouteRedirects } from '../types/redirects';
|
|
2
|
+
import { Route } from '../types/route';
|
|
3
|
+
type CreateRouteRedirectsContext = {
|
|
4
|
+
/**
|
|
5
|
+
* The to route for the redirectFrom callback and the from route for the redirectTo callback.
|
|
6
|
+
*/
|
|
7
|
+
getRoute: () => Route;
|
|
8
|
+
};
|
|
9
|
+
export declare function createRouteRedirects({ getRoute }: CreateRouteRedirectsContext): RouteRedirects;
|
|
10
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { createUseRouter } from '../compositions/useRouter';
|
|
|
7
7
|
import { createUseQueryValue } from '../compositions/useQueryValue';
|
|
8
8
|
import { createUseLink } from '../compositions/useLink';
|
|
9
9
|
import { createIsRoute } from '../guards/routes';
|
|
10
|
-
import {
|
|
10
|
+
import { AddBeforeLeaveHook, AddBeforeUpdateHook, AddAfterLeaveHook, AddAfterUpdateHook } from '../types/hooks';
|
|
11
11
|
export type RouterAssets<TRouter extends Router> = {
|
|
12
12
|
/**
|
|
13
13
|
* Registers a hook that is called before a route is left. Must be called from setup.
|
|
@@ -17,7 +17,7 @@ export type RouterAssets<TRouter extends Router> = {
|
|
|
17
17
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
18
18
|
* @group Hooks
|
|
19
19
|
*/
|
|
20
|
-
onBeforeRouteLeave:
|
|
20
|
+
onBeforeRouteLeave: AddBeforeLeaveHook<RouterRoutes<TRouter>, RouterRejections<TRouter>>;
|
|
21
21
|
/**
|
|
22
22
|
* Registers a hook that is called before a route is updated. Must be called from setup.
|
|
23
23
|
* This is particularly useful for handling changes in route parameters or query while staying within the same component.
|
|
@@ -26,7 +26,7 @@ export type RouterAssets<TRouter extends Router> = {
|
|
|
26
26
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
27
27
|
* @group Hooks
|
|
28
28
|
*/
|
|
29
|
-
onBeforeRouteUpdate:
|
|
29
|
+
onBeforeRouteUpdate: AddBeforeUpdateHook<RouterRoutes<TRouter>, RouterRejections<TRouter>>;
|
|
30
30
|
/**
|
|
31
31
|
* Registers a hook that is called after a route has been left. Must be called during setup.
|
|
32
32
|
* This can be used for cleanup actions after the component is no longer active, ensuring proper resource management.
|
|
@@ -35,7 +35,7 @@ export type RouterAssets<TRouter extends Router> = {
|
|
|
35
35
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
36
36
|
* @group Hooks
|
|
37
37
|
*/
|
|
38
|
-
onAfterRouteLeave:
|
|
38
|
+
onAfterRouteLeave: AddAfterLeaveHook<RouterRoutes<TRouter>, RouterRejections<TRouter>>;
|
|
39
39
|
/**
|
|
40
40
|
* Registers a hook that is called after a route has been updated. Must be called during setup.
|
|
41
41
|
* This is ideal for responding to updates within the same route, such as parameter changes, without full component reloads.
|
|
@@ -44,7 +44,7 @@ export type RouterAssets<TRouter extends Router> = {
|
|
|
44
44
|
* @returns {RouteHookRemove} A function that removes the added hook.
|
|
45
45
|
* @group Hooks
|
|
46
46
|
*/
|
|
47
|
-
onAfterRouteUpdate:
|
|
47
|
+
onAfterRouteUpdate: AddAfterUpdateHook<RouterRoutes<TRouter>, RouterRejections<TRouter>>;
|
|
48
48
|
/**
|
|
49
49
|
* A guard to verify if a route or unknown value matches a given route name.
|
|
50
50
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Router, RouterRejections, RouterRoutes } from '../types/router';
|
|
2
1
|
import { RouterPush } from '../types/routerPush';
|
|
3
2
|
import { RouterReject } from '../types/routerReject';
|
|
4
3
|
import { RouterReplace } from '../types/routerReplace';
|
|
5
|
-
import { InjectionKey } from 'vue';
|
|
6
4
|
import { BuiltInRejectionType } from './createRouterReject';
|
|
7
5
|
import { AsString } from '../types/utilities';
|
|
8
6
|
import { Routes } from '../types/route';
|
|
9
|
-
import {
|
|
7
|
+
import { Rejections } from '../types/rejection';
|
|
8
|
+
import { RouteUpdate } from '../types/routeUpdate';
|
|
9
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
10
10
|
/**
|
|
11
11
|
* Defines the structure of a successful callback response.
|
|
12
12
|
*/
|
|
@@ -37,11 +37,13 @@ export type RouterCallbackRejectResponse<TRejections extends string> = {
|
|
|
37
37
|
* A function that can be called to abort a routing operation.
|
|
38
38
|
*/
|
|
39
39
|
export type CallbackContextAbort = () => void;
|
|
40
|
-
export type RouterCallbackContext<TRoutes extends Routes = Routes, TRejections extends
|
|
40
|
+
export type RouterCallbackContext<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
|
|
41
41
|
reject: RouterReject<TRejections>;
|
|
42
42
|
push: RouterPush<TRoutes>;
|
|
43
43
|
replace: RouterReplace<TRoutes>;
|
|
44
|
+
update: RouteUpdate<ResolvedRoute<TRoutes[number]>>;
|
|
44
45
|
abort: CallbackContextAbort;
|
|
45
46
|
};
|
|
46
|
-
export declare function createRouterCallbackContext<
|
|
47
|
-
|
|
47
|
+
export declare function createRouterCallbackContext<TRoutes extends Routes, TRejections extends Rejections>({ to }: {
|
|
48
|
+
to: ResolvedRoute;
|
|
49
|
+
}): RouterCallbackContext<TRoutes, TRejections>;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AddGlobalHooks, AddComponentHook, AfterHookRunner, BeforeHookRunner, AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, ErrorHookRunner, AddErrorHook } from '../types/hooks';
|
|
2
2
|
import { HasVueAppStore } from './createVueAppStore';
|
|
3
3
|
export declare const getRouterHooksKey: (routerKey: import('vue').InjectionKey<import('../main').Router>) => import('vue').InjectionKey<RouterHooks>;
|
|
4
4
|
export type RouterHooks = HasVueAppStore & {
|
|
5
|
-
runBeforeRouteHooks:
|
|
6
|
-
runAfterRouteHooks:
|
|
7
|
-
runErrorHooks:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onError: AddRouterErrorHook;
|
|
5
|
+
runBeforeRouteHooks: BeforeHookRunner;
|
|
6
|
+
runAfterRouteHooks: AfterHookRunner;
|
|
7
|
+
runErrorHooks: ErrorHookRunner;
|
|
8
|
+
addComponentHook: AddComponentHook;
|
|
9
|
+
addGlobalRouteHooks: AddGlobalHooks;
|
|
10
|
+
onBeforeRouteEnter: AddBeforeEnterHook;
|
|
11
|
+
onBeforeRouteUpdate: AddBeforeUpdateHook;
|
|
12
|
+
onBeforeRouteLeave: AddBeforeLeaveHook;
|
|
13
|
+
onAfterRouteEnter: AddAfterEnterHook;
|
|
14
|
+
onAfterRouteUpdate: AddAfterUpdateHook;
|
|
15
|
+
onAfterRouteLeave: AddAfterLeaveHook;
|
|
16
|
+
onError: AddErrorHook;
|
|
18
17
|
};
|
|
19
18
|
export declare function createRouterHooks(): RouterHooks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CreateRouterPluginOptions, RouterPlugin, PluginRouteHooks } from '../types/routerPlugin';
|
|
2
|
-
import {
|
|
2
|
+
import { Rejections } from '../types/rejection';
|
|
3
3
|
import { Routes } from '../types/route';
|
|
4
|
-
export declare function createRouterPlugin<TRoutes extends Routes = Routes, TRejections extends
|
|
4
|
+
export declare function createRouterPlugin<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections>(plugin: CreateRouterPluginOptions<TRoutes, TRejections>): RouterPlugin<TRoutes, TRejections> & PluginRouteHooks<TRoutes, TRejections>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RouterOptions } from '../types/router';
|
|
1
|
+
import { Hooks } from '../models/hooks';
|
|
3
2
|
import { RouterPlugin } from '../types/routerPlugin';
|
|
4
|
-
export declare function getGlobalHooksForRouter(
|
|
3
|
+
export declare function getGlobalHooksForRouter(plugins?: RouterPlugin[]): Hooks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
-
import {
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
2
|
+
import { Hooks } from '../models/hooks';
|
|
3
|
+
export declare function getGlobalBeforeHooks(to: ResolvedRoute, from: ResolvedRoute | null, globalHooks: Hooks): Hooks;
|
|
4
|
+
export declare function getGlobalAfterHooks(to: ResolvedRoute, from: ResolvedRoute | null, globalHooks: Hooks): Hooks;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
-
import {
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
2
|
+
import { Hooks } from '../models/hooks';
|
|
3
|
+
export declare function getBeforeHooksFromRoutes(to: ResolvedRoute, from: ResolvedRoute | null): Hooks;
|
|
4
|
+
export declare function getAfterHooksFromRoutes(to: ResolvedRoute, from: ResolvedRoute | null): Hooks;
|
package/dist/services/hooks.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HookLifecycle } from '../types/hooks';
|
|
2
2
|
import { ResolvedRoute } from '../types/resolved';
|
|
3
3
|
type RouteHookCondition = (to: ResolvedRoute, from: ResolvedRoute | null, depth: number) => boolean;
|
|
4
4
|
export declare const isRouteEnter: RouteHookCondition;
|
|
5
5
|
export declare const isRouteLeave: RouteHookCondition;
|
|
6
6
|
export declare const isRouteUpdate: RouteHookCondition;
|
|
7
|
-
export declare function getRouteHookCondition(lifecycle:
|
|
7
|
+
export declare function getRouteHookCondition(lifecycle: HookLifecycle): RouteHookCondition;
|
|
8
8
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function insertBaseRoute(
|
|
1
|
+
import { Route } from '../types/route';
|
|
2
|
+
export declare function insertBaseRoute(route: Route, base?: string): Route;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RouteMatchRule } from '../types/routeMatchRule';
|
|
2
|
-
export declare const isNamedRoute: RouteMatchRule;
|
|
3
2
|
export declare const routeHostMatches: RouteMatchRule;
|
|
4
3
|
export declare const routePathMatches: RouteMatchRule;
|
|
5
4
|
export declare const routeQueryMatches: RouteMatchRule;
|
|
@@ -3,5 +3,5 @@ import { QuerySource } from '../types/querySource';
|
|
|
3
3
|
type RouteSortMethod = (aRoute: Route, bRoute: Route) => number;
|
|
4
4
|
export declare function getRouteScoreSortMethod(url: string): RouteSortMethod;
|
|
5
5
|
export declare function countExpectedPathParams(route: Route, actualPath: string): number;
|
|
6
|
-
export declare function countExpectedQueryParams(route: Route,
|
|
6
|
+
export declare function countExpectedQueryParams(route: Route, actualQuery: QuerySource): number;
|
|
7
7
|
export {};
|
|
@@ -3,6 +3,7 @@ import { WithParams } from './withParams';
|
|
|
3
3
|
export declare function splitByMatches(string: string, regexp: RegExp): string[];
|
|
4
4
|
export declare function generateRouteHostRegexPattern(route: Route): RegExp;
|
|
5
5
|
export declare function generateRoutePathRegexPattern(route: Route): RegExp;
|
|
6
|
+
export declare function generateRouteHashRegexPattern(route: Route): RegExp;
|
|
6
7
|
export declare function generateRouteQueryRegexPatterns(route: Route): RegExp[];
|
|
7
8
|
export declare function replaceParamSyntaxWithCatchAlls(value: string): string;
|
|
8
9
|
export declare function replaceIndividualParamWithCaptureGroup(path: string, paramName: string): string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Route } from '../types/route';
|
|
2
|
-
import {
|
|
2
|
+
import { UrlString } from '../types/urlString';
|
|
3
3
|
import { QuerySource } from '../types/querySource';
|
|
4
4
|
type AssembleUrlOptions = {
|
|
5
5
|
params?: Record<string, unknown>;
|
|
6
6
|
query?: QuerySource;
|
|
7
7
|
hash?: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function assembleUrl(route: Route, options?: AssembleUrlOptions):
|
|
9
|
+
export declare function assembleUrl(route: Route, options?: AssembleUrlOptions): UrlString;
|
|
10
10
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function combineUrl(previous:
|
|
1
|
+
import { UrlString, UrlParts } from '../types/urlString';
|
|
2
|
+
export declare function combineUrl(previous: UrlString | Partial<UrlParts>, updated: UrlString | Partial<UrlParts>): UrlString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function createUrl({ protocol, host, pathname, search, searchParams, hash }: Partial<UrlParts>):
|
|
1
|
+
import { UrlString, UrlParts } from '../types/urlString';
|
|
2
|
+
export declare function createUrl({ protocol, host, pathname, search, searchParams, hash }: Partial<UrlParts>): UrlString;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UrlParts } from '../types/
|
|
1
|
+
import { UrlParts } from '../types/urlString';
|
|
2
2
|
export declare function parseUrl(value: string): UrlParts;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RouterPush } from './routerPush';
|
|
2
|
+
export type CallbackContextSuccess = {
|
|
3
|
+
status: 'SUCCESS';
|
|
4
|
+
};
|
|
5
|
+
export type CallbackContextPush = {
|
|
6
|
+
status: 'PUSH';
|
|
7
|
+
to: Parameters<RouterPush>;
|
|
8
|
+
};
|
|
9
|
+
export type CallbackContextReject = {
|
|
10
|
+
status: 'REJECT';
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
export type CallbackContextAbort = {
|
|
14
|
+
status: 'ABORT';
|
|
15
|
+
};
|
|
@@ -15,7 +15,6 @@ import { MaybePromise } from './utilities';
|
|
|
15
15
|
import { ToMeta } from './meta';
|
|
16
16
|
import { ToState } from './state';
|
|
17
17
|
import { ToName } from './name';
|
|
18
|
-
import { WithHooks } from './hooks';
|
|
19
18
|
import { ToWithParams, WithParams } from '../services/withParams';
|
|
20
19
|
import { RouteContext, ToRouteContext } from './routeContext';
|
|
21
20
|
import { RouterViewProps } from '../components/routerView';
|
|
@@ -47,7 +46,7 @@ export declare function isWithComponents<T extends Record<string, unknown>>(opti
|
|
|
47
46
|
export declare function isWithComponentPropsRecord<T extends Record<string, unknown>>(options: T): options is T & {
|
|
48
47
|
props: RoutePropsRecord;
|
|
49
48
|
};
|
|
50
|
-
export 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> =
|
|
49
|
+
export 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> = {
|
|
51
50
|
/**
|
|
52
51
|
* Name for route, used to create route keys and in navigation.
|
|
53
52
|
*/
|
|
@@ -94,15 +93,9 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
94
93
|
* Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
|
|
95
94
|
*/
|
|
96
95
|
context?: RouteContext[];
|
|
97
|
-
/**
|
|
98
|
-
* Props have been moved to the second argument of `createRoute`. This property can no longer be used.
|
|
99
|
-
*
|
|
100
|
-
* @deprecated
|
|
101
|
-
*/
|
|
102
|
-
props?: never;
|
|
103
96
|
};
|
|
104
|
-
export type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions
|
|
105
|
-
export type RouterViewPropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions> = (route: ResolvedRoute<ToRoute<TOptions
|
|
97
|
+
export type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<ComponentProps<TComponent>>;
|
|
98
|
+
export type RouterViewPropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions> = (route: ResolvedRoute<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<RouterViewProps & Record<string, unknown>>;
|
|
106
99
|
type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
|
|
107
100
|
type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponents extends Record<string, Component> = Record<string, Component>> = {
|
|
108
101
|
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends true ? K : never]?: PropsGetter<TOptions, TComponents[K]>;
|
|
@@ -121,13 +114,13 @@ type ToMatch<TOptions extends CreateRouteOptions, TProps extends CreateRouteProp
|
|
|
121
114
|
type ToMatches<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = TOptions extends {
|
|
122
115
|
parent: infer TParent extends Route;
|
|
123
116
|
} ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<TOptions, TProps>];
|
|
124
|
-
export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = CreateRouteOptions extends TOptions ? Route : TOptions extends {
|
|
117
|
+
export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined = undefined> = CreateRouteOptions extends TOptions ? Route : TOptions extends {
|
|
125
118
|
parent: infer TParent extends Route;
|
|
126
|
-
} ? Route<ToName<TOptions['name']>, ToWithParams<TParent['host']>, 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>, [
|
|
119
|
+
} ? Route<ToName<TOptions['name']>, ToWithParams<TParent['host']>, 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, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, [
|
|
127
120
|
...ToRouteContext<TParent['context']>,
|
|
128
121
|
...ToRouteContext<TOptions['context']>
|
|
129
122
|
]> : Route<ToName<TOptions['name']>, TOptions extends {
|
|
130
123
|
host: string | WithParams;
|
|
131
|
-
} ? ToWithParams<TOptions['host']> : WithParams<'', {}>, ToWithParams<TOptions['path']>, ToWithParams<TOptions['query']>, ToWithParams<TOptions['hash']>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, TProps>, ToRouteContext<TOptions['context']>>;
|
|
124
|
+
} ? ToWithParams<TOptions['host']> : WithParams<'', {}>, ToWithParams<TOptions['path']>, ToWithParams<TOptions['query']>, ToWithParams<TOptions['hash']>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>, ToRouteContext<TOptions['context']>>;
|
|
132
125
|
export declare function combineRoutes(parent: Route, child: Route): Route;
|
|
133
126
|
export {};
|