@bleedingdev/modern-js-renderer-solid 0.0.0-stage → 3.9.3-ultramodern.2

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,290 @@
1
+ import type { HeadTag } from '@solidjs/web';
2
+ import type {
3
+ AssetCrossOriginConfig,
4
+ RouterManagedTag,
5
+ } from '@tanstack/router-core';
6
+ import {
7
+ _getAssetMatches,
8
+ appendUniqueUserTags,
9
+ escapeHtml,
10
+ getAssetCrossOrigin,
11
+ getScriptPreloadAttrs,
12
+ resolveManifestCssLink,
13
+ } from '@tanstack/router-core';
14
+ import { isServer } from '@tanstack/router-core/isServer';
15
+ import * as Solid from 'solid-js';
16
+ import { useRouter } from './useRouter';
17
+
18
+ /**
19
+ * Build the head/link/meta/script tags from the renderable presented prefix.
20
+ * Used internally by `HeadContent`.
21
+ */
22
+ export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
23
+ const router = useRouter();
24
+ const nonce = router.options.ssr?.nonce;
25
+ const activeMatches = Solid.createMemo(() =>
26
+ _getAssetMatches(router.stores.matches.get()),
27
+ );
28
+ const routeMeta = Solid.createMemo(() =>
29
+ activeMatches()
30
+ .map(match => match.meta)
31
+ .filter(meta => meta !== undefined),
32
+ );
33
+
34
+ const meta: Solid.Accessor<Array<RouterManagedTag>> = Solid.createMemo(() => {
35
+ const resultMeta: Array<RouterManagedTag> = [];
36
+ const metaByAttribute: Record<string, true> = {};
37
+ let title: RouterManagedTag | undefined;
38
+ const routeMetasArray = routeMeta();
39
+ for (let i = routeMetasArray.length - 1; i >= 0; i--) {
40
+ const metas = routeMetasArray[i]!;
41
+ for (let j = metas.length - 1; j >= 0; j--) {
42
+ const m = metas[j];
43
+ if (!m) {
44
+ continue;
45
+ }
46
+
47
+ if (m.title) {
48
+ if (!title) {
49
+ title = {
50
+ tag: 'title',
51
+ children: m.title,
52
+ };
53
+ }
54
+ } else if ('script:ld+json' in m) {
55
+ try {
56
+ const json = JSON.stringify(m['script:ld+json']);
57
+ resultMeta.push({
58
+ tag: 'script',
59
+ attrs: {
60
+ type: 'application/ld+json',
61
+ },
62
+ children: escapeHtml(json),
63
+ });
64
+ } catch {
65
+ // Skip invalid JSON-LD objects.
66
+ }
67
+ } else {
68
+ const attribute = m.name ?? m.property;
69
+ if (attribute) {
70
+ if (metaByAttribute[attribute]) {
71
+ continue;
72
+ }
73
+ metaByAttribute[attribute] = true;
74
+ }
75
+
76
+ resultMeta.push({
77
+ tag: 'meta',
78
+ attrs: {
79
+ ...m,
80
+ nonce,
81
+ },
82
+ });
83
+ }
84
+ }
85
+ }
86
+
87
+ if (title) {
88
+ resultMeta.push(title);
89
+ }
90
+
91
+ if (nonce) {
92
+ resultMeta.push({
93
+ tag: 'meta',
94
+ attrs: {
95
+ property: 'csp-nonce',
96
+ content: nonce,
97
+ },
98
+ });
99
+ }
100
+ resultMeta.reverse();
101
+ return resultMeta;
102
+ });
103
+
104
+ const links = Solid.createMemo(() => {
105
+ return activeMatches()
106
+ .flatMap(match => match.links ?? [])
107
+ .filter(link => link !== undefined)
108
+ .map(link => ({
109
+ tag: 'link',
110
+ attrs: {
111
+ ...link,
112
+ nonce,
113
+ },
114
+ })) satisfies Array<RouterManagedTag>;
115
+ });
116
+
117
+ const retainedManifestCssTags = new Map<string, RouterManagedTag>();
118
+ const manifestCssTags = Solid.createMemo(() => {
119
+ const manifest = router.ssr?.manifest;
120
+ const tags: Array<RouterManagedTag> = [];
121
+
122
+ if (!manifest) {
123
+ return tags;
124
+ }
125
+
126
+ for (const match of activeMatches()) {
127
+ for (const link of manifest.routes[match.routeId]?.css ?? []) {
128
+ const resolvedLink = resolveManifestCssLink(link);
129
+ const tag: RouterManagedTag = {
130
+ tag: 'link',
131
+ attrs: {
132
+ rel: 'stylesheet',
133
+ ...resolvedLink,
134
+ crossOrigin:
135
+ getAssetCrossOrigin(assetCrossOrigin, 'stylesheet') ??
136
+ resolvedLink.crossOrigin,
137
+ nonce,
138
+ },
139
+ };
140
+ const key = JSON.stringify(tag);
141
+ if (!retainedManifestCssTags.has(key)) {
142
+ retainedManifestCssTags.set(key, tag);
143
+ }
144
+ }
145
+ }
146
+
147
+ // Lazy modules are cached and do not reinsert their CSS when revisited.
148
+ tags.push(...retainedManifestCssTags.values());
149
+
150
+ if (manifest.inlineStyle) {
151
+ tags.push({
152
+ tag: 'style',
153
+ attrs: {
154
+ ...manifest.inlineStyle.attrs,
155
+ nonce,
156
+ },
157
+ children: manifest.inlineStyle.children,
158
+ inlineCss: true,
159
+ });
160
+ }
161
+
162
+ return tags;
163
+ });
164
+
165
+ const preloadLinks = Solid.createMemo(() => {
166
+ const manifest = router.ssr?.manifest;
167
+ const tags: Array<RouterManagedTag> = [];
168
+ for (const match of activeMatches()) {
169
+ for (const preload of manifest?.routes[match.routeId]?.preloads ?? []) {
170
+ if (!preload) {
171
+ continue;
172
+ }
173
+ tags.push({
174
+ tag: 'link',
175
+ attrs: {
176
+ ...getScriptPreloadAttrs(manifest, preload, assetCrossOrigin),
177
+ nonce,
178
+ },
179
+ });
180
+ }
181
+ }
182
+ return tags;
183
+ });
184
+
185
+ const styles = Solid.createMemo(() => {
186
+ return activeMatches()
187
+ .flatMap(match => match.styles ?? [])
188
+ .filter(style => style !== undefined)
189
+ .map(({ children, ...attrs }) => ({
190
+ tag: 'style',
191
+ attrs: {
192
+ ...attrs,
193
+ nonce,
194
+ },
195
+ children: children as string | undefined,
196
+ })) satisfies Array<RouterManagedTag>;
197
+ });
198
+
199
+ const headScripts = Solid.createMemo(() => {
200
+ return activeMatches()
201
+ .flatMap(match => match.headScripts ?? [])
202
+ .filter(script => script !== undefined)
203
+ .map(({ children, ...attrs }) => ({
204
+ tag: 'script',
205
+ attrs: {
206
+ ...attrs,
207
+ nonce,
208
+ },
209
+ children: children as string | undefined,
210
+ })) satisfies Array<RouterManagedTag>;
211
+ });
212
+
213
+ return Solid.createMemo(() => {
214
+ const next: Array<RouterManagedTag> = [];
215
+ appendUniqueUserTags(next, meta());
216
+ appendUniqueUserTags(next, links());
217
+ next.push(...manifestCssTags());
218
+ next.push(...preloadLinks());
219
+ appendUniqueUserTags(next, styles());
220
+ appendUniqueUserTags(next, headScripts());
221
+ return next;
222
+ });
223
+ };
224
+
225
+ const INLINE_CSS_HYDRATION_ATTR = 'data-tsr-inline-css';
226
+
227
+ /**
228
+ * Convert the router-managed tags into head registry descriptors for
229
+ * `useHead`. Pure data mapping — it is evaluated inside the registry's own
230
+ * flush boundary (server) / effect (client), so it must not allocate
231
+ * reactive owners.
232
+ */
233
+ export function toHeadTags(tags: Array<RouterManagedTag>): Array<HeadTag> {
234
+ return tags.map(toHeadTag);
235
+ }
236
+
237
+ function toHeadTag(t: RouterManagedTag): HeadTag {
238
+ const props: Record<string, any> = { ...t.attrs };
239
+ let children: string | undefined = t.children;
240
+
241
+ if (
242
+ t.tag === 'style' &&
243
+ t.inlineCss &&
244
+ (process.env.TSS_INLINE_CSS_ENABLED === 'true' ||
245
+ (process.env.TSS_INLINE_CSS_ENABLED === undefined && isServer))
246
+ ) {
247
+ // Mark the inline-CSS style so the client can find it again: the
248
+ // serialized manifest omits the CSS text, so on the client the tag
249
+ // arrives with `children === undefined` and the text is recovered from
250
+ // the server-rendered element.
251
+ props[INLINE_CSS_HYDRATION_ATTR] = '';
252
+ }
253
+
254
+ if (
255
+ t.tag === 'style' &&
256
+ t.inlineCss &&
257
+ children === undefined &&
258
+ typeof document !== 'undefined'
259
+ ) {
260
+ children =
261
+ document.querySelector<HTMLStyleElement>(
262
+ `style[${INLINE_CSS_HYDRATION_ATTR}]`,
263
+ )?.textContent ?? '';
264
+ }
265
+
266
+ if (children !== undefined) {
267
+ props.children = children;
268
+ }
269
+
270
+ const headTag: HeadTag = { tag: t.tag, props };
271
+
272
+ // Inline scripts and styles have no natural registry identity: the
273
+ // registry assigns them per-runtime unique ids, which can never match
274
+ // between server and client, so hydration would append a client copy
275
+ // next to the server-rendered one. A stable content-derived key gives
276
+ // both runtimes the same identity to reconcile on.
277
+ if (t.tag === 'style' || (t.tag === 'script' && props.src === undefined)) {
278
+ headTag.key = `tsr-${hashString(t.tag + JSON.stringify(props))}`;
279
+ }
280
+
281
+ return headTag;
282
+ }
283
+
284
+ function hashString(s: string): string {
285
+ let h = 5381;
286
+ for (let i = 0; i < s.length; i++) {
287
+ h = ((h << 5) + h + s.charCodeAt(i)) | 0;
288
+ }
289
+ return (h >>> 0).toString(36);
290
+ }
@@ -0,0 +1,9 @@
1
+ import type { HistoryLocation } from '@tanstack/history';
2
+
3
+ declare module '@tanstack/history' {
4
+ interface HistoryState {
5
+ __tempLocation?: HistoryLocation;
6
+ __tempKey?: string;
7
+ __hashScrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
8
+ }
9
+ }
@@ -0,0 +1,318 @@
1
+ export type {
2
+ BlockerFn,
3
+ HistoryLocation,
4
+ HistoryState,
5
+ ParsedPath,
6
+ RouterHistory,
7
+ } from '@tanstack/history';
8
+ export {
9
+ createBrowserHistory,
10
+ createHashHistory,
11
+ createHistory,
12
+ createMemoryHistory,
13
+ } from '@tanstack/history';
14
+ export type {
15
+ AbsoluteToPath,
16
+ ActiveOptions,
17
+ AllContext,
18
+ AllLoaderData,
19
+ AllParams,
20
+ AnyContext,
21
+ AnyPathParams,
22
+ AnyRedirect,
23
+ AnyRoute,
24
+ AnyRouteMatch,
25
+ AnyRouter,
26
+ AnyRouterWithContext,
27
+ AnyRouteWithContext,
28
+ AnySchema,
29
+ AnySerializationAdapter,
30
+ AnyValidator,
31
+ AnyValidatorAdapter,
32
+ AnyValidatorFn,
33
+ AnyValidatorObj,
34
+ Assign,
35
+ BaseRouteOptions,
36
+ BeforeLoadContextOptions,
37
+ BeforeLoadContextParameter,
38
+ BuildLocationFn,
39
+ BuildNextOptions,
40
+ CommitLocationOptions,
41
+ Constrain,
42
+ ContextAsyncReturnType,
43
+ ContextOptions,
44
+ ContextReturnType,
45
+ ControllablePromise,
46
+ ControlledPromise,
47
+ CreateFileRoute,
48
+ CreateLazyFileRoute,
49
+ DefaultValidator,
50
+ DeferredPromise,
51
+ DeferredPromiseState,
52
+ ErrorComponentProps,
53
+ ErrorRouteProps,
54
+ Expand,
55
+ FileBaseRouteOptions,
56
+ FileRoutesByPath,
57
+ FileRouteTypes,
58
+ FullSearchSchema,
59
+ FullSearchSchemaInput,
60
+ FullSearchSchemaOption,
61
+ InferAllContext,
62
+ InferAllParams,
63
+ InferDescendantToPaths,
64
+ InferFrom,
65
+ InferFullSearchSchema,
66
+ InferFullSearchSchemaInput,
67
+ InferMaskFrom,
68
+ InferMaskTo,
69
+ InferSelected,
70
+ InferShouldThrow,
71
+ InferStrict,
72
+ InferTo,
73
+ IntersectAssign,
74
+ LazyRouteOptions,
75
+ LinkOptions,
76
+ ListenerFn,
77
+ LoaderFnContext,
78
+ LocationRewrite,
79
+ LocationRewriteFunction,
80
+ LooseAsyncReturnType,
81
+ LooseReturnType,
82
+ MakeOptionalPathParams,
83
+ MakeRemountDepsOptionsUnion,
84
+ MakeRouteMatch,
85
+ MakeRouteMatchUnion,
86
+ Manifest,
87
+ MatchLocation,
88
+ MatchRouteOptions,
89
+ MergeAll,
90
+ MetaDescriptor,
91
+ NavigateFn,
92
+ NavigateOptions,
93
+ NotFoundError,
94
+ NotFoundRouteProps,
95
+ ParamsOptions,
96
+ ParsedLocation,
97
+ ParseParamsFn,
98
+ ParseRoute,
99
+ PathParamOptions,
100
+ PreloadableObj,
101
+ Redirect,
102
+ RedirectOptions,
103
+ Register,
104
+ RegisteredRouter,
105
+ RelativeToCurrentPath,
106
+ RelativeToParentPath,
107
+ RelativeToPath,
108
+ RelativeToPathAutoComplete,
109
+ RemountDepsOptions,
110
+ RemoveLeadingSlashes,
111
+ RemoveTrailingSlashes,
112
+ ResolveAllContext,
113
+ ResolveAllParamsFromParent,
114
+ ResolvedRedirect,
115
+ ResolveFullPath,
116
+ ResolveFullSearchSchema,
117
+ ResolveFullSearchSchemaInput,
118
+ ResolveId,
119
+ ResolveLoaderData,
120
+ ResolveOptionalParams,
121
+ ResolveParams,
122
+ ResolveRelativePath,
123
+ ResolveRequiredParams,
124
+ ResolveRoute,
125
+ ResolveRouteContext,
126
+ ResolveSearchValidatorInput,
127
+ ResolveSearchValidatorInputFn,
128
+ ResolveValidatorInput,
129
+ ResolveValidatorInputFn,
130
+ ResolveValidatorOutput,
131
+ ResolveValidatorOutputFn,
132
+ RootRouteId,
133
+ RootRouteOptions,
134
+ RouteById,
135
+ RouteByPath,
136
+ RouteConstraints,
137
+ RouteContext,
138
+ RouteContextFn,
139
+ RouteContextOptions,
140
+ RouteContextParameter,
141
+ RouteIds,
142
+ RouteLinkEntry,
143
+ RouteLoaderFn,
144
+ RouteMask,
145
+ RouteMatch,
146
+ RouteOptions,
147
+ RoutePathOptions,
148
+ RoutePathOptionsIntersection,
149
+ RoutePaths,
150
+ RouterConstructorOptions,
151
+ RouterContextOptions,
152
+ RouterEvent,
153
+ RouterEvents,
154
+ RouterListener,
155
+ RouterManagedTag,
156
+ RouterOptions,
157
+ RouterState,
158
+ RoutesById,
159
+ RoutesByPath,
160
+ SearchFilter,
161
+ SearchParamOptions,
162
+ SearchParser,
163
+ SearchSchemaInput,
164
+ SearchSerializer,
165
+ SerializableExtensions,
166
+ SerializationAdapter,
167
+ StaticDataRouteOption,
168
+ StringifyParamsFn,
169
+ ToMaskOptions,
170
+ ToOptions,
171
+ ToPathOption,
172
+ ToSubOptions,
173
+ TrailingSlashOption,
174
+ TrimPath,
175
+ TrimPathLeft,
176
+ TrimPathRight,
177
+ UpdatableRouteOptions,
178
+ UpdatableStaticRouteOption,
179
+ UseNavigateResult,
180
+ ValidateFromPath,
181
+ ValidateId,
182
+ ValidateNavigateOptions,
183
+ ValidateNavigateOptionsArray,
184
+ ValidateParams,
185
+ ValidateRedirectOptions,
186
+ ValidateRedirectOptionsArray,
187
+ ValidateSearch,
188
+ ValidateToPath,
189
+ ValidateUseParamsResult,
190
+ ValidateUseSearchResult,
191
+ Validator,
192
+ ValidatorAdapter,
193
+ ValidatorFn,
194
+ ValidatorObj,
195
+ } from '@tanstack/router-core';
196
+ export {
197
+ cleanPath,
198
+ composeRewrites,
199
+ createControlledPromise,
200
+ createSerializationAdapter,
201
+ DEFAULT_PROTOCOL_ALLOWLIST,
202
+ deepEqual,
203
+ defaultParseSearch,
204
+ defaultStringifySearch,
205
+ defer,
206
+ functionalUpdate,
207
+ interpolatePath,
208
+ isMatch,
209
+ isNotFound,
210
+ isRedirect,
211
+ joinPaths,
212
+ lazyFn,
213
+ notFound,
214
+ parseSearchWith,
215
+ redirect,
216
+ replaceEqualDeep,
217
+ resolvePath,
218
+ retainSearchParams,
219
+ rootRouteId,
220
+ SearchParamError,
221
+ stringifySearchWith,
222
+ stripSearchParams,
223
+ trimPath,
224
+ trimPathLeft,
225
+ trimPathRight,
226
+ } from '@tanstack/router-core';
227
+ export { Asset } from './Asset';
228
+ export type { AwaitOptions } from './awaited';
229
+ export { Await, useAwaited } from './awaited';
230
+ export { CatchBoundary, ErrorComponent } from './CatchBoundary';
231
+ export { ClientOnly, useHydrated } from './ClientOnly';
232
+ export {
233
+ createFileRoute,
234
+ createLazyFileRoute,
235
+ createLazyRoute,
236
+ FileRoute,
237
+ FileRouteLoader,
238
+ LazyRoute,
239
+ } from './fileRoute';
240
+ export { HeadContent } from './HeadContent';
241
+ export { useTags } from './headContentUtils';
242
+ export * from './history';
243
+ export { lazyRouteComponent } from './lazyRouteComponent';
244
+ export type {
245
+ ActiveLinkOptions,
246
+ CreateLinkProps,
247
+ LinkComponent,
248
+ LinkComponentProps,
249
+ LinkProps,
250
+ UseLinkPropsOptions,
251
+ } from './link';
252
+ export { createLink, Link, linkOptions, useLinkProps } from './link';
253
+ export { Match, Outlet } from './Match';
254
+ export type { MakeMatchRouteOptions, UseMatchRouteOptions } from './Matches';
255
+ export {
256
+ Matches,
257
+ MatchRoute,
258
+ useChildMatches,
259
+ useMatches,
260
+ useMatchRoute,
261
+ useParentMatches,
262
+ } from './Matches';
263
+ export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
264
+ export type { PublicMatchError, PublicSnapshotOwner } from './publicMatchData';
265
+ export {
266
+ preparePublicContextData,
267
+ preparePublicLoaderData,
268
+ preparePublicMatchError,
269
+ } from './publicMatchData';
270
+ export type { RouterProps } from './RouterProvider';
271
+ export { RouterContextProvider, RouterProvider } from './RouterProvider';
272
+ export { prepareRouterMatchTransfer } from './registryTransfer';
273
+ export type {
274
+ AnyRootRoute,
275
+ AsyncRouteComponent,
276
+ ErrorRouteComponent,
277
+ NotFoundRouteComponent,
278
+ RouteComponent,
279
+ SolidNode,
280
+ } from './route';
281
+ export {
282
+ createRootRoute,
283
+ createRootRouteWithContext,
284
+ createRoute,
285
+ createRouteMask,
286
+ getRouteApi,
287
+ NotFoundRoute,
288
+ RootRoute,
289
+ Route,
290
+ RouteApi,
291
+ rootRouteWithContext,
292
+ } from './route';
293
+ export { createRouter, Router } from './router';
294
+ export { ScriptOnce } from './ScriptOnce';
295
+ export { Scripts } from './Scripts';
296
+ export {
297
+ ScrollRestoration,
298
+ useElementScrollRestoration,
299
+ } from './ScrollRestoration';
300
+ export type {
301
+ ValidateLinkOptions,
302
+ ValidateLinkOptionsArray,
303
+ ValidateUseParamsOptions,
304
+ ValidateUseSearchOptions,
305
+ } from './typePrimitives';
306
+ export type { ShouldBlockFn, UseBlockerOpts } from './useBlocker';
307
+ export { Block, useBlocker } from './useBlocker';
308
+ export { useCanGoBack } from './useCanGoBack';
309
+ export { useLoaderData } from './useLoaderData';
310
+ export { useLoaderDeps } from './useLoaderDeps';
311
+ export { useLocation } from './useLocation';
312
+ export { useMatch } from './useMatch';
313
+ export { Navigate, useNavigate } from './useNavigate';
314
+ export { useParams } from './useParams';
315
+ export { useRouteContext } from './useRouteContext';
316
+ export { useRouter } from './useRouter';
317
+ export { useRouterState } from './useRouterState';
318
+ export { useSearch } from './useSearch';
@@ -0,0 +1,70 @@
1
+ import { isModuleNotFoundError } from '@tanstack/router-core';
2
+ import { lazy } from 'solid-js';
3
+ import type { AsyncRouteComponent } from './route';
4
+
5
+ export function lazyRouteComponent<
6
+ T extends Record<string, any>,
7
+ TKey extends keyof T = 'default',
8
+ >(
9
+ importer: () => Promise<T>,
10
+ exportName?: TKey,
11
+ ): T[TKey] extends (props: infer TProps) => any
12
+ ? AsyncRouteComponent<TProps>
13
+ : never {
14
+ const resolvedExport = (exportName as string | undefined) ?? 'default';
15
+ let preloadPromise: Promise<void> | undefined;
16
+
17
+ // lazy()'s { export } option names which export of the resolved module is
18
+ // the component — a call-site literal available on both runtimes, so the
19
+ // module namespace passes through untouched ($$moduleUrl included, which
20
+ // is how server-side lazy() resolves the route chunk's client assets) and
21
+ // hydration claims the component synchronously from the preloaded module.
22
+ const comp = lazy(
23
+ () =>
24
+ importer().catch(error => {
25
+ // If the load fails due to module not found, it may mean a new
26
+ // version of the build was deployed and the user's browser is still
27
+ // using an old version with an outdated URL to the lazy module. In
28
+ // that case, attempt one window refresh to get the latest — gated
29
+ // through sessionStorage so some other issue can't cause a reload
30
+ // loop.
31
+ if (
32
+ isModuleNotFoundError(error) &&
33
+ error instanceof Error &&
34
+ typeof window !== 'undefined' &&
35
+ typeof sessionStorage !== 'undefined'
36
+ ) {
37
+ const storageKey = `tanstack_router_reload:${error.message}`;
38
+ if (!sessionStorage.getItem(storageKey)) {
39
+ sessionStorage.setItem(storageKey, '1');
40
+ window.location.reload();
41
+
42
+ // The page is reloading; render nothing in the meantime.
43
+ return { [resolvedExport]: () => null } as unknown as T;
44
+ }
45
+ }
46
+
47
+ throw error;
48
+ }),
49
+ { export: resolvedExport },
50
+ );
51
+
52
+ const load = comp.preload;
53
+
54
+ // TanStack's preload contract: a memoized Promise<void> that never
55
+ // rejects. lazy() does not cache rejected module promises, so a failed
56
+ // download is retried by the next preload or render.
57
+ comp.preload = () => {
58
+ if (!preloadPromise) {
59
+ preloadPromise = load().then(
60
+ () => {},
61
+ () => {
62
+ preloadPromise = undefined;
63
+ },
64
+ );
65
+ }
66
+ return preloadPromise;
67
+ };
68
+
69
+ return comp as any;
70
+ }