@mandujs/core 0.54.18 → 0.54.19
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/package.json +1 -1
- package/src/agent/__tests__/context.test.ts +40 -9
- package/src/agent/verify.ts +55 -24
- package/src/bundler/build.test.ts +40 -3
- package/src/bundler/build.ts +35 -680
- package/src/client/__tests__/props-serialization.test.ts +37 -0
- package/src/client/hydrate.ts +2 -2
- package/src/client/index.ts +1 -1
- package/src/client/props-serialization.ts +233 -0
- package/src/client/runtime-entry.ts +567 -0
- package/src/client/runtime.ts +1 -1
- package/src/client/serialize.ts +50 -404
- package/src/diagnose/__tests__/checks.test.ts +15 -0
- package/src/diagnose/checks.ts +1 -1
- package/src/router/client-entry.test.ts +111 -23
- package/src/router/client-entry.ts +78 -301
- package/src/router/fs-routes.test.ts +55 -0
- package/src/router/fs-scanner.ts +11 -40
- package/src/router/fs-types.ts +7 -1
- package/src/router/route-source-analyzer.ts +521 -0
- package/src/runtime/__tests__/inline-client-hydration.test.ts +104 -1
- package/src/runtime/__tests__/page-render-response.test.ts +6 -0
- package/src/runtime/page-render-response.ts +23 -1
- package/src/runtime/server.ts +14 -0
|
@@ -11,6 +11,13 @@ export interface InlineClientHydrationTarget {
|
|
|
11
11
|
src: string;
|
|
12
12
|
priority: NonNullable<HydrationConfig["priority"]>;
|
|
13
13
|
component: unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Compatibility path for pre-F42 route-level client modules where the
|
|
16
|
+
* client component is hidden behind a server wrapper. Disabled by default
|
|
17
|
+
* because it invokes user function components outside React's renderer.
|
|
18
|
+
*/
|
|
19
|
+
legacyRuntimeScan?: boolean;
|
|
20
|
+
sourceFile?: string;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
export interface PageRenderResponseOptions {
|
|
@@ -125,7 +132,8 @@ async function resolveAndWrapInlineClientHydration(
|
|
|
125
132
|
};
|
|
126
133
|
}
|
|
127
134
|
|
|
128
|
-
if (typeof type === "function" && !isClassComponent(type)) {
|
|
135
|
+
if (target.legacyRuntimeScan && typeof type === "function" && !isClassComponent(type)) {
|
|
136
|
+
warnLegacyRuntimePartialScan(target);
|
|
129
137
|
const rendered = await renderFunctionComponentForInlineHydration(
|
|
130
138
|
type,
|
|
131
139
|
element.props ?? {},
|
|
@@ -152,6 +160,20 @@ async function resolveAndWrapInlineClientHydration(
|
|
|
152
160
|
return { node: cloned, didWrap: resolvedChildren.didWrap };
|
|
153
161
|
}
|
|
154
162
|
|
|
163
|
+
const warnedLegacyRuntimePartialScanRoutes = new Set<string>();
|
|
164
|
+
|
|
165
|
+
function warnLegacyRuntimePartialScan(target: InlineClientHydrationTarget): void {
|
|
166
|
+
if (warnedLegacyRuntimePartialScanRoutes.has(target.routeId)) return;
|
|
167
|
+
warnedLegacyRuntimePartialScanRoutes.add(target.routeId);
|
|
168
|
+
|
|
169
|
+
const file = target.sourceFile ? ` file="${target.sourceFile}"` : "";
|
|
170
|
+
console.warn(
|
|
171
|
+
`[MANDU_LEGACY_RUNTIME_PARTIAL_SCAN] route="${target.routeId}"${file}: ` +
|
|
172
|
+
"runtime client component discovery is running under the compatibility flag. " +
|
|
173
|
+
"Migrate this route to compiler-owned client boundaries so SSR does not invoke user components during discovery.",
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
155
177
|
function isAsyncFunctionComponent(type: Function): boolean {
|
|
156
178
|
return !type.prototype?.isReactComponent &&
|
|
157
179
|
(type as { constructor?: { name?: string } }).constructor?.name === "AsyncFunction";
|
package/src/runtime/server.ts
CHANGED
|
@@ -1117,9 +1117,11 @@ function createDefaultAppFactory(registry: ServerRegistry) {
|
|
|
1117
1117
|
async function resolveInlineClientHydrationTarget(
|
|
1118
1118
|
route: {
|
|
1119
1119
|
id: string;
|
|
1120
|
+
componentModule?: string;
|
|
1120
1121
|
clientModule?: string;
|
|
1121
1122
|
clientExportName?: string;
|
|
1122
1123
|
hydration?: HydrationConfig;
|
|
1124
|
+
boundaries?: unknown[];
|
|
1123
1125
|
},
|
|
1124
1126
|
rootDir: string,
|
|
1125
1127
|
src: string,
|
|
@@ -1127,6 +1129,14 @@ async function resolveInlineClientHydrationTarget(
|
|
|
1127
1129
|
if (!route.clientModule || !src) {
|
|
1128
1130
|
return undefined;
|
|
1129
1131
|
}
|
|
1132
|
+
if (route.boundaries && route.boundaries.length > 0) {
|
|
1133
|
+
return undefined;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
const legacyRuntimeScan = process.env.MANDU_LEGACY_RUNTIME_PARTIAL_SCAN === "1";
|
|
1137
|
+
if (!legacyRuntimeScan) {
|
|
1138
|
+
return undefined;
|
|
1139
|
+
}
|
|
1130
1140
|
|
|
1131
1141
|
try {
|
|
1132
1142
|
const module = await import(path.join(rootDir, route.clientModule));
|
|
@@ -1139,6 +1149,8 @@ async function resolveInlineClientHydrationTarget(
|
|
|
1139
1149
|
src,
|
|
1140
1150
|
priority: route.hydration?.priority ?? "visible",
|
|
1141
1151
|
component,
|
|
1152
|
+
legacyRuntimeScan,
|
|
1153
|
+
sourceFile: route.componentModule ?? route.clientModule,
|
|
1142
1154
|
};
|
|
1143
1155
|
} catch (error) {
|
|
1144
1156
|
console.warn(
|
|
@@ -2112,8 +2124,10 @@ async function renderPageSSR(
|
|
|
2112
2124
|
errorModule?: string;
|
|
2113
2125
|
loadingModule?: string;
|
|
2114
2126
|
notFoundModule?: string;
|
|
2127
|
+
componentModule?: string;
|
|
2115
2128
|
clientModule?: string;
|
|
2116
2129
|
clientExportName?: string;
|
|
2130
|
+
boundaries?: unknown[];
|
|
2117
2131
|
},
|
|
2118
2132
|
params: Record<string, string>,
|
|
2119
2133
|
loaderData: unknown,
|