@tanstack/vue-router 0.0.1 → 1.140.1

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 (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -45
  3. package/dist/esm/Asset.d.ts +2 -0
  4. package/dist/esm/Asset.js +33 -0
  5. package/dist/esm/Asset.js.map +1 -0
  6. package/dist/esm/CatchBoundary.d.ts +19 -0
  7. package/dist/esm/CatchBoundary.js +135 -0
  8. package/dist/esm/CatchBoundary.js.map +1 -0
  9. package/dist/esm/ClientOnly.d.ts +67 -0
  10. package/dist/esm/HeadContent.d.ts +10 -0
  11. package/dist/esm/HeadContent.js +116 -0
  12. package/dist/esm/HeadContent.js.map +1 -0
  13. package/dist/esm/Match.d.ts +25 -0
  14. package/dist/esm/Match.js +262 -0
  15. package/dist/esm/Match.js.map +1 -0
  16. package/dist/esm/Matches.d.ts +39 -0
  17. package/dist/esm/Matches.js +186 -0
  18. package/dist/esm/Matches.js.map +1 -0
  19. package/dist/esm/RouterProvider.d.ts +33 -0
  20. package/dist/esm/RouterProvider.js +65 -0
  21. package/dist/esm/RouterProvider.js.map +1 -0
  22. package/dist/esm/SafeFragment.d.ts +4 -0
  23. package/dist/esm/ScriptOnce.d.ts +5 -0
  24. package/dist/esm/ScriptOnce.js +21 -0
  25. package/dist/esm/ScriptOnce.js.map +1 -0
  26. package/dist/esm/Scripts.d.ts +1 -0
  27. package/dist/esm/Scripts.js +46 -0
  28. package/dist/esm/Scripts.js.map +1 -0
  29. package/dist/esm/ScrollRestoration.d.ts +14 -0
  30. package/dist/esm/ScrollRestoration.js +36 -0
  31. package/dist/esm/ScrollRestoration.js.map +1 -0
  32. package/dist/esm/Transitioner.d.ts +2 -0
  33. package/dist/esm/Transitioner.js +154 -0
  34. package/dist/esm/Transitioner.js.map +1 -0
  35. package/dist/esm/awaited.d.ts +12 -0
  36. package/dist/esm/awaited.js +40 -0
  37. package/dist/esm/awaited.js.map +1 -0
  38. package/dist/esm/fileRoute.d.ts +54 -0
  39. package/dist/esm/fileRoute.js +103 -0
  40. package/dist/esm/fileRoute.js.map +1 -0
  41. package/dist/esm/history.d.ts +8 -0
  42. package/dist/esm/index.d.ts +51 -0
  43. package/dist/esm/index.js +138 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/lazyRouteComponent.d.ts +8 -0
  46. package/dist/esm/lazyRouteComponent.js +106 -0
  47. package/dist/esm/lazyRouteComponent.js.map +1 -0
  48. package/dist/esm/link.d.ts +61 -0
  49. package/dist/esm/link.js +376 -0
  50. package/dist/esm/link.js.map +1 -0
  51. package/dist/esm/matchContext.d.ts +20 -0
  52. package/dist/esm/matchContext.js +16 -0
  53. package/dist/esm/matchContext.js.map +1 -0
  54. package/dist/esm/not-found.d.ts +12 -0
  55. package/dist/esm/not-found.js +45 -0
  56. package/dist/esm/not-found.js.map +1 -0
  57. package/dist/esm/renderRouteNotFound.d.ts +11 -0
  58. package/dist/esm/renderRouteNotFound.js +19 -0
  59. package/dist/esm/renderRouteNotFound.js.map +1 -0
  60. package/dist/esm/route.d.ts +96 -0
  61. package/dist/esm/route.js +176 -0
  62. package/dist/esm/route.js.map +1 -0
  63. package/dist/esm/router.d.ts +69 -0
  64. package/dist/esm/router.js +14 -0
  65. package/dist/esm/router.js.map +1 -0
  66. package/dist/esm/routerContext.d.ts +21 -0
  67. package/dist/esm/routerContext.js +21 -0
  68. package/dist/esm/routerContext.js.map +1 -0
  69. package/dist/esm/scroll-restoration.d.ts +1 -0
  70. package/dist/esm/scroll-restoration.js +21 -0
  71. package/dist/esm/scroll-restoration.js.map +1 -0
  72. package/dist/esm/typePrimitives.d.ts +10 -0
  73. package/dist/esm/useBlocker.d.ts +66 -0
  74. package/dist/esm/useBlocker.js +295 -0
  75. package/dist/esm/useBlocker.js.map +1 -0
  76. package/dist/esm/useCanGoBack.d.ts +1 -0
  77. package/dist/esm/useCanGoBack.js +8 -0
  78. package/dist/esm/useCanGoBack.js.map +1 -0
  79. package/dist/esm/useLoaderData.d.ts +8 -0
  80. package/dist/esm/useLoaderData.js +14 -0
  81. package/dist/esm/useLoaderData.js.map +1 -0
  82. package/dist/esm/useLoaderDeps.d.ts +7 -0
  83. package/dist/esm/useLoaderDeps.js +17 -0
  84. package/dist/esm/useLoaderDeps.js.map +1 -0
  85. package/dist/esm/useLocation.d.ts +7 -0
  86. package/dist/esm/useLocation.js +10 -0
  87. package/dist/esm/useLocation.js.map +1 -0
  88. package/dist/esm/useMatch.d.ts +10 -0
  89. package/dist/esm/useMatch.js +39 -0
  90. package/dist/esm/useMatch.js.map +1 -0
  91. package/dist/esm/useNavigate.d.ts +5 -0
  92. package/dist/esm/useNavigate.js +29 -0
  93. package/dist/esm/useNavigate.js.map +1 -0
  94. package/dist/esm/useParams.d.ts +9 -0
  95. package/dist/esm/useParams.js +15 -0
  96. package/dist/esm/useParams.js.map +1 -0
  97. package/dist/esm/useRouteContext.d.ts +4 -0
  98. package/dist/esm/useRouteContext.js +11 -0
  99. package/dist/esm/useRouteContext.js.map +1 -0
  100. package/dist/esm/useRouter.d.ts +4 -0
  101. package/dist/esm/useRouter.js +12 -0
  102. package/dist/esm/useRouter.js.map +1 -0
  103. package/dist/esm/useRouterState.d.ts +8 -0
  104. package/dist/esm/useRouterState.js +20 -0
  105. package/dist/esm/useRouterState.js.map +1 -0
  106. package/dist/esm/useSearch.d.ts +9 -0
  107. package/dist/esm/useSearch.js +15 -0
  108. package/dist/esm/useSearch.js.map +1 -0
  109. package/dist/esm/utils.d.ts +40 -0
  110. package/dist/esm/utils.js +44 -0
  111. package/dist/esm/utils.js.map +1 -0
  112. package/dist/source/Asset.d.ts +2 -0
  113. package/dist/source/Asset.jsx +22 -0
  114. package/dist/source/Asset.jsx.map +1 -0
  115. package/dist/source/CatchBoundary.d.ts +19 -0
  116. package/dist/source/CatchBoundary.jsx +134 -0
  117. package/dist/source/CatchBoundary.jsx.map +1 -0
  118. package/dist/source/ClientOnly.d.ts +67 -0
  119. package/dist/source/ClientOnly.jsx +63 -0
  120. package/dist/source/ClientOnly.jsx.map +1 -0
  121. package/dist/source/HeadContent.d.ts +10 -0
  122. package/dist/source/HeadContent.jsx +133 -0
  123. package/dist/source/HeadContent.jsx.map +1 -0
  124. package/dist/source/Match.d.ts +25 -0
  125. package/dist/source/Match.jsx +316 -0
  126. package/dist/source/Match.jsx.map +1 -0
  127. package/dist/source/Matches.d.ts +39 -0
  128. package/dist/source/Matches.jsx +191 -0
  129. package/dist/source/Matches.jsx.map +1 -0
  130. package/dist/source/RouterProvider.d.ts +33 -0
  131. package/dist/source/RouterProvider.jsx +63 -0
  132. package/dist/source/RouterProvider.jsx.map +1 -0
  133. package/dist/source/SafeFragment.d.ts +4 -0
  134. package/dist/source/SafeFragment.jsx +10 -0
  135. package/dist/source/SafeFragment.jsx.map +1 -0
  136. package/dist/source/ScriptOnce.d.ts +5 -0
  137. package/dist/source/ScriptOnce.jsx +17 -0
  138. package/dist/source/ScriptOnce.jsx.map +1 -0
  139. package/dist/source/Scripts.d.ts +1 -0
  140. package/dist/source/Scripts.jsx +49 -0
  141. package/dist/source/Scripts.jsx.map +1 -0
  142. package/dist/source/ScrollRestoration.d.ts +14 -0
  143. package/dist/source/ScrollRestoration.jsx +37 -0
  144. package/dist/source/ScrollRestoration.jsx.map +1 -0
  145. package/dist/source/Transitioner.d.ts +2 -0
  146. package/dist/source/Transitioner.jsx +181 -0
  147. package/dist/source/Transitioner.jsx.map +1 -0
  148. package/dist/source/awaited.d.ts +12 -0
  149. package/dist/source/awaited.jsx +38 -0
  150. package/dist/source/awaited.jsx.map +1 -0
  151. package/dist/source/fileRoute.d.ts +54 -0
  152. package/dist/source/fileRoute.js +98 -0
  153. package/dist/source/fileRoute.js.map +1 -0
  154. package/dist/source/history.d.ts +8 -0
  155. package/dist/source/history.js +2 -0
  156. package/dist/source/history.js.map +1 -0
  157. package/dist/source/index.d.ts +51 -0
  158. package/dist/source/index.jsx +40 -0
  159. package/dist/source/index.jsx.map +1 -0
  160. package/dist/source/lazyRouteComponent.d.ts +8 -0
  161. package/dist/source/lazyRouteComponent.jsx +135 -0
  162. package/dist/source/lazyRouteComponent.jsx.map +1 -0
  163. package/dist/source/link.d.ts +61 -0
  164. package/dist/source/link.jsx +495 -0
  165. package/dist/source/link.jsx.map +1 -0
  166. package/dist/source/matchContext.d.ts +20 -0
  167. package/dist/source/matchContext.jsx +32 -0
  168. package/dist/source/matchContext.jsx.map +1 -0
  169. package/dist/source/not-found.d.ts +12 -0
  170. package/dist/source/not-found.jsx +48 -0
  171. package/dist/source/not-found.jsx.map +1 -0
  172. package/dist/source/renderRouteNotFound.d.ts +11 -0
  173. package/dist/source/renderRouteNotFound.jsx +24 -0
  174. package/dist/source/renderRouteNotFound.jsx.map +1 -0
  175. package/dist/source/route.d.ts +97 -0
  176. package/dist/source/route.js +167 -0
  177. package/dist/source/route.js.map +1 -0
  178. package/dist/source/router.d.ts +70 -0
  179. package/dist/source/router.js +10 -0
  180. package/dist/source/router.js.map +1 -0
  181. package/dist/source/routerContext.d.ts +21 -0
  182. package/dist/source/routerContext.jsx +37 -0
  183. package/dist/source/routerContext.jsx.map +1 -0
  184. package/dist/source/scroll-restoration.d.ts +1 -0
  185. package/dist/source/scroll-restoration.jsx +16 -0
  186. package/dist/source/scroll-restoration.jsx.map +1 -0
  187. package/dist/source/typePrimitives.d.ts +10 -0
  188. package/dist/source/typePrimitives.js +2 -0
  189. package/dist/source/typePrimitives.js.map +1 -0
  190. package/dist/source/useBlocker.d.ts +66 -0
  191. package/dist/source/useBlocker.jsx +308 -0
  192. package/dist/source/useBlocker.jsx.map +1 -0
  193. package/dist/source/useCanGoBack.d.ts +1 -0
  194. package/dist/source/useCanGoBack.js +5 -0
  195. package/dist/source/useCanGoBack.js.map +1 -0
  196. package/dist/source/useLoaderData.d.ts +8 -0
  197. package/dist/source/useLoaderData.jsx +11 -0
  198. package/dist/source/useLoaderData.jsx.map +1 -0
  199. package/dist/source/useLoaderDeps.d.ts +7 -0
  200. package/dist/source/useLoaderDeps.jsx +11 -0
  201. package/dist/source/useLoaderDeps.jsx.map +1 -0
  202. package/dist/source/useLocation.d.ts +7 -0
  203. package/dist/source/useLocation.jsx +7 -0
  204. package/dist/source/useLocation.jsx.map +1 -0
  205. package/dist/source/useMatch.d.ts +10 -0
  206. package/dist/source/useMatch.jsx +46 -0
  207. package/dist/source/useMatch.jsx.map +1 -0
  208. package/dist/source/useNavigate.d.ts +5 -0
  209. package/dist/source/useNavigate.jsx +18 -0
  210. package/dist/source/useNavigate.jsx.map +1 -0
  211. package/dist/source/useParams.d.ts +9 -0
  212. package/dist/source/useParams.jsx +12 -0
  213. package/dist/source/useParams.jsx.map +1 -0
  214. package/dist/source/useRouteContext.d.ts +4 -0
  215. package/dist/source/useRouteContext.js +8 -0
  216. package/dist/source/useRouteContext.js.map +1 -0
  217. package/dist/source/useRouter.d.ts +4 -0
  218. package/dist/source/useRouter.jsx +9 -0
  219. package/dist/source/useRouter.jsx.map +1 -0
  220. package/dist/source/useRouterState.d.ts +8 -0
  221. package/dist/source/useRouterState.jsx +19 -0
  222. package/dist/source/useRouterState.jsx.map +1 -0
  223. package/dist/source/useSearch.d.ts +9 -0
  224. package/dist/source/useSearch.jsx +12 -0
  225. package/dist/source/useSearch.jsx.map +1 -0
  226. package/dist/source/utils.d.ts +40 -0
  227. package/dist/source/utils.js +78 -0
  228. package/dist/source/utils.js.map +1 -0
  229. package/package.json +77 -7
  230. package/src/Asset.tsx +23 -0
  231. package/src/CatchBoundary.tsx +186 -0
  232. package/src/ClientOnly.tsx +75 -0
  233. package/src/HeadContent.tsx +159 -0
  234. package/src/Match.tsx +415 -0
  235. package/src/Matches.tsx +349 -0
  236. package/src/RouterProvider.tsx +117 -0
  237. package/src/SafeFragment.tsx +10 -0
  238. package/src/ScriptOnce.tsx +30 -0
  239. package/src/Scripts.tsx +65 -0
  240. package/src/ScrollRestoration.tsx +69 -0
  241. package/src/Transitioner.tsx +213 -0
  242. package/src/awaited.tsx +54 -0
  243. package/src/fileRoute.ts +271 -0
  244. package/src/history.ts +9 -0
  245. package/src/index.tsx +346 -0
  246. package/src/lazyRouteComponent.tsx +173 -0
  247. package/src/link.tsx +765 -0
  248. package/src/matchContext.tsx +41 -0
  249. package/src/not-found.tsx +55 -0
  250. package/src/renderRouteNotFound.tsx +35 -0
  251. package/src/route.ts +658 -0
  252. package/src/router.ts +103 -0
  253. package/src/routerContext.tsx +53 -0
  254. package/src/scroll-restoration.tsx +29 -0
  255. package/src/typePrimitives.ts +74 -0
  256. package/src/useBlocker.tsx +501 -0
  257. package/src/useCanGoBack.ts +5 -0
  258. package/src/useLoaderData.tsx +50 -0
  259. package/src/useLoaderDeps.tsx +46 -0
  260. package/src/useLocation.tsx +30 -0
  261. package/src/useMatch.tsx +127 -0
  262. package/src/useNavigate.tsx +40 -0
  263. package/src/useParams.tsx +71 -0
  264. package/src/useRouteContext.ts +31 -0
  265. package/src/useRouter.tsx +15 -0
  266. package/src/useRouterState.tsx +43 -0
  267. package/src/useSearch.tsx +71 -0
  268. package/src/utils.ts +111 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/**\n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["opts"],"mappings":";;;;;;;;;AAqCO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEF,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AAxEE,SAAK,SAAS,OAAO;AAAA,EACvB;AAwEF;AAOO,SAAS,gBAId,OAea;AACb;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAIF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAO,SAAS;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,QAAQ,CAAC,MAAYA,OAAM,SAASA,MAAK,OAAO,EAAE,OAAO,IAAI,EAAE;AAAA,MAAA,CAChE;AAAA,IACH;AAEA,SAAA,YAA0C,CAACA,UAAS;AAClD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAClD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAA;AACf,aAAO,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AA1CE,SAAK,UAAU;AAAA,EACjB;AA0CF;AAEO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AACO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
@@ -0,0 +1,8 @@
1
+ declare module '@tanstack/history' {
2
+ interface HistoryState {
3
+ __tempLocation?: HistoryLocation;
4
+ __tempKey?: string;
5
+ __hashScrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
6
+ }
7
+ }
8
+ export {};
@@ -0,0 +1,51 @@
1
+ export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, interpolatePath, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
2
+ export type { AnyRoute, DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, Register, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, FileRoutesByPath, RouteById, RootRouteOptions, CreateFileRoute, SerializationAdapter, AnySerializationAdapter, } from '@tanstack/router-core';
3
+ export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
4
+ export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
5
+ export { useAwaited, Await } from './awaited.js';
6
+ export type { AwaitOptions } from './awaited.js';
7
+ export { CatchBoundary, ErrorComponent } from './CatchBoundary.js';
8
+ export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.js';
9
+ export * from './history.js';
10
+ export { lazyRouteComponent } from './lazyRouteComponent.js';
11
+ export { useLinkProps, createLink, Link, linkOptions } from './link.js';
12
+ export type { InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, FileRouteTypes, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, ResolveAllParamsFromParent, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, RouteIds, NavigateFn, BuildLocationFn, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, ResolveFullPath, AnyRouteWithContext, AnyRouterWithContext, CommitLocationOptions, MatchLocation, UseNavigateResult, AnyRedirect, Redirect, RedirectOptions, ResolvedRedirect, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadContextOptions, ContextOptions, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, LazyRouteOptions, AnyRouter, RegisteredRouter, RouterContextOptions, ControllablePromise, InjectedHtmlEntry, RouterOptions, RouterState, ListenerFn, BuildNextOptions, RouterConstructorOptions, RouterEvents, RouterEvent, RouterListener, RouteConstraints, RouteMask, MatchRouteOptions, CreateLazyFileRoute, } from '@tanstack/router-core';
13
+ export type { UseLinkPropsOptions, ActiveLinkOptions, LinkProps, LinkComponent, LinkComponentProps, CreateLinkProps, } from './link.js';
14
+ export { Matches, useMatchRoute, MatchRoute, useMatches, useParentMatches, useChildMatches, } from './Matches.js';
15
+ export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches.js';
16
+ export { matchContext } from './matchContext.js';
17
+ export { Match, Outlet } from './Match.js';
18
+ export { useMatch } from './useMatch.js';
19
+ export { useLoaderDeps } from './useLoaderDeps.js';
20
+ export { useLoaderData } from './useLoaderData.js';
21
+ export { redirect, isRedirect, createRouterConfig } from '@tanstack/router-core';
22
+ export { RouteApi, getRouteApi, Route, createRoute, RootRoute, rootRouteWithContext, createRootRoute, createRootRouteWithContext, createRouteMask, NotFoundRoute, } from './route.js';
23
+ export type { AnyRootRoute, VueNode, SyncRouteComponent, AsyncRouteComponent, RouteComponent, ErrorRouteComponent, NotFoundRouteComponent, } from './route.js';
24
+ export { createRouter, Router } from './router.js';
25
+ export { componentTypes, lazyFn, SearchParamError, PathParamError, getInitialRouterState, } from '@tanstack/router-core';
26
+ export { RouterProvider, RouterContextProvider } from './RouterProvider.js';
27
+ export type { RouterProps } from './RouterProvider.js';
28
+ export { useElementScrollRestoration, ScrollRestoration, } from './ScrollRestoration.js';
29
+ export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker.js';
30
+ export { useBlocker, Block } from './useBlocker.js';
31
+ export { useNavigate, Navigate } from './useNavigate.js';
32
+ export { useParams } from './useParams.js';
33
+ export { useSearch } from './useSearch.js';
34
+ export { getRouterContext, } from './routerContext.js';
35
+ export { useRouteContext } from './useRouteContext.js';
36
+ export { useRouter } from './useRouter.js';
37
+ export { useRouterState } from './useRouterState.js';
38
+ export { useLocation } from './useLocation.js';
39
+ export { useCanGoBack } from './useCanGoBack.js';
40
+ export { useLayoutEffect } from './utils.js';
41
+ export { CatchNotFound, DefaultGlobalNotFound } from './not-found.js';
42
+ export { notFound, isNotFound } from '@tanstack/router-core';
43
+ export type { NotFoundError } from '@tanstack/router-core';
44
+ export type { ValidateLinkOptions, ValidateUseSearchOptions, ValidateUseParamsOptions, ValidateLinkOptionsArray, } from './typePrimitives.js';
45
+ export type { ValidateFromPath, ValidateToPath, ValidateSearch, ValidateParams, InferFrom, InferTo, InferMaskTo, InferMaskFrom, ValidateNavigateOptions, ValidateNavigateOptionsArray, ValidateRedirectOptions, ValidateRedirectOptionsArray, ValidateId, InferStrict, InferShouldThrow, InferSelected, ValidateUseSearchResult, ValidateUseParamsResult, } from '@tanstack/router-core';
46
+ export { ScriptOnce } from './ScriptOnce.js';
47
+ export { Asset } from './Asset.js';
48
+ export { HeadContent } from './HeadContent.js';
49
+ export { Scripts } from './Scripts.js';
50
+ export { composeRewrites } from '@tanstack/router-core';
51
+ export type { LocationRewrite, LocationRewriteFunction, } from '@tanstack/router-core';
@@ -0,0 +1,138 @@
1
+ import { PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, composeRewrites, createControlledPromise, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, notFound, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
2
+ import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
3
+ import { Await, useAwaited } from "./awaited.js";
4
+ import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
5
+ import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute } from "./fileRoute.js";
6
+ import { lazyRouteComponent } from "./lazyRouteComponent.js";
7
+ import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
8
+ import { MatchRoute, Matches, useChildMatches, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
9
+ import { matchContext } from "./matchContext.js";
10
+ import { Match, Outlet } from "./Match.js";
11
+ import { useMatch } from "./useMatch.js";
12
+ import { useLoaderDeps } from "./useLoaderDeps.js";
13
+ import { useLoaderData } from "./useLoaderData.js";
14
+ import { NotFoundRoute, RootRoute, Route, RouteApi, createRootRoute, createRootRouteWithContext, createRoute, createRouteMask, getRouteApi, rootRouteWithContext } from "./route.js";
15
+ import { Router, createRouter } from "./router.js";
16
+ import { RouterContextProvider, RouterProvider } from "./RouterProvider.js";
17
+ import { ScrollRestoration, useElementScrollRestoration } from "./ScrollRestoration.js";
18
+ import { Block, useBlocker } from "./useBlocker.js";
19
+ import { Navigate, useNavigate } from "./useNavigate.js";
20
+ import { useParams } from "./useParams.js";
21
+ import { useSearch } from "./useSearch.js";
22
+ import { getRouterContext } from "./routerContext.js";
23
+ import { useRouteContext } from "./useRouteContext.js";
24
+ import { useRouter } from "./useRouter.js";
25
+ import { useRouterState } from "./useRouterState.js";
26
+ import { useLocation } from "./useLocation.js";
27
+ import { useCanGoBack } from "./useCanGoBack.js";
28
+ import { useLayoutEffect } from "./utils.js";
29
+ import { CatchNotFound, DefaultGlobalNotFound } from "./not-found.js";
30
+ import { ScriptOnce } from "./ScriptOnce.js";
31
+ import { Asset } from "./Asset.js";
32
+ import { HeadContent } from "./HeadContent.js";
33
+ import { Scripts } from "./Scripts.js";
34
+ export {
35
+ Asset,
36
+ Await,
37
+ Block,
38
+ CatchBoundary,
39
+ CatchNotFound,
40
+ DefaultGlobalNotFound,
41
+ ErrorComponent,
42
+ FileRoute,
43
+ FileRouteLoader,
44
+ HeadContent,
45
+ LazyRoute,
46
+ Link,
47
+ Match,
48
+ MatchRoute,
49
+ Matches,
50
+ Navigate,
51
+ NotFoundRoute,
52
+ Outlet,
53
+ PathParamError,
54
+ RootRoute,
55
+ Route,
56
+ RouteApi,
57
+ Router,
58
+ RouterContextProvider,
59
+ RouterProvider,
60
+ ScriptOnce,
61
+ Scripts,
62
+ ScrollRestoration,
63
+ SearchParamError,
64
+ TSR_DEFERRED_PROMISE,
65
+ cleanPath,
66
+ componentTypes,
67
+ composeRewrites,
68
+ createBrowserHistory,
69
+ createControlledPromise,
70
+ createFileRoute,
71
+ createHashHistory,
72
+ createHistory,
73
+ createLazyFileRoute,
74
+ createLazyRoute,
75
+ createLink,
76
+ createMemoryHistory,
77
+ createRootRoute,
78
+ createRootRouteWithContext,
79
+ createRoute,
80
+ createRouteMask,
81
+ createRouter,
82
+ createRouterConfig,
83
+ createSerializationAdapter,
84
+ deepEqual,
85
+ defaultParseSearch,
86
+ defaultSerializeError,
87
+ defaultStringifySearch,
88
+ defer,
89
+ functionalUpdate,
90
+ getInitialRouterState,
91
+ getRouteApi,
92
+ getRouterContext,
93
+ interpolatePath,
94
+ isMatch,
95
+ isNotFound,
96
+ isPlainArray,
97
+ isPlainObject,
98
+ isRedirect,
99
+ joinPaths,
100
+ lazyFn,
101
+ lazyRouteComponent,
102
+ linkOptions,
103
+ matchContext,
104
+ notFound,
105
+ parseSearchWith,
106
+ redirect,
107
+ replaceEqualDeep,
108
+ resolvePath,
109
+ retainSearchParams,
110
+ rootRouteId,
111
+ rootRouteWithContext,
112
+ stringifySearchWith,
113
+ stripSearchParams,
114
+ trimPath,
115
+ trimPathLeft,
116
+ trimPathRight,
117
+ useAwaited,
118
+ useBlocker,
119
+ useCanGoBack,
120
+ useChildMatches,
121
+ useElementScrollRestoration,
122
+ useLayoutEffect,
123
+ useLinkProps,
124
+ useLoaderData,
125
+ useLoaderDeps,
126
+ useLocation,
127
+ useMatch,
128
+ useMatchRoute,
129
+ useMatches,
130
+ useNavigate,
131
+ useParams,
132
+ useParentMatches,
133
+ useRouteContext,
134
+ useRouter,
135
+ useRouterState,
136
+ useSearch
137
+ };
138
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import { AsyncRouteComponent } from './route.js';
2
+ import * as Vue from 'vue';
3
+ export declare function ClientOnly(props: {
4
+ children?: any;
5
+ fallback?: Vue.VNode;
6
+ }): () => any;
7
+ export declare function useHydrated(): Vue.Ref<boolean, boolean> | Vue.ComputedRef<boolean>;
8
+ export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey, ssr?: () => boolean): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
@@ -0,0 +1,106 @@
1
+ import * as Vue from "vue";
2
+ import { Outlet } from "./Match.js";
3
+ function isModuleNotFoundError(error) {
4
+ if (typeof error?.message !== "string") return false;
5
+ return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
6
+ }
7
+ function ClientOnly(props) {
8
+ const hydrated = useHydrated();
9
+ return () => {
10
+ if (hydrated.value) {
11
+ return props.children;
12
+ }
13
+ return props.fallback || null;
14
+ };
15
+ }
16
+ function useHydrated() {
17
+ const hydrated = Vue.ref(false);
18
+ if (typeof window === "undefined") {
19
+ return Vue.computed(() => false);
20
+ }
21
+ Vue.onMounted(() => {
22
+ hydrated.value = true;
23
+ });
24
+ return hydrated;
25
+ }
26
+ function lazyRouteComponent(importer, exportName, ssr) {
27
+ let loadPromise;
28
+ let comp = null;
29
+ let error = null;
30
+ let attemptedReload = false;
31
+ const load = () => {
32
+ if (typeof document === "undefined" && ssr?.() === false) {
33
+ comp = () => null;
34
+ return Promise.resolve(comp);
35
+ }
36
+ if (!loadPromise) {
37
+ loadPromise = importer().then((res) => {
38
+ loadPromise = void 0;
39
+ comp = res[exportName ?? "default"];
40
+ return comp;
41
+ }).catch((err) => {
42
+ error = err;
43
+ loadPromise = void 0;
44
+ if (isModuleNotFoundError(error)) {
45
+ return null;
46
+ }
47
+ throw err;
48
+ });
49
+ }
50
+ return loadPromise;
51
+ };
52
+ const lazyComp = Vue.defineComponent({
53
+ name: "LazyRouteComponent",
54
+ setup(props) {
55
+ const component = Vue.ref(comp);
56
+ const errorState = Vue.ref(error);
57
+ const loading = Vue.ref(!component.value && !errorState.value);
58
+ Vue.onMounted(() => {
59
+ if (!component.value && !errorState.value) {
60
+ loading.value = true;
61
+ load().then((result) => {
62
+ component.value = result;
63
+ loading.value = false;
64
+ }).catch((err) => {
65
+ errorState.value = err;
66
+ loading.value = false;
67
+ });
68
+ }
69
+ });
70
+ if (errorState.value && isModuleNotFoundError(errorState.value) && !attemptedReload) {
71
+ if (typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
72
+ const storageKey = `tanstack_router_reload:${errorState.value.message}`;
73
+ if (!sessionStorage.getItem(storageKey)) {
74
+ sessionStorage.setItem(storageKey, "1");
75
+ attemptedReload = true;
76
+ window.location.reload();
77
+ return () => null;
78
+ }
79
+ }
80
+ }
81
+ if (errorState.value && !isModuleNotFoundError(errorState.value)) {
82
+ throw errorState.value;
83
+ }
84
+ return () => {
85
+ if (loading.value || !component.value) {
86
+ return Vue.h("div", null);
87
+ }
88
+ if (ssr?.() === false) {
89
+ return Vue.h(ClientOnly, {
90
+ fallback: Vue.h(Outlet),
91
+ children: Vue.h(component.value, props)
92
+ });
93
+ }
94
+ return Vue.h(component.value, props);
95
+ };
96
+ }
97
+ });
98
+ lazyComp.preload = load;
99
+ return lazyComp;
100
+ }
101
+ export {
102
+ ClientOnly,
103
+ lazyRouteComponent,
104
+ useHydrated
105
+ };
106
+ //# sourceMappingURL=lazyRouteComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { Outlet } from './Match'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n // chrome: \"Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // firefox: \"error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split\"\n // safari: \"Importing a module script failed.\"\n if (typeof error?.message !== 'string') return false\n return (\n error.message.startsWith('Failed to fetch dynamically imported module') ||\n error.message.startsWith('error loading dynamically imported module') ||\n error.message.startsWith('Importing a module script failed')\n )\n}\n\nexport function ClientOnly(props: { children?: any; fallback?: Vue.VNode }) {\n const hydrated = useHydrated()\n\n return () => {\n if (hydrated.value) {\n return props.children\n }\n return props.fallback || null\n }\n}\n\nexport function useHydrated() {\n // Only hydrate on client-side, never on server\n const hydrated = Vue.ref(false)\n\n // If on server, return false\n if (typeof window === 'undefined') {\n return Vue.computed(() => false)\n }\n\n // On client, set to true once mounted\n Vue.onMounted(() => {\n hydrated.value = true\n })\n\n return hydrated\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default'] | null = null\n let error: any = null\n let attemptedReload = false\n\n const load = () => {\n // If we're on the server and SSR is disabled for this component\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n\n // Use existing promise or create new one\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n loadPromise = undefined\n\n // If it's a module not found error, we'll try to handle it in the component\n if (isModuleNotFoundError(error)) {\n return null\n }\n\n throw err\n })\n }\n\n return loadPromise\n }\n\n // Create a lazy component wrapper using defineComponent so it works in Vue SFC templates\n const lazyComp = Vue.defineComponent({\n name: 'LazyRouteComponent',\n setup(props: any) {\n // Create refs to track component state\n const component = Vue.ref<any>(comp)\n const errorState = Vue.ref<any>(error)\n const loading = Vue.ref(!component.value && !errorState.value)\n\n // Setup effect to load the component when this component is used\n Vue.onMounted(() => {\n if (!component.value && !errorState.value) {\n loading.value = true\n\n load()\n .then((result) => {\n component.value = result\n loading.value = false\n })\n .catch((err) => {\n errorState.value = err\n loading.value = false\n })\n }\n })\n\n // Handle module not found error with reload attempt\n if (\n errorState.value &&\n isModuleNotFoundError(errorState.value) &&\n !attemptedReload\n ) {\n if (\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Try to reload once on module not found error\n const storageKey = `tanstack_router_reload:${errorState.value.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n attemptedReload = true\n window.location.reload()\n return () => null // Return empty while reloading\n }\n }\n }\n\n // If we have a non-module-not-found error, throw it\n if (errorState.value && !isModuleNotFoundError(errorState.value)) {\n throw errorState.value\n }\n\n // Return a render function\n return () => {\n // If we're still loading or don't have a component yet, use a suspense pattern\n if (loading.value || !component.value) {\n return Vue.h('div', null) // Empty div while loading\n }\n\n // If SSR is disabled for this component\n if (ssr?.() === false) {\n return Vue.h(ClientOnly, {\n fallback: Vue.h(Outlet),\n children: Vue.h(component.value, props),\n })\n }\n\n // Regular render with the loaded component\n return Vue.h(component.value, props)\n }\n },\n })\n\n // Add preload method\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["isModuleNotFoundError","error","message","startsWith","ClientOnly","props","hydrated","useHydrated","value","children","fallback","Vue","ref","window","computed","onMounted","lazyRouteComponent","importer","exportName","ssr","loadPromise","comp","attemptedReload","load","document","Promise","resolve","then","res","undefined","catch","err","lazyComp","defineComponent","name","setup","component","errorState","loading","result","sessionStorage","storageKey","getItem","setItem","location","reload","h","Outlet","preload"],"mappings":"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"}
@@ -0,0 +1,61 @@
1
+ import { AnyRouter, Constrain, LinkOptions, RegisteredRouter, RoutePaths } from '@tanstack/router-core';
2
+ import { ValidateLinkOptions, ValidateLinkOptionsArray } from './typePrimitives.js';
3
+ import * as Vue from 'vue';
4
+ type EventHandler<TEvent = Event> = (e: TEvent) => void;
5
+ interface HTMLAttributes {
6
+ class?: string;
7
+ style?: Record<string, string | number>;
8
+ onClick?: EventHandler<MouseEvent>;
9
+ onFocus?: EventHandler<FocusEvent>;
10
+ onMouseenter?: EventHandler<MouseEvent>;
11
+ onMouseleave?: EventHandler<MouseEvent>;
12
+ onMouseover?: EventHandler<MouseEvent>;
13
+ onMouseout?: EventHandler<MouseEvent>;
14
+ onTouchstart?: EventHandler<TouchEvent>;
15
+ onMouseEnter?: EventHandler<MouseEvent>;
16
+ onMouseLeave?: EventHandler<MouseEvent>;
17
+ onMouseOver?: EventHandler<MouseEvent>;
18
+ onMouseOut?: EventHandler<MouseEvent>;
19
+ onTouchStart?: EventHandler<TouchEvent>;
20
+ [key: string]: any;
21
+ }
22
+ export declare function useLinkProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): HTMLAttributes;
23
+ export type UseLinkPropsOptions<TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter['routeTree']> | string = string, TTo extends string | undefined = '.', TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & HTMLAttributes;
24
+ export type ActiveLinkOptions<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & ActiveLinkOptionProps<TComp>;
25
+ type ActiveLinkProps<TComp> = Partial<HTMLAttributes & {
26
+ [key: `data-${string}`]: unknown;
27
+ }>;
28
+ export interface ActiveLinkOptionProps<TComp = 'a'> {
29
+ /**
30
+ * A function that returns additional props for the `active` state of this link.
31
+ * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)
32
+ */
33
+ activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
34
+ /**
35
+ * A function that returns additional props for the `inactive` state of this link.
36
+ * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)
37
+ */
38
+ inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>);
39
+ }
40
+ export type LinkProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & LinkPropsChildren;
41
+ export interface LinkPropsChildren {
42
+ children?: Vue.VNode | ((state: {
43
+ isActive: boolean;
44
+ isTransitioning: boolean;
45
+ }) => Vue.VNode);
46
+ }
47
+ type LinkComponentVueProps<TComp> = TComp extends keyof HTMLElementTagNameMap ? Omit<HTMLAttributes, keyof CreateLinkProps> : TComp extends Vue.Component ? Record<string, any> : Record<string, any>;
48
+ export type LinkComponentProps<TComp = 'a', TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkComponentVueProps<TComp> & LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
49
+ export type CreateLinkProps = LinkProps<any, any, string, string, string, string>;
50
+ export type LinkComponent<TComp> = <TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => Vue.VNode;
51
+ export declare function createLink<const TComp>(Comp: Constrain<TComp, any, (props: CreateLinkProps) => Vue.VNode>): LinkComponent<TComp>;
52
+ /**
53
+ * Link component with proper TypeScript generics support
54
+ */
55
+ export declare const Link: {
56
+ <TRouter extends AnyRouter = RegisteredRouter, TFrom extends RoutePaths<TRouter["routeTree"]> | string = string, TTo extends string | undefined = ".", TMaskFrom extends RoutePaths<TRouter["routeTree"]> | string = TFrom, TMaskTo extends string = ".">(props: LinkComponentProps<"a", TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): Vue.VNode;
57
+ };
58
+ export type LinkOptionsFnOptions<TOptions, TComp, TRouter extends AnyRouter = RegisteredRouter> = TOptions extends ReadonlyArray<any> ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp> : ValidateLinkOptions<TRouter, TOptions, string, TComp>;
59
+ export type LinkOptionsFn<TComp> = <const TOptions, TRouter extends AnyRouter = RegisteredRouter>(options: LinkOptionsFnOptions<TOptions, TComp, TRouter>) => TOptions;
60
+ export declare const linkOptions: LinkOptionsFn<'a'>;
61
+ export {};