@kitbag/router 0.23.1 → 0.24.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/main.d.ts CHANGED
@@ -10,10 +10,10 @@ export type { RouteRedirects } from './types/redirects';
10
10
  export * from './types/register';
11
11
  export type { Rejection, RejectionType, Rejections } from './types/rejection';
12
12
  export * from './types/resolved';
13
- export * from './types/route';
13
+ export type { Route, CreatedRouteOptions } from './types/route';
14
14
  export * from './types/router';
15
15
  export * from './types/routerLink';
16
- export * from './types/routerPlugin';
16
+ export type { RouterPlugin, CreateRouterPluginOptions } from './types/routerPlugin';
17
17
  export * from './types/routerPush';
18
18
  export * from './types/routerPush';
19
19
  export * from './types/routerReject';
@@ -23,7 +23,7 @@ export * from './types/routerResolve';
23
23
  export * from './types/routerResolve';
24
24
  export * from './types/routerRoute';
25
25
  export * from './types/urlString';
26
- export * from './types/url';
26
+ export type { Url, CreateUrlOptions, ParseUrlOptions } from './types/url';
27
27
  export * from './types/useLink';
28
28
  export { DuplicateParamsError } from './errors/duplicateParamsError';
29
29
  export { MetaPropertyConflict } from './errors/metaPropertyConflict';
@@ -1,4 +1,4 @@
1
- import { AfterEnterHook, AfterLeaveHook, AfterUpdateHook, BeforeEnterHook, BeforeLeaveHook, BeforeUpdateHook, ErrorHook } from '../types/hooks';
1
+ import { AfterEnterHook, AfterLeaveHook, AfterUpdateHook, BeforeEnterHook, BeforeLeaveHook, BeforeUpdateHook, ErrorHook, RejectionHook } from '../types/hooks';
2
2
  import { RedirectHook } from '../types/redirects';
3
3
  export declare class Hooks {
4
4
  redirects: Set<RedirectHook>;
@@ -9,4 +9,5 @@ export declare class Hooks {
9
9
  onAfterRouteUpdate: Set<AfterUpdateHook>;
10
10
  onAfterRouteLeave: Set<AfterLeaveHook>;
11
11
  onError: Set<ErrorHook>;
12
+ onRejection: Set<RejectionHook>;
12
13
  }
@@ -0,0 +1,10 @@
1
+ import { Rejection, RouterRejection } from '../types/rejection';
2
+ type RejectionUpdate = (rejection: Rejection) => void;
3
+ type RejectionClear = () => void;
4
+ type CurrentRejectionContext = {
5
+ currentRejection: RouterRejection;
6
+ updateRejection: RejectionUpdate;
7
+ clearRejection: RejectionClear;
8
+ };
9
+ export declare function createCurrentRejection(): CurrentRejectionContext;
10
+ export {};
@@ -1,6 +1,7 @@
1
+ import { RejectionHooks } from '../types/hooks';
1
2
  import { Rejection } from '../types/rejection';
2
3
  import { Component } from 'vue';
3
4
  export declare function createRejection<TType extends string>(options: {
4
5
  type: TType;
5
6
  component?: Component;
6
- }): Rejection<TType>;
7
+ }): Rejection<TType> & RejectionHooks<TType>;
@@ -0,0 +1,9 @@
1
+ import { AddRejectionHook } from '../types/hooks';
2
+ import { Routes } from '../types/route';
3
+ import { Hooks } from '../models/hooks';
4
+ type RejectionHooks<TRoutes extends Routes = Routes, TRejections extends string = string> = {
5
+ onRejection: AddRejectionHook<TRejections, TRoutes>;
6
+ store: Hooks;
7
+ };
8
+ export declare function createRejectionHooks(): RejectionHooks;
9
+ export {};
@@ -1,7 +1,7 @@
1
- import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook } from '../types/hooks';
1
+ import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook, AddRejectionHook } from '../types/hooks';
2
2
  import { Routes } from '../types/route';
3
3
  import { Hooks } from '../models/hooks';
4
- import { Rejection } from '../types/rejection';
4
+ import { ExtractRejectionTypes, Rejection } from '../types/rejection';
5
5
  import { RouteRedirect } from '../types/redirects';
6
6
  type RouteHooks<TRoutes extends Routes = Routes, TRejections extends Rejection[] = Rejection[]> = {
7
7
  redirect: RouteRedirect;
@@ -12,6 +12,7 @@ type RouteHooks<TRoutes extends Routes = Routes, TRejections extends Rejection[]
12
12
  onAfterRouteUpdate: AddAfterUpdateHook<TRoutes, TRejections>;
13
13
  onAfterRouteLeave: AddAfterLeaveHook<TRoutes, TRejections>;
14
14
  onError: AddErrorHook<TRoutes[number], TRoutes, TRejections>;
15
+ onRejection: AddRejectionHook<ExtractRejectionTypes<TRejections>, TRoutes>;
15
16
  store: Hooks;
16
17
  };
17
18
  export declare function createRouteHooks(): RouteHooks;
@@ -1,10 +1,11 @@
1
- import { AddGlobalHooks, AddComponentHook, AfterHookRunner, BeforeHookRunner, AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, ErrorHookRunner, AddErrorHook } from '../types/hooks';
1
+ import { AddGlobalHooks, AddComponentHook, AfterHookRunner, BeforeHookRunner, AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, ErrorHookRunner, AddErrorHook, RejectionHookRunner, AddRejectionHook } 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
5
  runBeforeRouteHooks: BeforeHookRunner;
6
6
  runAfterRouteHooks: AfterHookRunner;
7
7
  runErrorHooks: ErrorHookRunner;
8
+ runRejectionHooks: RejectionHookRunner;
8
9
  addComponentHook: AddComponentHook;
9
10
  addGlobalRouteHooks: AddGlobalHooks;
10
11
  onBeforeRouteEnter: AddBeforeEnterHook;
@@ -14,5 +15,6 @@ export type RouterHooks = HasVueAppStore & {
14
15
  onAfterRouteUpdate: AddAfterUpdateHook;
15
16
  onAfterRouteLeave: AddAfterLeaveHook;
16
17
  onError: AddErrorHook;
18
+ onRejection: AddRejectionHook;
17
19
  };
18
20
  export declare function createRouterHooks(): RouterHooks;
@@ -1,4 +1,4 @@
1
1
  import { CreateRouterPluginOptions, RouterPlugin, PluginRouteHooks } from '../types/routerPlugin';
2
2
  import { Rejections } from '../types/rejection';
3
3
  import { Routes } from '../types/route';
4
- export declare function createRouterPlugin<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections>(plugin: CreateRouterPluginOptions<TRoutes, TRejections>): RouterPlugin<TRoutes, TRejections> & PluginRouteHooks<TRoutes, TRejections>;
4
+ export declare function createRouterPlugin<TRoutes extends Routes = [], TRejections extends Rejections = []>(plugin: CreateRouterPluginOptions<TRoutes, TRejections>): RouterPlugin<TRoutes, TRejections> & PluginRouteHooks<TRoutes, TRejections>;
@@ -0,0 +1,3 @@
1
+ import { Hooks } from '../models/hooks';
2
+ import { Rejection } from '../types/rejection';
3
+ export declare function getRejectionHooksFromRejection(rejection: Rejection): Hooks;
@@ -1,14 +1,28 @@
1
- import { Route, Routes } from '../types/route';
1
+ import { Route, RouteInternal, Routes } from '../types/route';
2
2
  import { RouterPlugin } from '../types/routerPlugin';
3
- type RouterRoutes = {
4
- routes: Routes;
5
- getRouteByName: (name: string) => Route | undefined;
6
- };
3
+ import { BuiltInRejectionType, Rejection, RejectionInternal } from '../types/rejection';
4
+ import { RouterOptions } from '../types/router';
7
5
  /**
8
6
  * Takes in routes and plugins and returns a list of routes with the base route inserted if provided.
9
7
  * Also checks for duplicate names in the routes.
10
8
  *
11
9
  * @throws {DuplicateNamesError} If there are duplicate names in the routes.
12
10
  */
13
- export declare function getRoutesForRouter(routes: Routes | Routes[], plugins?: RouterPlugin[], base?: string): RouterRoutes;
14
- export {};
11
+ export declare function getRoutesForRouter(routes: Routes | Routes[], plugins?: RouterPlugin[], options?: RouterOptions): {
12
+ routes: (import('../main').Url & {
13
+ id: string;
14
+ matched: import('../types/route').CreatedRouteOptions;
15
+ matches: import('../types/route').CreatedRouteOptions[];
16
+ name: string;
17
+ meta: Record<string, unknown>;
18
+ state: Record<string, import('../main').Param>;
19
+ prefetch?: import('../main').PrefetchConfig;
20
+ context: import('../types/routeContext').RouteContext[];
21
+ } & RouteInternal)[];
22
+ rejections: (Rejection & RejectionInternal)[];
23
+ getRouteByName: (type: string) => Route | undefined;
24
+ getRejectionByType: {
25
+ (type: BuiltInRejectionType): (Rejection & RejectionInternal);
26
+ (type: string): (Rejection & RejectionInternal) | undefined;
27
+ };
28
+ };
@@ -1,2 +1,2 @@
1
1
  import { Route } from '../types/route';
2
- export declare function insertBaseRoute(route: Route, base?: string): Route;
2
+ export declare function insertBaseRoute<T extends Route>(route: T, base?: string): T;
@@ -1,7 +1,6 @@
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';
5
4
  import { Param } from './paramTypes';
6
5
  import { PrefetchConfig } from './prefetch';
7
6
  import { RouteMeta } from './register';
@@ -129,5 +128,5 @@ export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRo
129
128
  ...ToRouteContext<TParent['context']>,
130
129
  ...ToRouteContext<TOptions['context']>
131
130
  ]> : 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']>>;
132
- export declare function combineRoutes(parent: Route, child: Route): Route & WithHooks;
131
+ export declare function combineRoutes(parent: Route, child: Route): Route;
133
132
  export {};
@@ -5,27 +5,14 @@ import { Route, Routes } from './route';
5
5
  import { RouterReject } from './routerReject';
6
6
  import { RouterPush } from './routerPush';
7
7
  import { RouterReplace } from './routerReplace';
8
- import { Rejections } from './rejection';
8
+ import { Rejection, Rejections } from './rejection';
9
9
  import { RouteContext, RouteContextToRejection, RouteContextToRoute } from './routeContext';
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[];
13
+ export declare function getHooks(value: Record<string, unknown> | undefined | null): Hooks[];
27
14
  export declare function combineHooks(parent: Route, child: Route): Hooks[];
28
- export type InternalRouteHooks<TRoute extends Route = Route, TContext extends RouteContext[] = []> = {
15
+ export type InternalRouteHooks<TRoute extends Route = Route, TContext extends RouteContext[] | undefined = undefined> = {
29
16
  /**
30
17
  * Registers a route hook to be called before the route is entered.
31
18
  */
@@ -57,6 +44,12 @@ export type ExternalRouteHooks<TRoute extends Route = Route, TContext extends Ro
57
44
  */
58
45
  onBeforeRouteEnter: AddBeforeEnterHook<[TRoute] | RouteContextToRoute<TContext>, RouteContextToRejection<TContext>, TRoute, Route>;
59
46
  };
47
+ export type RejectionHooks<TRejections extends string = string> = {
48
+ /**
49
+ * Registers a route hook to be called when a rejection occurs.
50
+ */
51
+ onRejection: AddRejectionHook<TRejections>;
52
+ };
60
53
  export type HookTiming = 'global' | 'component';
61
54
  /**
62
55
  * Union type for all component route hooks.
@@ -144,6 +137,16 @@ export type AfterHookRunner = <TRoutes extends Routes>(context: {
144
137
  to: RouterResolvedRouteUnion<TRoutes>;
145
138
  from: RouterResolvedRouteUnion<TRoutes> | null;
146
139
  }) => Promise<AfterHookResponse>;
140
+ export type RejectionHookContext<TRoutes extends Routes = Routes, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = {
141
+ to: ResolvedRouteUnion<TRouteTo> | null;
142
+ from: ResolvedRouteUnion<TRouteFrom> | null;
143
+ };
144
+ export type RejectionHook<TRejection extends string = string, TRoutes extends Routes = Routes, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = (rejection: TRejection, context: RejectionHookContext<TRoutes, TRouteTo, TRouteFrom>) => MaybePromise<void>;
145
+ export type AddRejectionHook<TRejections extends string = string, TRoutes extends Routes = Routes, TRouteTo extends Route = TRoutes[number], TRouteFrom extends Route = TRoutes[number]> = (hook: RejectionHook<TRejections, TRoutes, TRouteTo, TRouteFrom>) => HookRemove;
146
+ export type RejectionHookRunner<TRejection extends Rejection = Rejection, TRoutes extends Routes = Routes> = (rejection: TRejection, context: {
147
+ to: RouterResolvedRouteUnion<TRoutes> | null;
148
+ from: RouterResolvedRouteUnion<TRoutes> | null;
149
+ }) => void;
147
150
  export type ErrorHookContext<TRoute extends Route = Route, TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
148
151
  to: RouterResolvedRouteUnion<TRoutes>;
149
152
  from: RouterResolvedRouteUnion<TRoutes> | null;
@@ -3,17 +3,6 @@ import { Route, Routes } from './route';
3
3
  import { RouterReplace } from './routerReplace';
4
4
  import { UrlParamsReading, UrlParamsWriting } from './url';
5
5
  import { AllPropertiesAreOptional, MaybePromise } from './utilities';
6
- /**
7
- * redirect is returned by createRouteHooks but is not part of the Route type, so we use this type to assert that it exists.
8
- */
9
- type RouteWithRedirect<TRoute extends Route = Route> = TRoute & {
10
- redirect: RouteRedirect;
11
- };
12
- /**
13
- * Type guard to assert that a route has a redirect hook.
14
- * @internal
15
- */
16
- export declare function isRouteWithRedirect(route: Route): route is RouteWithRedirect;
17
6
  export type RouteRedirects<TRoute extends Route = Route> = {
18
7
  /**
19
8
  * Creates a redirect to redirect the current route to another route.
@@ -1,4 +1,19 @@
1
- import { Component } from 'vue';
1
+ import { Component, Ref } from 'vue';
2
+ import { ResolvedRoute } from './resolved';
3
+ import { Router } from './router';
4
+ import { RouterReject } from './routerReject';
5
+ import { Hooks } from '../models/hooks';
6
+ export declare const BUILT_IN_REJECTION_TYPES: readonly ["NotFound"];
7
+ export type BuiltInRejectionType = (typeof BUILT_IN_REJECTION_TYPES)[number];
8
+ export type RouterRejection<T extends Rejection = Rejection> = Ref<T | null>;
9
+ export type RouterRejections<TRouter extends Router> = TRouter['reject'] extends RouterReject<infer TRejections extends Rejection[]> ? TRejections[number] : never;
10
+ export declare const IS_REJECTION_SYMBOL: unique symbol;
11
+ export declare function isRejection(value: unknown): value is Rejection & RejectionInternal;
12
+ export type RejectionInternal = {
13
+ [IS_REJECTION_SYMBOL]: true;
14
+ route: ResolvedRoute;
15
+ hooks: Hooks[];
16
+ };
2
17
  /**
3
18
  * Represents an immutable array of Rejection instances.
4
19
  */
@@ -17,3 +32,4 @@ export type RejectionType<TRejections extends Rejections | undefined> = unknown
17
32
  export type ExtractRejections<T> = T extends {
18
33
  rejections: infer TRejections extends Rejections;
19
34
  } ? TRejections : [];
35
+ export type ExtractRejectionTypes<T extends Rejections> = T[number]['type'] extends string ? T[number]['type'] : never;
@@ -44,6 +44,10 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
44
44
  * Hash value of the route.
45
45
  */
46
46
  hash: string;
47
+ /**
48
+ * Title of the route.
49
+ */
50
+ title: Promise<string | undefined>;
47
51
  }>;
48
52
  /**
49
53
  * This type is the same as `ResolvedRoute<TRoutes[number]>` while remaining distributive
@@ -5,6 +5,18 @@ import { LastInArray } from './utilities';
5
5
  import { CreateRouteOptions } from './createRouteOptions';
6
6
  import { RouteContext } from './routeContext';
7
7
  import { Url } from './url';
8
+ import { GetTitle } from './titles';
9
+ import { Hooks } from '../models/hooks';
10
+ import { RouteRedirect } from './redirects';
11
+ export declare const IS_ROUTE_SYMBOL: unique symbol;
12
+ export declare function isRoute(value: unknown): value is Route & RouteInternal;
13
+ export type RouteInternal = {
14
+ [IS_ROUTE_SYMBOL]: true;
15
+ depth: number;
16
+ hooks: Hooks[];
17
+ redirect: RouteRedirect;
18
+ getTitle: GetTitle;
19
+ };
8
20
  /**
9
21
  * Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
10
22
  */
@@ -56,11 +68,6 @@ export type Route<TName extends string = string, TUrl extends Url = Url, TMeta e
56
68
  * Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
57
69
  */
58
70
  context: TContext;
59
- /**
60
- * A value that represents how many parents a route has. Used for route matching
61
- * @internal
62
- */
63
- depth: number;
64
71
  };
65
72
  export type GenericRoute = Url & {
66
73
  id: string;
@@ -70,5 +77,4 @@ export type GenericRoute = Url & {
70
77
  meta: RouteMeta;
71
78
  state: Record<string, Param>;
72
79
  prefetch?: PrefetchConfig;
73
- depth: number;
74
80
  };
@@ -1,7 +1,7 @@
1
1
  import { App, InjectionKey, Ref } from 'vue';
2
2
  import { RouterHistoryMode } from '../services/createRouterHistory';
3
3
  import { RouterRoute } from './routerRoute';
4
- import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook } from './hooks';
4
+ import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook, AddRejectionHook } from './hooks';
5
5
  import { PrefetchConfig } from './prefetch';
6
6
  import { ResolvedRoute } from './resolved';
7
7
  import { Route, Routes } from './route';
@@ -11,7 +11,7 @@ import { RouterResolve, RouterResolveOptions } from './routerResolve';
11
11
  import { RouterReject } from './routerReject';
12
12
  import { RouterPlugin } from './routerPlugin';
13
13
  import { RoutesName } from './routesMap';
14
- import { ExtractRejections, Rejections } from './rejection';
14
+ import { ExtractRejections, ExtractRejectionTypes, Rejections, BuiltInRejectionType } from './rejection';
15
15
  /**
16
16
  * Options to initialize a {@link Router} instance.
17
17
  */
@@ -130,6 +130,10 @@ export type Router<TRoutes extends Routes = any, TOptions extends RouterOptions
130
130
  * If the hook returns true, the error is considered handled and the other hooks are not run. If all hooks return false the error is rethrown
131
131
  */
132
132
  onError: AddErrorHook<TRoutes[number] | TPlugin['routes'][number], TRoutes | TPlugin['routes'], ExtractRejections<TOptions> | ExtractRejections<TPlugin>>;
133
+ /**
134
+ * Registers a hook to be called when a rejection occurs.
135
+ */
136
+ onRejection: AddRejectionHook<ExtractRejectionTypes<ExtractRejections<TOptions>> | ExtractRejectionTypes<ExtractRejections<TPlugin>> | BuiltInRejectionType, TRoutes | TPlugin['routes']>;
133
137
  /**
134
138
  * Given a URL, returns true if host does not match host stored on router instance
135
139
  */
@@ -9,6 +9,12 @@ import { RouterReplace } from './routerReplace';
9
9
  import { CallbackContextAbort } from '../services/createRouterCallbackContext';
10
10
  import { MaybePromise } from './utilities';
11
11
  export type EmptyRouterPlugin = RouterPlugin<[], []>;
12
+ export declare const IS_ROUTER_PLUGIN_SYMBOL: unique symbol;
13
+ export declare function isRouterPlugin(value: unknown): value is RouterPlugin & RouterPluginInternal;
14
+ export type RouterPluginInternal = {
15
+ [IS_ROUTER_PLUGIN_SYMBOL]: true;
16
+ hooks: Hooks;
17
+ };
12
18
  export type CreateRouterPluginOptions<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
13
19
  routes?: TRoutes;
14
20
  rejections?: TRejections;
@@ -16,19 +22,12 @@ export type CreateRouterPluginOptions<TRoutes extends Routes = Routes, TRejectio
16
22
  export type RouterPlugin<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
17
23
  /**
18
24
  * The routes supplied by the plugin.
19
- * @internal
20
25
  */
21
26
  routes: TRoutes;
22
27
  /**
23
28
  * The rejections supplied by the plugin.
24
- * @internal
25
- */
29
+ */
26
30
  rejections: TRejections;
27
- /**
28
- * The hooks supplied by the plugin.
29
- * @internal
30
- */
31
- hooks: Hooks;
32
31
  };
33
32
  type PluginBeforeRouteHookContext<TRoutes extends Routes, TRejections extends Rejections> = {
34
33
  from: ResolvedRoute | null;
@@ -1,3 +1,2 @@
1
- import { BuiltInRejectionType } from '../services/createRouterReject';
2
- import { Rejections, RejectionType } from './rejection';
1
+ import { BuiltInRejectionType, Rejections, RejectionType } from './rejection';
3
2
  export type RouterReject<TRejections extends Rejections | undefined> = <TSource extends (RejectionType<TRejections> | BuiltInRejectionType)>(type: TSource) => void;
@@ -31,6 +31,10 @@ export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
31
31
  * String value of the resolved URL.
32
32
  */
33
33
  readonly href: TRoute['href'];
34
+ /**
35
+ * Title of the route.
36
+ */
37
+ readonly title: TRoute['title'];
34
38
  params: TRoute['params'];
35
39
  state: TRoute['state'];
36
40
  get query(): URLSearchParams;
@@ -14,13 +14,9 @@ export type RouteSetTitle<TRoute extends Route = Route> = {
14
14
  */
15
15
  setTitle: SetTitle<TRoute>;
16
16
  };
17
- export type RouteGetTitle<TRoute extends Route = Route> = {
18
- /**
19
- * @internal
20
- * Gets the title for the route.
21
- */
22
- getTitle: GetTitle<TRoute>;
17
+ type CreateRouteTitle = {
18
+ setTitle: SetTitle;
19
+ getTitle: GetTitle;
23
20
  };
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;
21
+ export declare function createRouteTitle(parent: Route | undefined): CreateRouteTitle;
22
+ export {};
@@ -5,6 +5,11 @@ import { UrlString } from './urlString';
5
5
  import { ParamGetSet } from './paramTypes';
6
6
  import { MakeOptional } from '../utilities/makeOptional';
7
7
  export declare const IS_URL_SYMBOL: unique symbol;
8
+ export type UrlInternal = {
9
+ [IS_URL_SYMBOL]: true;
10
+ schema: Record<string, UrlPart>;
11
+ params: {};
12
+ };
8
13
  export type CreateUrlOptions = {
9
14
  host?: string | UrlPart | undefined;
10
15
  path?: string | UrlPart | undefined;
@@ -12,13 +17,7 @@ export type CreateUrlOptions = {
12
17
  hash?: string | UrlPart | undefined;
13
18
  };
14
19
  export type ToUrl<TOptions extends CreateUrlOptions> = Url<Identity<ToUrlPart<TOptions['host']>['params'] & ToUrlPart<TOptions['path']>['params'] & ToUrlQueryPart<TOptions['query']>['params'] & ToUrlPart<TOptions['hash']>['params']>>;
15
- /**
16
- * Type guard to assert that a url has a schema.
17
- * @internal
18
- */
19
- export declare function isUrlWithSchema(url: unknown): url is Url & {
20
- schema: Record<string, UrlPart>;
21
- };
20
+ export declare function isUrl(url: unknown): url is Url & UrlInternal;
22
21
  export type ParseUrlOptions = {
23
22
  /**
24
23
  * Whether to remove trailing slashes from the path. When true, trailing slashes will be removed from the path.
@@ -58,11 +57,6 @@ export type Url<TParams extends UrlParams = UrlParams> = {
58
57
  * True if the url is relative. False if the url is absolute.
59
58
  */
60
59
  isRelative: boolean;
61
- /**
62
- * @internal
63
- * Symbol to identify if the url is a valid url.
64
- */
65
- [IS_URL_SYMBOL]: true;
66
60
  };
67
61
  type UrlParamsArgs<TParams extends UrlParams> = AllPropertiesAreOptional<ToUrlParamsWriting<TParams>> extends true ? [params?: ToUrlParamsWriting<TParams>] : [params: ToUrlParamsWriting<TParams>];
68
62
  /**