@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.
@@ -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";
@@ -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,