dinou 9.3.0 → 10.0.1

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 (166) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/README.md +157 -132
  3. package/dinou/adapters/bun.js +34 -5
  4. package/dinou/adapters/cloudflare.js +110 -17
  5. package/dinou/adapters/deno.js +46 -8
  6. package/dinou/adapters/netlify.js +86 -50
  7. package/dinou/adapters/node.js +8 -0
  8. package/dinou/assets.d.ts +32 -5
  9. package/dinou/bun/build.js +190 -106
  10. package/dinou/cli.js +992 -532
  11. package/dinou/cloudflare/build.js +187 -106
  12. package/dinou/compiled/autoprefixer/index.js +509 -517
  13. package/dinou/compiled/babel-core/index.js +738 -716
  14. package/dinou/compiled/babel-generator/index.js +341 -299
  15. package/dinou/compiled/babel-loader/index.js +766 -744
  16. package/dinou/compiled/babel-parser/index.js +2 -2
  17. package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
  18. package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
  19. package/dinou/compiled/babel-preset-react/index.js +752 -730
  20. package/dinou/compiled/babel-preset-typescript/index.js +738 -716
  21. package/dinou/compiled/babel-traverse/index.js +463 -433
  22. package/dinou/compiled/babel-types/index.js +176 -176
  23. package/dinou/compiled/chokidar/index.js +4 -4
  24. package/dinou/compiled/commander/index.js +15 -15
  25. package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
  26. package/dinou/compiled/css-loader/index.js +289 -289
  27. package/dinou/compiled/css-loader/runtime/api.js +85 -0
  28. package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
  29. package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
  30. package/dinou/compiled/css-loader/runtime/package.json +3 -0
  31. package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
  32. package/dinou/compiled/fast-glob/index.js +5810 -0
  33. package/dinou/compiled/generic-names/index.js +16 -16
  34. package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
  35. package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
  36. package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
  37. package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
  38. package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
  39. package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
  40. package/dinou/compiled/postcss/index.js +83 -83
  41. package/dinou/compiled/postcss-import/index.js +147 -117
  42. package/dinou/compiled/postcss-modules/index.js +216 -216
  43. package/dinou/compiled/resolve/index.js +1224 -0
  44. package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
  45. package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
  46. package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
  47. package/dinou/compiled/rollup-plugin-json/index.js +22 -18
  48. package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
  49. package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
  50. package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
  51. package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
  52. package/dinou/compiled/vendors-manifest.json +59 -83
  53. package/dinou/core/asset-extensions.js +482 -33
  54. package/dinou/core/bailout-proxy.js +21 -2
  55. package/dinou/core/build-static-pages.js +523 -371
  56. package/dinou/core/builtin-asset-extensions.js +63 -0
  57. package/dinou/core/cache-revalidate.js +449 -256
  58. package/dinou/core/cache-slot.js +289 -79
  59. package/dinou/core/client-webpack.jsx +470 -39
  60. package/dinou/core/client.jsx +402 -39
  61. package/dinou/core/config.js +3 -0
  62. package/dinou/core/copy-static-dirs.js +98 -0
  63. package/dinou/core/createScopedName.js +22 -4
  64. package/dinou/core/dinou-paths.js +1 -1
  65. package/dinou/core/discover-layouts.js +200 -0
  66. package/dinou/core/edge-ssr.js +1 -1
  67. package/dinou/core/ensure-vendor-mode.js +78 -19
  68. package/dinou/core/env.js +544 -0
  69. package/dinou/core/export-static.js +41 -9
  70. package/dinou/core/generate-route-types.js +989 -95
  71. package/dinou/core/generate-static-rsc.js +5 -6
  72. package/dinou/core/generate-static.js +45 -6
  73. package/dinou/core/get-abs-path-with-ext.js +217 -75
  74. package/dinou/core/get-asset-from-manifest.js +19 -8
  75. package/dinou/core/get-error-jsx.js +4 -5
  76. package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
  77. package/dinou/core/get-jsx.js +220 -53
  78. package/dinou/core/handler.js +1647 -466
  79. package/dinou/core/import-module.js +7 -0
  80. package/dinou/core/layout-functions.js +72 -13
  81. package/dinou/core/link.jsx +34 -6
  82. package/dinou/core/load-dinou-config.js +520 -89
  83. package/dinou/core/manifest-provider.js +4 -14
  84. package/dinou/core/navigation-utils.js +141 -3
  85. package/dinou/core/navigation.js +134 -50
  86. package/dinou/core/node-middleware-runner.js +165 -0
  87. package/dinou/core/postcss-pipeline.js +236 -0
  88. package/dinou/core/ppr-context.js +114 -22
  89. package/dinou/core/ppr-runtime.js +391 -127
  90. package/dinou/core/redirect.jsx +1 -1
  91. package/dinou/core/render-jsx-to-client-jsx.js +216 -48
  92. package/dinou/core/request-context.js +59 -3
  93. package/dinou/core/resolve-contextual-dinou.js +523 -0
  94. package/dinou/core/resolve-setup-files.js +85 -27
  95. package/dinou/core/revalidating.js +10 -2
  96. package/dinou/core/route-generator.js +6 -2
  97. package/dinou/core/rsc-renderer.js +4 -1
  98. package/dinou/core/run-ssg.js +6 -0
  99. package/dinou/core/runtime-env.js +265 -0
  100. package/dinou/core/server-css-modules-plugin.js +155 -0
  101. package/dinou/core/server-function-proxy-webpack.js +27 -2
  102. package/dinou/core/server-function-proxy.js +27 -2
  103. package/dinou/core/slot.js +47 -2
  104. package/dinou/core/static-assets.js +503 -0
  105. package/dinou/core/storage-adapter.js +452 -24
  106. package/dinou/core/transform-server-functions.js +272 -24
  107. package/dinou/core/tsconfig-aliases.js +964 -0
  108. package/dinou/core/uneject.js +640 -0
  109. package/dinou/core/url-resolver.js +1 -1
  110. package/dinou/core/vfs.js +11 -2
  111. package/dinou/css.d.ts +4 -1
  112. package/dinou/deno/build.js +205 -153
  113. package/dinou/deno/seed-kv.js +4 -0
  114. package/dinou/env.d.ts +22 -2
  115. package/dinou/esbuild/build.js +40 -50
  116. package/dinou/esbuild/dev.js +33 -7
  117. package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
  118. package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
  119. package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
  120. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
  121. package/dinou/esbuild/helpers-esbuild/write.js +13 -3
  122. package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
  123. package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
  124. package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
  125. package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
  126. package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
  127. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
  128. package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
  129. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
  130. package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
  131. package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
  132. package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
  133. package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
  134. package/dinou/index.d.ts +1028 -88
  135. package/dinou/node/build.js +138 -74
  136. package/dinou/node/bundle-dual-engine.js +393 -131
  137. package/dinou/node/dev.js +1005 -275
  138. package/dinou/package.json +11 -34
  139. package/dinou/rollup/postcss.config.js +3 -4
  140. package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
  141. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
  142. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
  143. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
  144. package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
  145. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
  146. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
  147. package/dinou/rollup/rollup.config.js +174 -101
  148. package/dinou/scripts/build-vendors.js +123 -33
  149. package/dinou/server.d.ts +126 -15
  150. package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
  151. package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
  152. package/dinou/webpack/loaders/server-functions-loader.js +1 -1
  153. package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
  154. package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
  155. package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
  156. package/dinou/webpack/postcss.config.js +3 -4
  157. package/dinou/webpack/webpack.config.js +408 -132
  158. package/eject.js +6 -224
  159. package/package.json +7 -9
  160. package/dinou/compiled/cross-env/index.js +0 -661
  161. package/dinou/compiled/dotenv/index.js +0 -375
  162. package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
  163. package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
  164. package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
  165. package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
  166. package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
@@ -10,7 +10,8 @@ import {
10
10
  asyncRenderJSXToClientJSX,
11
11
  replaceLayoutChildrenPlaceholder,
12
12
  } from "./render-jsx-to-client-jsx.js";
13
- import { getLayoutProps } from "./layout-functions.js";
13
+ import { getLayoutProps, resolveLayoutChainPpr } from "./layout-functions.js";
14
+ import { resolveModulePpr } from "./resolve-module-ppr.js";
14
15
  import { DinouPageSlot as RawDinouPageSlot } from "./slot.js";
15
16
  import { getErrorJSX } from "./get-error-jsx.js";
16
17
  import {
@@ -25,8 +26,43 @@ import {
25
26
  import { getContext } from "./request-context.js";
26
27
  import { createRequire } from "node:module";
27
28
 
28
- const require = createRequire(import.meta.url);
29
- const currentDir = path.dirname(fileURLToPath(import.meta.url));
29
+ let require = null;
30
+ let currentDir = ".";
31
+ try {
32
+ require = createRequire(import.meta.url);
33
+ currentDir = path.dirname(fileURLToPath(import.meta.url));
34
+ } catch (e) {}
35
+
36
+ function createDinouPageSlotElement() {
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");
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
+ return React.createElement(DinouPageSlot);
65
+ }
30
66
 
31
67
  async function getJSX(
32
68
  reqPath,
@@ -44,36 +80,16 @@ async function getJSX(
44
80
  let jsx;
45
81
  let pageFunctionsProps;
46
82
 
83
+ const { layoutPprMap, defaultPpr } = await resolveLayoutChainPpr(
84
+ reqSegments,
85
+ query || {},
86
+ srcFolder,
87
+ { ignoreNoLayout: options?.segment === "layout" },
88
+ );
89
+
47
90
  // 1. Segmented handling for Layout: If only the layout is requested
48
91
  if (options && options.segment === "layout") {
49
- let DinouPageSlot = RawDinouPageSlot;
50
- if (
51
- typeof DinouPageSlot === "function" &&
52
- DinouPageSlot.$$typeof !== Symbol.for("react.client.reference")
53
- ) {
54
- const slotPath = path.resolve(currentDir, "slot.js");
55
- const fileUrl = pathToFileURL(slotPath).href;
56
- let regFn = null;
57
- try {
58
- const pkg = require("react-server-dom-webpack/server");
59
- regFn = pkg.registerClientReference;
60
- } catch (e) {}
61
- if (!regFn) {
62
- try {
63
- const pkg = require("@roggc/react-server-dom-esm/server.node.js");
64
- regFn = pkg.registerClientReference;
65
- } catch (e) {}
66
- }
67
- if (regFn) {
68
- DinouPageSlot = regFn(DinouPageSlot, fileUrl, "DinouPageSlot");
69
- } else {
70
- Object.defineProperties(DinouPageSlot, {
71
- $$typeof: { value: Symbol.for("react.client.reference") },
72
- $$id: { value: fileUrl + "#DinouPageSlot" },
73
- });
74
- }
75
- }
76
- jsx = React.createElement(DinouPageSlot);
92
+ jsx = createDinouPageSlotElement();
77
93
  } else {
78
94
  const hasRouterSyntax = reqSegments.some((seg) => {
79
95
  const isGroup = seg.startsWith("(") && seg.endsWith(")");
@@ -128,6 +144,7 @@ async function getJSX(
128
144
  null,
129
145
  `Page not found: no "page" file found for "${normalizedReqPath}"`,
130
146
  ),
147
+ Boolean(defaultPpr),
131
148
  );
132
149
  } else {
133
150
  const pageModule = await importModule(notFoundPath);
@@ -147,15 +164,27 @@ async function getJSX(
147
164
  undefined,
148
165
  reqSegments.length,
149
166
  );
167
+ let explicitNotFoundPpr = null;
150
168
  if (pageFunctionsPath) {
151
169
  const pageFunctionsModule = await importModule(pageFunctionsPath);
170
+ explicitNotFoundPpr = await resolveModulePpr(pageFunctionsModule);
152
171
  const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
153
172
  const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
154
173
  pageFunctionsProps = await getProps?.(dParams ?? {});
174
+ if (getContext()?._hasRedirected) {
175
+ return null;
176
+ }
155
177
  props = { ...props, ...(pageFunctionsProps ?? {}) };
156
178
  }
179
+ const notFoundEffectivePpr =
180
+ explicitNotFoundPpr !== null
181
+ ? explicitNotFoundPpr
182
+ : Boolean(defaultPpr);
157
183
 
158
- jsx = markPageRootElement(React.createElement(Page, props));
184
+ jsx = markPageRootElement(
185
+ React.createElement(Page, props),
186
+ notFoundEffectivePpr,
187
+ );
159
188
  const noLayoutNotFoundPath = path.join(
160
189
  notFoundDir,
161
190
  `no_layout_not_found`,
@@ -168,18 +197,18 @@ async function getJSX(
168
197
  !options?.skipLayoutProbe
169
198
  ) {
170
199
  jsx = await runInPageSegment(() => asyncRenderJSXToClientJSX(jsx));
200
+ const ctx = getContext();
201
+ if (ctx) {
202
+ ctx._resolvedPageClientJsx = jsx;
203
+ ctx._resolvedLayoutClientJsx = null;
204
+ ctx._hasResolvedSegments = true;
205
+ }
171
206
  }
172
207
  return jsx;
173
208
  }
174
209
  }
175
210
  } else {
176
211
  if (isNotFound) isNotFound.value = false;
177
- const pageModule = await importModule(pagePath);
178
- const Page = pageModule.default ?? pageModule;
179
-
180
- let props = {
181
- params: dynamicParams,
182
- };
183
212
 
184
213
  const pageFolder = path.dirname(pagePath);
185
214
  const [pageFunctionsPath] = getFilePathAndDynamicParams(
@@ -192,15 +221,67 @@ async function getJSX(
192
221
  undefined,
193
222
  reqSegments.length,
194
223
  );
224
+ let pageFunctionsModule = null;
225
+ let explicitPagePpr = null;
195
226
  if (pageFunctionsPath) {
196
- const pageFunctionsModule = await importModule(pageFunctionsPath);
197
- const defaultExport = pageFunctionsModule.default?.default ? pageFunctionsModule.default.default : pageFunctionsModule.default;
198
- const getProps = pageFunctionsModule.getProps || defaultExport?.getProps;
199
- pageFunctionsProps = await getProps?.(dynamicParams);
200
- props = { ...props, ...(pageFunctionsProps ?? {}) };
227
+ pageFunctionsModule = await importModule(pageFunctionsPath);
228
+ explicitPagePpr = await resolveModulePpr(pageFunctionsModule);
229
+ }
230
+ if (
231
+ explicitPagePpr === null &&
232
+ typeof globalThis !== "undefined" &&
233
+ globalThis.__DINOU_ROUTE_METADATA__
234
+ ) {
235
+ const normKey = (pageFunctionsPath || pagePath || "").replace(
236
+ /\\/g,
237
+ "/",
238
+ );
239
+ for (const [k, meta] of Object.entries(
240
+ globalThis.__DINOU_ROUTE_METADATA__,
241
+ )) {
242
+ if (
243
+ meta.ppr !== undefined &&
244
+ (normKey === k || normKey.endsWith("/" + k) || normKey.endsWith(k))
245
+ ) {
246
+ explicitPagePpr = Boolean(meta.ppr);
247
+ break;
248
+ }
249
+ }
201
250
  }
251
+ const pageEffectivePpr =
252
+ explicitPagePpr !== null ? explicitPagePpr : Boolean(defaultPpr);
202
253
 
203
- jsx = markPageRootElement(React.createElement(Page, props));
254
+ if (getContext()?._isPprRuntimeResume && !pageEffectivePpr) {
255
+ if (options && options.segment === "page") {
256
+ return null;
257
+ }
258
+ jsx = markPageRootElement(null, false);
259
+ } else {
260
+ const pageModule = await importModule(pagePath);
261
+ const Page = pageModule.default ?? pageModule;
262
+
263
+ let props = {
264
+ params: dynamicParams,
265
+ };
266
+
267
+ if (pageFunctionsModule) {
268
+ const defaultExport = pageFunctionsModule.default?.default
269
+ ? pageFunctionsModule.default.default
270
+ : pageFunctionsModule.default;
271
+ const getProps =
272
+ pageFunctionsModule.getProps || defaultExport?.getProps;
273
+ pageFunctionsProps = await getProps?.(dynamicParams);
274
+ if (getContext()?._hasRedirected) {
275
+ return null;
276
+ }
277
+ props = { ...props, ...(pageFunctionsProps ?? {}) };
278
+ }
279
+
280
+ jsx = markPageRootElement(
281
+ React.createElement(Page, props),
282
+ pageEffectivePpr,
283
+ );
284
+ }
204
285
  }
205
286
 
206
287
  if (
@@ -210,6 +291,13 @@ async function getJSX(
210
291
  !options?.skipLayoutProbe
211
292
  ) {
212
293
  jsx = await runInPageSegment(() => asyncRenderJSXToClientJSX(jsx));
294
+ const ctx = getContext();
295
+ if (ctx?._hasRedirected) {
296
+ return jsx;
297
+ }
298
+ if (ctx) {
299
+ ctx._resolvedPageClientJsx = jsx;
300
+ }
213
301
  }
214
302
 
215
303
  // 2. Segmented handling for Page: If only the page is requested, return without layouts
@@ -228,6 +316,11 @@ async function getJSX(
228
316
  false,
229
317
  )[0]
230
318
  ) {
319
+ const ctx = getContext();
320
+ if (ctx && !options?.segment) {
321
+ ctx._resolvedLayoutClientJsx = null;
322
+ ctx._hasResolvedSegments = true;
323
+ }
231
324
  return jsx;
232
325
  }
233
326
 
@@ -247,8 +340,9 @@ async function getJSX(
247
340
  if (layouts && Array.isArray(layouts)) {
248
341
  let index = 0;
249
342
  const layoutSegmentStore = { active: true, idCount: 0, holeCount: 0 };
343
+ let layoutOnlyJsx = !options?.segment && layouts.length > 0 ? createDinouPageSlotElement() : null;
344
+ let layoutRenderFailed = false;
250
345
  for (const [layoutPath, dParams, slots] of layouts.reverse()) {
251
- const layoutModule = await importModule(layoutPath);
252
346
  const layoutFolderPath = path.dirname(layoutPath);
253
347
  const resetLayoutPath = getFilePathAndDynamicParams(
254
348
  [],
@@ -257,12 +351,26 @@ async function getJSX(
257
351
  "reset_layout",
258
352
  false,
259
353
  )[0];
354
+ const normLayoutPath = layoutPath.replace(/\\/g, "/");
355
+ const layoutEffectivePpr = layoutPprMap.has(normLayoutPath)
356
+ ? Boolean(layoutPprMap.get(normLayoutPath))
357
+ : Boolean(defaultPpr);
358
+
359
+ if (getContext()?._isPprRuntimeResume && !layoutEffectivePpr) {
360
+ if (resetLayoutPath) {
361
+ break;
362
+ }
363
+ index++;
364
+ continue;
365
+ }
366
+
367
+ const layoutModule = await importModule(layoutPath);
260
368
  const Layout = layoutModule.default ?? layoutModule;
261
369
  const updatedSlots = {};
262
370
  for (const [slotName, slotValue] of Object.entries(slots)) {
263
371
  let updatedSlotElement;
264
372
  const slotFilePath = slotValue?.slotPath || slotValue?.props?.__modulePath;
265
- const slotParams = slotValue?.slotParams || slotValue?.props?.params || {};
373
+ const slotParams = slotValue?.slotParams || slotValue?.props?.params || dParams || {};
266
374
  const prevSlotIdCount = layoutSegmentStore.idCount;
267
375
  const prevSlotHoleCount = layoutSegmentStore.holeCount;
268
376
  try {
@@ -278,11 +386,18 @@ async function getJSX(
278
386
  } else {
279
387
  elementToRender = slotValue;
280
388
  }
281
- const resolvedSlot = await runInLayoutSegment(
389
+ elementToRender = markLayoutRootElement(
390
+ elementToRender,
391
+ layoutEffectivePpr,
392
+ );
393
+ const resolvedSlot = options?.skipLayoutProbe ? elementToRender : await runInLayoutSegment(
282
394
  () => asyncRenderJSXToClientJSX(elementToRender),
283
395
  layoutSegmentStore
284
396
  );
285
- updatedSlotElement = isPprBuildActive() ? elementToRender : resolvedSlot;
397
+ updatedSlotElement =
398
+ isPprBuildActive() || Boolean(getPprStore())
399
+ ? elementToRender
400
+ : resolvedSlot;
286
401
  } catch (e) {
287
402
  layoutSegmentStore.idCount = prevSlotIdCount;
288
403
  layoutSegmentStore.holeCount = prevSlotHoleCount;
@@ -299,6 +414,7 @@ async function getJSX(
299
414
  true, // finalDestination
300
415
  undefined, // lastFound
301
416
  reqSegments.length,
417
+ slotParams,
302
418
  );
303
419
 
304
420
  if (slotErrorPath) {
@@ -331,17 +447,39 @@ async function getJSX(
331
447
  } finally {
332
448
  updatedSlots[slotName] = updatedSlotElement;
333
449
  }
450
+ if (getContext()?._hasRedirected) {
451
+ return null;
452
+ }
334
453
  }
335
454
  const layoutProps = await getLayoutProps(layoutPath, dParams);
455
+ if (getContext()?._hasRedirected) {
456
+ return null;
457
+ }
336
458
  let props = { params: dParams, ...updatedSlots, ...(layoutProps ?? {}) };
337
459
  if (options?.skipLayoutProbe) {
338
- jsx = markLayoutRootElement(React.createElement(Layout, props, jsx));
339
- } else if (isPprBuildActive()) {
460
+ jsx = markLayoutRootElement(
461
+ React.createElement(Layout, props, jsx),
462
+ layoutEffectivePpr,
463
+ );
464
+ layoutOnlyJsx = null;
465
+ } else if (isPprBuildActive() || Boolean(getPprStore())) {
340
466
  try {
341
- const testElement = React.createElement(Layout, props, null);
467
+ const testElement = markLayoutRootElement(
468
+ React.createElement(Layout, props, null),
469
+ layoutEffectivePpr,
470
+ );
342
471
  await runInLayoutSegment(() => asyncRenderJSXToClientJSX(testElement));
343
- jsx = markLayoutRootElement(React.createElement(Layout, props, jsx));
472
+ if (getContext()?._hasRedirected) {
473
+ return null;
474
+ }
475
+ jsx = markLayoutRootElement(
476
+ React.createElement(Layout, props, jsx),
477
+ layoutEffectivePpr,
478
+ );
479
+ layoutOnlyJsx = null;
344
480
  } catch (layoutErr) {
481
+ layoutRenderFailed = true;
482
+ layoutOnlyJsx = null;
345
483
  console.warn(
346
484
  `[Dinou] Layout ${layoutPath} failed during render, isolating layout error:`,
347
485
  layoutErr?.message || layoutErr
@@ -364,13 +502,24 @@ async function getJSX(
364
502
  const prevLayoutHoleCount = layoutSegmentStore.holeCount;
365
503
  try {
366
504
  const placeholder = createLayoutChildrenPlaceholder();
367
- const testElement = React.createElement(Layout, props, placeholder);
505
+ const testElement = markLayoutRootElement(
506
+ React.createElement(Layout, props, placeholder),
507
+ layoutEffectivePpr,
508
+ );
368
509
  const resolvedLayout = await runInLayoutSegment(
369
510
  () => asyncRenderJSXToClientJSX(testElement),
370
511
  layoutSegmentStore
371
512
  );
513
+ if (getContext()?._hasRedirected) {
514
+ return null;
515
+ }
372
516
  jsx = replaceLayoutChildrenPlaceholder(resolvedLayout, jsx, placeholder);
517
+ if (layoutOnlyJsx && !layoutRenderFailed) {
518
+ layoutOnlyJsx = replaceLayoutChildrenPlaceholder(resolvedLayout, layoutOnlyJsx, placeholder);
519
+ }
373
520
  } catch (layoutErr) {
521
+ layoutRenderFailed = true;
522
+ layoutOnlyJsx = null;
374
523
  layoutSegmentStore.idCount = prevLayoutIdCount;
375
524
  layoutSegmentStore.holeCount = prevLayoutHoleCount;
376
525
  console.warn(
@@ -396,6 +545,24 @@ async function getJSX(
396
545
  }
397
546
  index++;
398
547
  }
548
+ if (!options?.segment) {
549
+ const ctx = getContext();
550
+ if (ctx) {
551
+ if (!layoutRenderFailed) {
552
+ ctx._resolvedLayoutClientJsx = layouts.length > 0 ? layoutOnlyJsx : null;
553
+ ctx._hasResolvedSegments = Boolean(layouts.length === 0 || layoutOnlyJsx);
554
+ } else {
555
+ ctx._resolvedLayoutClientJsx = null;
556
+ ctx._hasResolvedSegments = false;
557
+ }
558
+ }
559
+ }
560
+ } else if (!options?.segment) {
561
+ const ctx = getContext();
562
+ if (ctx) {
563
+ ctx._resolvedLayoutClientJsx = null;
564
+ ctx._hasResolvedSegments = true;
565
+ }
399
566
  }
400
567
 
401
568
  return jsx;