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

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 (43) hide show
  1. package/dist/cjs/boundary-debugger/index.js +99 -22
  2. package/dist/cjs/core/server/federatedCss.js +47 -0
  3. package/dist/cjs/core/server/stream/beforeTemplate.js +6 -1
  4. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +6 -1
  5. package/dist/cjs/core/server/stream/createReadableStream.js +4 -2
  6. package/dist/cjs/core/server/stream/createReadableStream.worker.js +3 -2
  7. package/dist/cjs/core/server/stream/shared.js +2 -1
  8. package/dist/cjs/core/server/string/index.js +2 -1
  9. package/dist/cjs/core/server/string/loadable.js +18 -7
  10. package/dist/cjs/router/cli/code/tanstackTypes.js +15 -0
  11. package/dist/cjs/router/runtime/tanstack/plugin.js +2 -5
  12. package/dist/cjs/router/runtime/tanstack/plugin.node.js +2 -5
  13. package/dist/esm/boundary-debugger/index.mjs +99 -22
  14. package/dist/esm/core/server/federatedCss.mjs +13 -0
  15. package/dist/esm/core/server/stream/beforeTemplate.mjs +6 -1
  16. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +6 -1
  17. package/dist/esm/core/server/stream/createReadableStream.mjs +4 -2
  18. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +3 -2
  19. package/dist/esm/core/server/stream/shared.mjs +2 -1
  20. package/dist/esm/core/server/string/index.mjs +2 -1
  21. package/dist/esm/core/server/string/loadable.mjs +18 -7
  22. package/dist/esm/router/cli/code/tanstackTypes.mjs +15 -0
  23. package/dist/esm/router/runtime/tanstack/plugin.mjs +6 -9
  24. package/dist/esm/router/runtime/tanstack/plugin.node.mjs +3 -6
  25. package/dist/esm-node/boundary-debugger/index.mjs +99 -22
  26. package/dist/esm-node/core/server/federatedCss.mjs +14 -0
  27. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +6 -1
  28. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +6 -1
  29. package/dist/esm-node/core/server/stream/createReadableStream.mjs +4 -2
  30. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +3 -2
  31. package/dist/esm-node/core/server/stream/shared.mjs +2 -1
  32. package/dist/esm-node/core/server/string/index.mjs +2 -1
  33. package/dist/esm-node/core/server/string/loadable.mjs +18 -7
  34. package/dist/esm-node/router/cli/code/tanstackTypes.mjs +15 -0
  35. package/dist/esm-node/router/runtime/tanstack/plugin.mjs +6 -9
  36. package/dist/esm-node/router/runtime/tanstack/plugin.node.mjs +3 -6
  37. package/dist/types/boundary-debugger/index.d.ts +3 -0
  38. package/dist/types/core/server/federatedCss.d.ts +5 -0
  39. package/dist/types/core/server/stream/beforeTemplate.d.ts +1 -0
  40. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +1 -0
  41. package/dist/types/core/server/stream/shared.d.ts +1 -0
  42. package/dist/types/core/server/string/loadable.d.ts +1 -0
  43. package/package.json +8 -8
@@ -30,12 +30,14 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
31
  const external_react_namespaceObject = require("react");
32
32
  const defaultStorageKey = 'modernjs:boundary-debugger:enabled';
33
+ const queryParamName = 'modern-boundaries';
34
+ const boundarySelector = '[data-modern-boundary-id]';
33
35
  const defaultLabels = {
34
36
  cs: {
35
- toggle: 'zobrazit hranice verticalů'
37
+ toggle: 'zobrazit hranice týmů'
36
38
  },
37
39
  en: {
38
- toggle: 'show vertical boundaries'
40
+ toggle: 'show team boundaries'
39
41
  }
40
42
  };
41
43
  const palette = [
@@ -45,18 +47,64 @@ const palette = [
45
47
  '#7c8cff',
46
48
  '#29b6f6'
47
49
  ];
48
- const readEnabled = (storageKey, fallback)=>{
50
+ const readStoredEnabled = (storageKey, fallback)=>{
49
51
  if ("u" < typeof window) return fallback;
50
- const stored = window.localStorage.getItem(storageKey);
51
- return null === stored ? fallback : 'true' === stored;
52
+ try {
53
+ const stored = window.localStorage.getItem(storageKey);
54
+ return null === stored ? fallback : 'true' === stored;
55
+ } catch {
56
+ return fallback;
57
+ }
58
+ };
59
+ const writeStoredEnabled = (storageKey, enabled)=>{
60
+ if ("u" < typeof window) return;
61
+ try {
62
+ window.localStorage.setItem(storageKey, String(enabled));
63
+ } catch {}
64
+ };
65
+ const parseEnabledOverride = (value)=>{
66
+ if (null === value) return;
67
+ const normalized = value.toLowerCase();
68
+ if ('1' === normalized || 'true' === normalized) return true;
69
+ if ('0' === normalized || 'false' === normalized) return false;
70
+ };
71
+ const readQueryEnabledOverride = ()=>{
72
+ if ("u" < typeof window) return;
73
+ try {
74
+ return parseEnabledOverride(new URLSearchParams(window.location.search).get(queryParamName));
75
+ } catch {
76
+ return;
77
+ }
52
78
  };
53
79
  const detectLanguage = ()=>{
54
80
  if ("u" < typeof document) return 'en';
55
81
  const htmlLanguage = document.documentElement.lang;
56
82
  if (htmlLanguage) return htmlLanguage.split('-')[0] || 'en';
83
+ if ("u" < typeof window) return 'en';
57
84
  return window.location.pathname.split('/').filter(Boolean)[0] || 'en';
58
85
  };
59
- function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, metadata, storageKey = defaultStorageKey }) {
86
+ const hashBoundaryId = (id)=>{
87
+ let hash = 0;
88
+ for(let index = 0; index < id.length; index++)hash = 31 * hash + id.charCodeAt(index) >>> 0;
89
+ return hash;
90
+ };
91
+ const formatRectKey = (rect)=>[
92
+ Math.round(100 * rect.left) / 100,
93
+ Math.round(100 * rect.top) / 100,
94
+ Math.round(100 * rect.width) / 100,
95
+ Math.round(100 * rect.height) / 100
96
+ ].join(':');
97
+ const getBoundaryId = (element)=>element.dataset.modernBoundaryId ?? element.dataset.mfRemote ?? element.getAttribute('data-mf-remote') ?? void 0;
98
+ const collectBoundaryElements = (legacySelector)=>{
99
+ const elements = new Set();
100
+ for (const element of document.querySelectorAll(boundarySelector))elements.add(element);
101
+ if (!legacySelector) return Array.from(elements);
102
+ try {
103
+ for (const element of document.querySelectorAll(legacySelector))elements.add(element);
104
+ } catch {}
105
+ return Array.from(elements);
106
+ };
107
+ function BoundaryDebugger({ controlMode = 'visible', enabledByDefault = false, labels = defaultLabels, legacySelector, metadata, storageKey = defaultStorageKey }) {
60
108
  const [mounted, setMounted] = (0, external_react_namespaceObject.useState)(false);
61
109
  const [enabled, setEnabled] = (0, external_react_namespaceObject.useState)(false);
62
110
  const [boxes, setBoxes] = (0, external_react_namespaceObject.useState)([]);
@@ -71,17 +119,18 @@ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, me
71
119
  metadata
72
120
  ]);
73
121
  const language = mounted ? detectLanguage() : 'en';
74
- const toggleLabel = labels[language]?.toggle ?? labels.en?.toggle ?? defaultLabels.en?.toggle ?? 'show vertical boundaries';
122
+ const toggleLabel = labels[language]?.toggle ?? labels.en?.toggle ?? defaultLabels.en?.toggle ?? 'show team boundaries';
75
123
  (0, external_react_namespaceObject.useEffect)(()=>{
76
124
  setMounted(true);
77
- setEnabled(readEnabled(storageKey, enabledByDefault));
125
+ const queryOverride = readQueryEnabledOverride();
126
+ setEnabled(queryOverride ?? readStoredEnabled(storageKey, enabledByDefault));
78
127
  }, [
79
128
  enabledByDefault,
80
129
  storageKey
81
130
  ]);
82
131
  (0, external_react_namespaceObject.useEffect)(()=>{
83
132
  if (!mounted) return;
84
- window.localStorage.setItem(storageKey, String(enabled));
133
+ writeStoredEnabled(storageKey, enabled);
85
134
  }, [
86
135
  enabled,
87
136
  mounted,
@@ -90,28 +139,38 @@ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, me
90
139
  (0, external_react_namespaceObject.useEffect)(()=>{
91
140
  if (!enabled) return void setBoxes([]);
92
141
  const readBoxes = ()=>{
93
- const nextBoxes = Array.from(document.querySelectorAll('[data-modern-boundary-id]')).map((element, index)=>{
94
- const boundaryId = element.dataset.modernBoundaryId;
142
+ const seenBoxes = new Set();
143
+ const nextBoxes = collectBoundaryElements(legacySelector).map((element)=>{
144
+ const boundaryId = getBoundaryId(element);
95
145
  if (!boundaryId) return;
96
146
  const rect = element.getBoundingClientRect();
97
147
  if (rect.width <= 0 || rect.height <= 0) return;
148
+ const rectKey = formatRectKey(rect);
149
+ const boxKey = `${boundaryId}:${rectKey}`;
150
+ if (seenBoxes.has(boxKey)) return;
151
+ seenBoxes.add(boxKey);
98
152
  const boundary = boundaries.get(boundaryId);
99
- const color = boundary?.color ?? palette[index % palette.length];
100
- return {
153
+ const color = boundary?.color ?? palette[hashBoundaryId(boundaryId) % palette.length];
154
+ const label = boundary?.label ?? boundary?.appId ?? boundaryId;
155
+ const expose = element.dataset.modernMfExpose;
156
+ const detail = expose && expose !== label && expose !== boundaryId ? expose : void 0;
157
+ const box = {
101
158
  color,
102
159
  height: rect.height,
103
- id: `${boundaryId}-${index}`,
104
- label: boundary?.label ?? boundaryId,
160
+ id: boxKey,
161
+ label,
105
162
  left: rect.left,
106
163
  top: rect.top,
107
164
  width: rect.width
108
165
  };
166
+ if (detail) box.detail = detail;
167
+ return box;
109
168
  }).filter((box)=>void 0 !== box);
110
169
  setBoxes(nextBoxes);
111
170
  };
112
171
  readBoxes();
113
172
  const resizeObserver = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(readBoxes);
114
- for (const element of document.querySelectorAll('[data-modern-boundary-id]'))resizeObserver?.observe(element);
173
+ for (const element of collectBoundaryElements(legacySelector))resizeObserver?.observe(element);
115
174
  const mutationObserver = new MutationObserver(readBoxes);
116
175
  mutationObserver.observe(document.body, {
117
176
  childList: true,
@@ -127,12 +186,14 @@ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, me
127
186
  };
128
187
  }, [
129
188
  boundaries,
130
- enabled
189
+ enabled,
190
+ legacySelector
131
191
  ]);
132
192
  if (!mounted) return null;
193
+ const shouldRenderToggle = 'visible' === controlMode || 'hidden-when-off' === controlMode && enabled;
133
194
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
134
195
  children: [
135
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("label", {
196
+ shouldRenderToggle ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("label", {
136
197
  style: {
137
198
  alignItems: 'center',
138
199
  background: 'rgba(255, 255, 255, 0.96)',
@@ -159,7 +220,7 @@ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, me
159
220
  children: toggleLabel
160
221
  })
161
222
  ]
162
- }),
223
+ }) : null,
163
224
  enabled ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
164
225
  "aria-hidden": "true",
165
226
  children: boxes.map((box)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
@@ -175,19 +236,35 @@ function BoundaryDebugger({ enabledByDefault = false, labels = defaultLabels, me
175
236
  width: box.width,
176
237
  zIndex: 2147482999
177
238
  },
178
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
239
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
179
240
  style: {
180
241
  background: box.color,
181
242
  borderRadius: 999,
182
243
  color: '#111827',
183
- font: '800 11px/1 system-ui, sans-serif',
244
+ display: 'grid',
245
+ font: '800 11px/1.1 system-ui, sans-serif',
246
+ gap: 3,
247
+ maxWidth: 'min(280px, calc(100vw - 24px))',
184
248
  padding: '5px 8px',
185
249
  position: 'absolute',
186
250
  right: 4,
187
251
  top: 4,
188
252
  whiteSpace: 'nowrap'
189
253
  },
190
- children: box.label
254
+ children: [
255
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
256
+ children: box.label
257
+ }),
258
+ box.detail ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
259
+ style: {
260
+ font: '700 10px/1.1 system-ui, sans-serif',
261
+ opacity: 0.82,
262
+ overflow: 'hidden',
263
+ textOverflow: 'ellipsis'
264
+ },
265
+ children: box.detail
266
+ }) : null
267
+ ]
191
268
  })
192
269
  }, box.id))
193
270
  }) : null
@@ -0,0 +1,47 @@
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
+ createFederatedCssLinks: ()=>createFederatedCssLinks
28
+ });
29
+ const external_utils_js_namespaceObject = require("./utils.js");
30
+ const createFederatedCssLinks = (assets, options)=>{
31
+ if (!assets?.length) return '';
32
+ const seen = new Set(options.existingAssets || []);
33
+ const attributes = (0, external_utils_js_namespaceObject.attributesToString)(options.attributes || {});
34
+ const links = [];
35
+ for (const asset of assets)if (!(!asset || seen.has(asset) || options.template.includes(asset))) {
36
+ seen.add(asset);
37
+ links.push(`<link${attributes} href="${asset}" rel="stylesheet" />`);
38
+ }
39
+ return links.join('');
40
+ };
41
+ exports.createFederatedCssLinks = __webpack_exports__.createFederatedCssLinks;
42
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
43
+ "createFederatedCssLinks"
44
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
45
+ Object.defineProperty(exports, '__esModule', {
46
+ value: true
47
+ });
@@ -40,6 +40,7 @@ const external_react_helmet_namespaceObject = require("react-helmet");
40
40
  var external_react_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_react_helmet_namespaceObject);
41
41
  const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
42
42
  const external_constants_js_namespaceObject = require("../constants.js");
43
+ const external_federatedCss_js_namespaceObject = require("../federatedCss.js");
43
44
  const external_helmet_js_namespaceObject = require("../helmet.js");
44
45
  const external_shared_js_namespaceObject = require("../shared.js");
45
46
  const external_utils_js_namespaceObject = require("../utils.js");
@@ -55,7 +56,7 @@ const checkIsInline = (chunk, enableInline)=>{
55
56
  return Boolean(enableInline);
56
57
  };
57
58
  async function buildShellBeforeTemplate(beforeAppTemplate, options) {
58
- const { config, runtimeContext, styledComponentsStyleTags, entryName } = options;
59
+ const { config, runtimeContext, styledComponentsStyleTags, entryName, moduleFederationCssAssets } = options;
59
60
  const helmetData = external_react_helmet_default().renderStatic();
60
61
  const callbacks = [
61
62
  (0, external_helmet_js_namespaceObject.createReplaceHelemt)(helmetData),
@@ -65,6 +66,10 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
65
66
  async function injectCss(template, entryName, styledComponentsStyleTags) {
66
67
  let css = await getCssChunks();
67
68
  if (styledComponentsStyleTags) css += styledComponentsStyleTags;
69
+ css += (0, external_federatedCss_js_namespaceObject.createFederatedCssLinks)(moduleFederationCssAssets, {
70
+ template,
71
+ existingAssets: css.match(/href="([^"]+)"/g)?.map((item)=>item.replace(/^href="/, '').replace(/"$/, ''))
72
+ });
68
73
  return (0, external_utils_js_namespaceObject.safeReplace)(template, external_constants_js_namespaceObject.CHUNK_CSS_PLACEHOLDER, css);
69
74
  async function getCssChunks() {
70
75
  const { routeManifest, routerContext, routes } = runtimeContext;
@@ -40,6 +40,7 @@ const external_react_helmet_namespaceObject = require("react-helmet");
40
40
  var external_react_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_react_helmet_namespaceObject);
41
41
  const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
42
42
  const external_constants_js_namespaceObject = require("../constants.js");
43
+ const external_federatedCss_js_namespaceObject = require("../federatedCss.js");
43
44
  const external_helmet_js_namespaceObject = require("../helmet.js");
44
45
  const external_shared_js_namespaceObject = require("../shared.js");
45
46
  const external_utils_js_namespaceObject = require("../utils.js");
@@ -49,7 +50,7 @@ const checkIsInline = (chunk, enableInline)=>{
49
50
  return Boolean(enableInline);
50
51
  };
51
52
  async function buildShellBeforeTemplate(beforeAppTemplate, options) {
52
- const { config, runtimeContext, styledComponentsStyleTags, entryName } = options;
53
+ const { config, runtimeContext, styledComponentsStyleTags, entryName, moduleFederationCssAssets } = options;
53
54
  const helmetData = external_react_helmet_default().renderStatic();
54
55
  const callbacks = [
55
56
  (0, external_helmet_js_namespaceObject.createReplaceHelemt)(helmetData),
@@ -59,6 +60,10 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
59
60
  async function injectCss(template, entryName, styledComponentsStyleTags) {
60
61
  let css = await getCssChunks();
61
62
  if (styledComponentsStyleTags) css += styledComponentsStyleTags;
63
+ css += (0, external_federatedCss_js_namespaceObject.createFederatedCssLinks)(moduleFederationCssAssets, {
64
+ template,
65
+ existingAssets: css.match(/href="([^"]+)"/g)?.map((item)=>item.replace(/^href="/, '').replace(/"$/, ''))
66
+ });
62
67
  return (0, external_utils_js_namespaceObject.safeReplace)(template, external_constants_js_namespaceObject.CHUNK_CSS_PLACEHOLDER, css);
63
68
  async function getCssChunks() {
64
69
  const { routeManifest, routerContext, routes } = runtimeContext;
@@ -43,7 +43,7 @@ const defaultExtender = {
43
43
  };
44
44
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
45
45
  const { renderToPipeableStream } = await import("react-dom/server");
46
- const { runtimeContext, htmlTemplate, config, ssrConfig, entryName } = options;
46
+ const { runtimeContext, htmlTemplate, config, ssrConfig, entryName, moduleFederationCssAssets } = options;
47
47
  let shellChunkStatus = external_shared_js_namespaceObject.ShellChunkStatus.START;
48
48
  let renderLevel = external_constants_js_namespaceObject.RenderLevel.SERVER_RENDER;
49
49
  const forceStream2String = Boolean(process.env.MODERN_JS_STREAM_TO_STRING);
@@ -80,6 +80,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
80
80
  runtimeContext,
81
81
  config,
82
82
  entryName,
83
+ moduleFederationCssAssets,
83
84
  styledComponentsStyleTags
84
85
  }).then(({ shellAfter, shellBefore })=>{
85
86
  const pendingScripts = [];
@@ -137,7 +138,8 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
137
138
  renderLevel,
138
139
  runtimeContext,
139
140
  entryName,
140
- config
141
+ config,
142
+ moduleFederationCssAssets
141
143
  }).then(({ shellAfter, shellBefore })=>{
142
144
  const fallbackHtml = `${shellBefore}${shellAfter}`;
143
145
  const readableStream = (0, external_shared_js_namespaceObject.getReadableStreamFromString)(fallbackHtml);
@@ -36,14 +36,15 @@ 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, rscManifest, rscRoot } = options;
39
+ const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, moduleFederationCssAssets, 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,
43
43
  ssrConfig,
44
44
  request,
45
45
  config,
46
- entryName
46
+ entryName,
47
+ moduleFederationCssAssets
47
48
  });
48
49
  try {
49
50
  const readableOriginal = await (0, ssr_namespaceObject.renderSSRStream)(rootElement, {
@@ -95,7 +95,7 @@ function createRenderStreaming(createReadableStreamPromise) {
95
95
  const end = (0, time_namespaceObject.time)();
96
96
  const { runtimeContext, config, resource } = options;
97
97
  const { onError, onTiming } = options;
98
- const { htmlTemplate, entryName } = resource;
98
+ const { htmlTemplate, entryName, moduleFederationCssAssets } = resource;
99
99
  const ssrConfig = (0, external_utils_js_namespaceObject.getSSRConfigByEntry)(entryName, config.ssr, config.ssrByEntries);
100
100
  const StreamServerRootWrapper = ({ children })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
101
101
  children: [
@@ -115,6 +115,7 @@ function createRenderStreaming(createReadableStreamPromise) {
115
115
  runtimeContext,
116
116
  ssrConfig,
117
117
  entryName,
118
+ moduleFederationCssAssets,
118
119
  rscClientManifest: options.rscClientManifest,
119
120
  rscSSRManifest: options.rscSSRManifest,
120
121
  rscServerManifest: options.rscServerManifest,
@@ -58,7 +58,7 @@ const renderString = async (request, serverRoot, options)=>{
58
58
  onTiming
59
59
  };
60
60
  const routerContext = runtimeContext.routerContext;
61
- const { htmlTemplate, entryName, loadableStats, routeManifest } = resource;
61
+ const { htmlTemplate, entryName, loadableStats, routeManifest, moduleFederationCssAssets } = resource;
62
62
  const ssrConfig = (0, external_utils_js_namespaceObject.getSSRConfigByEntry)(entryName, config.ssr, config.ssrByEntries);
63
63
  const chunkSet = {
64
64
  renderLevel: external_constants_js_namespaceObject.RenderLevel.CLIENT_RENDER,
@@ -74,6 +74,7 @@ const renderString = async (request, serverRoot, options)=>{
74
74
  runtimeContext,
75
75
  template: htmlTemplate,
76
76
  entryName,
77
+ moduleFederationCssAssets,
77
78
  chunkSet,
78
79
  config
79
80
  }),
@@ -28,6 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  });
29
29
  const server_namespaceObject = require("@loadable/server");
30
30
  const lifecycle_js_namespaceObject = require("../../../router/runtime/lifecycle.js");
31
+ const external_federatedCss_js_namespaceObject = require("../federatedCss.js");
31
32
  const external_utils_js_namespaceObject = require("../utils.js");
32
33
  const extname = (uri)=>{
33
34
  if ('string' != typeof uri || !uri.includes('.')) return '';
@@ -76,20 +77,21 @@ class LoadableCollector {
76
77
  return this.extractor.collectChunks(comopnent);
77
78
  }
78
79
  async effect() {
79
- if (!this.extractor) return;
80
80
  const { extractor, options } = this;
81
81
  const { entryName, config } = options;
82
82
  const asyncChunks = [];
83
- if (config.enableAsyncEntry) try {
83
+ if (extractor && config.enableAsyncEntry) try {
84
84
  asyncChunks.push(...extractor.getChunkAssets([
85
85
  `async-${entryName}`
86
86
  ]));
87
87
  } catch (e) {}
88
- const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks)).concat(this.getMatchedRouteChunks());
88
+ const chunks = [].concat(asyncChunks).concat(extractor ? extractor.getChunkAssets(extractor.chunks) : []).concat(this.getMatchedRouteChunks());
89
89
  const scriptChunks = generateChunks(chunks, 'js');
90
90
  const styleChunks = generateChunks(chunks, 'css');
91
- this.emitLoadableScripts(extractor);
92
- await this.emitScriptAssets(scriptChunks);
91
+ if (extractor) {
92
+ this.emitLoadableScripts(extractor);
93
+ await this.emitScriptAssets(scriptChunks);
94
+ }
93
95
  await this.emitStyleAssets(styleChunks);
94
96
  }
95
97
  emitLoadableScripts(extractor) {
@@ -124,19 +126,28 @@ class LoadableCollector {
124
126
  chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
125
127
  }
126
128
  async emitStyleAssets(chunks) {
127
- const { template, chunkSet, config, entryName } = this.options;
129
+ const { template, chunkSet, config, moduleFederationCssAssets } = this.options;
128
130
  const { inlineStyles } = config;
129
131
  const atrributes = (0, external_utils_js_namespaceObject.attributesToString)(this.generateAttributes());
130
132
  const linkRegExp = /<link .*?href="([^"]+)".*?>/g;
131
133
  const matchs = template.matchAll(linkRegExp);
132
134
  const existedLinks = [];
133
135
  for (const match of matchs)existedLinks.push(match[1]);
134
- const css = await Promise.all(chunks.filter((chunk)=>!existedLinks.includes(chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
136
+ const emittedChunks = chunks.filter((chunk)=>!existedLinks.includes(chunk.url) && !this.existsAssets?.includes(chunk.path));
137
+ const css = await Promise.all(emittedChunks.map(async (chunk)=>{
135
138
  const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
136
139
  if ((0, external_utils_js_namespaceObject.checkIsNode)() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
137
140
  return link;
138
141
  }));
139
142
  chunkSet.cssChunk += css.filter((css)=>Boolean(css)).join('');
143
+ chunkSet.cssChunk += (0, external_federatedCss_js_namespaceObject.createFederatedCssLinks)(moduleFederationCssAssets, {
144
+ template,
145
+ attributes: this.generateAttributes(),
146
+ existingAssets: [
147
+ ...existedLinks,
148
+ ...emittedChunks.map((chunk)=>chunk.url)
149
+ ]
150
+ });
140
151
  }
141
152
  generateAttributes(extraAtr = {}) {
142
153
  const { config } = this.options;
@@ -116,10 +116,21 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
116
116
  const topLevel = rootModern ? rootModern.children || [] : routes;
117
117
  const imports = [];
118
118
  const statements = [];
119
+ const componentImportMap = new Map();
119
120
  const loaderImportMap = new Map();
120
121
  const usedRouteVarNames = new Set();
122
+ let componentIndex = 0;
121
123
  let loaderIndex = 0;
122
124
  let routeIndex = 0;
125
+ const getImportNameForComponent = (componentPath)=>{
126
+ if ('string' != typeof componentPath || 0 === componentPath.length) return null;
127
+ const existing = componentImportMap.get(componentPath);
128
+ if (existing) return existing;
129
+ const componentName = `component_${componentIndex++}`;
130
+ imports.push(`import ${componentName} from ${quote(componentPath)};`);
131
+ componentImportMap.set(componentPath, componentName);
132
+ return componentName;
133
+ };
123
134
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
124
135
  const key = `${inline ? 'inline' : 'default'}:${hasAction ? 'action' : 'loader'}:${aliasedNoExtPath}`;
125
136
  const existing = loaderImportMap.get(key);
@@ -176,6 +187,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
176
187
  const routeOpts = [
177
188
  `getParentRoute: () => ${parentVar},`
178
189
  ];
190
+ const componentName = getImportNameForComponent(route._component);
191
+ if (componentName) routeOpts.push(`component: ${componentName},`);
179
192
  if (isPathlessLayout(route)) {
180
193
  const id = route.id;
181
194
  routeOpts.push(`id: ${quote(id || 'pathless')},`);
@@ -213,6 +226,8 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
213
226
  route
214
227
  })));
215
228
  const rootOpts = [];
229
+ const rootComponentName = getImportNameForComponent(rootModern?._component);
230
+ if (rootComponentName) rootOpts.push(`component: ${rootComponentName},`);
216
231
  if (rootLoaderName) rootOpts.push(`loader: modernLoaderToTanstack({ hasSplat: false }, ${rootLoaderName}),`);
217
232
  const routerGenTs = `/* eslint-disable */
218
233
  // This file is auto-generated by Modern.js. Do not edit manually.
@@ -210,11 +210,8 @@ const tanstackRouterPlugin = (userConfig = {})=>({
210
210
  router,
211
211
  runtimeContext: runtimeState
212
212
  });
213
- const RouterContent = hasSSRBootstrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Suspense, {
214
- fallback: null,
215
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.RouterClient, {
216
- router: router
217
- })
213
+ const RouterContent = hasSSRBootstrap ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(client_namespaceObject.RouterClient, {
214
+ router: router
218
215
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
219
216
  router: router
220
217
  });
@@ -255,11 +255,8 @@ const tanstackRouterPlugin = (userConfig = {})=>({
255
255
  if (!router) return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
256
256
  ...props
257
257
  }) : null;
258
- const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Suspense, {
259
- fallback: null,
260
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
261
- router: router
262
- })
258
+ const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_router_namespaceObject.RouterProvider, {
259
+ router: router
263
260
  });
264
261
  return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
265
262
  children: routerWrapper