@bleedingdev/modern-js-renderer-solid 0.0.0-stage → 3.9.3-ultramodern.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 (297) hide show
  1. package/dist/esm/actions.js +283 -0
  2. package/dist/esm/application-router.js +25 -0
  3. package/dist/esm/client.js +49 -0
  4. package/dist/esm/entry-application.js +60 -0
  5. package/dist/esm/entry-client.js +23 -0
  6. package/dist/esm/federation-context.js +25 -0
  7. package/dist/esm/federation-ssr.js +84 -0
  8. package/dist/esm/federation.js +83 -0
  9. package/dist/esm/i18n/I18nProvider.js +33 -0
  10. package/dist/esm/i18n/LocalizedLink.js +74 -0
  11. package/dist/esm/i18n/context.js +3 -0
  12. package/dist/esm/i18n/index.js +8 -0
  13. package/dist/esm/i18n/languageSync.js +50 -0
  14. package/dist/esm/i18n/types.js +0 -0
  15. package/dist/esm/i18n/useI18n.js +74 -0
  16. package/dist/esm/index.js +58 -0
  17. package/dist/esm/manifest.js +150 -0
  18. package/dist/esm/route-completion.js +150 -0
  19. package/dist/esm/route-data-error.js +108 -0
  20. package/dist/esm/router-binding/Asset.js +201 -0
  21. package/dist/esm/router-binding/CatchBoundary.js +94 -0
  22. package/dist/esm/router-binding/ClientOnly.js +26 -0
  23. package/dist/esm/router-binding/HeadContent.js +8 -0
  24. package/dist/esm/router-binding/LICENSE +21 -0
  25. package/dist/esm/router-binding/Match.js +319 -0
  26. package/dist/esm/router-binding/Matches.js +117 -0
  27. package/dist/esm/router-binding/PROVENANCE.json +94 -0
  28. package/dist/esm/router-binding/RouterProvider.js +51 -0
  29. package/dist/esm/router-binding/SafeFragment.js +5 -0
  30. package/dist/esm/router-binding/ScriptOnce.js +15 -0
  31. package/dist/esm/router-binding/Scripts.js +30 -0
  32. package/dist/esm/router-binding/ScrollRestoration.js +16 -0
  33. package/dist/esm/router-binding/Transitioner.js +103 -0
  34. package/dist/esm/router-binding/awaited.js +48 -0
  35. package/dist/esm/router-binding/fileRoute.js +83 -0
  36. package/dist/esm/router-binding/flightData.js +23 -0
  37. package/dist/esm/router-binding/headContentUtils.js +162 -0
  38. package/dist/esm/router-binding/history.js +0 -0
  39. package/dist/esm/router-binding/index.js +35 -0
  40. package/dist/esm/router-binding/lazyRouteComponent.js +30 -0
  41. package/dist/esm/router-binding/link.js +389 -0
  42. package/dist/esm/router-binding/matchContext.js +7 -0
  43. package/dist/esm/router-binding/nonRouteComponentContext.js +13 -0
  44. package/dist/esm/router-binding/not-found.js +35 -0
  45. package/dist/esm/router-binding/publicMatchData.js +447 -0
  46. package/dist/esm/router-binding/registryTransfer.js +210 -0
  47. package/dist/esm/router-binding/renderRouteNotFound.js +23 -0
  48. package/dist/esm/router-binding/route.js +143 -0
  49. package/dist/esm/router-binding/router.js +13 -0
  50. package/dist/esm/router-binding/routerContext.js +3 -0
  51. package/dist/esm/router-binding/routerStores.js +50 -0
  52. package/dist/esm/router-binding/scroll-restoration.js +13 -0
  53. package/dist/esm/router-binding/typePrimitives.js +0 -0
  54. package/dist/esm/router-binding/useBlocker.js +152 -0
  55. package/dist/esm/router-binding/useCanGoBack.js +7 -0
  56. package/dist/esm/router-binding/useLoaderData.js +9 -0
  57. package/dist/esm/router-binding/useLoaderDeps.js +8 -0
  58. package/dist/esm/router-binding/useLocation.js +14 -0
  59. package/dist/esm/router-binding/useMatch.js +28 -0
  60. package/dist/esm/router-binding/useNavigate.js +19 -0
  61. package/dist/esm/router-binding/useParams.js +13 -0
  62. package/dist/esm/router-binding/useRouteContext.js +8 -0
  63. package/dist/esm/router-binding/useRouter.js +10 -0
  64. package/dist/esm/router-binding/useRouterState.js +19 -0
  65. package/dist/esm/router-binding/useSearch.js +13 -0
  66. package/dist/esm/router-binding/utils.js +23 -0
  67. package/dist/esm/router.js +187 -0
  68. package/dist/esm-node/actions.js +263 -0
  69. package/dist/esm-node/application-router.js +25 -0
  70. package/dist/esm-node/client.js +49 -0
  71. package/dist/esm-node/entry-application.js +110 -0
  72. package/dist/esm-node/entry-client.js +23 -0
  73. package/dist/esm-node/entry-server.js +47 -0
  74. package/dist/esm-node/federation-context.js +25 -0
  75. package/dist/esm-node/federation-ssr.js +84 -0
  76. package/dist/esm-node/federation.js +83 -0
  77. package/dist/esm-node/i18n/I18nProvider.js +42 -0
  78. package/dist/esm-node/i18n/LocalizedLink.js +142 -0
  79. package/dist/esm-node/i18n/context.js +3 -0
  80. package/dist/esm-node/i18n/index.js +8 -0
  81. package/dist/esm-node/i18n/languageSync.js +50 -0
  82. package/dist/esm-node/i18n/types.js +1 -0
  83. package/dist/esm-node/i18n/useI18n.js +74 -0
  84. package/dist/esm-node/index.js +58 -0
  85. package/dist/esm-node/manifest.js +150 -0
  86. package/dist/esm-node/native-promise-serialization.js +113 -0
  87. package/dist/esm-node/plugin/compiler.js +209 -0
  88. package/dist/esm-node/plugin/create.js +235 -0
  89. package/dist/esm-node/plugin/index.js +73 -0
  90. package/dist/esm-node/plugin/profile.js +52 -0
  91. package/dist/esm-node/route-completion.js +160 -0
  92. package/dist/esm-node/route-data-error.js +108 -0
  93. package/dist/esm-node/router-binding/Asset.js +171 -0
  94. package/dist/esm-node/router-binding/CatchBoundary.js +136 -0
  95. package/dist/esm-node/router-binding/ClientOnly.js +46 -0
  96. package/dist/esm-node/router-binding/HeadContent.js +8 -0
  97. package/dist/esm-node/router-binding/LICENSE +21 -0
  98. package/dist/esm-node/router-binding/Match.js +660 -0
  99. package/dist/esm-node/router-binding/Matches.js +161 -0
  100. package/dist/esm-node/router-binding/PROVENANCE.json +94 -0
  101. package/dist/esm-node/router-binding/RouterProvider.js +87 -0
  102. package/dist/esm-node/router-binding/SafeFragment.js +5 -0
  103. package/dist/esm-node/router-binding/ScriptOnce.js +16 -0
  104. package/dist/esm-node/router-binding/Scripts.js +49 -0
  105. package/dist/esm-node/router-binding/ScrollRestoration.js +16 -0
  106. package/dist/esm-node/router-binding/Transitioner.js +103 -0
  107. package/dist/esm-node/router-binding/awaited.js +75 -0
  108. package/dist/esm-node/router-binding/fileRoute.js +83 -0
  109. package/dist/esm-node/router-binding/flightData.js +23 -0
  110. package/dist/esm-node/router-binding/headContentUtils.js +162 -0
  111. package/dist/esm-node/router-binding/history.js +1 -0
  112. package/dist/esm-node/router-binding/index.js +35 -0
  113. package/dist/esm-node/router-binding/lazyRouteComponent.js +30 -0
  114. package/dist/esm-node/router-binding/link.js +399 -0
  115. package/dist/esm-node/router-binding/matchContext.js +7 -0
  116. package/dist/esm-node/router-binding/nonRouteComponentContext.js +22 -0
  117. package/dist/esm-node/router-binding/not-found.js +49 -0
  118. package/dist/esm-node/router-binding/publicMatchData.js +447 -0
  119. package/dist/esm-node/router-binding/registryTransfer.js +210 -0
  120. package/dist/esm-node/router-binding/renderRouteNotFound.js +22 -0
  121. package/dist/esm-node/router-binding/route.js +162 -0
  122. package/dist/esm-node/router-binding/router.js +13 -0
  123. package/dist/esm-node/router-binding/routerContext.js +3 -0
  124. package/dist/esm-node/router-binding/routerStores.js +50 -0
  125. package/dist/esm-node/router-binding/scroll-restoration.js +12 -0
  126. package/dist/esm-node/router-binding/typePrimitives.js +1 -0
  127. package/dist/esm-node/router-binding/useBlocker.js +152 -0
  128. package/dist/esm-node/router-binding/useCanGoBack.js +7 -0
  129. package/dist/esm-node/router-binding/useLoaderData.js +9 -0
  130. package/dist/esm-node/router-binding/useLoaderDeps.js +8 -0
  131. package/dist/esm-node/router-binding/useLocation.js +14 -0
  132. package/dist/esm-node/router-binding/useMatch.js +28 -0
  133. package/dist/esm-node/router-binding/useNavigate.js +19 -0
  134. package/dist/esm-node/router-binding/useParams.js +13 -0
  135. package/dist/esm-node/router-binding/useRouteContext.js +8 -0
  136. package/dist/esm-node/router-binding/useRouter.js +10 -0
  137. package/dist/esm-node/router-binding/useRouterState.js +19 -0
  138. package/dist/esm-node/router-binding/useSearch.js +13 -0
  139. package/dist/esm-node/router-binding/utils.js +23 -0
  140. package/dist/esm-node/router.js +187 -0
  141. package/dist/esm-node/server.js +396 -0
  142. package/dist/types/actions.d.ts +45 -0
  143. package/dist/types/application-router.d.ts +5 -0
  144. package/dist/types/client.d.ts +23 -0
  145. package/dist/types/entry-application.d.ts +10 -0
  146. package/dist/types/entry-client.d.ts +5 -0
  147. package/dist/types/entry-server.d.ts +5 -0
  148. package/dist/types/federation-context.d.ts +16 -0
  149. package/dist/types/federation-ssr.d.ts +21 -0
  150. package/dist/types/federation.d.ts +30 -0
  151. package/dist/types/i18n/I18nProvider.d.ts +21 -0
  152. package/dist/types/i18n/LocalizedLink.d.ts +43 -0
  153. package/dist/types/i18n/context.d.ts +11 -0
  154. package/dist/types/i18n/index.d.ts +9 -0
  155. package/dist/types/i18n/languageSync.d.ts +31 -0
  156. package/dist/types/i18n/types.d.ts +33 -0
  157. package/dist/types/i18n/useI18n.d.ts +24 -0
  158. package/dist/types/index.d.ts +41 -0
  159. package/dist/types/manifest.d.ts +55 -0
  160. package/dist/types/native-promise-serialization.d.ts +9 -0
  161. package/dist/types/plugin/compiler.d.ts +6 -0
  162. package/dist/types/plugin/create.d.ts +21 -0
  163. package/dist/types/plugin/index.d.ts +3 -0
  164. package/dist/types/plugin/lazy-modules.d.cts +15 -0
  165. package/dist/types/plugin/preserve-import-loader.d.cts +3 -0
  166. package/dist/types/plugin/profile.d.ts +2 -0
  167. package/dist/types/plugin/solid-loader.d.cts +2 -0
  168. package/dist/types/plugin/svg-component-template.d.cts +6 -0
  169. package/dist/types/route-completion.d.ts +21 -0
  170. package/dist/types/route-data-error.d.ts +17 -0
  171. package/dist/types/router-binding/Asset.d.ts +3 -0
  172. package/dist/types/router-binding/CatchBoundary.d.ts +13 -0
  173. package/dist/types/router-binding/ClientOnly.d.ts +31 -0
  174. package/dist/types/router-binding/HeadContent.d.ts +13 -0
  175. package/dist/types/router-binding/Match.d.ts +6 -0
  176. package/dist/types/router-binding/Matches.d.ts +26 -0
  177. package/dist/types/router-binding/RouterProvider.d.ts +10 -0
  178. package/dist/types/router-binding/SafeFragment.d.ts +2 -0
  179. package/dist/types/router-binding/ScriptOnce.d.ts +6 -0
  180. package/dist/types/router-binding/Scripts.d.ts +2 -0
  181. package/dist/types/router-binding/ScrollRestoration.d.ts +14 -0
  182. package/dist/types/router-binding/Transitioner.d.ts +2 -0
  183. package/dist/types/router-binding/awaited.d.ts +11 -0
  184. package/dist/types/router-binding/fileRoute.d.ts +54 -0
  185. package/dist/types/router-binding/flightData.d.ts +38 -0
  186. package/dist/types/router-binding/headContentUtils.d.ts +15 -0
  187. package/dist/types/router-binding/history.d.ts +8 -0
  188. package/dist/types/router-binding/index.d.ts +45 -0
  189. package/dist/types/router-binding/lazyRouteComponent.d.ts +2 -0
  190. package/dist/types/router-binding/link.d.ts +43 -0
  191. package/dist/types/router-binding/matchContext.d.ts +7 -0
  192. package/dist/types/router-binding/nonRouteComponentContext.d.ts +5 -0
  193. package/dist/types/router-binding/not-found.d.ts +11 -0
  194. package/dist/types/router-binding/publicMatchData.d.ts +19 -0
  195. package/dist/types/router-binding/registryTransfer.d.ts +47 -0
  196. package/dist/types/router-binding/renderRouteNotFound.d.ts +11 -0
  197. package/dist/types/router-binding/route.d.ts +105 -0
  198. package/dist/types/router-binding/router.d.ts +70 -0
  199. package/dist/types/router-binding/routerContext.d.ts +3 -0
  200. package/dist/types/router-binding/routerStores.d.ts +2 -0
  201. package/dist/types/router-binding/scroll-restoration.d.ts +2 -0
  202. package/dist/types/router-binding/typePrimitives.d.ts +10 -0
  203. package/dist/types/router-binding/useBlocker.d.ts +70 -0
  204. package/dist/types/router-binding/useCanGoBack.d.ts +2 -0
  205. package/dist/types/router-binding/useLoaderData.d.ts +8 -0
  206. package/dist/types/router-binding/useLoaderDeps.d.ts +8 -0
  207. package/dist/types/router-binding/useLocation.d.ts +7 -0
  208. package/dist/types/router-binding/useMatch.d.ts +10 -0
  209. package/dist/types/router-binding/useNavigate.d.ts +5 -0
  210. package/dist/types/router-binding/useParams.d.ts +9 -0
  211. package/dist/types/router-binding/useRouteContext.d.ts +4 -0
  212. package/dist/types/router-binding/useRouter.d.ts +4 -0
  213. package/dist/types/router-binding/useRouterState.d.ts +8 -0
  214. package/dist/types/router-binding/useSearch.d.ts +9 -0
  215. package/dist/types/router-binding/utils.d.ts +25 -0
  216. package/dist/types/router.d.ts +31 -0
  217. package/dist/types/server.d.ts +47 -0
  218. package/package.json +123 -4
  219. package/src/actions.tsx +437 -0
  220. package/src/application-router.tsx +41 -0
  221. package/src/client.ts +106 -0
  222. package/src/entry-application.tsx +73 -0
  223. package/src/entry-client.tsx +48 -0
  224. package/src/entry-server.tsx +85 -0
  225. package/src/federation-context.ts +47 -0
  226. package/src/federation-ssr.ts +117 -0
  227. package/src/federation.tsx +193 -0
  228. package/src/i18n/I18nProvider.tsx +54 -0
  229. package/src/i18n/LocalizedLink.tsx +122 -0
  230. package/src/i18n/context.ts +13 -0
  231. package/src/i18n/index.ts +35 -0
  232. package/src/i18n/languageSync.ts +113 -0
  233. package/src/i18n/types.ts +35 -0
  234. package/src/i18n/useI18n.ts +121 -0
  235. package/src/index.ts +41 -0
  236. package/src/manifest.ts +337 -0
  237. package/src/native-promise-serialization.ts +167 -0
  238. package/src/plugin/compiler.ts +320 -0
  239. package/src/plugin/create.ts +270 -0
  240. package/src/plugin/index.ts +72 -0
  241. package/src/plugin/lazy-modules.cjs +146 -0
  242. package/src/plugin/preserve-import-loader.cjs +46 -0
  243. package/src/plugin/profile.ts +42 -0
  244. package/src/plugin/solid-loader.cjs +83 -0
  245. package/src/plugin/svg-component-template.cjs +19 -0
  246. package/src/route-completion.tsx +222 -0
  247. package/src/route-data-error.ts +175 -0
  248. package/src/router-binding/Asset.tsx +283 -0
  249. package/src/router-binding/CatchBoundary.tsx +130 -0
  250. package/src/router-binding/ClientOnly.tsx +76 -0
  251. package/src/router-binding/HeadContent.tsx +23 -0
  252. package/src/router-binding/LICENSE +21 -0
  253. package/src/router-binding/Match.tsx +397 -0
  254. package/src/router-binding/Matches.tsx +242 -0
  255. package/src/router-binding/PROVENANCE.json +94 -0
  256. package/src/router-binding/RouterProvider.tsx +129 -0
  257. package/src/router-binding/SafeFragment.tsx +5 -0
  258. package/src/router-binding/ScriptOnce.tsx +23 -0
  259. package/src/router-binding/Scripts.tsx +44 -0
  260. package/src/router-binding/ScrollRestoration.tsx +49 -0
  261. package/src/router-binding/Transitioner.tsx +172 -0
  262. package/src/router-binding/awaited.tsx +71 -0
  263. package/src/router-binding/fileRoute.ts +268 -0
  264. package/src/router-binding/flightData.ts +90 -0
  265. package/src/router-binding/headContentUtils.tsx +290 -0
  266. package/src/router-binding/history.ts +9 -0
  267. package/src/router-binding/index.tsx +318 -0
  268. package/src/router-binding/lazyRouteComponent.tsx +70 -0
  269. package/src/router-binding/link.tsx +865 -0
  270. package/src/router-binding/matchContext.tsx +15 -0
  271. package/src/router-binding/nonRouteComponentContext.tsx +23 -0
  272. package/src/router-binding/not-found.tsx +65 -0
  273. package/src/router-binding/publicMatchData.ts +674 -0
  274. package/src/router-binding/registryTransfer.ts +383 -0
  275. package/src/router-binding/renderRouteNotFound.tsx +53 -0
  276. package/src/router-binding/route.tsx +665 -0
  277. package/src/router-binding/router.ts +121 -0
  278. package/src/router-binding/routerContext.tsx +6 -0
  279. package/src/router-binding/routerStores.ts +85 -0
  280. package/src/router-binding/scroll-restoration.tsx +15 -0
  281. package/src/router-binding/typePrimitives.ts +74 -0
  282. package/src/router-binding/useBlocker.tsx +359 -0
  283. package/src/router-binding/useCanGoBack.ts +9 -0
  284. package/src/router-binding/useLoaderData.tsx +50 -0
  285. package/src/router-binding/useLoaderDeps.tsx +46 -0
  286. package/src/router-binding/useLocation.tsx +43 -0
  287. package/src/router-binding/useMatch.tsx +111 -0
  288. package/src/router-binding/useNavigate.tsx +43 -0
  289. package/src/router-binding/useParams.tsx +72 -0
  290. package/src/router-binding/useRouteContext.ts +30 -0
  291. package/src/router-binding/useRouter.tsx +17 -0
  292. package/src/router-binding/useRouterState.tsx +50 -0
  293. package/src/router-binding/useSearch.tsx +72 -0
  294. package/src/router-binding/utils.ts +59 -0
  295. package/src/router.ts +376 -0
  296. package/src/server.ts +645 -0
  297. package/README.md +0 -3
@@ -0,0 +1,121 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ import type { RouterHistory } from '@tanstack/history';
3
+ import type {
4
+ AnyRoute,
5
+ CreateRouterFn,
6
+ RouterConstructorOptions,
7
+ TrailingSlashOption,
8
+ } from '@tanstack/router-core';
9
+ import { RouterCore } from '@tanstack/router-core';
10
+ import { isServer } from '@tanstack/router-core/isServer';
11
+ import {
12
+ installPublicContextPublication,
13
+ primeRouterFromRegistry,
14
+ } from './registryTransfer';
15
+ import type {
16
+ ErrorRouteComponent,
17
+ NotFoundRouteComponent,
18
+ RouteComponent,
19
+ } from './route';
20
+ import { getStoreFactory } from './routerStores';
21
+
22
+ declare module '@tanstack/router-core' {
23
+ export interface RouterOptionsExtensions {
24
+ /**
25
+ * The default `component` a route should use if no component is provided.
26
+ *
27
+ * @default Outlet
28
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)
29
+ */
30
+ defaultComponent?: RouteComponent;
31
+ /**
32
+ * The default `errorComponent` a route should use if no error component is provided.
33
+ *
34
+ * @default ErrorComponent
35
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)
36
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)
37
+ */
38
+ defaultErrorComponent?: ErrorRouteComponent;
39
+ /**
40
+ * The default `pendingComponent` a route should use if no pending component is provided.
41
+ *
42
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)
43
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)
44
+ */
45
+ defaultPendingComponent?: RouteComponent;
46
+ /**
47
+ * The default `notFoundComponent` a route should use if no notFound component is provided.
48
+ *
49
+ * @default NotFound
50
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)
51
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)
52
+ */
53
+ defaultNotFoundComponent?: NotFoundRouteComponent;
54
+ /**
55
+ * A component that will be used to wrap the entire router.
56
+ *
57
+ * This is useful for providing a context to the entire router.
58
+ *
59
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)
60
+ */
61
+ Wrap?: (props: { children: any }) => JSX.Element;
62
+ /**
63
+ * A component that will be used to wrap the inner contents of the router.
64
+ *
65
+ * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.
66
+ *
67
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)
68
+ */
69
+ InnerWrap?: (props: { children: any }) => JSX.Element;
70
+
71
+ /**
72
+ * The default `onCatch` handler for errors caught by the Router ErrorBoundary
73
+ *
74
+ * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)
75
+ * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)
76
+ */
77
+ defaultOnCatch?: (error: Error) => void;
78
+ }
79
+ }
80
+
81
+ export const createRouter: CreateRouterFn = options => {
82
+ return new Router(options);
83
+ };
84
+
85
+ export class Router<
86
+ in out TRouteTree extends AnyRoute,
87
+ in out TTrailingSlashOption extends TrailingSlashOption = 'never',
88
+ in out TDefaultStructuralSharingOption extends boolean = false,
89
+ in out TRouterHistory extends RouterHistory = RouterHistory,
90
+ in out TDehydrated extends Record<string, any> = Record<string, any>,
91
+ > extends RouterCore<
92
+ TRouteTree,
93
+ TTrailingSlashOption,
94
+ TDefaultStructuralSharingOption,
95
+ TRouterHistory,
96
+ TDehydrated
97
+ > {
98
+ constructor(
99
+ options: RouterConstructorOptions<
100
+ TRouteTree,
101
+ TTrailingSlashOption,
102
+ TDefaultStructuralSharingOption,
103
+ TRouterHistory,
104
+ TDehydrated
105
+ >,
106
+ ) {
107
+ super(options, getStoreFactory);
108
+ installPublicContextPublication(this);
109
+ // The hydration-claiming boot (see registryTransfer). Router creation is
110
+ // the client's natural pre-render moment: module code runs after the
111
+ // document — and the registry entries the server's RouterProvider wrote —
112
+ // have parsed, and always before hydrate(). Committing here keeps every
113
+ // store write outside the hydration render, where it would desync the
114
+ // claiming walk. Inert without entries: an SPA page has no registry, and
115
+ // a Start app transfers through its own channel (`router.serverSsr`),
116
+ // so the first missing entry falls through to unchanged behavior.
117
+ if (!(isServer ?? this.isServer)) {
118
+ primeRouterFromRegistry(this);
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,6 @@
1
+ import type { AnyRouter } from '@tanstack/router-core';
2
+ import * as Solid from 'solid-js';
3
+
4
+ export const routerContext = Solid.createContext<AnyRouter>(
5
+ null as unknown as AnyRouter,
6
+ );
@@ -0,0 +1,85 @@
1
+ import type {
2
+ GetStoreConfig,
3
+ RouterReadableStore,
4
+ RouterWritableStore,
5
+ } from '@tanstack/router-core';
6
+ import {
7
+ createNonReactiveMutableStore,
8
+ createNonReactiveReadonlyStore,
9
+ } from '@tanstack/router-core';
10
+ import { isServer } from '@tanstack/router-core/isServer';
11
+ import * as Solid from 'solid-js';
12
+
13
+ export const getStoreFactory: GetStoreConfig = opts => {
14
+ if (isServer ?? opts.isServer) {
15
+ return {
16
+ createMutableStore: createNonReactiveMutableStore,
17
+ createReadonlyStore: createNonReactiveReadonlyStore,
18
+ batch: fn => fn(),
19
+ };
20
+ }
21
+
22
+ // router-core writes stores and re-reads them synchronously mid-pipeline,
23
+ // but Solid 2 defers signal commits to its scheduler. Rather than forcing a
24
+ // full synchronous flush after every core batch (which runs all effects,
25
+ // including renders, several times per navigation), each store keeps a
26
+ // synchronous shadow of its eventual settled value and serves it until the
27
+ // scheduler catches up. The reactive graph settles on its own schedule; the
28
+ // one explicit flush per navigation is the settle point in `startTransition`.
29
+ let writeEpoch = 0;
30
+
31
+ function createSolidMutableStore<TValue>(
32
+ initialValue: TValue,
33
+ ): RouterWritableStore<TValue> {
34
+ const [signal, setSignal] = Solid.createSignal(initialValue as any);
35
+ let current = initialValue;
36
+ let dirty = false;
37
+
38
+ return {
39
+ get: () => {
40
+ const settled = signal();
41
+ // `current` is always the post-flush value, so once the signal
42
+ // catches up the shadow can retire until the next write.
43
+ if (dirty && settled === current) dirty = false;
44
+ return dirty ? current : settled;
45
+ },
46
+ set: (next: TValue | ((prev: TValue) => TValue)) => {
47
+ current =
48
+ typeof next === 'function'
49
+ ? (next as (prev: TValue) => TValue)(current)
50
+ : next;
51
+ dirty = true;
52
+ writeEpoch++;
53
+ setSignal(() => current);
54
+ },
55
+ };
56
+ }
57
+
58
+ function createSolidReadonlyStore<TValue>(
59
+ read: () => TValue,
60
+ ): RouterReadableStore<TValue> {
61
+ const memo = Solid.createRoot(() => Solid.createMemo(read));
62
+ let cache: TValue;
63
+ let cachedAt = -1;
64
+
65
+ return {
66
+ get: () => {
67
+ // The memo carries reactive subscriptions; the served value comes
68
+ // from the epoch cache so it is fresh before the scheduler settles
69
+ // and identity-stable across flushes that change nothing.
70
+ memo();
71
+ if (cachedAt !== writeEpoch) {
72
+ cache = Solid.untrack(read);
73
+ cachedAt = writeEpoch;
74
+ }
75
+ return cache;
76
+ },
77
+ };
78
+ }
79
+
80
+ return {
81
+ createMutableStore: createSolidMutableStore,
82
+ createReadonlyStore: createSolidReadonlyStore,
83
+ batch: fn => fn(),
84
+ };
85
+ };
@@ -0,0 +1,15 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ import { getScrollRestorationScriptForRouter } from '@tanstack/router-core/scroll-restoration-script';
3
+ import { ScriptOnce } from './ScriptOnce';
4
+ import { useRouter } from './useRouter';
5
+
6
+ export function ScrollRestoration(): JSX.Element {
7
+ const router = useRouter();
8
+ const script = getScrollRestorationScriptForRouter(router);
9
+
10
+ if (!script) {
11
+ return null;
12
+ }
13
+
14
+ return <ScriptOnce children={script} />;
15
+ }
@@ -0,0 +1,74 @@
1
+ import type {
2
+ AnyRouter,
3
+ Constrain,
4
+ InferFrom,
5
+ InferMaskFrom,
6
+ InferMaskTo,
7
+ InferSelected,
8
+ InferShouldThrow,
9
+ InferStrict,
10
+ InferTo,
11
+ RegisteredRouter,
12
+ } from '@tanstack/router-core';
13
+ import type { LinkComponentProps } from './link';
14
+ import type { UseParamsOptions } from './useParams';
15
+ import type { UseSearchOptions } from './useSearch';
16
+
17
+ export type ValidateLinkOptions<
18
+ TRouter extends AnyRouter = RegisteredRouter,
19
+ TOptions = unknown,
20
+ TDefaultFrom extends string = string,
21
+ TComp = 'a',
22
+ > = Constrain<
23
+ TOptions,
24
+ LinkComponentProps<
25
+ TComp,
26
+ TRouter,
27
+ InferFrom<TOptions, TDefaultFrom>,
28
+ InferTo<TOptions>,
29
+ InferMaskFrom<TOptions>,
30
+ InferMaskTo<TOptions>
31
+ >
32
+ >;
33
+
34
+ export type ValidateLinkOptionsArray<
35
+ TRouter extends AnyRouter = RegisteredRouter,
36
+ TOptions extends ReadonlyArray<any> = ReadonlyArray<unknown>,
37
+ TDefaultFrom extends string = string,
38
+ TComp = 'a',
39
+ > = {
40
+ [K in keyof TOptions]: ValidateLinkOptions<
41
+ TRouter,
42
+ TOptions[K],
43
+ TDefaultFrom,
44
+ TComp
45
+ >;
46
+ };
47
+
48
+ export type ValidateUseSearchOptions<
49
+ TOptions,
50
+ TRouter extends AnyRouter = RegisteredRouter,
51
+ > = Constrain<
52
+ TOptions,
53
+ UseSearchOptions<
54
+ TRouter,
55
+ InferFrom<TOptions>,
56
+ InferStrict<TOptions>,
57
+ InferShouldThrow<TOptions>,
58
+ InferSelected<TOptions>
59
+ >
60
+ >;
61
+
62
+ export type ValidateUseParamsOptions<
63
+ TOptions,
64
+ TRouter extends AnyRouter = RegisteredRouter,
65
+ > = Constrain<
66
+ TOptions,
67
+ UseParamsOptions<
68
+ TRouter,
69
+ InferFrom<TOptions>,
70
+ InferStrict<TOptions>,
71
+ InferShouldThrow<TOptions>,
72
+ InferSelected<TOptions>
73
+ >
74
+ >;
@@ -0,0 +1,359 @@
1
+ import type {
2
+ BlockerFnArgs,
3
+ HistoryAction,
4
+ HistoryLocation,
5
+ } from '@tanstack/history';
6
+ import type {
7
+ AnyRoute,
8
+ AnyRouter,
9
+ ParseRoute,
10
+ RegisteredRouter,
11
+ } from '@tanstack/router-core';
12
+ import * as Solid from 'solid-js';
13
+ import type { SolidNode } from './route';
14
+ import { useRouter } from './useRouter';
15
+
16
+ type ShouldBlockFnLocation<
17
+ out TRouteId,
18
+ out TFullPath,
19
+ out TAllParams,
20
+ out TFullSearchSchema,
21
+ > = {
22
+ routeId: TRouteId;
23
+ fullPath: TFullPath;
24
+ pathname: string;
25
+ params: TAllParams;
26
+ search: TFullSearchSchema;
27
+ };
28
+
29
+ type AnyShouldBlockFnLocation = ShouldBlockFnLocation<any, any, any, any>;
30
+ type MakeShouldBlockFnLocationUnion<
31
+ TRouter extends AnyRouter = RegisteredRouter,
32
+ TRoute extends AnyRoute = ParseRoute<TRouter['routeTree']>,
33
+ > = TRoute extends any
34
+ ? ShouldBlockFnLocation<
35
+ TRoute['id'],
36
+ TRoute['fullPath'],
37
+ TRoute['types']['allParams'],
38
+ TRoute['types']['fullSearchSchema']
39
+ >
40
+ : never;
41
+
42
+ type BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> =
43
+ | {
44
+ status: 'blocked';
45
+ current: MakeShouldBlockFnLocationUnion<TRouter>;
46
+ next: MakeShouldBlockFnLocationUnion<TRouter>;
47
+ action: HistoryAction;
48
+ proceed: () => void;
49
+ reset: () => void;
50
+ }
51
+ | {
52
+ status: 'idle';
53
+ current: undefined;
54
+ next: undefined;
55
+ action: undefined;
56
+ proceed: undefined;
57
+ reset: undefined;
58
+ };
59
+
60
+ type ShouldBlockFnArgs<TRouter extends AnyRouter = RegisteredRouter> = {
61
+ current: MakeShouldBlockFnLocationUnion<TRouter>;
62
+ next: MakeShouldBlockFnLocationUnion<TRouter>;
63
+ action: HistoryAction;
64
+ };
65
+
66
+ export type ShouldBlockFn<TRouter extends AnyRouter = RegisteredRouter> = (
67
+ args: ShouldBlockFnArgs<TRouter>,
68
+ ) => boolean | Promise<boolean>;
69
+ export type UseBlockerOpts<
70
+ TRouter extends AnyRouter = RegisteredRouter,
71
+ TWithResolver extends boolean = boolean,
72
+ > = {
73
+ shouldBlockFn: ShouldBlockFn<TRouter>;
74
+ enableBeforeUnload?: boolean | (() => boolean);
75
+ disabled?: boolean;
76
+ withResolver?: TWithResolver;
77
+ };
78
+
79
+ type LegacyBlockerFn = () => Promise<any> | any;
80
+ type LegacyBlockerOpts = {
81
+ blockerFn?: LegacyBlockerFn;
82
+ condition?: boolean | any;
83
+ };
84
+
85
+ function _resolveBlockerOpts(
86
+ opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,
87
+ condition?: boolean | any,
88
+ ): UseBlockerOpts {
89
+ if (opts === undefined) {
90
+ return {
91
+ shouldBlockFn: () => true,
92
+ withResolver: false,
93
+ };
94
+ }
95
+
96
+ if ('shouldBlockFn' in opts) {
97
+ return opts;
98
+ }
99
+
100
+ if (typeof opts === 'function') {
101
+ const shouldBlock = Boolean(condition ?? true);
102
+
103
+ const _customBlockerFn = async () => {
104
+ if (shouldBlock) return await opts();
105
+ return false;
106
+ };
107
+
108
+ return {
109
+ shouldBlockFn: _customBlockerFn,
110
+ enableBeforeUnload: shouldBlock,
111
+ withResolver: false,
112
+ };
113
+ }
114
+
115
+ const shouldBlock = Solid.createMemo(() => Boolean(opts.condition ?? true));
116
+
117
+ const _customBlockerFn = async () => {
118
+ if (shouldBlock() && opts.blockerFn !== undefined) {
119
+ return await opts.blockerFn();
120
+ }
121
+ return shouldBlock();
122
+ };
123
+
124
+ return {
125
+ get shouldBlockFn() {
126
+ return _customBlockerFn;
127
+ },
128
+ get enableBeforeUnload() {
129
+ return shouldBlock();
130
+ },
131
+ get withResolver() {
132
+ return opts.blockerFn === undefined;
133
+ },
134
+ };
135
+ }
136
+
137
+ export function useBlocker<
138
+ TRouter extends AnyRouter = RegisteredRouter,
139
+ TWithResolver extends boolean = false,
140
+ >(
141
+ opts: UseBlockerOpts<TRouter, TWithResolver>,
142
+ ): TWithResolver extends true ? Solid.Accessor<BlockerResolver<TRouter>> : void;
143
+
144
+ /**
145
+ * @deprecated Use the shouldBlockFn property instead
146
+ */
147
+ export function useBlocker(
148
+ blockerFnOrOpts?: LegacyBlockerOpts,
149
+ ): Solid.Accessor<BlockerResolver>;
150
+
151
+ /**
152
+ * @deprecated Use the UseBlockerOpts object syntax instead
153
+ */
154
+ export function useBlocker(
155
+ blockerFn?: LegacyBlockerFn,
156
+ condition?: boolean | any,
157
+ ): Solid.Accessor<BlockerResolver>;
158
+
159
+ export function useBlocker(
160
+ opts?: UseBlockerOpts | LegacyBlockerOpts | LegacyBlockerFn,
161
+ condition?: boolean | any,
162
+ ): Solid.Accessor<BlockerResolver> | void {
163
+ const props = Solid.merge(
164
+ {
165
+ enableBeforeUnload: true,
166
+ disabled: false,
167
+ withResolver: false,
168
+ },
169
+ _resolveBlockerOpts(opts, condition),
170
+ );
171
+
172
+ const router = useRouter();
173
+
174
+ const [resolver, setResolver] = Solid.createSignal<BlockerResolver>({
175
+ status: 'idle',
176
+ current: undefined,
177
+ next: undefined,
178
+ action: undefined,
179
+ proceed: undefined,
180
+ reset: undefined,
181
+ });
182
+
183
+ let disposeBlock: (() => void) | undefined;
184
+
185
+ Solid.createEffect(
186
+ () => props.disabled,
187
+ disabled => {
188
+ // Dispose previous blocker registration when re-running
189
+ disposeBlock?.();
190
+ disposeBlock = undefined;
191
+
192
+ if (disabled) {
193
+ return;
194
+ }
195
+
196
+ const blockerFnComposed = async (blockerFnArgs: BlockerFnArgs) => {
197
+ function getLocation(
198
+ location: HistoryLocation,
199
+ ): AnyShouldBlockFnLocation {
200
+ const parsedLocation = router.parseLocation(location);
201
+ const [, rawParams, foundRoute] = router.getMatchedRoutes(
202
+ parsedLocation.pathname,
203
+ );
204
+ if (foundRoute === undefined) {
205
+ return {
206
+ routeId: '__notFound__',
207
+ fullPath: parsedLocation.pathname,
208
+ pathname: parsedLocation.pathname,
209
+ params: rawParams,
210
+ search: parsedLocation.search,
211
+ };
212
+ }
213
+ return {
214
+ routeId: foundRoute.id,
215
+ fullPath: foundRoute.fullPath,
216
+ pathname: parsedLocation.pathname,
217
+ params: rawParams,
218
+ search: parsedLocation.search,
219
+ };
220
+ }
221
+
222
+ const current = getLocation(blockerFnArgs.currentLocation);
223
+ const next = getLocation(blockerFnArgs.nextLocation);
224
+
225
+ if (
226
+ current.routeId === '__notFound__' &&
227
+ next.routeId !== '__notFound__'
228
+ ) {
229
+ return false;
230
+ }
231
+
232
+ const shouldBlock = await props.shouldBlockFn({
233
+ action: blockerFnArgs.action,
234
+ current,
235
+ next,
236
+ });
237
+ if (!props.withResolver) {
238
+ return shouldBlock;
239
+ }
240
+
241
+ if (!shouldBlock) {
242
+ return false;
243
+ }
244
+
245
+ const promise = new Promise<boolean>(resolve => {
246
+ setResolver({
247
+ status: 'blocked',
248
+ current,
249
+ next,
250
+ action: blockerFnArgs.action,
251
+ proceed: () => resolve(false),
252
+ reset: () => resolve(true),
253
+ });
254
+ });
255
+
256
+ const canNavigateAsync = await promise;
257
+ setResolver({
258
+ status: 'idle',
259
+ current: undefined,
260
+ next: undefined,
261
+ action: undefined,
262
+ proceed: undefined,
263
+ reset: undefined,
264
+ });
265
+
266
+ return canNavigateAsync;
267
+ };
268
+
269
+ disposeBlock = router.history.block({
270
+ blockerFn: blockerFnComposed,
271
+ enableBeforeUnload: props.enableBeforeUnload,
272
+ });
273
+ },
274
+ );
275
+
276
+ // Clean up on unmount
277
+ Solid.onSettled(() => {
278
+ return () => {
279
+ disposeBlock?.();
280
+ disposeBlock = undefined;
281
+ };
282
+ });
283
+
284
+ return resolver;
285
+ }
286
+
287
+ const _resolvePromptBlockerArgs = (
288
+ props: PromptProps | LegacyPromptProps,
289
+ ): UseBlockerOpts => {
290
+ if ('shouldBlockFn' in props) {
291
+ return props;
292
+ }
293
+
294
+ const shouldBlock = Solid.createMemo(() => Boolean(props.condition ?? true));
295
+
296
+ const _customBlockerFn = async () => {
297
+ if (shouldBlock() && props.blockerFn !== undefined) {
298
+ return await props.blockerFn();
299
+ }
300
+ return shouldBlock;
301
+ };
302
+
303
+ return {
304
+ shouldBlockFn: _customBlockerFn,
305
+ get enableBeforeUnload() {
306
+ return shouldBlock();
307
+ },
308
+ get withResolver() {
309
+ return props.blockerFn === undefined;
310
+ },
311
+ };
312
+ };
313
+
314
+ interface BlockComponent {
315
+ <
316
+ TRouter extends AnyRouter = RegisteredRouter,
317
+ TWithResolver extends boolean = boolean,
318
+ >(
319
+ opts: PromptProps<TRouter, TWithResolver>,
320
+ ): SolidNode;
321
+ /**
322
+ * @deprecated Use the UseBlockerOpts property instead
323
+ */
324
+ (opts: LegacyPromptProps): SolidNode;
325
+ }
326
+
327
+ export const Block: BlockComponent = function Block(
328
+ opts: PromptProps | LegacyPromptProps,
329
+ ): SolidNode {
330
+ const propsWithChildren = {
331
+ get children() {
332
+ return opts.children;
333
+ },
334
+ };
335
+ const args = _resolvePromptBlockerArgs(opts);
336
+
337
+ const resolver = useBlocker(args);
338
+ const children = Solid.createMemo(() => {
339
+ const child = propsWithChildren.children;
340
+ if (resolver && typeof child === 'function') return child(resolver());
341
+ return child;
342
+ });
343
+
344
+ return <>{children()}</>;
345
+ };
346
+
347
+ type LegacyPromptProps = {
348
+ blockerFn?: LegacyBlockerFn;
349
+ condition?: boolean | any;
350
+ children?: SolidNode | ((params: BlockerResolver) => SolidNode);
351
+ };
352
+
353
+ type PromptProps<
354
+ TRouter extends AnyRouter = RegisteredRouter,
355
+ TWithResolver extends boolean = boolean,
356
+ TParams = TWithResolver extends true ? BlockerResolver<TRouter> : void,
357
+ > = UseBlockerOpts<TRouter, TWithResolver> & {
358
+ children?: SolidNode | ((params: TParams) => SolidNode);
359
+ };
@@ -0,0 +1,9 @@
1
+ import * as Solid from 'solid-js';
2
+ import { useRouter } from './useRouter';
3
+
4
+ export function useCanGoBack() {
5
+ const router = useRouter();
6
+ return Solid.createMemo(
7
+ () => router.stores.location.get().state.__TSR_index !== 0,
8
+ );
9
+ }