@farm.js/core 0.1.82 → 0.1.83

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 (238) hide show
  1. package/dist/{agent-mcp.d-C2Su3x4D.d.ts → agent-mcp.d-7uKdOttc.d.ts} +1 -1
  2. package/dist/{agent-mcp.d-Yak-LqRd.d.mts → agent-mcp.d-LChlR2au.d.mts} +1 -1
  3. package/dist/agent-runtime.d.mts +2 -1
  4. package/dist/agent-runtime.d.ts +2 -1
  5. package/dist/analyzer-WGH6J2HN.cjs +17 -0
  6. package/dist/{analyzer-RPU2KG4J.mjs → analyzer-Y6IY26HI.mjs} +2 -2
  7. package/dist/api/node.d.mts +4 -3
  8. package/dist/api/node.d.ts +4 -3
  9. package/dist/api/route-manager.d.mts +4 -3
  10. package/dist/api/route-manager.d.ts +4 -3
  11. package/dist/api/runtime.d.mts +3 -2
  12. package/dist/api/runtime.d.ts +3 -2
  13. package/dist/api.d.mts +5 -4
  14. package/dist/api.d.ts +5 -4
  15. package/dist/{app-manifest.d-DZyXaICz.d.ts → app-manifest.d-CRp21oAz.d.ts} +1 -1
  16. package/dist/{app-manifest.d-BcyOFMrg.d.mts → app-manifest.d-QMdmqqCr.d.mts} +1 -1
  17. package/dist/app-markdown.d.mts +3 -2
  18. package/dist/app-markdown.d.ts +3 -2
  19. package/dist/{app.d-CIoXsAbN.d.ts → app.d-CVPu_hoD.d.ts} +34 -4
  20. package/dist/{app.d-C0ePpuaG.d.mts → app.d-eSm7jgoc.d.mts} +34 -4
  21. package/dist/{chunk-JK26IMT7.cjs → chunk-3CZ4MJHW.cjs} +1 -1
  22. package/dist/{chunk-5MUFW5UU.cjs → chunk-3DAJXBSL.cjs} +2 -2
  23. package/dist/{chunk-XMHERKSE.mjs → chunk-42IBGQTN.mjs} +5 -12
  24. package/dist/{chunk-4X7LSGM6.mjs → chunk-43N3X6OO.mjs} +1 -1
  25. package/dist/{chunk-LM2ZDNDD.cjs → chunk-55UJGUBP.cjs} +24 -19
  26. package/dist/{chunk-TPA2PV5J.mjs → chunk-5V6HSJFG.mjs} +24 -1
  27. package/dist/chunk-5X5GJU5A.cjs +426 -0
  28. package/dist/{chunk-Q2VOT3K2.cjs → chunk-7X2CYE66.cjs} +316 -310
  29. package/dist/{chunk-6BPFIYGY.cjs → chunk-A5BHJHDF.cjs} +3 -3
  30. package/dist/{chunk-EL2Z6YFZ.mjs → chunk-B5SJYXJK.mjs} +177 -67
  31. package/dist/chunk-BUQR7KKO.mjs +17 -0
  32. package/dist/{chunk-724WT3NI.mjs → chunk-CRE642TW.mjs} +1 -1
  33. package/dist/{chunk-NRCKBDYP.mjs → chunk-DPUZVGXH.mjs} +130 -27
  34. package/dist/{chunk-N2EFMN2K.cjs → chunk-DZTWUEBB.cjs} +2 -2
  35. package/dist/{chunk-DRO3NXA3.cjs → chunk-EFI6QWBQ.cjs} +200 -90
  36. package/dist/chunk-ELNRKD4V.mjs +426 -0
  37. package/dist/{chunk-63ZE6B6M.mjs → chunk-FFWSER54.mjs} +1 -1
  38. package/dist/chunk-FZ7OUN5M.cjs +30 -0
  39. package/dist/{chunk-5MMKNW7Q.cjs → chunk-H7REG7OX.cjs} +15 -8
  40. package/dist/{chunk-VMBIKDKW.cjs → chunk-HRH7OKBQ.cjs} +6 -4
  41. package/dist/{chunk-RMPUEH5T.cjs → chunk-IABI62FH.cjs} +2 -2
  42. package/dist/{chunk-ZIZRIZLP.mjs → chunk-IAIRQAHA.mjs} +3 -1
  43. package/dist/{chunk-EX6ZSN5P.cjs → chunk-IZYFP7IN.cjs} +17 -24
  44. package/dist/chunk-J6RFB324.cjs +17 -0
  45. package/dist/{chunk-ARORZ3MH.cjs → chunk-JHRJ5V2F.cjs} +366 -263
  46. package/dist/{chunk-OMB7UGVW.mjs → chunk-K3GHY7GY.mjs} +14 -9
  47. package/dist/{chunk-UVV3I5QA.cjs → chunk-L2GUEYHR.cjs} +29 -6
  48. package/dist/{chunk-HHQEKLZL.cjs → chunk-LN6FAYNB.cjs} +36 -31
  49. package/dist/chunk-M6AJZ4XR.mjs +30 -0
  50. package/dist/{chunk-47I2MYIR.mjs → chunk-NDWI6FDH.mjs} +442 -180
  51. package/dist/{chunk-BCTHOQPP.cjs → chunk-NGTZHWBG.cjs} +68 -1
  52. package/dist/{chunk-OP5VI4TP.mjs → chunk-NKVBWPXR.mjs} +1 -1
  53. package/dist/{chunk-CD5Z7RR5.cjs → chunk-OM6JIIJU.cjs} +4 -4
  54. package/dist/{chunk-C3VCYOU4.mjs → chunk-ORBBAA7B.mjs} +1 -1
  55. package/dist/{chunk-I4DR3HCH.mjs → chunk-R3VLM2MW.mjs} +1 -1
  56. package/dist/{chunk-I4WZRG73.mjs → chunk-RB5IGN3N.mjs} +13 -6
  57. package/dist/{chunk-RMLR5RMH.mjs → chunk-RGTZAM6Y.mjs} +67 -0
  58. package/dist/{chunk-GXLNARPO.mjs → chunk-RNJX3MD6.mjs} +1 -1
  59. package/dist/{chunk-EJCVG25Z.mjs → chunk-S3R4JDRO.mjs} +17 -9
  60. package/dist/{chunk-AIPZDBP6.cjs → chunk-SLIXHUMS.cjs} +780 -518
  61. package/dist/{chunk-WFVSAT7Y.cjs → chunk-T7HGXF7D.cjs} +3 -3
  62. package/dist/{chunk-CJDBTTLB.mjs → chunk-U56Z3755.mjs} +10 -5
  63. package/dist/{chunk-QSMUMK7Y.mjs → chunk-VQ6IXALL.mjs} +2 -2
  64. package/dist/{chunk-B2PGVHBG.cjs → chunk-WCSBYQOT.cjs} +4 -4
  65. package/dist/{chunk-DAXU2NBE.mjs → chunk-WZV2G2A6.mjs} +30 -24
  66. package/dist/{chunk-SM2SYWAR.cjs → chunk-XJDB564A.cjs} +18 -10
  67. package/dist/{cli-runtime.d-Hnvvadz7.d.mts → cli-runtime.d-C7aMfoTq.d.mts} +8 -6
  68. package/dist/{cli-runtime.d-I0MphTbc.d.ts → cli-runtime.d-DaElKjaL.d.ts} +8 -6
  69. package/dist/{client-component.d-DapRqtSC.d.mts → client-component.d-DLMCzmUx.d.mts} +1 -1
  70. package/dist/{client-component.d-5QEvtJsg.d.ts → client-component.d-DLknFP8l.d.ts} +1 -1
  71. package/dist/{client-plugins.d-DcmDzcSC.d.ts → client-plugins.d-BVXjyIkY.d.ts} +14 -0
  72. package/dist/{client-plugins.d-C1WM3ieD.d.mts → client-plugins.d-BwKwuO_0.d.mts} +14 -0
  73. package/dist/client-plugins.d.mts +2 -1
  74. package/dist/client-plugins.d.ts +2 -1
  75. package/dist/client.cjs +4 -3
  76. package/dist/client.d.mts +10 -9
  77. package/dist/client.d.ts +10 -9
  78. package/dist/client.mjs +3 -2
  79. package/dist/config.d.mts +2 -1
  80. package/dist/config.d.ts +2 -1
  81. package/dist/desktop.d.mts +3 -2
  82. package/dist/desktop.d.ts +3 -2
  83. package/dist/{devtools-C5GXZZ7E.mjs → devtools-OI52TCSD.mjs} +3 -3
  84. package/dist/{devtools-5B7NZE6F.cjs → devtools-ZM2AR36W.cjs} +5 -5
  85. package/dist/docs.cjs +8 -7
  86. package/dist/docs.d.mts +15 -6
  87. package/dist/docs.d.ts +15 -6
  88. package/dist/docs.mjs +7 -6
  89. package/dist/environment/vite.cjs +4 -4
  90. package/dist/environment/vite.d.mts +1 -0
  91. package/dist/environment/vite.d.ts +1 -0
  92. package/dist/environment/vite.mjs +3 -3
  93. package/dist/{generate-route-types.d-CaGMIaNI.d.mts → generate-route-types.d-BFOMM8Ef.d.mts} +3 -0
  94. package/dist/{generate-route-types.d-B76M5R11.d.ts → generate-route-types.d-C2m8myHb.d.ts} +3 -0
  95. package/dist/{handler.d-B8bPCBzl.d.mts → handler.d-BKTWzzNA.d.mts} +1 -1
  96. package/dist/{handler.d-Cliwo6Nu.d.ts → handler.d-Dzpyg3-N.d.ts} +1 -1
  97. package/dist/{headers.d-CVwSpSGX.d.mts → headers.d-5opjyhXw.d.mts} +1 -1
  98. package/dist/{headers.d-C_btqjV6.d.ts → headers.d-PZyXcDAH.d.ts} +1 -1
  99. package/dist/index.cjs +25 -23
  100. package/dist/{index.d-DFuMZk9-.d.mts → index.d-C0Mie66f.d.mts} +1 -1
  101. package/dist/{index.d-hOEbMcLk.d.ts → index.d-DV2q-0mE.d.ts} +1 -1
  102. package/dist/index.d.mts +26 -25
  103. package/dist/index.d.ts +26 -25
  104. package/dist/index.mjs +25 -23
  105. package/dist/integrations/orm.d.mts +2 -1
  106. package/dist/integrations/orm.d.ts +2 -1
  107. package/dist/integrations.d.mts +2 -1
  108. package/dist/integrations.d.ts +2 -1
  109. package/dist/internal/app-markdown-runtime.d.mts +3 -2
  110. package/dist/internal/app-markdown-runtime.d.ts +3 -2
  111. package/dist/internal/build-runtime.cjs +21 -21
  112. package/dist/internal/build-runtime.d.mts +5 -4
  113. package/dist/internal/build-runtime.d.ts +5 -4
  114. package/dist/internal/build-runtime.mjs +20 -20
  115. package/dist/internal/cli-runtime.cjs +6 -6
  116. package/dist/internal/cli-runtime.d.mts +8 -7
  117. package/dist/internal/cli-runtime.d.ts +8 -7
  118. package/dist/internal/cli-runtime.mjs +5 -5
  119. package/dist/internal/client-error-overlay.cjs +4 -4
  120. package/dist/internal/client-error-overlay.mjs +1 -1
  121. package/dist/internal/client-runtime.d.mts +5 -5
  122. package/dist/internal/client-runtime.d.ts +5 -5
  123. package/dist/internal/compression-runtime.d.mts +2 -1
  124. package/dist/internal/compression-runtime.d.ts +2 -1
  125. package/dist/internal/config-runtime.cjs +5 -5
  126. package/dist/internal/config-runtime.d.mts +6 -5
  127. package/dist/internal/config-runtime.d.ts +6 -5
  128. package/dist/internal/config-runtime.mjs +4 -4
  129. package/dist/internal/infra-analytics-runtime.cjs +6 -6
  130. package/dist/internal/infra-analytics-runtime.mjs +4 -4
  131. package/dist/internal/islands-action-client.cjs +18 -0
  132. package/dist/internal/islands-action-client.d.mts +18 -0
  133. package/dist/internal/islands-action-client.d.ts +18 -0
  134. package/dist/internal/islands-action-client.mjs +18 -0
  135. package/dist/internal/islands-runtime.cjs +3 -8
  136. package/dist/internal/islands-runtime.mjs +4 -9
  137. package/dist/internal/islx-actions-client.cjs +4 -3
  138. package/dist/internal/islx-actions-client.mjs +3 -2
  139. package/dist/internal/islx-actions-server.d.mts +0 -2
  140. package/dist/internal/islx-actions-server.d.ts +0 -2
  141. package/dist/internal/islx-client.cjs +13 -1
  142. package/dist/internal/islx-client.d.mts +11 -0
  143. package/dist/internal/islx-client.d.ts +11 -0
  144. package/dist/internal/islx-client.mjs +14 -0
  145. package/dist/internal/metadata-image-runtime.d.mts +1 -0
  146. package/dist/internal/metadata-image-runtime.d.ts +1 -0
  147. package/dist/internal/native-server-fns.cjs +4 -4
  148. package/dist/internal/native-server-fns.mjs +3 -3
  149. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  150. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  151. package/dist/internal/production-runtime.cjs +5 -5
  152. package/dist/internal/production-runtime.d.mts +11 -11
  153. package/dist/internal/production-runtime.d.ts +11 -11
  154. package/dist/internal/production-runtime.mjs +4 -4
  155. package/dist/internal/spa-router.d.mts +3 -3
  156. package/dist/internal/spa-router.d.ts +3 -3
  157. package/dist/internal/start-manifest.d.mts +2 -1
  158. package/dist/internal/start-manifest.d.ts +2 -1
  159. package/dist/markdown.d.mts +2 -1
  160. package/dist/markdown.d.ts +2 -1
  161. package/dist/middleware.d.mts +2 -1
  162. package/dist/middleware.d.ts +2 -1
  163. package/dist/mobile.d.mts +6 -3
  164. package/dist/mobile.d.ts +6 -3
  165. package/dist/{mount.d-DLeYxeRR.d.mts → mount.d-CZ_qL1iS.d.mts} +1 -1
  166. package/dist/{mount.d-CAovYKfs.d.ts → mount.d-gWul1GA1.d.ts} +1 -1
  167. package/dist/{navigation-delegate.d-Chv93QS6.d.mts → navigation-delegate.d-BBTzhJLj.d.mts} +1 -1
  168. package/dist/{navigation-delegate.d-BLM-8Q3Z.d.ts → navigation-delegate.d-BZsYEAet.d.ts} +1 -1
  169. package/dist/navigation.d.mts +5 -5
  170. package/dist/navigation.d.ts +5 -5
  171. package/dist/plugin.cjs +15 -15
  172. package/dist/plugin.d.mts +6 -6
  173. package/dist/plugin.d.ts +6 -6
  174. package/dist/plugin.mjs +14 -14
  175. package/dist/{render-plan.d-BSTjTH8h.d.ts → render-plan.d-AaJsYPX-.d.ts} +1 -1
  176. package/dist/{render-plan.d-CK5Lggyb.d.mts → render-plan.d-bnWxS12w.d.mts} +1 -1
  177. package/dist/renderer-client.cjs +6 -5
  178. package/dist/renderer-client.d.mts +8 -7
  179. package/dist/renderer-client.d.ts +8 -7
  180. package/dist/renderer-client.mjs +2 -1
  181. package/dist/renderer.cjs +6 -2
  182. package/dist/renderer.d.mts +87 -4
  183. package/dist/renderer.d.ts +87 -4
  184. package/dist/renderer.mjs +5 -1
  185. package/dist/{request.d-BhggxQf3.d.mts → request.d-C2HOn3Hi.d.mts} +1 -1
  186. package/dist/{request.d-CyJS9bjm.d.ts → request.d-CAeitOG1.d.ts} +1 -1
  187. package/dist/request.d.mts +3 -2
  188. package/dist/request.d.ts +3 -2
  189. package/dist/{route-rendering.d-BLPPmI5I.d.ts → route-rendering.d-A1dIkUK5.d.ts} +1 -1
  190. package/dist/{route-rendering.d-CUpG2mZJ.d.mts → route-rendering.d-CYA-ulnX.d.mts} +1 -1
  191. package/dist/{router.d-2NQM1Kgw.d.mts → router.d-8lxnzlkr.d.mts} +1 -1
  192. package/dist/{router.d-0X2Ki6rf.d.ts → router.d-A_Yt6jYz.d.ts} +1 -1
  193. package/dist/{routes.d-CCccJRrp.d.mts → routes.d-BWvpUoYu.d.mts} +1 -1
  194. package/dist/{routes.d-b7khoRoU.d.ts → routes.d-D7RWvfqL.d.ts} +1 -1
  195. package/dist/routes.d.mts +2 -1
  196. package/dist/routes.d.ts +2 -1
  197. package/dist/{rsc-pipeline-5AOF64FL.cjs → rsc-pipeline-MFJZGDPE.cjs} +5 -5
  198. package/dist/{rsc-pipeline-DNRLYOJ7.mjs → rsc-pipeline-TRZVFCBX.mjs} +4 -4
  199. package/dist/{runtime-ZVHG5SRB.cjs → runtime-MJUG2HGR.cjs} +10 -9
  200. package/dist/{runtime-EHG2FRXZ.mjs → runtime-O4Y3Z6V3.mjs} +6 -5
  201. package/dist/{runtime.d-CXuwkUgr.d.ts → runtime.d-BPyvWrgQ.d.ts} +1 -1
  202. package/dist/{runtime.d-CaFXcu_Q.d.mts → runtime.d-C_rZ9_DD.d.mts} +1 -1
  203. package/dist/{server-components-status.d-Cp7zvBm5.d.mts → server-components-status.d-BpxiEMQE.d.mts} +1 -1
  204. package/dist/{server-components-status.d-BdeFD8ZH.d.ts → server-components-status.d-C2UEKJn7.d.ts} +1 -1
  205. package/dist/server-plugins.d.mts +4 -3
  206. package/dist/server-plugins.d.ts +4 -3
  207. package/dist/server-query-call.d-rVM_lsYk.d.mts +15 -0
  208. package/dist/server-query-call.d-rVM_lsYk.d.ts +15 -0
  209. package/dist/server-query-client.cjs +5 -3
  210. package/dist/server-query-client.d.mts +3 -2
  211. package/dist/server-query-client.d.ts +3 -2
  212. package/dist/server-query-client.mjs +5 -3
  213. package/dist/{server-query-runtime.d-DXRNhX_3.d.ts → server-query-runtime.d-BlHd90D0.d.ts} +2 -8
  214. package/dist/{server-query-runtime.d-aP52iuL5.d.mts → server-query-runtime.d-CCLGkQtE.d.mts} +2 -8
  215. package/dist/server.cjs +39 -39
  216. package/dist/server.d.mts +12 -12
  217. package/dist/server.d.ts +12 -12
  218. package/dist/server.mjs +16 -16
  219. package/dist/{spa-router.d-l3G38xHa.d.mts → spa-router.d-BD-6WX1R.d.mts} +2 -2
  220. package/dist/{spa-router.d-Bjgl-Osi.d.ts → spa-router.d-Cw5i_15e.d.ts} +2 -2
  221. package/dist/{ssg.d-DDca17Lc.d.ts → ssg.d-Bifiq0EL.d.ts} +2 -2
  222. package/dist/{ssg.d-RnlHOqUL.d.mts → ssg.d-CCE9aob5.d.mts} +2 -2
  223. package/dist/{store-core.d-BaOUOPf7.d.ts → store-core.d-5tVn5vi1.d.ts} +3 -3
  224. package/dist/{store-core.d-BZjuC6Zc.d.mts → store-core.d-BN2MxSG9.d.mts} +3 -3
  225. package/dist/testing.d.mts +2 -1
  226. package/dist/testing.d.ts +2 -1
  227. package/dist/{utils.d-D8TWmpWo.d.ts → utils.d-BUjpSNIO.d.ts} +1 -1
  228. package/dist/{utils.d-tdzw0_zQ.d.mts → utils.d-wGPLeVbq.d.mts} +1 -1
  229. package/dist/version.cjs +2 -2
  230. package/dist/version.mjs +1 -1
  231. package/dist/vite.cjs +15 -15
  232. package/dist/vite.d.mts +6 -6
  233. package/dist/vite.d.ts +6 -6
  234. package/dist/vite.mjs +14 -14
  235. package/package.json +6 -1
  236. package/dist/analyzer-LV23T6QN.cjs +0 -17
  237. package/dist/chunk-AUFEM3FB.mjs +0 -229
  238. package/dist/chunk-S7WZUK3B.cjs +0 -229
@@ -7,9 +7,6 @@ import {
7
7
  hasFarmMobileClientEntry,
8
8
  removeFarmMobileClientManifest
9
9
  } from "./chunk-TM2E623I.mjs";
10
- import {
11
- loadFarmProductionVite
12
- } from "./chunk-PSUYE5HR.mjs";
13
10
  import {
14
11
  FARM_COMPILE_CACHE_DIR,
15
12
  FARM_DESKTOP_ENV_MODULE_FILE,
@@ -23,6 +20,9 @@ import {
23
20
  createReactProductionModePlugin,
24
21
  withProductionNodeEnv
25
22
  } from "./chunk-ZZGQD3LL.mjs";
23
+ import {
24
+ loadFarmProductionVite
25
+ } from "./chunk-PSUYE5HR.mjs";
26
26
  import {
27
27
  generateNativeMCPPluginSource
28
28
  } from "./chunk-KQH2COEJ.mjs";
@@ -32,16 +32,15 @@ import {
32
32
  import {
33
33
  collectFarmNativeServerFns,
34
34
  findFarmNativeScreenFiles
35
- } from "./chunk-C3VCYOU4.mjs";
35
+ } from "./chunk-ORBBAA7B.mjs";
36
36
  import {
37
37
  assertFarmDocsAdapterServesNoGuardedPages,
38
38
  compileFarmDocsAdapterEdgeManifest,
39
39
  createFarmDocsAPIHandler,
40
40
  farmDocsAdapterServesGuardedPages,
41
- hasFarmDocsRuntimeAdapter,
42
41
  listFarmDocsAdapterPages,
43
42
  listFarmDocsPagePaths
44
- } from "./chunk-OMB7UGVW.mjs";
43
+ } from "./chunk-K3GHY7GY.mjs";
45
44
  import {
46
45
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
47
46
  createFarmDocsHandler,
@@ -71,7 +70,7 @@ import {
71
70
  getDeployTargetForPreset,
72
71
  hasCustomFarmRouteContext,
73
72
  resolveDeployOutputPath
74
- } from "./chunk-CJDBTTLB.mjs";
73
+ } from "./chunk-U56Z3755.mjs";
75
74
  import {
76
75
  resolveFarmInstrumentationFile
77
76
  } from "./chunk-QRNYSISP.mjs";
@@ -116,7 +115,7 @@ import {
116
115
  resolveFarmNotFoundComponentPath,
117
116
  resolveFarmRouteRootStrategy,
118
117
  toBakedMarkdownSourcePath
119
- } from "./chunk-NRCKBDYP.mjs";
118
+ } from "./chunk-DPUZVGXH.mjs";
120
119
  import {
121
120
  TAILWIND_CSS_BROWSER_TARGET,
122
121
  generateFarmClientPluginEntryCode,
@@ -132,7 +131,7 @@ import {
132
131
  readRouteRenderingDirectiveFromFile,
133
132
  resolveRouteRenderingConfig,
134
133
  resolveRouteRenderingConfigFromFile
135
- } from "./chunk-ZIZRIZLP.mjs";
134
+ } from "./chunk-IAIRQAHA.mjs";
136
135
  import {
137
136
  HOISTED_HEAD_ELEMENT,
138
137
  appMiddlewareMayHandlePath,
@@ -155,7 +154,7 @@ import {
155
154
  import {
156
155
  FARM_PRERENDER_ENV,
157
156
  _farmWebMCPReportsEnabled
158
- } from "./chunk-GXLNARPO.mjs";
157
+ } from "./chunk-RNJX3MD6.mjs";
159
158
  import {
160
159
  FARM_API_CATALOG_PATH,
161
160
  FARM_APP_MANIFEST_LEGACY_PATH,
@@ -163,7 +162,7 @@ import {
163
162
  listFarmBuiltInRoutePaths,
164
163
  resolveFarmApiCatalogInput,
165
164
  resolveFarmAppManifestInput
166
- } from "./chunk-QSMUMK7Y.mjs";
165
+ } from "./chunk-VQ6IXALL.mjs";
167
166
  import {
168
167
  FARM_DEFAULT_MCP_PATH,
169
168
  createFarmDefaultMCPServer,
@@ -171,7 +170,7 @@ import {
171
170
  } from "./chunk-HR4N2K4V.mjs";
172
171
  import {
173
172
  isFarmPreviewDeploymentEnvironment
174
- } from "./chunk-4X7LSGM6.mjs";
173
+ } from "./chunk-43N3X6OO.mjs";
175
174
  import {
176
175
  FARM_NATIVE_SERVER_FN_PLUGIN
177
176
  } from "./chunk-L4RTTTVE.mjs";
@@ -192,15 +191,20 @@ import {
192
191
  withFarmSourceSnapshot,
193
192
  withFarmSourceSnapshotOf,
194
193
  withPackageClientBoundaryCache
195
- } from "./chunk-EL2Z6YFZ.mjs";
194
+ } from "./chunk-B5SJYXJK.mjs";
196
195
  import {
197
196
  generateFarmDocsAdapterClientRuntime,
198
197
  getFarmDocsAdapterConfigModule
199
- } from "./chunk-EJCVG25Z.mjs";
198
+ } from "./chunk-S3R4JDRO.mjs";
200
199
  import {
201
200
  resolveFarmDocsFontAssets,
202
201
  toFarmDocsPublicFontAssets
203
202
  } from "./chunk-NRNAHZ57.mjs";
203
+ import {
204
+ getFarmDocsAdapterRenderer,
205
+ getFarmDocsAdapterUIModule,
206
+ hasFarmDocsRuntimeAdapter
207
+ } from "./chunk-5V6HSJFG.mjs";
204
208
  import {
205
209
  nitroRouteRulesBelowBasePath,
206
210
  routeRulesToNitroRouteRules
@@ -224,7 +228,7 @@ import {
224
228
  isReactRenderer,
225
229
  loadFarmRendererVitePlugins,
226
230
  resolveFarmRendererAppSetup
227
- } from "./chunk-RMLR5RMH.mjs";
231
+ } from "./chunk-RGTZAM6Y.mjs";
228
232
  import {
229
233
  applyFarmCronVercelCrons,
230
234
  createFarmCronCloudflareConfig,
@@ -303,7 +307,7 @@ import {
303
307
  } from "./chunk-2I6PUKWJ.mjs";
304
308
  import {
305
309
  FARM_VERSION
306
- } from "./chunk-OP5VI4TP.mjs";
310
+ } from "./chunk-NKVBWPXR.mjs";
307
311
  import {
308
312
  FARM_VIDEO_PLAYER_PATH
309
313
  } from "./chunk-AG27TI6Q.mjs";
@@ -504,6 +508,7 @@ import path2 from "path";
504
508
  var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
505
509
  var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
506
510
  var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
511
+ var FARM_CLIENT_STYLESHEET_PLACEHOLDER = "__farm_client_stylesheet__";
507
512
  async function hashAndCopy(sourcePath, destinationDir, hashedName) {
508
513
  const fs5 = await import("fs/promises");
509
514
  try {
@@ -527,6 +532,15 @@ async function resolveHashedClientCssHref(clientOutputDir) {
527
532
  );
528
533
  return name ? `/assets/${name}` : "/farm-client.css";
529
534
  }
535
+ async function resolveClientStylesheetLinkHref(clientOutputDir, clientCssHref) {
536
+ const fs5 = await import("fs/promises");
537
+ try {
538
+ const stylesheet = await fs5.stat(path2.join(clientOutputDir, "farm-client.css"));
539
+ return stylesheet.size > 0 ? clientCssHref : null;
540
+ } catch {
541
+ return null;
542
+ }
543
+ }
530
544
  async function findFingerprintedClientEntry(clientOutputDir) {
531
545
  const fs5 = await import("fs/promises");
532
546
  try {
@@ -798,13 +812,15 @@ function collectFarmClientModulePreloads(bundle, options) {
798
812
  ...staticImports(chunk, loaded, [])
799
813
  ].map(index);
800
814
  }
801
- const dynamicFiles = (moduleIds) => {
815
+ const dynamicFiles = (moduleIds, before = []) => {
802
816
  const into = [];
803
- const loaded = new Set(entryLoaded);
817
+ const loaded = /* @__PURE__ */ new Set([...entryLoaded, ...before]);
804
818
  for (const moduleId of moduleIds ?? []) {
819
+ const is = (id) => path4.resolve(id.split("?")[0]) === path4.resolve(moduleId);
805
820
  const chunk = chunks.find(
806
- (candidate) => candidate.isDynamicEntry && candidate.facadeModuleId && path4.resolve(candidate.facadeModuleId.split("?")[0]) === path4.resolve(moduleId)
807
- );
821
+ (candidate) => candidate.isDynamicEntry && candidate.facadeModuleId && is(candidate.facadeModuleId)
822
+ ) ?? // A module another dynamic import shares can land in a common chunk without a facade.
823
+ chunks.find((candidate) => !candidate.isEntry && candidate.moduleIds?.some(is));
808
824
  if (!chunk || loaded.has(chunk.fileName)) continue;
809
825
  loaded.add(chunk.fileName);
810
826
  into.push(chunk.fileName);
@@ -813,11 +829,15 @@ function collectFarmClientModulePreloads(bundle, options) {
813
829
  return into;
814
830
  };
815
831
  const rendererFiles = dynamicFiles(options.rendererModules);
832
+ const rootFiles = dynamicFiles(options.rootModules);
833
+ const actionFiles = dynamicFiles(options.actionModules, rendererFiles);
816
834
  return {
817
835
  files,
818
836
  entry: entryFiles.map(index),
819
837
  router: dynamicFiles(options.routerModules).map(index),
820
838
  ...rendererFiles.length > 0 ? { renderer: rendererFiles.map(index) } : {},
839
+ ...rootFiles.length > 0 ? { root: rootFiles.map(index) } : {},
840
+ ...actionFiles.length > 0 ? { actions: actionFiles.map(index) } : {},
821
841
  modules
822
842
  };
823
843
  }
@@ -826,15 +846,22 @@ function createFarmClientModulePreloadPlugin(options) {
826
846
  name: "farm-client-module-preloads",
827
847
  enforce: "post",
828
848
  async generateBundle(_output, bundle) {
829
- const rendererModules = [];
830
- for (const specifier of options.rendererImports ?? []) {
831
- const resolved = await this.resolve(specifier, options.rendererImporter);
832
- if (resolved) rendererModules.push(resolved.id);
833
- }
849
+ const resolve = async (specifiers) => {
850
+ const ids = [];
851
+ for (const specifier of specifiers ?? []) {
852
+ const resolved = await this.resolve(specifier, options.rendererImporter);
853
+ if (resolved) ids.push(resolved.id);
854
+ }
855
+ return ids;
856
+ };
857
+ const rendererModules = await resolve(options.rendererImports);
858
+ const actionModules = await resolve(options.actionImports);
834
859
  await fs.mkdir(options.buildDir, { recursive: true });
835
860
  await fs.writeFile(
836
861
  path4.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
837
- JSON.stringify(collectFarmClientModulePreloads(bundle, { ...options, rendererModules }))
862
+ JSON.stringify(
863
+ collectFarmClientModulePreloads(bundle, { ...options, rendererModules, actionModules })
864
+ )
838
865
  );
839
866
  }
840
867
  };
@@ -907,8 +934,10 @@ function resolveFarmDocsClientRoutes(pages, docsPagePaths) {
907
934
  function isStatic(segment) {
908
935
  return segment === "static";
909
936
  }
910
- function generateFarmClientRouteTableModule(table) {
911
- return `export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
937
+ function generateFarmClientRouteTableModule(table, options = {}) {
938
+ const matcher = options.matcher ? `export { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
939
+ ` : "";
940
+ return `${matcher}export default JSON.parse(${JSON.stringify(JSON.stringify(table))});
912
941
  `;
913
942
  }
914
943
  async function writeFarmClientRouteTable(buildDir, table) {
@@ -3170,9 +3199,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3170
3199
  const layoutAppliesToRoute = routeBoundaryCoversDirectory;
3171
3200
  const routeDirectory = (route) => route.directory ?? route.pattern;
3172
3201
  const islandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
3173
- const adapterOwnsDocsRuntime = Boolean(
3174
- isReactRenderer(config.renderer) && config.docs?.enabled && config.docs.adapter?.server && config.docs.adapter.react
3175
- );
3202
+ const adapterOwnsDocsRuntime = hasFarmDocsRuntimeAdapter(config.docs);
3176
3203
  const docsEntries = config.docs?.enabled ? getFarmDocsRoots(config.docs).map(
3177
3204
  (docsRoot) => `/${docsRoot.entry || "docs"}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/"
3178
3205
  ) : [];
@@ -3423,7 +3450,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3423
3450
  adapterOwnsDocsRuntime ? false : isFarmDocsSearchEnabled(config.docs),
3424
3451
  adapterOwnsDocsRuntime ? void 0 : resolveFarmDocsSearchClientModule(root),
3425
3452
  config.docs?.enabled ? getFarmDocsRoots(config.docs).map((docsRoot) => docsRoot.entry) : void 0,
3426
- adapterOwnsDocsRuntime ? config.docs.adapter?.react : void 0,
3453
+ adapterOwnsDocsRuntime ? getFarmDocsAdapterUIModule(config.docs.adapter) : void 0,
3427
3454
  config.i18n,
3428
3455
  config.plugins,
3429
3456
  config.renderer,
@@ -3444,15 +3471,20 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3444
3471
  ) : []
3445
3472
  );
3446
3473
  const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
3447
- const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
3474
+ const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientEntry(clientHydrationCode) : { entry: clientHydrationCode, router: void 0, root: void 0 };
3448
3475
  await fs5.writeFile(clientEntryPath, clientEntry.entry);
3449
3476
  await fs5.writeFile(
3450
3477
  path17.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
3451
- generateFarmClientRouteTableModule(clientRouteTable)
3478
+ generateFarmClientRouteTableModule(clientRouteTable, {
3479
+ matcher: islandsMode && platform !== "mobile"
3480
+ })
3452
3481
  );
3453
3482
  if (clientEntry.router !== void 0) {
3454
3483
  await fs5.writeFile(path17.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
3455
3484
  }
3485
+ if (clientEntry.root !== void 0) {
3486
+ await fs5.writeFile(path17.join(clientEntryDir, "farm-client-root.tsx"), clientEntry.root);
3487
+ }
3456
3488
  const clientInput = { [entryName]: clientEntryPath };
3457
3489
  if (platform === "web" && canBootFarmIslandsClient(config)) {
3458
3490
  const clientBootPath = path17.join(clientEntryDir, "farm-client-boot.tsx");
@@ -3548,6 +3580,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3548
3580
  path17.join(clientEntryDir, "farm-client-router.tsx"),
3549
3581
  path17.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`)
3550
3582
  ],
3583
+ rootModules: [path17.join(clientEntryDir, "farm-client-root.tsx")],
3551
3584
  // What the islands entry loads with its first render or hydration (RFC 0010).
3552
3585
  ...islandsMode && isReactRenderer(config.renderer) ? {
3553
3586
  rendererImports: [
@@ -3555,6 +3588,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3555
3588
  "react-dom/client",
3556
3589
  "@farm.js/core/internal/islands-runtime"
3557
3590
  ],
3591
+ // What a call's result is handled with, imported on the first (RFC 0013).
3592
+ actionImports: ["@farm.js/core/internal/islands-action-client"],
3558
3593
  rendererImporter: clientEntryPath
3559
3594
  } : {}
3560
3595
  }),
@@ -3565,7 +3600,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3565
3600
  importer: clientEntryPath,
3566
3601
  entryName: "farm-client",
3567
3602
  modules: [
3568
- config.docs.adapter.react,
3603
+ getFarmDocsAdapterUIModule(config.docs.adapter),
3569
3604
  getFarmDocsAdapterConfigModule(config.docs)
3570
3605
  ].filter((specifier) => Boolean(specifier))
3571
3606
  })
@@ -3841,18 +3876,27 @@ function loadFarmClientRouteTable() { return null; }
3841
3876
  function prefetchFarmClientRouteTable() {}
3842
3877
  const farmClientRoutesBoot = null;`;
3843
3878
  }
3879
+ const lazy = options.lazyMatcher === true;
3880
+ const toClientRoute = `function(route) {
3881
+ const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
3882
+ return { ...route, navigation: "html-fragment", load: load || null };
3883
+ }`;
3844
3884
  return `${prefetch}
3845
3885
  let clientRoutes = [];
3846
- let clientRouteMatcher = createFarmRouter([]);
3847
- let clientPageRouteMatcher = clientRouteMatcher;
3886
+ ${lazy ? `// The matcher, which loads with the table. Until then the entry matches only the document's own
3887
+ // path (readFarmClientBootRoute).
3888
+ let createFarmRouter = null;
3889
+ let isFarmRouteActive = null;
3890
+ let matchFarmRoute = null;
3891
+ let clientRouteMatcher = null;
3892
+ let clientPageRouteMatcher = null;
3893
+ let farmClientBootRoute = null;` : `let clientRouteMatcher = createFarmRouter([]);
3894
+ let clientPageRouteMatcher = clientRouteMatcher;`}
3848
3895
  let farmClientRouteTableLoad = null;
3849
3896
  let farmClientRouteTableLoaded = false;
3850
3897
 
3851
3898
  function setFarmClientRoutes(routes) {
3852
- clientRoutes = routes.map(function(route) {
3853
- const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
3854
- return { ...route, navigation: "html-fragment", load: load || null };
3855
- });
3899
+ clientRoutes = routes.map(${lazy ? "toFarmClientRoute" : toClientRoute});
3856
3900
  clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
3857
3901
  return { path: route.pattern, meta: route };
3858
3902
  }));
@@ -3862,12 +3906,27 @@ function setFarmClientRoutes(routes) {
3862
3906
  return { path: route.pattern, meta: route };
3863
3907
  }))` : "clientRouteMatcher"};
3864
3908
  }
3909
+ ${lazy ? `
3910
+ function toFarmClientRoute(route) {
3911
+ const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
3912
+ return { ...route, navigation: "html-fragment", load: load || null };
3913
+ }
3865
3914
 
3915
+ // The document's own route, which it names with its params and layouts, until the table loads. A
3916
+ // match for another path waits for the table: the router loads it before it matches.
3917
+ function readFarmClientBootRoute(path) {
3918
+ if (farmClientBootRoute && farmClientBootRoute.path === path) return farmClientBootRoute;
3919
+ throw new Error("[Farm.js] " + path + " cannot be matched before the client route table loads.");
3920
+ }
3921
+ ` : ""}
3866
3922
  // Null once the whole table is in place, else a promise that settles when it is.
3867
3923
  function loadFarmClientRouteTable() {
3868
3924
  if (farmClientRouteTableLoaded) return null;
3869
3925
  return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
3870
- setFarmClientRoutes(module.default);
3926
+ ${lazy ? ` createFarmRouter = module.createFarmRouter;
3927
+ isFarmRouteActive = module.isFarmRouteActive;
3928
+ matchFarmRoute = module.matchFarmRoute;
3929
+ ` : ""} setFarmClientRoutes(module.default);
3871
3930
  farmClientRouteTableLoaded = true;
3872
3931
  }, function(error) {
3873
3932
  farmClientRouteTableLoad = null;
@@ -3883,8 +3942,9 @@ function prefetchFarmClientRouteTable() {
3883
3942
 
3884
3943
  const farmClientRoutesBoot = (function() {
3885
3944
  const boot = window.__FARM_CLIENT_ROUTES__;
3886
- if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
3887
- setFarmClientRoutes(boot.routes);
3945
+ if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)${lazy ? " &&\n boot.params && Array.isArray(boot.layouts)" : ""}) {
3946
+ ${lazy ? ` clientRoutes = boot.routes.map(toFarmClientRoute);
3947
+ farmClientBootRoute = boot;` : " setFarmClientRoutes(boot.routes);"}
3888
3948
  return null;
3889
3949
  }
3890
3950
  return loadFarmClientRouteTable().catch(function(error) {
@@ -3907,7 +3967,75 @@ for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
3907
3967
  document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
3908
3968
  }`;
3909
3969
  }
3910
- function generateFarmClientBootRoutesServerSource(tableSource) {
3970
+ function getFarmClientLayoutMatch(pattern) {
3971
+ const groupScope = getRouteGroupScope(pattern);
3972
+ return groupScope ? { pattern, urlPattern: stripRouteGroups(pattern), groupScope } : { pattern };
3973
+ }
3974
+ function generateFarmClientLayoutSelectionSource() {
3975
+ return `function selectFarmClientLayouts(layouts, routePathname, readDirectory) {
3976
+ const normalizedPath = routePathname.replace(/\\/$/, '') || '/';
3977
+ let directory;
3978
+ return layouts.filter(function(layout) {
3979
+ // Route groups add no URL segment: match the layout's URL, then keep a
3980
+ // grouped layout to the pages inside its group directory.
3981
+ const urlPattern = layout.urlPattern || layout.pattern;
3982
+ if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, normalizedPath, { exact: false })) return false;
3983
+ if (!layout.groupScope) return true;
3984
+ if (directory === undefined) directory = readDirectory();
3985
+ return typeof directory === 'string' &&
3986
+ (directory === layout.groupScope || directory.startsWith(layout.groupScope + '/'));
3987
+ });
3988
+ }`;
3989
+ }
3990
+ function generateFarmClientRouteMatchSource(options = {}) {
3991
+ const select = "selectFarmClientLayouts(layoutRoutes, path, function() { return getFarmPageDirectory(pathname); })";
3992
+ return `${generateFarmClientLayoutSelectionSource()}
3993
+ ${options.lazyMatcher ? `
3994
+ // The document's own layouts, which it names, until the table loads (readFarmClientBootRoute).
3995
+ function readFarmClientBootLayouts(path) {
3996
+ const names = readFarmClientBootRoute(path).layouts;
3997
+ return layoutRoutes.filter(function(layout) { return names.includes(layout.pattern); });
3998
+ }
3999
+ ` : ""}
4000
+ // Get applicable layouts for a pathname (sorted by depth, root first)
4001
+ function getApplicableLayouts(pathname) {
4002
+ const path = getFarmRoutePathname(pathname);
4003
+ const applicable = ${options.lazyMatcher ? `clientRouteMatcher
4004
+ ? ${select}
4005
+ : readFarmClientBootLayouts(path)` : select};
4006
+
4007
+ // Sort by depth (root first)
4008
+ applicable.sort(function(a, b) {
4009
+ const depthA = a.pattern.split('/').filter(Boolean).length;
4010
+ const depthB = b.pattern.split('/').filter(Boolean).length;
4011
+ return depthA - depthB;
4012
+ });
4013
+
4014
+ return applicable;
4015
+ }
4016
+
4017
+ function hasHydratableLayout(pathname) {
4018
+ return getApplicableLayouts(pathname).some(function(layout) {
4019
+ return layout.shouldHydrate === true;
4020
+ });
4021
+ }
4022
+
4023
+ // Match pathname to client route
4024
+ function matchRoute(pathname) {
4025
+ const path = getFarmRoutePathname(pathname);
4026
+ ${options.lazyMatcher ? ` if (!clientRouteMatcher) {
4027
+ // Without the document's route either (the table did not load), nothing matches, as with no table.
4028
+ if (!farmClientBootRoute) return null;
4029
+ const boot = readFarmClientBootRoute(path);
4030
+ return clientRoutes.length > 0 ? { route: clientRoutes[0], params: boot.params } : null;
4031
+ }
4032
+ ` : ""} const matched = clientRouteMatcher.match(path);
4033
+ return matched
4034
+ ? { route: matched.route.meta, params: matched.params }
4035
+ : null;
4036
+ }`;
4037
+ }
4038
+ function generateFarmClientBootRoutesServerSource(tableSource, layouts) {
3911
4039
  return `// The client route table (client-route-table.ts), filled in from the client build. The client
3912
4040
  // loads it on its first navigation; a document names the entries its page boots with, found
3913
4041
  // with the client's own matcher, so its page hydrates without the table.
@@ -3927,18 +4055,40 @@ const farmClientRouteTable = (() => {
3927
4055
  return null;
3928
4056
  }
3929
4057
  })();
3930
-
4058
+ ${layouts ? `
4059
+ // The client's layouts (layoutRoutes in the client entry), of which a document names those that
4060
+ // apply at its path.
4061
+ const farmClientLayoutTable = ${JSON.stringify(layouts)};
4062
+ ${generateFarmClientLayoutSelectionSource()}
4063
+
4064
+ // The layouts that apply at a route path, with the page directory the client's
4065
+ // getFarmPageDirectory reads from the route matched there.
4066
+ function getFarmClientBootLayouts(routePathname, matched, page) {
4067
+ const directory = !matched
4068
+ ? null
4069
+ : matched.route.meta.docs && !matched.route.meta.directory
4070
+ ? page ? page.route.meta.directory || page.route.meta.pattern : null
4071
+ : matched.route.meta.directory || matched.route.meta.pattern;
4072
+ return selectFarmClientLayouts(farmClientLayoutTable, routePathname, function() { return directory; })
4073
+ .map(function(layout) { return layout.pattern; });
4074
+ }
4075
+ ` : ""}
3931
4076
  // The entries the client's matchRoute and getFarmPageDirectory read for this route path.
3932
4077
  function getFarmClientBootRoutes(routePathname) {
3933
4078
  if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
3934
4079
  const routes = [];
3935
4080
  const matched = farmClientRouteTable.routes.match(routePathname);
4081
+ const page = matched && matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
3936
4082
  if (matched) {
3937
4083
  routes.push(matched.route.meta);
3938
- const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
3939
4084
  if (page) routes.push(page.route.meta);
3940
4085
  }
3941
- return { path: routePathname, routes: routes };
4086
+ return { path: routePathname, routes: routes${layouts ? ", params: matched ? matched.params : {}, layouts: getFarmClientBootLayouts(routePathname, matched, page)" : ""} };
4087
+ }
4088
+
4089
+ // A status document's: no route matches at its path.
4090
+ function getFarmClientStatusBootRoutes(routePathname) {
4091
+ return { path: routePathname, routes: []${layouts ? ", params: {}, layouts: getFarmClientBootLayouts(routePathname, null, null)" : ""} };
3942
4092
  }`;
3943
4093
  }
3944
4094
  function generateClientPageDirectorySource() {
@@ -4834,40 +4984,82 @@ function readFarmEntryImports(source) {
4834
4984
  }
4835
4985
  return bindings;
4836
4986
  }
4837
- function splitFarmClientRouter(code) {
4987
+ var FARM_LAZY_ROOT_STUB = `let farmRootLoading = null;
4988
+ function loadFarmRoot() {
4989
+ return farmRootLoading || (farmRootLoading = import("./farm-client-root").catch(function(error) {
4990
+ farmRootLoading = null;
4991
+ throw error;
4992
+ }));
4993
+ }
4994
+ `;
4995
+ var FARM_ROOT_MODULE_EXPORTS = [
4996
+ "createMatchedHydrationRoute",
4997
+ "hydrateFarmRoute",
4998
+ "renderFarmRoute",
4999
+ "farmTreeLayoutsReady",
5000
+ "loadRouteComponent",
5001
+ "createLayoutPageBoundary",
5002
+ "createFarmRouteState"
5003
+ ];
5004
+ function takeFarmEntryRegions(code, kind) {
4838
5005
  const regions = [];
4839
- const eager = code.replace(
4840
- /\/\*farm-router-start\*\/([\s\S]*?)\/\*farm-router-end\*\/\n?/g,
4841
- (_, body2) => {
4842
- regions.push(body2);
5006
+ const rest = code.replace(
5007
+ new RegExp(`/\\*farm-${kind}-start\\*/([\\s\\S]*?)/\\*farm-${kind}-end\\*/\\n?`, "g"),
5008
+ (_, body) => {
5009
+ regions.push(body);
4843
5010
  return "";
4844
5011
  }
4845
5012
  );
4846
- const body = regions.join("\n");
4847
- const moved = readFarmEntryDeclarations(body);
4848
- const usedByRouter = (name) => !moved.has(name) && bindingPattern(name).test(body);
5013
+ return { rest, body: regions.join("\n") };
5014
+ }
5015
+ function splitFarmClientEntry(code) {
5016
+ const router = takeFarmEntryRegions(code, "router");
5017
+ const root = takeFarmEntryRegions(router.rest, "root");
5018
+ const splitsRoot = root.body !== "";
5019
+ const eager = splitsRoot ? root.rest.replace(
5020
+ /\/\*farm-root-stub-start\*\/[\s\S]*?\/\*farm-root-stub-end\*\/\n?/,
5021
+ () => FARM_LAZY_ROOT_STUB
5022
+ ) : root.rest;
5023
+ const declared = {
5024
+ router: readFarmEntryDeclarations(router.body),
5025
+ root: readFarmEntryDeclarations(root.body),
5026
+ entry: readFarmEntryDeclarations(eager)
5027
+ };
4849
5028
  const eagerCode = eager.replace(/^import\s[^;]*;/gm, "");
4850
5029
  const usedByEntry = (name) => bindingPattern(name).test(eagerCode);
4851
- const bindings = readFarmEntryImports(eager).filter((binding) => usedByRouter(binding.local));
4852
- const imports = bindings.filter((binding) => !usedByEntry(binding.local));
4853
- const reexported = bindings.filter((binding) => usedByEntry(binding.local)).map((binding) => binding.local);
4854
- const shared = [
4855
- .../* @__PURE__ */ new Set([
4856
- ...reexported,
4857
- ...[...readFarmEntryDeclarations(eager)].filter((name) => usedByRouter(name))
4858
- ])
4859
- ];
5030
+ const eagerImports = readFarmEntryImports(eager);
5031
+ const fromEntry = /* @__PURE__ */ new Set();
5032
+ const link = (body, own) => {
5033
+ const uses = (name) => !own.has(name) && bindingPattern(name).test(body);
5034
+ const lines = [];
5035
+ const shared = [];
5036
+ for (const binding of eagerImports.filter((candidate) => uses(candidate.local))) {
5037
+ if (usedByEntry(binding.local)) shared.push(binding.local);
5038
+ else lines.push(`import ${binding.clause} from ${binding.from};`);
5039
+ }
5040
+ for (const name of declared.entry) if (uses(name)) shared.push(name);
5041
+ const names = [...new Set(shared)];
5042
+ for (const name of names) fromEntry.add(name);
5043
+ if (names.length > 0) lines.push(`import { ${names.join(", ")} } from "./farm-client-entry";`);
5044
+ return lines;
5045
+ };
5046
+ const routerImports = link(router.body, declared.router);
5047
+ const rootImports = splitsRoot ? link(root.body, declared.root) : [];
5048
+ const crossing = (body, names) => [...names].filter((name) => !declared.entry.has(name) && bindingPattern(name).test(body));
5049
+ const crossed = splitsRoot ? [...crossing(root.body, declared.router), ...crossing(router.body, declared.root)] : [];
5050
+ if (crossed.length > 0) {
5051
+ throw new Error(
5052
+ `The client entry's router and root code use ${crossed.join(", ")} from each other. Keep what both use outside the \`farm-router\` and \`farm-root\` regions.`
5053
+ );
5054
+ }
4860
5055
  return {
4861
5056
  entry: `${eager.replace("/*farm-router-stub*/", FARM_LAZY_ROUTER_STUB)}
4862
- export { ${shared.join(", ")} };
5057
+ export { ${[...fromEntry].join(", ")} };
4863
5058
  `,
4864
- router: [
4865
- ...imports.map((binding) => `import ${binding.clause} from ${binding.from};`),
4866
- `import { ${shared.join(", ")} } from "./farm-client-entry";`,
4867
- body,
4868
- "export { spaRouter };",
4869
- ""
4870
- ].join("\n")
5059
+ router: [...routerImports, router.body, "export { spaRouter };", ""].join("\n"),
5060
+ root: splitsRoot ? [...rootImports, root.body, `export { ${FARM_ROOT_MODULE_EXPORTS.join(", ")} };`, ""].join(
5061
+ "\n"
5062
+ ) : void 0
4871
5063
  };
4872
5064
  }
4873
5065
  var FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME = `
@@ -4897,7 +5089,7 @@ var FARM_DOCUMENT_PARSED_RUNTIME = `function farmDocumentParsed() {
4897
5089
  }
4898
5090
 
4899
5091
  `;
4900
- function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlots, root, srcDir, docsSearchEnabled, docsSearchModuleId, docsEntryPath, docsAdapterReact, i18nConfig = {
5092
+ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlots, root, srcDir, docsSearchEnabled, docsSearchModuleId, docsEntryPath, docsAdapterUI, i18nConfig = {
4901
5093
  enabled: false,
4902
5094
  basePath: "/",
4903
5095
  locales: ["en"],
@@ -4926,6 +5118,8 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
4926
5118
  );
4927
5119
  const appSetupPath = resolveFarmRendererAppSetup(root, renderer);
4928
5120
  const lazyRenderer = islandValues && platform !== "mobile" && isReactRenderer(renderer) && clientRouteSlots.length === 0;
5121
+ const lazyRoot = islandValues && platform !== "mobile";
5122
+ const lazyMatcher = lazyRoot && clientPages.length > 0;
4929
5123
  const rendererClientImports = lazyRenderer ? `import { holdFarmIslandInteractions, restorePagePosition, watchFarmIslandTriggers } from "@farm.js/core/internal/client-runtime";` : isReactRenderer(renderer) ? `import React from "react";
4930
5124
  import { createRoot, hydrateRoot } from "react-dom/client";
4931
5125
  import { restorePagePosition } from "@farm.js/core/internal/client-runtime";` : (
@@ -4962,6 +5156,7 @@ const React = { ...__farmRendererClient };`
4962
5156
  ).join("\n");
4963
5157
  const layoutImportStatements = [];
4964
5158
  const layoutRegistrations = [];
5159
+ const layoutComponents = [];
4965
5160
  const hydratingLayoutPatterns = layoutRoutes.filter((layout) => layout.shouldHydrate).map((layout) => layout.pattern);
4966
5161
  const treeLayoutPatterns = islandValues ? getFarmServerTreeLayoutPatterns(layoutRoutes) : /* @__PURE__ */ new Set();
4967
5162
  layoutRoutes.forEach((layout, index) => {
@@ -4973,13 +5168,23 @@ const React = { ...__farmRendererClient };`
4973
5168
  if (rendersOnClient && !treeLayout) {
4974
5169
  layoutImportStatements.push(`import Layout${index} from "${relativePath}";`);
4975
5170
  }
4976
- const groupScope = getRouteGroupScope(layout.pattern);
4977
- const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(stripRouteGroups(layout.pattern))}, groupScope: ${JSON.stringify(groupScope)}` : "";
5171
+ const { urlPattern, groupScope } = getFarmClientLayoutMatch(layout.pattern);
5172
+ const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(urlPattern)}, groupScope: ${JSON.stringify(groupScope)}` : "";
5173
+ const component = rendersOnClient ? treeLayout ? `getFarmTreeLayoutComponent(${JSON.stringify(layout.pattern)})` : `Layout${index}` : "null";
5174
+ layoutComponents.push(component);
4978
5175
  layoutRegistrations.push(
4979
- ` { pattern: ${JSON.stringify(layout.pattern)}${groupFields}, Component: ${rendersOnClient ? treeLayout ? `getFarmTreeLayoutComponent(${JSON.stringify(layout.pattern)})` : `Layout${index}` : "null"}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)}${treeLayout ? ", serverTree: true" : ""} }`
5176
+ ` { pattern: ${JSON.stringify(layout.pattern)}${groupFields}, Component: ${lazyRoot ? "null" : component}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)}${treeLayout ? ", serverTree: true" : ""} }`
4980
5177
  );
4981
5178
  });
4982
5179
  const layoutImports = layoutImportStatements.join("\n");
5180
+ const layoutComponentsRuntime = lazyRoot && layoutComponents.some((component) => component !== "null") ? `/*farm-root-start*/
5181
+ ${layoutImports}
5182
+ // The layouts' components, which only a page or layout root renders.
5183
+ [${layoutComponents.join(", ")}].forEach(function(Component, index) {
5184
+ layoutRoutes[index].Component = Component;
5185
+ });
5186
+ /*farm-root-end*/
5187
+ ` : "";
4983
5188
  const hasServerTreeLayouts = treeLayoutPatterns.size > 0;
4984
5189
  const i18nRoutingConfig = {
4985
5190
  locales: i18nConfig.locales,
@@ -5036,8 +5241,10 @@ function isFarmDocsPath() {
5036
5241
  }
5037
5242
  `;
5038
5243
  const docsAdapterRuntime = generateFarmDocsAdapterClientRuntime(
5039
- docsAdapterReact,
5040
- docsConfigModule
5244
+ docsAdapterUI,
5245
+ docsConfigModule,
5246
+ // Config resolution keeps an adapter to its UI's renderer, so this is the UI's renderer too.
5247
+ isReactRenderer(renderer) ? void 0 : renderer.client
5041
5248
  );
5042
5249
  if (clientPages.length === 0 && clientRouteSlots.length === 0 && !providerClientCode.hasProviders) {
5043
5250
  return `
@@ -5498,6 +5705,7 @@ async function hydrateFarmIsolatedClientBoundaries(scope = document, signal) {
5498
5705
  await farmIsolatedHydrationRuntime.hydrate(scope, signal);
5499
5706
  }
5500
5707
  ${serverTreeEnabled ? `
5708
+ /*farm-root-start*/
5501
5709
  // A server-tree page (an async page below a hydrating layout) rebuilds in the layout's root.
5502
5710
  async function createFarmServerTreePageElement(source, pathname) {
5503
5711
  try {
@@ -5511,7 +5719,10 @@ async function createFarmServerTreePageElement(source, pathname) {
5511
5719
  console.warn("[Farm.js] Could not rebuild the server tree of " + pathname + "; its server HTML was kept.", error);
5512
5720
  return null;
5513
5721
  }
5514
- }` : "async function createFarmServerTreePageElement() { return null; }"}` : `async function createFarmServerTreePageElement() { return null; }`;
5722
+ }
5723
+ /*farm-root-end*/` : "\n/*farm-root-start*/\nasync function createFarmServerTreePageElement() { return null; }\n/*farm-root-end*/"}` : `/*farm-root-start*/
5724
+ async function createFarmServerTreePageElement() { return null; }
5725
+ /*farm-root-end*/`;
5515
5726
  const routeClientGraphRuntime = isolatedHydrationEnabled ? `function wrapFarmRouteClientGraph(element) {
5516
5727
  return wrapFarmIsolatedClientGraph(React, element);
5517
5728
  }` : `function wrapFarmRouteClientGraph(element) { return element; }`;
@@ -5531,13 +5742,13 @@ async function createFarmServerTreePageElement(source, pathname) {
5531
5742
  return `
5532
5743
  // Farm.js Client Runtime - SPA with Hydration
5533
5744
  ${cssImport}
5534
- ${layoutImports}
5745
+ ${lazyRoot ? "" : layoutImports}
5535
5746
  ${rendererClientImports}
5536
5747
  ${isolatedHydrationImport}
5537
5748
  ${providerClientCode.imports}
5538
5749
  import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, keepFarmIslandValues, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, readFarmLinkNavigateOptions, rememberFarmLinkLocale, reconcileFarmDocumentHead, replayFarmQueuedInteraction, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
5539
5750
  import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
5540
- import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
5751
+ ${lazyMatcher ? "" : 'import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";'}
5541
5752
  ${clientPluginEntry.imports}
5542
5753
  ${clientCachePersistence.imports}
5543
5754
  ${i18nClientRuntime}
@@ -5561,7 +5772,8 @@ ${routeLoaders.join("\n")}
5561
5772
  ${generateFarmClientRouteTableRuntime({
5562
5773
  table: clientPages.length > 0,
5563
5774
  docs: clientPages.some((page) => page.docs),
5564
- streamNavigations: islandValues
5775
+ streamNavigations: islandValues,
5776
+ lazyMatcher
5565
5777
  })}
5566
5778
  ${generateClientPageDirectorySource()}
5567
5779
 
@@ -5577,43 +5789,9 @@ const layoutRoutes = [
5577
5789
  ${layoutRegistrations.join(",\n")}
5578
5790
  ];
5579
5791
 
5580
- // Get applicable layouts for a pathname (sorted by depth, root first)
5581
- function getApplicableLayouts(pathname) {
5582
- const applicable = [];
5583
- const normalizedPath = getFarmRoutePathname(pathname).replace(/\\/$/, '') || '/';
5584
- let directory;
5585
-
5586
- for (const layout of layoutRoutes) {
5587
- // Route groups add no URL segment: match the layout's URL, then keep a
5588
- // grouped layout to the pages inside its group directory.
5589
- const urlPattern = layout.urlPattern || layout.pattern;
5590
- if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, normalizedPath, { exact: false })) continue;
5591
- if (layout.groupScope) {
5592
- if (directory === undefined) directory = getFarmPageDirectory(pathname);
5593
- if (
5594
- typeof directory !== 'string' ||
5595
- (directory !== layout.groupScope && !directory.startsWith(layout.groupScope + '/'))
5596
- ) continue;
5597
- }
5598
- applicable.push(layout);
5599
- }
5600
-
5601
- // Sort by depth (root first)
5602
- applicable.sort(function(a, b) {
5603
- const depthA = a.pattern.split('/').filter(Boolean).length;
5604
- const depthB = b.pattern.split('/').filter(Boolean).length;
5605
- return depthA - depthB;
5606
- });
5607
-
5608
- return applicable;
5609
- }
5610
-
5611
- function hasHydratableLayout(pathname) {
5612
- return getApplicableLayouts(pathname).some(function(layout) {
5613
- return layout.shouldHydrate === true;
5614
- });
5615
- }
5792
+ ${generateFarmClientRouteMatchSource({ lazyMatcher })}
5616
5793
 
5794
+ ${layoutComponentsRuntime}/*farm-root-start*/
5617
5795
  ${FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
5618
5796
  // Wrap a page element with applicable layouts
5619
5797
  function wrapWithLayouts(pageElement, pathname, params) {
@@ -5679,15 +5857,9 @@ function prepareFarmTreeLayouts(pathname, params, source) {
5679
5857
  );
5680
5858
  }` : `function farmTreeLayoutsReady() { return true; }
5681
5859
  async function prepareFarmTreeLayouts() { return true; }`}
5860
+ /*farm-root-end*/
5682
5861
 
5683
- // Match pathname to client route
5684
- function matchRoute(pathname) {
5685
- const matched = clientRouteMatcher.match(getFarmRoutePathname(pathname));
5686
- return matched
5687
- ? { route: matched.route.meta, params: matched.params }
5688
- : null;
5689
- }
5690
-
5862
+ /*farm-root-start*/
5691
5863
  async function loadRouteComponent(route) {
5692
5864
  if (!route.load) return null;${lazyRenderer ? `
5693
5865
  // A page component renders with React DOM, which loads beside it (RFC 0010).
@@ -5816,6 +5988,7 @@ function renderFarmRoute(root, route) {
5816
5988
  if (route.layouts.length > 0 && typeof root.renderRoute === "function") root.renderRoute(route);
5817
5989
  else root.render(route.element);
5818
5990
  }
5991
+ /*farm-root-end*/
5819
5992
 
5820
5993
  /*farm-router-start*/
5821
5994
  function matchesRoutePrefix(pathname, pattern) {
@@ -6199,7 +6372,10 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6199
6372
  }
6200
6373
  const searchParams = searchParamsToObject(new URLSearchParams(window.location.search));
6201
6374
  const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
6202
- const routeState = await createMatchedHydrationRoute(
6375
+ // The code that renders the root loads when its strategy is due (RFC 0013).
6376
+ const farmRoot = await loadFarmRoot();
6377
+ if (hydrationController.signal.aborted || !container.isConnected) return;
6378
+ const routeState = await farmRoot.createMatchedHydrationRoute(
6203
6379
  matched,
6204
6380
  pathname,
6205
6381
  searchParams,
@@ -6219,7 +6395,7 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6219
6395
  // navigation, that is not a failure, so error hooks never see it.
6220
6396
  if (hydrationController.signal.aborted || !container.isConnected) return;
6221
6397
  if (shouldHydrate) {
6222
- reactRoot = hydrateFarmRoute(container, routeState);
6398
+ reactRoot = farmRoot.hydrateFarmRoute(container, routeState);
6223
6399
  reactRootContainer = container;
6224
6400
  isHydrated = true;
6225
6401
  } else {
@@ -6227,7 +6403,7 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6227
6403
  reactRoot = createRoot(container);
6228
6404
  reactRootContainer = container;
6229
6405
  }
6230
- renderFarmRoute(reactRoot, routeState);
6406
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6231
6407
  }
6232
6408
  await farmClientRuntime.completeHydration(hydrationSession);
6233
6409
  } catch (error) {
@@ -6242,6 +6418,14 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6242
6418
  });
6243
6419
  }
6244
6420
 
6421
+ // The code that renders a page or layout root, which islands mode's web build loads on demand
6422
+ // (RFC 0013) and every other client has here.
6423
+ /*farm-root-stub-start*/
6424
+ function loadFarmRoot() {
6425
+ return Promise.resolve({ ${FARM_ROOT_MODULE_EXPORTS.join(", ")} });
6426
+ }
6427
+ /*farm-root-stub-end*/
6428
+
6245
6429
  /*farm-router-start*/
6246
6430
  // A layout boundary is the same layout when its key matches: islands mode keys it by pattern and
6247
6431
  // params, so a layout whose params change renders again. Other modes compare patterns.
@@ -6517,6 +6701,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6517
6701
  }
6518
6702
  const pathname = url.pathname;
6519
6703
  const matched = matchRoute(pathname);
6704
+ // A root that hydrates on load renders with code that loads beside its page (RFC 0013).
6705
+ if (
6706
+ matched &&
6707
+ (matched.route.pageShouldHydrate || hasHydratableLayout(pathname)) &&
6708
+ (matched.route.islandStrategy || "load") === "load"
6709
+ ) {
6710
+ void loadFarmRoot().catch(function() {});
6711
+ }
6520
6712
  const from = this.currentPath;
6521
6713
  if (await this.shouldBlockNavigation({ from, to, action })) {
6522
6714
  if (action === "pop") this.revertBlockedPopState(from);
@@ -6606,23 +6798,22 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6606
6798
  }
6607
6799
  }
6608
6800
 
6609
- if (
6610
- !options.refresh &&
6611
- matched?.route.navigation === "client-render" &&
6612
- farmTreeLayoutsReady(pathname, matched.params)
6613
- ) {
6801
+ // The code that renders a page loads with the navigation to one (RFC 0013).
6802
+ const farmRoot =
6803
+ !options.refresh && matched?.route.navigation === "client-render" ? await loadFarmRoot() : null;
6804
+ if (farmRoot && farmRoot.farmTreeLayoutsReady(pathname, matched.params)) {
6614
6805
  // Navigation itself signals intent, so destination routes load eagerly even
6615
6806
  // when their initial document hydration strategy is deferred.
6616
- const Component = await loadRouteComponent(matched.route);
6807
+ const Component = await farmRoot.loadRouteComponent(matched.route);
6617
6808
  if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
6618
6809
  const params = matched.params;
6619
6810
  const searchParams = searchParamsToObject(url.searchParams);
6620
6811
  const props = { params: params, searchParams: createFarmSearchParams(searchParams) };
6621
6812
  let pageElement = React.createElement(Component, props);
6622
6813
  if (hasHydratableLayout(pathname)) {
6623
- pageElement = createLayoutPageBoundary(matched.route, pageElement);
6814
+ pageElement = farmRoot.createLayoutPageBoundary(matched.route, pageElement);
6624
6815
  }
6625
- const routeState = createFarmRouteState(
6816
+ const routeState = farmRoot.createFarmRouteState(
6626
6817
  pageElement,
6627
6818
  pathname,
6628
6819
  params,
@@ -6645,7 +6836,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6645
6836
  if (!reactRoot) {
6646
6837
  setFarmReactRoot(createRoot(container), container);
6647
6838
  }
6648
- renderFarmRoute(reactRoot, routeState);
6839
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6649
6840
  }
6650
6841
  this.currentPath = to;
6651
6842
  });
@@ -6793,12 +6984,22 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6793
6984
  const matched = matchRoute(newPathname);
6794
6985
  const hydrateLayouts = hasHydratableLayout(newPathname);
6795
6986
  const nextPage = newRoot.querySelector("#__farm_page__");
6987
+ // A root that hydrates on load, or one React already renders, renders with code that loads
6988
+ // with the navigation to it (RFC 0013). One that waits for its trigger loads it then.
6989
+ const farmRoot =
6990
+ matched &&
6991
+ (hydrateLayouts || matched.route.pageShouldHydrate) &&
6992
+ ((matched.route.islandStrategy || "load") === "load" ||
6993
+ (hydrateLayouts && reactRoot && reactRootContainer === currentRoot))
6994
+ ? await loadFarmRoot()
6995
+ : null;
6996
+ if (!isNavigationCurrent()) return false;
6796
6997
 
6797
6998
  // If React already owns the shared layout, update that root. React keeps
6798
6999
  // matching layout component instances and their state mounted.
6799
- if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot) {
7000
+ if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot && farmRoot) {
6800
7001
  const searchParams = searchParamsToObject(targetUrl.searchParams);
6801
- const routeState = await createMatchedHydrationRoute(
7002
+ const routeState = await farmRoot.createMatchedHydrationRoute(
6802
7003
  matched,
6803
7004
  newPathname,
6804
7005
  searchParams,
@@ -6808,7 +7009,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6808
7009
  );
6809
7010
  if (!isNavigationCurrent()) return false;
6810
7011
  if (routeState) {
6811
- renderFarmRoute(reactRoot, routeState);
7012
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6812
7013
  window.__FARM_ROUTE_SLOTS__ = nextRouteSlots;
6813
7014
  setFarmHydrated();
6814
7015
  return true;
@@ -6857,7 +7058,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6857
7058
  );
6858
7059
  } else {
6859
7060
  const searchParams = searchParamsToObject(targetUrl.searchParams);
6860
- const routeState = await createMatchedHydrationRoute(
7061
+ // Without a page or layout root to hydrate, there is no route state.
7062
+ const routeState = farmRoot && await farmRoot.createMatchedHydrationRoute(
6861
7063
  matched,
6862
7064
  newPathname,
6863
7065
  searchParams,
@@ -6868,7 +7070,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6868
7070
  );
6869
7071
  if (!isNavigationCurrent()) return false;
6870
7072
  if (routeState) {
6871
- setFarmReactRoot(hydrateFarmRoute(pageContainer, routeState), pageContainer);
7073
+ setFarmReactRoot(farmRoot.hydrateFarmRoute(pageContainer, routeState), pageContainer);
6872
7074
  setFarmHydrated();
6873
7075
  }
6874
7076
  }
@@ -7173,7 +7375,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
7173
7375
  }))
7174
7376
  );
7175
7377
  const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
7176
- const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
7378
+ const notFoundPath = resolveFarmNotFoundComponentPath(
7379
+ config,
7380
+ appDirs,
7381
+ routeManager.getRendererNotFoundPath()
7382
+ );
7177
7383
  if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
7178
7384
  layoutRoutes.sort((a, b) => {
7179
7385
  const depthA = a.pattern.split("/").filter(Boolean).length;
@@ -7945,12 +8151,10 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
7945
8151
  const hasInfraAnalyticsRuntime = config.analytics !== false && resolveFarmInstrumentationRuntime(preset) === "nodejs";
7946
8152
  const reportsWebMCPCalls = hasInfraAnalyticsRuntime && _farmWebMCPReportsEnabled(config.plugins);
7947
8153
  const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
7948
- const adapterOwnsDocsRuntime = Boolean(
7949
- isReactRenderer(config.renderer) && config.docs?.enabled && config.docs.adapter?.server && config.docs.adapter.react
7950
- );
8154
+ const adapterOwnsDocsRuntime = hasFarmDocsRuntimeAdapter(config.docs);
7951
8155
  if (config.docs?.enabled && config.docs.roots?.length && !adapterOwnsDocsRuntime) {
7952
8156
  throw new Error(
7953
- "Several docs roots need the docs adapter, which serves the React renderer only; Farm's built-in docs renderer serves a single docs root."
8157
+ "Several docs roots need a docs adapter; Farm's built-in docs renderer serves a single docs root."
7954
8158
  );
7955
8159
  }
7956
8160
  const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
@@ -8515,7 +8719,7 @@ const isFarmDocsAPIRequest = (requestOrPathname) => {
8515
8719
  return pathname === apiPath || pathname.startsWith(apiPath + "/");
8516
8720
  };` : adapterOwnsDocsRuntime ? `import { ${docsConfigModulePath ? "getFarmDocsConfigModuleRoot, " : ""}isFarmDocsAPIRequest } from "@farm.js/core/docs";
8517
8721
  import { ${config.docs.roots?.length ? "createFarmDocsMultiRuntimeHandler as createFarmDocsAdapterMultiRuntimeHandler" : "createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler"} } from ${JSON.stringify(config.docs.adapter.server)};
8518
- import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
8722
+ import * as FarmDocsAdapterUI from ${JSON.stringify(getFarmDocsAdapterUIModule(config.docs.adapter))};${docsConfigModulePath ? `
8519
8723
  import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
8520
8724
  const docsFontImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
8521
8725
  const docsRuntimeImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
@@ -9031,7 +9235,9 @@ const farmDocsModulePreloadPaths = farmDocsModulePreloads
9031
9235
  ),
9032
9236
  }
9033
9237
  : undefined;
9034
- const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {
9238
+ ${adapterOwnsDocsRuntime && !hasPrecompiledDocs ? `// The renderer contract's server exports, for a docs UI that builds its pages with them.
9239
+ const farmDocsAppRenderer = ${isReactRenderer(config.renderer) ? '{ name: "react", createElement: React.createElement, Fragment: React.Fragment, renderToString: ReactDOMServer.renderToString }' : "__farmRendererServer"};
9240
+ ` : ""}const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `${adapterHandler.factory}(${adapterHandler.config}, {
9035
9241
  rootDir: farmDocsRuntimeRoot,
9036
9242
  // A production build's content cannot change, so the adapter reads its
9037
9243
  // navigation once instead of scanning the content directory per request.
@@ -9047,7 +9253,10 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
9047
9253
  resolveFarmLayoutFonts(
9048
9254
  getApplicableLayouts(getFarmRoutePathname(pathname)).map((layout) => layout.module),
9049
9255
  ),
9050
- loadReactModule: async () => FarmDocsAdapterReact,
9256
+ loadUIModule: async () => FarmDocsAdapterUI,
9257
+ // The app's renderer, for a UI that builds its pages with it.
9258
+ loadRenderer: async () => farmDocsAppRenderer,${getFarmDocsAdapterRenderer(config.docs.adapter) === "react" ? `
9259
+ loadReactModule: async () => FarmDocsAdapterUI,` : ""}
9051
9260
  // Lists the docs MCP endpoint in /.well-known/ai-catalog.json for the server's lifetime.
9052
9261
  registerMCPServer: registerFarmMCPServer,
9053
9262
  // A page built with this keeps its HTML string, so the preload budget and the response
@@ -9240,7 +9449,7 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
9240
9449
  'window[Symbol.for("farm.searchPreserveRoutes")]=' + serializeFarmInlineValue(farmSearchPreserveRoutes) + ';'` : ""};
9241
9450
  // The client boots at the canonical path when the script below moves it there.
9242
9451
  const bootRoutes = statusDocument
9243
- ? typeof routePathname === "string" ? { path: routePathname, routes: [] } : undefined
9452
+ ? typeof routePathname === "string" ? getFarmClientStatusBootRoutes(routePathname) : undefined
9244
9453
  : getFarmClientBootRoutes(
9245
9454
  typeof canonicalPath === "string" && canonicalPath.startsWith("/")
9246
9455
  ? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
@@ -10044,7 +10253,7 @@ function createFarmErrorDocument(html, title, routePathname) {
10044
10253
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
10045
10254
  ' <link rel="icon" href="data:,">\\n' +
10046
10255
  ' <title>' + escapedTitle + '</title>\\n' +
10047
- ' <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html) + '\\n' +
10256
+ ' ' + renderFarmClientStylesheet() + renderFarmClientModulePreloads(html) + '\\n' +
10048
10257
  renderFarmRendererHydrationScript() + '\\n' +
10049
10258
  '</head>\\n<body>\\n' +
10050
10259
  ' <div id="root">' + html + '</div>\\n' +
@@ -10055,7 +10264,7 @@ function createFarmErrorDocument(html, title, routePathname) {
10055
10264
 
10056
10265
  let fullHtml = ensureFarmDocumentRoot(ensureFarmDocumentHead(fullDocument));
10057
10266
  fullHtml = fullHtml
10058
- .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
10267
+ .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n ' + renderFarmClientStylesheet() + renderFarmClientModulePreloads(fullDocument); })
10059
10268
  // Function replacements: dynamic markup may contain $-sequences ($&, $', $$)
10060
10269
  // that a string replacement would expand, corrupting the document.
10061
10270
  .replace(/<\\/head>/i, function() { return renderFarmRendererHydrationScript() + '\\n</head>'; })
@@ -10079,6 +10288,23 @@ function createFarmErrorDocument(html, title, routePathname) {
10079
10288
  : "<!DOCTYPE html>\\n" + fullHtml;
10080
10289
  }
10081
10290
 
10291
+ // The client stylesheet a document links, filled in from the client build once it has finished
10292
+ // (see buildNitroUniversal): null for an app without CSS, whose empty stylesheet would still hold
10293
+ // the first paint for a round trip. Parsed at runtime, so the bundler cannot fold the stand-in.
10294
+ const farmClientStylesheetHref = (() => {
10295
+ try {
10296
+ return JSON.parse("${FARM_CLIENT_STYLESHEET_PLACEHOLDER}");
10297
+ } catch {
10298
+ return "${FARM_CLIENT_CSS_HREF_PLACEHOLDER}";
10299
+ }
10300
+ })();
10301
+
10302
+ function renderFarmClientStylesheet() {
10303
+ return farmClientStylesheetHref
10304
+ ? '<link rel="stylesheet" href="' + farmClientStylesheetHref + '">'
10305
+ : "";
10306
+ }
10307
+
10082
10308
  // The client modules a page needs before it hydrates, filled in from the client
10083
10309
  // build once it has finished (see buildNitroUniversal).
10084
10310
  const farmClientModulePreloads = (() => {
@@ -10088,7 +10314,10 @@ const farmClientModulePreloads = (() => {
10088
10314
  return null;
10089
10315
  }
10090
10316
  })();
10091
- ${generateFarmClientBootRoutesServerSource(`"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`)}
10317
+ ${generateFarmClientBootRoutesServerSource(
10318
+ `"${FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER}"`,
10319
+ farmIslandsMode ? layoutRoutes.map((layout) => getFarmClientLayoutMatch(layout.pattern)) : void 0
10320
+ )}
10092
10321
 
10093
10322
  const farmClientEntryPreloadTags = farmClientModulePreloads
10094
10323
  ? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
@@ -10098,10 +10327,18 @@ const farmClientEntryPreloadTags = farmClientModulePreloads
10098
10327
  const farmClientRendererPreloadTags = farmClientModulePreloads
10099
10328
  ? (farmClientModulePreloads.renderer || []).map(renderFarmClientModulePreload).join("")
10100
10329
  : "";
10330
+ // Islands mode's entry imports the code that renders a page or layout root when one hydrates (RFC
10331
+ // 0013), so a document that has one lists that code.
10332
+ const farmClientRootPreloadTags = farmClientModulePreloads
10333
+ ? (farmClientModulePreloads.root || []).map(renderFarmClientModulePreload).join("")
10334
+ : "";
10101
10335
  // The client modules a document's markup loads: its islands' boundaries and the
10102
10336
  // client references of its server tree. An island with a deferred strategy loads its
10103
10337
  // module on its own trigger, so it is not preloaded.
10104
10338
  const FARM_CLIENT_MODULE_REFERENCE_PATTERN = /<f-island src="([^"]+)"([^>]*)>|"r":"(\\/[^"]+)"/g;
10339
+ // A server action reference in a document's markup: an action in an island's or a client
10340
+ // component's props (islx's \`{"$":"a",...}\`), or a server form posting one (its \`$F_REF_\` field).
10341
+ const FARM_ACTION_REFERENCE_PATTERN = /"\\$":"a"|name="\\$F_REF_/;
10105
10342
 
10106
10343
  function renderFarmClientModulePreload(index) {
10107
10344
  return '\\n <link rel="modulepreload" href="/' +
@@ -10132,15 +10369,28 @@ function collectFarmClientDocumentModules(markup, pageModule, listed) {
10132
10369
  return indexes;
10133
10370
  }
10134
10371
 
10372
+ // The manifest indexes of islands mode's action client, which handles a call's result (RFC 0013),
10373
+ // for a document whose markup holds an action reference, leaving out those already listed. Its
10374
+ // islands import it on their first call otherwise.
10375
+ function collectFarmClientActionModules(markup, listed) {
10376
+ const actions = farmClientModulePreloads.actions;
10377
+ if (!actions || typeof markup !== "string" || !FARM_ACTION_REFERENCE_PATTERN.test(markup)) return [];
10378
+ return actions.filter((index) => !listed.has(index) && listed.add(index));
10379
+ }
10380
+
10135
10381
  // The modulepreload links for a document: the entry's static imports and, unless it answers a
10136
- // client navigation, the renderer, then the modules its hydrating page and its markup load.
10137
- function renderFarmClientModulePreloads(markup, pageModule, navigation) {
10382
+ // client navigation, the renderer and, when a page or layout root hydrates in it (\`hydratesRoot\`),
10383
+ // the code that renders it; then the modules its hydrating page and its markup load.
10384
+ function renderFarmClientModulePreloads(markup, pageModule, navigation, hydratesRoot) {
10138
10385
  // A nonce policy blocks parser-inserted links without the nonce, and the
10139
10386
  // response filter manages nonces on script elements only, so CSP nonce mode
10140
10387
  // keeps the documents it had.
10141
10388
  if (!farmClientModulePreloads || (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce)) return "";
10389
+ const listed = new Set();
10142
10390
  return farmClientEntryPreloadTags + (navigation ? "" : farmClientRendererPreloadTags) +
10143
- collectFarmClientDocumentModules(markup, pageModule, new Set())
10391
+ (hydratesRoot && !navigation ? farmClientRootPreloadTags : "") +
10392
+ collectFarmClientDocumentModules(markup, pageModule, listed)
10393
+ .concat(collectFarmClientActionModules(markup, listed))
10144
10394
  .map(renderFarmClientModulePreload)
10145
10395
  .join("");
10146
10396
  }
@@ -10162,13 +10412,26 @@ function renderFarmClientBootPreloads(markup, pageModule, root, rootStrategy, na
10162
10412
  ) + '"';
10163
10413
  };
10164
10414
  const entry = farmClientModulePreloads.entry;
10415
+ // The root hydrates with the code that hydrates roots (RFC 0013) and its page's modules.
10165
10416
  const rootModules = root
10166
- ? collectFarmClientDocumentModules(markup, pageModule, new Set(entry))
10417
+ ? (farmClientModulePreloads.root || []).concat(
10418
+ collectFarmClientDocumentModules(
10419
+ markup,
10420
+ pageModule,
10421
+ new Set(entry.concat(farmClientModulePreloads.root || [])),
10422
+ ),
10423
+ )
10167
10424
  : [];
10168
10425
  const waitsForClick = rootStrategy === "interaction";
10426
+ // A call needs a hydrated island, so the action client comes with the renderer.
10427
+ const renderer = navigation
10428
+ ? []
10429
+ : (farmClientModulePreloads.renderer || []).concat(
10430
+ collectFarmClientActionModules(markup, new Set(entry.concat(rootModules))),
10431
+ );
10169
10432
  return attribute("data-farm-preload", waitsForClick ? entry : entry.concat(rootModules)) +
10170
10433
  attribute("data-farm-preload-router", farmClientModulePreloads.router || []) +
10171
- attribute("data-farm-preload-renderer", navigation ? [] : farmClientModulePreloads.renderer || []) +
10434
+ attribute("data-farm-preload-renderer", renderer) +
10172
10435
  (waitsForClick ? attribute("data-farm-preload-root", rootModules) : "");
10173
10436
  }
10174
10437
 
@@ -11150,8 +11413,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
11150
11413
  }
11151
11414
  html = html.replace(/<[/]head>/i, function() { return renderedRoot.head + "\\n</head>"; });
11152
11415
  }
11153
- if (!html.includes('href="/__farm_client_css_href__"')) {
11154
- const clientStylesheet = ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n';
11416
+ if (farmClientStylesheetHref && !html.includes('href="' + farmClientStylesheetHref + '"')) {
11417
+ const clientStylesheet = ' ' + renderFarmClientStylesheet() + '\\n';
11155
11418
  const firstStyleIndex = html.search(/<style(?:\\s|>)/i);
11156
11419
  html =
11157
11420
  firstStyleIndex >= 0
@@ -12612,10 +12875,9 @@ ${hasServerRuntimeIntegrations ? `
12612
12875
  // A document something hydrates over holds the clicks and submits made before it hydrates,
12613
12876
  // for the client entry to replay, as development does. One that starts with the boot entry
12614
12877
  // holds its own.
12878
+ const farmHydratesRoot = route.shouldHydrate || shouldHydrateLayout;
12615
12879
  const farmHoldsInteractions =
12616
- route.shouldHydrate ||
12617
- shouldHydrateLayout ||
12618
- renderedRouteSlots.some(function(slot) { return slot.hydrates; });
12880
+ farmHydratesRoot || renderedRouteSlots.some(function(slot) { return slot.hydrates; });
12619
12881
  const renderFarmPreHydrationHoldScript = function() {
12620
12882
  return farmHoldsInteractions && !farmBootsClient
12621
12883
  ? stampFarmCspNonce(createPreHydrationClickQueueScript()) + '\\n'
@@ -12634,7 +12896,7 @@ ${hasServerRuntimeIntegrations ? `
12634
12896
  );
12635
12897
  composed = composed
12636
12898
  // Inject CSS link after opening head tag or first meta tag
12637
- .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + (farmBootsClient ? "" : renderFarmClientModulePreloads(composed, route.clientModule, farmNavigationRequest)); })
12899
+ .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n ' + renderFarmClientStylesheet() + (farmBootsClient ? "" : renderFarmClientModulePreloads(composed, route.clientModule, farmNavigationRequest, farmHydratesRoot)); })
12638
12900
  .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n' + renderFarmPreHydrationHoldScript() + '</head>')
12639
12901
  // Explicit metadata wins over renderer and layout titles. Without
12640
12902
  // explicit metadata, a renderer title wins over the layout title.
@@ -12707,8 +12969,8 @@ ${hasServerRuntimeIntegrations ? `
12707
12969
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
12708
12970
  (suppressDefaultTitle ? '' : ' <title>' + title + '</title>') + metaTags +
12709
12971
  (rendererHead ? '\\n ' + rendererHead : '') + '\\n' +
12710
- ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
12711
- ' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule) + '\\n' +
12972
+ ' ' + renderFarmClientStylesheet() + '\\n' +
12973
+ ' <link rel="modulepreload" href="/__farm_client_js_src__">' + renderFarmClientModulePreloads(null, route.clientModule, false, farmHydratesRoot) + '\\n' +
12712
12974
  renderFarmRendererHydrationScript() + '\\n' +
12713
12975
  renderFarmPreHydrationHoldScript() +
12714
12976
  '</head>\\n<body>\\n' + farmEarlyClientScripts + ' <div id="root">';
@@ -12822,7 +13084,6 @@ ${hasServerRuntimeIntegrations ? `
12822
13084
  }
12823
13085
  }
12824
13086
  // A route that hydrates as one root starts with the boot entry only when that root waits.
12825
- const farmHydratesRoot = route.shouldHydrate || shouldHydrateLayout;
12826
13087
  farmBootsClient = farmDocumentBootsClient(
12827
13088
  html,
12828
13089
  (farmHydratesRoot && !route.rootStrategy) || Boolean(pprCacheKey),
@@ -12865,7 +13126,7 @@ ${hasServerRuntimeIntegrations ? `
12865
13126
  \${viewportTags}
12866
13127
  \${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
12867
13128
  \${suppressDefaultTitle ? "" : "<title>" + title + "</title>"}\${metaTags}\${rendererHead ? "\\n " + rendererHead : ""}
12868
- <link rel="stylesheet" href="/__farm_client_css_href__">\${farmBootsClient ? "" : renderFarmClientModulePreloads(html, route.clientModule, farmNavigationRequest)}
13129
+ \${renderFarmClientStylesheet()}\${farmBootsClient ? "" : renderFarmClientModulePreloads(html, route.clientModule, farmNavigationRequest, farmHydratesRoot)}
12869
13130
  \${renderFarmRendererHydrationScript()}
12870
13131
  \${renderFarmPreHydrationHoldScript()}</head>
12871
13132
  <body>
@@ -13226,7 +13487,7 @@ ${farmRendererDisabled ? `
13226
13487
  "<head" + attrs + ">" +
13227
13488
  headContent.replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>\\s*/gi, "") +
13228
13489
  "\\n <title>" + notFoundMetadata.title + "</title>" + notFoundMetadata.tags + "\\n</head>")
13229
- .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(fullDocument); })
13490
+ .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n ' + renderFarmClientStylesheet() + renderFarmClientModulePreloads(fullDocument); })
13230
13491
  .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
13231
13492
  .replace(
13232
13493
  /<\\/body>/i,
@@ -13244,7 +13505,7 @@ ${farmRendererDisabled ? `
13244
13505
  <meta charset="UTF-8">
13245
13506
  \${notFoundMetadata.viewport}
13246
13507
  \${notFoundMetadata.hasFavicon ? "" : '<link rel="icon" href="data:,">'}
13247
- <link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html)}
13508
+ \${renderFarmClientStylesheet()}\${renderFarmClientModulePreloads(html)}
13248
13509
  <title>\${notFoundMetadata.title}</title>\${notFoundMetadata.tags}
13249
13510
  \${renderFarmRendererHydrationScript()}
13250
13511
  </head>
@@ -13667,12 +13928,6 @@ async function getFarmDocsPrerenderPages(config, root, preset) {
13667
13928
  }
13668
13929
  return pages2;
13669
13930
  }
13670
- if (!isReactRenderer(config.renderer)) {
13671
- logger.warn(
13672
- `The docs adapter ${JSON.stringify(config.docs.adapter.id)} renders with React; docs.prerender keeps its pages rendering on request with the "${config.renderer.name}" renderer.`
13673
- );
13674
- return [];
13675
- }
13676
13931
  const pages = await listFarmDocsAdapterPages(config.docs, { root, srcDir: config.srcDir });
13677
13932
  if (!pages) {
13678
13933
  logger.warn(
@@ -13690,7 +13945,7 @@ async function listFarmDocsAnalyticsPages(config, root, preset) {
13690
13945
  return await listFarmDocsPagePaths(config.docs, {
13691
13946
  root,
13692
13947
  srcDir: config.srcDir,
13693
- adapter: isReactRenderer(config.renderer) && hasFarmDocsRuntimeAdapter(config.docs)
13948
+ adapter: hasFarmDocsRuntimeAdapter(config.docs)
13694
13949
  });
13695
13950
  } catch (error) {
13696
13951
  logger.warn(
@@ -13859,6 +14114,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
13859
14114
  const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
13860
14115
  const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
13861
14116
  const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
14117
+ const encodedClientStylesheet = encodeFarmBuildJSONPlaceholder(
14118
+ await resolveClientStylesheetLinkHref(clientOutputDir, clientCssHref)
14119
+ );
13862
14120
  const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
13863
14121
  await finalizeFarmMobileClient({
13864
14122
  buildDir: path17.join(root, distDir),
@@ -13883,6 +14141,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
13883
14141
  if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
13884
14142
  output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
13885
14143
  }
14144
+ if (output.code.includes(FARM_CLIENT_STYLESHEET_PLACEHOLDER)) {
14145
+ output.code = output.code.split(FARM_CLIENT_STYLESHEET_PLACEHOLDER).join(encodedClientStylesheet);
14146
+ }
13886
14147
  if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
13887
14148
  output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
13888
14149
  }
@@ -15243,6 +15504,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
15243
15504
  ],
15244
15505
  suppressLintOnLink: config.suppressLintOnLink,
15245
15506
  componentExtensions: config.renderer.componentExtensions,
15507
+ renderer: config.renderer,
15246
15508
  i18nConfig: config.i18n
15247
15509
  }).catch((error) => {
15248
15510
  const message = error instanceof Error ? error.message : String(error);