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.
- package/CHANGELOG.md +54 -0
- package/README.md +503 -9883
- package/dinou/bun/build.js +38 -1
- package/{cli.js → dinou/cli.js} +8 -7
- package/dinou/cloudflare/build.js +37 -0
- package/dinou/core/build-static-pages.js +15 -7
- package/dinou/core/cache-revalidate.js +909 -151
- package/dinou/core/cache-slot.js +728 -97
- package/dinou/core/client-webpack.jsx +60 -9
- package/dinou/core/client.jsx +60 -9
- package/dinou/core/edge-ssr.js +33 -5
- package/dinou/core/generate-static.js +109 -47
- package/dinou/core/get-jsx.js +333 -329
- package/dinou/core/handler.js +2983 -2343
- package/dinou/core/layout-functions.js +102 -1
- package/dinou/core/ppr-context.js +256 -105
- package/dinou/core/ppr-runtime.js +540 -267
- package/dinou/core/render-jsx-to-client-jsx.js +131 -71
- package/dinou/core/slot.js +246 -33
- package/dinou/core/storage-adapter.js +117 -11
- package/dinou/deno/build.js +38 -1
- package/dinou/deno/seed-kv.js +43 -11
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +242 -225
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +253 -226
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +209 -209
- package/dinou/node/build.js +2 -2
- package/dinou/node/bundle-dual-engine.js +2 -0
- package/dinou/node/dev.js +2853 -2704
- package/dinou/package.json +5 -2
- package/dinou/rollup/react-refresh/esm-hmr/client.js +220 -220
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +182 -160
- package/dinou/server.d.ts +25 -11
- package/dinou/server.js +5 -0
- package/dinou/webpack/loaders/server-functions-loader.js +101 -94
- package/dinou/webpack/webpack.config.js +9 -4
- package/eject.js +219 -223
- package/package.json +2 -2
package/dinou/core/get-jsx.js
CHANGED
|
@@ -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 {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$$
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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;
|