@kitbag/router 0.24.2 → 0.25.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 (261) hide show
  1. package/dist/{src/components → components}/routerLink.d.ts +4 -4
  2. package/dist/{src/components → components}/routerView.d.ts +3 -3
  3. package/dist/{src/compositions → compositions}/useComponentsStore.d.ts +2 -2
  4. package/dist/{src/compositions → compositions}/useLink.d.ts +6 -6
  5. package/dist/{src/compositions → compositions}/usePrefetching.d.ts +3 -3
  6. package/dist/{src/compositions → compositions}/useQueryValue.d.ts +3 -3
  7. package/dist/{src/compositions → compositions}/useRejection.d.ts +2 -2
  8. package/dist/{src/compositions → compositions}/useRoute.d.ts +2 -2
  9. package/dist/compositions/useRouteValueStore.d.ts +7 -0
  10. package/dist/{src/compositions → compositions}/useRouter.d.ts +1 -1
  11. package/dist/{src/compositions → compositions}/useRouterDepth.d.ts +1 -1
  12. package/dist/{src/compositions → compositions}/useRouterHooks.d.ts +2 -2
  13. package/dist/{src/compositions → compositions}/useVisibilityObserver.d.ts +1 -1
  14. package/dist/{src/devtools → devtools}/createRouterDevtools.d.ts +2 -2
  15. package/dist/{src/devtools → devtools}/filters.d.ts +1 -1
  16. package/dist/{src/errors → errors}/contextAbortError.d.ts +1 -1
  17. package/dist/{src/errors → errors}/contextPushError.d.ts +1 -1
  18. package/dist/{src/errors → errors}/contextRejectionError.d.ts +1 -1
  19. package/dist/{src/errors → errors}/invalidRouteParamValueError.d.ts +1 -1
  20. package/dist/errors/loaderDataAccessError.d.ts +8 -0
  21. package/dist/errors/loaderNameConflict.d.ts +9 -0
  22. package/dist/errors/navigationAbandonedError.d.ts +6 -0
  23. package/dist/{src/guards → guards}/routes.d.ts +2 -2
  24. package/dist/kitbag-router.d.ts +1 -0
  25. package/dist/kitbag-router.js +6452 -6172
  26. package/dist/kitbag-router.umd.cjs +5 -4
  27. package/dist/{src/main.d.ts → main.d.ts} +10 -2
  28. package/dist/{src/models → models}/hooks.d.ts +2 -2
  29. package/dist/services/addLoader.d.ts +40 -0
  30. package/dist/services/addView.d.ts +37 -0
  31. package/dist/{src/services → services}/arrayOf.d.ts +2 -2
  32. package/dist/{src/services → services}/combineHash.d.ts +2 -2
  33. package/dist/{src/services → services}/combinePath.d.ts +2 -2
  34. package/dist/{src/services → services}/combineQuery.d.ts +2 -2
  35. package/dist/{src/services → services}/combineState.d.ts +1 -1
  36. package/dist/{src/services → services}/combineUrl.d.ts +2 -2
  37. package/dist/{src/services → services}/component.d.ts +3 -4
  38. package/dist/{src/services → services}/createComponentHooks.d.ts +4 -4
  39. package/dist/{src/services → services}/createComponentsStore.d.ts +3 -3
  40. package/dist/{src/services → services}/createCurrentRejection.d.ts +2 -2
  41. package/dist/services/createCurrentRoute.d.ts +25 -0
  42. package/dist/services/createDataStore.d.ts +48 -0
  43. package/dist/{src/services → services}/createExternalRoute.d.ts +4 -4
  44. package/dist/services/createNavigationStores.d.ts +31 -0
  45. package/dist/{src/services → services}/createParam.d.ts +3 -3
  46. package/dist/{src/services → services}/createRejection.d.ts +3 -3
  47. package/dist/{src/services → services}/createRejectionHooks.d.ts +3 -3
  48. package/dist/services/createResolvedRoute.d.ts +4 -0
  49. package/dist/{src/services → services}/createResolvedRouteQuery.d.ts +1 -1
  50. package/dist/{src/services → services}/createRoute.d.ts +3 -6
  51. package/dist/{src/services → services}/createRouteHooks.d.ts +5 -5
  52. package/dist/{src/services → services}/createRouteRedirects.d.ts +2 -2
  53. package/dist/services/createRouteValueStore.d.ts +56 -0
  54. package/dist/services/createRouteViews.d.ts +16 -0
  55. package/dist/{src/services → services}/createRouter.d.ts +3 -3
  56. package/dist/{src/services → services}/createRouterAssets.d.ts +10 -10
  57. package/dist/{src/services → services}/createRouterCallbackContext.d.ts +7 -7
  58. package/dist/{src/services → services}/createRouterHistory.d.ts +1 -1
  59. package/dist/{src/services → services}/createRouterHooks.d.ts +2 -2
  60. package/dist/{src/services → services}/createRouterKeyStore.d.ts +1 -1
  61. package/dist/{src/services → services}/createRouterPlugin.d.ts +3 -3
  62. package/dist/services/createRouterRoute.d.ts +7 -0
  63. package/dist/{src/services → services}/createUrl.d.ts +1 -1
  64. package/dist/services/getGlobalHooksForRouter.d.ts +3 -0
  65. package/dist/{src/services → services}/getGlobalRouteHooks.d.ts +2 -2
  66. package/dist/{src/services → services}/getMatchesForUrl.d.ts +3 -3
  67. package/dist/{src/services → services}/getParamsForString.d.ts +2 -2
  68. package/dist/services/getRejectionHooks.d.ts +3 -0
  69. package/dist/{src/services → services}/getRouteHooks.d.ts +2 -2
  70. package/dist/{src/services → services}/getRoutesForRouter.d.ts +5 -6
  71. package/dist/{src/services → services}/hooks.d.ts +2 -2
  72. package/dist/{src/services → services}/insertBaseRoute.d.ts +1 -1
  73. package/dist/{src/services → services}/literal.d.ts +1 -1
  74. package/dist/{src/services → services}/params.d.ts +3 -3
  75. package/dist/{src/services → services}/queryParamFilter.d.ts +1 -1
  76. package/dist/{src/services → services}/routeRegex.d.ts +1 -1
  77. package/dist/{src/services → services}/state.d.ts +1 -1
  78. package/dist/{src/services → services}/tupleOf.d.ts +2 -2
  79. package/dist/services/unionOf.d.ts +3 -0
  80. package/dist/{src/services → services}/urlParser.d.ts +2 -2
  81. package/dist/{src/services → services}/valibot.d.ts +1 -1
  82. package/dist/{src/services → services}/withDefault.d.ts +2 -2
  83. package/dist/{src/services → services}/withParams.d.ts +4 -4
  84. package/dist/services/withRouteMethods.d.ts +7 -0
  85. package/dist/{src/services → services}/zod.d.ts +2 -2
  86. package/dist/types/addLoader.d.ts +69 -0
  87. package/dist/types/addView.d.ts +104 -0
  88. package/dist/{src/types → types}/createRouteOptions.d.ts +57 -36
  89. package/dist/{src/types → types}/hooks.d.ts +14 -14
  90. package/dist/{src/types → types}/paramTypes.d.ts +2 -2
  91. package/dist/{src/types → types}/params.d.ts +1 -1
  92. package/dist/{src/types → types}/prefetch.d.ts +1 -0
  93. package/dist/{src/types → types}/props.d.ts +13 -5
  94. package/dist/{src/types → types}/register.d.ts +1 -1
  95. package/dist/{src/types → types}/rejection.d.ts +4 -4
  96. package/dist/{src/types → types}/resolved.d.ts +24 -5
  97. package/dist/types/route.d.ts +121 -0
  98. package/dist/types/routeCallbackContext.d.ts +30 -0
  99. package/dist/types/routeLoaders.d.ts +30 -0
  100. package/dist/{src/types → types}/routeTitle.d.ts +1 -1
  101. package/dist/{src/types → types}/routeUpdate.d.ts +2 -2
  102. package/dist/types/routeViews.d.ts +44 -0
  103. package/dist/types/routeWithMethods.d.ts +16 -0
  104. package/dist/{src/types → types}/routeWithParams.d.ts +3 -3
  105. package/dist/{src/types → types}/router.d.ts +13 -13
  106. package/dist/{src/types → types}/routerLink.d.ts +5 -5
  107. package/dist/{src/types → types}/routerPlugin.d.ts +3 -3
  108. package/dist/{src/types → types}/routerPush.d.ts +8 -8
  109. package/dist/{src/types → types}/routerReject.d.ts +1 -1
  110. package/dist/{src/types → types}/routerReplace.d.ts +8 -8
  111. package/dist/{src/types → types}/routerResolve.d.ts +7 -7
  112. package/dist/{src/types → types}/routerRoute.d.ts +9 -3
  113. package/dist/{src/types → types}/routesMap.d.ts +2 -2
  114. package/dist/{src/types → types}/state.d.ts +6 -6
  115. package/dist/{src/types → types}/url.d.ts +6 -6
  116. package/dist/{src/types → types}/useLink.d.ts +5 -5
  117. package/dist/{src/types → types}/utilities.d.ts +1 -0
  118. package/dist/{src/utilities → utilities}/checkDuplicateNames.d.ts +1 -1
  119. package/dist/utilities/checkDuplicateNames.spec.d.ts +1 -0
  120. package/dist/utilities/checkDuplicateParams.spec.d.ts +1 -0
  121. package/dist/utilities/components.spec.d.ts +1 -0
  122. package/dist/utilities/guards.spec.d.ts +1 -0
  123. package/dist/utilities/isBrowser.browser.spec.d.ts +1 -0
  124. package/dist/utilities/isBrowser.spec.d.ts +1 -0
  125. package/dist/{src/utilities → utilities}/isNamedRoute.d.ts +1 -1
  126. package/dist/{src/utilities → utilities}/prefetch.d.ts +2 -2
  127. package/dist/utilities/prefetch.spec.d.ts +1 -0
  128. package/dist/utilities/props.d.ts +16 -0
  129. package/dist/{src/utilities → utilities}/setDocumentTitle.d.ts +1 -1
  130. package/dist/utilities/testHelpers.d.ts +242 -0
  131. package/dist/utilities/trailingSlashes.spec.d.ts +1 -0
  132. package/dist/{src/utilities → utilities}/urlSearchParams.d.ts +1 -1
  133. package/dist/utilities/urlSearchParams.spec.d.ts +1 -0
  134. package/package.json +18 -16
  135. package/dist/src/compositions/usePropStore.d.ts +0 -7
  136. package/dist/src/services/createCurrentRoute.d.ts +0 -13
  137. package/dist/src/services/createPropStore.d.ts +0 -13
  138. package/dist/src/services/createResolvedRoute.d.ts +0 -4
  139. package/dist/src/services/createRouterRoute.d.ts +0 -7
  140. package/dist/src/services/getGlobalHooksForRouter.d.ts +0 -3
  141. package/dist/src/services/getRejectionHooks.d.ts +0 -3
  142. package/dist/src/services/unionOf.d.ts +0 -3
  143. package/dist/src/types/route.d.ts +0 -80
  144. package/dist/src/utilities/props.d.ts +0 -6
  145. package/dist/src/utilities/testHelpers.d.ts +0 -3699
  146. /package/dist/{src/components → components}/echo.d.ts +0 -0
  147. /package/dist/{src/components → components}/helloWorld.d.ts +0 -0
  148. /package/dist/{src/components → components}/rejection.d.ts +0 -0
  149. /package/dist/{src/components → components}/routerLink.browser.spec.d.ts +0 -0
  150. /package/dist/{src/components → components}/routerView.browser.spec.d.ts +0 -0
  151. /package/dist/{src/components → components}/routerView.spec.d.ts +0 -0
  152. /package/dist/{src/compositions → compositions}/useEventListener.d.ts +0 -0
  153. /package/dist/{src/compositions → compositions}/useQueryValue.browser.spec.d.ts +0 -0
  154. /package/dist/{src/compositions → compositions}/useQueryValue.spec-d.d.ts +0 -0
  155. /package/dist/{src/compositions → compositions}/useRoute.browser.spec.d.ts +0 -0
  156. /package/dist/{src/compositions → compositions}/useRoute.spec-d.d.ts +0 -0
  157. /package/dist/{src/devtools → devtools}/getDevtoolsLabel.d.ts +0 -0
  158. /package/dist/{src/devtools → devtools}/types.d.ts +0 -0
  159. /package/dist/{src/errors → errors}/contextError.d.ts +0 -0
  160. /package/dist/{src/errors → errors}/duplicateNamesError.d.ts +0 -0
  161. /package/dist/{src/errors → errors}/duplicateParamsError.d.ts +0 -0
  162. /package/dist/{src/errors → errors}/initialRouteMissingError.d.ts +0 -0
  163. /package/dist/{src/errors → errors}/invalidRouteRedirectError.d.ts +0 -0
  164. /package/dist/{src/errors → errors}/metaPropertyConflict.d.ts +0 -0
  165. /package/dist/{src/errors → errors}/multipleRouteRedirectsError.d.ts +0 -0
  166. /package/dist/{src/errors → errors}/routeNotFoundError.d.ts +0 -0
  167. /package/dist/{src/errors → errors}/routerNotInstalledError.d.ts +0 -0
  168. /package/dist/{src/errors → errors}/useRouteInvalidError.d.ts +0 -0
  169. /package/dist/{src/guards → guards}/routes.spec-d.d.ts +0 -0
  170. /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
  171. /package/dist/{src/services/arrayOf.spec.d.ts → services/addLoader.spec-d.d.ts} +0 -0
  172. /package/dist/{src/services/combineHash.spec.d.ts → services/addLoader.spec.d.ts} +0 -0
  173. /package/dist/{src/services/combineMeta.spec.d.ts → services/addView.browser.spec.d.ts} +0 -0
  174. /package/dist/{src/services/combinePath.spec-d.d.ts → services/addView.spec-d.d.ts} +0 -0
  175. /package/dist/{src/services/combinePath.spec.d.ts → services/addView.spec.d.ts} +0 -0
  176. /package/dist/{src/services/combineQuery.spec.d.ts → services/arrayOf.spec.d.ts} +0 -0
  177. /package/dist/{src/services/combineState.spec.d.ts → services/combineHash.spec.d.ts} +0 -0
  178. /package/dist/{src/services → services}/combineMeta.d.ts +0 -0
  179. /package/dist/{src/services/combineUrl.spec.d.ts → services/combineMeta.spec.d.ts} +0 -0
  180. /package/dist/{src/services/component.browser.spec.d.ts → services/combinePath.spec-d.d.ts} +0 -0
  181. /package/dist/{src/services/createExternalRoute.spec.d.ts → services/combinePath.spec.d.ts} +0 -0
  182. /package/dist/{src/services/createIsExternal.spec.d.ts → services/combineQuery.spec.d.ts} +0 -0
  183. /package/dist/{src/services/createResolvedRoute.spec.d.ts → services/combineState.spec.d.ts} +0 -0
  184. /package/dist/{src/services/createRoute.spec-d.d.ts → services/combineUrl.spec.d.ts} +0 -0
  185. /package/dist/{src/services/createRoute.spec.d.ts → services/component.browser.spec.d.ts} +0 -0
  186. /package/dist/{src/services/createRouteRedirects.spec.d.ts → services/createDataStore.spec.d.ts} +0 -0
  187. /package/dist/{src/services/createRouter.browser.spec.d.ts → services/createExternalRoute.spec.d.ts} +0 -0
  188. /package/dist/{src/services → services}/createIsExternal.d.ts +0 -0
  189. /package/dist/{src/services/createRouter.spec-d.d.ts → services/createIsExternal.spec.d.ts} +0 -0
  190. /package/dist/{src/services/createRouter.spec.d.ts → services/createNavigationStores.spec.d.ts} +0 -0
  191. /package/dist/{src/services/createRouterHistory.browser.spec.d.ts → services/createResolvedRoute.spec.d.ts} +0 -0
  192. /package/dist/{src/services/createRouterPlugin.browser.spec.d.ts → services/createRoute.spec-d.d.ts} +0 -0
  193. /package/dist/{src/services/createRouterPlugin.spec-d.d.ts → services/createRoute.spec.d.ts} +0 -0
  194. /package/dist/{src/services → services}/createRouteId.d.ts +0 -0
  195. /package/dist/{src/services/createRouterRoute.spec.d.ts → services/createRouteRedirects.spec.d.ts} +0 -0
  196. /package/dist/{src/services/createUrl.spec.d.ts → services/createRouter.browser.spec.d.ts} +0 -0
  197. /package/dist/{src/services/getInitialUrl.browser.spec.d.ts → services/createRouter.spec-d.d.ts} +0 -0
  198. /package/dist/{src/services/getInitialUrl.spec.d.ts → services/createRouter.spec.d.ts} +0 -0
  199. /package/dist/{src/services/getMatchesForUrl.spec.d.ts → services/createRouterHistory.browser.spec.d.ts} +0 -0
  200. /package/dist/{src/services/getRouteHooks.spec.d.ts → services/createRouterPlugin.browser.spec.d.ts} +0 -0
  201. /package/dist/{src/services/getRoutesForRouter.spec.d.ts → services/createRouterPlugin.spec-d.d.ts} +0 -0
  202. /package/dist/{src/services/history.browser.spec.d.ts → services/createRouterRoute.spec.d.ts} +0 -0
  203. /package/dist/{src/services → services}/createUniqueIdSequence.d.ts +0 -0
  204. /package/dist/{src/services/hooks.browser.spec.d.ts → services/createUrl.spec.d.ts} +0 -0
  205. /package/dist/{src/services → services}/createVisibilityObserver.d.ts +0 -0
  206. /package/dist/{src/services → services}/createVueAppStore.d.ts +0 -0
  207. /package/dist/{src/services/hooks.spec.d.ts → services/getInitialUrl.browser.spec.d.ts} +0 -0
  208. /package/dist/{src/services → services}/getInitialUrl.d.ts +0 -0
  209. /package/dist/{src/services/insertBaseRoute.spec.d.ts → services/getInitialUrl.spec.d.ts} +0 -0
  210. /package/dist/{src/services/params.spec.d.ts → services/getMatchesForUrl.spec.d.ts} +0 -0
  211. /package/dist/{src/services/paramsFinder.spec.d.ts → services/getRouteHooks.spec.d.ts} +0 -0
  212. /package/dist/{src/services/queryParamFilter.spec.d.ts → services/getRoutesForRouter.spec.d.ts} +0 -0
  213. /package/dist/{src/services/routeRegex.spec.d.ts → services/history.browser.spec.d.ts} +0 -0
  214. /package/dist/{src/services → services}/history.d.ts +0 -0
  215. /package/dist/{src/services/state.spec.d.ts → services/hooks.browser.spec.d.ts} +0 -0
  216. /package/dist/{src/tests → services}/hooks.spec.d.ts +0 -0
  217. /package/dist/{src/services/tupleOf.spec.d.ts → services/insertBaseRoute.spec.d.ts} +0 -0
  218. /package/dist/{src/services/unionOf.spec.d.ts → services/params.spec.d.ts} +0 -0
  219. /package/dist/{src/services → services}/paramsFinder.d.ts +0 -0
  220. /package/dist/{src/services/urlParser.spec.d.ts → services/paramsFinder.spec.d.ts} +0 -0
  221. /package/dist/{src/services/valibot.spec-d.d.ts → services/queryParamFilter.spec.d.ts} +0 -0
  222. /package/dist/{src/services/valibot.spec.d.ts → services/routeRegex.spec.d.ts} +0 -0
  223. /package/dist/{src/services/withParams.spec-d.d.ts → services/state.spec.d.ts} +0 -0
  224. /package/dist/{src/services/withParams.spec.d.ts → services/tupleOf.spec.d.ts} +0 -0
  225. /package/dist/{src/services/zod.spec-d.d.ts → services/unionOf.spec.d.ts} +0 -0
  226. /package/dist/{src/services/zod.spec.d.ts → services/urlParser.spec.d.ts} +0 -0
  227. /package/dist/{src/tests/routeProps.browser.spec.d.ts → services/valibot.spec-d.d.ts} +0 -0
  228. /package/dist/{src/tests/routeProps.spec.d.ts → services/valibot.spec.d.ts} +0 -0
  229. /package/dist/{src/types/redirects.spec-d.d.ts → services/withParams.spec-d.d.ts} +0 -0
  230. /package/dist/{src/types/register.spec.d.ts → services/withParams.spec.d.ts} +0 -0
  231. /package/dist/{src/types/resolved.spec-d.d.ts → services/zod.spec-d.d.ts} +0 -0
  232. /package/dist/{src/types/route.spec-d.d.ts → services/zod.spec.d.ts} +0 -0
  233. /package/dist/{src/types/routeTitle.browser.spec.d.ts → tests/hooks.spec.d.ts} +0 -0
  234. /package/dist/{src/types/routeWithParams.spec-d.d.ts → tests/routeLoaders.browser.spec.d.ts} +0 -0
  235. /package/dist/{src/types/routesMap.spec-ts.d.ts → tests/routeLoaders.spec.d.ts} +0 -0
  236. /package/dist/{src/utilities/checkDuplicateNames.spec.d.ts → tests/routeProps.browser.spec.d.ts} +0 -0
  237. /package/dist/{src/utilities/checkDuplicateParams.spec.d.ts → tests/routeProps.spec.d.ts} +0 -0
  238. /package/dist/{src/types → types}/callbackContext.d.ts +0 -0
  239. /package/dist/{src/types → types}/meta.d.ts +0 -0
  240. /package/dist/{src/types → types}/name.d.ts +0 -0
  241. /package/dist/{src/types → types}/querySource.d.ts +0 -0
  242. /package/dist/{src/types → types}/redirects.d.ts +0 -0
  243. /package/dist/{src/utilities/components.spec.d.ts → types/redirects.spec-d.d.ts} +0 -0
  244. /package/dist/{src/utilities/guards.spec.d.ts → types/register.spec.d.ts} +0 -0
  245. /package/dist/{src/utilities/isBrowser.browser.spec.d.ts → types/resolved.spec-d.d.ts} +0 -0
  246. /package/dist/{src/utilities/isBrowser.spec.d.ts → types/route.spec-d.d.ts} +0 -0
  247. /package/dist/{src/types → types}/routeContext.d.ts +0 -0
  248. /package/dist/{src/utilities/prefetch.spec.d.ts → types/routeTitle.browser.spec.d.ts} +0 -0
  249. /package/dist/{src/utilities/trailingSlashes.spec.d.ts → types/routeWithParams.spec-d.d.ts} +0 -0
  250. /package/dist/{src/types → types}/routerAbort.d.ts +0 -0
  251. /package/dist/{src/utilities/urlSearchParams.spec.d.ts → types/routesMap.spec-ts.d.ts} +0 -0
  252. /package/dist/{src/types → types}/urlString.d.ts +0 -0
  253. /package/dist/{src/utilities → utilities}/array.d.ts +0 -0
  254. /package/dist/{src/utilities → utilities}/checkDuplicateParams.d.ts +0 -0
  255. /package/dist/{src/utilities → utilities}/components.d.ts +0 -0
  256. /package/dist/{src/utilities → utilities}/guards.d.ts +0 -0
  257. /package/dist/{src/utilities → utilities}/index.d.ts +0 -0
  258. /package/dist/{src/utilities → utilities}/isBrowser.d.ts +0 -0
  259. /package/dist/{src/utilities → utilities}/makeOptional.d.ts +0 -0
  260. /package/dist/{src/utilities → utilities}/promises.d.ts +0 -0
  261. /package/dist/{src/utilities → utilities}/trailingSlashes.d.ts +0 -0
@@ -1,11 +1,14 @@
1
- import { CreateRouteOptions, PropsGetter } from '../../types/createRouteOptions';
2
- import { Route } from '../../types/route';
1
+ import { CreateRouteOptions } from './createRouteOptions';
2
+ import { Route } from './route';
3
3
  import { RouterReject } from './routerReject';
4
4
  import { RouterPush } from './routerPush';
5
5
  import { RouterReplace } from './routerReplace';
6
6
  import { ExtractRouteContextRejections, ExtractRouteContextRoutes } from './routeContext';
7
7
  import { ResolvedRoute } from './resolved';
8
8
  import { RouteUpdate } from './routeUpdate';
9
+ import { LoadersDataReturnType } from './routeLoaders';
10
+ import { ViewsPropsReturnType } from './routeViews';
11
+ import { LastInArray } from './utilities';
9
12
  /**
10
13
  * Context provided to props callback functions
11
14
  */
@@ -19,11 +22,16 @@ export type PropsCallbackContext<TRoute extends Route = Route, TOptions extends
19
22
  export type PropsCallbackParent<TParent extends Route | undefined = Route | undefined> = Route | undefined extends TParent ? undefined | {
20
23
  name: string;
21
24
  props: unknown;
25
+ data: unknown;
22
26
  } : TParent extends Route ? {
23
27
  name: TParent['name'];
24
28
  props: GetParentPropsReturnType<TParent>;
29
+ data: GetParentDataReturnType<TParent>;
25
30
  } : undefined;
26
- 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> ? {
27
- [K in keyof TParent['matched']['props']]: ReturnType<TParent['matched']['props'][K]>;
28
- } : undefined : undefined;
31
+ type GetParentPropsReturnType<TParent extends Route | undefined = Route | undefined> = TParent extends Route ? LastInArray<TParent['matches']> extends {
32
+ views: infer TViews;
33
+ } ? ViewsPropsReturnType<TViews> : undefined : undefined;
34
+ type GetParentDataReturnType<TParent extends Route | undefined = Route | undefined> = TParent extends Route ? LastInArray<TParent['matches']> extends {
35
+ loaders: infer TLoaders;
36
+ } ? LoadersDataReturnType<TLoaders> : undefined : undefined;
29
37
  export {};
@@ -1,4 +1,4 @@
1
- import { Router } from '../../types/router';
1
+ import { Router } from './router';
2
2
  /**
3
3
  * Represents the state of currently registered router, and route meta. Used to provide correct type context for
4
4
  * components like `RouterLink`, as well as for composables like `useRouter`, `useRoute`, and hooks.
@@ -1,8 +1,8 @@
1
1
  import { Ref } from 'vue';
2
- import { Route } from '../../types/route';
3
- import { Router } from '../../types/router';
4
- import { RouterReject } from '../../types/routerReject';
5
- import { Hooks } from '../../models/hooks';
2
+ import { Route } from './route';
3
+ import { Router } from './router';
4
+ import { RouterReject } from './routerReject';
5
+ import { Hooks } from '../models/hooks';
6
6
  export declare const BUILT_IN_REJECTION_TYPES: readonly ["NotFound"];
7
7
  export type BuiltInRejectionType = (typeof BUILT_IN_REJECTION_TYPES)[number];
8
8
  export type RouterRejection<T extends Rejection = Rejection> = Ref<T | null>;
@@ -1,7 +1,13 @@
1
- import { Route, Routes } from '../../types/route';
2
- import { ExtractRouteStateParamsAsOptional } from '../../types/state';
3
- import { UrlString } from '../../types/urlString';
4
- import { UrlParamsReading } from '../../types/url';
1
+ import { CreatedRouteOptions, Route, RouteDataOf, Routes } from './route';
2
+ import { LastInArray } from './utilities';
3
+ import { ExtractRouteStateParamsAsOptional } from './state';
4
+ import { UrlString } from './urlString';
5
+ import { UrlParamsReading } from './url';
6
+ /**
7
+ * The match a route resolved to, which is the last of its matches. Falls back to the wide match type when
8
+ * the matches are not a concrete tuple, so an unregistered router stays assignable.
9
+ */
10
+ type MatchedRoute<TMatches> = LastInArray<TMatches, CreatedRouteOptions> extends infer TMatched ? unknown extends TMatched ? CreatedRouteOptions : TMatched : never;
5
11
  /**
6
12
  * Represents a route that the router has matched to current browser location.
7
13
  * @template TRoute - Underlying Route that has been resolved.
@@ -14,7 +20,7 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
14
20
  /**
15
21
  * The specific route properties that were matched in the current route.
16
22
  */
17
- matched: TRoute['matched'];
23
+ matched: MatchedRoute<TRoute['matches']>;
18
24
  /**
19
25
  * The specific route properties that were matched in the current route, including any ancestors.
20
26
  * Order of routes will be from greatest ancestor to narrowest matched.
@@ -49,6 +55,18 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
49
55
  */
50
56
  title: Promise<string | undefined>;
51
57
  }>;
58
+ /**
59
+ * A resolved route whose loaders' data is available. Only the route being navigated to has data: a route
60
+ * the router merely resolved is not being loaded, so data on it could never settle. The current route and
61
+ * a props getter's route have it, `router.resolve` and hooks do not.
62
+ */
63
+ export type WithData<TRoute extends Route = Route> = {
64
+ /**
65
+ * What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed
66
+ * exposes that loader's data here directly. Always promises, since loaders never block rendering.
67
+ */
68
+ data: RouteDataOf<TRoute['matches']>;
69
+ };
52
70
  /**
53
71
  * This type is the same as `ResolvedRoute<TRoutes[number]>` while remaining distributive
54
72
  */
@@ -65,3 +83,4 @@ export type RouterResolvedRouteUnion<TRoutes extends Routes> = {
65
83
  * type ResolvedUnion = ResolvedRouteUnion<RouteUnion> // ResolvedRoute<RouteA> | ResolvedRoute<RouteB>
66
84
  */
67
85
  export type ResolvedRouteUnion<TRoute extends Route> = TRoute extends Route ? ResolvedRoute<TRoute> : never;
86
+ export {};
@@ -0,0 +1,121 @@
1
+ import { Param } from './paramTypes';
2
+ import { PrefetchConfig } from './prefetch';
3
+ import { RouteMeta } from './register';
4
+ import { LastInArray } from './utilities';
5
+ import { CreateRouteOptions } from './createRouteOptions';
6
+ import { RouteContext, ToRouteContext } from './routeContext';
7
+ import { ToMeta } from './meta';
8
+ import { ToState } from './state';
9
+ import { Url } from './url';
10
+ import { GetRouteTitle } from './routeTitle';
11
+ import { Hooks } from '../models/hooks';
12
+ import { RouteRedirect } from './redirects';
13
+ import { RouteViews } from './routeViews';
14
+ import { LoadersDataReturnType, RouteLoaders } from './routeLoaders';
15
+ export declare const IS_ROUTE_SYMBOL: unique symbol;
16
+ export declare function isRoute(value: unknown): value is Route & RouteInternal;
17
+ export type RouteInternal = {
18
+ [IS_ROUTE_SYMBOL]: true;
19
+ depth: number;
20
+ hooks: Hooks[];
21
+ redirect: RouteRedirect;
22
+ getTitle: GetRouteTitle;
23
+ };
24
+ /**
25
+ * Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
26
+ */
27
+ export type Routes = readonly Route[];
28
+ /**
29
+ * The Route properties originally provided to `createRoute`, plus the views that route renders and the
30
+ * loaders it runs. The deprecated `component`/`components` options are folded into `views` (see
31
+ * {@link RouteViews}).
32
+ */
33
+ export type CreatedRouteOptions = Omit<CreateRouteOptions, 'component' | 'components'> & {
34
+ id: string;
35
+ views: RouteViews;
36
+ loaders: RouteLoaders;
37
+ };
38
+ /**
39
+ * The name of the narrowest matched route.
40
+ */
41
+ type RouteNameOf<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
42
+ name: infer TName extends string;
43
+ } ? TName : string;
44
+ /**
45
+ * The meta of every matched route, combined. Mirrors `combineMeta`, which is an intersection.
46
+ */
47
+ type RouteMetaOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteMeta : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? ToMeta<THead extends {
48
+ meta: infer TMeta extends RouteMeta;
49
+ } ? TMeta : undefined> & RouteMetaOf<TRest> : {};
50
+ /**
51
+ * The state of every matched route, combined. Mirrors `combineState`, which is an intersection.
52
+ * A match without state contributes `{}` rather than `ToState<undefined>`, which widens to
53
+ * `Record<string, Param>` and would swallow the rest of the intersection.
54
+ */
55
+ type RouteStateOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? Record<string, Param> : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? (THead extends {
56
+ state: infer TState extends Record<string, Param>;
57
+ } ? ToState<TState> : {}) & RouteStateOf<TRest> : {};
58
+ /**
59
+ * The loaders of every matched route, combined. A plain intersection: a loader name is unique across a
60
+ * route and its ancestors, which `addLoader` enforces.
61
+ */
62
+ type RouteLoadersOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteLoaders : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? (THead extends {
63
+ loaders: infer TLoaders extends RouteLoaders;
64
+ } ? TLoaders : {}) & RouteLoadersOf<TRest> : {};
65
+ /**
66
+ * The data every matched route's loaders resolve to, which is what a resolved route exposes as `data`.
67
+ * Undefined when nothing in the route tree declares a loader.
68
+ */
69
+ export type RouteDataOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? Promise<unknown> | Record<string, Promise<unknown>> | undefined : LoadersDataReturnType<RouteLoadersOf<TMatches>>;
70
+ /**
71
+ * The context of every matched route, flattened from greatest ancestor to narrowest matched.
72
+ */
73
+ type RouteContextOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteContext[] : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? [...ToRouteContext<THead extends {
74
+ context: infer TContext extends RouteContext[];
75
+ } ? TContext : []>, ...RouteContextOf<TRest>] : [];
76
+ /**
77
+ * Represents the structure of a route within the application. Return value of `createRoute`
78
+ * @template TUrl - The url the route resolves to, combined with any parents. Intersected into the route.
79
+ * @template TMatches - The options of the route and its ancestors, indexed by depth. Name, meta, state,
80
+ * and context are all derived from this, including each route's views.
81
+ */
82
+ export type Route<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = TUrl & {
83
+ /**
84
+ * Unique identifier for the route, generated by router.
85
+ */
86
+ id: string;
87
+ /**
88
+ * The specific route properties that were matched in the current route, including any ancestors.
89
+ * Order of routes will be from greatest ancestor to narrowest matched.
90
+ */
91
+ matches: TMatches;
92
+ /**
93
+ * Identifier for the route as defined by user. Name must be unique among named routes. Name is used for routing and for matching.
94
+ */
95
+ name: RouteNameOf<TMatches>;
96
+ /**
97
+ * Represents additional metadata associated with a route, combined with any parents.
98
+ */
99
+ meta: RouteMetaOf<TMatches>;
100
+ /**
101
+ * Represents the schema of the route state, combined with any parents.
102
+ */
103
+ state: RouteStateOf<TMatches>;
104
+ /**
105
+ * Determines what assets are prefetched when router-link is rendered for this route. Overrides router level prefetch.
106
+ */
107
+ prefetch?: PrefetchConfig;
108
+ /**
109
+ * Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
110
+ */
111
+ context: RouteContextOf<TMatches>;
112
+ };
113
+ export type GenericRoute = Url & {
114
+ id: string;
115
+ name: string;
116
+ matches: CreatedRouteOptions[];
117
+ meta: RouteMeta;
118
+ state: Record<string, Param>;
119
+ prefetch?: PrefetchConfig;
120
+ };
121
+ export {};
@@ -0,0 +1,30 @@
1
+ import { ResolvedRoute } from './resolved';
2
+ import { CreatedRouteOptions, Route } from './route';
3
+ import { RouteContextToRejection, RouteContextToRoute } from './routeContext';
4
+ import { RouterPush } from './routerPush';
5
+ import { RouterReject } from './routerReject';
6
+ import { RouterReplace } from './routerReplace';
7
+ import { RouteUpdate } from './routeUpdate';
8
+ import { LoadersDataReturnType } from './routeLoaders';
9
+ import { ViewsPropsReturnType } from './routeViews';
10
+ /**
11
+ * Context provided to a callback attached to a route — an `addView` props getter, or a loader. Sourced
12
+ * from the route: rejections/routes from the route's context, and the parent from the route's `matches`.
13
+ */
14
+ export type RouteCallbackContext<TRoute extends Route> = {
15
+ reject: RouterReject<RouteContextToRejection<TRoute['context']>>;
16
+ push: RouterPush<[TRoute] | RouteContextToRoute<TRoute['context']>>;
17
+ replace: RouterReplace<[TRoute] | RouteContextToRoute<TRoute['context']>>;
18
+ update: RouteUpdate<ResolvedRoute<TRoute>>;
19
+ parent: RouteCallbackParent<TRoute>;
20
+ };
21
+ /**
22
+ * The parent context ({ name, props, data }) reconstructed from the second-to-last `matches` entry, which
23
+ * carries the parent's name, its views and its loaders.
24
+ */
25
+ type RouteCallbackParent<TRoute extends Route> = TRoute['matches'] extends [...CreatedRouteOptions[], infer TParent extends CreatedRouteOptions, CreatedRouteOptions] ? {
26
+ name: TParent['name'];
27
+ props: ViewsPropsReturnType<TParent['views']>;
28
+ data: LoadersDataReturnType<TParent['loaders']>;
29
+ } : undefined;
30
+ export {};
@@ -0,0 +1,30 @@
1
+ import { PrefetchConfig } from './prefetch';
2
+ import { AnyFunction } from './utilities';
3
+ /**
4
+ * A single loader: how to load its data, and how to prefetch it. Unlike a view, a loader always has a
5
+ * getter — a loader without one would have nothing to contribute.
6
+ *
7
+ * @template TData - What this loader's getter returns, carried so a route's data can be typed from it.
8
+ */
9
+ export type RouteLoader<TData = unknown> = {
10
+ load: AnyFunction<TData>;
11
+ prefetch?: PrefetchConfig;
12
+ };
13
+ /**
14
+ * The loaders for a single route, keyed by loader name (the unnamed loader under 'default').
15
+ */
16
+ export type RouteLoaders = Record<string, RouteLoader>;
17
+ /**
18
+ * The data a set of loaders resolves to. A lone unnamed loader is given directly rather than under a
19
+ * 'default' key, matching how the loader is written. Each loader's data is always a promise, since a
20
+ * loader never blocks rendering, even when the loader itself is synchronous.
21
+ */
22
+ export type LoadersDataReturnType<TLoaders> = keyof TLoaders extends never ? undefined : keyof TLoaders extends 'default' ? LoaderData<Extract<TLoaders, {
23
+ default: unknown;
24
+ }>['default']> : {
25
+ [K in keyof TLoaders]: LoaderData<TLoaders[K]>;
26
+ };
27
+ type LoaderData<TLoader> = TLoader extends {
28
+ load: AnyFunction<infer TData>;
29
+ } ? Promise<Awaited<TData>> : never;
30
+ export {};
@@ -1,4 +1,4 @@
1
- import { ResolvedRoute, ResolvedRouteUnion } from '../../types/resolved';
1
+ import { ResolvedRoute, ResolvedRouteUnion } from './resolved';
2
2
  import { Route } from './route';
3
3
  import { MaybePromise } from './utilities';
4
4
  export type SetRouteTitleContext = {
@@ -1,5 +1,5 @@
1
- import { ResolvedRoute } from '../../types/resolved';
2
- import { RouterPushOptions } from '../../types/routerPush';
1
+ import { ResolvedRoute } from './resolved';
2
+ import { RouterPushOptions } from './routerPush';
3
3
  export type RouteUpdate<TRoute extends ResolvedRoute = ResolvedRoute> = ResolvedRoute extends TRoute ? {
4
4
  (paramName: string, paramValue: unknown, options?: RouterPushOptions): Promise<void>;
5
5
  (params: Partial<TRoute['params']>, options?: RouterPushOptions): Promise<void>;
@@ -0,0 +1,44 @@
1
+ import { Component } from 'vue';
2
+ import { PrefetchConfig } from './prefetch';
3
+ import { AnyFunction } from './utilities';
4
+ /**
5
+ * A single view: what to render, how to get its props, and how to prefetch it. `component` is optional
6
+ * because a route can bind props to the nested RouterView it renders without declaring a component.
7
+ *
8
+ * @template TProps - What this view's props getter returns, carried so parent props can be typed from it.
9
+ */
10
+ export type RouteView<TProps = undefined> = {
11
+ component?: Component;
12
+ props?: AnyFunction<TProps>;
13
+ prefetch?: PrefetchConfig;
14
+ };
15
+ /**
16
+ * The views for a single route, keyed by view name (the unnamed view under 'default'). Indexed by depth in
17
+ * `route.views` — parallel to how `route.matches` indexes the matched options, which is where a route's id
18
+ * comes from at a given depth.
19
+ */
20
+ export type RouteViews = Record<string, RouteView<unknown>>;
21
+ /**
22
+ * The props a child sees for a parent's views. A lone unnamed view is given directly rather than under a
23
+ * 'default' key, matching how the props argument is written. Each view's props are always a promise,
24
+ * since the parent's props may not have been computed when the child's getter runs.
25
+ */
26
+ export type ViewsPropsReturnType<TViews> = keyof ViewsWithProps<TViews> extends never ? undefined : keyof ViewsWithProps<TViews> extends 'default' ? ParentViewProps<Extract<ViewsWithProps<TViews>, {
27
+ default: unknown;
28
+ }>['default']> : {
29
+ [K in keyof ViewsWithProps<TViews>]: ParentViewProps<ViewsWithProps<TViews>[K]>;
30
+ };
31
+ type ViewsWithProps<TViews> = {
32
+ [K in keyof TViews as HasViewProps<TViews[K]> extends true ? K : never]: TViews[K];
33
+ };
34
+ /**
35
+ * A view has props unless its getter is absent, which is carried as props resolving to undefined. Asked
36
+ * both ways because a getter that only ever throws resolves to never, which is assignable to undefined
37
+ * without being the absent case.
38
+ */
39
+ type HasViewProps<TView> = [ViewProps<TView>] extends [undefined] ? [undefined] extends [ViewProps<TView>] ? false : true : true;
40
+ type ViewProps<TView> = TView extends {
41
+ props?: AnyFunction<infer TProps>;
42
+ } ? TProps : undefined;
43
+ type ParentViewProps<TView> = Promise<Awaited<ViewProps<TView>>>;
44
+ export {};
@@ -0,0 +1,16 @@
1
+ import { RouteAddLoader } from './addLoader';
2
+ import { RouteAddView } from './addView';
3
+ import { InternalRouteHooks } from './hooks';
4
+ import { RouteRedirects } from './redirects';
5
+ import { CreatedRouteOptions, Route } from './route';
6
+ import { RouteSetTitle } from './routeTitle';
7
+ import { Url } from './url';
8
+ /**
9
+ * A route plus every chainable/available method: addView, addLoader, hooks, redirects, and title. The type
10
+ * level counterpart to `withRouteMethods`.
11
+ *
12
+ * Takes the url and matches rather than an assembled route so that adding a view or a loader can rebuild
13
+ * from them directly. Taking the route would mean re-deriving the url from it on every call, and that
14
+ * reference is what made chained calls nest one inside the last.
15
+ */
16
+ export type RouteWithMethods<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = Route<TUrl, TMatches> & RouteAddView<TUrl, TMatches> & RouteAddLoader<TUrl, TMatches> & InternalRouteHooks<Route<TUrl, TMatches>, Route<TUrl, TMatches>['context']> & RouteRedirects<Route<TUrl, TMatches>> & RouteSetTitle<Route<TUrl, TMatches>>;
@@ -1,5 +1,5 @@
1
- import { Route, Routes } from '../../types/route';
2
- import { RoutesName, RoutesMap } from '../../types/routesMap';
3
- import { UrlParamsWriting } from '../../types/url';
1
+ import { Route, Routes } from './route';
2
+ import { RoutesName, RoutesMap } from './routesMap';
3
+ import { UrlParamsWriting } from './url';
4
4
  export type RouteGetByKey<TRoutes extends Routes, TKey extends RoutesName<TRoutes>> = RoutesMap<TRoutes>[TKey];
5
5
  export type RouteParamsByKey<TRoutes extends Routes, TKey extends string> = RouteGetByKey<TRoutes, TKey> extends Route ? UrlParamsWriting<RouteGetByKey<TRoutes, TKey>> : Record<string, unknown>;
@@ -1,17 +1,17 @@
1
1
  import { App, InjectionKey, Ref } from 'vue';
2
- import { RouterHistoryMode } from '../../services/createRouterHistory';
3
- import { RouterRoute } from '../../types/routerRoute';
4
- import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook, AddRejectionHook } from '../../types/hooks';
5
- import { PrefetchConfig } from '../../types/prefetch';
6
- import { ResolvedRoute } from '../../types/resolved';
7
- import { Route, Routes } from '../../types/route';
8
- import { RouterPush } from '../../types/routerPush';
9
- import { RouterReplace } from '../../types/routerReplace';
10
- import { RouterResolve, RouterResolveOptions } from '../../types/routerResolve';
11
- import { RouterReject } from '../../types/routerReject';
12
- import { RouterPlugin } from '../../types/routerPlugin';
13
- import { RoutesName } from '../../types/routesMap';
14
- import { ExtractRejections, ExtractRejectionTypes, Rejections, BuiltInRejectionType } from '../../types/rejection';
2
+ import { RouterHistoryMode } from '../services/createRouterHistory';
3
+ import { RouterRoute } from './routerRoute';
4
+ import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook, AddRejectionHook } from './hooks';
5
+ import { PrefetchConfig } from './prefetch';
6
+ import { ResolvedRoute } from './resolved';
7
+ import { Route, Routes } from './route';
8
+ import { RouterPush } from './routerPush';
9
+ import { RouterReplace } from './routerReplace';
10
+ import { RouterResolve, RouterResolveOptions } from './routerResolve';
11
+ import { RouterReject } from './routerReject';
12
+ import { RouterPlugin } from './routerPlugin';
13
+ import { RoutesName } from './routesMap';
14
+ import { ExtractRejections, ExtractRejectionTypes, Rejections, BuiltInRejectionType } from './rejection';
15
15
  /**
16
16
  * Options to initialize a {@link Router} instance.
17
17
  */
@@ -1,8 +1,8 @@
1
- import { PrefetchConfig } from '../../types/prefetch';
2
- import { UrlString } from '../../types/urlString';
3
- import { ResolvedRoute } from '../../types/resolved';
4
- import { Router } from '../../types/router';
5
- import { RouterPushOptions } from '../../types/routerPush';
1
+ import { PrefetchConfig } from './prefetch';
2
+ import { UrlString } from './urlString';
3
+ import { ResolvedRoute } from './resolved';
4
+ import { Router } from './router';
5
+ import { RouterPushOptions } from './routerPush';
6
6
  export type ToCallback<TRouter extends Router> = (resolve: TRouter['resolve']) => ResolvedRoute | UrlString | undefined;
7
7
  export type RouterLinkProps<TRouter extends Router> = RouterPushOptions & {
8
8
  /**
@@ -1,12 +1,12 @@
1
1
  import { HookRemove } from './hooks';
2
2
  import { Routes } from './route';
3
3
  import { Rejections } from './rejection';
4
- import { Hooks } from '../../models/hooks';
4
+ import { Hooks } from '../models/hooks';
5
5
  import { ResolvedRoute } from './resolved';
6
6
  import { RouterReject } from './routerReject';
7
7
  import { RouterPush } from './routerPush';
8
8
  import { RouterReplace } from './routerReplace';
9
- import { CallbackContextAbort } from '../../services/createRouterCallbackContext';
9
+ import { CallbackContextAbort } from '../services/createRouterCallbackContext';
10
10
  import { MaybePromise } from './utilities';
11
11
  export type EmptyRouterPlugin = RouterPlugin<[], []>;
12
12
  export declare const IS_ROUTER_PLUGIN_SYMBOL: unique symbol;
@@ -49,7 +49,7 @@ type AddPluginAfterRouteHook<TRoutes extends Routes, TRejections extends Rejecti
49
49
  export type PluginErrorHookContext<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
50
50
  to: ResolvedRoute;
51
51
  from: ResolvedRoute | null;
52
- source: 'props' | 'hook' | 'component';
52
+ source: 'props' | 'loader' | 'hook' | 'component';
53
53
  reject: RouterReject<TRejections>;
54
54
  push: RouterPush<TRoutes>;
55
55
  replace: RouterReplace<TRoutes>;
@@ -1,11 +1,11 @@
1
- import { Routes } from '../../types/route';
2
- import { RoutesName } from '../../types/routesMap';
3
- import { RouteParamsByKey } from '../../types/routeWithParams';
4
- import { RouteStateByName } from '../../types/state';
5
- import { UrlString } from '../../types/urlString';
6
- import { AllPropertiesAreOptional } from '../../types/utilities';
7
- import { QuerySource } from '../../types/querySource';
8
- import { ResolvedRoute } from '../../types/resolved';
1
+ import { Routes } from './route';
2
+ import { RoutesName } from './routesMap';
3
+ import { RouteParamsByKey } from './routeWithParams';
4
+ import { RouteStateByName } from './state';
5
+ import { UrlString } from './urlString';
6
+ import { AllPropertiesAreOptional } from './utilities';
7
+ import { QuerySource } from './querySource';
8
+ import { ResolvedRoute } from './resolved';
9
9
  export type RouterPushOptions<TState = unknown> = {
10
10
  /**
11
11
  * The query string to add to the url.
@@ -1,2 +1,2 @@
1
- import { BuiltInRejectionType, Rejections, RejectionType } from '../../types/rejection';
1
+ import { BuiltInRejectionType, Rejections, RejectionType } from './rejection';
2
2
  export type RouterReject<TRejections extends Rejections | undefined> = <TSource extends (RejectionType<TRejections> | BuiltInRejectionType)>(type: TSource) => void;
@@ -1,11 +1,11 @@
1
- import { Routes } from '../../types/route';
2
- import { RoutesName } from '../../types/routesMap';
3
- import { RouteParamsByKey } from '../../types/routeWithParams';
4
- import { RouteStateByName } from '../../types/state';
5
- import { UrlString } from '../../types/urlString';
6
- import { AllPropertiesAreOptional } from '../../types/utilities';
7
- import { QuerySource } from '../../types/querySource';
8
- import { ResolvedRoute } from '../../types/resolved';
1
+ import { Routes } from './route';
2
+ import { RoutesName } from './routesMap';
3
+ import { RouteParamsByKey } from './routeWithParams';
4
+ import { RouteStateByName } from './state';
5
+ import { UrlString } from './urlString';
6
+ import { AllPropertiesAreOptional } from './utilities';
7
+ import { QuerySource } from './querySource';
8
+ import { ResolvedRoute } from './resolved';
9
9
  export type RouterReplaceOptions<TState = unknown> = {
10
10
  query?: QuerySource;
11
11
  hash?: string;
@@ -1,10 +1,10 @@
1
- import { Routes } from '../../types/route';
2
- import { RoutesName } from '../../types/routesMap';
3
- import { RouteParamsByKey } from '../../types/routeWithParams';
4
- import { AllPropertiesAreOptional } from '../../types/utilities';
5
- import { QuerySource } from '../../types/querySource';
6
- import { ResolvedRoute } from '../../types/resolved';
7
- import { RouteStateByName } from '../../types/state';
1
+ import { Routes } from './route';
2
+ import { RoutesName } from './routesMap';
3
+ import { RouteParamsByKey } from './routeWithParams';
4
+ import { AllPropertiesAreOptional } from './utilities';
5
+ import { QuerySource } from './querySource';
6
+ import { ResolvedRoute } from './resolved';
7
+ import { RouteStateByName } from './state';
8
8
  export type RouterResolveOptions<TState = unknown> = {
9
9
  query?: QuerySource;
10
10
  hash?: string;
@@ -1,6 +1,7 @@
1
- import { RouteUpdate } from '../../types/routeUpdate';
2
- import { ResolvedRoute } from '../../types/resolved';
3
- import { QuerySource } from '../../types/querySource';
1
+ import { RouteUpdate } from './routeUpdate';
2
+ import { ResolvedRoute } from './resolved';
3
+ import { RouteDataOf } from './route';
4
+ import { QuerySource } from './querySource';
4
5
  export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
5
6
  /**
6
7
  * Unique identifier for the route, generated by router.
@@ -35,6 +36,11 @@ export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
35
36
  * Title of the route.
36
37
  */
37
38
  readonly title: TRoute['title'];
39
+ /**
40
+ * What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed
41
+ * exposes that loader's data here directly.
42
+ */
43
+ readonly data: RouteDataOf<TRoute['matches']>;
38
44
  params: TRoute['params'];
39
45
  state: TRoute['state'];
40
46
  get query(): URLSearchParams;
@@ -1,5 +1,5 @@
1
- import { Route, Routes } from '../../types/route';
2
- import { StringHasValue } from '../../utilities/guards';
1
+ import { Route, Routes } from './route';
2
+ import { StringHasValue } from '../utilities/guards';
3
3
  type IsRouteUnnamed<T extends Route> = StringHasValue<T['name']> extends true ? false : true;
4
4
  type AsNamedRoute<T extends Route> = IsRouteUnnamed<T> extends true ? never : T;
5
5
  export type RoutesMap<TRoutes extends Routes = []> = {
@@ -1,9 +1,9 @@
1
- import { ExtractParamName, ExtractParamType } from '../../types/params';
2
- import { Param } from '../../types/paramTypes';
3
- import { Routes } from '../../types/route';
4
- import { RouteGetByKey } from '../../types/routeWithParams';
5
- import { MakeOptional } from '../../utilities/makeOptional';
6
- import { Identity } from '../../types/utilities';
1
+ import { ExtractParamName, ExtractParamType } from './params';
2
+ import { Param } from './paramTypes';
3
+ import { Routes } from './route';
4
+ import { RouteGetByKey } from './routeWithParams';
5
+ import { MakeOptional } from '../utilities/makeOptional';
6
+ import { Identity } from './utilities';
7
7
  export type ToState<TState extends Record<string, Param> | undefined> = TState extends undefined ? Record<string, Param> : unknown extends TState ? {} : TState;
8
8
  export type ExtractRouteStateParamsAsOptional<TParams extends Record<string, Param>> = {
9
9
  [K in keyof TParams]: ExtractParamType<TParams[K]> | undefined;
@@ -1,9 +1,9 @@
1
- import { OptionalUrlParam, UrlQueryPart, ToUrlQueryPart, RequiredUrlParam, ToUrlPart, UrlParams, UrlPart } from '../../services/withParams';
2
- import { ExtractParamType } from '../../types/params';
3
- import { AllPropertiesAreOptional, Identity } from '../../types/utilities';
4
- import { UrlString } from '../../types/urlString';
5
- import { ParamGetSet } from '../../types/paramTypes';
6
- import { MakeOptional } from '../../utilities/makeOptional';
1
+ import { OptionalUrlParam, UrlQueryPart, ToUrlQueryPart, RequiredUrlParam, ToUrlPart, UrlParams, UrlPart } from '../services/withParams';
2
+ import { ExtractParamType } from './params';
3
+ import { AllPropertiesAreOptional, Identity } from './utilities';
4
+ import { UrlString } from './urlString';
5
+ import { ParamGetSet } from './paramTypes';
6
+ import { MakeOptional } from '../utilities/makeOptional';
7
7
  export declare const IS_URL_SYMBOL: unique symbol;
8
8
  export type UrlInternal = {
9
9
  [IS_URL_SYMBOL]: true;
@@ -1,9 +1,9 @@
1
1
  import { ComputedRef, Ref } from 'vue';
2
- import { PrefetchConfig } from '../../types/prefetch';
3
- import { ResolvedRoute } from '../../types/resolved';
4
- import { RouterPushOptions } from '../../types/routerPush';
5
- import { RouterReplaceOptions } from '../../types/routerReplace';
6
- import { UrlString } from '../../types/urlString';
2
+ import { PrefetchConfig } from './prefetch';
3
+ import { ResolvedRoute } from './resolved';
4
+ import { RouterPushOptions } from './routerPush';
5
+ import { RouterReplaceOptions } from './routerReplace';
6
+ import { UrlString } from './urlString';
7
7
  export type UseLink = {
8
8
  /**
9
9
  * A template ref to bind to the dom for automatic prefetching
@@ -4,6 +4,7 @@ export type Identity<T> = T extends object ? {} & {
4
4
  type IsEmptyObject<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false;
5
5
  export type LastInArray<T, TFallback = never> = T extends [...any[], infer Last] ? Last : TFallback;
6
6
  export type MaybePromise<T> = T | Promise<T>;
7
+ export type AnyFunction<TReturn = any> = (...args: any[]) => TReturn;
7
8
  type OnlyRequiredProperties<T> = {
8
9
  [K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
9
10
  };
@@ -1,2 +1,2 @@
1
- import { Routes } from '../../types/route';
1
+ import { Routes } from '../types/route';
2
2
  export declare function checkDuplicateNames(routes: Routes): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};