@bleedingdev/modern-js-runtime 3.9.0-ultramodern.1 → 3.9.0-ultramodern.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/code.js +3 -1
- package/dist/cjs/cli/ssr/index.js +2 -74
- package/dist/cjs/core/browser/hydrate.js +6 -1
- package/dist/cjs/core/context/index.js +4 -43
- package/dist/cjs/core/context/public.js +4 -7
- package/dist/cjs/core/context/runtime.js +17 -5
- package/dist/cjs/core/react/wrapper.js +22 -65
- package/dist/cjs/core/server/helmet.js +5 -4
- package/dist/cjs/core/server/requestResponse.js +4 -4
- package/dist/cjs/core/server/routerCleanup.js +2 -2
- package/dist/cjs/core/server/shared.js +171 -4
- package/dist/cjs/core/server/stream/afterTemplate.js +21 -16
- package/dist/cjs/core/server/stream/beforeTemplate.js +34 -25
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +28 -21
- package/dist/cjs/core/server/stream/createReadableStream.js +208 -123
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +159 -90
- package/dist/cjs/core/server/stream/deferredScript.js +3 -3
- package/dist/cjs/core/server/stream/shared.js +2 -2
- package/dist/cjs/core/server/string/index.js +100 -64
- package/dist/cjs/core/server/string/loadable.js +34 -19
- package/dist/cjs/core/server/string/ssrData.js +5 -12
- package/dist/cjs/core/server/utils.js +1 -2
- package/dist/cjs/exports/head.js +7 -14
- package/dist/cjs/router/runtime/PrefetchLink.js +67 -123
- package/dist/cjs/router/runtime/hooks.js +13 -2
- package/dist/cjs/router/runtime/internal.js +7 -45
- package/dist/cjs/router/runtime/plugin.js +2 -8
- package/dist/cjs/router/runtime/plugin.node.js +2 -30
- package/dist/cjs/router/runtime/redirect.js +1 -1
- package/dist/esm/cli/code.mjs +3 -1
- package/dist/esm/cli/ssr/index.mjs +3 -72
- package/dist/esm/core/browser/hydrate.mjs +7 -2
- package/dist/esm/core/context/index.mjs +2 -5
- package/dist/esm/core/context/public.mjs +1 -5
- package/dist/esm/core/context/runtime.mjs +13 -4
- package/dist/esm/core/react/wrapper.mjs +21 -67
- package/dist/esm/core/server/helmet.mjs +5 -4
- package/dist/esm/core/server/requestResponse.mjs +3 -3
- package/dist/esm/core/server/routerCleanup.mjs +1 -1
- package/dist/esm/core/server/shared.mjs +153 -1
- package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm/core/server/stream/beforeTemplate.mjs +37 -28
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +31 -24
- package/dist/esm/core/server/stream/createReadableStream.mjs +207 -122
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +149 -90
- package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm/core/server/stream/shared.mjs +2 -2
- package/dist/esm/core/server/string/index.mjs +104 -68
- package/dist/esm/core/server/string/loadable.mjs +34 -19
- package/dist/esm/core/server/string/ssrData.mjs +5 -12
- package/dist/esm/core/server/utils.mjs +1 -2
- package/dist/esm/exports/head.mjs +7 -14
- package/dist/esm/router/runtime/PrefetchLink.mjs +67 -123
- package/dist/esm/router/runtime/hooks.mjs +9 -1
- package/dist/esm/router/runtime/internal.mjs +2 -33
- package/dist/esm/router/runtime/plugin.mjs +1 -7
- package/dist/esm/router/runtime/plugin.node.mjs +1 -29
- package/dist/esm/router/runtime/redirect.mjs +1 -1
- package/dist/esm-node/cli/code.mjs +3 -1
- package/dist/esm-node/cli/ssr/index.mjs +3 -72
- package/dist/esm-node/core/browser/hydrate.mjs +7 -2
- package/dist/esm-node/core/context/index.mjs +2 -5
- package/dist/esm-node/core/context/public.mjs +1 -5
- package/dist/esm-node/core/context/runtime.mjs +13 -4
- package/dist/esm-node/core/react/wrapper.mjs +21 -67
- package/dist/esm-node/core/server/helmet.mjs +5 -4
- package/dist/esm-node/core/server/requestResponse.mjs +3 -3
- package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
- package/dist/esm-node/core/server/shared.mjs +153 -1
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +37 -28
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +31 -24
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +207 -122
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +149 -90
- package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
- package/dist/esm-node/core/server/stream/shared.mjs +2 -2
- package/dist/esm-node/core/server/string/index.mjs +104 -68
- package/dist/esm-node/core/server/string/loadable.mjs +34 -19
- package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
- package/dist/esm-node/core/server/utils.mjs +1 -2
- package/dist/esm-node/exports/head.mjs +7 -14
- package/dist/esm-node/router/runtime/PrefetchLink.mjs +67 -123
- package/dist/esm-node/router/runtime/hooks.mjs +9 -1
- package/dist/esm-node/router/runtime/internal.mjs +2 -33
- package/dist/esm-node/router/runtime/plugin.mjs +1 -7
- package/dist/esm-node/router/runtime/plugin.node.mjs +1 -29
- package/dist/esm-node/router/runtime/redirect.mjs +1 -1
- package/dist/types/cli/ssr/index.d.ts +0 -3
- package/dist/types/core/context/index.d.ts +4 -6
- package/dist/types/core/context/public.d.ts +1 -23
- package/dist/types/core/context/runtime.d.ts +26 -2
- package/dist/types/core/react/wrapper.d.ts +6 -0
- package/dist/types/core/server/helmet.d.ts +4 -5
- package/dist/types/core/server/requestHandler.d.ts +2 -2
- package/dist/types/core/server/requestResponse.d.ts +1 -1
- package/dist/types/core/server/routerCleanup.d.ts +1 -1
- package/dist/types/core/server/shared.d.ts +24 -1
- package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
- package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
- package/dist/types/core/server/stream/shared.d.ts +2 -2
- package/dist/types/core/server/string/loadable.d.ts +6 -3
- package/dist/types/core/server/string/ssrData.d.ts +2 -1
- package/dist/types/core/server/string/types.d.ts +1 -5
- package/dist/types/core/server/tracer.d.ts +1 -1
- package/dist/types/core/server/utils.d.ts +1 -1
- package/dist/types/core/types.d.ts +1 -2
- package/dist/types/exports/head.d.ts +2 -2
- package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
- package/dist/types/router/runtime/hooks.d.ts +19 -2
- package/dist/types/router/runtime/internal.d.ts +4 -21
- package/dist/types/router/runtime/types.d.ts +2 -43
- package/package.json +18 -46
- package/rstest.config.mts +32 -2
- package/dist/cjs/boundary-debugger/index.js +0 -317
- package/dist/cjs/core/context/extensions.js +0 -74
- package/dist/cjs/core/context/helmetContext.js +0 -54
- package/dist/cjs/core/server/federatedCss.js +0 -58
- package/dist/cjs/core/server/scriptOrder.js +0 -140
- package/dist/cjs/module-federation/consume-surface.js +0 -199
- package/dist/cjs/module-federation/distributed-ssr.js +0 -135
- package/dist/cjs/module-federation/index.js +0 -316
- package/dist/cjs/module-federation/last-known-good.js +0 -157
- package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
- package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
- package/dist/cjs/router/runtime/lifecycle.js +0 -167
- package/dist/cjs/router/runtime/provider.js +0 -153
- package/dist/esm/boundary-debugger/index.mjs +0 -277
- package/dist/esm/core/context/extensions.mjs +0 -33
- package/dist/esm/core/context/helmetContext.mjs +0 -13
- package/dist/esm/core/server/federatedCss.mjs +0 -20
- package/dist/esm/core/server/scriptOrder.mjs +0 -90
- package/dist/esm/module-federation/consume-surface.mjs +0 -158
- package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
- package/dist/esm/module-federation/index.mjs +0 -115
- package/dist/esm/module-federation/last-known-good.mjs +0 -113
- package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
- package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
- package/dist/esm/router/runtime/lifecycle.mjs +0 -105
- package/dist/esm/router/runtime/provider.mjs +0 -100
- package/dist/esm-node/boundary-debugger/index.mjs +0 -278
- package/dist/esm-node/core/context/extensions.mjs +0 -34
- package/dist/esm-node/core/context/helmetContext.mjs +0 -14
- package/dist/esm-node/core/server/federatedCss.mjs +0 -21
- package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
- package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
- package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
- package/dist/esm-node/module-federation/index.mjs +0 -116
- package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
- package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
- package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
- package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
- package/dist/esm-node/router/runtime/provider.mjs +0 -101
- package/dist/types/boundary-debugger/index.d.ts +0 -28
- package/dist/types/core/context/extensions.d.ts +0 -35
- package/dist/types/core/context/helmetContext.d.ts +0 -10
- package/dist/types/core/server/federatedCss.d.ts +0 -5
- package/dist/types/core/server/scriptOrder.d.ts +0 -25
- package/dist/types/module-federation/consume-surface.d.ts +0 -104
- package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
- package/dist/types/module-federation/index.d.ts +0 -71
- package/dist/types/module-federation/last-known-good.d.ts +0 -52
- package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
- package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
- package/dist/types/router/runtime/lifecycle.d.ts +0 -27
- package/dist/types/router/runtime/provider.d.ts +0 -78
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useMemo, useState } from "react";
|
|
3
|
-
const defaultStorageKey = 'modernjs:boundary-debugger:enabled';
|
|
4
|
-
const queryParamName = 'modern-boundaries';
|
|
5
|
-
const boundarySelector = '[data-modern-boundary-id]';
|
|
6
|
-
const defaultLabels = {
|
|
7
|
-
cs: {
|
|
8
|
-
toggle: 'zobrazit hranice týmů'
|
|
9
|
-
},
|
|
10
|
-
en: {
|
|
11
|
-
toggle: 'show team boundaries'
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const palette = [
|
|
15
|
-
'#ff5a5f',
|
|
16
|
-
'#30e27a',
|
|
17
|
-
'#f6cf45',
|
|
18
|
-
'#7c8cff',
|
|
19
|
-
'#29b6f6'
|
|
20
|
-
];
|
|
21
|
-
const readStoredEnabled = (storageKey, fallback)=>{
|
|
22
|
-
if ("u" < typeof window) return fallback;
|
|
23
|
-
try {
|
|
24
|
-
const stored = window.localStorage.getItem(storageKey);
|
|
25
|
-
return null === stored ? fallback : 'true' === stored;
|
|
26
|
-
} catch {
|
|
27
|
-
return fallback;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const writeStoredEnabled = (storageKey, enabled)=>{
|
|
31
|
-
if ("u" < typeof window) return;
|
|
32
|
-
try {
|
|
33
|
-
window.localStorage.setItem(storageKey, String(enabled));
|
|
34
|
-
} catch {}
|
|
35
|
-
};
|
|
36
|
-
const parseEnabledOverride = (value)=>{
|
|
37
|
-
if (null === value) return;
|
|
38
|
-
const normalized = value.toLowerCase();
|
|
39
|
-
if ('1' === normalized || 'true' === normalized) return true;
|
|
40
|
-
if ('0' === normalized || 'false' === normalized) return false;
|
|
41
|
-
};
|
|
42
|
-
const readQueryEnabledOverride = ()=>{
|
|
43
|
-
if ("u" < typeof window) return;
|
|
44
|
-
try {
|
|
45
|
-
return parseEnabledOverride(new URLSearchParams(window.location.search).get(queryParamName));
|
|
46
|
-
} catch {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const detectLanguage = ()=>{
|
|
51
|
-
if ("u" < typeof document) return 'en';
|
|
52
|
-
const htmlLanguage = document.documentElement.lang;
|
|
53
|
-
if ('' !== htmlLanguage) return htmlLanguage.split('-')[0] || 'en';
|
|
54
|
-
if ("u" < typeof window) return 'en';
|
|
55
|
-
return window.location.pathname.split('/').filter(Boolean)[0] || 'en';
|
|
56
|
-
};
|
|
57
|
-
const hashBoundaryId = (id)=>{
|
|
58
|
-
let hash = 0;
|
|
59
|
-
for(let index = 0; index < id.length; index++)hash = 31 * hash + id.charCodeAt(index) >>> 0;
|
|
60
|
-
return hash;
|
|
61
|
-
};
|
|
62
|
-
const formatRectKey = (rect)=>[
|
|
63
|
-
Math.round(100 * rect.left) / 100,
|
|
64
|
-
Math.round(100 * rect.top) / 100,
|
|
65
|
-
Math.round(100 * rect.width) / 100,
|
|
66
|
-
Math.round(100 * rect.height) / 100
|
|
67
|
-
].join(':');
|
|
68
|
-
const getBoundaryId = (element)=>element.dataset.modernBoundaryId ?? element.dataset.mfRemote ?? element.getAttribute('data-mf-remote') ?? void 0;
|
|
69
|
-
const collectBoundaryElements = (legacySelector)=>{
|
|
70
|
-
const elements = new Set();
|
|
71
|
-
for (const element of document.querySelectorAll(boundarySelector))elements.add(element);
|
|
72
|
-
if (void 0 === legacySelector || '' === legacySelector) return Array.from(elements);
|
|
73
|
-
try {
|
|
74
|
-
for (const element of document.querySelectorAll(legacySelector))elements.add(element);
|
|
75
|
-
} catch {}
|
|
76
|
-
return Array.from(elements);
|
|
77
|
-
};
|
|
78
|
-
function BoundaryDebugger({ controlMode = 'visible', enabledByDefault = false, labels = defaultLabels, legacySelector, metadata, storageKey = defaultStorageKey }) {
|
|
79
|
-
const [mounted, setMounted] = useState(false);
|
|
80
|
-
const [enabled, setEnabled] = useState(false);
|
|
81
|
-
const [boxes, setBoxes] = useState([]);
|
|
82
|
-
const boundaries = useMemo(()=>new Map(metadata.boundaries.map((entry, index)=>[
|
|
83
|
-
entry.mfName,
|
|
84
|
-
{
|
|
85
|
-
...entry,
|
|
86
|
-
color: entry.color ?? palette[index % palette.length],
|
|
87
|
-
label: entry.label ?? entry.appId
|
|
88
|
-
}
|
|
89
|
-
])), [
|
|
90
|
-
metadata
|
|
91
|
-
]);
|
|
92
|
-
const language = mounted ? detectLanguage() : 'en';
|
|
93
|
-
const toggleLabel = labels[language]?.toggle ?? labels.en?.toggle ?? defaultLabels.en?.toggle ?? 'show team boundaries';
|
|
94
|
-
useEffect(()=>{
|
|
95
|
-
setMounted(true);
|
|
96
|
-
const queryOverride = readQueryEnabledOverride();
|
|
97
|
-
setEnabled(queryOverride ?? readStoredEnabled(storageKey, enabledByDefault));
|
|
98
|
-
}, [
|
|
99
|
-
enabledByDefault,
|
|
100
|
-
storageKey
|
|
101
|
-
]);
|
|
102
|
-
useEffect(()=>{
|
|
103
|
-
if (!mounted) return;
|
|
104
|
-
writeStoredEnabled(storageKey, enabled);
|
|
105
|
-
}, [
|
|
106
|
-
enabled,
|
|
107
|
-
mounted,
|
|
108
|
-
storageKey
|
|
109
|
-
]);
|
|
110
|
-
useEffect(()=>{
|
|
111
|
-
if (!enabled) return void setBoxes([]);
|
|
112
|
-
let resizeObserver;
|
|
113
|
-
const observedElements = new Set();
|
|
114
|
-
const observeBoundaryElements = (elements)=>{
|
|
115
|
-
if (void 0 === resizeObserver) return;
|
|
116
|
-
for (const element of elements)if (!observedElements.has(element)) {
|
|
117
|
-
observedElements.add(element);
|
|
118
|
-
resizeObserver.observe(element);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const readBoxes = ()=>{
|
|
122
|
-
const elements = collectBoundaryElements(legacySelector);
|
|
123
|
-
observeBoundaryElements(elements);
|
|
124
|
-
const seenBoxes = new Set();
|
|
125
|
-
const nextBoxes = elements.map((element)=>{
|
|
126
|
-
const boundaryId = getBoundaryId(element);
|
|
127
|
-
if (void 0 === boundaryId || '' === boundaryId) return;
|
|
128
|
-
const rect = element.getBoundingClientRect();
|
|
129
|
-
if (rect.width <= 0 || rect.height <= 0) return;
|
|
130
|
-
const rectKey = formatRectKey(rect);
|
|
131
|
-
const boxKey = `${boundaryId}:${rectKey}`;
|
|
132
|
-
if (seenBoxes.has(boxKey)) return;
|
|
133
|
-
seenBoxes.add(boxKey);
|
|
134
|
-
const boundary = boundaries.get(boundaryId);
|
|
135
|
-
const color = boundary?.color ?? palette[hashBoundaryId(boundaryId) % palette.length];
|
|
136
|
-
const label = boundary?.label ?? boundary?.appId ?? boundaryId;
|
|
137
|
-
const expose = element.dataset.modernMfExpose;
|
|
138
|
-
const detail = void 0 !== expose && '' !== expose && expose !== label && expose !== boundaryId ? expose : void 0;
|
|
139
|
-
const box = {
|
|
140
|
-
color,
|
|
141
|
-
height: rect.height,
|
|
142
|
-
id: boxKey,
|
|
143
|
-
label,
|
|
144
|
-
left: rect.left,
|
|
145
|
-
top: rect.top,
|
|
146
|
-
width: rect.width
|
|
147
|
-
};
|
|
148
|
-
if (void 0 !== detail) box.detail = detail;
|
|
149
|
-
return box;
|
|
150
|
-
}).filter((box)=>void 0 !== box);
|
|
151
|
-
setBoxes(nextBoxes);
|
|
152
|
-
};
|
|
153
|
-
resizeObserver = "u" < typeof ResizeObserver ? void 0 : new ResizeObserver(readBoxes);
|
|
154
|
-
readBoxes();
|
|
155
|
-
const mutationObserver = new MutationObserver(readBoxes);
|
|
156
|
-
mutationObserver.observe(document.body, {
|
|
157
|
-
childList: true,
|
|
158
|
-
subtree: true
|
|
159
|
-
});
|
|
160
|
-
window.addEventListener('resize', readBoxes);
|
|
161
|
-
window.addEventListener('scroll', readBoxes, true);
|
|
162
|
-
return ()=>{
|
|
163
|
-
mutationObserver.disconnect();
|
|
164
|
-
resizeObserver?.disconnect();
|
|
165
|
-
window.removeEventListener('resize', readBoxes);
|
|
166
|
-
window.removeEventListener('scroll', readBoxes, true);
|
|
167
|
-
};
|
|
168
|
-
}, [
|
|
169
|
-
boundaries,
|
|
170
|
-
enabled,
|
|
171
|
-
legacySelector
|
|
172
|
-
]);
|
|
173
|
-
if (!mounted) return null;
|
|
174
|
-
const shouldRenderToggle = 'visible' === controlMode || 'hidden-when-off' === controlMode && enabled;
|
|
175
|
-
return /*#__PURE__*/ jsxs(Fragment, {
|
|
176
|
-
children: [
|
|
177
|
-
shouldRenderToggle ? /*#__PURE__*/ jsxs("label", {
|
|
178
|
-
style: {
|
|
179
|
-
alignItems: 'center',
|
|
180
|
-
background: 'rgba(255, 255, 255, 0.96)',
|
|
181
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
182
|
-
borderRadius: 10,
|
|
183
|
-
boxShadow: '0 10px 28px rgba(0, 0, 0, 0.14)',
|
|
184
|
-
color: '#111827',
|
|
185
|
-
display: 'flex',
|
|
186
|
-
font: '600 13px/1.2 system-ui, sans-serif',
|
|
187
|
-
gap: 8,
|
|
188
|
-
left: 'max(12px, env(safe-area-inset-left))',
|
|
189
|
-
maxWidth: 'calc(100vw - 24px)',
|
|
190
|
-
padding: '9px 11px',
|
|
191
|
-
position: 'fixed',
|
|
192
|
-
top: 'max(12px, env(safe-area-inset-top))',
|
|
193
|
-
zIndex: 2147483000
|
|
194
|
-
},
|
|
195
|
-
children: [
|
|
196
|
-
/*#__PURE__*/ jsx("input", {
|
|
197
|
-
checked: enabled,
|
|
198
|
-
onChange: (event)=>setEnabled(event.currentTarget.checked),
|
|
199
|
-
type: "checkbox"
|
|
200
|
-
}),
|
|
201
|
-
/*#__PURE__*/ jsx("span", {
|
|
202
|
-
children: toggleLabel
|
|
203
|
-
})
|
|
204
|
-
]
|
|
205
|
-
}) : null,
|
|
206
|
-
enabled ? /*#__PURE__*/ jsx("div", {
|
|
207
|
-
"aria-hidden": "true",
|
|
208
|
-
children: boxes.map((box)=>/*#__PURE__*/ jsx("div", {
|
|
209
|
-
"data-modern-boundary-overlay": "",
|
|
210
|
-
"data-modern-boundary-overlay-id": box.id,
|
|
211
|
-
"data-modern-boundary-overlay-label": box.label,
|
|
212
|
-
style: {
|
|
213
|
-
border: `2px solid ${box.color}`,
|
|
214
|
-
borderRadius: 8,
|
|
215
|
-
boxSizing: 'border-box',
|
|
216
|
-
boxShadow: `0 0 0 1px rgba(255,255,255,.72), 0 6px 20px color-mix(in srgb, ${box.color} 20%, transparent)`,
|
|
217
|
-
height: box.height,
|
|
218
|
-
left: box.left,
|
|
219
|
-
pointerEvents: 'none',
|
|
220
|
-
position: 'fixed',
|
|
221
|
-
top: box.top,
|
|
222
|
-
width: box.width,
|
|
223
|
-
zIndex: 2147482999
|
|
224
|
-
},
|
|
225
|
-
children: /*#__PURE__*/ jsxs("span", {
|
|
226
|
-
style: {
|
|
227
|
-
background: box.color,
|
|
228
|
-
borderRadius: 999,
|
|
229
|
-
color: '#111827',
|
|
230
|
-
display: 'grid',
|
|
231
|
-
font: '800 11px/1.1 system-ui, sans-serif',
|
|
232
|
-
gap: 3,
|
|
233
|
-
maxWidth: 'min(280px, calc(100vw - 24px))',
|
|
234
|
-
padding: '5px 8px',
|
|
235
|
-
position: 'absolute',
|
|
236
|
-
right: 4,
|
|
237
|
-
top: 4,
|
|
238
|
-
whiteSpace: 'nowrap'
|
|
239
|
-
},
|
|
240
|
-
children: [
|
|
241
|
-
/*#__PURE__*/ jsx("span", {
|
|
242
|
-
children: box.label
|
|
243
|
-
}),
|
|
244
|
-
void 0 !== box.detail && '' !== box.detail ? /*#__PURE__*/ jsx("span", {
|
|
245
|
-
style: {
|
|
246
|
-
font: '700 10px/1.1 system-ui, sans-serif',
|
|
247
|
-
opacity: 0.82,
|
|
248
|
-
overflow: 'hidden',
|
|
249
|
-
textOverflow: 'ellipsis'
|
|
250
|
-
},
|
|
251
|
-
children: box.detail
|
|
252
|
-
}) : null
|
|
253
|
-
]
|
|
254
|
-
})
|
|
255
|
-
}, box.id))
|
|
256
|
-
}) : null
|
|
257
|
-
]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
const ultramodernBoundaryDebuggerPlugin = (options)=>({
|
|
261
|
-
name: '@modern-js/runtime/boundary-debugger',
|
|
262
|
-
setup: (api)=>{
|
|
263
|
-
api.wrapRoot((App)=>(props)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
264
|
-
children: [
|
|
265
|
-
/*#__PURE__*/ jsx(App, {
|
|
266
|
-
...props
|
|
267
|
-
}),
|
|
268
|
-
/*#__PURE__*/ jsx(BoundaryDebugger, {
|
|
269
|
-
...options
|
|
270
|
-
})
|
|
271
|
-
]
|
|
272
|
-
}));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
const boundary_debugger = ultramodernBoundaryDebuggerPlugin;
|
|
276
|
-
export default boundary_debugger;
|
|
277
|
-
export { ultramodernBoundaryDebuggerPlugin };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const EXTENSIONS_SLOT = Symbol.for('@modern-js/runtime:context-extensions');
|
|
2
|
-
function getStore(context) {
|
|
3
|
-
return context[EXTENSIONS_SLOT];
|
|
4
|
-
}
|
|
5
|
-
function ensureStore(context) {
|
|
6
|
-
const target = context;
|
|
7
|
-
const store = target[EXTENSIONS_SLOT] ?? new Map();
|
|
8
|
-
Object.defineProperty(target, EXTENSIONS_SLOT, {
|
|
9
|
-
configurable: true,
|
|
10
|
-
enumerable: true,
|
|
11
|
-
value: store
|
|
12
|
-
});
|
|
13
|
-
return store;
|
|
14
|
-
}
|
|
15
|
-
function stripRuntimeContextExtensions(context) {
|
|
16
|
-
delete context[EXTENSIONS_SLOT];
|
|
17
|
-
}
|
|
18
|
-
function createRuntimeContextExtension(id) {
|
|
19
|
-
const key = Symbol.for(`@modern-js/runtime:context-extension:${id}`);
|
|
20
|
-
return {
|
|
21
|
-
key,
|
|
22
|
-
get (context) {
|
|
23
|
-
return getStore(context)?.get(key);
|
|
24
|
-
},
|
|
25
|
-
set (context, value) {
|
|
26
|
-
ensureStore(context).set(key, value);
|
|
27
|
-
},
|
|
28
|
-
remove (context) {
|
|
29
|
-
getStore(context)?.delete(key);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export { createRuntimeContextExtension, stripRuntimeContextExtensions };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRuntimeContextExtension } from "./extensions.mjs";
|
|
2
|
-
const helmetContextExtension = createRuntimeContextExtension('@modern-js/runtime:helmet-context');
|
|
3
|
-
function getHelmetContext(context) {
|
|
4
|
-
return helmetContextExtension.get(context);
|
|
5
|
-
}
|
|
6
|
-
function ensureHelmetContext(context) {
|
|
7
|
-
const existing = helmetContextExtension.get(context);
|
|
8
|
-
if (void 0 !== existing) return existing;
|
|
9
|
-
const created = {};
|
|
10
|
-
helmetContextExtension.set(context, created);
|
|
11
|
-
return created;
|
|
12
|
-
}
|
|
13
|
-
export { ensureHelmetContext, getHelmetContext };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { escapeHtmlAttribute } from "@modern-js/runtime-extensions";
|
|
2
|
-
import { attributesToString, hasStylesheetLink } from "./utils.mjs";
|
|
3
|
-
const createFederatedCssLinks = (assets, options)=>{
|
|
4
|
-
if (void 0 === assets || 0 === assets.length) return '';
|
|
5
|
-
const seen = new Set(options.existingAssets || []);
|
|
6
|
-
const attributes = attributesToString(Object.fromEntries(Object.entries(options.attributes || {}).filter(([name])=>![
|
|
7
|
-
'href',
|
|
8
|
-
'rel'
|
|
9
|
-
].includes(name.toLowerCase()))));
|
|
10
|
-
const links = [];
|
|
11
|
-
for (const asset of assets){
|
|
12
|
-
const href = escapeHtmlAttribute(asset);
|
|
13
|
-
if (!('' === asset || seen.has(asset) || hasStylesheetLink(options.template, asset) || hasStylesheetLink(options.template, href))) {
|
|
14
|
-
seen.add(asset);
|
|
15
|
-
links.push(`<link${attributes} href="${href}" rel="stylesheet" />`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return links.join('');
|
|
19
|
-
};
|
|
20
|
-
export { createFederatedCssLinks };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { getRouterMatchedRouteIds } from "../../router/runtime/lifecycle.mjs";
|
|
2
|
-
import { CHUNK_JS_PLACEHOLDER } from "./constants.mjs";
|
|
3
|
-
import { attributesToString, safeReplace } from "./utils.mjs";
|
|
4
|
-
function getScriptTags(template) {
|
|
5
|
-
const scriptRegExp = /<script\b[^>]*\bsrc=(["'])(.*?)\1[^>]*><\/script>/g;
|
|
6
|
-
return Array.from(template.matchAll(scriptRegExp)).map((match)=>({
|
|
7
|
-
index: match.index ?? 0,
|
|
8
|
-
tag: match[0],
|
|
9
|
-
src: match[2]
|
|
10
|
-
}));
|
|
11
|
-
}
|
|
12
|
-
function getAssetBasename(src) {
|
|
13
|
-
const withoutQuery = src.split(/[?#]/)[0];
|
|
14
|
-
return withoutQuery.split('/').pop() || withoutQuery;
|
|
15
|
-
}
|
|
16
|
-
function isEntryScript(src, entryName, asyncEntry) {
|
|
17
|
-
const basename = getAssetBasename(src);
|
|
18
|
-
const prefix = asyncEntry ? `async-${entryName}` : entryName;
|
|
19
|
-
return basename === `${prefix}.js` || basename.startsWith(`${prefix}.`) || basename.startsWith(`${prefix}-`);
|
|
20
|
-
}
|
|
21
|
-
const dedupeByUrl = (chunks)=>{
|
|
22
|
-
const seen = new Set();
|
|
23
|
-
return chunks.filter((chunk)=>{
|
|
24
|
-
if (void 0 === chunk.url || '' === chunk.url || seen.has(chunk.url)) return false;
|
|
25
|
-
seen.add(chunk.url);
|
|
26
|
-
return true;
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const isAsyncEntryScriptChunk = (chunk, entryName)=>{
|
|
30
|
-
if (void 0 === chunk.url || !chunk.url.endsWith('.js')) return false;
|
|
31
|
-
const asyncEntryName = `async-${entryName}`;
|
|
32
|
-
const filename = chunk.filename ?? chunk.url;
|
|
33
|
-
const basename = filename.split('/').pop() ?? filename;
|
|
34
|
-
return basename === `${asyncEntryName}.js` || basename.startsWith(`${asyncEntryName}.`) || basename.startsWith(`${asyncEntryName}-`);
|
|
35
|
-
};
|
|
36
|
-
function getRouteAssets(runtimeContext, routeManifest = runtimeContext.routeManifest) {
|
|
37
|
-
return routeManifest?.routeAssets;
|
|
38
|
-
}
|
|
39
|
-
function getMatchedRouteAssets(runtimeContext, routeManifest) {
|
|
40
|
-
const routeAssets = getRouteAssets(runtimeContext, routeManifest);
|
|
41
|
-
if (void 0 === routeAssets) return [];
|
|
42
|
-
const matchedRouteIds = getRouterMatchedRouteIds(runtimeContext) ?? [];
|
|
43
|
-
return matchedRouteIds.flatMap((routeId)=>routeAssets[routeId]?.assets ?? []);
|
|
44
|
-
}
|
|
45
|
-
function getMatchedRouteChunks(runtimeContext, routeManifest, routeAssetToChunk) {
|
|
46
|
-
if (void 0 === routeManifest) return [];
|
|
47
|
-
return getMatchedRouteAssets(runtimeContext, routeManifest).map(routeAssetToChunk);
|
|
48
|
-
}
|
|
49
|
-
const orderHydrationScriptChunks = ({ asyncEntryChunks, collectedChunks, matchedRouteChunks, entryName })=>{
|
|
50
|
-
const asyncEntryScriptChunks = [];
|
|
51
|
-
const asyncEntryDependencyChunks = [];
|
|
52
|
-
for (const chunk of asyncEntryChunks)if (isAsyncEntryScriptChunk(chunk, entryName)) asyncEntryScriptChunks.push(chunk);
|
|
53
|
-
else asyncEntryDependencyChunks.push(chunk);
|
|
54
|
-
return dedupeByUrl([
|
|
55
|
-
...asyncEntryDependencyChunks,
|
|
56
|
-
...collectedChunks,
|
|
57
|
-
...matchedRouteChunks,
|
|
58
|
-
...asyncEntryScriptChunks
|
|
59
|
-
]);
|
|
60
|
-
};
|
|
61
|
-
function injectBeforeHydrationEntryScript(template, scripts, entryName = 'index') {
|
|
62
|
-
if ('' === scripts) return template;
|
|
63
|
-
const scriptTags = getScriptTags(template);
|
|
64
|
-
const target = scriptTags.find((match)=>isEntryScript(match.src, entryName, false)) ?? scriptTags.find((match)=>isEntryScript(match.src, entryName, true));
|
|
65
|
-
if (void 0 === target) return template;
|
|
66
|
-
return `${template.slice(0, target.index)}${scripts}${template.slice(target.index)}`;
|
|
67
|
-
}
|
|
68
|
-
function replaceChunkJsPlaceholder(template, scripts, entryName, placeholder = CHUNK_JS_PLACEHOLDER) {
|
|
69
|
-
if (!template.includes(placeholder)) return template;
|
|
70
|
-
if ('' === scripts) return safeReplace(template, placeholder, '');
|
|
71
|
-
const withoutPlaceholder = safeReplace(template, placeholder, '');
|
|
72
|
-
const withEarlyScripts = injectBeforeHydrationEntryScript(withoutPlaceholder, scripts, entryName);
|
|
73
|
-
if (withEarlyScripts !== withoutPlaceholder) return withEarlyScripts;
|
|
74
|
-
return safeReplace(template, placeholder, scripts);
|
|
75
|
-
}
|
|
76
|
-
function createRouteHydrationScriptTags(runtimeContext, entryName, options = {}) {
|
|
77
|
-
const { nonce, template } = options;
|
|
78
|
-
const routeAssets = getRouteAssets(runtimeContext);
|
|
79
|
-
if (void 0 === routeAssets) return '';
|
|
80
|
-
const existingScriptSrcs = void 0 === template ? new Set() : new Set(getScriptTags(template).map(({ src })=>src));
|
|
81
|
-
const jsAssets = Array.from(new Set([
|
|
82
|
-
...getMatchedRouteAssets(runtimeContext),
|
|
83
|
-
...routeAssets[`async-${entryName}`]?.assets ?? []
|
|
84
|
-
].filter((asset)=>asset.endsWith('.js'))));
|
|
85
|
-
return jsAssets.filter((asset)=>!existingScriptSrcs.has(asset)).map((asset)=>`<script${attributesToString({
|
|
86
|
-
src: asset,
|
|
87
|
-
nonce: nonce || void 0
|
|
88
|
-
})}></script>`).join(' ');
|
|
89
|
-
}
|
|
90
|
-
export { createRouteHydrationScriptTags, getMatchedRouteChunks, injectBeforeHydrationEntryScript, orderHydrationScriptChunks, replaceChunkJsPlaceholder };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { classifyModuleFederationFallback, createModuleFederationFallbackTelemetry, emitModuleFederationFallbackTelemetry } from "./index.mjs";
|
|
2
|
-
import { createDiscoveryError, formatSurfaceRef, parseSurfaceRef, validateSurfaceRef } from "./surface-resolution-types.mjs";
|
|
3
|
-
function classifyDiscoveryError(code) {
|
|
4
|
-
switch(code){
|
|
5
|
-
case 'major-not-published':
|
|
6
|
-
case 'stale-record':
|
|
7
|
-
return 'version-skew';
|
|
8
|
-
case 'identity-mismatch':
|
|
9
|
-
return 'contract';
|
|
10
|
-
case 'unknown-unit':
|
|
11
|
-
case 'unknown-surface':
|
|
12
|
-
case 'provider-unavailable':
|
|
13
|
-
return 'remote-unavailable';
|
|
14
|
-
default:
|
|
15
|
-
return 'remote-unavailable';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function toRemoteString(ref) {
|
|
19
|
-
return void 0 === validateSurfaceRef(ref) ? formatSurfaceRef(ref) : `${ref.unitId}#${ref.surfaceId}`;
|
|
20
|
-
}
|
|
21
|
-
async function reportFailure(options, ref, base) {
|
|
22
|
-
const remote = toRemoteString(ref);
|
|
23
|
-
const telemetry = createModuleFederationFallbackTelemetry({
|
|
24
|
-
appName: options.appName,
|
|
25
|
-
classification: base.classification,
|
|
26
|
-
error: base.error ?? base.discoveryError,
|
|
27
|
-
metadata: {
|
|
28
|
-
env: options.env,
|
|
29
|
-
surfaceRef: remote,
|
|
30
|
-
...base.discoveryError ? {
|
|
31
|
-
discoveryErrorCode: base.discoveryError.code
|
|
32
|
-
} : {},
|
|
33
|
-
...base.resolved ? {
|
|
34
|
-
buildMarker: base.resolved.buildMarker
|
|
35
|
-
} : {}
|
|
36
|
-
},
|
|
37
|
-
phase: base.phase,
|
|
38
|
-
remote,
|
|
39
|
-
status: 'degraded'
|
|
40
|
-
});
|
|
41
|
-
try {
|
|
42
|
-
await emitModuleFederationFallbackTelemetry({
|
|
43
|
-
appName: options.appName,
|
|
44
|
-
classification: base.classification,
|
|
45
|
-
error: base.error ?? base.discoveryError,
|
|
46
|
-
metadata: telemetry.metadata,
|
|
47
|
-
phase: base.phase,
|
|
48
|
-
remote,
|
|
49
|
-
status: 'degraded'
|
|
50
|
-
}, options.telemetry ?? {});
|
|
51
|
-
} catch {}
|
|
52
|
-
const failure = {
|
|
53
|
-
ref,
|
|
54
|
-
env: options.env,
|
|
55
|
-
phase: base.phase,
|
|
56
|
-
classification: base.classification,
|
|
57
|
-
telemetry
|
|
58
|
-
};
|
|
59
|
-
if (base.discoveryError) failure.discoveryError = base.discoveryError;
|
|
60
|
-
if (void 0 !== base.error) failure.error = base.error;
|
|
61
|
-
if (base.resolved) failure.resolved = base.resolved;
|
|
62
|
-
const critical = (options.classification ?? 'critical') === 'critical';
|
|
63
|
-
const reason = base.discoveryError ?? (void 0 !== base.error ? base.error : createDiscoveryError('identity-mismatch', remote, `resolved record for "${remote}" is incompatible`, {
|
|
64
|
-
env: options.env
|
|
65
|
-
}));
|
|
66
|
-
let degradedValue;
|
|
67
|
-
try {
|
|
68
|
-
degradedValue = await options.degraded(failure);
|
|
69
|
-
} catch (handlerError) {
|
|
70
|
-
try {
|
|
71
|
-
await emitModuleFederationFallbackTelemetry({
|
|
72
|
-
appName: options.appName,
|
|
73
|
-
classification: base.classification,
|
|
74
|
-
error: handlerError,
|
|
75
|
-
metadata: {
|
|
76
|
-
...telemetry.metadata,
|
|
77
|
-
degradedHandlerFailed: true
|
|
78
|
-
},
|
|
79
|
-
phase: base.phase,
|
|
80
|
-
remote,
|
|
81
|
-
status: 'failed'
|
|
82
|
-
}, options.telemetry ?? {});
|
|
83
|
-
} catch {}
|
|
84
|
-
if (critical) throw reason;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (critical) throw reason;
|
|
88
|
-
return degradedValue;
|
|
89
|
-
}
|
|
90
|
-
async function consumeSurface(options) {
|
|
91
|
-
let ref;
|
|
92
|
-
if ('string' == typeof options.ref) {
|
|
93
|
-
const parsed = parseSurfaceRef(options.ref);
|
|
94
|
-
if (!parsed.ok) {
|
|
95
|
-
const hashIndex = options.ref.indexOf('#');
|
|
96
|
-
const echoed = -1 === hashIndex ? {
|
|
97
|
-
unitId: options.ref,
|
|
98
|
-
surfaceId: ''
|
|
99
|
-
} : {
|
|
100
|
-
unitId: options.ref.slice(0, hashIndex),
|
|
101
|
-
surfaceId: options.ref.slice(hashIndex + 1)
|
|
102
|
-
};
|
|
103
|
-
return reportFailure(options, echoed, {
|
|
104
|
-
phase: 'discovery',
|
|
105
|
-
classification: 'remote-unavailable',
|
|
106
|
-
discoveryError: createDiscoveryError('unknown-surface', options.ref, `SurfaceRef "${options.ref}" is not a valid canonical reference (${parsed.error.code}).`, {
|
|
107
|
-
parseError: parsed.error,
|
|
108
|
-
env: options.env
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
ref = parsed.ref;
|
|
113
|
-
} else ref = options.ref;
|
|
114
|
-
let resolution;
|
|
115
|
-
try {
|
|
116
|
-
resolution = await options.provider.resolve(ref, options.env);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
return reportFailure(options, ref, {
|
|
119
|
-
phase: 'discovery',
|
|
120
|
-
classification: classifyModuleFederationFallback(error),
|
|
121
|
-
error
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
if (!resolution.ok) return reportFailure(options, ref, {
|
|
125
|
-
phase: 'discovery',
|
|
126
|
-
classification: classifyDiscoveryError(resolution.error.code),
|
|
127
|
-
discoveryError: resolution.error
|
|
128
|
-
});
|
|
129
|
-
const resolved = resolution.unit;
|
|
130
|
-
if ('incompatible' === resolved.compatibility.status) return reportFailure(options, ref, {
|
|
131
|
-
phase: 'discovery',
|
|
132
|
-
classification: 'contract',
|
|
133
|
-
resolved
|
|
134
|
-
});
|
|
135
|
-
try {
|
|
136
|
-
return await options.load({
|
|
137
|
-
resolved,
|
|
138
|
-
ref,
|
|
139
|
-
env: options.env
|
|
140
|
-
});
|
|
141
|
-
} catch (error) {
|
|
142
|
-
return reportFailure(options, ref, {
|
|
143
|
-
phase: 'load',
|
|
144
|
-
classification: classifyModuleFederationFallback(error),
|
|
145
|
-
error,
|
|
146
|
-
resolved
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function createSurfaceConsumer(base) {
|
|
151
|
-
return function(options) {
|
|
152
|
-
return consumeSurface({
|
|
153
|
-
...base,
|
|
154
|
-
...options
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export { consumeSurface, createSurfaceConsumer };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRuntimeContext } from "../core/context/runtime.mjs";
|
|
3
|
-
const DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY = '__modernDistributedSsrFragments';
|
|
4
|
-
const DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY = '__modernDistributedSsrFragmentRequest';
|
|
5
|
-
function distributedSsrFragmentKey(remote, expose) {
|
|
6
|
-
return `${remote}::${expose}`;
|
|
7
|
-
}
|
|
8
|
-
function getDistributedSsrFragmentContext(response) {
|
|
9
|
-
const locals = response?.locals;
|
|
10
|
-
if ('object' != typeof locals || null === locals) return;
|
|
11
|
-
const context = DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY in locals ? locals[DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY] : void 0;
|
|
12
|
-
if ('object' != typeof context || null === context) return;
|
|
13
|
-
return context;
|
|
14
|
-
}
|
|
15
|
-
function useDistributedSsrFragmentProps({ boundaryId, expose }) {
|
|
16
|
-
const runtimeContext = useRuntimeContext();
|
|
17
|
-
const locals = runtimeContext.requestContext?.response?.locals;
|
|
18
|
-
const request = 'object' == typeof locals && null !== locals && DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY in locals ? locals[DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY] : void 0;
|
|
19
|
-
if ('object' != typeof request || null === request || !('boundaryId' in request) || request.boundaryId !== boundaryId || !('expose' in request) || request.expose !== expose) throw new Error(`Distributed SSR fragment request contract mismatch for ${boundaryId} ${expose}.`);
|
|
20
|
-
const props = 'props' in request ? request.props : void 0;
|
|
21
|
-
if ('object' != typeof props || null === props || Array.isArray(props)) throw new Error(`Distributed SSR fragment request props must be an object for ${boundaryId} ${expose}.`);
|
|
22
|
-
return props;
|
|
23
|
-
}
|
|
24
|
-
function isThenable(value) {
|
|
25
|
-
return void 0 !== value && 'then' in value && 'function' == typeof value.then;
|
|
26
|
-
}
|
|
27
|
-
function DistributedSsrBoundary({ children, expose, fallback, fragmentProps, remote }) {
|
|
28
|
-
const runtimeContext = useRuntimeContext();
|
|
29
|
-
const key = distributedSsrFragmentKey(remote, expose);
|
|
30
|
-
const attributes = {
|
|
31
|
-
'data-modern-distributed-ssr-boundary': key
|
|
32
|
-
};
|
|
33
|
-
if (runtimeContext.isBrowser) return /*#__PURE__*/ jsx("div", {
|
|
34
|
-
...attributes,
|
|
35
|
-
children: children
|
|
36
|
-
});
|
|
37
|
-
const fragmentContext = getDistributedSsrFragmentContext(runtimeContext.requestContext?.response);
|
|
38
|
-
if (void 0 === fragmentContext) return /*#__PURE__*/ jsx("div", {
|
|
39
|
-
...attributes,
|
|
40
|
-
children: children
|
|
41
|
-
});
|
|
42
|
-
const resolverFragmentProps = void 0 === fragmentProps ? {} : Object.fromEntries(Object.entries(fragmentProps));
|
|
43
|
-
const fragmentOrPromise = fragmentContext.resolve?.(remote, expose, resolverFragmentProps) ?? fragmentContext.fragments?.[key];
|
|
44
|
-
if (isThenable(fragmentOrPromise)) throw fragmentOrPromise;
|
|
45
|
-
const fragment = fragmentOrPromise;
|
|
46
|
-
if (fragment?.status === 'ready') return /*#__PURE__*/ jsx("div", {
|
|
47
|
-
...attributes,
|
|
48
|
-
"data-modern-distributed-ssr-build": fragment.buildMarker,
|
|
49
|
-
"data-modern-distributed-ssr-digest": fragment.digest,
|
|
50
|
-
"data-modern-distributed-ssr-status": "ready",
|
|
51
|
-
dangerouslySetInnerHTML: {
|
|
52
|
-
__html: fragment.html
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return /*#__PURE__*/ jsx("div", {
|
|
56
|
-
...attributes,
|
|
57
|
-
"data-modern-distributed-ssr-reason": fragment?.reason ?? 'missing',
|
|
58
|
-
"data-modern-distributed-ssr-status": "degraded",
|
|
59
|
-
children: fallback
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function createDistributedSsrComponent({ createComponent, expose, fallback, remote }) {
|
|
63
|
-
let RemoteComponent;
|
|
64
|
-
function DeferredRemoteComponent(props) {
|
|
65
|
-
RemoteComponent ??= createComponent();
|
|
66
|
-
return /*#__PURE__*/ jsx(RemoteComponent, {
|
|
67
|
-
...props
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return function(props) {
|
|
71
|
-
return /*#__PURE__*/ jsx(DistributedSsrBoundary, {
|
|
72
|
-
expose: expose,
|
|
73
|
-
fallback: fallback,
|
|
74
|
-
fragmentProps: props,
|
|
75
|
-
remote: remote,
|
|
76
|
-
children: /*#__PURE__*/ jsx(DeferredRemoteComponent, {
|
|
77
|
-
...props
|
|
78
|
-
})
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
export { DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY, DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY, DistributedSsrBoundary, createDistributedSsrComponent, distributedSsrFragmentKey, useDistributedSsrFragmentProps };
|