@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.
Files changed (88) hide show
  1. package/dist/components/routerLink.d.ts +5 -4
  2. package/dist/components/routerProgress.d.ts +18 -0
  3. package/dist/components/routerProgressBar.d.ts +12 -0
  4. package/dist/components/viewTransition.browser.spec.d.ts +1 -0
  5. package/dist/components/viewTransition.d.ts +16 -0
  6. package/dist/components/viewTransition.spec-d.d.ts +1 -0
  7. package/dist/compositions/useLink.d.ts +2 -2
  8. package/dist/compositions/useLink.spec-d.d.ts +1 -0
  9. package/dist/compositions/useNavigation.browser.spec.d.ts +1 -0
  10. package/dist/compositions/useNavigation.d.ts +5 -0
  11. package/dist/compositions/useViewTransition.d.ts +5 -0
  12. package/dist/errors/contextRedirectError.d.ts +1 -2
  13. package/dist/errors/unreachableRouteError.d.ts +7 -0
  14. package/dist/kitbag-router.js +2449 -1826
  15. package/dist/kitbag-router.umd.cjs +2 -2
  16. package/dist/main.d.ts +37 -2
  17. package/dist/main.spec-d.d.ts +1 -0
  18. package/dist/services/addAlias.d.ts +19 -0
  19. package/dist/services/addAlias.spec-d.d.ts +1 -0
  20. package/dist/services/addAlias.spec.d.ts +1 -0
  21. package/dist/services/addView.d.ts +3 -3
  22. package/dist/services/createCanonicalUrl.d.ts +14 -0
  23. package/dist/services/createCanonicalUrl.spec.d.ts +1 -0
  24. package/dist/services/createDataStore.d.ts +4 -0
  25. package/dist/services/createNavigationProgress.d.ts +49 -0
  26. package/dist/services/createNavigationProgress.spec.d.ts +1 -0
  27. package/dist/services/createNavigationSignals.d.ts +17 -0
  28. package/dist/services/createNavigationSignals.spec.d.ts +1 -0
  29. package/dist/services/createResolvedRoute.d.ts +10 -1
  30. package/dist/services/createRoute.d.ts +2 -4
  31. package/dist/services/createRouteValueStore.d.ts +4 -0
  32. package/dist/services/createRouter.d.ts +2 -2
  33. package/dist/services/createRouterAssets.d.ts +30 -0
  34. package/dist/services/createRouterHistory.d.ts +10 -2
  35. package/dist/services/createRouterHooks.d.ts +7 -2
  36. package/dist/services/createUniqueIdSequence.d.ts +0 -1
  37. package/dist/services/createViewTransitions.browser.spec.d.ts +1 -0
  38. package/dist/services/createViewTransitions.d.ts +38 -0
  39. package/dist/services/getMatchesForUrl.d.ts +4 -0
  40. package/dist/services/getRoutesForRouter.d.ts +3 -2
  41. package/dist/services/history.d.ts +1 -0
  42. package/dist/services/routeRegex.d.ts +6 -1
  43. package/dist/services/routeViews.d.ts +7 -0
  44. package/dist/services/updateResolvedRoute.d.ts +7 -0
  45. package/dist/services/updateResolvedRoute.spec.d.ts +1 -0
  46. package/dist/services/withRouteMethods.d.ts +3 -3
  47. package/dist/tests/loaderPrefetch.browser.spec.d.ts +1 -0
  48. package/dist/tests/navigationBehavior.browser.spec.d.ts +1 -0
  49. package/dist/tests/navigationProgress.spec.d.ts +1 -0
  50. package/dist/tests/viewTransitions.browser.spec.d.ts +1 -0
  51. package/dist/types/addAlias.d.ts +79 -0
  52. package/dist/types/addView.d.ts +3 -4
  53. package/dist/types/callbackContext.d.ts +0 -5
  54. package/dist/types/createRouteOptions.d.ts +23 -63
  55. package/dist/types/hooks.d.ts +9 -5
  56. package/dist/types/navigation.d.ts +38 -0
  57. package/dist/types/prefetch.d.ts +6 -1
  58. package/dist/types/props.d.ts +0 -17
  59. package/dist/types/redirects.d.ts +4 -0
  60. package/dist/types/resolved.d.ts +22 -2
  61. package/dist/types/route.d.ts +4 -3
  62. package/dist/types/routeAlias.d.ts +41 -0
  63. package/dist/types/routeCallbackContext.d.ts +1 -0
  64. package/dist/types/routeViews.d.ts +5 -7
  65. package/dist/types/routeWithMethods.d.ts +3 -2
  66. package/dist/types/router.d.ts +13 -0
  67. package/dist/types/routerLink.d.ts +1 -1
  68. package/dist/types/routerNavigationInternal.d.ts +29 -0
  69. package/dist/types/routerPush.d.ts +8 -0
  70. package/dist/types/routerReplace.d.ts +3 -0
  71. package/dist/types/routerRoute.d.ts +5 -1
  72. package/dist/types/useLink.d.ts +5 -0
  73. package/dist/types/viewTransition.d.ts +49 -0
  74. package/dist/utilities/components.d.ts +6 -2
  75. package/dist/utilities/getRegexMatcher.d.ts +1 -0
  76. package/dist/utilities/getRegexMatcher.spec.d.ts +1 -0
  77. package/dist/utilities/navigation.d.ts +15 -0
  78. package/dist/utilities/percentEncoding.d.ts +10 -0
  79. package/dist/utilities/percentEncoding.spec.d.ts +1 -0
  80. package/dist/utilities/promises.d.ts +4 -0
  81. package/dist/utilities/promises.spec.d.ts +1 -0
  82. package/dist/utilities/testHelpers.d.ts +32 -100
  83. package/dist/utilities/viewTransition.d.ts +11 -0
  84. package/dist/utilities/viewTransition.spec.d.ts +1 -0
  85. package/package.json +9 -8
  86. package/dist/services/createNavigationIds.d.ts +0 -6
  87. package/dist/services/createRouteViews.d.ts +0 -16
  88. /package/dist/{services/createNavigationIds.spec.d.ts → components/routerProgress.browser.spec.d.ts} +0 -0
package/dist/main.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { RouterAssets } from './services/createRouterAssets';
2
2
  import { RegisteredRouter } from './types/register';
3
- export type { WithHost, WithoutHost, WithParent, WithoutParent, CreateRouteOptions, PropsGetter, RouterViewPropsGetter, CreateRouteProps, ToRoute } from './types/createRouteOptions';
3
+ export type { WithHost, WithoutHost, WithParent, WithoutParent, CreateRouteOptions, ToRoute } from './types/createRouteOptions';
4
4
  export type { RouteAddView, AddViewOptions, AddViewPropsGetter, AddViewPropsCallbackContext } from './types/addView';
5
5
  export type { RouteAddLoader, AddLoaderOptions, LoaderGetter } from './types/addLoader';
6
+ export type { RouteAddAlias, AddAliasOptions } from './types/addAlias';
7
+ export type { AliasTransform, AliasTransformContext } from './types/routeAlias';
6
8
  export type { RouteCallbackContext } from './types/routeCallbackContext';
7
9
  export type { RouteViews } from './types/routeViews';
8
10
  export type { RouteLoader, RouteLoaders } from './types/routeLoaders';
@@ -14,10 +16,12 @@ export * from './types/querySource';
14
16
  export type { RouteRedirects } from './types/redirects';
15
17
  export * from './types/register';
16
18
  export type { Rejection, RejectionType, Rejections } from './types/rejection';
17
- export * from './types/resolved';
19
+ export { isResolvedRoute } from './types/resolved';
20
+ export type { ResolvedRoute, WithData, ResolvedRouteUnion, RouterResolvedRouteUnion } from './types/resolved';
18
21
  export type { Route, CreatedRouteOptions } from './types/route';
19
22
  export * from './types/router';
20
23
  export * from './types/routerLink';
24
+ export type { RouterProgressProps } from './components/routerProgress';
21
25
  export type { RouterPlugin, CreateRouterPluginOptions } from './types/routerPlugin';
22
26
  export * from './types/routerPush';
23
27
  export * from './types/routerPush';
@@ -30,6 +34,8 @@ export * from './types/routerRoute';
30
34
  export * from './types/urlString';
31
35
  export type { Url, CreateUrlOptions, ParseUrlOptions } from './types/url';
32
36
  export * from './types/useLink';
37
+ export * from './types/viewTransition';
38
+ export * from './types/navigation';
33
39
  export { DuplicateParamsError } from './errors/duplicateParamsError';
34
40
  export { LoaderDataAccessError } from './errors/loaderDataAccessError';
35
41
  export { LoaderNameConflict } from './errors/loaderNameConflict';
@@ -39,6 +45,7 @@ export { PayloadValueError } from './errors/payloadValueError';
39
45
  export { RouterNotInstalledError } from './errors/routerNotInstalledError';
40
46
  export { UseRouteInvalidError } from './errors/useRouteInvalidError';
41
47
  export { SsrOptionRequiredError } from './errors/ssrOptionRequiredError';
48
+ export { UnreachableRouteError } from './errors/unreachableRouteError';
42
49
  export { createRoute } from './services/createRoute';
43
50
  export { createRejection } from './services/createRejection';
44
51
  export { createExternalRoute } from './services/createExternalRoute';
@@ -53,6 +60,7 @@ export { literal } from './services/literal';
53
60
  export { createParam } from './services/createParam';
54
61
  export { createRouter } from './services/createRouter';
55
62
  export { createUrl } from './services/createUrl';
63
+ export type { ViewTransitionProps } from './components/viewTransition';
56
64
  /**
57
65
  * Registers a hook that is called before a route is left. Must be called from setup.
58
66
  * This is useful for performing actions or cleanups before navigating away from a route component.
@@ -113,6 +121,17 @@ export declare const RouterView: RouterAssets<RegisteredRouter>['RouterView'];
113
121
  * @group Components
114
122
  */
115
123
  export declare const RouterLink: RouterAssets<RegisteredRouter>['RouterLink'];
124
+ /** Names a shared element for a view transition. @group Components */
125
+ export declare const ViewTransition: new <TElement extends keyof HTMLElementTagNameMap = "span">(props: import('./main').ViewTransitionProps<TElement>) => import('vue').ComponentPublicInstance<import('./main').ViewTransitionProps<TElement>>;
126
+ /**
127
+ * A component to render a bar across the top of the page while a navigation is pending, filled by how
128
+ * much of the navigation's work has settled.
129
+ *
130
+ * @param props - The props to pass to the router progress component.
131
+ * @returns The router progress component.
132
+ * @group Components
133
+ */
134
+ export declare const RouterProgress: RouterAssets<RegisteredRouter>['RouterProgress'];
116
135
  /**
117
136
  * A composition to access the current route or verify a specific route name within a Vue component.
118
137
  * This function provides two overloads:
@@ -164,9 +183,25 @@ export declare const useLink: RouterAssets<RegisteredRouter>['useLink'];
164
183
  * @group Compositions
165
184
  */
166
185
  export declare const useRejection: RouterAssets<RegisteredRouter>['useRejection'];
186
+ /**
187
+ * A composition to access the view transition in flight, if any.
188
+ *
189
+ * @returns The router's view transition state.
190
+ * @group Compositions
191
+ */
192
+ export declare const useViewTransition: RouterAssets<RegisteredRouter>['useViewTransition'];
193
+ /**
194
+ * A composition to access the navigation under way: whether one is pending, which routes it leaves and
195
+ * leads to, and how much of the work it waits on has settled.
196
+ *
197
+ * @returns {UseNavigation} Reactive state of the navigation under way.
198
+ * @group Compositions
199
+ */
200
+ export declare const useNavigation: RouterAssets<RegisteredRouter>['useNavigation'];
167
201
  declare module 'vue' {
168
202
  interface GlobalComponents {
169
203
  RouterView: typeof RouterView;
170
204
  RouterLink: typeof RouterLink;
205
+ RouterProgress: typeof RouterProgress;
171
206
  }
172
207
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { AddAliasOptions } from '../types/addAlias';
2
+ import { AliasTransform, RouteAlias } from '../types/routeAlias';
3
+ import { CreatedRouteOptions, Route } from '../types/route';
4
+ /**
5
+ * The loose runtime signature of the `addAlias` method. Purposely wide: it returns Route rather than the
6
+ * refined chainable route `RouteAddAlias` describes.
7
+ */
8
+ export type AddAlias = (options: AddAliasOptions, transform?: AliasTransform) => Route;
9
+ /**
10
+ * The aliases a nested route inherits: each of its parent's aliases combined with the route's own segment.
11
+ * The parent's own url is left out, since combined with the route's own segment it is the route's own url,
12
+ * not an alias.
13
+ */
14
+ export declare function combineAliases(parent: Route, child: Route): RouteAlias[];
15
+ /**
16
+ * The aliases an `addAlias` call adds: the alias segment combined with every url the parent can be reached
17
+ * under, or standing alone when there is no parent to combine with.
18
+ */
19
+ export declare function createAliases(match: CreatedRouteOptions, options: AddAliasOptions, transform: AliasTransform | undefined): RouteAlias[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Component } from 'vue';
2
2
  import { AnyPayloadTransformer } from './payload';
3
- import { PropsGetter } from '../types/createRouteOptions';
3
+ import { AddViewPropsGetter } from '../types/addView';
4
4
  import { PrefetchConfig } from '../types/prefetch';
5
5
  import { CreatedRouteOptions, Route } from '../types/route';
6
6
  /**
@@ -9,7 +9,7 @@ import { CreatedRouteOptions, Route } from '../types/route';
9
9
  */
10
10
  type ViewOptions = {
11
11
  name?: string;
12
- props?: PropsGetter;
12
+ props?: AddViewPropsGetter<Route, Component>;
13
13
  prefetch?: PrefetchConfig;
14
14
  transformer?: AnyPayloadTransformer;
15
15
  };
@@ -25,7 +25,7 @@ export type AddView = (...args: AddViewParameters) => Route;
25
25
  type View = {
26
26
  name: string;
27
27
  component: Component;
28
- props: PropsGetter | undefined;
28
+ props: AddViewPropsGetter<Route, Component> | undefined;
29
29
  prefetch: PrefetchConfig | undefined;
30
30
  transformer: AnyPayloadTransformer | undefined;
31
31
  };
@@ -0,0 +1,14 @@
1
+ import { RouteAliasMatch } from '../types/routeAlias';
2
+ import { Url } from '../types/url';
3
+ import { UrlString } from '../types/urlString';
4
+ type CreateCanonicalUrlContext = {
5
+ route: Url;
6
+ params: Record<string, unknown>;
7
+ alias?: RouteAliasMatch;
8
+ };
9
+ /**
10
+ * Adds undeclared query values and a hash to the route's own url. Declared query keys (including
11
+ * omitted optional params) and a declared hash belong to the route and cannot be replaced by extras.
12
+ */
13
+ export declare function createCanonicalUrl(visitedUrl: UrlString, context: CreateCanonicalUrlContext): UrlString;
14
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -39,6 +39,10 @@ export type DataStore = {
39
39
  * What is known about a key, without waiting for it. Reactive, and readable during render.
40
40
  */
41
41
  get: (key: string) => DataResult;
42
+ /**
43
+ * Aborts when the store is disposed, so a getter still running can stop work nothing will read.
44
+ */
45
+ signal: AbortSignal;
42
46
  /**
43
47
  * Ends the store. Every value is rejected so that anything waiting on one resumes rather than staying
44
48
  * suspended, then discarded.
@@ -0,0 +1,49 @@
1
+ import { ResolvedRoute } from '../types/resolved';
2
+ import { UseNavigation } from '../types/navigation';
3
+ /**
4
+ * The units of work one navigation waits on, counted as they are planned and as they settle. Every method
5
+ * is a no-op once the navigation is over or another has begun, so a unit settling late never counts
6
+ * against a later navigation.
7
+ */
8
+ export type NavigationProgressTracker = {
9
+ /**
10
+ * Plans units that will be tracked later.
11
+ */
12
+ expect: (count: number) => void;
13
+ /**
14
+ * Counts each unit as settled when it does, however it settles. Only units already expected.
15
+ */
16
+ track: (...units: Promise<unknown>[]) => void;
17
+ /**
18
+ * Nothing more will be tracked. The navigation ends once every tracked unit has settled.
19
+ */
20
+ close: () => void;
21
+ /**
22
+ * Ends the navigation as having gone nowhere, wiping its counts.
23
+ */
24
+ abort: () => void;
25
+ };
26
+ type BeginContext = {
27
+ to: ResolvedRoute | null;
28
+ from: ResolvedRoute | null;
29
+ /**
30
+ * Units known before anything runs, so the total never shrinks a navigation's progress midway.
31
+ */
32
+ expected: number;
33
+ /**
34
+ * An inert tracker counts nothing and leaves the state alone, for navigations with nothing to show.
35
+ */
36
+ inert?: boolean;
37
+ };
38
+ export type NavigationProgress = UseNavigation & {
39
+ /**
40
+ * Begins counting a navigation, discarding whatever the navigation before it still had outstanding.
41
+ */
42
+ begin: (context: BeginContext) => NavigationProgressTracker;
43
+ /**
44
+ * Aborts the navigation being counted, if any.
45
+ */
46
+ stop: () => void;
47
+ };
48
+ export declare function createNavigationProgress(): NavigationProgress;
49
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Which navigation is under way. Only the latest navigation counts: beginning another makes the one before
3
+ * it moot, and so does stopping the router.
4
+ */
5
+ export type NavigationSignals = {
6
+ /**
7
+ * Begins a navigation, aborting the one under way. The controller aborts once a later navigation begins
8
+ * or the router stops, and is already aborted for a navigation begun after the router stopped. The
9
+ * navigation aborts it itself when it ends without committing.
10
+ */
11
+ begin: () => AbortController;
12
+ /**
13
+ * Aborts the navigation under way, and every one begun afterwards.
14
+ */
15
+ stop: () => void;
16
+ };
17
+ export declare function createNavigationSignals(): NavigationSignals;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,13 @@
1
1
  import { RouterResolveOptions } from '../types/routerResolve';
2
2
  import { ResolvedRoute } from '../types/resolved';
3
3
  import { Route } from '../types/route';
4
- export declare function createResolvedRoute(route: Route, params?: Record<string, unknown>, options?: RouterResolveOptions): ResolvedRoute;
4
+ import { RouteAliasMatch } from '../types/routeAlias';
5
+ type CreateResolvedRouteOptions = RouterResolveOptions & {
6
+ /**
7
+ * The alias the route was matched through, which is what `href` is built from instead of the route's
8
+ * own url.
9
+ */
10
+ alias?: RouteAliasMatch;
11
+ };
12
+ export declare function createResolvedRoute(route: Route, params?: Record<string, unknown>, options?: CreateResolvedRouteOptions): ResolvedRoute;
13
+ export {};
@@ -1,5 +1,3 @@
1
- import { CreateRouteOptions, PropsGetter, CreateRouteProps, ToRouteMatches, ToRouteUrl, RouterViewPropsGetter } from '../types/createRouteOptions';
1
+ import { CreateRouteOptions, ToRouteMatches, ToRouteUrl } from '../types/createRouteOptions';
2
2
  import { RouteWithMethods } from '../types/routeWithMethods';
3
- 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];
4
- export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): RouteWithMethods<ToRouteUrl<TOptions>, ToRouteMatches<TOptions, TProps>>;
5
- export {};
3
+ export declare function createRoute<const TOptions extends CreateRouteOptions>(options: TOptions): RouteWithMethods<ToRouteUrl<TOptions>, ToRouteMatches<TOptions>>;
@@ -20,6 +20,10 @@ export type RouteValueResponse = CallbackContextSuccess | CallbackContextPush |
20
20
  export type RouteValueResponses = {
21
21
  props: Promise<RouteValueResponse>;
22
22
  loaders: Promise<RouteValueResponse>;
23
+ /**
24
+ * Each value on its own as it settles, for whoever counts them.
25
+ */
26
+ values: Promise<unknown>[];
23
27
  };
24
28
  /**
25
29
  * A store of a route's values, whichever store that is.
@@ -17,8 +17,8 @@ import { EmptyRouterPlugin, RouterPlugin } from '../types/routerPlugin';
17
17
  * const About = { template: '<div>About</div>' }
18
18
  *
19
19
  * export const routes = [
20
- * createRoute({ name: 'home', path: '/', component: Home }),
21
- * createRoute({ name: 'path', path: '/about', component: About }),
20
+ * createRoute({ name: 'home', path: '/' }).addView(Home),
21
+ * createRoute({ name: 'path', path: '/about' }).addView(About),
22
22
  * ] as const
23
23
  *
24
24
  * const router = createRouter(routes)
@@ -1,7 +1,9 @@
1
+ import { ViewTransition } from '../components/viewTransition';
1
2
  import { Router, RouterRoutes, RouterRejections } from '../types/router';
2
3
  import { InjectionKey } from 'vue';
3
4
  import { createRouterView } from '../components/routerView';
4
5
  import { createRouterLink } from '../components/routerLink';
6
+ import { createRouterProgress } from '../components/routerProgress';
5
7
  import { createUseRoute } from '../compositions/useRoute';
6
8
  import { createUseRouter } from '../compositions/useRouter';
7
9
  import { createUseQueryValue } from '../compositions/useQueryValue';
@@ -9,6 +11,8 @@ import { createUseLink } from '../compositions/useLink';
9
11
  import { createIsRoute } from '../guards/routes';
10
12
  import { AddBeforeLeaveHook, AddBeforeUpdateHook, AddAfterLeaveHook, AddAfterUpdateHook } from '../types/hooks';
11
13
  import { createUseRejection } from '../compositions/useRejection';
14
+ import { createUseViewTransition } from '../compositions/useViewTransition';
15
+ import { createUseNavigation } from '../compositions/useNavigation';
12
16
  export type RouterAssets<TRouter extends Router> = {
13
17
  /**
14
18
  * Registers a hook that is called before a route is left. Must be called from setup.
@@ -70,6 +74,17 @@ export type RouterAssets<TRouter extends Router> = {
70
74
  * @group Components
71
75
  */
72
76
  RouterLink: ReturnType<typeof createRouterLink<TRouter>>;
77
+ /** Names a shared element for a view transition. @group Components */
78
+ ViewTransition: typeof ViewTransition;
79
+ /**
80
+ * A component to render a bar across the top of the page while a navigation is pending, filled by how
81
+ * much of the navigation's work has settled.
82
+ *
83
+ * @param props - The props to pass to the router progress component.
84
+ * @returns The router progress component.
85
+ * @group Components
86
+ */
87
+ RouterProgress: ReturnType<typeof createRouterProgress<TRouter>>;
73
88
  /**
74
89
  * A composition to access the current route or verify a specific route name within a Vue component.
75
90
  * This function provides two overloads:
@@ -121,6 +136,21 @@ export type RouterAssets<TRouter extends Router> = {
121
136
  * @group Compositions
122
137
  */
123
138
  useRejection: ReturnType<typeof createUseRejection<TRouter>>;
139
+ /**
140
+ * A composition to access the view transition in flight, if any.
141
+ *
142
+ * @returns The router's view transition state.
143
+ * @group Compositions
144
+ */
145
+ useViewTransition: ReturnType<typeof createUseViewTransition<TRouter>>;
146
+ /**
147
+ * A composition to access the navigation under way: whether one is pending, which routes it leaves and
148
+ * leads to, and how much of the work it waits on has settled.
149
+ *
150
+ * @returns {UseNavigation} Reactive state of the navigation under way.
151
+ * @group Compositions
152
+ */
153
+ useNavigation: ReturnType<typeof createUseNavigation<TRouter>>;
124
154
  };
125
155
  export declare function createRouterAssets<TRouter extends Router>(router: TRouter): RouterAssets<TRouter>;
126
156
  export declare function createRouterAssets<TRouter extends Router>(routerKey: InjectionKey<TRouter>): RouterAssets<TRouter>;
@@ -1,4 +1,4 @@
1
- import { History, Listener } from './history';
1
+ import { History, Update } from './history';
2
2
  type NavigationPushOptions = {
3
3
  replace?: boolean;
4
4
  state?: unknown;
@@ -12,8 +12,16 @@ type RouterHistory = History & {
12
12
  stopListening: () => void;
13
13
  };
14
14
  export type RouterHistoryMode = 'auto' | 'browser' | 'memory' | 'hash';
15
+ /** Called by the router while the traversal navigation is active. */
16
+ export type RouterHistoryTraversal = {
17
+ commit: () => void;
18
+ restore: () => void;
19
+ };
20
+ type RouterHistoryUpdate = Update & {
21
+ traversal?: RouterHistoryTraversal;
22
+ };
15
23
  type RouterHistoryOptions = {
16
- listener: Listener;
24
+ listener: (event: RouterHistoryUpdate) => void;
17
25
  mode?: RouterHistoryMode;
18
26
  };
19
27
  export declare function createRouterHistory({ mode, listener }: RouterHistoryOptions): RouterHistory;
@@ -1,6 +1,7 @@
1
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
- export declare const getRouterHooksKey: (routerKey: import('vue').InjectionKey<import('../main').Router>) => import('vue').InjectionKey<RouterHooks>;
3
+ import { RedirectStatus } from '../types/router';
4
+ export declare const getRouterHooksKey: (routerKey: import('vue').InjectionKey<import('../types/router').Router>) => import('vue').InjectionKey<RouterHooks>;
4
5
  export type RouterHooks = HasVueAppStore & {
5
6
  runBeforeRouteHooks: BeforeHookRunner;
6
7
  runAfterRouteHooks: AfterHookRunner;
@@ -17,4 +18,8 @@ export type RouterHooks = HasVueAppStore & {
17
18
  onError: AddErrorHook;
18
19
  onRejection: AddRejectionHook;
19
20
  };
20
- export declare function createRouterHooks(): RouterHooks;
21
+ type RouterHooksOptions = {
22
+ redirectStatus: RedirectStatus;
23
+ };
24
+ export declare function createRouterHooks({ redirectStatus }: RouterHooksOptions): RouterHooks;
25
+ export {};
@@ -1,2 +1 @@
1
1
  export declare function createUniqueIdSequence(): () => string;
2
- export declare function isFirstUniqueSequenceId(id: string): boolean;
@@ -0,0 +1,38 @@
1
+ import { ResolvedRoute } from '../types/resolved';
2
+ import { RouterViewTransition, ViewTransitionTypes } from '../types/viewTransition';
3
+ export type PendingViewTransition = {
4
+ to: ResolvedRoute;
5
+ from: ResolvedRoute;
6
+ types: ViewTransitionTypes;
7
+ };
8
+ export type ViewTransitions = {
9
+ /**
10
+ * The transition in flight, as the router exposes it.
11
+ */
12
+ viewTransition: RouterViewTransition;
13
+ /**
14
+ * Records the navigation about to transition, ahead of its data loading, so the page being left can
15
+ * prepare before it is captured.
16
+ */
17
+ prepare: (navigation: PendingViewTransition) => void;
18
+ /**
19
+ * Forgets a prepared navigation that was superseded before it transitioned, unless a newer one has
20
+ * taken over the state since.
21
+ */
22
+ cancel: (navigation: PendingViewTransition) => void;
23
+ /**
24
+ * Forgets the transition in flight, for a navigation that commits without one.
25
+ */
26
+ reset: () => void;
27
+ /**
28
+ * Runs the update inside a view transition. Resolves after the update and Vue flush, ahead of the animation.
29
+ */
30
+ start: (update: () => void | Promise<unknown>) => Promise<void>;
31
+ };
32
+ /**
33
+ * Owns the one transition the document runs at a time. Starting another while the first has not yet run
34
+ * its callback leaves the browser free to run the two callbacks in either order, so a navigation arriving
35
+ * then takes over the pending callback instead. Once the callback has run the browser skips the old
36
+ * animation on its own.
37
+ */
38
+ export declare function createViewTransitions(): ViewTransitions;
@@ -4,5 +4,9 @@ import { ParseUrlOptions } from '../types/url';
4
4
  type MatchOptions = {
5
5
  state?: Partial<unknown>;
6
6
  } & ParseUrlOptions;
7
+ /**
8
+ * Every route's own url is tried before any alias, so an alias never outranks another route's own url
9
+ * regardless of the order the routes were defined in.
10
+ */
7
11
  export declare function getMatchForUrl(routes: Routes, url: string, options?: MatchOptions): ResolvedRoute | undefined;
8
12
  export {};
@@ -4,12 +4,13 @@ import { BuiltInRejectionType, Rejection, RejectionInternal } from '../types/rej
4
4
  import { RouterOptions } from '../types/router';
5
5
  /**
6
6
  * Takes in routes and plugins and returns a list of routes with the base route inserted if provided.
7
- * Also checks for duplicate names in the routes.
7
+ * Also checks for duplicate names and unreachable paths in the routes.
8
8
  *
9
9
  * @throws {DuplicateNamesError} If there are duplicate names in the routes.
10
+ * @throws {UnreachableRouteError} If a named route's path does not start with `/`.
10
11
  */
11
12
  export declare function getRoutesForRouter(routes: Routes | Routes[], plugins?: RouterPlugin[], options?: RouterOptions): {
12
- routes: (import('../main').Url & {
13
+ routes: (import('../types/url').Url & {
13
14
  id: string;
14
15
  matches: import('../types/route').CreatedRouteOptions[];
15
16
  name: string;
@@ -23,6 +23,7 @@ export interface Transition extends Update {
23
23
  export type Blocker = (tx: Transition) => void;
24
24
  export type To = string | Partial<Path>;
25
25
  export interface History {
26
+ readonly index: number | null;
26
27
  readonly action: Action;
27
28
  readonly location: Location;
28
29
  createHref: (to: To) => string;
@@ -7,13 +7,18 @@ export declare const regexCatchAll = "[^/]*";
7
7
  export declare const regexGreedyCatchAll = ".*";
8
8
  export declare const regexCaptureAll = "([^/]*)";
9
9
  export declare const regexGreedyCaptureAll = "(.*)";
10
+ export declare function escapeRegExp(string: string): string;
10
11
  export declare function splitByMatches(string: string, regexp: RegExp): string[];
11
12
  export declare function generateRouteHostRegexPattern(host: string): RegExp;
12
13
  export declare function generateRoutePathRegexPattern(path: string): RegExp;
13
14
  export declare function generateRouteHashRegexPattern(hash: string): RegExp;
14
15
  export declare function generateRouteQueryRegexPatterns(query: string): RegExp[];
15
16
  export declare function replaceParamSyntaxWithCatchAlls(value: string): string;
16
- export declare function replaceIndividualParamWithCaptureGroup(path: UrlPart, paramName: string): string;
17
+ /**
18
+ * A pattern that captures one param and matches the rest of the part literally, with every other param
19
+ * replaced by a catch-all.
20
+ */
21
+ export declare function replaceParamWithCaptureGroupAndEscapeRest(part: UrlPart, paramName: string): string;
17
22
  export declare function isOptionalParamSyntax(value: string): boolean;
18
23
  export declare function isRequiredParamSyntax(value: string): boolean;
19
24
  export declare function isGreedyParamSyntax(value: string): boolean;
@@ -0,0 +1,7 @@
1
+ import { RouteViews } from '../types/routeViews';
2
+ export declare const DEFAULT_VIEW_NAME = "default";
3
+ /**
4
+ * The names of the views that have a props getter. A view without one is never computed, so waiting on it
5
+ * would never settle.
6
+ */
7
+ export declare function viewNamesWithProps(views: RouteViews): string[];
@@ -0,0 +1,7 @@
1
+ import { ResolvedRoute } from '../types/resolved';
2
+ import { RouterResolveOptions } from '../types/routerResolve';
3
+ /**
4
+ * Applies query, hash, and state to an already resolved route the same way a push with those options
5
+ * changes the url. Query values are appended, hash and state values override.
6
+ */
7
+ export declare function updateResolvedRoute(route: ResolvedRoute, options: RouterResolveOptions): ResolvedRoute;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Route } from '../types/route';
2
2
  /**
3
- * Attaches the chainable, immutable route methods — `addView` and `addLoader`. Each call rebuilds the
4
- * route's own (last) match and returns a new route with the methods re-attached, so neither mutates the
5
- * route it was called on, and chaining one never drops the other.
3
+ * Attaches the chainable, immutable route methods — `addView`, `addLoader`, and `addAlias`. Each call
4
+ * rebuilds the route's own (last) match, or its aliases, and returns a new route with the methods
5
+ * re-attached, so none mutates the route it was called on, and chaining one never drops another.
6
6
  */
7
7
  export declare function withRouteMethods<TRoute extends Route>(route: TRoute): TRoute;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};