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

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 (301) hide show
  1. package/dist/esm/actions.js +282 -0
  2. package/dist/esm/application-router.js +30 -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 +24 -0
  6. package/dist/esm/federation-context.js +25 -0
  7. package/dist/esm/federation-ssr.js +92 -0
  8. package/dist/esm/federation.js +87 -0
  9. package/dist/esm/i18n/I18nProvider.js +33 -0
  10. package/dist/esm/i18n/LocalizedLink.js +52 -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 +151 -0
  19. package/dist/esm/route-data-error.js +108 -0
  20. package/dist/esm/router-binding/Asset.js +202 -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 +124 -0
  27. package/dist/esm/router-binding/PROVENANCE.json +94 -0
  28. package/dist/esm/router-binding/RouterProvider.js +52 -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 +109 -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 +168 -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 +387 -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 +223 -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 +14 -0
  50. package/dist/esm/router-binding/routerContext.js +3 -0
  51. package/dist/esm/router-binding/routerOptions.js +0 -0
  52. package/dist/esm/router-binding/routerStores.js +50 -0
  53. package/dist/esm/router-binding/scroll-restoration.js +13 -0
  54. package/dist/esm/router-binding/typePrimitives.js +0 -0
  55. package/dist/esm/router-binding/useBlocker.js +152 -0
  56. package/dist/esm/router-binding/useCanGoBack.js +7 -0
  57. package/dist/esm/router-binding/useLoaderData.js +8 -0
  58. package/dist/esm/router-binding/useLoaderDeps.js +8 -0
  59. package/dist/esm/router-binding/useLocation.js +14 -0
  60. package/dist/esm/router-binding/useMatch.js +28 -0
  61. package/dist/esm/router-binding/useNavigate.js +25 -0
  62. package/dist/esm/router-binding/useParams.js +11 -0
  63. package/dist/esm/router-binding/useRouteContext.js +8 -0
  64. package/dist/esm/router-binding/useRouter.js +10 -0
  65. package/dist/esm/router-binding/useRouterState.js +19 -0
  66. package/dist/esm/router-binding/useSearch.js +11 -0
  67. package/dist/esm/router-binding/utils.js +23 -0
  68. package/dist/esm/router.js +187 -0
  69. package/dist/esm-node/actions.js +263 -0
  70. package/dist/esm-node/application-router.js +30 -0
  71. package/dist/esm-node/client.js +49 -0
  72. package/dist/esm-node/entry-application.js +110 -0
  73. package/dist/esm-node/entry-client.js +24 -0
  74. package/dist/esm-node/entry-server.js +47 -0
  75. package/dist/esm-node/federation-context.js +25 -0
  76. package/dist/esm-node/federation-ssr.js +92 -0
  77. package/dist/esm-node/federation.js +87 -0
  78. package/dist/esm-node/i18n/I18nProvider.js +42 -0
  79. package/dist/esm-node/i18n/LocalizedLink.js +88 -0
  80. package/dist/esm-node/i18n/context.js +3 -0
  81. package/dist/esm-node/i18n/index.js +8 -0
  82. package/dist/esm-node/i18n/languageSync.js +50 -0
  83. package/dist/esm-node/i18n/types.js +1 -0
  84. package/dist/esm-node/i18n/useI18n.js +74 -0
  85. package/dist/esm-node/index.js +58 -0
  86. package/dist/esm-node/manifest.js +150 -0
  87. package/dist/esm-node/native-promise-serialization.js +113 -0
  88. package/dist/esm-node/plugin/compiler.js +209 -0
  89. package/dist/esm-node/plugin/create.js +236 -0
  90. package/dist/esm-node/plugin/index.js +70 -0
  91. package/dist/esm-node/plugin/profile.js +51 -0
  92. package/dist/esm-node/route-completion.js +161 -0
  93. package/dist/esm-node/route-data-error.js +108 -0
  94. package/dist/esm-node/router-binding/Asset.js +172 -0
  95. package/dist/esm-node/router-binding/CatchBoundary.js +136 -0
  96. package/dist/esm-node/router-binding/ClientOnly.js +46 -0
  97. package/dist/esm-node/router-binding/HeadContent.js +8 -0
  98. package/dist/esm-node/router-binding/LICENSE +21 -0
  99. package/dist/esm-node/router-binding/Match.js +660 -0
  100. package/dist/esm-node/router-binding/Matches.js +161 -0
  101. package/dist/esm-node/router-binding/PROVENANCE.json +94 -0
  102. package/dist/esm-node/router-binding/RouterProvider.js +88 -0
  103. package/dist/esm-node/router-binding/SafeFragment.js +5 -0
  104. package/dist/esm-node/router-binding/ScriptOnce.js +16 -0
  105. package/dist/esm-node/router-binding/Scripts.js +49 -0
  106. package/dist/esm-node/router-binding/ScrollRestoration.js +16 -0
  107. package/dist/esm-node/router-binding/Transitioner.js +109 -0
  108. package/dist/esm-node/router-binding/awaited.js +75 -0
  109. package/dist/esm-node/router-binding/fileRoute.js +83 -0
  110. package/dist/esm-node/router-binding/flightData.js +23 -0
  111. package/dist/esm-node/router-binding/headContentUtils.js +168 -0
  112. package/dist/esm-node/router-binding/history.js +1 -0
  113. package/dist/esm-node/router-binding/index.js +35 -0
  114. package/dist/esm-node/router-binding/lazyRouteComponent.js +30 -0
  115. package/dist/esm-node/router-binding/link.js +399 -0
  116. package/dist/esm-node/router-binding/matchContext.js +7 -0
  117. package/dist/esm-node/router-binding/nonRouteComponentContext.js +22 -0
  118. package/dist/esm-node/router-binding/not-found.js +49 -0
  119. package/dist/esm-node/router-binding/publicMatchData.js +447 -0
  120. package/dist/esm-node/router-binding/registryTransfer.js +223 -0
  121. package/dist/esm-node/router-binding/renderRouteNotFound.js +22 -0
  122. package/dist/esm-node/router-binding/route.js +162 -0
  123. package/dist/esm-node/router-binding/router.js +14 -0
  124. package/dist/esm-node/router-binding/routerContext.js +3 -0
  125. package/dist/esm-node/router-binding/routerOptions.js +1 -0
  126. package/dist/esm-node/router-binding/routerStores.js +50 -0
  127. package/dist/esm-node/router-binding/scroll-restoration.js +12 -0
  128. package/dist/esm-node/router-binding/typePrimitives.js +1 -0
  129. package/dist/esm-node/router-binding/useBlocker.js +152 -0
  130. package/dist/esm-node/router-binding/useCanGoBack.js +7 -0
  131. package/dist/esm-node/router-binding/useLoaderData.js +8 -0
  132. package/dist/esm-node/router-binding/useLoaderDeps.js +8 -0
  133. package/dist/esm-node/router-binding/useLocation.js +14 -0
  134. package/dist/esm-node/router-binding/useMatch.js +28 -0
  135. package/dist/esm-node/router-binding/useNavigate.js +25 -0
  136. package/dist/esm-node/router-binding/useParams.js +11 -0
  137. package/dist/esm-node/router-binding/useRouteContext.js +8 -0
  138. package/dist/esm-node/router-binding/useRouter.js +10 -0
  139. package/dist/esm-node/router-binding/useRouterState.js +19 -0
  140. package/dist/esm-node/router-binding/useSearch.js +11 -0
  141. package/dist/esm-node/router-binding/utils.js +23 -0
  142. package/dist/esm-node/router.js +187 -0
  143. package/dist/esm-node/server.js +396 -0
  144. package/dist/types/actions.d.ts +45 -0
  145. package/dist/types/application-router.d.ts +5 -0
  146. package/dist/types/client.d.ts +23 -0
  147. package/dist/types/entry-application.d.ts +10 -0
  148. package/dist/types/entry-client.d.ts +5 -0
  149. package/dist/types/entry-server.d.ts +5 -0
  150. package/dist/types/federation-context.d.ts +16 -0
  151. package/dist/types/federation-ssr.d.ts +19 -0
  152. package/dist/types/federation.d.ts +30 -0
  153. package/dist/types/i18n/I18nProvider.d.ts +21 -0
  154. package/dist/types/i18n/LocalizedLink.d.ts +15 -0
  155. package/dist/types/i18n/context.d.ts +11 -0
  156. package/dist/types/i18n/index.d.ts +9 -0
  157. package/dist/types/i18n/languageSync.d.ts +31 -0
  158. package/dist/types/i18n/types.d.ts +33 -0
  159. package/dist/types/i18n/useI18n.d.ts +24 -0
  160. package/dist/types/index.d.ts +41 -0
  161. package/dist/types/manifest.d.ts +55 -0
  162. package/dist/types/native-promise-serialization.d.ts +9 -0
  163. package/dist/types/plugin/compiler.d.ts +6 -0
  164. package/dist/types/plugin/create.d.ts +21 -0
  165. package/dist/types/plugin/index.d.ts +3 -0
  166. package/dist/types/plugin/lazy-modules.d.cts +15 -0
  167. package/dist/types/plugin/preserve-import-loader.d.cts +3 -0
  168. package/dist/types/plugin/profile.d.ts +2 -0
  169. package/dist/types/plugin/solid-loader.d.cts +2 -0
  170. package/dist/types/plugin/svg-component-template.d.cts +6 -0
  171. package/dist/types/route-completion.d.ts +21 -0
  172. package/dist/types/route-data-error.d.ts +17 -0
  173. package/dist/types/router-binding/Asset.d.ts +3 -0
  174. package/dist/types/router-binding/CatchBoundary.d.ts +13 -0
  175. package/dist/types/router-binding/ClientOnly.d.ts +31 -0
  176. package/dist/types/router-binding/HeadContent.d.ts +13 -0
  177. package/dist/types/router-binding/Match.d.ts +6 -0
  178. package/dist/types/router-binding/Matches.d.ts +26 -0
  179. package/dist/types/router-binding/RouterProvider.d.ts +11 -0
  180. package/dist/types/router-binding/SafeFragment.d.ts +2 -0
  181. package/dist/types/router-binding/ScriptOnce.d.ts +6 -0
  182. package/dist/types/router-binding/Scripts.d.ts +2 -0
  183. package/dist/types/router-binding/ScrollRestoration.d.ts +14 -0
  184. package/dist/types/router-binding/Transitioner.d.ts +2 -0
  185. package/dist/types/router-binding/awaited.d.ts +11 -0
  186. package/dist/types/router-binding/fileRoute.d.ts +54 -0
  187. package/dist/types/router-binding/flightData.d.ts +38 -0
  188. package/dist/types/router-binding/headContentUtils.d.ts +15 -0
  189. package/dist/types/router-binding/history.d.ts +8 -0
  190. package/dist/types/router-binding/index.d.ts +46 -0
  191. package/dist/types/router-binding/lazyRouteComponent.d.ts +2 -0
  192. package/dist/types/router-binding/link.d.ts +43 -0
  193. package/dist/types/router-binding/matchContext.d.ts +7 -0
  194. package/dist/types/router-binding/nonRouteComponentContext.d.ts +5 -0
  195. package/dist/types/router-binding/not-found.d.ts +11 -0
  196. package/dist/types/router-binding/publicMatchData.d.ts +19 -0
  197. package/dist/types/router-binding/registryTransfer.d.ts +49 -0
  198. package/dist/types/router-binding/renderRouteNotFound.d.ts +11 -0
  199. package/dist/types/router-binding/route.d.ts +105 -0
  200. package/dist/types/router-binding/router.d.ts +70 -0
  201. package/dist/types/router-binding/routerContext.d.ts +3 -0
  202. package/dist/types/router-binding/routerOptions.d.ts +6 -0
  203. package/dist/types/router-binding/routerStores.d.ts +2 -0
  204. package/dist/types/router-binding/scroll-restoration.d.ts +2 -0
  205. package/dist/types/router-binding/typePrimitives.d.ts +10 -0
  206. package/dist/types/router-binding/useBlocker.d.ts +70 -0
  207. package/dist/types/router-binding/useCanGoBack.d.ts +2 -0
  208. package/dist/types/router-binding/useLoaderData.d.ts +8 -0
  209. package/dist/types/router-binding/useLoaderDeps.d.ts +8 -0
  210. package/dist/types/router-binding/useLocation.d.ts +7 -0
  211. package/dist/types/router-binding/useMatch.d.ts +10 -0
  212. package/dist/types/router-binding/useNavigate.d.ts +5 -0
  213. package/dist/types/router-binding/useParams.d.ts +9 -0
  214. package/dist/types/router-binding/useRouteContext.d.ts +4 -0
  215. package/dist/types/router-binding/useRouter.d.ts +4 -0
  216. package/dist/types/router-binding/useRouterState.d.ts +8 -0
  217. package/dist/types/router-binding/useSearch.d.ts +9 -0
  218. package/dist/types/router-binding/utils.d.ts +25 -0
  219. package/dist/types/router.d.ts +31 -0
  220. package/dist/types/server.d.ts +47 -0
  221. package/package.json +130 -4
  222. package/src/actions.tsx +441 -0
  223. package/src/application-router.tsx +47 -0
  224. package/src/client.ts +106 -0
  225. package/src/entry-application.tsx +73 -0
  226. package/src/entry-client.tsx +49 -0
  227. package/src/entry-server.tsx +85 -0
  228. package/src/federation-context.ts +47 -0
  229. package/src/federation-ssr.ts +136 -0
  230. package/src/federation.tsx +197 -0
  231. package/src/i18n/I18nProvider.tsx +54 -0
  232. package/src/i18n/LocalizedLink.tsx +83 -0
  233. package/src/i18n/context.ts +13 -0
  234. package/src/i18n/index.ts +31 -0
  235. package/src/i18n/languageSync.ts +113 -0
  236. package/src/i18n/types.ts +35 -0
  237. package/src/i18n/useI18n.ts +121 -0
  238. package/src/index.ts +41 -0
  239. package/src/manifest.ts +337 -0
  240. package/src/native-promise-serialization.ts +167 -0
  241. package/src/plugin/compiler.ts +320 -0
  242. package/src/plugin/create.ts +271 -0
  243. package/src/plugin/index.ts +69 -0
  244. package/src/plugin/lazy-modules.cjs +146 -0
  245. package/src/plugin/preserve-import-loader.cjs +46 -0
  246. package/src/plugin/profile.ts +42 -0
  247. package/src/plugin/solid-loader.cjs +83 -0
  248. package/src/plugin/svg-component-template.cjs +19 -0
  249. package/src/route-completion.tsx +226 -0
  250. package/src/route-data-error.ts +175 -0
  251. package/src/router-binding/Asset.tsx +284 -0
  252. package/src/router-binding/CatchBoundary.tsx +130 -0
  253. package/src/router-binding/ClientOnly.tsx +76 -0
  254. package/src/router-binding/HeadContent.tsx +23 -0
  255. package/src/router-binding/LICENSE +21 -0
  256. package/src/router-binding/Match.tsx +397 -0
  257. package/src/router-binding/Matches.tsx +242 -0
  258. package/src/router-binding/PROVENANCE.json +94 -0
  259. package/src/router-binding/RouterProvider.tsx +128 -0
  260. package/src/router-binding/SafeFragment.tsx +5 -0
  261. package/src/router-binding/ScriptOnce.tsx +23 -0
  262. package/src/router-binding/Scripts.tsx +44 -0
  263. package/src/router-binding/ScrollRestoration.tsx +49 -0
  264. package/src/router-binding/Transitioner.tsx +177 -0
  265. package/src/router-binding/awaited.tsx +71 -0
  266. package/src/router-binding/fileRoute.ts +268 -0
  267. package/src/router-binding/flightData.ts +90 -0
  268. package/src/router-binding/headContentUtils.tsx +292 -0
  269. package/src/router-binding/history.ts +9 -0
  270. package/src/router-binding/index.tsx +315 -0
  271. package/src/router-binding/lazyRouteComponent.tsx +70 -0
  272. package/src/router-binding/link.tsx +865 -0
  273. package/src/router-binding/matchContext.tsx +15 -0
  274. package/src/router-binding/nonRouteComponentContext.tsx +23 -0
  275. package/src/router-binding/not-found.tsx +65 -0
  276. package/src/router-binding/publicMatchData.ts +674 -0
  277. package/src/router-binding/registryTransfer.ts +400 -0
  278. package/src/router-binding/renderRouteNotFound.tsx +53 -0
  279. package/src/router-binding/route.tsx +665 -0
  280. package/src/router-binding/router.ts +123 -0
  281. package/src/router-binding/routerContext.tsx +6 -0
  282. package/src/router-binding/routerOptions.ts +26 -0
  283. package/src/router-binding/routerStores.ts +85 -0
  284. package/src/router-binding/scroll-restoration.tsx +15 -0
  285. package/src/router-binding/typePrimitives.ts +74 -0
  286. package/src/router-binding/useBlocker.tsx +359 -0
  287. package/src/router-binding/useCanGoBack.ts +9 -0
  288. package/src/router-binding/useLoaderData.tsx +51 -0
  289. package/src/router-binding/useLoaderDeps.tsx +46 -0
  290. package/src/router-binding/useLocation.tsx +43 -0
  291. package/src/router-binding/useMatch.tsx +111 -0
  292. package/src/router-binding/useNavigate.tsx +45 -0
  293. package/src/router-binding/useParams.tsx +70 -0
  294. package/src/router-binding/useRouteContext.ts +30 -0
  295. package/src/router-binding/useRouter.tsx +17 -0
  296. package/src/router-binding/useRouterState.tsx +50 -0
  297. package/src/router-binding/useSearch.tsx +70 -0
  298. package/src/router-binding/utils.ts +59 -0
  299. package/src/router.ts +376 -0
  300. package/src/server.ts +645 -0
  301. package/README.md +0 -3
@@ -0,0 +1,292 @@
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
+ ...(manifest.inlineStyle.children !== undefined
158
+ ? { children: manifest.inlineStyle.children }
159
+ : {}),
160
+ inlineCss: true,
161
+ });
162
+ }
163
+
164
+ return tags;
165
+ });
166
+
167
+ const preloadLinks = Solid.createMemo(() => {
168
+ const manifest = router.ssr?.manifest;
169
+ const tags: Array<RouterManagedTag> = [];
170
+ for (const match of activeMatches()) {
171
+ for (const preload of manifest?.routes[match.routeId]?.preloads ?? []) {
172
+ if (!preload) {
173
+ continue;
174
+ }
175
+ tags.push({
176
+ tag: 'link',
177
+ attrs: {
178
+ ...getScriptPreloadAttrs(manifest, preload, assetCrossOrigin),
179
+ nonce,
180
+ },
181
+ });
182
+ }
183
+ }
184
+ return tags;
185
+ });
186
+
187
+ const styles = Solid.createMemo(() => {
188
+ return activeMatches()
189
+ .flatMap(match => match.styles ?? [])
190
+ .filter(style => style !== undefined)
191
+ .map(({ children, ...attrs }) => ({
192
+ tag: 'style',
193
+ attrs: {
194
+ ...attrs,
195
+ nonce,
196
+ },
197
+ ...(children != null ? { children: String(children) } : {}),
198
+ })) satisfies Array<RouterManagedTag>;
199
+ });
200
+
201
+ const headScripts = Solid.createMemo(() => {
202
+ return activeMatches()
203
+ .flatMap(match => match.headScripts ?? [])
204
+ .filter(script => script !== undefined)
205
+ .map(({ children, ...attrs }) => ({
206
+ tag: 'script',
207
+ attrs: {
208
+ ...attrs,
209
+ nonce,
210
+ },
211
+ ...(children != null ? { children: String(children) } : {}),
212
+ })) satisfies Array<RouterManagedTag>;
213
+ });
214
+
215
+ return Solid.createMemo(() => {
216
+ const next: Array<RouterManagedTag> = [];
217
+ appendUniqueUserTags(next, meta());
218
+ appendUniqueUserTags(next, links());
219
+ next.push(...manifestCssTags());
220
+ next.push(...preloadLinks());
221
+ appendUniqueUserTags(next, styles());
222
+ appendUniqueUserTags(next, headScripts());
223
+ return next;
224
+ });
225
+ };
226
+
227
+ const INLINE_CSS_HYDRATION_ATTR = 'data-tsr-inline-css';
228
+
229
+ /**
230
+ * Convert the router-managed tags into head registry descriptors for
231
+ * `useHead`. Pure data mapping — it is evaluated inside the registry's own
232
+ * flush boundary (server) / effect (client), so it must not allocate
233
+ * reactive owners.
234
+ */
235
+ export function toHeadTags(tags: Array<RouterManagedTag>): Array<HeadTag> {
236
+ return tags.map(toHeadTag);
237
+ }
238
+
239
+ function toHeadTag(t: RouterManagedTag): HeadTag {
240
+ const props: Record<string, any> = { ...t.attrs };
241
+ let children: string | undefined = t.children;
242
+
243
+ if (
244
+ t.tag === 'style' &&
245
+ t.inlineCss &&
246
+ (process.env.TSS_INLINE_CSS_ENABLED === 'true' ||
247
+ (process.env.TSS_INLINE_CSS_ENABLED === undefined && isServer))
248
+ ) {
249
+ // Mark the inline-CSS style so the client can find it again: the
250
+ // serialized manifest omits the CSS text, so on the client the tag
251
+ // arrives with `children === undefined` and the text is recovered from
252
+ // the server-rendered element.
253
+ props[INLINE_CSS_HYDRATION_ATTR] = '';
254
+ }
255
+
256
+ if (
257
+ t.tag === 'style' &&
258
+ t.inlineCss &&
259
+ children === undefined &&
260
+ typeof document !== 'undefined'
261
+ ) {
262
+ children =
263
+ document.querySelector<HTMLStyleElement>(
264
+ `style[${INLINE_CSS_HYDRATION_ATTR}]`,
265
+ )?.textContent ?? '';
266
+ }
267
+
268
+ if (children !== undefined) {
269
+ props.children = children;
270
+ }
271
+
272
+ const headTag: HeadTag = { tag: t.tag, props };
273
+
274
+ // Inline scripts and styles have no natural registry identity: the
275
+ // registry assigns them per-runtime unique ids, which can never match
276
+ // between server and client, so hydration would append a client copy
277
+ // next to the server-rendered one. A stable content-derived key gives
278
+ // both runtimes the same identity to reconcile on.
279
+ if (t.tag === 'style' || (t.tag === 'script' && props.src === undefined)) {
280
+ headTag.key = `tsr-${hashString(t.tag + JSON.stringify(props))}`;
281
+ }
282
+
283
+ return headTag;
284
+ }
285
+
286
+ function hashString(s: string): string {
287
+ let h = 5381;
288
+ for (let i = 0; i < s.length; i++) {
289
+ h = ((h << 5) + h + s.charCodeAt(i)) | 0;
290
+ }
291
+ return (h >>> 0).toString(36);
292
+ }
@@ -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,315 @@
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
+ AnyValidator,
30
+ AnyValidatorAdapter,
31
+ AnyValidatorFn,
32
+ AnyValidatorObj,
33
+ Assign,
34
+ BaseRouteOptions,
35
+ BeforeLoadContextOptions,
36
+ BeforeLoadContextParameter,
37
+ BuildLocationFn,
38
+ BuildNextOptions,
39
+ CommitLocationOptions,
40
+ Constrain,
41
+ ContextAsyncReturnType,
42
+ ContextOptions,
43
+ ContextReturnType,
44
+ ControllablePromise,
45
+ ControlledPromise,
46
+ CreateFileRoute,
47
+ CreateLazyFileRoute,
48
+ DefaultValidator,
49
+ DeferredPromise,
50
+ DeferredPromiseState,
51
+ ErrorComponentProps,
52
+ ErrorRouteProps,
53
+ Expand,
54
+ FileBaseRouteOptions,
55
+ FileRoutesByPath,
56
+ FileRouteTypes,
57
+ FullSearchSchema,
58
+ FullSearchSchemaInput,
59
+ FullSearchSchemaOption,
60
+ InferAllContext,
61
+ InferAllParams,
62
+ InferDescendantToPaths,
63
+ InferFrom,
64
+ InferFullSearchSchema,
65
+ InferFullSearchSchemaInput,
66
+ InferMaskFrom,
67
+ InferMaskTo,
68
+ InferSelected,
69
+ InferShouldThrow,
70
+ InferStrict,
71
+ InferTo,
72
+ IntersectAssign,
73
+ LazyRouteOptions,
74
+ LinkOptions,
75
+ ListenerFn,
76
+ LoaderFnContext,
77
+ LocationRewrite,
78
+ LocationRewriteFunction,
79
+ LooseAsyncReturnType,
80
+ LooseReturnType,
81
+ MakeOptionalPathParams,
82
+ MakeRemountDepsOptionsUnion,
83
+ MakeRouteMatch,
84
+ MakeRouteMatchUnion,
85
+ Manifest,
86
+ MatchLocation,
87
+ MatchRouteOptions,
88
+ MergeAll,
89
+ MetaDescriptor,
90
+ NavigateFn,
91
+ NavigateOptions,
92
+ NotFoundError,
93
+ NotFoundRouteProps,
94
+ ParamsOptions,
95
+ ParsedLocation,
96
+ ParseParamsFn,
97
+ ParseRoute,
98
+ PathParamOptions,
99
+ PreloadableObj,
100
+ Redirect,
101
+ RedirectOptions,
102
+ Register,
103
+ RegisteredRouter,
104
+ RelativeToCurrentPath,
105
+ RelativeToParentPath,
106
+ RelativeToPath,
107
+ RelativeToPathAutoComplete,
108
+ RemountDepsOptions,
109
+ RemoveLeadingSlashes,
110
+ RemoveTrailingSlashes,
111
+ ResolveAllContext,
112
+ ResolveAllParamsFromParent,
113
+ ResolvedRedirect,
114
+ ResolveFullPath,
115
+ ResolveFullSearchSchema,
116
+ ResolveFullSearchSchemaInput,
117
+ ResolveId,
118
+ ResolveLoaderData,
119
+ ResolveOptionalParams,
120
+ ResolveParams,
121
+ ResolveRelativePath,
122
+ ResolveRequiredParams,
123
+ ResolveRoute,
124
+ ResolveRouteContext,
125
+ ResolveSearchValidatorInput,
126
+ ResolveSearchValidatorInputFn,
127
+ ResolveValidatorInput,
128
+ ResolveValidatorInputFn,
129
+ ResolveValidatorOutput,
130
+ ResolveValidatorOutputFn,
131
+ RootRouteId,
132
+ RootRouteOptions,
133
+ RouteById,
134
+ RouteByPath,
135
+ RouteConstraints,
136
+ RouteContext,
137
+ RouteContextFn,
138
+ RouteContextOptions,
139
+ RouteContextParameter,
140
+ RouteIds,
141
+ RouteLinkEntry,
142
+ RouteLoaderFn,
143
+ RouteMask,
144
+ RouteMatch,
145
+ RouteOptions,
146
+ RoutePathOptions,
147
+ RoutePathOptionsIntersection,
148
+ RoutePaths,
149
+ RouterConstructorOptions,
150
+ RouterContextOptions,
151
+ RouterEvent,
152
+ RouterEvents,
153
+ RouterListener,
154
+ RouterManagedTag,
155
+ RouterState,
156
+ RoutesById,
157
+ RoutesByPath,
158
+ SearchFilter,
159
+ SearchParamOptions,
160
+ SearchParser,
161
+ SearchSchemaInput,
162
+ SearchSerializer,
163
+ SerializableExtensions,
164
+ StaticDataRouteOption,
165
+ StringifyParamsFn,
166
+ ToMaskOptions,
167
+ ToOptions,
168
+ ToPathOption,
169
+ ToSubOptions,
170
+ TrailingSlashOption,
171
+ TrimPath,
172
+ TrimPathLeft,
173
+ TrimPathRight,
174
+ UpdatableRouteOptions,
175
+ UpdatableStaticRouteOption,
176
+ UseNavigateResult,
177
+ ValidateFromPath,
178
+ ValidateId,
179
+ ValidateNavigateOptions,
180
+ ValidateNavigateOptionsArray,
181
+ ValidateParams,
182
+ ValidateRedirectOptions,
183
+ ValidateRedirectOptionsArray,
184
+ ValidateSearch,
185
+ ValidateToPath,
186
+ ValidateUseParamsResult,
187
+ ValidateUseSearchResult,
188
+ Validator,
189
+ ValidatorAdapter,
190
+ ValidatorFn,
191
+ ValidatorObj,
192
+ } from '@tanstack/router-core';
193
+ export {
194
+ cleanPath,
195
+ composeRewrites,
196
+ createControlledPromise,
197
+ DEFAULT_PROTOCOL_ALLOWLIST,
198
+ deepEqual,
199
+ defaultParseSearch,
200
+ defaultStringifySearch,
201
+ defer,
202
+ functionalUpdate,
203
+ interpolatePath,
204
+ isMatch,
205
+ isNotFound,
206
+ isRedirect,
207
+ joinPaths,
208
+ lazyFn,
209
+ notFound,
210
+ parseSearchWith,
211
+ redirect,
212
+ replaceEqualDeep,
213
+ resolvePath,
214
+ retainSearchParams,
215
+ rootRouteId,
216
+ SearchParamError,
217
+ stringifySearchWith,
218
+ stripSearchParams,
219
+ trimPath,
220
+ trimPathLeft,
221
+ trimPathRight,
222
+ } from '@tanstack/router-core';
223
+ export { Asset } from './Asset';
224
+ export type { AwaitOptions } from './awaited';
225
+ export { Await, useAwaited } from './awaited';
226
+ export { CatchBoundary, ErrorComponent } from './CatchBoundary';
227
+ export { ClientOnly, useHydrated } from './ClientOnly';
228
+ export {
229
+ createFileRoute,
230
+ createLazyFileRoute,
231
+ createLazyRoute,
232
+ FileRoute,
233
+ FileRouteLoader,
234
+ LazyRoute,
235
+ } from './fileRoute';
236
+ export { HeadContent } from './HeadContent';
237
+ export { useTags } from './headContentUtils';
238
+ export * from './history';
239
+ export { lazyRouteComponent } from './lazyRouteComponent';
240
+ export type {
241
+ ActiveLinkOptions,
242
+ CreateLinkProps,
243
+ LinkComponent,
244
+ LinkComponentProps,
245
+ LinkProps,
246
+ UseLinkPropsOptions,
247
+ } from './link';
248
+ export { createLink, Link, linkOptions, useLinkProps } from './link';
249
+ export { Match, Outlet } from './Match';
250
+ export type { MakeMatchRouteOptions, UseMatchRouteOptions } from './Matches';
251
+ export {
252
+ Matches,
253
+ MatchRoute,
254
+ useChildMatches,
255
+ useMatches,
256
+ useMatchRoute,
257
+ useParentMatches,
258
+ } from './Matches';
259
+ export { CatchNotFound, DefaultGlobalNotFound } from './not-found';
260
+ export type { PublicMatchError, PublicSnapshotOwner } from './publicMatchData';
261
+ export {
262
+ preparePublicContextData,
263
+ preparePublicLoaderData,
264
+ preparePublicMatchError,
265
+ } from './publicMatchData';
266
+ export type { RouterProps } from './RouterProvider';
267
+ export { RouterContextProvider, RouterProvider } from './RouterProvider';
268
+ export { prepareRouterMatchTransfer } from './registryTransfer';
269
+ export type {
270
+ AnyRootRoute,
271
+ AsyncRouteComponent,
272
+ ErrorRouteComponent,
273
+ NotFoundRouteComponent,
274
+ RouteComponent,
275
+ SolidNode,
276
+ } from './route';
277
+ export {
278
+ createRootRoute,
279
+ createRootRouteWithContext,
280
+ createRoute,
281
+ createRouteMask,
282
+ getRouteApi,
283
+ NotFoundRoute,
284
+ RootRoute,
285
+ Route,
286
+ RouteApi,
287
+ rootRouteWithContext,
288
+ } from './route';
289
+ export { createRouter, Router } from './router';
290
+ export type { RouterOptions } from './routerOptions';
291
+ export { ScriptOnce } from './ScriptOnce';
292
+ export { Scripts } from './Scripts';
293
+ export {
294
+ ScrollRestoration,
295
+ useElementScrollRestoration,
296
+ } from './ScrollRestoration';
297
+ export type {
298
+ ValidateLinkOptions,
299
+ ValidateLinkOptionsArray,
300
+ ValidateUseParamsOptions,
301
+ ValidateUseSearchOptions,
302
+ } from './typePrimitives';
303
+ export type { ShouldBlockFn, UseBlockerOpts } from './useBlocker';
304
+ export { Block, useBlocker } from './useBlocker';
305
+ export { useCanGoBack } from './useCanGoBack';
306
+ export { useLoaderData } from './useLoaderData';
307
+ export { useLoaderDeps } from './useLoaderDeps';
308
+ export { useLocation } from './useLocation';
309
+ export { useMatch } from './useMatch';
310
+ export { Navigate, useNavigate } from './useNavigate';
311
+ export { useParams } from './useParams';
312
+ export { useRouteContext } from './useRouteContext';
313
+ export { useRouter } from './useRouter';
314
+ export { useRouterState } from './useRouterState';
315
+ 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
+ }