@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
package/src/index.tsx ADDED
@@ -0,0 +1,346 @@
1
+ export {
2
+ defer,
3
+ TSR_DEFERRED_PROMISE,
4
+ isMatch,
5
+ joinPaths,
6
+ cleanPath,
7
+ trimPathLeft,
8
+ trimPathRight,
9
+ trimPath,
10
+ resolvePath,
11
+ interpolatePath,
12
+ rootRouteId,
13
+ defaultSerializeError,
14
+ defaultParseSearch,
15
+ defaultStringifySearch,
16
+ parseSearchWith,
17
+ stringifySearchWith,
18
+ functionalUpdate,
19
+ replaceEqualDeep,
20
+ isPlainObject,
21
+ isPlainArray,
22
+ deepEqual,
23
+ createControlledPromise,
24
+ retainSearchParams,
25
+ stripSearchParams,
26
+ createSerializationAdapter,
27
+ } from '@tanstack/router-core'
28
+
29
+ export type {
30
+ AnyRoute,
31
+ DeferredPromiseState,
32
+ DeferredPromise,
33
+ ParsedLocation,
34
+ RemoveTrailingSlashes,
35
+ RemoveLeadingSlashes,
36
+ ActiveOptions,
37
+ ResolveRelativePath,
38
+ RootRouteId,
39
+ AnyPathParams,
40
+ ResolveParams,
41
+ ResolveOptionalParams,
42
+ ResolveRequiredParams,
43
+ SearchSchemaInput,
44
+ AnyContext,
45
+ RouteContext,
46
+ PreloadableObj,
47
+ RoutePathOptions,
48
+ StaticDataRouteOption,
49
+ RoutePathOptionsIntersection,
50
+ UpdatableStaticRouteOption,
51
+ MetaDescriptor,
52
+ RouteLinkEntry,
53
+ ParseParamsFn,
54
+ SearchFilter,
55
+ ResolveId,
56
+ InferFullSearchSchema,
57
+ InferFullSearchSchemaInput,
58
+ ErrorRouteProps,
59
+ ErrorComponentProps,
60
+ NotFoundRouteProps,
61
+ TrimPath,
62
+ TrimPathLeft,
63
+ TrimPathRight,
64
+ StringifyParamsFn,
65
+ ParamsOptions,
66
+ InferAllParams,
67
+ InferAllContext,
68
+ LooseReturnType,
69
+ LooseAsyncReturnType,
70
+ ContextReturnType,
71
+ ContextAsyncReturnType,
72
+ ResolveLoaderData,
73
+ ResolveRouteContext,
74
+ SearchSerializer,
75
+ SearchParser,
76
+ TrailingSlashOption,
77
+ Manifest,
78
+ RouterManagedTag,
79
+ ControlledPromise,
80
+ Constrain,
81
+ Expand,
82
+ MergeAll,
83
+ Assign,
84
+ IntersectAssign,
85
+ ResolveValidatorInput,
86
+ ResolveValidatorOutput,
87
+ Register,
88
+ AnyValidator,
89
+ DefaultValidator,
90
+ ValidatorFn,
91
+ AnySchema,
92
+ AnyValidatorAdapter,
93
+ AnyValidatorFn,
94
+ AnyValidatorObj,
95
+ ResolveValidatorInputFn,
96
+ ResolveValidatorOutputFn,
97
+ ResolveSearchValidatorInput,
98
+ ResolveSearchValidatorInputFn,
99
+ Validator,
100
+ ValidatorAdapter,
101
+ ValidatorObj,
102
+ FileRoutesByPath,
103
+ RouteById,
104
+ RootRouteOptions,
105
+ CreateFileRoute,
106
+ SerializationAdapter,
107
+ AnySerializationAdapter,
108
+ } from '@tanstack/router-core'
109
+
110
+ export {
111
+ createHistory,
112
+ createBrowserHistory,
113
+ createHashHistory,
114
+ createMemoryHistory,
115
+ } from '@tanstack/history'
116
+
117
+ export type {
118
+ BlockerFn,
119
+ HistoryLocation,
120
+ RouterHistory,
121
+ ParsedPath,
122
+ HistoryState,
123
+ } from '@tanstack/history'
124
+
125
+ export { useAwaited, Await } from './awaited'
126
+ export type { AwaitOptions } from './awaited'
127
+
128
+ export { CatchBoundary, ErrorComponent } from './CatchBoundary'
129
+
130
+ export {
131
+ FileRoute,
132
+ createFileRoute,
133
+ FileRouteLoader,
134
+ LazyRoute,
135
+ createLazyRoute,
136
+ createLazyFileRoute,
137
+ } from './fileRoute'
138
+
139
+ export * from './history'
140
+
141
+ export { lazyRouteComponent } from './lazyRouteComponent'
142
+
143
+ export { useLinkProps, createLink, Link, linkOptions } from './link'
144
+ export type {
145
+ InferDescendantToPaths,
146
+ RelativeToPath,
147
+ RelativeToParentPath,
148
+ RelativeToCurrentPath,
149
+ AbsoluteToPath,
150
+ RelativeToPathAutoComplete,
151
+ NavigateOptions,
152
+ ToOptions,
153
+ ToMaskOptions,
154
+ ToSubOptions,
155
+ ResolveRoute,
156
+ SearchParamOptions,
157
+ PathParamOptions,
158
+ ToPathOption,
159
+ LinkOptions,
160
+ MakeOptionalPathParams,
161
+ FileRouteTypes,
162
+ RouteContextParameter,
163
+ BeforeLoadContextParameter,
164
+ ResolveAllContext,
165
+ ResolveAllParamsFromParent,
166
+ ResolveFullSearchSchema,
167
+ ResolveFullSearchSchemaInput,
168
+ RouteIds,
169
+ NavigateFn,
170
+ BuildLocationFn,
171
+ FullSearchSchemaOption,
172
+ MakeRemountDepsOptionsUnion,
173
+ RemountDepsOptions,
174
+ ResolveFullPath,
175
+ AnyRouteWithContext,
176
+ AnyRouterWithContext,
177
+ CommitLocationOptions,
178
+ MatchLocation,
179
+ UseNavigateResult,
180
+ AnyRedirect,
181
+ Redirect,
182
+ RedirectOptions,
183
+ ResolvedRedirect,
184
+ MakeRouteMatch,
185
+ MakeRouteMatchUnion,
186
+ RouteMatch,
187
+ AnyRouteMatch,
188
+ RouteContextFn,
189
+ RouteContextOptions,
190
+ BeforeLoadContextOptions,
191
+ ContextOptions,
192
+ RouteOptions,
193
+ FileBaseRouteOptions,
194
+ BaseRouteOptions,
195
+ UpdatableRouteOptions,
196
+ RouteLoaderFn,
197
+ LoaderFnContext,
198
+ LazyRouteOptions,
199
+ AnyRouter,
200
+ RegisteredRouter,
201
+ RouterContextOptions,
202
+ ControllablePromise,
203
+ InjectedHtmlEntry,
204
+ RouterOptions,
205
+ RouterState,
206
+ ListenerFn,
207
+ BuildNextOptions,
208
+ RouterConstructorOptions,
209
+ RouterEvents,
210
+ RouterEvent,
211
+ RouterListener,
212
+ RouteConstraints,
213
+ RouteMask,
214
+ MatchRouteOptions,
215
+ CreateLazyFileRoute,
216
+ } from '@tanstack/router-core'
217
+ export type {
218
+ UseLinkPropsOptions,
219
+ ActiveLinkOptions,
220
+ LinkProps,
221
+ LinkComponent,
222
+ LinkComponentProps,
223
+ CreateLinkProps,
224
+ } from './link'
225
+
226
+ export {
227
+ Matches,
228
+ useMatchRoute,
229
+ MatchRoute,
230
+ useMatches,
231
+ useParentMatches,
232
+ useChildMatches,
233
+ } from './Matches'
234
+
235
+ export type { UseMatchRouteOptions, MakeMatchRouteOptions } from './Matches'
236
+
237
+ export { matchContext } from './matchContext'
238
+ export { Match, Outlet } from './Match'
239
+
240
+ export { useMatch } from './useMatch'
241
+ export { useLoaderDeps } from './useLoaderDeps'
242
+ export { useLoaderData } from './useLoaderData'
243
+
244
+ export { redirect, isRedirect, createRouterConfig } from '@tanstack/router-core'
245
+
246
+ export {
247
+ RouteApi,
248
+ getRouteApi,
249
+ Route,
250
+ createRoute,
251
+ RootRoute,
252
+ rootRouteWithContext,
253
+ createRootRoute,
254
+ createRootRouteWithContext,
255
+ createRouteMask,
256
+ NotFoundRoute,
257
+ } from './route'
258
+ export type {
259
+ AnyRootRoute,
260
+ VueNode,
261
+ SyncRouteComponent,
262
+ AsyncRouteComponent,
263
+ RouteComponent,
264
+ ErrorRouteComponent,
265
+ NotFoundRouteComponent,
266
+ } from './route'
267
+
268
+ export { createRouter, Router } from './router'
269
+
270
+ export {
271
+ componentTypes,
272
+ lazyFn,
273
+ SearchParamError,
274
+ PathParamError,
275
+ getInitialRouterState,
276
+ } from '@tanstack/router-core'
277
+
278
+ export { RouterProvider, RouterContextProvider } from './RouterProvider'
279
+ export type { RouterProps } from './RouterProvider'
280
+
281
+ export {
282
+ useElementScrollRestoration,
283
+ ScrollRestoration,
284
+ } from './ScrollRestoration'
285
+
286
+ export type { UseBlockerOpts, ShouldBlockFn } from './useBlocker'
287
+ export { useBlocker, Block } from './useBlocker'
288
+
289
+ export { useNavigate, Navigate } from './useNavigate'
290
+
291
+ export { useParams } from './useParams'
292
+ export { useSearch } from './useSearch'
293
+
294
+ export {
295
+ getRouterContext, // SSR
296
+ } from './routerContext'
297
+
298
+ export { useRouteContext } from './useRouteContext'
299
+ export { useRouter } from './useRouter'
300
+ export { useRouterState } from './useRouterState'
301
+ export { useLocation } from './useLocation'
302
+ export { useCanGoBack } from './useCanGoBack'
303
+
304
+ export { useLayoutEffect } from './utils'
305
+
306
+ export { CatchNotFound, DefaultGlobalNotFound } from './not-found'
307
+ export { notFound, isNotFound } from '@tanstack/router-core'
308
+ export type { NotFoundError } from '@tanstack/router-core'
309
+
310
+ export type {
311
+ ValidateLinkOptions,
312
+ ValidateUseSearchOptions,
313
+ ValidateUseParamsOptions,
314
+ ValidateLinkOptionsArray,
315
+ } from './typePrimitives'
316
+
317
+ export type {
318
+ ValidateFromPath,
319
+ ValidateToPath,
320
+ ValidateSearch,
321
+ ValidateParams,
322
+ InferFrom,
323
+ InferTo,
324
+ InferMaskTo,
325
+ InferMaskFrom,
326
+ ValidateNavigateOptions,
327
+ ValidateNavigateOptionsArray,
328
+ ValidateRedirectOptions,
329
+ ValidateRedirectOptionsArray,
330
+ ValidateId,
331
+ InferStrict,
332
+ InferShouldThrow,
333
+ InferSelected,
334
+ ValidateUseSearchResult,
335
+ ValidateUseParamsResult,
336
+ } from '@tanstack/router-core'
337
+
338
+ export { ScriptOnce } from './ScriptOnce'
339
+ export { Asset } from './Asset'
340
+ export { HeadContent } from './HeadContent'
341
+ export { Scripts } from './Scripts'
342
+ export { composeRewrites } from '@tanstack/router-core'
343
+ export type {
344
+ LocationRewrite,
345
+ LocationRewriteFunction,
346
+ } from '@tanstack/router-core'
@@ -0,0 +1,173 @@
1
+ import * as Vue from 'vue'
2
+ import { Outlet } from './Match'
3
+ import type { AsyncRouteComponent } from './route'
4
+
5
+ // If the load fails due to module not found, it may mean a new version of
6
+ // the build was deployed and the user's browser is still using an old version.
7
+ // If this happens, the old version in the user's browser would have an outdated
8
+ // URL to the lazy module.
9
+ // In that case, we want to attempt one window refresh to get the latest.
10
+ function isModuleNotFoundError(error: any): boolean {
11
+ // chrome: "Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
12
+ // firefox: "error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
13
+ // safari: "Importing a module script failed."
14
+ if (typeof error?.message !== 'string') return false
15
+ return (
16
+ error.message.startsWith('Failed to fetch dynamically imported module') ||
17
+ error.message.startsWith('error loading dynamically imported module') ||
18
+ error.message.startsWith('Importing a module script failed')
19
+ )
20
+ }
21
+
22
+ export function ClientOnly(props: { children?: any; fallback?: Vue.VNode }) {
23
+ const hydrated = useHydrated()
24
+
25
+ return () => {
26
+ if (hydrated.value) {
27
+ return props.children
28
+ }
29
+ return props.fallback || null
30
+ }
31
+ }
32
+
33
+ export function useHydrated() {
34
+ // Only hydrate on client-side, never on server
35
+ const hydrated = Vue.ref(false)
36
+
37
+ // If on server, return false
38
+ if (typeof window === 'undefined') {
39
+ return Vue.computed(() => false)
40
+ }
41
+
42
+ // On client, set to true once mounted
43
+ Vue.onMounted(() => {
44
+ hydrated.value = true
45
+ })
46
+
47
+ return hydrated
48
+ }
49
+
50
+ export function lazyRouteComponent<
51
+ T extends Record<string, any>,
52
+ TKey extends keyof T = 'default',
53
+ >(
54
+ importer: () => Promise<T>,
55
+ exportName?: TKey,
56
+ ssr?: () => boolean,
57
+ ): T[TKey] extends (props: infer TProps) => any
58
+ ? AsyncRouteComponent<TProps>
59
+ : never {
60
+ let loadPromise: Promise<any> | undefined
61
+ let comp: T[TKey] | T['default'] | null = null
62
+ let error: any = null
63
+ let attemptedReload = false
64
+
65
+ const load = () => {
66
+ // If we're on the server and SSR is disabled for this component
67
+ if (typeof document === 'undefined' && ssr?.() === false) {
68
+ comp = (() => null) as any
69
+ return Promise.resolve(comp)
70
+ }
71
+
72
+ // Use existing promise or create new one
73
+ if (!loadPromise) {
74
+ loadPromise = importer()
75
+ .then((res) => {
76
+ loadPromise = undefined
77
+ comp = res[exportName ?? 'default']
78
+ return comp
79
+ })
80
+ .catch((err) => {
81
+ error = err
82
+ loadPromise = undefined
83
+
84
+ // If it's a module not found error, we'll try to handle it in the component
85
+ if (isModuleNotFoundError(error)) {
86
+ return null
87
+ }
88
+
89
+ throw err
90
+ })
91
+ }
92
+
93
+ return loadPromise
94
+ }
95
+
96
+ // Create a lazy component wrapper using defineComponent so it works in Vue SFC templates
97
+ const lazyComp = Vue.defineComponent({
98
+ name: 'LazyRouteComponent',
99
+ setup(props: any) {
100
+ // Create refs to track component state
101
+ const component = Vue.ref<any>(comp)
102
+ const errorState = Vue.ref<any>(error)
103
+ const loading = Vue.ref(!component.value && !errorState.value)
104
+
105
+ // Setup effect to load the component when this component is used
106
+ Vue.onMounted(() => {
107
+ if (!component.value && !errorState.value) {
108
+ loading.value = true
109
+
110
+ load()
111
+ .then((result) => {
112
+ component.value = result
113
+ loading.value = false
114
+ })
115
+ .catch((err) => {
116
+ errorState.value = err
117
+ loading.value = false
118
+ })
119
+ }
120
+ })
121
+
122
+ // Handle module not found error with reload attempt
123
+ if (
124
+ errorState.value &&
125
+ isModuleNotFoundError(errorState.value) &&
126
+ !attemptedReload
127
+ ) {
128
+ if (
129
+ typeof window !== 'undefined' &&
130
+ typeof sessionStorage !== 'undefined'
131
+ ) {
132
+ // Try to reload once on module not found error
133
+ const storageKey = `tanstack_router_reload:${errorState.value.message}`
134
+ if (!sessionStorage.getItem(storageKey)) {
135
+ sessionStorage.setItem(storageKey, '1')
136
+ attemptedReload = true
137
+ window.location.reload()
138
+ return () => null // Return empty while reloading
139
+ }
140
+ }
141
+ }
142
+
143
+ // If we have a non-module-not-found error, throw it
144
+ if (errorState.value && !isModuleNotFoundError(errorState.value)) {
145
+ throw errorState.value
146
+ }
147
+
148
+ // Return a render function
149
+ return () => {
150
+ // If we're still loading or don't have a component yet, use a suspense pattern
151
+ if (loading.value || !component.value) {
152
+ return Vue.h('div', null) // Empty div while loading
153
+ }
154
+
155
+ // If SSR is disabled for this component
156
+ if (ssr?.() === false) {
157
+ return Vue.h(ClientOnly, {
158
+ fallback: Vue.h(Outlet),
159
+ children: Vue.h(component.value, props),
160
+ })
161
+ }
162
+
163
+ // Regular render with the loaded component
164
+ return Vue.h(component.value, props)
165
+ }
166
+ },
167
+ })
168
+
169
+ // Add preload method
170
+ ;(lazyComp as any).preload = load
171
+
172
+ return lazyComp as any
173
+ }