@vistagenic/vista 0.2.4 → 0.2.5
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.
|
@@ -282,8 +282,8 @@ function buildRoutes(components, appDir) {
|
|
|
282
282
|
// Static URL pattern + auto mode = static by default
|
|
283
283
|
renderMode = 'static';
|
|
284
284
|
}
|
|
285
|
-
else if (rt === 'dynamic' && hasStaticParams) {
|
|
286
|
-
// Dynamic URL pattern + generateStaticParams = can be statically generated
|
|
285
|
+
else if ((rt === 'dynamic' || rt === 'catch-all') && hasStaticParams) {
|
|
286
|
+
// Dynamic or catch-all URL pattern + generateStaticParams = can be statically generated
|
|
287
287
|
renderMode = 'static';
|
|
288
288
|
}
|
|
289
289
|
routes.push({
|
|
@@ -181,6 +181,21 @@ async function prerenderPage(urlPath, route, params, cwd) {
|
|
|
181
181
|
try {
|
|
182
182
|
const React = require('react');
|
|
183
183
|
const { renderToString } = require('react-dom/server');
|
|
184
|
+
const isAsyncComponent = (component) => {
|
|
185
|
+
return (typeof component === 'function' &&
|
|
186
|
+
component.constructor &&
|
|
187
|
+
component.constructor.name === 'AsyncFunction');
|
|
188
|
+
};
|
|
189
|
+
const renderComponent = async (component, props, child) => {
|
|
190
|
+
if (isAsyncComponent(component)) {
|
|
191
|
+
const asyncProps = child === undefined ? props : { ...props, children: child };
|
|
192
|
+
return component(asyncProps);
|
|
193
|
+
}
|
|
194
|
+
if (child === undefined) {
|
|
195
|
+
return React.createElement(component, props);
|
|
196
|
+
}
|
|
197
|
+
return React.createElement(component, props, child);
|
|
198
|
+
};
|
|
184
199
|
// Load page component from webpack-built server bundle
|
|
185
200
|
const pageModule = require(route.pagePath);
|
|
186
201
|
const PageComponent = pageModule.default;
|
|
@@ -189,14 +204,14 @@ async function prerenderPage(urlPath, route, params, cwd) {
|
|
|
189
204
|
return null;
|
|
190
205
|
}
|
|
191
206
|
// Build the element, passing params as props
|
|
192
|
-
let element =
|
|
207
|
+
let element = await renderComponent(PageComponent, { params: params || {} });
|
|
193
208
|
// Wrap in layouts (outside-in)
|
|
194
209
|
for (let i = route.layoutPaths.length - 1; i >= 0; i--) {
|
|
195
210
|
try {
|
|
196
211
|
const layoutModule = require(route.layoutPaths[i]);
|
|
197
212
|
const LayoutComponent = layoutModule.default;
|
|
198
213
|
if (LayoutComponent) {
|
|
199
|
-
element =
|
|
214
|
+
element = await renderComponent(LayoutComponent, { params: params || {}, searchParams: {} }, element);
|
|
200
215
|
}
|
|
201
216
|
}
|
|
202
217
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vistagenic/vista",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "The React Framework for Visionaries - Rust-powered SSR with Server Components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -132,6 +132,5 @@
|
|
|
132
132
|
"@types/webpack": "^5.28.5",
|
|
133
133
|
"@types/webpack-hot-middleware": "^2.25.9",
|
|
134
134
|
"typescript": "^5.7.2"
|
|
135
|
-
}
|
|
136
|
-
"gitHead": "9fac2fe1ed23e51248ba8bcecbd623b9e3a3b520"
|
|
135
|
+
}
|
|
137
136
|
}
|