@bleedingdev/modern-js-runtime 3.2.0-ultramodern.6 → 3.2.0-ultramodern.62

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 (193) hide show
  1. package/dist/cjs/boundary-debugger/index.js +221 -0
  2. package/dist/cjs/cli/ssr/index.js +3 -2
  3. package/dist/cjs/cli/template.server.js +1 -0
  4. package/dist/cjs/core/plugin/index.js +3 -2
  5. package/dist/cjs/core/server/helmet.js +2 -2
  6. package/dist/cjs/core/server/stream/afterTemplate.js +9 -6
  7. package/dist/cjs/core/server/stream/beforeTemplate.js +6 -7
  8. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +104 -0
  9. package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -1
  10. package/dist/cjs/core/server/stream/shared.js +1 -0
  11. package/dist/cjs/core/server/string/index.js +1 -0
  12. package/dist/cjs/core/server/string/loadable.js +16 -1
  13. package/dist/cjs/router/cli/code/tanstackTypes.js +20 -6
  14. package/dist/cjs/router/cli/code/templates.js +1 -8
  15. package/dist/cjs/router/runtime/tanstack/plugin.js +2 -0
  16. package/dist/cjs/router/runtime/tanstack/routeTree.js +38 -2
  17. package/dist/cjs/rsc/server.worker.js +58 -0
  18. package/dist/esm/boundary-debugger/index.mjs +185 -0
  19. package/dist/esm/cli/ssr/index.mjs +3 -2
  20. package/dist/esm/cli/template.server.mjs +1 -0
  21. package/dist/esm/core/plugin/index.mjs +3 -2
  22. package/dist/esm/core/server/helmet.mjs +1 -1
  23. package/dist/esm/core/server/stream/afterTemplate.mjs +10 -7
  24. package/dist/esm/core/server/stream/beforeTemplate.mjs +6 -7
  25. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +60 -0
  26. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +2 -1
  27. package/dist/esm/core/server/stream/shared.mjs +1 -0
  28. package/dist/esm/core/server/string/index.mjs +1 -0
  29. package/dist/esm/core/server/string/loadable.mjs +16 -1
  30. package/dist/esm/router/cli/code/tanstackTypes.mjs +20 -6
  31. package/dist/esm/router/cli/code/templates.mjs +1 -8
  32. package/dist/esm/router/runtime/tanstack/plugin.mjs +2 -0
  33. package/dist/esm/router/runtime/tanstack/routeTree.mjs +38 -2
  34. package/dist/esm/rsc/server.worker.mjs +1 -0
  35. package/dist/esm-node/boundary-debugger/index.mjs +186 -0
  36. package/dist/esm-node/cli/ssr/index.mjs +3 -2
  37. package/dist/esm-node/cli/template.server.mjs +1 -0
  38. package/dist/esm-node/core/plugin/index.mjs +3 -2
  39. package/dist/esm-node/core/server/helmet.mjs +1 -1
  40. package/dist/esm-node/core/server/stream/afterTemplate.mjs +10 -7
  41. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +6 -7
  42. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +61 -0
  43. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +2 -1
  44. package/dist/esm-node/core/server/stream/shared.mjs +1 -0
  45. package/dist/esm-node/core/server/string/index.mjs +1 -0
  46. package/dist/esm-node/core/server/string/loadable.mjs +16 -1
  47. package/dist/esm-node/router/cli/code/tanstackTypes.mjs +20 -6
  48. package/dist/esm-node/router/cli/code/templates.mjs +1 -8
  49. package/dist/esm-node/router/runtime/tanstack/plugin.mjs +2 -0
  50. package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +38 -2
  51. package/dist/esm-node/rsc/server.worker.mjs +2 -0
  52. package/dist/types/boundary-debugger/index.d.ts +25 -0
  53. package/dist/types/cache/index.d.ts +1 -0
  54. package/dist/types/cli/alias.d.ts +7 -0
  55. package/dist/types/cli/code.d.ts +3 -0
  56. package/dist/types/cli/constants.d.ts +9 -0
  57. package/dist/types/cli/entry.d.ts +2 -0
  58. package/dist/types/cli/index.d.ts +11 -0
  59. package/dist/types/cli/ssr/index.d.ts +6 -0
  60. package/dist/types/cli/ssr/loadable-bundler-plugin.d.ts +31 -0
  61. package/dist/types/cli/ssr/mode.d.ts +15 -0
  62. package/dist/types/cli/template.d.ts +50 -0
  63. package/dist/types/cli/template.server.d.ts +20 -0
  64. package/dist/types/common.d.ts +8 -0
  65. package/dist/types/core/browser/hydrate.d.ts +5 -0
  66. package/dist/types/core/browser/index.d.ts +9 -0
  67. package/dist/types/core/browser/withCallback.d.ts +5 -0
  68. package/dist/types/core/compat/hooks.d.ts +4 -0
  69. package/dist/types/core/compat/index.d.ts +2 -0
  70. package/dist/types/core/compat/requestContext.d.ts +5 -0
  71. package/dist/types/core/config.d.ts +6 -0
  72. package/dist/types/core/constants.d.ts +6 -0
  73. package/dist/types/core/context/index.d.ts +50 -0
  74. package/dist/types/core/context/monitors/default.d.ts +2 -0
  75. package/dist/types/core/context/monitors/index.d.ts +1 -0
  76. package/dist/types/core/context/monitors/index.server.d.ts +2 -0
  77. package/dist/types/core/context/request/index.d.ts +1 -0
  78. package/dist/types/core/context/request/index.server.d.ts +1 -0
  79. package/dist/types/core/context/response/index.d.ts +4 -0
  80. package/dist/types/core/context/response/index.server.d.ts +4 -0
  81. package/dist/types/core/context/runtime.d.ts +42 -0
  82. package/dist/types/core/context/serverPayload/index.d.ts +4 -0
  83. package/dist/types/core/context/serverPayload/index.server.d.ts +31 -0
  84. package/dist/types/core/index.d.ts +5 -0
  85. package/dist/types/core/plugin/index.d.ts +5 -0
  86. package/dist/types/core/plugin/types.d.ts +10 -0
  87. package/dist/types/core/react/index.d.ts +2 -0
  88. package/dist/types/core/react/wrapper.d.ts +3 -0
  89. package/dist/types/core/server/constants.d.ts +4 -0
  90. package/dist/types/core/server/helmet.d.ts +3 -0
  91. package/dist/types/core/server/index.d.ts +4 -0
  92. package/dist/types/core/server/react/index.d.ts +2 -0
  93. package/dist/types/core/server/react/no-ssr-cache/index.d.ts +2 -0
  94. package/dist/types/core/server/react/nossr/index.d.ts +4 -0
  95. package/dist/types/core/server/requestHandler.d.ts +13 -0
  96. package/dist/types/core/server/server.d.ts +4 -0
  97. package/dist/types/core/server/shared.d.ts +8 -0
  98. package/dist/types/core/server/stream/afterTemplate.d.ts +13 -0
  99. package/dist/types/core/server/stream/beforeTemplate.d.ts +9 -0
  100. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +9 -0
  101. package/dist/types/core/server/stream/createReadableStream.d.ts +2 -0
  102. package/dist/types/core/server/stream/createReadableStream.worker.d.ts +2 -0
  103. package/dist/types/core/server/stream/deferredScript.d.ts +15 -0
  104. package/dist/types/core/server/stream/index.d.ts +1 -0
  105. package/dist/types/core/server/stream/shared.d.ts +40 -0
  106. package/dist/types/core/server/stream/template.d.ts +9 -0
  107. package/dist/types/core/server/string/index.d.ts +2 -0
  108. package/dist/types/core/server/string/loadable.d.ts +39 -0
  109. package/dist/types/core/server/string/ssrData.d.ts +20 -0
  110. package/dist/types/core/server/string/types.d.ts +12 -0
  111. package/dist/types/core/server/tracer.d.ts +17 -0
  112. package/dist/types/core/server/utils.d.ts +19 -0
  113. package/dist/types/core/types.d.ts +49 -0
  114. package/dist/types/document/Body.d.ts +2 -0
  115. package/dist/types/document/Comment.d.ts +5 -0
  116. package/dist/types/document/DocumentContext.d.ts +13 -0
  117. package/dist/types/document/DocumentStructureContext.d.ts +12 -0
  118. package/dist/types/document/Head.d.ts +5 -0
  119. package/dist/types/document/Html.d.ts +4 -0
  120. package/dist/types/document/Links.d.ts +2 -0
  121. package/dist/types/document/Root.d.ts +7 -0
  122. package/dist/types/document/Script.d.ts +4 -0
  123. package/dist/types/document/Scripts.d.ts +2 -0
  124. package/dist/types/document/Style.d.ts +5 -0
  125. package/dist/types/document/Title.d.ts +1 -0
  126. package/dist/types/document/cli/index.d.ts +5 -0
  127. package/dist/types/document/constants.d.ts +25 -0
  128. package/dist/types/document/index.d.ts +12 -0
  129. package/dist/types/exports/config-routes.d.ts +9 -0
  130. package/dist/types/exports/head.d.ts +4 -0
  131. package/dist/types/exports/loadable.d.ts +3 -0
  132. package/dist/types/exports/tanstack-router.d.ts +5 -0
  133. package/dist/types/index.d.ts +10 -0
  134. package/dist/types/internal.d.ts +2 -0
  135. package/dist/types/react-server.d.ts +3 -0
  136. package/dist/types/router/cli/code/getClientRoutes/getRoutes.d.ts +8 -0
  137. package/dist/types/router/cli/code/getClientRoutes/index.d.ts +1 -0
  138. package/dist/types/router/cli/code/getClientRoutes/utils.d.ts +4 -0
  139. package/dist/types/router/cli/code/index.d.ts +12 -0
  140. package/dist/types/router/cli/code/inspect.d.ts +22 -0
  141. package/dist/types/router/cli/code/makeLegalIdentifier.d.ts +1 -0
  142. package/dist/types/router/cli/code/nestedRoutes.d.ts +13 -0
  143. package/dist/types/router/cli/code/tanstackTypes.d.ts +10 -0
  144. package/dist/types/router/cli/code/templates.d.ts +28 -0
  145. package/dist/types/router/cli/code/utils.d.ts +12 -0
  146. package/dist/types/router/cli/config-routes/converter.d.ts +15 -0
  147. package/dist/types/router/cli/config-routes/parseRouteConfig.d.ts +32 -0
  148. package/dist/types/router/cli/constants.d.ts +31 -0
  149. package/dist/types/router/cli/entry.d.ts +18 -0
  150. package/dist/types/router/cli/handler.d.ts +28 -0
  151. package/dist/types/router/cli/index.d.ts +5 -0
  152. package/dist/types/router/index.d.ts +1 -0
  153. package/dist/types/router/internal.d.ts +2 -0
  154. package/dist/types/router/runtime/CSSLinks.d.ts +9 -0
  155. package/dist/types/router/runtime/DefaultNotFound.d.ts +2 -0
  156. package/dist/types/router/runtime/DeferredDataScripts.d.ts +2 -0
  157. package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +11 -0
  158. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -0
  159. package/dist/types/router/runtime/constants.d.ts +146 -0
  160. package/dist/types/router/runtime/hooks.d.ts +18 -0
  161. package/dist/types/router/runtime/index.d.ts +7 -0
  162. package/dist/types/router/runtime/internal.d.ts +11 -0
  163. package/dist/types/router/runtime/lifecycle.d.ts +25 -0
  164. package/dist/types/router/runtime/plugin.d.ts +9 -0
  165. package/dist/types/router/runtime/plugin.node.d.ts +7 -0
  166. package/dist/types/router/runtime/routerHelper.d.ts +5 -0
  167. package/dist/types/router/runtime/rsc-router.d.ts +20 -0
  168. package/dist/types/router/runtime/rsc.d.ts +1 -0
  169. package/dist/types/router/runtime/server.d.ts +1 -0
  170. package/dist/types/router/runtime/tanstack/basepathRewrite.d.ts +8 -0
  171. package/dist/types/router/runtime/tanstack/dataMutation.d.ts +29 -0
  172. package/dist/types/router/runtime/tanstack/plugin.d.ts +6 -0
  173. package/dist/types/router/runtime/tanstack/plugin.node.d.ts +6 -0
  174. package/dist/types/router/runtime/tanstack/prefetchLink.d.ts +11 -0
  175. package/dist/types/router/runtime/tanstack/routeTree.d.ts +8 -0
  176. package/dist/types/router/runtime/tanstack/rsc/ClientSlot.d.ts +5 -0
  177. package/dist/types/router/runtime/tanstack/rsc/CompositeComponent.d.ts +3 -0
  178. package/dist/types/router/runtime/tanstack/rsc/ReplayableStream.d.ts +24 -0
  179. package/dist/types/router/runtime/tanstack/rsc/RscNodeRenderer.d.ts +5 -0
  180. package/dist/types/router/runtime/tanstack/rsc/SlotContext.d.ts +11 -0
  181. package/dist/types/router/runtime/tanstack/rsc/client.d.ts +11 -0
  182. package/dist/types/router/runtime/tanstack/rsc/createRscProxy.d.ts +7 -0
  183. package/dist/types/router/runtime/tanstack/rsc/index.d.ts +2 -0
  184. package/dist/types/router/runtime/tanstack/rsc/server.d.ts +14 -0
  185. package/dist/types/router/runtime/tanstack/rsc/slotUsageSanitizer.d.ts +2 -0
  186. package/dist/types/router/runtime/tanstack/rsc/symbols.d.ts +46 -0
  187. package/dist/types/router/runtime/types.d.ts +119 -0
  188. package/dist/types/router/runtime/utils.d.ts +48 -0
  189. package/dist/types/router/runtime/withRouter.d.ts +10 -0
  190. package/dist/types/rsc/client.d.ts +2 -0
  191. package/dist/types/rsc/server.d.ts +1 -0
  192. package/dist/types/rsc/server.worker.d.ts +1 -0
  193. package/package.json +22 -15
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ default: ()=>boundary_debugger,
28
+ ultramodernBoundaryDebuggerPlugin: ()=>ultramodernBoundaryDebuggerPlugin
29
+ });
30
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
+ const external_react_namespaceObject = require("react");
32
+ const defaultStorageKey = 'modernjs:boundary-debugger:enabled';
33
+ const defaultLabels = {
34
+ cs: {
35
+ toggle: 'zobrazit hranice verticalů'
36
+ },
37
+ en: {
38
+ toggle: 'show vertical boundaries'
39
+ }
40
+ };
41
+ const palette = [
42
+ '#ff5a5f',
43
+ '#30e27a',
44
+ '#f6cf45',
45
+ '#7c8cff',
46
+ '#29b6f6'
47
+ ];
48
+ const readEnabled = (storageKey, fallback)=>{
49
+ if ("u" < typeof window) return fallback;
50
+ const stored = window.localStorage.getItem(storageKey);
51
+ return null === stored ? fallback : 'true' === stored;
52
+ };
53
+ const detectLanguage = ()=>{
54
+ if ("u" < typeof document) return 'en';
55
+ const htmlLanguage = document.documentElement.lang;
56
+ if (htmlLanguage) return htmlLanguage.split('-')[0] || 'en';
57
+ return window.location.pathname.split('/').filter(Boolean)[0] || 'en';
58
+ };
59
+ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, metadata, storageKey = defaultStorageKey }) {
60
+ const [mounted, setMounted] = (0, external_react_namespaceObject.useState)(false);
61
+ const [enabled, setEnabled] = (0, external_react_namespaceObject.useState)(false);
62
+ const [boxes, setBoxes] = (0, external_react_namespaceObject.useState)([]);
63
+ const boundaries = (0, external_react_namespaceObject.useMemo)(()=>new Map(metadata.boundaries.map((entry, index)=>[
64
+ entry.mfName,
65
+ {
66
+ ...entry,
67
+ color: entry.color ?? palette[index % palette.length],
68
+ label: entry.label ?? entry.appId
69
+ }
70
+ ])), [
71
+ metadata
72
+ ]);
73
+ const language = mounted ? detectLanguage() : 'en';
74
+ const toggleLabel = labels[language]?.toggle ?? labels.en?.toggle ?? defaultLabels.en?.toggle ?? 'show vertical boundaries';
75
+ (0, external_react_namespaceObject.useEffect)(()=>{
76
+ setMounted(true);
77
+ setEnabled(readEnabled(storageKey, enabledByDefault));
78
+ }, [
79
+ enabledByDefault,
80
+ storageKey
81
+ ]);
82
+ (0, external_react_namespaceObject.useEffect)(()=>{
83
+ if (!mounted) return;
84
+ window.localStorage.setItem(storageKey, String(enabled));
85
+ }, [
86
+ enabled,
87
+ mounted,
88
+ storageKey
89
+ ]);
90
+ (0, external_react_namespaceObject.useEffect)(()=>{
91
+ if (!enabled) return void setBoxes([]);
92
+ const readBoxes = ()=>{
93
+ const nextBoxes = Array.from(document.querySelectorAll('[data-modern-boundary-id]')).map((element, index)=>{
94
+ const boundaryId = element.dataset.modernBoundaryId;
95
+ if (!boundaryId) return;
96
+ const rect = element.getBoundingClientRect();
97
+ if (rect.width <= 0 || rect.height <= 0) return;
98
+ const boundary = boundaries.get(boundaryId);
99
+ const color = boundary?.color ?? palette[index % palette.length];
100
+ return {
101
+ color,
102
+ height: rect.height,
103
+ id: `${boundaryId}-${index}`,
104
+ label: boundary?.label ?? boundaryId,
105
+ left: rect.left,
106
+ top: rect.top,
107
+ width: rect.width
108
+ };
109
+ }).filter((box)=>void 0 !== box);
110
+ setBoxes(nextBoxes);
111
+ };
112
+ readBoxes();
113
+ const resizeObserver = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(readBoxes);
114
+ for (const element of document.querySelectorAll('[data-modern-boundary-id]'))resizeObserver?.observe(element);
115
+ const mutationObserver = new MutationObserver(readBoxes);
116
+ mutationObserver.observe(document.body, {
117
+ childList: true,
118
+ subtree: true
119
+ });
120
+ window.addEventListener('resize', readBoxes);
121
+ window.addEventListener('scroll', readBoxes, true);
122
+ return ()=>{
123
+ mutationObserver.disconnect();
124
+ resizeObserver?.disconnect();
125
+ window.removeEventListener('resize', readBoxes);
126
+ window.removeEventListener('scroll', readBoxes, true);
127
+ };
128
+ }, [
129
+ boundaries,
130
+ enabled
131
+ ]);
132
+ if (!mounted) return null;
133
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
134
+ children: [
135
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("label", {
136
+ style: {
137
+ alignItems: 'center',
138
+ background: 'rgba(255, 255, 255, 0.96)',
139
+ border: '1px solid rgba(0, 0, 0, 0.1)',
140
+ borderRadius: 12,
141
+ bottom: 20,
142
+ boxShadow: '0 16px 40px rgba(0, 0, 0, 0.16)',
143
+ color: '#111827',
144
+ display: 'flex',
145
+ font: '600 14px/1.2 system-ui, sans-serif',
146
+ gap: 8,
147
+ left: 20,
148
+ padding: '12px 14px',
149
+ position: 'fixed',
150
+ zIndex: 2147483000
151
+ },
152
+ children: [
153
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("input", {
154
+ checked: enabled,
155
+ onChange: (event)=>setEnabled(event.currentTarget.checked),
156
+ type: "checkbox"
157
+ }),
158
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
159
+ children: toggleLabel
160
+ })
161
+ ]
162
+ }),
163
+ enabled ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
164
+ "aria-hidden": "true",
165
+ children: boxes.map((box)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
166
+ style: {
167
+ border: `2px solid ${box.color}`,
168
+ borderRadius: 8,
169
+ boxShadow: `0 0 0 1px rgba(255,255,255,.72), 0 6px 20px color-mix(in srgb, ${box.color} 20%, transparent)`,
170
+ height: box.height,
171
+ left: box.left,
172
+ pointerEvents: 'none',
173
+ position: 'fixed',
174
+ top: box.top,
175
+ width: box.width,
176
+ zIndex: 2147482999
177
+ },
178
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
179
+ style: {
180
+ background: box.color,
181
+ borderRadius: 999,
182
+ color: '#111827',
183
+ font: '800 11px/1 system-ui, sans-serif',
184
+ padding: '5px 8px',
185
+ position: 'absolute',
186
+ right: 4,
187
+ top: 4,
188
+ whiteSpace: 'nowrap'
189
+ },
190
+ children: box.label
191
+ })
192
+ }, box.id))
193
+ }) : null
194
+ ]
195
+ });
196
+ }
197
+ const ultramodernBoundaryDebuggerPlugin = (options)=>({
198
+ name: '@modern-js/runtime/boundary-debugger',
199
+ setup: (api)=>{
200
+ api.wrapRoot((App)=>(props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
201
+ children: [
202
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
203
+ ...props
204
+ }),
205
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BoundaryDebugger, {
206
+ ...options
207
+ })
208
+ ]
209
+ }));
210
+ }
211
+ });
212
+ const boundary_debugger = ultramodernBoundaryDebuggerPlugin;
213
+ exports["default"] = __webpack_exports__["default"];
214
+ exports.ultramodernBoundaryDebuggerPlugin = __webpack_exports__.ultramodernBoundaryDebuggerPlugin;
215
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
216
+ "default",
217
+ "ultramodernBoundaryDebuggerPlugin"
218
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
219
+ Object.defineProperty(exports, '__esModule', {
220
+ value: true
221
+ });
@@ -125,13 +125,14 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
125
125
  const hasServerRendering = hasServerRenderingConfig(userConfig);
126
126
  const hasModuleFederationRuntimeMarker = hasServerRendering && shouldUseModuleFederationNodeOutput(config);
127
127
  const hasExplicitMfSsrFlag = isModuleFederationAppSSREnabled(userConfig);
128
+ const isCloudflareWorkerSSR = 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare';
128
129
  const requireExplicitMfSsrFlag = 'true' === process.env.MODERN_MF_APP_SSR_REQUIRE_EXPLICIT;
129
130
  if (hasServerRendering && hasModuleFederationRuntimeMarker && !hasExplicitMfSsrFlag) {
130
131
  const warningMessage = '[modernjs][mf-ssr] Module Federation SSR was auto-detected from runtime markers. Set server.ssr.moduleFederationAppSSR=true explicitly in host and remotes to avoid heuristic drift.';
131
132
  if (requireExplicitMfSsrFlag) throw new Error(`${warningMessage} (enforced by MODERN_MF_APP_SSR_REQUIRE_EXPLICIT=true)`);
132
133
  console.warn(warningMessage);
133
134
  }
134
- const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag;
135
+ const isModuleFederationAppSSR = hasServerRendering && hasExplicitMfSsrFlag && !isCloudflareWorkerSSR;
135
136
  const useModuleFederationNodeOutput = hasServerRendering && isModuleFederationAppSSR && isNodeEnvironmentTarget(config.output.target);
136
137
  const ssrEnv = userConfig.deploy?.worker?.ssr || userConfig.server?.rsc ? 'edge' : 'node';
137
138
  const appContext = modernAPI.getAppContext();
@@ -148,7 +149,7 @@ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
148
149
  } : void 0;
149
150
  const useLoadablePlugin = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig, appDirectory, entrypoints);
150
151
  const outputConfig = {
151
- module: isServerEnvironment && !useModuleFederationNodeOutput && outputModule
152
+ module: isServerEnvironment && !useModuleFederationNodeOutput && (outputModule || 'workerSSR' === name && userConfig.deploy?.target === 'cloudflare')
152
153
  };
153
154
  const useLoadableComponents = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig, appDirectory, entrypoints);
154
155
  return mergeEnvironmentConfig(config, {
@@ -64,6 +64,7 @@ const handleRequest = async (request, ServerRoot, options) => {
64
64
  </ServerRoot>,
65
65
  {
66
66
  ...options,
67
+ rscManifest: __rspack_rsc_manifest__,
67
68
  rscRoot: options.rscRoot,
68
69
  },
69
70
  );
@@ -45,8 +45,9 @@ function registerPlugin(internalPlugins, runtimeConfig) {
45
45
  config: runtimeConfig || {},
46
46
  handleSetupResult: hooks_js_namespaceObject.handleSetupResult
47
47
  });
48
- (0, external_context_index_js_namespaceObject.setGlobalInternalRuntimeContext)(runtimeContext);
49
- return runtimeContext;
48
+ const internalRuntimeContext = runtimeContext;
49
+ (0, external_context_index_js_namespaceObject.setGlobalInternalRuntimeContext)(internalRuntimeContext);
50
+ return internalRuntimeContext;
50
51
  }
51
52
  function mergeConfig(config, ...otherConfig) {
52
53
  return (0, merge_namespaceObject.merge)({}, config, ...otherConfig);
@@ -27,8 +27,8 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  createReplaceHelemt: ()=>createReplaceHelemt,
28
28
  helmetReplace: ()=>helmetReplace
29
29
  });
30
- const external_os_namespaceObject = require("os");
31
30
  const external_utils_js_namespaceObject = require("./utils.js");
31
+ const EOL = '\n';
32
32
  const RE_HTML_ATTR = /<html[^>]*>/;
33
33
  const RE_BODY_ATTR = /<body[^>]*>/;
34
34
  const RE_LAST_IN_HEAD = /<\/head>/;
@@ -61,7 +61,7 @@ function helmetReplace(content, helmetData) {
61
61
  script,
62
62
  style,
63
63
  !existTitleTag ? title : ''
64
- ].reduce((pre, cur)=>pre + (cur.length > 0 ? ` ${cur}${external_os_namespaceObject.EOL}` : ''), '');
64
+ ].reduce((pre, cur)=>pre + (cur.length > 0 ? ` ${cur}${EOL}` : ''), '');
65
65
  return (0, external_utils_js_namespaceObject.safeReplace)(result, RE_LAST_IN_HEAD, `${helmetStr}</head>`);
66
66
  }
67
67
  exports.createReplaceHelemt = __webpack_exports__.createReplaceHelemt;
@@ -50,12 +50,15 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
50
50
  if (!routeManifest) return template;
51
51
  const { routeAssets } = routeManifest;
52
52
  if (!routeAssets) return template;
53
- const asyncEntry = routeAssets[`async-${entryName}`];
54
- if (asyncEntry) {
55
- const { assets } = asyncEntry;
56
- const jsChunkStr = assets?.filter((asset)=>asset.endsWith('.js'))?.map((asset)=>`<script src=${asset} nonce="${nonce}"></script>`).join(' ');
57
- if (jsChunkStr) return (0, external_utils_js_namespaceObject.safeReplace)(template, '<!--<?- chunksMap.js ?>-->', jsChunkStr);
58
- }
53
+ const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext) ?? [];
54
+ const assetEntries = [
55
+ ...matchedRouteIds.map((routeId)=>routeAssets[routeId]),
56
+ routeAssets[`async-${entryName}`]
57
+ ].filter(Boolean);
58
+ const jsAssets = Array.from(new Set(assetEntries.flatMap((entry)=>(entry.assets ?? []).filter((asset)=>asset.endsWith('.js')))));
59
+ const nonceAttr = nonce ? ` nonce="${nonce}"` : '';
60
+ const jsChunkStr = jsAssets.filter((asset)=>!template.includes(asset)).map((asset)=>`<script src=${asset}${nonceAttr}></script>`).join(' ');
61
+ if (jsChunkStr) return (0, external_utils_js_namespaceObject.safeReplace)(template, '<!--<?- chunksMap.js ?>-->', jsChunkStr);
59
62
  return template;
60
63
  }
61
64
  return (0, external_shared_js_namespaceObject.buildHtml)(afterAppTemplate, callbacks);
@@ -70,28 +70,27 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
70
70
  const { routeManifest, routerContext, routes } = runtimeContext;
71
71
  if (!routeManifest) return '';
72
72
  const { routeAssets } = routeManifest;
73
- let matchedRouteManifests;
73
+ let matchedRouteManifests = [];
74
74
  const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext);
75
75
  if (matchedRouteIds?.length) matchedRouteManifests = matchedRouteIds.map((routeId)=>routeAssets[routeId]).filter(Boolean);
76
- else {
77
- if (!routerContext || !routes) return '';
76
+ else if (routerContext && routes) {
78
77
  const matches = (0, router_namespaceObject.matchRoutes)(routes, routerContext.location, routerContext.basename);
79
78
  matchedRouteManifests = matches?.map((match, index)=>{
80
79
  if (!index) return;
81
80
  const routeId = match.route.id;
82
81
  if (routeId) return routeAssets[routeId];
83
- }).filter(Boolean);
82
+ }).filter(Boolean) ?? [];
84
83
  }
85
84
  const asyncEntry = routeAssets[`async-${entryName}`];
86
- if (asyncEntry) matchedRouteManifests?.push(asyncEntry);
87
- const cssChunks = matchedRouteManifests ? matchedRouteManifests.reduce((chunks, routeManifest)=>{
85
+ if (asyncEntry) matchedRouteManifests.push(asyncEntry);
86
+ const cssChunks = matchedRouteManifests.reduce((chunks, routeManifest)=>{
88
87
  const { referenceCssAssets = [] } = routeManifest;
89
88
  const _cssChunks = referenceCssAssets.filter((asset)=>asset?.endsWith('.css') && !template.includes(asset));
90
89
  return [
91
90
  ...chunks,
92
91
  ..._cssChunks
93
92
  ];
94
- }, []) : [];
93
+ }, []);
95
94
  const { inlineStyles } = config;
96
95
  const styles = await Promise.all(cssChunks.map(async (chunk)=>{
97
96
  const link = `<link href="${chunk}" rel="stylesheet" />`;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ buildShellBeforeTemplate: ()=>buildShellBeforeTemplate
37
+ });
38
+ const router_namespaceObject = require("@modern-js/runtime-utils/router");
39
+ const external_react_helmet_namespaceObject = require("react-helmet");
40
+ var external_react_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_react_helmet_namespaceObject);
41
+ const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
42
+ const external_constants_js_namespaceObject = require("../constants.js");
43
+ const external_helmet_js_namespaceObject = require("../helmet.js");
44
+ const external_shared_js_namespaceObject = require("../shared.js");
45
+ const external_utils_js_namespaceObject = require("../utils.js");
46
+ const checkIsInline = (chunk, enableInline)=>{
47
+ if ('production' !== process.env.NODE_ENV) return false;
48
+ if (enableInline instanceof RegExp) return enableInline.test(chunk);
49
+ return Boolean(enableInline);
50
+ };
51
+ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
52
+ const { config, runtimeContext, styledComponentsStyleTags, entryName } = options;
53
+ const helmetData = external_react_helmet_default().renderStatic();
54
+ const callbacks = [
55
+ (0, external_helmet_js_namespaceObject.createReplaceHelemt)(helmetData),
56
+ (template)=>injectCss(template, entryName, styledComponentsStyleTags)
57
+ ];
58
+ return (0, external_shared_js_namespaceObject.buildHtml)(beforeAppTemplate, callbacks);
59
+ async function injectCss(template, entryName, styledComponentsStyleTags) {
60
+ let css = await getCssChunks();
61
+ if (styledComponentsStyleTags) css += styledComponentsStyleTags;
62
+ return (0, external_utils_js_namespaceObject.safeReplace)(template, external_constants_js_namespaceObject.CHUNK_CSS_PLACEHOLDER, css);
63
+ async function getCssChunks() {
64
+ const { routeManifest, routerContext, routes } = runtimeContext;
65
+ if (!routeManifest) return '';
66
+ const { routeAssets } = routeManifest;
67
+ let matchedRouteManifests = [];
68
+ const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext);
69
+ if (matchedRouteIds?.length) matchedRouteManifests = matchedRouteIds.map((routeId)=>routeAssets[routeId]).filter(Boolean);
70
+ else if (routerContext && routes) {
71
+ const matches = (0, router_namespaceObject.matchRoutes)(routes, routerContext.location, routerContext.basename);
72
+ matchedRouteManifests = matches?.map((match, index)=>{
73
+ if (!index) return;
74
+ const routeId = match.route.id;
75
+ if (routeId) return routeAssets[routeId];
76
+ }).filter(Boolean) ?? [];
77
+ }
78
+ const asyncEntry = routeAssets[`async-${entryName}`];
79
+ if (asyncEntry) matchedRouteManifests.push(asyncEntry);
80
+ const cssChunks = matchedRouteManifests.reduce((chunks, routeManifest)=>{
81
+ const { referenceCssAssets = [] } = routeManifest;
82
+ const _cssChunks = referenceCssAssets.filter((asset)=>asset?.endsWith('.css') && !template.includes(asset));
83
+ return [
84
+ ...chunks,
85
+ ..._cssChunks
86
+ ];
87
+ }, []);
88
+ const { inlineStyles } = config;
89
+ const styles = cssChunks.map((chunk)=>{
90
+ const link = `<link href="${chunk}" rel="stylesheet" />`;
91
+ checkIsInline(chunk, inlineStyles);
92
+ return link;
93
+ });
94
+ return `${styles.join('')}`;
95
+ }
96
+ }
97
+ }
98
+ exports.buildShellBeforeTemplate = __webpack_exports__.buildShellBeforeTemplate;
99
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
100
+ "buildShellBeforeTemplate"
101
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
102
+ Object.defineProperty(exports, '__esModule', {
103
+ value: true
104
+ });
@@ -36,7 +36,7 @@ const external_template_js_namespaceObject = require("./template.js");
36
36
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
37
37
  let shellChunkStatus = external_shared_js_namespaceObject.ShellChunkStatus.START;
38
38
  const chunkVec = [];
39
- const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, rscRoot } = options;
39
+ const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, rscManifest, rscRoot } = options;
40
40
  const { shellBefore, shellAfter } = await (0, external_template_js_namespaceObject.getTemplates)(htmlTemplate, {
41
41
  renderLevel: external_constants_js_namespaceObject.RenderLevel.SERVER_RENDER,
42
42
  runtimeContext,
@@ -49,6 +49,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
49
49
  const readableOriginal = await (0, ssr_namespaceObject.renderSSRStream)(rootElement, {
50
50
  request,
51
51
  nonce: config.nonce,
52
+ rscManifest,
52
53
  rscRoot: rscRoot,
53
54
  routes: runtimeContext.routes,
54
55
  onError (error) {
@@ -118,6 +118,7 @@ function createRenderStreaming(createReadableStreamPromise) {
118
118
  rscClientManifest: options.rscClientManifest,
119
119
  rscSSRManifest: options.rscSSRManifest,
120
120
  rscServerManifest: options.rscServerManifest,
121
+ rscManifest: options.rscManifest,
121
122
  rscRoot: options.rscRoot,
122
123
  onShellReady () {
123
124
  const cost = end();
@@ -71,6 +71,7 @@ const renderString = async (request, serverRoot, options)=>{
71
71
  stats: loadableStats,
72
72
  nonce: config.nonce,
73
73
  routeManifest,
74
+ runtimeContext,
74
75
  template: htmlTemplate,
75
76
  entryName,
76
77
  chunkSet,
@@ -27,6 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  LoadableCollector: ()=>LoadableCollector
28
28
  });
29
29
  const server_namespaceObject = require("@loadable/server");
30
+ const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
30
31
  const external_utils_js_namespaceObject = require("../utils.js");
31
32
  const extname = (uri)=>{
32
33
  if ('string' != typeof uri || !uri.includes('.')) return '';
@@ -49,6 +50,20 @@ class LoadableCollector {
49
50
  const { routeManifest, entryName } = this.options;
50
51
  return routeManifest?.routeAssets?.[entryName]?.assets;
51
52
  }
53
+ getMatchedRouteChunks() {
54
+ const { routeManifest, runtimeContext } = this.options;
55
+ const routeAssets = routeManifest?.routeAssets;
56
+ if (!routeAssets) return [];
57
+ const matchedRouteIds = (0, lifecycle_js_namespaceObject.getRouterMatchedRouteIds)(runtimeContext) ?? [];
58
+ return matchedRouteIds.flatMap((routeId)=>{
59
+ const routeAsset = routeAssets[routeId];
60
+ return (routeAsset?.assets ?? []).map((asset)=>({
61
+ filename: asset.replace(/^\//, ''),
62
+ path: asset,
63
+ url: asset
64
+ }));
65
+ });
66
+ }
52
67
  collect(comopnent) {
53
68
  const { stats, entryName } = this.options;
54
69
  if (!stats) return comopnent;
@@ -70,7 +85,7 @@ class LoadableCollector {
70
85
  `async-${entryName}`
71
86
  ]));
72
87
  } catch (e) {}
73
- const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks));
88
+ const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks)).concat(this.getMatchedRouteChunks());
74
89
  const scriptChunks = generateChunks(chunks, 'js');
75
90
  const styleChunks = generateChunks(chunks, 'css');
76
91
  this.emitLoadableScripts(extractor);
@@ -117,6 +117,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
117
117
  const imports = [];
118
118
  const statements = [];
119
119
  const loaderImportMap = new Map();
120
+ const usedRouteVarNames = new Set();
120
121
  let loaderIndex = 0;
121
122
  let routeIndex = 0;
122
123
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
@@ -150,10 +151,17 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
150
151
  actionName
151
152
  };
152
153
  };
154
+ const reserveRouteVarName = (preferred)=>{
155
+ let candidate = preferred;
156
+ let suffix = 1;
157
+ while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
158
+ usedRouteVarNames.add(candidate);
159
+ return candidate;
160
+ };
153
161
  const createRouteVarName = (route)=>{
154
162
  const id = route.id;
155
163
  const base = id ? (0, external_makeLegalIdentifier_js_namespaceObject.makeLegalIdentifier)(id) : `r_${routeIndex++}`;
156
- return `route_${base}`;
164
+ return reserveRouteVarName(`route_${base}`);
157
165
  };
158
166
  const buildRoute = async (opts)=>{
159
167
  const { parentVar, route } = opts;
@@ -182,14 +190,16 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
182
190
  actionName
183
191
  });
184
192
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
185
- statements.push(`const ${varName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
186
193
  const children = route.children;
194
+ const hasChildren = Boolean(children && children.length > 0);
195
+ const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
196
+ statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
187
197
  if (children && children.length > 0) {
188
198
  const childVars = await Promise.all(children.map((child)=>buildRoute({
189
- parentVar: varName,
199
+ parentVar: routeCtorVarName,
190
200
  route: child
191
201
  })));
192
- statements.push(`${varName}.addChildren([${childVars.join(', ')}]);`);
202
+ statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
193
203
  }
194
204
  return varName;
195
205
  };
@@ -262,7 +272,11 @@ function createRouteStaticData(opts: {
262
272
  modernRouteAction?: unknown;
263
273
  modernRouteLoader?: unknown;
264
274
  }) {
265
- const staticData: Record<string, unknown> = {};
275
+ const staticData: {
276
+ modernRouteId?: string;
277
+ modernRouteAction?: unknown;
278
+ modernRouteLoader?: unknown;
279
+ } = {};
266
280
 
267
281
  if (opts.modernRouteId) {
268
282
  staticData.modernRouteId = opts.modernRouteId;
@@ -276,7 +290,7 @@ function createRouteStaticData(opts: {
276
290
  staticData.modernRouteAction = opts.modernRouteAction;
277
291
  }
278
292
 
279
- return Object.keys(staticData).length > 0 ? staticData : undefined;
293
+ return staticData;
280
294
  }
281
295
 
282
296
  function modernLoaderToTanstack<TLoader extends (args: any) => any>(
@@ -211,16 +211,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
211
211
  webpackChunkName: true
212
212
  });
213
213
  component = 'string' === ssrMode ? `loadable(${lazyImport})` : `lazy(${lazyImport})`;
214
- } else if ('string' === ssrMode) {
214
+ } else {
215
215
  components.push(route._component);
216
216
  component = `component_${components.length - 1}`;
217
- } else {
218
- lazyImport = createLazyImport({
219
- componentPath: route._component,
220
- routeId: route.id,
221
- eager: true
222
- });
223
- component = `lazy(${lazyImport})`;
224
217
  }
225
218
  } else if (route._component) if (splitRouteChunks) {
226
219
  lazyImport = `() => import('${route._component}')`;
@@ -37,6 +37,7 @@ const external_hooks_js_namespaceObject = require("../hooks.js");
37
37
  const external_lifecycle_js_namespaceObject = require("../lifecycle.js");
38
38
  const external_utils_js_namespaceObject = require("../utils.js");
39
39
  const external_basepathRewrite_js_namespaceObject = require("./basepathRewrite.js");
40
+ const external_prefetchLink_js_namespaceObject = require("./prefetchLink.js");
40
41
  const external_routeTree_js_namespaceObject = require("./routeTree.js");
41
42
  const client_js_namespaceObject = require("./rsc/client.js");
42
43
  const BLOCKING_SUBSCRIBE_SYMBOL = Symbol.for('@modern-js/plugin-runtime:tanstack-blocking-subscribe');
@@ -98,6 +99,7 @@ const tanstackRouterPlugin = (userConfig = {})=>({
98
99
  }
99
100
  }
100
101
  context.router = {
102
+ Link: external_prefetchLink_js_namespaceObject.Link,
101
103
  useMatches: react_router_namespaceObject.useMatches,
102
104
  useLocation: react_router_namespaceObject.useLocation,
103
105
  useNavigate: react_router_namespaceObject.useNavigate,