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

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,6 +1,195 @@
1
1
  import "node:module";
2
2
  "use client";
3
- import react_helmet, { Helmet } from "react-helmet";
4
- const head = react_helmet;
5
- export default head;
6
- export { Helmet };
3
+ import react from "react";
4
+ import { Helmet, HelmetData, HelmetProvider } from "react-helmet-async";
5
+ import { InternalRuntimeContext } from "../core/context/index.mjs";
6
+ const ATTRIBUTE_NAME_MAP = {
7
+ charSet: 'charset',
8
+ className: 'class',
9
+ contentEditable: 'contenteditable',
10
+ httpEquiv: 'http-equiv',
11
+ itemProp: 'itemprop',
12
+ tabIndex: 'tabindex'
13
+ };
14
+ const escapeHtml = (value)=>String(value).replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
15
+ const toHtmlAttributeName = (name)=>ATTRIBUTE_NAME_MAP[name] ?? name;
16
+ const attributesToString = (attributes, includeHelmetAttribute = false)=>{
17
+ const pairs = [];
18
+ if (includeHelmetAttribute) pairs.push('data-rh="true"');
19
+ for (const [name, value] of Object.entries(attributes ?? {})){
20
+ if (false === value || null == value) continue;
21
+ const htmlName = toHtmlAttributeName(name);
22
+ if (true === value) pairs.push(htmlName);
23
+ else pairs.push(`${htmlName}="${escapeHtml(value)}"`);
24
+ }
25
+ return pairs.join(' ');
26
+ };
27
+ const createDatum = (tagName, tags)=>({
28
+ toComponent: ()=>[],
29
+ toString: ()=>tags.map((tag)=>{
30
+ const attrs = attributesToString(tag, true);
31
+ if ("script" === tagName && 'string' == typeof tag.innerHTML) return `<script ${attrs}>${tag.innerHTML}</script>`;
32
+ if ('style' === tagName && 'string' == typeof tag.cssText) return `<style ${attrs}>${tag.cssText}</style>`;
33
+ if ("noscript" === tagName && 'string' == typeof tag.innerHTML) return `<noscript ${attrs}>${tag.innerHTML}</noscript>`;
34
+ return `<${tagName} ${attrs}>`;
35
+ }).join('')
36
+ });
37
+ const createAttributeDatum = (attributes)=>({
38
+ toComponent: ()=>attributes,
39
+ toString: ()=>attributesToString(attributes)
40
+ });
41
+ const createTitleDatum = (title, attributes)=>({
42
+ toComponent: ()=>[],
43
+ toString: ()=>{
44
+ if (void 0 === title || '' === title) return '';
45
+ const attrs = attributesToString(attributes, true);
46
+ return `<title ${attrs}>${escapeHtml(title)}</title>`;
47
+ }
48
+ });
49
+ const createEmptyHelmetState = ()=>({
50
+ base: createDatum('base', []),
51
+ bodyAttributes: createAttributeDatum({}),
52
+ htmlAttributes: createAttributeDatum({}),
53
+ link: createDatum('link', []),
54
+ meta: createDatum('meta', []),
55
+ noscript: createDatum("noscript", []),
56
+ priority: createDatum('meta', []),
57
+ script: createDatum("script", []),
58
+ style: createDatum('style', []),
59
+ title: createTitleDatum(void 0, {})
60
+ });
61
+ const normalizeHelmetTitle = (title)=>{
62
+ if ('string' == typeof title) return title;
63
+ if (Array.isArray(title)) return title.map((part)=>String(part)).join('');
64
+ };
65
+ const mergeAttributes = (current, next)=>({
66
+ ...current,
67
+ ...next ?? {}
68
+ });
69
+ const collectChildren = (children, draft)=>{
70
+ react.Children.forEach(children, (child)=>{
71
+ if (!react.isValidElement(child)) return;
72
+ if (child.type === react.Fragment) return void collectChildren(child.props.children, draft);
73
+ if ('string' != typeof child.type) return;
74
+ const { children: nestedChildren, ...props } = child.props;
75
+ if ('title' === child.type) {
76
+ draft.title = react.Children.toArray(nestedChildren).join('');
77
+ draft.titleAttributes = mergeAttributes(draft.titleAttributes, props);
78
+ return;
79
+ }
80
+ if ('html' === child.type || 'body' === child.type) return;
81
+ if ('base' === child.type || 'link' === child.type || 'meta' === child.type || "noscript" === child.type || "script" === child.type || 'style' === child.type) {
82
+ const tag = {
83
+ ...props
84
+ };
85
+ if (("script" === child.type || 'style' === child.type || "noscript" === child.type) && 'string' == typeof nestedChildren) tag['style' === child.type ? 'cssText' : 'innerHTML'] = nestedChildren;
86
+ draft[child.type].push(tag);
87
+ }
88
+ });
89
+ };
90
+ const collectHelmetProps = (current, props)=>{
91
+ const baseState = current ?? createEmptyHelmetState();
92
+ const draft = {
93
+ base: [
94
+ ...void 0 !== props.base ? [
95
+ props.base
96
+ ] : []
97
+ ],
98
+ bodyAttributes: props.bodyAttributes,
99
+ htmlAttributes: props.htmlAttributes,
100
+ link: [
101
+ ...props.link ?? []
102
+ ],
103
+ meta: [
104
+ ...props.meta ?? []
105
+ ],
106
+ noscript: [
107
+ ...props.noscript ?? []
108
+ ],
109
+ script: [
110
+ ...props.script ?? []
111
+ ],
112
+ style: [
113
+ ...props.style ?? []
114
+ ],
115
+ title: normalizeHelmetTitle(props.title),
116
+ titleAttributes: props.titleAttributes ?? {}
117
+ };
118
+ collectChildren(props.children, draft);
119
+ const title = void 0 !== draft.title && '' !== draft.title && void 0 !== props.titleTemplate ? props.titleTemplate.replaceAll('%s', draft.title) : draft.title ?? props.defaultTitle;
120
+ return {
121
+ base: createDatum('base', [
122
+ ...baseState.__baseTags ?? [],
123
+ ...draft.base
124
+ ]),
125
+ bodyAttributes: createAttributeDatum(mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes)),
126
+ htmlAttributes: createAttributeDatum(mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes)),
127
+ link: createDatum('link', [
128
+ ...baseState.__linkTags ?? [],
129
+ ...draft.link
130
+ ]),
131
+ meta: createDatum('meta', [
132
+ ...baseState.__metaTags ?? [],
133
+ ...draft.meta
134
+ ]),
135
+ noscript: createDatum("noscript", [
136
+ ...baseState.__noscriptTags ?? [],
137
+ ...draft.noscript
138
+ ]),
139
+ priority: createDatum('meta', []),
140
+ script: createDatum("script", [
141
+ ...baseState.__scriptTags ?? [],
142
+ ...draft.script
143
+ ]),
144
+ style: createDatum('style', [
145
+ ...baseState.__styleTags ?? [],
146
+ ...draft.style
147
+ ]),
148
+ title: createTitleDatum(title ?? baseState.__title, mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)),
149
+ __baseTags: [
150
+ ...baseState.__baseTags ?? [],
151
+ ...draft.base
152
+ ],
153
+ __bodyAttributes: mergeAttributes(baseState.__bodyAttributes ?? {}, draft.bodyAttributes),
154
+ __htmlAttributes: mergeAttributes(baseState.__htmlAttributes ?? {}, draft.htmlAttributes),
155
+ __linkTags: [
156
+ ...baseState.__linkTags ?? [],
157
+ ...draft.link
158
+ ],
159
+ __metaTags: [
160
+ ...baseState.__metaTags ?? [],
161
+ ...draft.meta
162
+ ],
163
+ __noscriptTags: [
164
+ ...baseState.__noscriptTags ?? [],
165
+ ...draft.noscript
166
+ ],
167
+ __scriptTags: [
168
+ ...baseState.__scriptTags ?? [],
169
+ ...draft.script
170
+ ],
171
+ __styleTags: [
172
+ ...baseState.__styleTags ?? [],
173
+ ...draft.style
174
+ ],
175
+ __title: title ?? baseState.__title,
176
+ __titleAttributes: mergeAttributes(baseState.__titleAttributes ?? {}, draft.titleAttributes)
177
+ };
178
+ };
179
+ const head_Helmet = (props)=>{
180
+ const runtimeContext = react.useContext(InternalRuntimeContext);
181
+ if (null !== runtimeContext && false === runtimeContext.isBrowser) {
182
+ runtimeContext._helmetContext ??= {};
183
+ runtimeContext._helmetContext.helmet = collectHelmetProps(runtimeContext._helmetContext.helmet ?? void 0, props);
184
+ return null;
185
+ }
186
+ return react.createElement(Helmet, props);
187
+ };
188
+ const head = {
189
+ Helmet: head_Helmet,
190
+ HelmetData: HelmetData,
191
+ HelmetProvider: HelmetProvider
192
+ };
193
+ const exports_head = head;
194
+ export default exports_head;
195
+ export { HelmetData, HelmetProvider, head_Helmet as Helmet };
@@ -1,5 +1,28 @@
1
1
  import "node:module";
2
- import component from "@loadable/component";
2
+ import * as __rspack_external__loadable_component_0aaae075 from "@loadable/component";
3
3
  export * from "@loadable/component";
4
- const loadable = component;
5
- export default loadable;
4
+ function asLoadableNamespace(value) {
5
+ return 'object' == typeof value && null !== value ? value : {};
6
+ }
7
+ function resolveLoadable(module) {
8
+ const namespace = asLoadableNamespace(module);
9
+ const defaultExport = asLoadableNamespace(namespace.default);
10
+ const candidates = [
11
+ module,
12
+ namespace.default,
13
+ defaultExport?.default
14
+ ];
15
+ const loadable = candidates.find((candidate)=>'function' == typeof candidate);
16
+ if ('function' != typeof loadable) throw new TypeError('Modern.js runtime loadable export must resolve to a function');
17
+ return loadable;
18
+ }
19
+ const loadable_loadable = resolveLoadable(__rspack_external__loadable_component_0aaae075);
20
+ const loadableNamespace = asLoadableNamespace(__rspack_external__loadable_component_0aaae075);
21
+ const loadableDefaultNamespace = asLoadableNamespace(loadableNamespace.default);
22
+ const callableLoadableNamespace = asLoadableNamespace(loadable_loadable);
23
+ const lazy = loadableNamespace.lazy ?? loadableDefaultNamespace.lazy ?? callableLoadableNamespace.lazy;
24
+ const loadableReady = loadableNamespace.loadableReady ?? loadableDefaultNamespace.loadableReady ?? callableLoadableNamespace.loadableReady;
25
+ 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;
26
+ const exports_loadable = loadable_loadable;
27
+ export default exports_loadable;
28
+ export { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, lazy, loadableReady };
@@ -1,4 +1,5 @@
1
1
  import "node:module";
2
- export * from "@tanstack/react-router";
2
+ 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";
3
3
  export { Form, RouteActionResponseError, useFetcher } from "../router/runtime/tanstack/dataMutation.mjs";
4
+ export { Outlet } from "../router/runtime/tanstack/outlet.mjs";
4
5
  export { Link, NavLink } from "../router/runtime/tanstack/prefetchLink.mjs";
@@ -78,9 +78,21 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
78
78
  const topLevel = rootModern ? rootModern.children || [] : routes;
79
79
  const imports = [];
80
80
  const statements = [];
81
+ const componentImportMap = new Map();
81
82
  const loaderImportMap = new Map();
83
+ const usedRouteVarNames = new Set();
84
+ let componentIndex = 0;
82
85
  let loaderIndex = 0;
83
86
  let routeIndex = 0;
87
+ const getImportNameForComponent = (componentPath)=>{
88
+ if ('string' != typeof componentPath || 0 === componentPath.length) return null;
89
+ const existing = componentImportMap.get(componentPath);
90
+ if (existing) return existing;
91
+ const componentName = `component_${componentIndex++}`;
92
+ imports.push(`import ${componentName} from ${quote(componentPath)};`);
93
+ componentImportMap.set(componentPath, componentName);
94
+ return componentName;
95
+ };
84
96
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
85
97
  const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
86
98
  const existing = loaderImportMap.get(key);
@@ -112,10 +124,17 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
112
124
  actionName
113
125
  };
114
126
  };
127
+ const reserveRouteVarName = (preferred)=>{
128
+ let candidate = preferred;
129
+ let suffix = 1;
130
+ while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
131
+ usedRouteVarNames.add(candidate);
132
+ return candidate;
133
+ };
115
134
  const createRouteVarName = (route)=>{
116
135
  const id = route.id;
117
136
  const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
118
- return `route_${base}`;
137
+ return reserveRouteVarName(`route_${base}`);
119
138
  };
120
139
  const buildRoute = async (opts)=>{
121
140
  const { parentVar, route } = opts;
@@ -130,6 +149,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
130
149
  const routeOpts = [
131
150
  `getParentRoute: () => ${parentVar},`
132
151
  ];
152
+ const componentName = getImportNameForComponent(route._component);
153
+ if (componentName) routeOpts.push(`component: ${componentName},`);
133
154
  if (isPathlessLayout(route)) {
134
155
  const id = route.id;
135
156
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
@@ -144,14 +165,16 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
144
165
  actionName
145
166
  });
146
167
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
147
- statements.push(`const ${varName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
148
168
  const children = route.children;
169
+ const hasChildren = Boolean(children && children.length > 0);
170
+ const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
171
+ statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
149
172
  if (children && children.length > 0) {
150
173
  const childVars = await Promise.all(children.map((child)=>buildRoute({
151
- parentVar: varName,
174
+ parentVar: routeCtorVarName,
152
175
  route: child
153
176
  })));
154
- statements.push(`${varName}.addChildren([${childVars.join(', ')}]);`);
177
+ statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
155
178
  }
156
179
  return varName;
157
180
  };
@@ -165,6 +188,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
165
188
  route
166
189
  })));
167
190
  const rootOpts = [];
191
+ const rootComponentName = getImportNameForComponent(rootModern?._component);
192
+ if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
168
193
  if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
169
194
  const routerGenTs = `/* eslint-disable */
170
195
  // This file is auto-generated by Modern.js. Do not edit manually.
@@ -198,7 +223,7 @@ function isRedirectResponse(res: Response) {
198
223
  }
199
224
 
200
225
  function throwTanstackRedirect(location: string) {
201
- const target = location || '/';
226
+ const target = location.length > 0 ? location : '/';
202
227
  try {
203
228
  void new URL(target);
204
229
  throw redirect({ href: target });
@@ -224,21 +249,87 @@ function createRouteStaticData(opts: {
224
249
  modernRouteAction?: unknown;
225
250
  modernRouteLoader?: unknown;
226
251
  }) {
227
- const staticData: Record<string, unknown> = {};
252
+ const staticData: {
253
+ modernRouteId?: string;
254
+ modernRouteAction?: unknown;
255
+ modernRouteLoader?: unknown;
256
+ } = {};
228
257
 
229
- if (opts.modernRouteId) {
258
+ if (typeof opts.modernRouteId === 'string' && opts.modernRouteId.length > 0) {
230
259
  staticData.modernRouteId = opts.modernRouteId;
231
260
  }
232
261
 
233
- if (opts.modernRouteLoader) {
262
+ if (typeof opts.modernRouteLoader !== 'undefined') {
234
263
  staticData.modernRouteLoader = opts.modernRouteLoader;
235
264
  }
236
265
 
237
- if (opts.modernRouteAction) {
266
+ if (typeof opts.modernRouteAction !== 'undefined') {
238
267
  staticData.modernRouteAction = opts.modernRouteAction;
239
268
  }
240
269
 
241
- return Object.keys(staticData).length > 0 ? staticData : undefined;
270
+ return staticData;
271
+ }
272
+
273
+ function getLoaderSignal(ctx: any): AbortSignal {
274
+ const abortSignal = ctx?.abortController?.signal;
275
+ if (abortSignal instanceof AbortSignal) {
276
+ return abortSignal;
277
+ }
278
+ if (ctx?.signal instanceof AbortSignal) {
279
+ return ctx.signal;
280
+ }
281
+ return new AbortController().signal;
282
+ }
283
+
284
+ function getLoaderHref(ctx: any): string {
285
+ if (typeof ctx?.location === 'string') {
286
+ return ctx.location;
287
+ }
288
+
289
+ const publicHref = ctx?.location?.publicHref;
290
+ if (typeof publicHref === 'string') {
291
+ return publicHref;
292
+ }
293
+
294
+ const href = ctx?.location?.href;
295
+ if (typeof href === 'string') {
296
+ return href;
297
+ }
298
+
299
+ const urlHref = ctx?.location?.url?.href;
300
+ return typeof urlHref === 'string' ? urlHref : '';
301
+ }
302
+
303
+ function getLoaderParams(ctx: any): Record<string, string> {
304
+ return typeof ctx?.params === 'object' && ctx.params !== null ? ctx.params : {};
305
+ }
306
+
307
+ function handleModernLoaderResult<LoaderResult>(result: LoaderResult): LoaderResult {
308
+ if (isResponse(result)) {
309
+ if (isRedirectResponse(result)) {
310
+ const location = result.headers.get('Location') ?? '/';
311
+ throwTanstackRedirect(location);
312
+ }
313
+ if (result.status === 404) {
314
+ throw notFound();
315
+ }
316
+ }
317
+
318
+ return result;
319
+ }
320
+
321
+ function handleModernLoaderError(err: unknown): never {
322
+ if (isResponse(err)) {
323
+ if (isRedirectResponse(err)) {
324
+ const location = err.headers.get('Location') ?? '/';
325
+ throwTanstackRedirect(location);
326
+ }
327
+ if (err.status === 404) {
328
+ throw notFound();
329
+ }
330
+ }
331
+
332
+ throw err;
242
333
  }
243
334
 
244
335
  function modernLoaderToTanstack<TLoader extends (args: any) => any>(
@@ -247,57 +338,31 @@ function modernLoaderToTanstack<TLoader extends (args: any) => any>(
247
338
  ) {
248
339
  type LoaderResult = Awaited<ReturnType<TLoader>>;
249
340
 
250
- return async (ctx: any): Promise<LoaderResult> => {
341
+ return (ctx: any): Promise<LoaderResult> => {
251
342
  try {
252
- const signal: AbortSignal =
253
- ctx?.abortController?.signal ||
254
- ctx?.signal ||
255
- new AbortController().signal;
343
+ const signal = getLoaderSignal(ctx);
256
344
  const baseRequest: Request | undefined =
257
345
  ctx?.context?.request instanceof Request ? ctx.context.request : undefined;
258
346
 
259
- const href =
260
- typeof ctx?.location === 'string'
261
- ? ctx.location
262
- : ctx?.location?.publicHref ||
263
- ctx?.location?.href ||
264
- ctx?.location?.url?.href ||
265
- '';
347
+ const href = getLoaderHref(ctx);
266
348
 
267
- const request = baseRequest
349
+ const request = baseRequest !== undefined
268
350
  ? new Request(baseRequest, { signal })
269
351
  : new Request(href, { signal });
270
352
 
271
- const params = mapParamsForModernLoader(ctx?.params || {}, opts.hasSplat);
272
-
273
- const result = await (modernLoader as any)({
274
- request,
275
- params,
276
- context: ctx?.context?.requestContext,
277
- });
278
-
279
- if (isResponse(result)) {
280
- if (isRedirectResponse(result)) {
281
- const location = result.headers.get('Location') || '/';
282
- throwTanstackRedirect(location);
283
- }
284
- if (result.status === 404) {
285
- throw notFound();
286
- }
287
- }
353
+ const params = mapParamsForModernLoader(getLoaderParams(ctx), opts.hasSplat);
288
354
 
289
- return result as LoaderResult;
355
+ return Promise.resolve(
356
+ (modernLoader as any)({
357
+ request,
358
+ params,
359
+ context: ctx?.context?.requestContext,
360
+ }),
361
+ )
362
+ .then((result: LoaderResult) => handleModernLoaderResult(result))
363
+ .catch(handleModernLoaderError);
290
364
  } catch (err) {
291
- if (isResponse(err)) {
292
- if (isRedirectResponse(err)) {
293
- const location = err.headers.get('Location') || '/';
294
- throwTanstackRedirect(location);
295
- }
296
- if (err.status === 404) {
297
- throw notFound();
298
- }
299
- }
300
- throw err;
365
+ handleModernLoaderError(err);
301
366
  }
302
367
  };
303
368
  }
@@ -102,7 +102,20 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
102
102
  const loadersMapFile = path.join(internalDirectory, entryName, TEMP_LOADERS_DIR, 'map.json');
103
103
  const importLazyCode = `
104
104
  import { lazy } from "react";
105
- import loadable, { lazy as loadableLazy } from "@${metaName}/runtime/loadable"
105
+ import * as loadableModule from "@${metaName}/runtime/loadable"
106
+
107
+ const resolveLoadableExport = module => {
108
+ const candidates = [module, module.default, module.default?.default];
109
+ const loadable = candidates.find(candidate => typeof candidate === 'function');
110
+
111
+ if (!loadable) {
112
+ throw new TypeError('Modern.js runtime loadable export must resolve to a function');
113
+ }
114
+
115
+ return loadable;
116
+ };
117
+ const loadable = resolveLoadableExport(loadableModule);
118
+ const loadableLazy = loadableModule.lazy || loadableModule.default?.lazy || loadable.lazy;
106
119
  `;
107
120
  let rootLayoutCode = "";
108
121
  const getDataLoaderPath = ({ loaderId, clientData, action, inline, routeId, inValidSSRRoute })=>{
@@ -172,16 +185,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
172
185
  webpackChunkName: true
173
186
  });
174
187
  component = 'string' === ssrMode ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
175
- } else if ('string' === ssrMode) {
188
+ } else {
176
189
  components.push(route._component);
177
190
  component = `component_${components.length - 1}`;
178
- } else {
179
- lazyImport = createLazyImport({
180
- componentPath: route._component,
181
- routeId: route.id,
182
- eager: true
183
- });
184
- component = `lazy(${lazyImport})`;
185
191
  }
186
192
  } else if (route._component) if (splitRouteChunks) {
187
193
  lazyImport = `() => import('${route._component}')`;