@bleedingdev/modern-js-runtime 3.2.0-ultramodern.11 → 3.2.0-ultramodern.110

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 (229) hide show
  1. package/dist/cjs/boundary-debugger/index.js +303 -0
  2. package/dist/cjs/cache/index.js +9 -5
  3. package/dist/cjs/cli/alias.js +9 -5
  4. package/dist/cjs/cli/code.js +9 -5
  5. package/dist/cjs/cli/constants.js +20 -16
  6. package/dist/cjs/cli/entry.js +9 -5
  7. package/dist/cjs/cli/index.js +9 -5
  8. package/dist/cjs/cli/ssr/index.js +14 -20
  9. package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +9 -5
  10. package/dist/cjs/cli/ssr/mode.js +12 -8
  11. package/dist/cjs/cli/template.js +9 -5
  12. package/dist/cjs/cli/template.server.js +10 -5
  13. package/dist/cjs/common.js +14 -10
  14. package/dist/cjs/core/browser/hydrate.js +9 -5
  15. package/dist/cjs/core/browser/index.js +9 -5
  16. package/dist/cjs/core/browser/withCallback.js +9 -5
  17. package/dist/cjs/core/compat/hooks.js +14 -10
  18. package/dist/cjs/core/compat/index.js +9 -5
  19. package/dist/cjs/core/compat/requestContext.js +13 -9
  20. package/dist/cjs/core/config.js +12 -8
  21. package/dist/cjs/core/constants.js +15 -10
  22. package/dist/cjs/core/context/index.js +9 -5
  23. package/dist/cjs/core/context/monitors/default.js +12 -8
  24. package/dist/cjs/core/context/monitors/index.js +9 -5
  25. package/dist/cjs/core/context/monitors/index.server.js +9 -5
  26. package/dist/cjs/core/context/request/index.js +12 -8
  27. package/dist/cjs/core/context/request/index.server.js +9 -5
  28. package/dist/cjs/core/context/response/index.js +15 -11
  29. package/dist/cjs/core/context/response/index.server.js +9 -5
  30. package/dist/cjs/core/context/runtime.js +9 -5
  31. package/dist/cjs/core/context/serverPayload/index.js +13 -9
  32. package/dist/cjs/core/context/serverPayload/index.server.js +9 -5
  33. package/dist/cjs/core/index.js +9 -5
  34. package/dist/cjs/core/plugin/index.js +9 -5
  35. package/dist/cjs/core/react/index.js +9 -5
  36. package/dist/cjs/core/react/wrapper.js +18 -8
  37. package/dist/cjs/core/server/constants.js +15 -11
  38. package/dist/cjs/core/server/federatedCss.js +51 -0
  39. package/dist/cjs/core/server/helmet.js +17 -7
  40. package/dist/cjs/core/server/index.js +9 -5
  41. package/dist/cjs/core/server/react/index.js +9 -5
  42. package/dist/cjs/core/server/react/no-ssr-cache/index.js +9 -5
  43. package/dist/cjs/core/server/react/nossr/index.js +9 -5
  44. package/dist/cjs/core/server/requestHandler.js +9 -5
  45. package/dist/cjs/core/server/scriptOrder.js +63 -0
  46. package/dist/cjs/core/server/server.js +9 -5
  47. package/dist/cjs/core/server/shared.js +12 -8
  48. package/dist/cjs/core/server/stream/afterTemplate.js +22 -10
  49. package/dist/cjs/core/server/stream/beforeTemplate.js +22 -25
  50. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +102 -0
  51. package/dist/cjs/core/server/stream/createReadableStream.js +16 -7
  52. package/dist/cjs/core/server/stream/createReadableStream.worker.js +13 -7
  53. package/dist/cjs/core/server/stream/deferredScript.js +9 -5
  54. package/dist/cjs/core/server/stream/index.js +9 -5
  55. package/dist/cjs/core/server/stream/shared.js +12 -6
  56. package/dist/cjs/core/server/stream/template.js +9 -5
  57. package/dist/cjs/core/server/string/index.js +25 -14
  58. package/dist/cjs/core/server/string/loadable.js +83 -15
  59. package/dist/cjs/core/server/string/ssrData.js +9 -5
  60. package/dist/cjs/core/server/tracer.js +13 -9
  61. package/dist/cjs/core/server/utils.js +9 -5
  62. package/dist/cjs/document/Body.js +9 -5
  63. package/dist/cjs/document/Comment.js +9 -5
  64. package/dist/cjs/document/DocumentContext.js +9 -5
  65. package/dist/cjs/document/DocumentStructureContext.js +9 -5
  66. package/dist/cjs/document/Head.js +9 -5
  67. package/dist/cjs/document/Html.js +9 -5
  68. package/dist/cjs/document/Links.js +9 -5
  69. package/dist/cjs/document/Root.js +9 -5
  70. package/dist/cjs/document/Script.js +9 -5
  71. package/dist/cjs/document/Scripts.js +9 -5
  72. package/dist/cjs/document/Style.js +9 -5
  73. package/dist/cjs/document/Title.js +9 -5
  74. package/dist/cjs/document/cli/index.js +12 -6
  75. package/dist/cjs/document/constants.js +9 -5
  76. package/dist/cjs/document/index.js +9 -5
  77. package/dist/cjs/exports/config-routes.js +12 -8
  78. package/dist/cjs/exports/head.js +209 -10
  79. package/dist/cjs/exports/loadable.js +51 -12
  80. package/dist/cjs/exports/tanstack-router.js +320 -59
  81. package/dist/cjs/index.js +9 -5
  82. package/dist/cjs/internal.js +9 -5
  83. package/dist/cjs/react-server.js +9 -5
  84. package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +9 -5
  85. package/dist/cjs/router/cli/code/getClientRoutes/index.js +9 -5
  86. package/dist/cjs/router/cli/code/getClientRoutes/utils.js +9 -5
  87. package/dist/cjs/router/cli/code/index.js +9 -5
  88. package/dist/cjs/router/cli/code/inspect.js +9 -5
  89. package/dist/cjs/router/cli/code/makeLegalIdentifier.js +12 -8
  90. package/dist/cjs/router/cli/code/nestedRoutes.js +9 -5
  91. package/dist/cjs/router/cli/code/tanstackTypes.js +125 -56
  92. package/dist/cjs/router/cli/code/templates.js +24 -14
  93. package/dist/cjs/router/cli/code/utils.js +9 -5
  94. package/dist/cjs/router/cli/config-routes/converter.js +9 -5
  95. package/dist/cjs/router/cli/config-routes/parseRouteConfig.js +9 -5
  96. package/dist/cjs/router/cli/constants.js +23 -19
  97. package/dist/cjs/router/cli/entry.js +9 -5
  98. package/dist/cjs/router/cli/handler.js +9 -5
  99. package/dist/cjs/router/cli/index.js +9 -5
  100. package/dist/cjs/router/index.js +9 -5
  101. package/dist/cjs/router/internal.js +12 -8
  102. package/dist/cjs/router/runtime/CSSLinks.js +9 -5
  103. package/dist/cjs/router/runtime/DefaultNotFound.js +9 -5
  104. package/dist/cjs/router/runtime/DeferredDataScripts.js +12 -8
  105. package/dist/cjs/router/runtime/DeferredDataScripts.node.js +9 -5
  106. package/dist/cjs/router/runtime/PrefetchLink.js +162 -26
  107. package/dist/cjs/router/runtime/constants.js +9 -5
  108. package/dist/cjs/router/runtime/hooks.js +9 -5
  109. package/dist/cjs/router/runtime/index.js +15 -10
  110. package/dist/cjs/router/runtime/internal.js +9 -5
  111. package/dist/cjs/router/runtime/lifecycle.js +18 -14
  112. package/dist/cjs/router/runtime/plugin.js +9 -5
  113. package/dist/cjs/router/runtime/plugin.node.js +9 -5
  114. package/dist/cjs/router/runtime/routerHelper.js +9 -5
  115. package/dist/cjs/router/runtime/rsc-router.js +9 -5
  116. package/dist/cjs/router/runtime/rsc.js +9 -5
  117. package/dist/cjs/router/runtime/server.js +9 -5
  118. package/dist/cjs/router/runtime/tanstack/basepathRewrite.js +12 -8
  119. package/dist/cjs/router/runtime/tanstack/dataMutation.js +9 -5
  120. package/dist/cjs/router/runtime/tanstack/hydrationBoundary.js +48 -0
  121. package/dist/cjs/router/runtime/tanstack/outlet.js +58 -0
  122. package/dist/cjs/router/runtime/tanstack/plugin.js +199 -96
  123. package/dist/cjs/router/runtime/tanstack/plugin.node.js +13 -19
  124. package/dist/cjs/router/runtime/tanstack/prefetchLink.js +10 -6
  125. package/dist/cjs/router/runtime/tanstack/routeTree.js +73 -17
  126. package/dist/cjs/router/runtime/tanstack/rsc/ClientSlot.js +9 -5
  127. package/dist/cjs/router/runtime/tanstack/rsc/CompositeComponent.js +9 -5
  128. package/dist/cjs/router/runtime/tanstack/rsc/ReplayableStream.js +14 -9
  129. package/dist/cjs/router/runtime/tanstack/rsc/RscNodeRenderer.js +9 -5
  130. package/dist/cjs/router/runtime/tanstack/rsc/SlotContext.js +9 -5
  131. package/dist/cjs/router/runtime/tanstack/rsc/client.js +9 -5
  132. package/dist/cjs/router/runtime/tanstack/rsc/createRscProxy.js +9 -5
  133. package/dist/cjs/router/runtime/tanstack/rsc/index.js +9 -5
  134. package/dist/cjs/router/runtime/tanstack/rsc/server.js +9 -5
  135. package/dist/cjs/router/runtime/tanstack/rsc/slotUsageSanitizer.js +9 -5
  136. package/dist/cjs/router/runtime/tanstack/rsc/symbols.js +20 -15
  137. package/dist/cjs/router/runtime/utils.js +9 -5
  138. package/dist/cjs/router/runtime/withRouter.js +9 -5
  139. package/dist/cjs/rsc/client.js +12 -8
  140. package/dist/cjs/rsc/server.js +9 -5
  141. package/dist/cjs/rsc/server.worker.js +62 -0
  142. package/dist/cjs/ssr/index.node.js +13 -9
  143. package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +9 -5
  144. package/dist/cjs/ssr/serverRender/renderToString/entry.js +18 -13
  145. package/dist/cjs/ssr/serverRender/types.js +9 -5
  146. package/dist/esm/boundary-debugger/index.mjs +263 -0
  147. package/dist/esm/cli/ssr/index.mjs +5 -15
  148. package/dist/esm/cli/template.server.mjs +1 -0
  149. package/dist/esm/core/react/wrapper.mjs +9 -3
  150. package/dist/esm/core/server/federatedCss.mjs +13 -0
  151. package/dist/esm/core/server/helmet.mjs +5 -2
  152. package/dist/esm/core/server/scriptOrder.mjs +25 -0
  153. package/dist/esm/core/server/stream/afterTemplate.mjs +14 -6
  154. package/dist/esm/core/server/stream/beforeTemplate.mjs +14 -11
  155. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +64 -0
  156. package/dist/esm/core/server/stream/createReadableStream.mjs +7 -2
  157. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +4 -2
  158. package/dist/esm/core/server/stream/shared.mjs +3 -1
  159. package/dist/esm/core/server/string/index.mjs +17 -9
  160. package/dist/esm/core/server/string/loadable.mjs +70 -9
  161. package/dist/esm/document/cli/index.mjs +3 -1
  162. package/dist/esm/exports/head.mjs +193 -4
  163. package/dist/esm/exports/loadable.mjs +26 -3
  164. package/dist/esm/exports/tanstack-router.mjs +2 -1
  165. package/dist/esm/router/cli/code/tanstackTypes.mjs +116 -51
  166. package/dist/esm/router/cli/code/templates.mjs +15 -9
  167. package/dist/esm/router/runtime/PrefetchLink.mjs +153 -21
  168. package/dist/esm/router/runtime/tanstack/hydrationBoundary.mjs +10 -0
  169. package/dist/esm/router/runtime/tanstack/outlet.mjs +17 -0
  170. package/dist/esm/router/runtime/tanstack/plugin.mjs +193 -94
  171. package/dist/esm/router/runtime/tanstack/plugin.node.mjs +5 -15
  172. package/dist/esm/router/runtime/tanstack/prefetchLink.mjs +1 -1
  173. package/dist/esm/router/runtime/tanstack/routeTree.mjs +65 -13
  174. package/dist/esm/rsc/server.worker.mjs +1 -0
  175. package/dist/esm/ssr/serverRender/renderToString/entry.mjs +9 -6
  176. package/dist/esm-node/boundary-debugger/index.mjs +264 -0
  177. package/dist/esm-node/cli/ssr/index.mjs +5 -15
  178. package/dist/esm-node/cli/template.server.mjs +1 -0
  179. package/dist/esm-node/core/react/wrapper.mjs +9 -3
  180. package/dist/esm-node/core/server/federatedCss.mjs +14 -0
  181. package/dist/esm-node/core/server/helmet.mjs +5 -2
  182. package/dist/esm-node/core/server/scriptOrder.mjs +26 -0
  183. package/dist/esm-node/core/server/stream/afterTemplate.mjs +14 -6
  184. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +14 -11
  185. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +65 -0
  186. package/dist/esm-node/core/server/stream/createReadableStream.mjs +7 -2
  187. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +4 -2
  188. package/dist/esm-node/core/server/stream/shared.mjs +3 -1
  189. package/dist/esm-node/core/server/string/index.mjs +17 -9
  190. package/dist/esm-node/core/server/string/loadable.mjs +70 -9
  191. package/dist/esm-node/document/cli/index.mjs +3 -1
  192. package/dist/esm-node/exports/head.mjs +193 -4
  193. package/dist/esm-node/exports/loadable.mjs +26 -3
  194. package/dist/esm-node/exports/tanstack-router.mjs +2 -1
  195. package/dist/esm-node/router/cli/code/tanstackTypes.mjs +116 -51
  196. package/dist/esm-node/router/cli/code/templates.mjs +15 -9
  197. package/dist/esm-node/router/runtime/PrefetchLink.mjs +153 -21
  198. package/dist/esm-node/router/runtime/tanstack/hydrationBoundary.mjs +11 -0
  199. package/dist/esm-node/router/runtime/tanstack/outlet.mjs +18 -0
  200. package/dist/esm-node/router/runtime/tanstack/plugin.mjs +193 -94
  201. package/dist/esm-node/router/runtime/tanstack/plugin.node.mjs +5 -15
  202. package/dist/esm-node/router/runtime/tanstack/prefetchLink.mjs +1 -1
  203. package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +65 -13
  204. package/dist/esm-node/rsc/server.worker.mjs +2 -0
  205. package/dist/esm-node/ssr/serverRender/renderToString/entry.mjs +9 -6
  206. package/dist/types/boundary-debugger/index.d.ts +28 -0
  207. package/dist/types/cli/entry.d.ts +2 -2
  208. package/dist/types/core/context/response/index.server.d.ts +4 -1
  209. package/dist/types/core/context/runtime.d.ts +4 -0
  210. package/dist/types/core/plugin/index.d.ts +1 -1
  211. package/dist/types/core/server/federatedCss.d.ts +5 -0
  212. package/dist/types/core/server/helmet.d.ts +5 -3
  213. package/dist/types/core/server/scriptOrder.d.ts +1 -0
  214. package/dist/types/core/server/stream/beforeTemplate.d.ts +1 -0
  215. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +10 -0
  216. package/dist/types/core/server/stream/shared.d.ts +8 -0
  217. package/dist/types/core/server/string/loadable.d.ts +11 -0
  218. package/dist/types/core/server/utils.d.ts +11 -1
  219. package/dist/types/document/constants.d.ts +3 -1
  220. package/dist/types/exports/head.d.ts +10 -3
  221. package/dist/types/exports/loadable.d.ts +8 -1
  222. package/dist/types/exports/tanstack-router.d.ts +3 -1
  223. package/dist/types/router/cli/code/utils.d.ts +1 -1
  224. package/dist/types/router/cli/entry.d.ts +1 -1
  225. package/dist/types/router/runtime/PrefetchLink.d.ts +5 -1
  226. package/dist/types/router/runtime/tanstack/hydrationBoundary.d.ts +2 -0
  227. package/dist/types/router/runtime/tanstack/outlet.d.ts +2 -0
  228. package/dist/types/rsc/server.worker.d.ts +1 -0
  229. package/package.json +31 -25
@@ -1,5 +1,194 @@
1
1
  "use client";
2
- import react_helmet, { Helmet } from "react-helmet";
3
- const head = react_helmet;
4
- export default head;
5
- export { Helmet };
2
+ import react from "react";
3
+ import { Helmet, HelmetData, HelmetProvider } from "react-helmet-async";
4
+ import { InternalRuntimeContext } from "../core/context/index.mjs";
5
+ const ATTRIBUTE_NAME_MAP = {
6
+ charSet: 'charset',
7
+ className: 'class',
8
+ contentEditable: 'contenteditable',
9
+ httpEquiv: 'http-equiv',
10
+ itemProp: 'itemprop',
11
+ tabIndex: 'tabindex'
12
+ };
13
+ const escapeHtml = (value)=>String(value).replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
14
+ const toHtmlAttributeName = (name)=>ATTRIBUTE_NAME_MAP[name] ?? name;
15
+ const attributesToString = (attributes, includeHelmetAttribute = false)=>{
16
+ const pairs = [];
17
+ if (includeHelmetAttribute) pairs.push('data-rh="true"');
18
+ for (const [name, value] of Object.entries(attributes ?? {})){
19
+ if (false === value || null == value) continue;
20
+ const htmlName = toHtmlAttributeName(name);
21
+ if (true === value) pairs.push(htmlName);
22
+ else pairs.push(`${htmlName}="${escapeHtml(value)}"`);
23
+ }
24
+ return pairs.join(' ');
25
+ };
26
+ const createDatum = (tagName, tags)=>({
27
+ toComponent: ()=>[],
28
+ toString: ()=>tags.map((tag)=>{
29
+ const attrs = attributesToString(tag, true);
30
+ if ("script" === tagName && 'string' == typeof tag.innerHTML) return `<script ${attrs}>${tag.innerHTML}</script>`;
31
+ if ('style' === tagName && 'string' == typeof tag.cssText) return `<style ${attrs}>${tag.cssText}</style>`;
32
+ if ("noscript" === tagName && 'string' == typeof tag.innerHTML) return `<noscript ${attrs}>${tag.innerHTML}</noscript>`;
33
+ return `<${tagName} ${attrs}>`;
34
+ }).join('')
35
+ });
36
+ const createAttributeDatum = (attributes)=>({
37
+ toComponent: ()=>attributes,
38
+ toString: ()=>attributesToString(attributes)
39
+ });
40
+ const createTitleDatum = (title, attributes)=>({
41
+ toComponent: ()=>[],
42
+ toString: ()=>{
43
+ if (void 0 === title || '' === title) return '';
44
+ const attrs = attributesToString(attributes, true);
45
+ return `<title ${attrs}>${escapeHtml(title)}</title>`;
46
+ }
47
+ });
48
+ const createEmptyHelmetState = ()=>({
49
+ base: createDatum('base', []),
50
+ bodyAttributes: createAttributeDatum({}),
51
+ htmlAttributes: createAttributeDatum({}),
52
+ link: createDatum('link', []),
53
+ meta: createDatum('meta', []),
54
+ noscript: createDatum("noscript", []),
55
+ priority: createDatum('meta', []),
56
+ script: createDatum("script", []),
57
+ style: createDatum('style', []),
58
+ title: createTitleDatum(void 0, {})
59
+ });
60
+ const normalizeHelmetTitle = (title)=>{
61
+ if ('string' == typeof title) return title;
62
+ if (Array.isArray(title)) return title.map((part)=>String(part)).join('');
63
+ };
64
+ const mergeAttributes = (current, next)=>({
65
+ ...current,
66
+ ...next ?? {}
67
+ });
68
+ const collectChildren = (children, draft)=>{
69
+ react.Children.forEach(children, (child)=>{
70
+ if (!react.isValidElement(child)) return;
71
+ if (child.type === react.Fragment) return void collectChildren(child.props.children, draft);
72
+ if ('string' != typeof child.type) return;
73
+ const { children: nestedChildren, ...props } = child.props;
74
+ if ('title' === child.type) {
75
+ draft.title = react.Children.toArray(nestedChildren).join('');
76
+ draft.titleAttributes = mergeAttributes(draft.titleAttributes, props);
77
+ return;
78
+ }
79
+ if ('html' === child.type || 'body' === child.type) return;
80
+ if ('base' === child.type || 'link' === child.type || 'meta' === child.type || "noscript" === child.type || "script" === child.type || 'style' === child.type) {
81
+ const tag = {
82
+ ...props
83
+ };
84
+ if (("script" === child.type || 'style' === child.type || "noscript" === child.type) && 'string' == typeof nestedChildren) tag['style' === child.type ? 'cssText' : 'innerHTML'] = nestedChildren;
85
+ draft[child.type].push(tag);
86
+ }
87
+ });
88
+ };
89
+ const collectHelmetProps = (current, props)=>{
90
+ const baseState = current ?? createEmptyHelmetState();
91
+ const draft = {
92
+ base: [
93
+ ...void 0 !== props.base ? [
94
+ props.base
95
+ ] : []
96
+ ],
97
+ bodyAttributes: props.bodyAttributes,
98
+ htmlAttributes: props.htmlAttributes,
99
+ link: [
100
+ ...props.link ?? []
101
+ ],
102
+ meta: [
103
+ ...props.meta ?? []
104
+ ],
105
+ noscript: [
106
+ ...props.noscript ?? []
107
+ ],
108
+ script: [
109
+ ...props.script ?? []
110
+ ],
111
+ style: [
112
+ ...props.style ?? []
113
+ ],
114
+ title: normalizeHelmetTitle(props.title),
115
+ titleAttributes: props.titleAttributes ?? {}
116
+ };
117
+ collectChildren(props.children, draft);
118
+ const title = void 0 !== draft.title && '' !== draft.title && void 0 !== props.titleTemplate ? props.titleTemplate.replaceAll('%s', draft.title) : draft.title ?? props.defaultTitle;
119
+ return {
120
+ base: createDatum('base', [
121
+ ...baseState.__baseTags ?? [],
122
+ ...draft.base
123
+ ]),
124
+ bodyAttributes: createAttributeDatum(mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes)),
125
+ htmlAttributes: createAttributeDatum(mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes)),
126
+ link: createDatum('link', [
127
+ ...baseState.__linkTags ?? [],
128
+ ...draft.link
129
+ ]),
130
+ meta: createDatum('meta', [
131
+ ...baseState.__metaTags ?? [],
132
+ ...draft.meta
133
+ ]),
134
+ noscript: createDatum("noscript", [
135
+ ...baseState.__noscriptTags ?? [],
136
+ ...draft.noscript
137
+ ]),
138
+ priority: createDatum('meta', []),
139
+ script: createDatum("script", [
140
+ ...baseState.__scriptTags ?? [],
141
+ ...draft.script
142
+ ]),
143
+ style: createDatum('style', [
144
+ ...baseState.__styleTags ?? [],
145
+ ...draft.style
146
+ ]),
147
+ title: createTitleDatum(title ?? baseState.__title, mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)),
148
+ __baseTags: [
149
+ ...baseState.__baseTags ?? [],
150
+ ...draft.base
151
+ ],
152
+ __bodyAttributes: mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes),
153
+ __htmlAttributes: mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes),
154
+ __linkTags: [
155
+ ...baseState.__linkTags ?? [],
156
+ ...draft.link
157
+ ],
158
+ __metaTags: [
159
+ ...baseState.__metaTags ?? [],
160
+ ...draft.meta
161
+ ],
162
+ __noscriptTags: [
163
+ ...baseState.__noscriptTags ?? [],
164
+ ...draft.noscript
165
+ ],
166
+ __scriptTags: [
167
+ ...baseState.__scriptTags ?? [],
168
+ ...draft.script
169
+ ],
170
+ __styleTags: [
171
+ ...baseState.__styleTags ?? [],
172
+ ...draft.style
173
+ ],
174
+ __title: title ?? baseState.__title,
175
+ __titleAttributes: mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)
176
+ };
177
+ };
178
+ const head_Helmet = (props)=>{
179
+ const runtimeContext = react.useContext(InternalRuntimeContext);
180
+ if (null !== runtimeContext && false === runtimeContext.isBrowser) {
181
+ runtimeContext._helmetContext ??= {};
182
+ runtimeContext._helmetContext.helmet = collectHelmetProps(runtimeContext._helmetContext.helmet ?? void 0, props);
183
+ return null;
184
+ }
185
+ return react.createElement(Helmet, props);
186
+ };
187
+ const head = {
188
+ Helmet: head_Helmet,
189
+ HelmetData: HelmetData,
190
+ HelmetProvider: HelmetProvider
191
+ };
192
+ const exports_head = head;
193
+ export default exports_head;
194
+ export { HelmetData, HelmetProvider, head_Helmet as Helmet };
@@ -1,4 +1,27 @@
1
- import component from "@loadable/component";
1
+ import * as __rspack_external__loadable_component_0aaae075 from "@loadable/component";
2
2
  export * from "@loadable/component";
3
- const loadable = component;
4
- export default loadable;
3
+ function asLoadableNamespace(value) {
4
+ return 'object' == typeof value && null !== value ? value : {};
5
+ }
6
+ function resolveLoadable(module) {
7
+ const namespace = asLoadableNamespace(module);
8
+ const defaultExport = asLoadableNamespace(namespace.default);
9
+ const candidates = [
10
+ module,
11
+ namespace.default,
12
+ defaultExport?.default
13
+ ];
14
+ const loadable = candidates.find((candidate)=>'function' == typeof candidate);
15
+ if ('function' != typeof loadable) throw new TypeError('Modern.js runtime loadable export must resolve to a function');
16
+ return loadable;
17
+ }
18
+ const loadable_loadable = resolveLoadable(__rspack_external__loadable_component_0aaae075);
19
+ const loadableNamespace = asLoadableNamespace(__rspack_external__loadable_component_0aaae075);
20
+ const loadableDefaultNamespace = asLoadableNamespace(loadableNamespace.default);
21
+ const callableLoadableNamespace = asLoadableNamespace(loadable_loadable);
22
+ const lazy = loadableNamespace.lazy ?? loadableDefaultNamespace.lazy ?? callableLoadableNamespace.lazy;
23
+ const loadableReady = loadableNamespace.loadableReady ?? loadableDefaultNamespace.loadableReady ?? callableLoadableNamespace.loadableReady;
24
+ const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = loadableNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ?? loadableDefaultNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ?? callableLoadableNamespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
25
+ const exports_loadable = loadable_loadable;
26
+ export default exports_loadable;
27
+ export { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, lazy, loadableReady };
@@ -1,3 +1,4 @@
1
- export * from "@tanstack/react-router";
1
+ export { Asset, Await, Block, CatchBoundary, CatchNotFound, ClientOnly, DEFAULT_PROTOCOL_ALLOWLIST, DefaultGlobalNotFound, ErrorComponent, FileRoute, FileRouteLoader, HeadContent, LazyRoute, Match, MatchRoute, Matches, Navigate, NotFoundRoute, RootRoute, Route, RouteApi, Router, RouterContextProvider, RouterProvider, ScriptOnce, Scripts, ScrollRestoration, SearchParamError, cleanPath, composeRewrites, createBrowserHistory, createControlledPromise, createFileRoute, createHashHistory, createHistory, createLazyFileRoute, createLazyRoute, createLink, createMemoryHistory, createRootRoute, createRootRouteWithContext, createRoute, createRouteMask, createRouter, createRouterConfig, createSerializationAdapter, deepEqual, defaultParseSearch, defaultStringifySearch, defer, functionalUpdate, getRouteApi, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, lazyRouteComponent, linkOptions, notFound, parseSearchWith, reactUse, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rootRouteId, rootRouteWithContext, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight, useAwaited, useBlocker, useCanGoBack, useChildMatches, useElementScrollRestoration, useHydrated, useLayoutEffect, useLinkProps, useLoaderData, useLoaderDeps, useLocation, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useParentMatches, useRouteContext, useRouter, useRouterState, useSearch, useTags } from "@tanstack/react-router";
2
2
  export { Form, RouteActionResponseError, useFetcher } from "../router/runtime/tanstack/dataMutation.mjs";
3
+ export { Outlet } from "../router/runtime/tanstack/outlet.mjs";
3
4
  export { Link, NavLink } from "../router/runtime/tanstack/prefetchLink.mjs";
@@ -77,9 +77,21 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
77
77
  const topLevel = rootModern ? rootModern.children || [] : routes;
78
78
  const imports = [];
79
79
  const statements = [];
80
+ const componentImportMap = new Map();
80
81
  const loaderImportMap = new Map();
82
+ const usedRouteVarNames = new Set();
83
+ let componentIndex = 0;
81
84
  let loaderIndex = 0;
82
85
  let routeIndex = 0;
86
+ const getImportNameForComponent = (componentPath)=>{
87
+ if ('string' != typeof componentPath || 0 === componentPath.length) return null;
88
+ const existing = componentImportMap.get(componentPath);
89
+ if (existing) return existing;
90
+ const componentName = `component_${componentIndex++}`;
91
+ imports.push(`import ${componentName} from ${quote(componentPath)};`);
92
+ componentImportMap.set(componentPath, componentName);
93
+ return componentName;
94
+ };
83
95
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
84
96
  const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
85
97
  const existing = loaderImportMap.get(key);
@@ -111,10 +123,17 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
111
123
  actionName
112
124
  };
113
125
  };
126
+ const reserveRouteVarName = (preferred)=>{
127
+ let candidate = preferred;
128
+ let suffix = 1;
129
+ while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
130
+ usedRouteVarNames.add(candidate);
131
+ return candidate;
132
+ };
114
133
  const createRouteVarName = (route)=>{
115
134
  const id = route.id;
116
135
  const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
117
- return `route_${base}`;
136
+ return reserveRouteVarName(`route_${base}`);
118
137
  };
119
138
  const buildRoute = async (opts)=>{
120
139
  const { parentVar, route } = opts;
@@ -129,6 +148,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
129
148
  const routeOpts = [
130
149
  `getParentRoute: () => ${parentVar},`
131
150
  ];
151
+ const componentName = getImportNameForComponent(route._component);
152
+ if (componentName) routeOpts.push(`component: ${componentName},`);
132
153
  if (isPathlessLayout(route)) {
133
154
  const id = route.id;
134
155
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
@@ -143,14 +164,16 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
143
164
  actionName
144
165
  });
145
166
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
146
- statements.push(`const ${varName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
147
167
  const children = route.children;
168
+ const hasChildren = Boolean(children && children.length > 0);
169
+ const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
170
+ statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
148
171
  if (children && children.length > 0) {
149
172
  const childVars = await Promise.all(children.map((child)=>buildRoute({
150
- parentVar: varName,
173
+ parentVar: routeCtorVarName,
151
174
  route: child
152
175
  })));
153
- statements.push(`${varName}.addChildren([${childVars.join(', ')}]);`);
176
+ statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
154
177
  }
155
178
  return varName;
156
179
  };
@@ -164,6 +187,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
164
187
  route
165
188
  })));
166
189
  const rootOpts = [];
190
+ const rootComponentName = getImportNameForComponent(rootModern?._component);
191
+ if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
167
192
  if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
168
193
  const routerGenTs = `/* eslint-disable */
169
194
  // This file is auto-generated by Modern.js. Do not edit manually.
@@ -197,7 +222,7 @@ function isRedirectResponse(res: Response) {
197
222
  }
198
223
 
199
224
  function throwTanstackRedirect(location: string) {
200
- const target = location || '/';
225
+ const target = location.length > 0 ? location : '/';
201
226
  try {
202
227
  void new URL(target);
203
228
  throw redirect({ href: target });
@@ -223,21 +248,87 @@ function createRouteStaticData(opts: {
223
248
  modernRouteAction?: unknown;
224
249
  modernRouteLoader?: unknown;
225
250
  }) {
226
- const staticData: Record<string, unknown> = {};
251
+ const staticData: {
252
+ modernRouteId?: string;
253
+ modernRouteAction?: unknown;
254
+ modernRouteLoader?: unknown;
255
+ } = {};
227
256
 
228
- if (opts.modernRouteId) {
257
+ if (typeof opts.modernRouteId === 'string' && opts.modernRouteId.length > 0) {
229
258
  staticData.modernRouteId = opts.modernRouteId;
230
259
  }
231
260
 
232
- if (opts.modernRouteLoader) {
261
+ if (typeof opts.modernRouteLoader !== 'undefined') {
233
262
  staticData.modernRouteLoader = opts.modernRouteLoader;
234
263
  }
235
264
 
236
- if (opts.modernRouteAction) {
265
+ if (typeof opts.modernRouteAction !== 'undefined') {
237
266
  staticData.modernRouteAction = opts.modernRouteAction;
238
267
  }
239
268
 
240
- return Object.keys(staticData).length > 0 ? staticData : undefined;
269
+ return staticData;
270
+ }
271
+
272
+ function getLoaderSignal(ctx: any): AbortSignal {
273
+ const abortSignal = ctx?.abortController?.signal;
274
+ if (abortSignal instanceof AbortSignal) {
275
+ return abortSignal;
276
+ }
277
+ if (ctx?.signal instanceof AbortSignal) {
278
+ return ctx.signal;
279
+ }
280
+ return new AbortController().signal;
281
+ }
282
+
283
+ function getLoaderHref(ctx: any): string {
284
+ if (typeof ctx?.location === 'string') {
285
+ return ctx.location;
286
+ }
287
+
288
+ const publicHref = ctx?.location?.publicHref;
289
+ if (typeof publicHref === 'string') {
290
+ return publicHref;
291
+ }
292
+
293
+ const href = ctx?.location?.href;
294
+ if (typeof href === 'string') {
295
+ return href;
296
+ }
297
+
298
+ const urlHref = ctx?.location?.url?.href;
299
+ return typeof urlHref === 'string' ? urlHref : '';
300
+ }
301
+
302
+ function getLoaderParams(ctx: any): Record<string, string> {
303
+ return typeof ctx?.params === 'object' && ctx.params !== null ? ctx.params : {};
304
+ }
305
+
306
+ function handleModernLoaderResult<LoaderResult>(result: LoaderResult): LoaderResult {
307
+ if (isResponse(result)) {
308
+ if (isRedirectResponse(result)) {
309
+ const location = result.headers.get('Location') ?? '/';
310
+ throwTanstackRedirect(location);
311
+ }
312
+ if (result.status === 404) {
313
+ throw notFound();
314
+ }
315
+ }
316
+
317
+ return result;
318
+ }
319
+
320
+ function handleModernLoaderError(err: unknown): never {
321
+ if (isResponse(err)) {
322
+ if (isRedirectResponse(err)) {
323
+ const location = err.headers.get('Location') ?? '/';
324
+ throwTanstackRedirect(location);
325
+ }
326
+ if (err.status === 404) {
327
+ throw notFound();
328
+ }
329
+ }
330
+
331
+ throw err;
241
332
  }
242
333
 
243
334
  function modernLoaderToTanstack<TLoader extends (args: any) => any>(
@@ -246,57 +337,31 @@ function modernLoaderToTanstack<TLoader extends (args: any) => any>(
246
337
  ) {
247
338
  type LoaderResult = Awaited<ReturnType<TLoader>>;
248
339
 
249
- return async (ctx: any): Promise<LoaderResult> => {
340
+ return (ctx: any): Promise<LoaderResult> => {
250
341
  try {
251
- const signal: AbortSignal =
252
- ctx?.abortController?.signal ||
253
- ctx?.signal ||
254
- new AbortController().signal;
342
+ const signal = getLoaderSignal(ctx);
255
343
  const baseRequest: Request | undefined =
256
344
  ctx?.context?.request instanceof Request ? ctx.context.request : undefined;
257
345
 
258
- const href =
259
- typeof ctx?.location === 'string'
260
- ? ctx.location
261
- : ctx?.location?.publicHref ||
262
- ctx?.location?.href ||
263
- ctx?.location?.url?.href ||
264
- '';
346
+ const href = getLoaderHref(ctx);
265
347
 
266
- const request = baseRequest
348
+ const request = baseRequest !== undefined
267
349
  ? new Request(baseRequest, { signal })
268
350
  : new Request(href, { signal });
269
351
 
270
- const params = mapParamsForModernLoader(ctx?.params || {}, opts.hasSplat);
271
-
272
- const result = await (modernLoader as any)({
273
- request,
274
- params,
275
- context: ctx?.context?.requestContext,
276
- });
277
-
278
- if (isResponse(result)) {
279
- if (isRedirectResponse(result)) {
280
- const location = result.headers.get('Location') || '/';
281
- throwTanstackRedirect(location);
282
- }
283
- if (result.status === 404) {
284
- throw notFound();
285
- }
286
- }
352
+ const params = mapParamsForModernLoader(getLoaderParams(ctx), opts.hasSplat);
287
353
 
288
- return result as LoaderResult;
354
+ return Promise.resolve(
355
+ (modernLoader as any)({
356
+ request,
357
+ params,
358
+ context: ctx?.context?.requestContext,
359
+ }),
360
+ )
361
+ .then((result: LoaderResult) => handleModernLoaderResult(result))
362
+ .catch(handleModernLoaderError);
289
363
  } catch (err) {
290
- if (isResponse(err)) {
291
- if (isRedirectResponse(err)) {
292
- const location = err.headers.get('Location') || '/';
293
- throwTanstackRedirect(location);
294
- }
295
- if (err.status === 404) {
296
- throw notFound();
297
- }
298
- }
299
- throw err;
364
+ handleModernLoaderError(err);
300
365
  }
301
366
  };
302
367
  }
@@ -100,7 +100,20 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
100
100
  const loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, 'map.json');
101
101
  const importLazyCode = `
102
102
  import { lazy } from "react";
103
- import loadable, { lazy as loadableLazy } from "@${metaName}/runtime/loadable"
103
+ import * as loadableModule from "@${metaName}/runtime/loadable"
104
+
105
+ const resolveLoadableExport = module => {
106
+ const candidates = [module, module.default, module.default?.default];
107
+ const loadable = candidates.find(candidate => typeof candidate === 'function');
108
+
109
+ if (!loadable) {
110
+ throw new TypeError('Modern.js runtime loadable export must resolve to a function');
111
+ }
112
+
113
+ return loadable;
114
+ };
115
+ const loadable = resolveLoadableExport(loadableModule);
116
+ const loadableLazy = loadableModule.lazy || loadableModule.default?.lazy || loadable.lazy;
104
117
  `;
105
118
  let rootLayoutCode = "";
106
119
  const getDataLoaderPath = ({ loaderId, clientData, action, inline, routeId, inValidSSRRoute })=>{
@@ -170,16 +183,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
170
183
  webpackChunkName: true
171
184
  });
172
185
  component = 'string' === ssrMode ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
173
- } else if ('string' === ssrMode) {
186
+ } else {
174
187
  components.push(route._component);
175
188
  component = `component_${components.length - 1}`;
176
- } else {
177
- lazyImport = createLazyImport({
178
- componentPath: route._component,
179
- routeId: route.id,
180
- eager: true
181
- });
182
- component = `lazy(${lazyImport})`;
183
189
  }
184
190
  } else if (route._component) if (splitRouteChunks) {
185
191
  lazyImport = `() => import('${route._component}')`;