dinou 9.0.2 → 9.0.3

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 (37) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +503 -9883
  3. package/dinou/bun/build.js +38 -1
  4. package/{cli.js → dinou/cli.js} +8 -7
  5. package/dinou/cloudflare/build.js +37 -0
  6. package/dinou/core/build-static-pages.js +15 -7
  7. package/dinou/core/cache-revalidate.js +909 -151
  8. package/dinou/core/cache-slot.js +728 -97
  9. package/dinou/core/client-webpack.jsx +60 -9
  10. package/dinou/core/client.jsx +60 -9
  11. package/dinou/core/edge-ssr.js +33 -5
  12. package/dinou/core/generate-static.js +109 -47
  13. package/dinou/core/get-jsx.js +333 -329
  14. package/dinou/core/handler.js +2983 -2343
  15. package/dinou/core/layout-functions.js +102 -1
  16. package/dinou/core/ppr-context.js +256 -105
  17. package/dinou/core/ppr-runtime.js +540 -267
  18. package/dinou/core/render-jsx-to-client-jsx.js +131 -71
  19. package/dinou/core/slot.js +246 -33
  20. package/dinou/core/storage-adapter.js +117 -11
  21. package/dinou/deno/build.js +38 -1
  22. package/dinou/deno/seed-kv.js +43 -11
  23. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +242 -225
  24. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +253 -226
  25. package/dinou/esbuild/react-refresh/esm-hmr/client.js +209 -209
  26. package/dinou/node/build.js +2 -2
  27. package/dinou/node/bundle-dual-engine.js +2 -0
  28. package/dinou/node/dev.js +2853 -2704
  29. package/dinou/package.json +5 -2
  30. package/dinou/rollup/react-refresh/esm-hmr/client.js +220 -220
  31. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +182 -160
  32. package/dinou/server.d.ts +25 -11
  33. package/dinou/server.js +5 -0
  34. package/dinou/webpack/loaders/server-functions-loader.js +101 -94
  35. package/dinou/webpack/webpack.config.js +9 -4
  36. package/eject.js +219 -223
  37. package/package.json +2 -2
@@ -1,329 +1,333 @@
1
- import path from "node:path";
2
- import { pathToFileURL, fileURLToPath } from "node:url";
3
- import { existsSync } from "./vfs.js";
4
- import React from "react";
5
- import {
6
- getFilePathAndDynamicParams,
7
- } from "./get-file-path-and-dynamic-params.js";
8
- import importModule from "./import-module.js";
9
- import { asyncRenderJSXToClientJSX } from "./render-jsx-to-client-jsx.js";
10
- import { getLayoutProps } from "./layout-functions.js";
11
- import { DinouPageSlot as RawDinouPageSlot } from "./slot.js";
12
- import { getErrorJSX } from "./get-error-jsx.js";
13
- import { createRequire } from "node:module";
14
-
15
- const require = createRequire(import.meta.url);
16
- const currentDir = path.dirname(fileURLToPath(import.meta.url));
17
-
18
- async function getJSX(
19
- reqPath,
20
- query,
21
- isNotFound = null,
22
- isDevelopment = false,
23
- forceNotFound = false,
24
- options = {},
25
- ) {
26
- const srcFolder = path.resolve(process.cwd(), "src");
27
- const reqSegments = reqPath.split("/").filter(Boolean);
28
- const normalizedReqPath =
29
- "/" + reqSegments.join("/") + (reqSegments.length > 0 ? "/" : "");
30
-
31
- let jsx;
32
- let pageFunctionsProps;
33
-
34
- // 1. Segmented handling for Layout: If only the layout is requested
35
- if (options && options.segment === "layout") {
36
- let DinouPageSlot = RawDinouPageSlot;
37
- if (
38
- typeof DinouPageSlot === "function" &&
39
- DinouPageSlot.$$typeof !== Symbol.for("react.client.reference")
40
- ) {
41
- const slotPath = path.resolve(currentDir, "slot.js");
42
- const fileUrl = pathToFileURL(slotPath).href;
43
- let regFn = null;
44
- try {
45
- const pkg = require("react-server-dom-webpack/server");
46
- regFn = pkg.registerClientReference;
47
- } catch (e) {}
48
- if (!regFn) {
49
- try {
50
- const pkg = require("@roggc/react-server-dom-esm/server.node.js");
51
- regFn = pkg.registerClientReference;
52
- } catch (e) {}
53
- }
54
- if (regFn) {
55
- DinouPageSlot = regFn(DinouPageSlot, fileUrl, "DinouPageSlot");
56
- } else {
57
- Object.defineProperties(DinouPageSlot, {
58
- $$typeof: { value: Symbol.for("react.client.reference") },
59
- $$id: { value: fileUrl + "#DinouPageSlot" },
60
- });
61
- }
62
- }
63
- jsx = React.createElement(DinouPageSlot);
64
- } else {
65
- const hasRouterSyntax = reqSegments.some((seg) => {
66
- const isGroup = seg.startsWith("(") && seg.endsWith(")");
67
-
68
- const isDynamic = seg.startsWith("[") && seg.endsWith("]");
69
- const isSlot = seg.startsWith("@");
70
- const isPrivate = seg.startsWith("_");
71
-
72
- return isGroup || isDynamic || isSlot || isPrivate;
73
- });
74
-
75
- let pagePath;
76
- let folderPath = "";
77
- if (!hasRouterSyntax) {
78
- folderPath = path.join(srcFolder, ...reqSegments);
79
- if (existsSync(folderPath)) {
80
- for (const ext of [".tsx", ".ts", ".jsx", ".js"]) {
81
- const candidatePath = path.join(folderPath, `page${ext}`);
82
- if (existsSync(candidatePath)) {
83
- pagePath = candidatePath;
84
- break;
85
- }
86
- }
87
- }
88
- }
89
- let dynamicParams = {};
90
-
91
- if (!pagePath) {
92
- const [filePath, dParams] = getFilePathAndDynamicParams(
93
- reqSegments,
94
- query,
95
- srcFolder,
96
- );
97
- pagePath = filePath;
98
- dynamicParams = dParams ?? {};
99
- }
100
-
101
- if (!pagePath || forceNotFound) {
102
- if (isNotFound) isNotFound.value = true;
103
- const [notFoundPath, dParams] = getFilePathAndDynamicParams(
104
- reqSegments,
105
- query,
106
- srcFolder,
107
- "not_found",
108
- true,
109
- false,
110
- );
111
- if (!notFoundPath) {
112
- jsx = React.createElement(
113
- "div",
114
- null,
115
- `Page not found: no "page" file found for "${normalizedReqPath}"`,
116
- );
117
- } else {
118
- const pageModule = await importModule(notFoundPath);
119
- const Page = pageModule.default ?? pageModule;
120
- let props = {
121
- params: dParams ?? {},
122
- };
123
- const notFoundDir = path.dirname(notFoundPath);
124
-
125
- const [pageFunctionsPath] = getFilePathAndDynamicParams(
126
- reqSegments,
127
- query,
128
- notFoundDir,
129
- "page_functions",
130
- true,
131
- true,
132
- undefined,
133
- reqSegments.length,
134
- );
135
- if (pageFunctionsPath) {
136
- const pageFunctionsModule = await importModule(pageFunctionsPath);
137
- const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
138
- const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
139
- pageFunctionsProps = await getProps?.(dParams ?? {});
140
- props = { ...props, ...(pageFunctionsProps ?? {}) };
141
- }
142
-
143
- jsx = React.createElement(Page, props);
144
- const noLayoutNotFoundPath = path.join(
145
- notFoundDir,
146
- `no_layout_not_found`,
147
- );
148
- if (existsSync(noLayoutNotFoundPath)) {
149
- return jsx;
150
- }
151
- }
152
- } else {
153
- if (isNotFound) isNotFound.value = false;
154
- const pageModule = await importModule(pagePath);
155
- const Page = pageModule.default ?? pageModule;
156
-
157
- let props = {
158
- params: dynamicParams,
159
- };
160
-
161
- const pageFolder = path.dirname(pagePath);
162
- const [pageFunctionsPath] = getFilePathAndDynamicParams(
163
- reqSegments,
164
- query,
165
- pageFolder,
166
- "page_functions",
167
- true,
168
- true,
169
- undefined,
170
- reqSegments.length,
171
- );
172
- if (pageFunctionsPath) {
173
- const pageFunctionsModule = await importModule(pageFunctionsPath);
174
- const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
175
- const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
176
- pageFunctionsProps = await getProps?.(dynamicParams);
177
- props = { ...props, ...(pageFunctionsProps ?? {}) };
178
- }
179
-
180
- jsx = React.createElement(Page, props);
181
- }
182
-
183
- // 2. Segmented handling for Page: If only the page is requested, return without layouts
184
- if (options && options.segment === "page") {
185
- return jsx;
186
- }
187
- }
188
-
189
- if (
190
- getFilePathAndDynamicParams(
191
- reqSegments,
192
- query,
193
- srcFolder,
194
- "no_layout",
195
- false,
196
- )[0]
197
- ) {
198
- return jsx;
199
- }
200
-
201
- const layouts = getFilePathAndDynamicParams(
202
- reqSegments,
203
- query,
204
- srcFolder,
205
- "layout",
206
- true,
207
- false,
208
- undefined,
209
- 0,
210
- {},
211
- true,
212
- );
213
-
214
- if (layouts && Array.isArray(layouts)) {
215
- let index = 0;
216
- for (const [layoutPath, dParams, slots] of layouts.reverse()) {
217
- const layoutModule = await importModule(layoutPath);
218
- const layoutFolderPath = path.dirname(layoutPath);
219
- const resetLayoutPath = getFilePathAndDynamicParams(
220
- [],
221
- {},
222
- layoutFolderPath,
223
- "reset_layout",
224
- false,
225
- )[0];
226
- const Layout = layoutModule.default ?? layoutModule;
227
- const updatedSlots = {};
228
- for (const [slotName, slotValue] of Object.entries(slots)) {
229
- let updatedSlotElement;
230
- const slotFilePath = slotValue?.slotPath || slotValue?.props?.__modulePath;
231
- const slotParams = slotValue?.slotParams || slotValue?.props?.params || {};
232
- try {
233
- let elementToRender;
234
- if (slotValue && slotValue.slotPath) {
235
- const slotModule = await importModule(slotValue.slotPath);
236
- const Slot = slotModule.default ?? slotModule;
237
- elementToRender = React.createElement(Slot, {
238
- params: slotParams,
239
- key: slotName,
240
- __modulePath: slotValue.slotPath,
241
- });
242
- } else {
243
- elementToRender = slotValue;
244
- }
245
- await asyncRenderJSXToClientJSX(elementToRender);
246
- updatedSlotElement = elementToRender;
247
- } catch (e) {
248
- if (slotFilePath) {
249
- const realSlotFolder = path.dirname(slotFilePath);
250
-
251
- const [slotErrorPath, slotErrorParams] =
252
- getFilePathAndDynamicParams(
253
- reqSegments,
254
- query,
255
- realSlotFolder,
256
- "error",
257
- true, // withExtension
258
- true, // finalDestination
259
- undefined, // lastFound
260
- reqSegments.length,
261
- );
262
-
263
- if (slotErrorPath) {
264
- const slotErrorModule = await importModule(slotErrorPath);
265
- const SlotError = slotErrorModule.default ?? slotErrorModule;
266
-
267
- const serializedError = {
268
- message: e.message || "Unknown Error",
269
- name: e.name,
270
- stack: isDevelopment ? e.stack : undefined,
271
- };
272
-
273
- updatedSlotElement = React.createElement(SlotError, {
274
- params: slotErrorParams,
275
- key: slotName,
276
- error: serializedError,
277
- });
278
- } else {
279
- console.warn(
280
- `[Dinou] Slot @${slotName} failed and does not have error.tsx`,
281
- );
282
- updatedSlotElement = null;
283
- }
284
- } else {
285
- console.error(
286
- `[Dinou] Could not locate the path of the slot @${slotName}`,
287
- );
288
- updatedSlotElement = null;
289
- }
290
- } finally {
291
- updatedSlots[slotName] = updatedSlotElement;
292
- }
293
- }
294
- const layoutProps = await getLayoutProps(layoutPath, dParams);
295
- let props = { params: dParams, ...updatedSlots, ...(layoutProps ?? {}) };
296
- try {
297
- const testElement = React.createElement(Layout, props, null);
298
- await asyncRenderJSXToClientJSX(testElement);
299
- jsx = React.createElement(Layout, props, jsx);
300
- } catch (layoutErr) {
301
- console.warn(
302
- `[Dinou] Layout ${layoutPath} failed during render, isolating layout error:`,
303
- layoutErr?.message || layoutErr
304
- );
305
- const serializedError = {
306
- message: layoutErr.message || "Unknown Error",
307
- name: layoutErr.name || "Error",
308
- stack: isDevelopment ? layoutErr.stack : undefined,
309
- };
310
- jsx = await getErrorJSX(
311
- reqPath,
312
- query,
313
- serializedError,
314
- isDevelopment,
315
- { segment: "page" }
316
- );
317
- }
318
- if (resetLayoutPath) {
319
- break;
320
- }
321
- index++;
322
- }
323
- }
324
-
325
- return jsx;
326
- }
327
-
328
- export { getJSX };
329
- export default getJSX;
1
+ import path from "node:path";
2
+ import { pathToFileURL, fileURLToPath } from "node:url";
3
+ import { existsSync } from "./vfs.js";
4
+ import React from "react";
5
+ import {
6
+ getFilePathAndDynamicParams,
7
+ } from "./get-file-path-and-dynamic-params.js";
8
+ import importModule from "./import-module.js";
9
+ import { asyncRenderJSXToClientJSX } from "./render-jsx-to-client-jsx.js";
10
+ import { getLayoutProps } from "./layout-functions.js";
11
+ import { DinouPageSlot as RawDinouPageSlot } from "./slot.js";
12
+ import { getErrorJSX } from "./get-error-jsx.js";
13
+ import { markPageRootElement, runInLayoutSegment } from "./ppr-context.js";
14
+ import { createRequire } from "node:module";
15
+
16
+ const require = createRequire(import.meta.url);
17
+ const currentDir = path.dirname(fileURLToPath(import.meta.url));
18
+
19
+ async function getJSX(
20
+ reqPath,
21
+ query,
22
+ isNotFound = null,
23
+ isDevelopment = false,
24
+ forceNotFound = false,
25
+ options = {},
26
+ ) {
27
+ const srcFolder = path.resolve(process.cwd(), "src");
28
+ const reqSegments = reqPath.split("/").filter(Boolean);
29
+ const normalizedReqPath =
30
+ "/" + reqSegments.join("/") + (reqSegments.length > 0 ? "/" : "");
31
+
32
+ let jsx;
33
+ let pageFunctionsProps;
34
+
35
+ // 1. Segmented handling for Layout: If only the layout is requested
36
+ if (options && options.segment === "layout") {
37
+ let DinouPageSlot = RawDinouPageSlot;
38
+ if (
39
+ typeof DinouPageSlot === "function" &&
40
+ DinouPageSlot.$$typeof !== Symbol.for("react.client.reference")
41
+ ) {
42
+ const slotPath = path.resolve(currentDir, "slot.js");
43
+ const fileUrl = pathToFileURL(slotPath).href;
44
+ let regFn = null;
45
+ try {
46
+ const pkg = require("react-server-dom-webpack/server");
47
+ regFn = pkg.registerClientReference;
48
+ } catch (e) {}
49
+ if (!regFn) {
50
+ try {
51
+ const pkg = require("@roggc/react-server-dom-esm/server.node.js");
52
+ regFn = pkg.registerClientReference;
53
+ } catch (e) {}
54
+ }
55
+ if (regFn) {
56
+ DinouPageSlot = regFn(DinouPageSlot, fileUrl, "DinouPageSlot");
57
+ } else {
58
+ Object.defineProperties(DinouPageSlot, {
59
+ $$typeof: { value: Symbol.for("react.client.reference") },
60
+ $$id: { value: fileUrl + "#DinouPageSlot" },
61
+ });
62
+ }
63
+ }
64
+ jsx = React.createElement(DinouPageSlot);
65
+ } else {
66
+ const hasRouterSyntax = reqSegments.some((seg) => {
67
+ const isGroup = seg.startsWith("(") && seg.endsWith(")");
68
+
69
+ const isDynamic = seg.startsWith("[") && seg.endsWith("]");
70
+ const isSlot = seg.startsWith("@");
71
+ const isPrivate = seg.startsWith("_");
72
+
73
+ return isGroup || isDynamic || isSlot || isPrivate;
74
+ });
75
+
76
+ let pagePath;
77
+ let folderPath = "";
78
+ if (!hasRouterSyntax) {
79
+ folderPath = path.join(srcFolder, ...reqSegments);
80
+ if (existsSync(folderPath)) {
81
+ for (const ext of [".tsx", ".ts", ".jsx", ".js"]) {
82
+ const candidatePath = path.join(folderPath, `page${ext}`);
83
+ if (existsSync(candidatePath)) {
84
+ pagePath = candidatePath;
85
+ break;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ let dynamicParams = {};
91
+
92
+ if (!pagePath) {
93
+ const [filePath, dParams] = getFilePathAndDynamicParams(
94
+ reqSegments,
95
+ query,
96
+ srcFolder,
97
+ );
98
+ pagePath = filePath;
99
+ dynamicParams = dParams ?? {};
100
+ }
101
+
102
+ if (!pagePath || forceNotFound) {
103
+ if (isNotFound) isNotFound.value = true;
104
+ const [notFoundPath, dParams] = getFilePathAndDynamicParams(
105
+ reqSegments,
106
+ query,
107
+ srcFolder,
108
+ "not_found",
109
+ true,
110
+ false,
111
+ );
112
+ if (!notFoundPath) {
113
+ jsx = markPageRootElement(
114
+ React.createElement(
115
+ "div",
116
+ null,
117
+ `Page not found: no "page" file found for "${normalizedReqPath}"`,
118
+ ),
119
+ );
120
+ } else {
121
+ const pageModule = await importModule(notFoundPath);
122
+ const Page = pageModule.default ?? pageModule;
123
+ let props = {
124
+ params: dParams ?? {},
125
+ };
126
+ const notFoundDir = path.dirname(notFoundPath);
127
+
128
+ const [pageFunctionsPath] = getFilePathAndDynamicParams(
129
+ reqSegments,
130
+ query,
131
+ notFoundDir,
132
+ "page_functions",
133
+ true,
134
+ true,
135
+ undefined,
136
+ reqSegments.length,
137
+ );
138
+ if (pageFunctionsPath) {
139
+ const pageFunctionsModule = await importModule(pageFunctionsPath);
140
+ const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
141
+ const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
142
+ pageFunctionsProps = await getProps?.(dParams ?? {});
143
+ props = { ...props, ...(pageFunctionsProps ?? {}) };
144
+ }
145
+
146
+ jsx = markPageRootElement(React.createElement(Page, props));
147
+ const noLayoutNotFoundPath = path.join(
148
+ notFoundDir,
149
+ `no_layout_not_found`,
150
+ );
151
+ if (existsSync(noLayoutNotFoundPath)) {
152
+ return jsx;
153
+ }
154
+ }
155
+ } else {
156
+ if (isNotFound) isNotFound.value = false;
157
+ const pageModule = await importModule(pagePath);
158
+ const Page = pageModule.default ?? pageModule;
159
+
160
+ let props = {
161
+ params: dynamicParams,
162
+ };
163
+
164
+ const pageFolder = path.dirname(pagePath);
165
+ const [pageFunctionsPath] = getFilePathAndDynamicParams(
166
+ reqSegments,
167
+ query,
168
+ pageFolder,
169
+ "page_functions",
170
+ true,
171
+ true,
172
+ undefined,
173
+ reqSegments.length,
174
+ );
175
+ if (pageFunctionsPath) {
176
+ const pageFunctionsModule = await importModule(pageFunctionsPath);
177
+ const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
178
+ const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
179
+ pageFunctionsProps = await getProps?.(dynamicParams);
180
+ props = { ...props, ...(pageFunctionsProps ?? {}) };
181
+ }
182
+
183
+ jsx = markPageRootElement(React.createElement(Page, props));
184
+ }
185
+
186
+ // 2. Segmented handling for Page: If only the page is requested, return without layouts
187
+ if (options && options.segment === "page") {
188
+ return jsx;
189
+ }
190
+ }
191
+
192
+ if (
193
+ options?.segment !== "layout" &&
194
+ getFilePathAndDynamicParams(
195
+ reqSegments,
196
+ query,
197
+ srcFolder,
198
+ "no_layout",
199
+ false,
200
+ )[0]
201
+ ) {
202
+ return jsx;
203
+ }
204
+
205
+ const layouts = getFilePathAndDynamicParams(
206
+ reqSegments,
207
+ query,
208
+ srcFolder,
209
+ "layout",
210
+ true,
211
+ false,
212
+ undefined,
213
+ 0,
214
+ {},
215
+ true,
216
+ );
217
+
218
+ if (layouts && Array.isArray(layouts)) {
219
+ let index = 0;
220
+ for (const [layoutPath, dParams, slots] of layouts.reverse()) {
221
+ const layoutModule = await importModule(layoutPath);
222
+ const layoutFolderPath = path.dirname(layoutPath);
223
+ const resetLayoutPath = getFilePathAndDynamicParams(
224
+ [],
225
+ {},
226
+ layoutFolderPath,
227
+ "reset_layout",
228
+ false,
229
+ )[0];
230
+ const Layout = layoutModule.default ?? layoutModule;
231
+ const updatedSlots = {};
232
+ for (const [slotName, slotValue] of Object.entries(slots)) {
233
+ let updatedSlotElement;
234
+ const slotFilePath = slotValue?.slotPath || slotValue?.props?.__modulePath;
235
+ const slotParams = slotValue?.slotParams || slotValue?.props?.params || {};
236
+ try {
237
+ let elementToRender;
238
+ if (slotValue && slotValue.slotPath) {
239
+ const slotModule = await importModule(slotValue.slotPath);
240
+ const Slot = slotModule.default ?? slotModule;
241
+ elementToRender = React.createElement(Slot, {
242
+ params: slotParams,
243
+ key: slotName,
244
+ __modulePath: slotValue.slotPath,
245
+ });
246
+ } else {
247
+ elementToRender = slotValue;
248
+ }
249
+ await runInLayoutSegment(() => asyncRenderJSXToClientJSX(elementToRender));
250
+ updatedSlotElement = elementToRender;
251
+ } catch (e) {
252
+ if (slotFilePath) {
253
+ const realSlotFolder = path.dirname(slotFilePath);
254
+
255
+ const [slotErrorPath, slotErrorParams] =
256
+ getFilePathAndDynamicParams(
257
+ reqSegments,
258
+ query,
259
+ realSlotFolder,
260
+ "error",
261
+ true, // withExtension
262
+ true, // finalDestination
263
+ undefined, // lastFound
264
+ reqSegments.length,
265
+ );
266
+
267
+ if (slotErrorPath) {
268
+ const slotErrorModule = await importModule(slotErrorPath);
269
+ const SlotError = slotErrorModule.default ?? slotErrorModule;
270
+
271
+ const serializedError = {
272
+ message: e.message || "Unknown Error",
273
+ name: e.name,
274
+ stack: isDevelopment ? e.stack : undefined,
275
+ };
276
+
277
+ updatedSlotElement = React.createElement(SlotError, {
278
+ params: slotErrorParams,
279
+ key: slotName,
280
+ error: serializedError,
281
+ });
282
+ } else {
283
+ console.warn(
284
+ `[Dinou] Slot @${slotName} failed and does not have error.tsx`,
285
+ );
286
+ updatedSlotElement = null;
287
+ }
288
+ } else {
289
+ console.error(
290
+ `[Dinou] Could not locate the path of the slot @${slotName}`,
291
+ );
292
+ updatedSlotElement = null;
293
+ }
294
+ } finally {
295
+ updatedSlots[slotName] = updatedSlotElement;
296
+ }
297
+ }
298
+ const layoutProps = await getLayoutProps(layoutPath, dParams);
299
+ let props = { params: dParams, ...updatedSlots, ...(layoutProps ?? {}) };
300
+ try {
301
+ const testElement = React.createElement(Layout, props, null);
302
+ await runInLayoutSegment(() => asyncRenderJSXToClientJSX(testElement));
303
+ jsx = React.createElement(Layout, props, jsx);
304
+ } catch (layoutErr) {
305
+ console.warn(
306
+ `[Dinou] Layout ${layoutPath} failed during render, isolating layout error:`,
307
+ layoutErr?.message || layoutErr
308
+ );
309
+ const serializedError = {
310
+ message: layoutErr.message || "Unknown Error",
311
+ name: layoutErr.name || "Error",
312
+ stack: isDevelopment ? layoutErr.stack : undefined,
313
+ };
314
+ jsx = await getErrorJSX(
315
+ reqPath,
316
+ query,
317
+ serializedError,
318
+ isDevelopment,
319
+ { segment: "page" }
320
+ );
321
+ }
322
+ if (resetLayoutPath) {
323
+ break;
324
+ }
325
+ index++;
326
+ }
327
+ }
328
+
329
+ return jsx;
330
+ }
331
+
332
+ export { getJSX };
333
+ export default getJSX;