@kitbag/router 0.20.6 → 0.20.7

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 (203) hide show
  1. package/dist/components/echo.d.ts +6 -0
  2. package/dist/components/helloWorld.d.ts +2 -0
  3. package/dist/components/rejection.d.ts +2 -0
  4. package/dist/components/routerLink.browser.spec.d.ts +1 -0
  5. package/dist/components/routerLink.d.ts +36 -0
  6. package/dist/components/routerView.browser.spec.d.ts +1 -0
  7. package/dist/components/routerView.d.ts +20 -0
  8. package/dist/components/routerView.spec.d.ts +1 -0
  9. package/dist/compositions/useComponentsStore.d.ts +5 -0
  10. package/dist/compositions/useEventListener.d.ts +2 -0
  11. package/dist/compositions/useLink.d.ts +16 -0
  12. package/dist/compositions/usePrefetching.d.ts +14 -0
  13. package/dist/compositions/usePropStore.d.ts +7 -0
  14. package/dist/compositions/useQueryValue.browser.spec.d.ts +1 -0
  15. package/dist/compositions/useQueryValue.d.ts +15 -0
  16. package/dist/compositions/useRejection.d.ts +7 -0
  17. package/dist/compositions/useRoute.browser.spec.d.ts +1 -0
  18. package/dist/compositions/useRoute.d.ts +16 -0
  19. package/dist/compositions/useRouter.d.ts +3 -0
  20. package/dist/compositions/useRouterDepth.d.ts +8 -0
  21. package/dist/compositions/useRouterHooks.d.ts +4 -0
  22. package/dist/compositions/useVisibilityObserver.d.ts +8 -0
  23. package/dist/errors/callbackContextAbortError.d.ts +5 -0
  24. package/dist/errors/callbackContextPushError.d.ts +5 -0
  25. package/dist/errors/callbackContextRejectionError.d.ts +6 -0
  26. package/dist/errors/duplicateNamesError.d.ts +11 -0
  27. package/dist/errors/duplicateParamsError.d.ts +13 -0
  28. package/dist/errors/initialRouteMissingError.d.ts +3 -0
  29. package/dist/errors/invalidRouteParamValueError.d.ts +2 -0
  30. package/dist/errors/metaPropertyConflict.d.ts +8 -0
  31. package/dist/errors/routeNotFoundError.d.ts +6 -0
  32. package/dist/errors/routerNotInstalledError.d.ts +7 -0
  33. package/dist/errors/useRouteInvalidError.d.ts +13 -0
  34. package/dist/guards/routes.d.ts +46 -0
  35. package/dist/guards/routes.spec-d.d.ts +1 -0
  36. package/dist/keys.d.ts +3 -0
  37. package/dist/kitbag-router.d.ts +2 -1433
  38. package/dist/kitbag-router.js +1751 -1675
  39. package/dist/kitbag-router.umd.cjs +3 -3
  40. package/dist/main.d.ts +302 -0
  41. package/dist/models/RouteHooks.d.ts +9 -0
  42. package/dist/models/RouterRouteHooks.d.ts +10 -0
  43. package/dist/services/arrayOf.d.ts +7 -0
  44. package/dist/services/arrayOf.spec.d.ts +1 -0
  45. package/dist/services/combineHash.d.ts +4 -0
  46. package/dist/services/combineHash.spec.d.ts +1 -0
  47. package/dist/services/combineMeta.d.ts +2 -0
  48. package/dist/services/combineMeta.spec.d.ts +1 -0
  49. package/dist/services/combinePath.d.ts +12 -0
  50. package/dist/services/combinePath.spec-d.d.ts +1 -0
  51. package/dist/services/combinePath.spec.d.ts +1 -0
  52. package/dist/services/combineQuery.d.ts +13 -0
  53. package/dist/services/combineQuery.spec.d.ts +1 -0
  54. package/dist/services/combineState.d.ts +3 -0
  55. package/dist/services/combineState.spec.d.ts +1 -0
  56. package/dist/services/component.browser.spec.d.ts +1 -0
  57. package/dist/services/component.d.ts +12 -0
  58. package/dist/services/createCallbackContext.d.ts +38 -0
  59. package/dist/services/createComponentHooks.d.ts +11 -0
  60. package/dist/services/createComponentsStore.d.ts +7 -0
  61. package/dist/services/createCurrentRoute.d.ts +13 -0
  62. package/dist/services/createExternalRoute.d.ts +3 -0
  63. package/dist/services/createExternalRoute.spec.d.ts +1 -0
  64. package/dist/services/createIsExternal.d.ts +1 -0
  65. package/dist/services/createIsExternal.spec.d.ts +1 -0
  66. package/dist/services/createParam.d.ts +6 -0
  67. package/dist/services/createPropStore.d.ts +13 -0
  68. package/dist/services/createResolvedRoute.d.ts +4 -0
  69. package/dist/services/createResolvedRouteForUrl.browser.spec.d.ts +1 -0
  70. package/dist/services/createResolvedRouteForUrl.d.ts +3 -0
  71. package/dist/services/createResolvedRouteQuery.d.ts +5 -0
  72. package/dist/services/createRoute.d.ts +4 -0
  73. package/dist/services/createRoute.spec-d.d.ts +1 -0
  74. package/dist/services/createRoute.spec.d.ts +1 -0
  75. package/dist/services/createRouteId.d.ts +1 -0
  76. package/dist/services/createRouter.browser.spec.d.ts +1 -0
  77. package/dist/services/createRouter.d.ts +28 -0
  78. package/dist/services/createRouter.spec-d.d.ts +1 -0
  79. package/dist/services/createRouter.spec.d.ts +1 -0
  80. package/dist/services/createRouterAssets.d.ts +118 -0
  81. package/dist/services/createRouterHistory.browser.spec.d.ts +1 -0
  82. package/dist/services/createRouterHistory.d.ts +20 -0
  83. package/dist/services/createRouterHooks.d.ts +20 -0
  84. package/dist/services/createRouterKeyStore.d.ts +3 -0
  85. package/dist/services/createRouterPlugin.browser.spec.d.ts +1 -0
  86. package/dist/services/createRouterPlugin.d.ts +4 -0
  87. package/dist/services/createRouterReject.d.ts +16 -0
  88. package/dist/services/createRouterRoute.d.ts +7 -0
  89. package/dist/services/createRouterRoute.spec.d.ts +1 -0
  90. package/dist/services/createUniqueIdSequence.d.ts +2 -0
  91. package/dist/services/createVisibilityObserver.d.ts +7 -0
  92. package/dist/services/createVueAppStore.d.ts +8 -0
  93. package/dist/services/getGlobalHooksForRouter.d.ts +4 -0
  94. package/dist/services/getGlobalRouteHooks.d.ts +5 -0
  95. package/dist/services/getInitialUrl.browser.spec.d.ts +1 -0
  96. package/dist/services/getInitialUrl.d.ts +1 -0
  97. package/dist/services/getInitialUrl.spec.d.ts +1 -0
  98. package/dist/services/getMatchesForUrl.d.ts +2 -0
  99. package/dist/services/getMatchesForUrl.spec.d.ts +1 -0
  100. package/dist/services/getParamsForString.d.ts +2 -0
  101. package/dist/services/getRouteHooks.d.ts +4 -0
  102. package/dist/services/getRouteHooks.spec.d.ts +1 -0
  103. package/dist/services/getRoutesForRouter.d.ts +9 -0
  104. package/dist/services/getRoutesForRouter.spec.d.ts +1 -0
  105. package/dist/services/hooks.browser.spec.d.ts +1 -0
  106. package/dist/services/hooks.d.ts +8 -0
  107. package/dist/services/hooks.spec.d.ts +1 -0
  108. package/dist/services/insertBaseRoute.d.ts +2 -0
  109. package/dist/services/insertBaseRoute.spec.d.ts +1 -0
  110. package/dist/services/paramValidation.d.ts +4 -0
  111. package/dist/services/paramValidation.spec.d.ts +1 -0
  112. package/dist/services/params.d.ts +7 -0
  113. package/dist/services/params.spec.d.ts +1 -0
  114. package/dist/services/paramsFinder.d.ts +3 -0
  115. package/dist/services/paramsFinder.spec.d.ts +1 -0
  116. package/dist/services/routeMatchRules.d.ts +5 -0
  117. package/dist/services/routeMatchRules.spec.d.ts +1 -0
  118. package/dist/services/routeMatchScore.d.ts +7 -0
  119. package/dist/services/routeMatchScore.spec.d.ts +1 -0
  120. package/dist/services/routeRegex.d.ts +18 -0
  121. package/dist/services/routeRegex.spec.d.ts +1 -0
  122. package/dist/services/state.d.ts +9 -0
  123. package/dist/services/state.spec.d.ts +1 -0
  124. package/dist/services/tupleOf.d.ts +10 -0
  125. package/dist/services/tupleOf.spec.d.ts +1 -0
  126. package/dist/services/unionOf.d.ts +3 -0
  127. package/dist/services/unionOf.spec.d.ts +1 -0
  128. package/dist/services/urlAssembly.d.ts +10 -0
  129. package/dist/services/urlAssembly.spec.d.ts +1 -0
  130. package/dist/services/urlCombine.d.ts +2 -0
  131. package/dist/services/urlCombine.spec.d.ts +1 -0
  132. package/dist/services/urlCreator.d.ts +2 -0
  133. package/dist/services/urlCreator.spec.d.ts +1 -0
  134. package/dist/services/urlParser.d.ts +2 -0
  135. package/dist/services/urlParser.spec.d.ts +1 -0
  136. package/dist/services/valibot.d.ts +7 -0
  137. package/dist/services/valibot.spec-d.d.ts +1 -0
  138. package/dist/services/valibot.spec.d.ts +1 -0
  139. package/dist/services/withDefault.d.ts +5 -0
  140. package/dist/services/withParams.d.ts +15 -0
  141. package/dist/services/withParams.spec-d.d.ts +1 -0
  142. package/dist/services/withParams.spec.d.ts +1 -0
  143. package/dist/services/zod.d.ts +11 -0
  144. package/dist/services/zod.spec-d.d.ts +1 -0
  145. package/dist/services/zod.spec.d.ts +1 -0
  146. package/dist/tests/hooks.spec.d.ts +1 -0
  147. package/dist/tests/routeProps.browser.spec.d.ts +1 -0
  148. package/dist/tests/routeProps.spec.d.ts +1 -0
  149. package/dist/types/createRouteOptions.d.ts +120 -0
  150. package/dist/types/hooks.d.ts +111 -0
  151. package/dist/types/meta.d.ts +2 -0
  152. package/dist/types/name.d.ts +2 -0
  153. package/dist/types/paramTypes.d.ts +14 -0
  154. package/dist/types/params.d.ts +71 -0
  155. package/dist/types/prefetch.d.ts +27 -0
  156. package/dist/types/props.d.ts +23 -0
  157. package/dist/types/querySource.d.ts +1 -0
  158. package/dist/types/register.d.ts +57 -0
  159. package/dist/types/register.spec.d.ts +1 -0
  160. package/dist/types/resolved.d.ts +47 -0
  161. package/dist/types/resolved.spec-d.d.ts +1 -0
  162. package/dist/types/route.d.ts +76 -0
  163. package/dist/types/route.spec-d.d.ts +1 -0
  164. package/dist/types/routeMatchRule.d.ts +2 -0
  165. package/dist/types/routeUpdate.d.ts +9 -0
  166. package/dist/types/routeWithParams.d.ts +5 -0
  167. package/dist/types/routeWithParams.spec-d.d.ts +1 -0
  168. package/dist/types/router.d.ts +185 -0
  169. package/dist/types/routerLink.d.ts +16 -0
  170. package/dist/types/routerPlugin.d.ts +18 -0
  171. package/dist/types/routerPush.d.ts +33 -0
  172. package/dist/types/routerReject.d.ts +3 -0
  173. package/dist/types/routerReplace.d.ts +20 -0
  174. package/dist/types/routerResolve.d.ts +15 -0
  175. package/dist/types/routerRoute.d.ts +16 -0
  176. package/dist/types/routesMap.d.ts +9 -0
  177. package/dist/types/routesMap.spec-ts.d.ts +1 -0
  178. package/dist/types/state.d.ts +18 -0
  179. package/dist/types/url.d.ts +23 -0
  180. package/dist/types/useLink.d.ts +51 -0
  181. package/dist/types/utilities.d.ts +22 -0
  182. package/dist/utilities/array.d.ts +2 -0
  183. package/dist/utilities/checkDuplicateKeys.d.ts +1 -0
  184. package/dist/utilities/checkDuplicateKeys.spec.d.ts +1 -0
  185. package/dist/utilities/checkDuplicateNames.d.ts +2 -0
  186. package/dist/utilities/checkDuplicateNames.spec.d.ts +1 -0
  187. package/dist/utilities/components.d.ts +6 -0
  188. package/dist/utilities/components.spec.d.ts +1 -0
  189. package/dist/utilities/guards.d.ts +5 -0
  190. package/dist/utilities/guards.spec.d.ts +1 -0
  191. package/dist/utilities/index.d.ts +6 -0
  192. package/dist/utilities/isBrowser.browser.spec.d.ts +1 -0
  193. package/dist/utilities/isBrowser.d.ts +1 -0
  194. package/dist/utilities/isBrowser.spec.d.ts +1 -0
  195. package/dist/utilities/makeOptional.d.ts +9 -0
  196. package/dist/utilities/prefetch.d.ts +4 -0
  197. package/dist/utilities/prefetch.spec.d.ts +1 -0
  198. package/dist/utilities/promises.d.ts +1 -0
  199. package/dist/utilities/props.d.ts +6 -0
  200. package/dist/utilities/testHelpers.d.ts +144 -0
  201. package/dist/utilities/urlSearchParams.d.ts +2 -0
  202. package/dist/utilities/urlSearchParams.spec.d.ts +1 -0
  203. package/package.json +11 -11
@@ -1,1433 +1,2 @@
1
- import { App } from 'vue';
2
- import { AsyncComponentLoader } from 'vue';
3
- import { Component } from 'vue';
4
- import { ComponentOptionsMixin } from 'vue';
5
- import { ComponentProvideOptions } from 'vue';
6
- import { ComputedRef } from 'vue';
7
- import { DefineComponent } from 'vue';
8
- import { FunctionalComponent } from 'vue';
9
- import { MaybeRefOrGetter } from 'vue';
10
- import { PrefetchConfig as PrefetchConfig_2 } from '../types';
11
- import { PublicProps } from 'vue';
12
- import { Ref } from 'vue';
13
- import { StandardSchemaV1 } from '@standard-schema/spec';
14
- import { UnwrapRef } from 'vue';
15
- import { VNode } from 'vue';
16
-
17
- declare type __VLS_WithTemplateSlots<T, S> = T & {
18
- new (): {
19
- $slots: S;
20
- };
21
- };
22
-
23
- declare type __VLS_WithTemplateSlots_2<T, S> = T & {
24
- new (): {
25
- $slots: S;
26
- };
27
- };
28
-
29
- /**
30
- * Adds a hook that is called after a route change. Returns a function to remove the hook.
31
- * @param hook - {@link AfterRouteHook} The hook function to add.
32
- * @returns {RouteHookRemove} A function that removes the added hook.
33
- */
34
- export declare type AddAfterRouteHook = (hook: AfterRouteHook) => RouteHookRemove;
35
-
36
- /**
37
- * Adds a hook that is called before a route change. Returns a function to remove the hook.
38
- * @param hook - {@link BeforeRouteHook} The hook function to add.
39
- * @returns {RouteHookRemove} A function that removes the added hook.
40
- */
41
- export declare type AddBeforeRouteHook = (hook: BeforeRouteHook) => RouteHookRemove;
42
-
43
- export declare type AddComponentAfterRouteHook = (hook: AfterRouteHookRegistration) => RouteHookRemove;
44
-
45
- export declare type AddComponentBeforeRouteHook = (hook: BeforeRouteHookRegistration) => RouteHookRemove;
46
-
47
- export declare type AddGlobalRouteHooks = (hooks: RouteHooks) => void;
48
-
49
- export declare type AfterHookContext = {
50
- to: ResolvedRoute;
51
- from: ResolvedRoute | null;
52
- };
53
-
54
- /**
55
- * Represents a function called after a route change has occurred.
56
- * @param to - {@link ResolvedRoute} The resolved route the router has navigated to.
57
- * @param context - {@link AfterRouteHookContext} The context providing functions and state for the routing operation.
58
- * @returns Possibly a promise that resolves when the hook's logic has completed.
59
- */
60
- export declare type AfterRouteHook = (to: ResolvedRoute, context: AfterRouteHookContext) => MaybePromise<void>;
61
-
62
- /**
63
- * Context provided to route hooks, containing context of previous route and functions for triggering rejections and push/replace to another route.
64
- */
65
- export declare type AfterRouteHookContext = RouteHookContext;
66
-
67
- /**
68
- * Enumerates the lifecycle events for after route hooks.
69
- */
70
- export declare type AfterRouteHookLifecycle = 'onAfterRouteEnter' | 'onAfterRouteUpdate' | 'onAfterRouteLeave';
71
-
72
- export declare type AfterRouteHookRegistration = {
73
- lifecycle: 'onAfterRouteEnter' | 'onAfterRouteUpdate' | 'onAfterRouteLeave';
74
- hook: AfterRouteHook;
75
- depth: number;
76
- };
77
-
78
- /**
79
- * Type for responses from an after route hook, which may indicate different outcomes such as success, push, or reject.
80
- * @template TRoutes - The type of the routes configuration.
81
- */
82
- export declare type AfterRouteHookResponse = CallbackSuccessResponse | CallbackPushResponse | CallbackRejectResponse;
83
-
84
- declare type AllPropertiesAreOptional<T> = Record<string, unknown> extends T ? true : IsEmptyObject<OnlyRequiredProperties<T>>;
85
-
86
- export declare function arrayOf<const T extends Param[]>(params: T, options?: ArrayOfOptions): ParamGetSet<ExtractParamType<T[number]>[]>;
87
-
88
- declare type ArrayOfOptions = {
89
- separator?: string;
90
- };
91
-
92
- declare type AsNamedRoute<T extends Route> = IsRouteUnnamed<T> extends true ? never : T;
93
-
94
- /**
95
- * Converts a type to a string if it is a string, otherwise returns never.
96
- * Specifically useful when using keyof T to produce a union of strings
97
- * rather than string | number | symbol.
98
- */
99
- declare type AsString<T> = T extends string ? T : never;
100
-
101
- /**
102
- * Converts a string to a valid URL.
103
- * @param value - The string to convert.
104
- * @returns The valid URL.
105
- */
106
- export declare function asUrl(value: string): Url;
107
-
108
- export declare type BeforeHookContext = {
109
- to: ResolvedRoute;
110
- from: ResolvedRoute | null;
111
- };
112
-
113
- /**
114
- * Represents a function called before a route change, potentially altering the routing operation.
115
- * @param to - {@link ResolvedRoute} The resolved route the router is navigating to.
116
- * @param context - {@link BeforeRouteHookContext} The context providing functions and state for the routing operation.
117
- * @returns Possibly a promise that resolves when the hook's logic has completed.
118
- */
119
- export declare type BeforeRouteHook = (to: ResolvedRoute, context: BeforeRouteHookContext) => MaybePromise<void>;
120
-
121
- /**
122
- * Context provided to route hooks, containing context of previous route and functions for triggering rejections, push/replace to another route,
123
- * as well as aborting current route change.
124
- */
125
- export declare type BeforeRouteHookContext = RouteHookContext & {
126
- abort: CallbackContextAbort;
127
- };
128
-
129
- /**
130
- * Enumerates the lifecycle events for before route hooks.
131
- */
132
- export declare type BeforeRouteHookLifecycle = 'onBeforeRouteEnter' | 'onBeforeRouteUpdate' | 'onBeforeRouteLeave';
133
-
134
- export declare type BeforeRouteHookRegistration = {
135
- lifecycle: 'onBeforeRouteEnter' | 'onBeforeRouteUpdate' | 'onBeforeRouteLeave';
136
- hook: BeforeRouteHook;
137
- depth: number;
138
- };
139
-
140
- /**
141
- * Type for responses from a before route hook, which may indicate different outcomes such as success, push, reject, or abort.
142
- * @template TRoutes - The type of the routes configuration.
143
- */
144
- export declare type BeforeRouteHookResponse = CallbackSuccessResponse | CallbackPushResponse | CallbackRejectResponse | CallbackAbortResponse;
145
-
146
- declare type BuiltInRejectionType = 'NotFound';
147
-
148
- /**
149
- * Defines the structure of an aborted callback response.
150
- */
151
- declare type CallbackAbortResponse = {
152
- status: 'ABORT';
153
- };
154
-
155
- declare type CallbackContext = {
156
- reject: RegisteredRouterReject;
157
- push: RegisteredRouterPush;
158
- replace: RegisteredRouterReplace;
159
- abort: CallbackContextAbort;
160
- };
161
-
162
- /**
163
- * A function that can be called to abort a routing operation.
164
- */
165
- declare type CallbackContextAbort = () => void;
166
-
167
- /**
168
- * Defines the structure of a callback response that results in a push to a new route.
169
- */
170
- declare type CallbackPushResponse = {
171
- status: 'PUSH';
172
- to: Parameters<RegisteredRouterPush>;
173
- };
174
-
175
- /**
176
- * Defines the structure of a callback response that results in the rejection of a route transition.
177
- */
178
- declare type CallbackRejectResponse = {
179
- status: 'REJECT';
180
- type: RegisteredRejectionType;
181
- };
182
-
183
- /**
184
- * Defines the structure of a successful callback response.
185
- */
186
- declare type CallbackSuccessResponse = {
187
- status: 'SUCCESS';
188
- };
189
-
190
- declare type CombineHash<TParent extends WithParams, TChild extends WithParams> = CombinePath<TParent, TChild>;
191
-
192
- declare type CombineMeta<TParent extends Record<string, unknown>, TChild extends Record<string, unknown>> = TParent & TChild;
193
-
194
- declare type CombinePath<TParent extends WithParams, TChild extends WithParams> = ToWithParams<TParent> extends {
195
- value: infer TParentPath extends string;
196
- params: infer TParentParams extends Record<string, unknown>;
197
- } ? ToWithParams<TChild> extends {
198
- value: infer TChildPath extends string;
199
- params: infer TChildParams extends Record<string, unknown>;
200
- } ? TParentParams & TChildParams extends Record<string, Param | undefined> ? WithParams<CombinePathString<TParentPath, TChildPath>, TParentParams & TChildParams> : WithParams<CombinePathString<TParentPath, TChildPath>, {}> : WithParams<'', {}> : WithParams<'', {}>;
201
-
202
- declare type CombinePathString<TParent extends string, TChild extends string> = `${TParent}${TChild}`;
203
-
204
- declare type CombineQuery<TParent extends WithParams, TChild extends WithParams> = ToWithParams<TParent> extends {
205
- value: infer TParentQuery extends string;
206
- params: infer TParentParams extends Record<string, unknown>;
207
- } ? ToWithParams<TChild> extends {
208
- value: infer TChildQuery extends string;
209
- params: infer TChildParams extends Record<string, unknown>;
210
- } ? TParentParams & TChildParams extends Record<string, Param | undefined> ? WithParams<CombineQueryString<TParentQuery, TChildQuery>, TParentParams & TChildParams> : WithParams<CombineQueryString<TParentQuery, TChildQuery>, {}> : WithParams<'', {}> : WithParams<'', {}>;
211
-
212
- declare type CombineQueryString<TParent extends string | undefined, TChild extends string | undefined> = StringHasValue<TParent> extends true ? StringHasValue<TChild> extends true ? `${TParent}&${TChild}` : TParent : TChild;
213
-
214
- declare type CombineState<TParent extends Record<string, Param>, TChild extends Record<string, Param>> = TParent & TChild;
215
-
216
- declare type ComponentProps<TComponent extends Component> = TComponent extends Constructor ? InstanceType<TComponent>['$props'] : TComponent extends AsyncComponentLoader<infer T extends Component> ? ComponentProps<T> : TComponent extends FunctionalComponent<infer T> ? T : {};
217
-
218
- declare type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
219
-
220
- declare type Constructor = new (...args: any) => any;
221
-
222
- /**
223
- * The Route properties originally provided to `createRoute`. The only change is normalizing meta to always default to an empty object.
224
- */
225
- export declare type CreatedRouteOptions = Omit<CreateRouteOptions, 'props'> & WithHooks & {
226
- id: string;
227
- props?: unknown;
228
- };
229
-
230
- export declare function createExternalRoute<const TOptions extends CreateRouteOptions & WithHost & WithoutParent>(options: TOptions): ToRoute<TOptions, undefined>;
231
-
232
- export declare function createExternalRoute<const TOptions extends CreateRouteOptions & WithoutHost & WithParent>(options: TOptions): ToRoute<TOptions, undefined>;
233
-
234
- export declare function createParam<TParam extends ParamWithDefault>(param: TParam): TParam;
235
-
236
- export declare function createParam<TParam extends Param>(param: TParam): ParamGetSet<ExtractParamType<TParam>>;
237
-
238
- export declare function createParam<TParam extends Param>(param: TParam, defaultValue: NoInfer<ExtractParamType<TParam>>): ParamWithDefault<TParam>;
239
-
240
- export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): ToRoute<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>;
241
-
242
- export declare 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> = WithHooks & {
243
- /**
244
- * Name for route, used to create route keys and in navigation.
245
- */
246
- name?: TName;
247
- /**
248
- * Path part of URL.
249
- */
250
- path?: TPath;
251
- /**
252
- * Query (aka search) part of URL.
253
- */
254
- query?: TQuery;
255
- /**
256
- * Hash part of URL.
257
- */
258
- hash?: THash;
259
- /**
260
- * Represents additional metadata associated with a route, customizable via declaration merging.
261
- */
262
- meta?: TMeta;
263
- /**
264
- * Determines what assets are prefetched when router-link is rendered for this route. Overrides router level prefetch.
265
- */
266
- prefetch?: PrefetchConfig;
267
- /**
268
- * Type params for additional data intended to be stored in history state, all keys will be optional unless a default is provided.
269
- */
270
- state?: Record<string, Param>;
271
- /**
272
- * An optional parent route to nest this route under.
273
- */
274
- parent?: Route;
275
- /**
276
- * An optional component to render when this route is matched.
277
- *
278
- * @default RouterView
279
- */
280
- component?: Component;
281
- /**
282
- * An object of named components to render using named views
283
- */
284
- components?: Record<string, Component>;
285
- /**
286
- * Props have been moved to the second argument of `createRoute`. This property can no longer be used.
287
- *
288
- * @deprecated
289
- */
290
- props?: never;
291
- };
292
-
293
- declare type CreateRouteProps<TOptions extends CreateRouteOptions = CreateRouteOptions> = TOptions['component'] extends Component ? PropsGetter<TOptions, TOptions['component']> : TOptions['components'] extends Record<string, Component> ? RoutePropsRecord<TOptions, TOptions['components']> : PropsGetter<TOptions, typeof RouterView>;
294
-
295
- /**
296
- * Creates a router instance for a Vue application, equipped with methods for route handling, lifecycle hooks, and state management.
297
- *
298
- * @param routes - {@link Routes} An array of route definitions specifying the configuration of routes in the application.
299
- * Use createRoute method to create the route definitions.
300
- * @param options - {@link RouterOptions} for the router, including history mode and initial URL settings.
301
- * @returns Router instance
302
- *
303
- * @example
304
- * ```ts
305
- * import { createRoute, createRouter } from '@kitbag/router'
306
- *
307
- * const Home = { template: '<div>Home</div>' }
308
- * const About = { template: '<div>About</div>' }
309
- *
310
- * export const routes = [
311
- * createRoute({ name: 'home', path: '/', component: Home }),
312
- * createRoute({ name: 'path', path: '/about', component: About }),
313
- * ] as const
314
- *
315
- * const router = createRouter(routes)
316
- * ```
317
- */
318
- export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions, const TPlugin extends RouterPlugin = EmptyRouterPlugin>(routes: TRoutes, options?: TOptions, plugins?: TPlugin[]): Router<TRoutes, TOptions, TPlugin>;
319
-
320
- export declare function createRouter<const TRoutes extends Routes, const TOptions extends RouterOptions, const TPlugin extends RouterPlugin = EmptyRouterPlugin>(routes: TRoutes[], options?: TOptions, plugins?: TPlugin[]): Router<TRoutes, TOptions, TPlugin>;
321
-
322
- export declare function createRouterPlugin<TRoutes extends Routes = [], TRejections extends Record<string, Component> = {}>(plugin: Partial<RouterPlugin<TRoutes, TRejections>>): RouterPlugin<TRoutes, TRejections>;
323
-
324
- declare type CreateRouteWithProps<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<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];
325
-
326
- /**
327
- * An error thrown when duplicate parameters are detected in a route.
328
- * Param names must be unique. This includes params defined in a path
329
- * parent and params defined in the query.
330
- * @group Errors
331
- */
332
- export declare class DuplicateParamsError extends Error {
333
- /**
334
- * Constructs a new DuplicateParamsError instance with a message indicating the problematic parameter.
335
- * @param paramName - The name of the parameter that was duplicated.
336
- */
337
- constructor(paramName: string);
338
- }
339
-
340
- declare type EmptyRouterPlugin = {
341
- routes: [];
342
- rejections: {};
343
- };
344
-
345
- /**
346
- * Extracts the parameter name from a string, handling optional parameters denoted by a leading '?'.
347
- * @template TParam - The string from which to extract the parameter name.
348
- * @returns The extracted parameter name, or never if the parameter string is empty.
349
- */
350
- declare type ExtractParamName<TParam extends PropertyKey> = TParam extends string ? TParam extends `?${infer Param}` ? Param extends '' ? never : Param : TParam extends '' ? never : TParam : never;
351
-
352
- /**
353
- * Extracts the actual type from a parameter type, handling getters and setters.
354
- * @template TParam - The parameter type.
355
- * @returns The extracted type, or 'string' as a fallback.
356
- */
357
- declare type ExtractParamType<TParam extends Param> = TParam extends ParamGetSet<infer Type> ? Type : TParam extends ParamGetter ? ReturnType<TParam> : TParam extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TParam> : TParam extends LiteralParam ? TParam : string;
358
-
359
- declare type ExtractParamTypes<TParams extends Record<string, Param>> = Identity<MakeOptional<{
360
- [K in keyof TParams as ExtractParamName<K>]: ExtractParamType<TParams[K]>;
361
- }>>;
362
-
363
- /**
364
- * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
365
- * @template TParams - The record of parameter types, possibly including undefined.
366
- * @returns A new type with the appropriate properties marked as optional.
367
- */
368
- declare type ExtractParamTypesReading<TWithParams extends WithParams> = {
369
- [K in keyof TWithParams['params']]: TWithParams['value'] extends `${string}${ParamStart}?${K & string}${ParamEnd}${string}` ? TWithParams['params'][K] extends Required<ParamGetSet> ? ExtractParamType<TWithParams['params'][K]> : ExtractParamType<TWithParams['params'][K]> | undefined : ExtractParamType<TWithParams['params'][K]>;
370
- };
371
-
372
- /**
373
- * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
374
- * Differs from ExtractParamTypesReading in that optional params with defaults will remain optional.
375
- * @template TParams - The record of parameter types, possibly including undefined.
376
- * @returns A new type with the appropriate properties marked as optional.
377
- */
378
- declare type ExtractParamTypesWriting<TWithParams extends WithParams> = {
379
- [K in keyof TWithParams['params']]: TWithParams['value'] extends `${string}${ParamStart}?${K & string}${ParamEnd}${string}` ? ExtractParamType<TWithParams['params'][K]> | undefined : ExtractParamType<TWithParams['params'][K]>;
380
- };
381
-
382
- /**
383
- * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
384
- * @template TRoute - The route type from which to extract and merge parameter types.
385
- * @returns A record of parameter names to their respective types, extracted and merged from both path and query parameters.
386
- */
387
- declare type ExtractRouteParamTypesReading<TRoute extends Route> = Identity<MakeOptional<ExtractParamTypesReading<TRoute['host']> & ExtractParamTypesReading<TRoute['path']> & ExtractParamTypesReading<TRoute['query']> & ExtractParamTypesReading<TRoute['hash']>>>;
388
-
389
- /**
390
- * Extracts combined types of path and query parameters for a given route, creating a unified parameter object.
391
- * Differs from ExtractRouteParamTypesReading in that optional params with defaults will remain optional.
392
- * @template TRoute - The route type from which to extract and merge parameter types.
393
- * @returns A record of parameter names to their respective types, extracted and merged from both path and query parameters.
394
- */
395
- declare type ExtractRouteParamTypesWriting<TRoute extends Route> = Identity<MakeOptional<ExtractParamTypesWriting<TRoute['host']> & ExtractParamTypesWriting<TRoute['path']> & ExtractParamTypesWriting<TRoute['query']> & ExtractParamTypesWriting<TRoute['hash']>>>;
396
-
397
- declare type ExtractRouteStateParamsAsOptional<TParams extends Record<string, Param>> = {
398
- [K in keyof TParams]: ExtractParamType<TParams[K]> | undefined;
399
- };
400
-
401
- declare type ExtractStateParams<TRoute> = TRoute extends {
402
- state: infer TState extends Record<string, Param>;
403
- } ? ExtractParamTypes<TState> : Record<string, unknown>;
404
-
405
- declare type GetParentPropsReturnType<TParent extends Route | undefined = Route | undefined> = TParent extends Route ? TParent['matched']['props'] extends PropsGetter ? ReturnType<TParent['matched']['props']> : TParent['matched']['props'] extends Record<string, PropsGetter> ? {
406
- [K in keyof TParent['matched']['props']]: ReturnType<TParent['matched']['props'][K]>;
407
- } : undefined : undefined;
408
-
409
- /**
410
- * @deprecated use `withParams` instead
411
- * @hidden we don't want to expose this in the api docs
412
- */
413
- export declare const host: typeof withParams;
414
-
415
- declare type Identity<T> = T extends object ? {} & {
416
- [P in keyof T as T[P] extends never ? never : P]: T[P];
417
- } : T;
418
-
419
- declare type IsEmptyObject<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false;
420
-
421
- /**
422
- * A type guard for determining if a value is a valid RouterRoute.
423
- * @param route - The value to check.
424
- * @returns `true` if the value is a valid RouterRoute, otherwise `false`.
425
- * @group Type Guards
426
- */
427
- export declare function isRoute(route: unknown): route is RouterRoute;
428
-
429
- /**
430
- * A type guard for determining if a value is a valid RouterRoute with an exact match.
431
- * @param route - The value to check.
432
- * @param routeName - The expected route name.
433
- * @returns `true` if the value is a valid RouterRoute with an exact match, otherwise `false`.
434
- * @group Type Guards
435
- */
436
- export declare function isRoute<TRoute extends RouterRoute, TRouteName extends TRoute['name']>(route: TRoute, routeName: TRouteName, options: IsRouteOptions & {
437
- exact: true;
438
- }): route is TRoute & {
439
- name: TRouteName;
440
- };
441
-
442
- /**
443
- * A type guard for determining if a value is a valid RouterRoute with a partial match.
444
- * @param route - The value to check.
445
- * @param routeName - The expected route name.
446
- * @returns `true` if the value is a valid RouterRoute with a partial match, otherwise `false`.
447
- * @group Type Guards
448
- */
449
- export declare function isRoute<TRoute extends RouterRoute, TRouteName extends TRoute['name']>(route: TRoute, routeName: TRouteName, options?: IsRouteOptions): route is RouteWithMatch<TRoute, TRouteName>;
450
-
451
- /**
452
- * A type guard for determining if a value is a valid RegisteredRouterRoute with an exact match.
453
- * @param route - The value to check.
454
- * @param routeName - The expected route name.
455
- * @returns `true` if the value is a valid RegisteredRouterRoute with an exact match, otherwise `false`.
456
- * @group Type Guards
457
- */
458
- export declare function isRoute<TRouteName extends RegisteredRoutesName>(route: unknown, routeName: TRouteName, options: IsRouteOptions & {
459
- exact: true;
460
- }): route is RegisteredRouterRoute & {
461
- name: TRouteName;
462
- };
463
-
464
- /**
465
- * A type guard for determining if a value is a valid RegisteredRouterRoute with a partial match.
466
- * @param route - The value to check.
467
- * @param routeName - The expected route name.
468
- * @returns `true` if the value is a valid RegisteredRouterRoute with a partial match, otherwise `false`.
469
- * @group Type Guards
470
- */
471
- export declare function isRoute<TRouteName extends RegisteredRoutesName>(route: unknown, routeName: TRouteName, options?: IsRouteOptions): route is RouteWithMatch<RegisteredRouterRoute, TRouteName>;
472
-
473
- /**
474
- * A type guard for determining if a value is a valid RouterRoute.
475
- * @param route - The value to check.
476
- * @param routeName - The expected route name.
477
- * @returns `true` if the value is a valid RouterRoute, otherwise `false`.
478
- * @group Type Guards
479
- */
480
- export declare function isRoute(route: unknown, routeName?: string, options?: IsRouteOptions): boolean;
481
-
482
- declare type IsRouteOptions = {
483
- exact?: boolean;
484
- };
485
-
486
- declare type IsRouteUnnamed<T extends Route> = StringHasValue<T['name']> extends true ? false : true;
487
-
488
- /**
489
- * A type guard for determining if a value is a valid URL.
490
- * @param value - The value to check.
491
- * @returns `true` if the value is a valid URL, otherwise `false`.
492
- * @group Type Guards
493
- */
494
- export declare function isUrl(value: unknown): value is Url;
495
-
496
- /**
497
- * Extracts the keys of a union type.
498
- */
499
- declare type KeysOfUnion<T> = T extends T ? keyof T : never;
500
-
501
- declare type LastInArray<T, TFallback = never> = T extends [...any[], infer Last] ? Last : TFallback;
502
-
503
- export declare type LiteralParam = string | number | boolean;
504
-
505
- declare type MakeOptional<T> = {
506
- [P in WithOptionalProperties<T>]?: T[P];
507
- } & {
508
- [P in Exclude<keyof T, WithOptionalProperties<T>>]: T[P];
509
- };
510
-
511
- declare type MaybeArray<T> = T | T[];
512
-
513
- declare type MaybePromise<T> = T | Promise<T>;
514
-
515
- /**
516
- * An error thrown when a parent's meta has the same key as a child and the types are not compatible.
517
- * A child's meta can override properties of the parent, however the types must match!
518
- * @group Errors
519
- */
520
- export declare class MetaPropertyConflict extends Error {
521
- constructor(property?: string);
522
- }
523
-
524
- /**
525
- * Registers a hook that is called after a route has been left. Must be called during setup.
526
- * This can be used for cleanup actions after the component is no longer active, ensuring proper resource management.
527
- *
528
- * @param AfterRouteHook - The hook callback function
529
- * @returns {RouteHookRemove} A function that removes the added hook.
530
- * @group Hooks
531
- */
532
- export declare const onAfterRouteLeave: AddAfterRouteHook;
533
-
534
- /**
535
- * Registers a hook that is called after a route has been updated. Must be called during setup.
536
- * This is ideal for responding to updates within the same route, such as parameter changes, without full component reloads.
537
- *
538
- * @param AfterRouteHook - The hook callback function
539
- * @returns {RouteHookRemove} A function that removes the added hook.
540
- * @group Hooks
541
- */
542
- export declare const onAfterRouteUpdate: AddAfterRouteHook;
543
-
544
- /**
545
- * Registers a hook that is called before a route is left. Must be called from setup.
546
- * This is useful for performing actions or cleanups before navigating away from a route component.
547
- *
548
- * @param BeforeRouteHook - The hook callback function
549
- * @returns {RouteHookRemove} A function that removes the added hook.
550
- * @group Hooks
551
- */
552
- export declare const onBeforeRouteLeave: AddBeforeRouteHook;
553
-
554
- /**
555
- * Registers a hook that is called before a route is updated. Must be called from setup.
556
- * This is particularly useful for handling changes in route parameters or query while staying within the same component.
557
- *
558
- * @param BeforeRouteHook - The hook callback function
559
- * @returns {RouteHookRemove} A function that removes the added hook.
560
- * @group Hooks
561
- */
562
- export declare const onBeforeRouteUpdate: AddBeforeRouteHook;
563
-
564
- declare type OnlyRequiredProperties<T> = {
565
- [K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
566
- };
567
-
568
- export declare type Param = ParamGetter | ParamGetSet | RegExp | BooleanConstructor | NumberConstructor | StringConstructor | DateConstructor | JSON | ZodSchemaLike | ValibotSchemaLike | LiteralParam;
569
-
570
- declare type ParamEnd = typeof paramEnd;
571
-
572
- declare const paramEnd = "]";
573
-
574
- export declare type ParamExtras = {
575
- invalid: (message?: string) => never;
576
- };
577
-
578
- export declare type ParamGetSet<T = any> = {
579
- get: ParamGetter<T>;
580
- set: ParamSetter<T>;
581
- defaultValue?: T;
582
- };
583
-
584
- export declare type ParamGetter<T = any> = (value: string, extras: ParamExtras) => T;
585
-
586
- export declare type ParamSetter<T = any> = (value: T, extras: ParamExtras) => string;
587
-
588
- declare type ParamStart = typeof paramStart;
589
-
590
- declare const paramStart = "[";
591
-
592
- declare type ParamWithDefault<TParam extends Param = Param> = Required<ParamGetSet<ExtractParamType<TParam>>>;
593
-
594
- /**
595
- * @deprecated use `withParams` instead
596
- * @hidden we don't want to expose this in the api docs
597
- */
598
- export declare const path: typeof withParams;
599
-
600
- /**
601
- * Determines what assets are prefetched. A boolean enables or disables all prefetching.
602
- */
603
- export declare type PrefetchConfig = boolean | PrefetchStrategy | PrefetchConfigOptions;
604
-
605
- declare type PrefetchConfigOptions = {
606
- /**
607
- * When true any component that is wrapped in vue's defineAsyncComponent will be prefetched
608
- * @default 'eager'
609
- */
610
- components?: boolean | PrefetchStrategy;
611
- /**
612
- * When true any props for routes will be prefetched
613
- * @default false
614
- */
615
- props?: boolean | PrefetchStrategy;
616
- };
617
-
618
- /**
619
- * Determines when assets are prefetched.
620
- * eager: Fetched immediately
621
- * lazy: Fetched when visible
622
- */
623
- export declare type PrefetchStrategy = 'eager' | 'lazy' | 'intent';
624
-
625
- /**
626
- * Context provided to props callback functions
627
- */
628
- export declare type PropsCallbackContext<TParent extends Route | undefined = Route | undefined> = {
629
- push: CallbackContext['push'];
630
- replace: CallbackContext['replace'];
631
- reject: CallbackContext['reject'];
632
- parent: PropsCallbackParent<TParent>;
633
- };
634
-
635
- declare type PropsCallbackParent<TParent extends Route | undefined = Route | undefined> = Route | undefined extends TParent ? undefined | {
636
- name: string;
637
- props: unknown;
638
- } : TParent extends Route ? {
639
- name: TParent['name'];
640
- props: GetParentPropsReturnType<TParent>;
641
- } : undefined;
642
-
643
- declare type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions, undefined>>, context: PropsCallbackContext<TOptions['parent']>) => MaybePromise<ComponentProps<TComponent>>;
644
-
645
- /**
646
- * @deprecated use `withParams` instead
647
- * @hidden we don't want to expose this in the api docs
648
- */
649
- export declare const query: typeof withParams;
650
-
651
- export declare type QuerySource = ConstructorParameters<typeof URLSearchParams>[0];
652
-
653
- /**
654
- * Represents the state of currently registered router, and route meta. Used to provide correct type context for
655
- * components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
656
- *
657
- * @example
658
- * ```ts
659
- * declare module '@kitbag/router' {
660
- * interface Register {
661
- * router: typeof router
662
- * routeMeta: { public?: boolean }
663
- * }
664
- * }
665
- * ```
666
- */
667
- export declare interface Register {
668
- }
669
-
670
- /**
671
- * Represents the possible Rejections registered within {@link Register}
672
- */
673
- export declare type RegisteredRejectionType<T = Register> = T extends {
674
- router: Router<any, infer TOptions extends RouterOptions>;
675
- } ? keyof TOptions['rejections'] | BuiltInRejectionType : BuiltInRejectionType;
676
-
677
- /**
678
- * Represents the a map of all possible route names with corresponding Route registered within {@link Register}
679
- */
680
- export declare type RegisteredRouteMap = RoutesMap<RegisteredRoutes>;
681
-
682
- /**
683
- * Represents the Router property within {@link Register}
684
- */
685
- export declare type RegisteredRouter<T = Register> = T extends {
686
- router: infer TRouter;
687
- } ? TRouter : Router;
688
-
689
- /**
690
- * Represents the type for router `push`, with types for routes registered within {@link Register}
691
- */
692
- export declare type RegisteredRouterPush = RouterPush<RegisteredRoutes>;
693
-
694
- /**
695
- * Type for Router Reject method. Triggers rejections registered within {@link Register}
696
- */
697
- export declare type RegisteredRouterReject = (type: RegisteredRejectionType) => void;
698
-
699
- /**
700
- * Represents the type for router `replace`, with types for routes registered within {@link Register}
701
- */
702
- export declare type RegisteredRouterReplace = RouterReplace<RegisteredRoutes>;
703
-
704
- /**
705
- * Represents the Router property within {@link Register}
706
- */
707
- export declare type RegisteredRouterRoute = RegisteredRouter['route'];
708
-
709
- /**
710
- * Represents the Router routes property within {@link Register}
711
- */
712
- export declare type RegisteredRoutes<T = Register> = T extends {
713
- router: Router<infer TRoutes extends Routes>;
714
- } ? TRoutes : Route[];
715
-
716
- /**
717
- * Represents the union of all possible route names registered within {@link Register}
718
- */
719
- export declare type RegisteredRoutesName = RoutesName<RegisteredRoutes>;
720
-
721
- /**
722
- * Represents a route that the router has matched to current browser location.
723
- * @template TRoute - Underlying Route that has been resolved.
724
- */
725
- export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
726
- /**
727
- * Unique identifier for the route, generated by router.
728
- */
729
- id: TRoute['id'];
730
- /**
731
- * The specific route properties that were matched in the current route.
732
- */
733
- matched: TRoute['matched'];
734
- /**
735
- * The specific route properties that were matched in the current route, including any ancestors.
736
- * Order of routes will be from greatest ancestor to narrowest matched.
737
- */
738
- matches: TRoute['matches'];
739
- /**
740
- * Unique identifier for the route. Name is used for routing and for matching.
741
- */
742
- name: TRoute['name'];
743
- /**
744
- * Accessor for query string values from user in the current browser location.
745
- */
746
- query: URLSearchParams;
747
- /**
748
- * Hash value of the route.
749
- */
750
- hash: string;
751
- /**
752
- * Key value pair for route params, values will be the user provided value from current browser location.
753
- */
754
- params: ExtractRouteParamTypesReading<TRoute>;
755
- /**
756
- * Type for additional data intended to be stored in history state.
757
- */
758
- state: ExtractRouteStateParamsAsOptional<TRoute['state']>;
759
- /**
760
- * String value of the resolved URL.
761
- */
762
- href: Url;
763
- }>;
764
-
765
- /**
766
- * Represents the structure of a route within the application. Return value of `createRoute`
767
- * @template TName - Represents the unique name identifying the route, typically a string.
768
- * @template TPath - The type or structure of the route's path.
769
- * @template TQuery - The type or structure of the query parameters associated with the route.
770
- */
771
- export declare type Route<TName extends string = string, THost extends WithParams = WithParams, TPath extends WithParams = WithParams, TQuery extends WithParams = WithParams, THash extends WithParams = WithParams, TMeta extends RouteMeta = RouteMeta, TState extends Record<string, Param> = Record<string, Param>, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = {
772
- /**
773
- * Unique identifier for the route, generated by router.
774
- */
775
- id: string;
776
- /**
777
- * The specific route properties that were matched in the current route.
778
- */
779
- matched: LastInArray<TMatches, CreatedRouteOptions>;
780
- /**
781
- * The specific route properties that were matched in the current route, including any ancestors.
782
- * Order of routes will be from greatest ancestor to narrowest matched.
783
- */
784
- matches: TMatches;
785
- /**
786
- * Identifier for the route as defined by user. Name must be unique among named routes. Name is used for routing and for matching.
787
- */
788
- name: TName;
789
- /**
790
- * Represents the host for this route. Used for external routes.
791
- */
792
- host: THost;
793
- /**
794
- * Represents the structured path of the route, including path params.
795
- */
796
- path: TPath;
797
- /**
798
- * Represents the structured query of the route, including query params.
799
- */
800
- query: TQuery;
801
- /**
802
- * Represents the hash of the route.
803
- */
804
- hash: THash;
805
- /**
806
- * Represents additional metadata associated with a route, combined with any parents.
807
- */
808
- meta: TMeta;
809
- /**
810
- * Represents the schema of the route state, combined with any parents.
811
- */
812
- state: TState;
813
- /**
814
- * Determines what assets are prefetched when router-link is rendered for this route. Overrides router level prefetch.
815
- */
816
- prefetch?: PrefetchConfig;
817
- /* Excluded from this release type: depth */
818
- };
819
-
820
- declare type RouteGetByKey<TRoutes extends Routes, TKey extends RoutesName<TRoutes>> = RoutesMap<TRoutes>[TKey];
821
-
822
- /**
823
- * Generic type representing a route hook, which can be either before or after a route change.
824
- */
825
- export declare type RouteHook = BeforeRouteHook | AfterRouteHook;
826
-
827
- export declare type RouteHookAfterRunner = (context: AfterHookContext) => Promise<AfterRouteHookResponse>;
828
-
829
- export declare type RouteHookBeforeRunner = (context: BeforeHookContext) => Promise<BeforeRouteHookResponse>;
830
-
831
- /**
832
- * Context provided to route hooks, containing context of previous route and functions for triggering rejections and push/replace to another route.
833
- */
834
- declare type RouteHookContext = {
835
- from: ResolvedRoute | null;
836
- reject: CallbackContext['reject'];
837
- push: CallbackContext['push'];
838
- replace: CallbackContext['replace'];
839
- };
840
-
841
- /**
842
- * Union type for all route hook lifecycle events.
843
- */
844
- export declare type RouteHookLifecycle = BeforeRouteHookLifecycle | AfterRouteHookLifecycle;
845
-
846
- /**
847
- * A function to remove a previously registered route hook.
848
- */
849
- export declare type RouteHookRemove = () => void;
850
-
851
- /**
852
- * Union type for all possible route hook responses, covering both before and after scenarios.
853
- * @template TRoutes - The type of the routes configuration.
854
- */
855
- export declare type RouteHookResponse = BeforeRouteHookResponse | AfterRouteHookResponse;
856
-
857
- declare class RouteHooks {
858
- onBeforeRouteEnter: Set<BeforeRouteHook>;
859
- onBeforeRouteUpdate: Set<BeforeRouteHook>;
860
- onBeforeRouteLeave: Set<BeforeRouteHook>;
861
- onAfterRouteEnter: Set<AfterRouteHook>;
862
- onAfterRouteUpdate: Set<AfterRouteHook>;
863
- onAfterRouteLeave: Set<AfterRouteHook>;
864
- }
865
-
866
- export declare type RouteHookTiming = 'global' | 'component';
867
-
868
- /**
869
- * Represents additional metadata associated with a route, customizable via declaration merging.
870
- */
871
- export declare type RouteMeta<T = Register> = T extends {
872
- routeMeta: infer RouteMeta extends Record<string, unknown>;
873
- } ? RouteMeta : Record<string, unknown>;
874
-
875
- declare type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = RouteGetByKey<TRoutes, TKey> extends Route ? ExtractRouteParamTypesWriting<RouteGetByKey<TRoutes, TKey>> : Record<string, unknown>;
876
-
877
- declare type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponents extends Record<string, Component> = Record<string, Component>> = {
878
- [K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends true ? K : never]?: PropsGetter<TOptions, TComponents[K]>;
879
- } & {
880
- [K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends false ? K : never]: PropsGetter<TOptions, TComponents[K]>;
881
- };
882
-
883
- export declare type Router<TRoutes extends Routes = any, TOptions extends RouterOptions = any, TPlugin extends RouterPlugin = any> = {
884
- /**
885
- * Installs the router into a Vue application instance.
886
- * @param app The Vue application instance to install the router into
887
- */
888
- install: (app: App) => void;
889
- /**
890
- * Manages the current route state.
891
- */
892
- route: RouterRoutes<TRoutes> | RouterRoutes<TPlugin['routes']>;
893
- /**
894
- * Creates a ResolvedRoute record for a given route name and params.
895
- */
896
- resolve: RouterResolve<TRoutes | TPlugin['routes']>;
897
- /**
898
- * Creates a ResolvedRoute record for a given URL.
899
- */
900
- find: (url: string, options?: RouterResolveOptions) => ResolvedRoute | undefined;
901
- /**
902
- * Navigates to a specified path or route object in the history stack, adding a new entry.
903
- */
904
- push: RouterPush<TRoutes | TPlugin['routes']>;
905
- /**
906
- * Replaces the current entry in the history stack with a new one.
907
- */
908
- replace: RouterReplace<TRoutes | TPlugin['routes']>;
909
- /**
910
- * Handles route rejection based on a specified rejection type.
911
- */
912
- reject: RouterReject<keyof TOptions['rejections'] | KeysOfUnion<TPlugin['rejections']>>;
913
- /**
914
- * Forces the router to re-evaluate the current route.
915
- */
916
- refresh: () => void;
917
- /**
918
- * Navigates to the previous entry in the browser's history stack.
919
- */
920
- back: () => void;
921
- /**
922
- * Navigates to the next entry in the browser's history stack.
923
- */
924
- forward: () => void;
925
- /**
926
- * Moves the current history entry to a specific point in the history stack.
927
- */
928
- go: (delta: number) => void;
929
- /**
930
- * Registers a hook to be called before a route is entered.
931
- */
932
- onBeforeRouteEnter: AddBeforeRouteHook;
933
- /**
934
- * Registers a hook to be called before a route is left.
935
- */
936
- onBeforeRouteLeave: AddBeforeRouteHook;
937
- /**
938
- * Registers a hook to be called before a route is updated.
939
- */
940
- onBeforeRouteUpdate: AddBeforeRouteHook;
941
- /**
942
- * Registers a hook to be called after a route is entered.
943
- */
944
- onAfterRouteEnter: AddAfterRouteHook;
945
- /**
946
- * Registers a hook to be called after a route is left.
947
- */
948
- onAfterRouteLeave: AddAfterRouteHook;
949
- /**
950
- * Registers a hook to be called after a route is updated.
951
- */
952
- onAfterRouteUpdate: AddAfterRouteHook;
953
- /**
954
- * Given a URL, returns true if host does not match host stored on router instance
955
- */
956
- isExternal: (url: string) => boolean;
957
- /**
958
- * Determines what assets are prefetched.
959
- */
960
- prefetch?: PrefetchConfig;
961
- /**
962
- * Initializes the router based on the initial route. Automatically called when the router is installed. Calling this more than once has no effect.
963
- */
964
- start: () => Promise<void>;
965
- /**
966
- * Returns true if the router has been started.
967
- */
968
- started: Ref<boolean>;
969
- /**
970
- * Stops the router and teardown any listeners.
971
- */
972
- stop: () => void;
973
- };
974
-
975
- declare type RouterHistoryMode = 'auto' | 'browser' | 'memory' | 'hash';
976
-
977
- /**
978
- * @hidden we don't want the criptic component types showing up in the api docs
979
- */
980
- export declare const RouterLink: __VLS_WithTemplateSlots_2<DefineComponent<RouterLinkProps & RouterPushOptions, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<RouterLinkProps & RouterPushOptions> & Readonly<{}>, {
981
- prefetch: PrefetchConfig_2;
982
- }, {}, {}, {}, string, ComponentProvideOptions, false, {
983
- element: HTMLAnchorElement;
984
- }, HTMLAnchorElement>, Readonly<{
985
- default?: (props: {
986
- route: ResolvedRoute | undefined;
987
- isMatch: boolean;
988
- isExactMatch: boolean;
989
- isActive: boolean;
990
- isExactActive: boolean;
991
- isExternal: boolean;
992
- }) => unknown;
993
- }> & {
994
- default?: (props: {
995
- route: ResolvedRoute | undefined;
996
- isMatch: boolean;
997
- isExactMatch: boolean;
998
- isActive: boolean;
999
- isExactActive: boolean;
1000
- isExternal: boolean;
1001
- }) => unknown;
1002
- }>;
1003
-
1004
- export declare type RouterLinkProps = {
1005
- /**
1006
- * The url string to navigate to or a callback that returns a url string
1007
- */
1008
- to: Url | ResolvedRoute | ToCallback;
1009
- /**
1010
- * Determines what assets are prefetched when router-link is rendered for this route. Overrides route level prefetch.
1011
- */
1012
- prefetch?: PrefetchConfig;
1013
- };
1014
-
1015
- /**
1016
- * An error thrown when an attempt is made to use routing functionality before the router has been installed.
1017
- * @group Errors
1018
- */
1019
- export declare class RouterNotInstalledError extends Error {
1020
- constructor();
1021
- }
1022
-
1023
- /**
1024
- * Options to initialize a {@link Router} instance.
1025
- */
1026
- export declare type RouterOptions = WithHooks & {
1027
- /**
1028
- * Initial URL for the router to use. Required if using Node environment. Defaults to window.location when using browser.
1029
- *
1030
- * @default window.location.toString()
1031
- */
1032
- initialUrl?: string;
1033
- /**
1034
- * Specifies the history mode for the router, such as "browser", "memory", or "hash".
1035
- *
1036
- * @default "auto"
1037
- */
1038
- historyMode?: RouterHistoryMode;
1039
- /**
1040
- * Base path to be prepended to any URL. Can be used for Vue applications that run in nested folder for domain.
1041
- * For example having `base` of `/foo` would assume all routes should start with `your.domain.com/foo`.
1042
- */
1043
- base?: string;
1044
- /**
1045
- * Determines what assets are prefetched when router-link is rendered for a specific route
1046
- */
1047
- prefetch?: PrefetchConfig;
1048
- /**
1049
- * Components assigned to each type of rejection your router supports.
1050
- */
1051
- rejections?: Partial<Record<string, Component>>;
1052
- };
1053
-
1054
- export declare type RouterPlugin<TRoutes extends Routes = Routes, TRejections extends Record<string, Component> = Record<string, Component>> = {
1055
- routes: TRoutes;
1056
- rejections: TRejections;
1057
- onBeforeRouteEnter?: MaybeArray<BeforeRouteHook>;
1058
- onAfterRouteEnter?: MaybeArray<AfterRouteHook>;
1059
- onBeforeRouteUpdate?: MaybeArray<BeforeRouteHook>;
1060
- onAfterRouteUpdate?: MaybeArray<AfterRouteHook>;
1061
- onBeforeRouteLeave?: MaybeArray<BeforeRouteHook>;
1062
- onAfterRouteLeave?: MaybeArray<AfterRouteHook>;
1063
- };
1064
-
1065
- declare type RouterPush<TRoutes extends Routes = any> = {
1066
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterPushArgs<TRoutes, TSource>): Promise<void>;
1067
- (route: ResolvedRoute, options?: RouterPushOptions): Promise<void>;
1068
- (url: Url, options?: RouterPushOptions): Promise<void>;
1069
- };
1070
-
1071
- declare type RouterPushArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterPushOptions<RouteStateByName<TRoutes, TSource>>];
1072
-
1073
- export declare type RouterPushOptions<TState = unknown> = {
1074
- /**
1075
- * The query string to add to the url.
1076
- */
1077
- query?: QuerySource;
1078
- /**
1079
- * The hash to append to the url.
1080
- */
1081
- hash?: string;
1082
- /**
1083
- * Whether to replace the current history entry.
1084
- */
1085
- replace?: boolean;
1086
- /**
1087
- * State values to pass to the route.
1088
- */
1089
- state?: Partial<TState>;
1090
- };
1091
-
1092
- declare type RouterReject<TRejectionType extends PropertyKey> = (type: AsString<TRejectionType> | BuiltInRejectionType) => void;
1093
-
1094
- declare type RouterRejection = Ref<null | {
1095
- type: string;
1096
- component: Component;
1097
- }>;
1098
-
1099
- declare type RouterReplace<TRoutes extends Routes> = {
1100
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterReplaceArgs<TRoutes, TSource>): Promise<void>;
1101
- (route: ResolvedRoute, options?: RouterReplaceOptions): Promise<void>;
1102
- (url: Url, options?: RouterReplaceOptions): Promise<void>;
1103
- };
1104
-
1105
- declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>];
1106
-
1107
- declare type RouterReplaceOptions<TState = unknown> = {
1108
- query?: QuerySource;
1109
- hash?: string;
1110
- state?: Partial<TState>;
1111
- };
1112
-
1113
- declare type RouterResolve<TRoutes extends Routes> = <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>) => ResolvedRoute;
1114
-
1115
- declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>];
1116
-
1117
- declare type RouterResolveOptions<TState = unknown> = {
1118
- query?: QuerySource;
1119
- hash?: string;
1120
- state?: Partial<TState>;
1121
- };
1122
-
1123
- export declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
1124
- readonly id: TRoute['id'];
1125
- readonly name: TRoute['name'];
1126
- readonly matched: TRoute['matched'];
1127
- readonly matches: TRoute['matches'];
1128
- readonly hash: TRoute['hash'];
1129
- readonly update: RouteUpdate<TRoute>;
1130
- readonly href: TRoute['href'];
1131
- params: TRoute['params'];
1132
- state: TRoute['state'];
1133
- get query(): URLSearchParams;
1134
- set query(value: QuerySource);
1135
- };
1136
-
1137
- /**
1138
- * This type is the same as `RouterRoute<ResolvedRoute<TRoutes[number]>>` while remaining distributive
1139
- */
1140
- export declare type RouterRoutes<TRoutes extends Routes> = {
1141
- [K in keyof TRoutes]: RouterRoute<ResolvedRoute<TRoutes[K]>>;
1142
- }[number];
1143
-
1144
- /**
1145
- * @hidden we don't want the criptic component types showing up in the api docs
1146
- */
1147
- export declare const RouterView: __VLS_WithTemplateSlots<DefineComponent< {
1148
- name?: string;
1149
- }, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
1150
- name?: string;
1151
- }> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>, Readonly<{
1152
- default?: (props: {
1153
- route: RouterRoute;
1154
- component: Component;
1155
- rejection: UnwrapRef<RouterRejection>;
1156
- }) => VNode;
1157
- }> & {
1158
- default?: (props: {
1159
- route: RouterRoute;
1160
- component: Component;
1161
- rejection: UnwrapRef<RouterRejection>;
1162
- }) => VNode;
1163
- }>;
1164
-
1165
- /**
1166
- * Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
1167
- */
1168
- export declare type Routes = readonly Route[];
1169
-
1170
- declare type RoutesMap<TRoutes extends Routes = []> = {
1171
- [K in TRoutes[number] as AsNamedRoute<K>['name']]: AsNamedRoute<K>;
1172
- };
1173
-
1174
- declare type RoutesName<TRoutes extends Routes> = string & keyof RoutesMap<TRoutes>;
1175
-
1176
- declare type RouteStateByName<TRoutes extends Routes, TName extends string> = ExtractStateParams<RouteGetByKey<TRoutes, TName>>;
1177
-
1178
- declare type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = ResolvedRoute extends TRoute ? {
1179
- (paramName: string, paramValue: unknown, options?: RouterPushOptions): Promise<void>;
1180
- (params: Partial<TRoute['params']>, options?: RouterPushOptions): Promise<void>;
1181
- } : {
1182
- <TParamName extends keyof TRoute['params']>(paramName: TParamName, paramValue: TRoute['params'][TParamName], options?: RouterPushOptions): Promise<void>;
1183
- (params: Partial<TRoute['params']>, options?: RouterPushOptions): Promise<void>;
1184
- };
1185
-
1186
- declare type RouteWithMatch<TRoute extends RouterRoute, TRouteName extends TRoute['name']> = TRoute extends RouterRoute ? TRouteName extends TRoute['matches'][number]['name'] ? TRoute : never : never;
1187
-
1188
- declare type StringHasValue<T> = string extends T ? true : '' extends T ? false : T extends string ? true : false;
1189
-
1190
- export declare type ToCallback = (resolve: RegisteredRouter['resolve']) => ResolvedRoute | Url | undefined;
1191
-
1192
- declare type ToMatch<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = Omit<TOptions, 'props'> & {
1193
- id: string;
1194
- props: TProps;
1195
- };
1196
-
1197
- declare type ToMatches<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = TOptions extends {
1198
- parent: infer TParent extends Route;
1199
- } ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<TOptions, TProps>];
1200
-
1201
- declare type ToMeta<TMeta extends RouteMeta | undefined> = TMeta extends undefined ? {} : unknown extends TMeta ? {} : TMeta;
1202
-
1203
- declare type ToName<T extends string | undefined> = T extends string ? T : '';
1204
-
1205
- declare type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined> = CreateRouteOptions extends TOptions ? Route : TOptions extends {
1206
- parent: infer TParent extends Route;
1207
- } ? 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>> : Route<ToName<TOptions['name']>, TOptions extends {
1208
- host: string | WithParams;
1209
- } ? ToWithParams<TOptions['host']> : WithParams<'', {}>, ToWithParams<TOptions['path']>, ToWithParams<TOptions['query']>, ToWithParams<TOptions['hash']>, ToMeta<TOptions['meta']>, ToState<TOptions['state']>, ToMatches<TOptions, TProps>>;
1210
-
1211
- declare type ToState<TState extends Record<string, Param> | undefined> = TState extends undefined ? Record<string, Param> : unknown extends TState ? {} : TState;
1212
-
1213
- declare type ToWithParams<T extends string | WithParams | undefined> = T extends string ? WithParams<T, {}> : T extends undefined ? WithParams<'', {}> : unknown extends T ? WithParams<'', {}> : T;
1214
-
1215
- declare type TupleOf<T extends Param[]> = {
1216
- [K in keyof T]: ExtractParamType<T[K]>;
1217
- };
1218
-
1219
- export declare function tupleOf<const T extends Param[]>(params: T, options?: TupleOfOptions): ParamGetSet<TupleOf<T>>;
1220
-
1221
- declare type TupleOfOptions = {
1222
- separator?: string;
1223
- };
1224
-
1225
- export declare function unionOf<const T extends Param[]>(params: T): ParamGetSet<ExtractParamType<T[number]>>;
1226
-
1227
- export declare type Url = `http://${string}` | `https://${string}` | `/${string}`;
1228
-
1229
- export declare type UrlParts = {
1230
- protocol?: string;
1231
- host?: string;
1232
- pathname: string;
1233
- searchParams: QuerySource;
1234
- search: string;
1235
- hash: string;
1236
- };
1237
-
1238
- export declare type UseLink = {
1239
- /**
1240
- * A template ref to bind to the dom for automatic prefetching
1241
- */
1242
- element: Ref<HTMLElement | undefined>;
1243
- /**
1244
- * ResolvedRoute if matched. Same value as `router.find`
1245
- */
1246
- route: ComputedRef<ResolvedRoute | undefined>;
1247
- /**
1248
- * Resolved URL with params interpolated and query applied. Same value as `router.resolve`.
1249
- */
1250
- href: ComputedRef<Url | undefined>;
1251
- /**
1252
- * True if route matches current URL or is ancestor of route that matches current URL
1253
- */
1254
- isMatch: ComputedRef<boolean>;
1255
- /**
1256
- * True if route matches current URL. Route is the same as what's currently stored at `router.route`.
1257
- */
1258
- isExactMatch: ComputedRef<boolean>;
1259
- /**
1260
- * True if route matches current URL, or is a parent route that matches the parent of the current URL.
1261
- */
1262
- isActive: ComputedRef<boolean>;
1263
- /**
1264
- * True if route matches current URL exactly.
1265
- */
1266
- isExactActive: ComputedRef<boolean>;
1267
- /**
1268
- *
1269
- */
1270
- isExternal: ComputedRef<boolean>;
1271
- /**
1272
- * Convenience method for executing `router.push` with route context passed in.
1273
- */
1274
- push: (options?: RouterPushOptions) => Promise<void>;
1275
- /**
1276
- * Convenience method for executing `router.replace` with route context passed in.
1277
- */
1278
- replace: (options?: RouterReplaceOptions) => Promise<void>;
1279
- };
1280
-
1281
- /**
1282
- * A composition to export much of the functionality that drives RouterLink component. Can be given route details to discover resolved URL,
1283
- * or resolved URL to discover route details. Also exports some useful context about routes relationship to current URL and convenience methods
1284
- * for navigating.
1285
- *
1286
- * @param source - The name of the route or a valid URL.
1287
- * @param params - If providing route name, this argument will expect corresponding params.
1288
- * @param options - {@link RouterResolveOptions} Same options as router resolve.
1289
- * @returns {UseLink} Reactive context values for as well as navigation methods.
1290
- * @group Compositions
1291
- */
1292
- export declare function useLink<TRouteKey extends RegisteredRoutesName>(name: MaybeRefOrGetter<TRouteKey>, ...args: UseLinkArgs<TRouteKey>): UseLink;
1293
-
1294
- export declare function useLink(url: MaybeRefOrGetter<Url>, options?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1295
-
1296
- export declare function useLink(resolvedRoute: MaybeRefOrGetter<ResolvedRoute | undefined>, options?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1297
-
1298
- export declare function useLink(source: MaybeRefOrGetter<string | ResolvedRoute | undefined>, paramsOrOptions?: MaybeRefOrGetter<Record<PropertyKey, unknown> | UseLinkOptions>, maybeOptions?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1299
-
1300
- declare type UseLinkArgs<TSource extends RegisteredRoutesName, TParams = RouteParamsByKey<RegisteredRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>] : [params: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>];
1301
-
1302
- export declare type UseLinkOptions = RouterPushOptions & {
1303
- prefetch?: PrefetchConfig;
1304
- };
1305
-
1306
- declare type UseQueryValue<T> = {
1307
- value: Ref<T | null>;
1308
- values: Ref<T[]>;
1309
- remove: () => void;
1310
- };
1311
-
1312
- export declare function useQueryValue(key: MaybeRefOrGetter<string>): UseQueryValue<string>;
1313
-
1314
- export declare function useQueryValue<TParam extends Param>(key: MaybeRefOrGetter<string>, param: TParam): UseQueryValue<ExtractParamType<TParam>>;
1315
-
1316
- /**
1317
- * A composition to access the current route or verify a specific route name within a Vue component.
1318
- * This function provides two overloads:
1319
- * 1. When called without arguments, it returns the current route from the router without types.
1320
- * 2. When called with a route name, it checks if the current active route includes the specified route name.
1321
- *
1322
- * The function also sets up a reactive watcher on the route object from the router to continually check the validity of the route name
1323
- * if provided, throwing an error if the validation fails at any point during the component's lifecycle.
1324
- *
1325
- * @template TRouteName - A string type that should match route name of RegisteredRouteMap, ensuring the route name exists.
1326
- * @param routeName - Optional. The name of the route to validate against the current active routes.
1327
- * @returns The current router route. If a route name is provided, it validates the route name first.
1328
- * @throws {UseRouteInvalidError} Throws an error if the provided route name is not valid or does not match the current route.
1329
- * @group Compositions
1330
- */
1331
- export declare function useRoute(): RegisteredRouterRoute;
1332
-
1333
- export declare function useRoute<TRouteName extends RegisteredRoutesName>(routeName: TRouteName, options: IsRouteOptions & {
1334
- exact: true;
1335
- }): RegisteredRouterRoute & {
1336
- name: TRouteName;
1337
- };
1338
-
1339
- export declare function useRoute<TRouteName extends RegisteredRoutesName>(routeName: TRouteName, options?: IsRouteOptions): RegisteredRouterRoute & {
1340
- name: `${TRouteName}${string}`;
1341
- };
1342
-
1343
- /**
1344
- * An error thrown when there is a mismatch between an expected route and the one actually used.
1345
- * @group Errors
1346
- */
1347
- export declare class UseRouteInvalidError extends Error {
1348
- /**
1349
- * Constructs a new UseRouteInvalidError instance with a message that specifies both the given and expected route names.
1350
- * This detailed error message aids in quickly identifying and resolving mismatches in route usage.
1351
- * @param routeName - The route name that was incorrectly used.
1352
- * @param actualRouteName - The expected route name that should have been used.
1353
- */
1354
- constructor(routeName: string, actualRouteName: string);
1355
- }
1356
-
1357
- /**
1358
- * A composition to access the registered router instance within a Vue component.
1359
- *
1360
- * @returns The registered router instance.
1361
- * @throws {RouterNotInstalledError} Throws an error if the router has not been installed,
1362
- * ensuring the component does not operate without routing functionality.
1363
- * @group Compositions
1364
- */
1365
- export declare function useRouter(): RegisteredRouter;
1366
-
1367
- declare interface ValibotSchemaLike extends StandardSchemaV1<any> {
1368
- type: string;
1369
- }
1370
-
1371
- export declare function withDefault<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
1372
-
1373
- /**
1374
- * Defines route hooks that can be applied before entering, updating, or leaving a route, as well as after these events.
1375
- */
1376
- export declare type WithHooks = {
1377
- onBeforeRouteEnter?: MaybeArray<BeforeRouteHook>;
1378
- onBeforeRouteUpdate?: MaybeArray<BeforeRouteHook>;
1379
- onBeforeRouteLeave?: MaybeArray<BeforeRouteHook>;
1380
- onAfterRouteEnter?: MaybeArray<AfterRouteHook>;
1381
- onAfterRouteUpdate?: MaybeArray<AfterRouteHook>;
1382
- onAfterRouteLeave?: MaybeArray<AfterRouteHook>;
1383
- };
1384
-
1385
- declare type WithHost<THost extends string | WithParams = string | WithParams> = {
1386
- /**
1387
- * Host part of URL.
1388
- */
1389
- host: THost;
1390
- };
1391
-
1392
- declare type WithOptionalProperties<T> = {
1393
- [P in keyof T]-?: undefined extends T[P] ? P : never;
1394
- }[keyof T];
1395
-
1396
- declare type WithoutHost = {
1397
- host?: never;
1398
- };
1399
-
1400
- declare type WithoutParent = {
1401
- parent?: never;
1402
- };
1403
-
1404
- declare type WithParams<TValue extends string = string, TParams extends Record<string, Param | undefined> = Record<string, Param | undefined>> = {
1405
- value: TValue;
1406
- params: string extends TValue ? Record<string, Param> : Identity<WithParamsParamsOutput<TValue, TParams>>;
1407
- };
1408
-
1409
- export declare function withParams<const TValue extends string, const TParams extends MakeOptional<WithParamsParamsInput<TValue>>>(value: TValue, params: TParams): WithParams<TValue, TParams>;
1410
-
1411
- export declare function withParams(): WithParams<'', {}>;
1412
-
1413
- declare type WithParamsParamsInput<TValue extends string> = TValue extends `${string}${ParamStart}${infer TParam}${ParamEnd}${infer Rest}` ? Record<ExtractParamName<TParam>, Param | undefined> & WithParamsParamsInput<Rest> : {};
1414
-
1415
- declare type WithParamsParamsOutput<TValue extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TValue extends `${string}${ParamStart}${infer TParam}${ParamEnd}${infer Rest}` ? ExtractParamName<TParam> extends keyof TParams ? Record<ExtractParamName<TParam>, TParams[ExtractParamName<TParam>]> & WithParamsParamsOutput<Rest, TParams> : Record<ExtractParamName<TParam>, StringConstructor> & WithParamsParamsOutput<Rest, TParams> : {};
1416
-
1417
- declare type WithParent<TParent extends Route = Route> = {
1418
- parent: TParent;
1419
- };
1420
-
1421
- declare interface ZodSchemaLike extends StandardSchemaV1<any> {
1422
- parse: (input: any) => any;
1423
- }
1424
-
1425
- export { }
1426
-
1427
-
1428
- declare module 'vue' {
1429
- interface GlobalComponents {
1430
- RouterView: typeof RouterView;
1431
- RouterLink: typeof RouterLink;
1432
- }
1433
- }
1
+ export * from './main'
2
+ export {}