@farm.js/core 0.1.81 → 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 (290) hide show
  1. package/dist/{agent-mcp.d-Cxi3214_.d.ts → agent-mcp.d-7uKdOttc.d.ts} +1 -1
  2. package/dist/{agent-mcp.d-DMqOqnOA.d.mts → agent-mcp.d-LChlR2au.d.mts} +1 -1
  3. package/dist/agent-runtime.cjs +4 -3
  4. package/dist/agent-runtime.d.mts +2 -1
  5. package/dist/agent-runtime.d.ts +2 -1
  6. package/dist/agent-runtime.mjs +3 -2
  7. package/dist/analyzer-WGH6J2HN.cjs +17 -0
  8. package/dist/{analyzer-IC66UJCU.mjs → analyzer-Y6IY26HI.mjs} +2 -2
  9. package/dist/api/node.cjs +5 -4
  10. package/dist/api/node.d.mts +4 -3
  11. package/dist/api/node.d.ts +4 -3
  12. package/dist/api/node.mjs +4 -3
  13. package/dist/api/route-manager.cjs +5 -4
  14. package/dist/api/route-manager.d.mts +4 -3
  15. package/dist/api/route-manager.d.ts +4 -3
  16. package/dist/api/route-manager.mjs +4 -3
  17. package/dist/api/runtime.cjs +4 -3
  18. package/dist/api/runtime.d.mts +3 -2
  19. package/dist/api/runtime.d.ts +3 -2
  20. package/dist/api/runtime.mjs +3 -2
  21. package/dist/api.cjs +7 -6
  22. package/dist/api.d.mts +5 -4
  23. package/dist/api.d.ts +5 -4
  24. package/dist/api.mjs +6 -5
  25. package/dist/{app-manifest.d-C8Cswd31.d.ts → app-manifest.d-CRp21oAz.d.ts} +1 -1
  26. package/dist/{app-manifest.d-Bbxp5kes.d.mts → app-manifest.d-QMdmqqCr.d.mts} +1 -1
  27. package/dist/app-markdown.d.mts +3 -2
  28. package/dist/app-markdown.d.ts +3 -2
  29. package/dist/{app.d-DGIoFt5D.d.ts → app.d-CVPu_hoD.d.ts} +51 -4
  30. package/dist/{app.d-BJuSurgy.d.mts → app.d-eSm7jgoc.d.mts} +51 -4
  31. package/dist/{chunk-NSLRK5DK.cjs → chunk-3CZ4MJHW.cjs} +1 -1
  32. package/dist/{chunk-CPZZBCPO.cjs → chunk-3DAJXBSL.cjs} +2 -2
  33. package/dist/chunk-3DE6RK7K.cjs +36 -0
  34. package/dist/{chunk-XMHERKSE.mjs → chunk-42IBGQTN.mjs} +5 -12
  35. package/dist/{chunk-GY63XD6K.mjs → chunk-43N3X6OO.mjs} +1 -1
  36. package/dist/{chunk-MOGRRZMW.cjs → chunk-55UJGUBP.cjs} +35 -30
  37. package/dist/{chunk-BPWTSPK6.mjs → chunk-5AL2GXAU.mjs} +1 -1
  38. package/dist/{chunk-GAWSWJJ2.cjs → chunk-5GFTMTX3.cjs} +2 -2
  39. package/dist/{chunk-LKIG5SM6.cjs → chunk-5P65LXGU.cjs} +9 -9
  40. package/dist/{chunk-TPA2PV5J.mjs → chunk-5V6HSJFG.mjs} +24 -1
  41. package/dist/chunk-5X5GJU5A.cjs +426 -0
  42. package/dist/{chunk-UF4BNKKJ.mjs → chunk-6QYPP5KC.mjs} +2 -2
  43. package/dist/{chunk-ATISIC6G.mjs → chunk-7VJXYB6S.mjs} +7 -1
  44. package/dist/{chunk-OIWDEDUO.cjs → chunk-7X2CYE66.cjs} +419 -357
  45. package/dist/{chunk-XOGCNKB7.cjs → chunk-A5BHJHDF.cjs} +3 -3
  46. package/dist/{chunk-WGWWRV2M.cjs → chunk-B3HQTGXS.cjs} +6 -4
  47. package/dist/{chunk-HTNJ7A4D.mjs → chunk-B5SJYXJK.mjs} +177 -67
  48. package/dist/chunk-BUQR7KKO.mjs +17 -0
  49. package/dist/{chunk-OO4GVGM3.mjs → chunk-CA2HBLXP.mjs} +11 -1
  50. package/dist/{chunk-724WT3NI.mjs → chunk-CRE642TW.mjs} +1 -1
  51. package/dist/{chunk-Z5BANEQD.cjs → chunk-DMSXZNQR.cjs} +2 -2
  52. package/dist/{chunk-IPG6B25T.mjs → chunk-DPUZVGXH.mjs} +203 -54
  53. package/dist/{chunk-ZIYJWJV2.cjs → chunk-DZTWUEBB.cjs} +8 -8
  54. package/dist/{chunk-4OFWG4IK.cjs → chunk-EACD6ND7.cjs} +8 -2
  55. package/dist/{chunk-46UV2E7I.cjs → chunk-EFI6QWBQ.cjs} +200 -90
  56. package/dist/chunk-ELNRKD4V.mjs +426 -0
  57. package/dist/{chunk-XOXCQGAF.mjs → chunk-FFWSER54.mjs} +1 -1
  58. package/dist/chunk-FZ7OUN5M.cjs +30 -0
  59. package/dist/{chunk-5MMKNW7Q.cjs → chunk-H7REG7OX.cjs} +15 -8
  60. package/dist/{chunk-5ZHC6QGD.cjs → chunk-HQKCSJEH.cjs} +8 -2
  61. package/dist/{chunk-OUDNUFVR.cjs → chunk-HRH7OKBQ.cjs} +6 -4
  62. package/dist/{chunk-RHI67C2V.cjs → chunk-HUGPJFOC.cjs} +1 -35
  63. package/dist/{chunk-ADQ2LATR.cjs → chunk-IABI62FH.cjs} +2 -2
  64. package/dist/{chunk-TLSGRK7E.mjs → chunk-IAIRQAHA.mjs} +3 -1
  65. package/dist/{chunk-C2OLXVUC.mjs → chunk-IVP5Q4BX.mjs} +10 -3
  66. package/dist/{chunk-EX6ZSN5P.cjs → chunk-IZYFP7IN.cjs} +17 -24
  67. package/dist/chunk-J6RFB324.cjs +17 -0
  68. package/dist/{chunk-CL7BUGVB.cjs → chunk-JHRJ5V2F.cjs} +509 -360
  69. package/dist/{chunk-WIZRYFB2.cjs → chunk-JYQ6DGPW.cjs} +8 -6
  70. package/dist/{chunk-POL5RCVU.mjs → chunk-K3GHY7GY.mjs} +14 -9
  71. package/dist/{chunk-TYHWZOA2.mjs → chunk-KWI3SQFX.mjs} +4 -2
  72. package/dist/{chunk-UVV3I5QA.cjs → chunk-L2GUEYHR.cjs} +29 -6
  73. package/dist/{chunk-POVHO46S.mjs → chunk-L3RDECA5.mjs} +1 -1
  74. package/dist/{chunk-E3HBD2K3.cjs → chunk-LN6FAYNB.cjs} +36 -31
  75. package/dist/chunk-M6AJZ4XR.mjs +30 -0
  76. package/dist/{chunk-RPA45OQS.mjs → chunk-MO4UTDQ6.mjs} +1 -1
  77. package/dist/{chunk-6WVRVGKC.mjs → chunk-NAHDG6UX.mjs} +1 -1
  78. package/dist/{chunk-NOYKBGUK.mjs → chunk-NDWI6FDH.mjs} +558 -212
  79. package/dist/{chunk-OFVCWV2D.cjs → chunk-NEKO3HM2.cjs} +11 -1
  80. package/dist/{chunk-M6DAIE4T.cjs → chunk-NGTZHWBG.cjs} +78 -9
  81. package/dist/{chunk-D77OGI6X.mjs → chunk-NKVBWPXR.mjs} +1 -1
  82. package/dist/{chunk-SLEHAGGV.mjs → chunk-NQ3Y6E2T.mjs} +7 -1
  83. package/dist/{chunk-W6C3LEXX.cjs → chunk-OM6JIIJU.cjs} +155 -20
  84. package/dist/{chunk-S3IWDDQ3.mjs → chunk-ORBBAA7B.mjs} +1 -1
  85. package/dist/{chunk-7VCLTNED.mjs → chunk-PNMAD3OS.mjs} +1 -35
  86. package/dist/{chunk-BJWJP5A4.mjs → chunk-R3VLM2MW.mjs} +3 -3
  87. package/dist/{chunk-I4WZRG73.mjs → chunk-RB5IGN3N.mjs} +13 -6
  88. package/dist/{chunk-2HMSSPCZ.mjs → chunk-RGTZAM6Y.mjs} +71 -2
  89. package/dist/{chunk-IM3UINTZ.mjs → chunk-RNJX3MD6.mjs} +151 -16
  90. package/dist/{chunk-EJCVG25Z.mjs → chunk-S3R4JDRO.mjs} +17 -9
  91. package/dist/{chunk-2Y2HRZQY.cjs → chunk-SLIXHUMS.cjs} +931 -585
  92. package/dist/{chunk-WFVSAT7Y.cjs → chunk-T7HGXF7D.cjs} +3 -3
  93. package/dist/{chunk-ZKNXCRUQ.cjs → chunk-U54REWMJ.cjs} +23 -23
  94. package/dist/{chunk-YH7ENV3K.mjs → chunk-U56Z3755.mjs} +13 -8
  95. package/dist/chunk-U6XYBTUT.mjs +36 -0
  96. package/dist/{chunk-TCMRLW3K.cjs → chunk-VACYUMXW.cjs} +10 -3
  97. package/dist/{chunk-RZ6XUEQS.mjs → chunk-VQ6IXALL.mjs} +2 -2
  98. package/dist/{chunk-UGLTOLTJ.cjs → chunk-W76C7TCW.cjs} +2 -2
  99. package/dist/{chunk-FYZD7DUS.cjs → chunk-WCSBYQOT.cjs} +4 -4
  100. package/dist/{chunk-5N526T7Q.mjs → chunk-WZV2G2A6.mjs} +95 -33
  101. package/dist/{chunk-SM2SYWAR.cjs → chunk-XJDB564A.cjs} +18 -10
  102. package/dist/{chunk-6JWXHPVR.mjs → chunk-XRSNW4IU.mjs} +4 -2
  103. package/dist/{cli-runtime.d-D8O1v2_X.d.mts → cli-runtime.d-C7aMfoTq.d.mts} +8 -6
  104. package/dist/{cli-runtime.d-hf4L1MNP.d.ts → cli-runtime.d-DaElKjaL.d.ts} +8 -6
  105. package/dist/{client-component.d-DFwUHlOz.d.mts → client-component.d-DLMCzmUx.d.mts} +1 -1
  106. package/dist/{client-component.d-CX8UCQh-.d.ts → client-component.d-DLknFP8l.d.ts} +1 -1
  107. package/dist/{client-plugins.d-qWp8hNwd.d.ts → client-plugins.d-BVXjyIkY.d.ts} +20 -1
  108. package/dist/{client-plugins.d-BflSNO-b.d.mts → client-plugins.d-BwKwuO_0.d.mts} +20 -1
  109. package/dist/client-plugins.d.mts +2 -1
  110. package/dist/client-plugins.d.ts +2 -1
  111. package/dist/client.cjs +4 -3
  112. package/dist/client.d.mts +10 -9
  113. package/dist/client.d.ts +10 -9
  114. package/dist/client.mjs +3 -2
  115. package/dist/config.d.mts +2 -1
  116. package/dist/config.d.ts +2 -1
  117. package/dist/cron.cjs +2 -2
  118. package/dist/cron.mjs +1 -1
  119. package/dist/desktop.d.mts +3 -2
  120. package/dist/desktop.d.ts +3 -2
  121. package/dist/{devtools-XJHODO5H.mjs → devtools-OI52TCSD.mjs} +8 -7
  122. package/dist/{devtools-EI5N366Z.cjs → devtools-ZM2AR36W.cjs} +11 -10
  123. package/dist/docs.cjs +13 -11
  124. package/dist/docs.d.mts +15 -6
  125. package/dist/docs.d.ts +15 -6
  126. package/dist/docs.mjs +12 -10
  127. package/dist/environment/vite.cjs +4 -4
  128. package/dist/environment/vite.d.mts +1 -0
  129. package/dist/environment/vite.d.ts +1 -0
  130. package/dist/environment/vite.mjs +3 -3
  131. package/dist/{generate-route-types.d-CaGMIaNI.d.mts → generate-route-types.d-BFOMM8Ef.d.mts} +3 -0
  132. package/dist/{generate-route-types.d-B76M5R11.d.ts → generate-route-types.d-C2m8myHb.d.ts} +3 -0
  133. package/dist/{handler.d-DoH5Krkq.d.mts → handler.d-BKTWzzNA.d.mts} +1 -1
  134. package/dist/{handler.d-C2oRihfa.d.ts → handler.d-Dzpyg3-N.d.ts} +1 -1
  135. package/dist/{headers.d-BrX53wFQ.d.mts → headers.d-5opjyhXw.d.mts} +1 -1
  136. package/dist/{headers.d-Dj0mfYpb.d.ts → headers.d-PZyXcDAH.d.ts} +1 -1
  137. package/dist/index.cjs +38 -35
  138. package/dist/{index.d-DzDHOttz.d.mts → index.d-C0Mie66f.d.mts} +1 -1
  139. package/dist/{index.d-Dhc2scRl.d.ts → index.d-DV2q-0mE.d.ts} +1 -1
  140. package/dist/index.d.mts +26 -25
  141. package/dist/index.d.ts +26 -25
  142. package/dist/index.mjs +38 -35
  143. package/dist/integrations/orm.d.mts +2 -1
  144. package/dist/integrations/orm.d.ts +2 -1
  145. package/dist/integrations.cjs +4 -3
  146. package/dist/integrations.d.mts +2 -1
  147. package/dist/integrations.d.ts +2 -1
  148. package/dist/integrations.mjs +3 -2
  149. package/dist/internal/app-markdown-runtime.d.mts +3 -2
  150. package/dist/internal/app-markdown-runtime.d.ts +3 -2
  151. package/dist/internal/build-runtime.cjs +31 -30
  152. package/dist/internal/build-runtime.d.mts +5 -4
  153. package/dist/internal/build-runtime.d.ts +5 -4
  154. package/dist/internal/build-runtime.mjs +30 -29
  155. package/dist/internal/cli-runtime.cjs +12 -11
  156. package/dist/internal/cli-runtime.d.mts +8 -7
  157. package/dist/internal/cli-runtime.d.ts +8 -7
  158. package/dist/internal/cli-runtime.mjs +11 -10
  159. package/dist/internal/client-error-overlay.cjs +4 -4
  160. package/dist/internal/client-error-overlay.mjs +1 -1
  161. package/dist/internal/client-runtime.d.mts +5 -5
  162. package/dist/internal/client-runtime.d.ts +5 -5
  163. package/dist/internal/compression-runtime.d.mts +2 -1
  164. package/dist/internal/compression-runtime.d.ts +2 -1
  165. package/dist/internal/config-runtime.cjs +10 -9
  166. package/dist/internal/config-runtime.d.mts +6 -5
  167. package/dist/internal/config-runtime.d.ts +6 -5
  168. package/dist/internal/config-runtime.mjs +9 -8
  169. package/dist/internal/infra-analytics-runtime.cjs +8 -6
  170. package/dist/internal/infra-analytics-runtime.d.mts +8 -2
  171. package/dist/internal/infra-analytics-runtime.d.ts +8 -2
  172. package/dist/internal/infra-analytics-runtime.mjs +8 -6
  173. package/dist/internal/islands-action-client.cjs +18 -0
  174. package/dist/internal/islands-action-client.d.mts +18 -0
  175. package/dist/internal/islands-action-client.d.ts +18 -0
  176. package/dist/internal/islands-action-client.mjs +18 -0
  177. package/dist/internal/islands-boot.cjs +54 -20
  178. package/dist/internal/islands-boot.d.mts +5 -3
  179. package/dist/internal/islands-boot.d.ts +5 -3
  180. package/dist/internal/islands-boot.mjs +49 -15
  181. package/dist/internal/islands-runtime.cjs +3 -8
  182. package/dist/internal/islands-runtime.mjs +4 -9
  183. package/dist/internal/islx-actions-client.cjs +4 -3
  184. package/dist/internal/islx-actions-client.mjs +3 -2
  185. package/dist/internal/islx-actions-server.d.mts +0 -2
  186. package/dist/internal/islx-actions-server.d.ts +0 -2
  187. package/dist/internal/islx-client.cjs +13 -1
  188. package/dist/internal/islx-client.d.mts +11 -0
  189. package/dist/internal/islx-client.d.ts +11 -0
  190. package/dist/internal/islx-client.mjs +14 -0
  191. package/dist/internal/metadata-image-runtime.d.mts +1 -0
  192. package/dist/internal/metadata-image-runtime.d.ts +1 -0
  193. package/dist/internal/native-server-fns.cjs +4 -4
  194. package/dist/internal/native-server-fns.mjs +3 -3
  195. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  196. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  197. package/dist/internal/production-runtime.cjs +12 -7
  198. package/dist/internal/production-runtime.d.mts +14 -12
  199. package/dist/internal/production-runtime.d.ts +14 -12
  200. package/dist/internal/production-runtime.mjs +11 -6
  201. package/dist/internal/spa-router.d.mts +3 -3
  202. package/dist/internal/spa-router.d.ts +3 -3
  203. package/dist/internal/start-manifest.d.mts +2 -1
  204. package/dist/internal/start-manifest.d.ts +2 -1
  205. package/dist/markdown.d.mts +2 -1
  206. package/dist/markdown.d.ts +2 -1
  207. package/dist/middleware.d.mts +2 -1
  208. package/dist/middleware.d.ts +2 -1
  209. package/dist/mobile.d.mts +6 -3
  210. package/dist/mobile.d.ts +6 -3
  211. package/dist/{mount.d-DOaeUoWq.d.mts → mount.d-CZ_qL1iS.d.mts} +1 -1
  212. package/dist/{mount.d-DwXjaOHY.d.ts → mount.d-gWul1GA1.d.ts} +1 -1
  213. package/dist/{navigation-delegate.d-BElGUMgt.d.mts → navigation-delegate.d-BBTzhJLj.d.mts} +1 -1
  214. package/dist/{navigation-delegate.d-o3pPd9VI.d.ts → navigation-delegate.d-BZsYEAet.d.ts} +1 -1
  215. package/dist/navigation.d.mts +5 -5
  216. package/dist/navigation.d.ts +5 -5
  217. package/dist/{nitro-YLTGVGK4.mjs → nitro-FK3SZM4H.mjs} +1 -1
  218. package/dist/{nitro-XGIO6EQN.cjs → nitro-YDFMH5PY.cjs} +4 -4
  219. package/dist/{plugin-LN3JBZRR.cjs → plugin-3PT7I26P.cjs} +2 -2
  220. package/dist/{plugin-33I3V42N.mjs → plugin-QOTAPTVV.mjs} +1 -1
  221. package/dist/plugin.cjs +25 -23
  222. package/dist/plugin.d.mts +6 -6
  223. package/dist/plugin.d.ts +6 -6
  224. package/dist/plugin.mjs +24 -22
  225. package/dist/{render-plan.d-BD06tqFA.d.ts → render-plan.d-AaJsYPX-.d.ts} +1 -1
  226. package/dist/{render-plan.d-xWCRAJeR.d.mts → render-plan.d-bnWxS12w.d.mts} +1 -1
  227. package/dist/renderer-client.cjs +54 -10
  228. package/dist/renderer-client.d.mts +8 -7
  229. package/dist/renderer-client.d.ts +8 -7
  230. package/dist/renderer-client.mjs +50 -6
  231. package/dist/renderer.cjs +6 -2
  232. package/dist/renderer.d.mts +97 -4
  233. package/dist/renderer.d.ts +97 -4
  234. package/dist/renderer.mjs +5 -1
  235. package/dist/{request.d-Dx82V8bz.d.mts → request.d-C2HOn3Hi.d.mts} +1 -1
  236. package/dist/{request.d-DUMuWxSN.d.ts → request.d-CAeitOG1.d.ts} +1 -1
  237. package/dist/request.d.mts +3 -2
  238. package/dist/request.d.ts +3 -2
  239. package/dist/{route-rendering.d-BwBVpLtD.d.ts → route-rendering.d-A1dIkUK5.d.ts} +1 -1
  240. package/dist/{route-rendering.d-DJh6GauM.d.mts → route-rendering.d-CYA-ulnX.d.mts} +1 -1
  241. package/dist/{router.d-BtkKDxUB.d.mts → router.d-8lxnzlkr.d.mts} +1 -1
  242. package/dist/{router.d-CJBSG5jr.d.ts → router.d-A_Yt6jYz.d.ts} +1 -1
  243. package/dist/{routes.d-CCccJRrp.d.mts → routes.d-BWvpUoYu.d.mts} +1 -1
  244. package/dist/{routes.d-b7khoRoU.d.ts → routes.d-D7RWvfqL.d.ts} +1 -1
  245. package/dist/routes.d.mts +2 -1
  246. package/dist/routes.d.ts +2 -1
  247. package/dist/{rsc-pipeline-H5AXQA7A.cjs → rsc-pipeline-MFJZGDPE.cjs} +11 -10
  248. package/dist/{rsc-pipeline-GD6KLOIG.mjs → rsc-pipeline-TRZVFCBX.mjs} +10 -9
  249. package/dist/{runtime-YWQVBC3V.cjs → runtime-MJUG2HGR.cjs} +15 -13
  250. package/dist/{runtime-OJ7FXFUI.mjs → runtime-O4Y3Z6V3.mjs} +11 -9
  251. package/dist/{runtime.d-BQnD0cfC.d.ts → runtime.d-BPyvWrgQ.d.ts} +1 -1
  252. package/dist/{runtime.d-C4SuZXf6.d.mts → runtime.d-C_rZ9_DD.d.mts} +1 -1
  253. package/dist/{server-components-status.d-9rH7ZoEq.d.mts → server-components-status.d-BpxiEMQE.d.mts} +1 -1
  254. package/dist/{server-components-status.d-rfKOcE0N.d.ts → server-components-status.d-C2UEKJn7.d.ts} +1 -1
  255. package/dist/server-plugins.d.mts +4 -3
  256. package/dist/server-plugins.d.ts +4 -3
  257. package/dist/server-query-call.d-rVM_lsYk.d.mts +15 -0
  258. package/dist/server-query-call.d-rVM_lsYk.d.ts +15 -0
  259. package/dist/server-query-client.cjs +5 -3
  260. package/dist/server-query-client.d.mts +3 -2
  261. package/dist/server-query-client.d.ts +3 -2
  262. package/dist/server-query-client.mjs +5 -3
  263. package/dist/{server-query-runtime.d-DXRNhX_3.d.ts → server-query-runtime.d-BlHd90D0.d.ts} +2 -8
  264. package/dist/{server-query-runtime.d-aP52iuL5.d.mts → server-query-runtime.d-CCLGkQtE.d.mts} +2 -8
  265. package/dist/server.cjs +58 -52
  266. package/dist/server.d.mts +12 -12
  267. package/dist/server.d.ts +12 -12
  268. package/dist/server.mjs +34 -28
  269. package/dist/{spa-router.d-V6XLSTCy.d.mts → spa-router.d-BD-6WX1R.d.mts} +2 -2
  270. package/dist/{spa-router.d-DMKiBsHH.d.ts → spa-router.d-Cw5i_15e.d.ts} +2 -2
  271. package/dist/{ssg.d-MNedvvMB.d.ts → ssg.d-Bifiq0EL.d.ts} +2 -2
  272. package/dist/{ssg.d-BnCKPQL0.d.mts → ssg.d-CCE9aob5.d.mts} +2 -2
  273. package/dist/{store-core.d-Ad5biajo.d.ts → store-core.d-5tVn5vi1.d.ts} +12 -4
  274. package/dist/{store-core.d-BqJI1-ix.d.mts → store-core.d-BN2MxSG9.d.mts} +12 -4
  275. package/dist/testing.cjs +5 -4
  276. package/dist/testing.d.mts +2 -1
  277. package/dist/testing.d.ts +2 -1
  278. package/dist/testing.mjs +4 -3
  279. package/dist/{utils.d-BdjHKDuT.d.ts → utils.d-BUjpSNIO.d.ts} +1 -1
  280. package/dist/{utils.d-BEKLWa0Z.d.mts → utils.d-wGPLeVbq.d.mts} +1 -1
  281. package/dist/version.cjs +2 -2
  282. package/dist/version.mjs +1 -1
  283. package/dist/vite.cjs +25 -23
  284. package/dist/vite.d.mts +6 -6
  285. package/dist/vite.d.ts +6 -6
  286. package/dist/vite.mjs +24 -22
  287. package/package.json +7 -2
  288. package/dist/analyzer-435DCIQ6.cjs +0 -17
  289. package/dist/chunk-AHVF5GI2.cjs +0 -229
  290. package/dist/chunk-ONSZP5JK.mjs +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-S3IWDDQ3.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-POL5RCVU.mjs";
43
+ } from "./chunk-K3GHY7GY.mjs";
45
44
  import {
46
45
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
47
46
  createFarmDocsHandler,
@@ -63,9 +62,6 @@ import {
63
62
  import {
64
63
  CDN_CACHE_CONTROL_HEADERS
65
64
  } from "./chunk-UBLKPREL.mjs";
66
- import {
67
- FARM_PRERENDER_ENV
68
- } from "./chunk-IM3UINTZ.mjs";
69
65
  import {
70
66
  loadFarmDocsEngine
71
67
  } from "./chunk-LRPPXKCX.mjs";
@@ -74,7 +70,7 @@ import {
74
70
  getDeployTargetForPreset,
75
71
  hasCustomFarmRouteContext,
76
72
  resolveDeployOutputPath
77
- } from "./chunk-YH7ENV3K.mjs";
73
+ } from "./chunk-U56Z3755.mjs";
78
74
  import {
79
75
  resolveFarmInstrumentationFile
80
76
  } from "./chunk-QRNYSISP.mjs";
@@ -119,23 +115,23 @@ import {
119
115
  resolveFarmNotFoundComponentPath,
120
116
  resolveFarmRouteRootStrategy,
121
117
  toBakedMarkdownSourcePath
122
- } from "./chunk-IPG6B25T.mjs";
118
+ } from "./chunk-DPUZVGXH.mjs";
123
119
  import {
124
120
  TAILWIND_CSS_BROWSER_TARGET,
125
121
  generateFarmClientPluginEntryCode,
126
122
  hasFarmServerRuntimePlugins,
127
123
  includesTailwindVitePlugin,
128
124
  loadTailwindVitePlugin
129
- } from "./chunk-RPA45OQS.mjs";
125
+ } from "./chunk-MO4UTDQ6.mjs";
130
126
  import {
131
127
  PluginManager
132
- } from "./chunk-C2OLXVUC.mjs";
128
+ } from "./chunk-IVP5Q4BX.mjs";
133
129
  import {
134
130
  generateFarmTypeArtifacts,
135
131
  readRouteRenderingDirectiveFromFile,
136
132
  resolveRouteRenderingConfig,
137
133
  resolveRouteRenderingConfigFromFile
138
- } from "./chunk-TLSGRK7E.mjs";
134
+ } from "./chunk-IAIRQAHA.mjs";
139
135
  import {
140
136
  HOISTED_HEAD_ELEMENT,
141
137
  appMiddlewareMayHandlePath,
@@ -148,13 +144,17 @@ import {
148
144
  layoutsCanCoverSamePage,
149
145
  routeBoundaryCoversDirectory,
150
146
  stripRouteGroups
151
- } from "./chunk-OO4GVGM3.mjs";
147
+ } from "./chunk-CA2HBLXP.mjs";
152
148
  import {
153
149
  FARM_NATIVE_TREE_CONTENT_TYPE
154
150
  } from "./chunk-LLZSYFOM.mjs";
155
151
  import {
156
152
  farmPluginMayAffectRuntimePath
157
153
  } from "./chunk-UUMKLGUU.mjs";
154
+ import {
155
+ FARM_PRERENDER_ENV,
156
+ _farmWebMCPReportsEnabled
157
+ } from "./chunk-RNJX3MD6.mjs";
158
158
  import {
159
159
  FARM_API_CATALOG_PATH,
160
160
  FARM_APP_MANIFEST_LEGACY_PATH,
@@ -162,7 +162,7 @@ import {
162
162
  listFarmBuiltInRoutePaths,
163
163
  resolveFarmApiCatalogInput,
164
164
  resolveFarmAppManifestInput
165
- } from "./chunk-RZ6XUEQS.mjs";
165
+ } from "./chunk-VQ6IXALL.mjs";
166
166
  import {
167
167
  FARM_DEFAULT_MCP_PATH,
168
168
  createFarmDefaultMCPServer,
@@ -170,7 +170,7 @@ import {
170
170
  } from "./chunk-HR4N2K4V.mjs";
171
171
  import {
172
172
  isFarmPreviewDeploymentEnvironment
173
- } from "./chunk-GY63XD6K.mjs";
173
+ } from "./chunk-43N3X6OO.mjs";
174
174
  import {
175
175
  FARM_NATIVE_SERVER_FN_PLUGIN
176
176
  } from "./chunk-L4RTTTVE.mjs";
@@ -191,15 +191,20 @@ import {
191
191
  withFarmSourceSnapshot,
192
192
  withFarmSourceSnapshotOf,
193
193
  withPackageClientBoundaryCache
194
- } from "./chunk-HTNJ7A4D.mjs";
194
+ } from "./chunk-B5SJYXJK.mjs";
195
195
  import {
196
196
  generateFarmDocsAdapterClientRuntime,
197
197
  getFarmDocsAdapterConfigModule
198
- } from "./chunk-EJCVG25Z.mjs";
198
+ } from "./chunk-S3R4JDRO.mjs";
199
199
  import {
200
200
  resolveFarmDocsFontAssets,
201
201
  toFarmDocsPublicFontAssets
202
202
  } from "./chunk-NRNAHZ57.mjs";
203
+ import {
204
+ getFarmDocsAdapterRenderer,
205
+ getFarmDocsAdapterUIModule,
206
+ hasFarmDocsRuntimeAdapter
207
+ } from "./chunk-5V6HSJFG.mjs";
203
208
  import {
204
209
  nitroRouteRulesBelowBasePath,
205
210
  routeRulesToNitroRouteRules
@@ -223,14 +228,14 @@ import {
223
228
  isReactRenderer,
224
229
  loadFarmRendererVitePlugins,
225
230
  resolveFarmRendererAppSetup
226
- } from "./chunk-2HMSSPCZ.mjs";
231
+ } from "./chunk-RGTZAM6Y.mjs";
227
232
  import {
228
233
  applyFarmCronVercelCrons,
229
234
  createFarmCronCloudflareConfig,
230
235
  mergeScheduledTasks,
231
236
  prepareFarmCronForNitro,
232
237
  toFarmCronCloudflareScheduledTasks
233
- } from "./chunk-ATISIC6G.mjs";
238
+ } from "./chunk-7VJXYB6S.mjs";
234
239
  import {
235
240
  resolveServerActionsConfig
236
241
  } from "./chunk-NLATR3T3.mjs";
@@ -260,7 +265,7 @@ import {
260
265
  import {
261
266
  getFarmIntegrationPluginServerRuntime,
262
267
  getIntegrationProviders
263
- } from "./chunk-6JWXHPVR.mjs";
268
+ } from "./chunk-XRSNW4IU.mjs";
264
269
  import {
265
270
  FARM_INTEGRATION_API_BASE_PATH_KEY
266
271
  } from "./chunk-CZOXZ6WQ.mjs";
@@ -274,7 +279,7 @@ import {
274
279
  } from "./chunk-QD34VE4N.mjs";
275
280
  import {
276
281
  APIRouteManager
277
- } from "./chunk-6WVRVGKC.mjs";
282
+ } from "./chunk-NAHDG6UX.mjs";
278
283
  import {
279
284
  readFarmI18nCatalogs
280
285
  } from "./chunk-VO55MMBX.mjs";
@@ -302,7 +307,7 @@ import {
302
307
  } from "./chunk-2I6PUKWJ.mjs";
303
308
  import {
304
309
  FARM_VERSION
305
- } from "./chunk-D77OGI6X.mjs";
310
+ } from "./chunk-NKVBWPXR.mjs";
306
311
  import {
307
312
  FARM_VIDEO_PLAYER_PATH
308
313
  } from "./chunk-AG27TI6Q.mjs";
@@ -503,6 +508,7 @@ import path2 from "path";
503
508
  var FARM_CLIENT_CSS_HREF_PLACEHOLDER = "/__farm_client_css_href__";
504
509
  var FARM_CLIENT_JS_SRC_PLACEHOLDER = "/__farm_client_js_src__";
505
510
  var FARM_CLIENT_BOOT_SRC_PLACEHOLDER = "/__farm_client_boot_src__";
511
+ var FARM_CLIENT_STYLESHEET_PLACEHOLDER = "__farm_client_stylesheet__";
506
512
  async function hashAndCopy(sourcePath, destinationDir, hashedName) {
507
513
  const fs5 = await import("fs/promises");
508
514
  try {
@@ -526,6 +532,15 @@ async function resolveHashedClientCssHref(clientOutputDir) {
526
532
  );
527
533
  return name ? `/assets/${name}` : "/farm-client.css";
528
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
+ }
529
544
  async function findFingerprintedClientEntry(clientOutputDir) {
530
545
  const fs5 = await import("fs/promises");
531
546
  try {
@@ -797,13 +812,15 @@ function collectFarmClientModulePreloads(bundle, options) {
797
812
  ...staticImports(chunk, loaded, [])
798
813
  ].map(index);
799
814
  }
800
- const dynamicFiles = (moduleIds) => {
815
+ const dynamicFiles = (moduleIds, before = []) => {
801
816
  const into = [];
802
- const loaded = new Set(entryLoaded);
817
+ const loaded = /* @__PURE__ */ new Set([...entryLoaded, ...before]);
803
818
  for (const moduleId of moduleIds ?? []) {
819
+ const is = (id) => path4.resolve(id.split("?")[0]) === path4.resolve(moduleId);
804
820
  const chunk = chunks.find(
805
- (candidate) => candidate.isDynamicEntry && candidate.facadeModuleId && path4.resolve(candidate.facadeModuleId.split("?")[0]) === path4.resolve(moduleId)
806
- );
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));
807
824
  if (!chunk || loaded.has(chunk.fileName)) continue;
808
825
  loaded.add(chunk.fileName);
809
826
  into.push(chunk.fileName);
@@ -812,11 +829,15 @@ function collectFarmClientModulePreloads(bundle, options) {
812
829
  return into;
813
830
  };
814
831
  const rendererFiles = dynamicFiles(options.rendererModules);
832
+ const rootFiles = dynamicFiles(options.rootModules);
833
+ const actionFiles = dynamicFiles(options.actionModules, rendererFiles);
815
834
  return {
816
835
  files,
817
836
  entry: entryFiles.map(index),
818
837
  router: dynamicFiles(options.routerModules).map(index),
819
838
  ...rendererFiles.length > 0 ? { renderer: rendererFiles.map(index) } : {},
839
+ ...rootFiles.length > 0 ? { root: rootFiles.map(index) } : {},
840
+ ...actionFiles.length > 0 ? { actions: actionFiles.map(index) } : {},
820
841
  modules
821
842
  };
822
843
  }
@@ -825,15 +846,22 @@ function createFarmClientModulePreloadPlugin(options) {
825
846
  name: "farm-client-module-preloads",
826
847
  enforce: "post",
827
848
  async generateBundle(_output, bundle) {
828
- const rendererModules = [];
829
- for (const specifier of options.rendererImports ?? []) {
830
- const resolved = await this.resolve(specifier, options.rendererImporter);
831
- if (resolved) rendererModules.push(resolved.id);
832
- }
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);
833
859
  await fs.mkdir(options.buildDir, { recursive: true });
834
860
  await fs.writeFile(
835
861
  path4.join(options.buildDir, FARM_CLIENT_MODULE_PRELOADS_FILE),
836
- JSON.stringify(collectFarmClientModulePreloads(bundle, { ...options, rendererModules }))
862
+ JSON.stringify(
863
+ collectFarmClientModulePreloads(bundle, { ...options, rendererModules, actionModules })
864
+ )
837
865
  );
838
866
  }
839
867
  };
@@ -906,8 +934,10 @@ function resolveFarmDocsClientRoutes(pages, docsPagePaths) {
906
934
  function isStatic(segment) {
907
935
  return segment === "static";
908
936
  }
909
- function generateFarmClientRouteTableModule(table) {
910
- 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))});
911
941
  `;
912
942
  }
913
943
  async function writeFarmClientRouteTable(buildDir, table) {
@@ -3127,7 +3157,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3127
3157
  farmPlugin,
3128
3158
  farmServerOnlyEntriesPlugin
3129
3159
  } = await import("./vite.mjs");
3130
- const { PluginManager: PluginManager2 } = await import("./plugin-33I3V42N.mjs");
3160
+ const { PluginManager: PluginManager2 } = await import("./plugin-QOTAPTVV.mjs");
3131
3161
  const fs5 = await import("fs/promises");
3132
3162
  const pluginManager = new PluginManager2({
3133
3163
  config,
@@ -3169,9 +3199,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3169
3199
  const layoutAppliesToRoute = routeBoundaryCoversDirectory;
3170
3200
  const routeDirectory = (route) => route.directory ?? route.pattern;
3171
3201
  const islandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
3172
- const adapterOwnsDocsRuntime = Boolean(
3173
- isReactRenderer(config.renderer) && config.docs?.enabled && config.docs.adapter?.server && config.docs.adapter.react
3174
- );
3202
+ const adapterOwnsDocsRuntime = hasFarmDocsRuntimeAdapter(config.docs);
3175
3203
  const docsEntries = config.docs?.enabled ? getFarmDocsRoots(config.docs).map(
3176
3204
  (docsRoot) => `/${docsRoot.entry || "docs"}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/"
3177
3205
  ) : [];
@@ -3422,7 +3450,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3422
3450
  adapterOwnsDocsRuntime ? false : isFarmDocsSearchEnabled(config.docs),
3423
3451
  adapterOwnsDocsRuntime ? void 0 : resolveFarmDocsSearchClientModule(root),
3424
3452
  config.docs?.enabled ? getFarmDocsRoots(config.docs).map((docsRoot) => docsRoot.entry) : void 0,
3425
- adapterOwnsDocsRuntime ? config.docs.adapter?.react : void 0,
3453
+ adapterOwnsDocsRuntime ? getFarmDocsAdapterUIModule(config.docs.adapter) : void 0,
3426
3454
  config.i18n,
3427
3455
  config.plugins,
3428
3456
  config.renderer,
@@ -3443,15 +3471,20 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3443
3471
  ) : []
3444
3472
  );
3445
3473
  const entryName = platform === "mobile" ? FARM_MOBILE_CLIENT_ENTRY_NAME : "farm-client";
3446
- 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 };
3447
3475
  await fs5.writeFile(clientEntryPath, clientEntry.entry);
3448
3476
  await fs5.writeFile(
3449
3477
  path17.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`),
3450
- generateFarmClientRouteTableModule(clientRouteTable)
3478
+ generateFarmClientRouteTableModule(clientRouteTable, {
3479
+ matcher: islandsMode && platform !== "mobile"
3480
+ })
3451
3481
  );
3452
3482
  if (clientEntry.router !== void 0) {
3453
3483
  await fs5.writeFile(path17.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
3454
3484
  }
3485
+ if (clientEntry.root !== void 0) {
3486
+ await fs5.writeFile(path17.join(clientEntryDir, "farm-client-root.tsx"), clientEntry.root);
3487
+ }
3455
3488
  const clientInput = { [entryName]: clientEntryPath };
3456
3489
  if (platform === "web" && canBootFarmIslandsClient(config)) {
3457
3490
  const clientBootPath = path17.join(clientEntryDir, "farm-client-boot.tsx");
@@ -3547,6 +3580,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3547
3580
  path17.join(clientEntryDir, "farm-client-router.tsx"),
3548
3581
  path17.join(clientEntryDir, `${FARM_CLIENT_ROUTE_TABLE_MODULE}.tsx`)
3549
3582
  ],
3583
+ rootModules: [path17.join(clientEntryDir, "farm-client-root.tsx")],
3550
3584
  // What the islands entry loads with its first render or hydration (RFC 0010).
3551
3585
  ...islandsMode && isReactRenderer(config.renderer) ? {
3552
3586
  rendererImports: [
@@ -3554,6 +3588,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3554
3588
  "react-dom/client",
3555
3589
  "@farm.js/core/internal/islands-runtime"
3556
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"],
3557
3593
  rendererImporter: clientEntryPath
3558
3594
  } : {}
3559
3595
  }),
@@ -3564,7 +3600,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
3564
3600
  importer: clientEntryPath,
3565
3601
  entryName: "farm-client",
3566
3602
  modules: [
3567
- config.docs.adapter.react,
3603
+ getFarmDocsAdapterUIModule(config.docs.adapter),
3568
3604
  getFarmDocsAdapterConfigModule(config.docs)
3569
3605
  ].filter((specifier) => Boolean(specifier))
3570
3606
  })
@@ -3840,18 +3876,27 @@ function loadFarmClientRouteTable() { return null; }
3840
3876
  function prefetchFarmClientRouteTable() {}
3841
3877
  const farmClientRoutesBoot = null;`;
3842
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
+ }`;
3843
3884
  return `${prefetch}
3844
3885
  let clientRoutes = [];
3845
- let clientRouteMatcher = createFarmRouter([]);
3846
- 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;`}
3847
3895
  let farmClientRouteTableLoad = null;
3848
3896
  let farmClientRouteTableLoaded = false;
3849
3897
 
3850
3898
  function setFarmClientRoutes(routes) {
3851
- clientRoutes = routes.map(function(route) {
3852
- const load = typeof route.loader === "number" ? farmClientRouteLoaders[route.loader] : undefined;
3853
- return { ...route, navigation: "html-fragment", load: load || null };
3854
- });
3899
+ clientRoutes = routes.map(${lazy ? "toFarmClientRoute" : toClientRoute});
3855
3900
  clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
3856
3901
  return { path: route.pattern, meta: route };
3857
3902
  }));
@@ -3861,12 +3906,27 @@ function setFarmClientRoutes(routes) {
3861
3906
  return { path: route.pattern, meta: route };
3862
3907
  }))` : "clientRouteMatcher"};
3863
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
+ }
3864
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
+ ` : ""}
3865
3922
  // Null once the whole table is in place, else a promise that settles when it is.
3866
3923
  function loadFarmClientRouteTable() {
3867
3924
  if (farmClientRouteTableLoaded) return null;
3868
3925
  return farmClientRouteTableLoad || (farmClientRouteTableLoad = import("./${FARM_CLIENT_ROUTE_TABLE_MODULE}").then(function(module) {
3869
- setFarmClientRoutes(module.default);
3926
+ ${lazy ? ` createFarmRouter = module.createFarmRouter;
3927
+ isFarmRouteActive = module.isFarmRouteActive;
3928
+ matchFarmRoute = module.matchFarmRoute;
3929
+ ` : ""} setFarmClientRoutes(module.default);
3870
3930
  farmClientRouteTableLoaded = true;
3871
3931
  }, function(error) {
3872
3932
  farmClientRouteTableLoad = null;
@@ -3882,8 +3942,9 @@ function prefetchFarmClientRouteTable() {
3882
3942
 
3883
3943
  const farmClientRoutesBoot = (function() {
3884
3944
  const boot = window.__FARM_CLIENT_ROUTES__;
3885
- if (boot && Array.isArray(boot.routes) && boot.path === getFarmRoutePathname(window.location.pathname)) {
3886
- 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);"}
3887
3948
  return null;
3888
3949
  }
3889
3950
  return loadFarmClientRouteTable().catch(function(error) {
@@ -3906,7 +3967,75 @@ for (const type of FARM_ROUTE_TABLE_INTENT_EVENTS) {
3906
3967
  document.addEventListener(type, warmFarmClientRouteTable, { capture: true, passive: true });
3907
3968
  }`;
3908
3969
  }
3909
- 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) {
3910
4039
  return `// The client route table (client-route-table.ts), filled in from the client build. The client
3911
4040
  // loads it on its first navigation; a document names the entries its page boots with, found
3912
4041
  // with the client's own matcher, so its page hydrates without the table.
@@ -3926,18 +4055,40 @@ const farmClientRouteTable = (() => {
3926
4055
  return null;
3927
4056
  }
3928
4057
  })();
3929
-
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
+ ` : ""}
3930
4076
  // The entries the client's matchRoute and getFarmPageDirectory read for this route path.
3931
4077
  function getFarmClientBootRoutes(routePathname) {
3932
4078
  if (!farmClientRouteTable || typeof routePathname !== "string") return undefined;
3933
4079
  const routes = [];
3934
4080
  const matched = farmClientRouteTable.routes.match(routePathname);
4081
+ const page = matched && matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
3935
4082
  if (matched) {
3936
4083
  routes.push(matched.route.meta);
3937
- const page = matched.route.meta.docs ? farmClientRouteTable.pages.match(routePathname) : null;
3938
4084
  if (page) routes.push(page.route.meta);
3939
4085
  }
3940
- 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)" : ""} };
3941
4092
  }`;
3942
4093
  }
3943
4094
  function generateClientPageDirectorySource() {
@@ -4833,40 +4984,82 @@ function readFarmEntryImports(source) {
4833
4984
  }
4834
4985
  return bindings;
4835
4986
  }
4836
- 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) {
4837
5005
  const regions = [];
4838
- const eager = code.replace(
4839
- /\/\*farm-router-start\*\/([\s\S]*?)\/\*farm-router-end\*\/\n?/g,
4840
- (_, body2) => {
4841
- 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);
4842
5010
  return "";
4843
5011
  }
4844
5012
  );
4845
- const body = regions.join("\n");
4846
- const moved = readFarmEntryDeclarations(body);
4847
- 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
+ };
4848
5028
  const eagerCode = eager.replace(/^import\s[^;]*;/gm, "");
4849
5029
  const usedByEntry = (name) => bindingPattern(name).test(eagerCode);
4850
- const bindings = readFarmEntryImports(eager).filter((binding) => usedByRouter(binding.local));
4851
- const imports = bindings.filter((binding) => !usedByEntry(binding.local));
4852
- const reexported = bindings.filter((binding) => usedByEntry(binding.local)).map((binding) => binding.local);
4853
- const shared = [
4854
- .../* @__PURE__ */ new Set([
4855
- ...reexported,
4856
- ...[...readFarmEntryDeclarations(eager)].filter((name) => usedByRouter(name))
4857
- ])
4858
- ];
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
+ }
4859
5055
  return {
4860
5056
  entry: `${eager.replace("/*farm-router-stub*/", FARM_LAZY_ROUTER_STUB)}
4861
- export { ${shared.join(", ")} };
5057
+ export { ${[...fromEntry].join(", ")} };
4862
5058
  `,
4863
- router: [
4864
- ...imports.map((binding) => `import ${binding.clause} from ${binding.from};`),
4865
- `import { ${shared.join(", ")} } from "./farm-client-entry";`,
4866
- body,
4867
- "export { spaRouter };",
4868
- ""
4869
- ].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
4870
5063
  };
4871
5064
  }
4872
5065
  var FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME = `
@@ -4896,7 +5089,7 @@ var FARM_DOCUMENT_PARSED_RUNTIME = `function farmDocumentParsed() {
4896
5089
  }
4897
5090
 
4898
5091
  `;
4899
- 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 = {
4900
5093
  enabled: false,
4901
5094
  basePath: "/",
4902
5095
  locales: ["en"],
@@ -4925,6 +5118,8 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
4925
5118
  );
4926
5119
  const appSetupPath = resolveFarmRendererAppSetup(root, renderer);
4927
5120
  const lazyRenderer = islandValues && platform !== "mobile" && isReactRenderer(renderer) && clientRouteSlots.length === 0;
5121
+ const lazyRoot = islandValues && platform !== "mobile";
5122
+ const lazyMatcher = lazyRoot && clientPages.length > 0;
4928
5123
  const rendererClientImports = lazyRenderer ? `import { holdFarmIslandInteractions, restorePagePosition, watchFarmIslandTriggers } from "@farm.js/core/internal/client-runtime";` : isReactRenderer(renderer) ? `import React from "react";
4929
5124
  import { createRoot, hydrateRoot } from "react-dom/client";
4930
5125
  import { restorePagePosition } from "@farm.js/core/internal/client-runtime";` : (
@@ -4938,6 +5133,7 @@ __farmConfigureApp(__farmAppSetup);` : `import * as __farmRendererClient from ${
4938
5133
  import { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};
4939
5134
  const React = { ...__farmRendererClient };`
4940
5135
  );
5136
+ const hydrateFarmRouteCall = isReactRenderer(renderer) ? "return hydrateRoot(container, route.element);" : "return route.layouts.length > 0 ? hydrateRoot(container, route.element, route) : hydrateRoot(container, route.element);";
4941
5137
  const providerClientCode = generateFarmIntegrationProviderClientCode(
4942
5138
  integrationProviders,
4943
5139
  root,
@@ -4960,6 +5156,7 @@ const React = { ...__farmRendererClient };`
4960
5156
  ).join("\n");
4961
5157
  const layoutImportStatements = [];
4962
5158
  const layoutRegistrations = [];
5159
+ const layoutComponents = [];
4963
5160
  const hydratingLayoutPatterns = layoutRoutes.filter((layout) => layout.shouldHydrate).map((layout) => layout.pattern);
4964
5161
  const treeLayoutPatterns = islandValues ? getFarmServerTreeLayoutPatterns(layoutRoutes) : /* @__PURE__ */ new Set();
4965
5162
  layoutRoutes.forEach((layout, index) => {
@@ -4971,13 +5168,23 @@ const React = { ...__farmRendererClient };`
4971
5168
  if (rendersOnClient && !treeLayout) {
4972
5169
  layoutImportStatements.push(`import Layout${index} from "${relativePath}";`);
4973
5170
  }
4974
- const groupScope = getRouteGroupScope(layout.pattern);
4975
- 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);
4976
5175
  layoutRegistrations.push(
4977
- ` { 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" : ""} }`
4978
5177
  );
4979
5178
  });
4980
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
+ ` : "";
4981
5188
  const hasServerTreeLayouts = treeLayoutPatterns.size > 0;
4982
5189
  const i18nRoutingConfig = {
4983
5190
  locales: i18nConfig.locales,
@@ -5034,8 +5241,10 @@ function isFarmDocsPath() {
5034
5241
  }
5035
5242
  `;
5036
5243
  const docsAdapterRuntime = generateFarmDocsAdapterClientRuntime(
5037
- docsAdapterReact,
5038
- 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
5039
5248
  );
5040
5249
  if (clientPages.length === 0 && clientRouteSlots.length === 0 && !providerClientCode.hasProviders) {
5041
5250
  return `
@@ -5212,11 +5421,12 @@ ${generateUniversalRouterStateProperties()}
5212
5421
 
5213
5422
  reconcileFarmDocumentHead(doc);
5214
5423
 
5215
- // Swap root content
5424
+ // Swap root content: the parsed nodes themselves, not markup the page parses again.
5216
5425
  const newRoot = doc.getElementById("root");
5217
5426
  const currentRoot = document.getElementById("root");
5218
5427
  if (!newRoot || !currentRoot) return this.swapDocument(doc);
5219
- currentRoot.innerHTML = newRoot.innerHTML;
5428
+ adoptFarmParsedNodes(newRoot);
5429
+ currentRoot.replaceChildren(...newRoot.childNodes);
5220
5430
  return true;
5221
5431
  },
5222
5432
 
@@ -5233,7 +5443,8 @@ ${generateUniversalRouterStateProperties()}
5233
5443
  });
5234
5444
 
5235
5445
  document.head.innerHTML = doc.head ? doc.head.innerHTML : "";
5236
- document.body.innerHTML = doc.body.innerHTML;
5446
+ adoptFarmParsedNodes(doc.body);
5447
+ document.body.replaceChildren(...doc.body.childNodes);
5237
5448
  delete window.__farmDocsRuntime;
5238
5449
  delete window.__farmDocsPageActionsRuntime;
5239
5450
 
@@ -5494,6 +5705,7 @@ async function hydrateFarmIsolatedClientBoundaries(scope = document, signal) {
5494
5705
  await farmIsolatedHydrationRuntime.hydrate(scope, signal);
5495
5706
  }
5496
5707
  ${serverTreeEnabled ? `
5708
+ /*farm-root-start*/
5497
5709
  // A server-tree page (an async page below a hydrating layout) rebuilds in the layout's root.
5498
5710
  async function createFarmServerTreePageElement(source, pathname) {
5499
5711
  try {
@@ -5507,7 +5719,10 @@ async function createFarmServerTreePageElement(source, pathname) {
5507
5719
  console.warn("[Farm.js] Could not rebuild the server tree of " + pathname + "; its server HTML was kept.", error);
5508
5720
  return null;
5509
5721
  }
5510
- }` : "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*/`;
5511
5726
  const routeClientGraphRuntime = isolatedHydrationEnabled ? `function wrapFarmRouteClientGraph(element) {
5512
5727
  return wrapFarmIsolatedClientGraph(React, element);
5513
5728
  }` : `function wrapFarmRouteClientGraph(element) { return element; }`;
@@ -5527,13 +5742,13 @@ async function createFarmServerTreePageElement(source, pathname) {
5527
5742
  return `
5528
5743
  // Farm.js Client Runtime - SPA with Hydration
5529
5744
  ${cssImport}
5530
- ${layoutImports}
5745
+ ${lazyRoot ? "" : layoutImports}
5531
5746
  ${rendererClientImports}
5532
5747
  ${isolatedHydrationImport}
5533
5748
  ${providerClientCode.imports}
5534
- import { createClientCancellation, createClientPluginManager, createPluginlessClientRuntime, getFarmIslandValueHeaders, getHashTargetElement, keepFarmIslandValues, installChunkErrorRecovery, installFarmLinkPrefetch, isFarmBlockedNavigationURL, isFarmExternalNavigationURL, readFarmLinkNavigateOptions, rememberFarmLinkLocale, reconcileFarmDocumentHead, runFarmNavigationDelegates, scheduleFarmIslandHydration, createFarmSearchParams, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from "@farm.js/core/internal/client-runtime";
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";
5535
5750
  import { createFarmDeploymentMismatchError, createFarmDeploymentRequestHeaders, isFarmDeploymentMismatchResponse } from "@farm.js/core/deployment";
5536
- import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";
5751
+ ${lazyMatcher ? "" : 'import { createFarmRouter, isFarmRouteActive, matchFarmRoute } from "@farm.js/core/router";'}
5537
5752
  ${clientPluginEntry.imports}
5538
5753
  ${clientCachePersistence.imports}
5539
5754
  ${i18nClientRuntime}
@@ -5557,7 +5772,8 @@ ${routeLoaders.join("\n")}
5557
5772
  ${generateFarmClientRouteTableRuntime({
5558
5773
  table: clientPages.length > 0,
5559
5774
  docs: clientPages.some((page) => page.docs),
5560
- streamNavigations: islandValues
5775
+ streamNavigations: islandValues,
5776
+ lazyMatcher
5561
5777
  })}
5562
5778
  ${generateClientPageDirectorySource()}
5563
5779
 
@@ -5573,43 +5789,9 @@ const layoutRoutes = [
5573
5789
  ${layoutRegistrations.join(",\n")}
5574
5790
  ];
5575
5791
 
5576
- // Get applicable layouts for a pathname (sorted by depth, root first)
5577
- function getApplicableLayouts(pathname) {
5578
- const applicable = [];
5579
- const normalizedPath = getFarmRoutePathname(pathname).replace(/\\/$/, '') || '/';
5580
- let directory;
5581
-
5582
- for (const layout of layoutRoutes) {
5583
- // Route groups add no URL segment: match the layout's URL, then keep a
5584
- // grouped layout to the pages inside its group directory.
5585
- const urlPattern = layout.urlPattern || layout.pattern;
5586
- if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, normalizedPath, { exact: false })) continue;
5587
- if (layout.groupScope) {
5588
- if (directory === undefined) directory = getFarmPageDirectory(pathname);
5589
- if (
5590
- typeof directory !== 'string' ||
5591
- (directory !== layout.groupScope && !directory.startsWith(layout.groupScope + '/'))
5592
- ) continue;
5593
- }
5594
- applicable.push(layout);
5595
- }
5596
-
5597
- // Sort by depth (root first)
5598
- applicable.sort(function(a, b) {
5599
- const depthA = a.pattern.split('/').filter(Boolean).length;
5600
- const depthB = b.pattern.split('/').filter(Boolean).length;
5601
- return depthA - depthB;
5602
- });
5603
-
5604
- return applicable;
5605
- }
5606
-
5607
- function hasHydratableLayout(pathname) {
5608
- return getApplicableLayouts(pathname).some(function(layout) {
5609
- return layout.shouldHydrate === true;
5610
- });
5611
- }
5792
+ ${generateFarmClientRouteMatchSource({ lazyMatcher })}
5612
5793
 
5794
+ ${layoutComponentsRuntime}/*farm-root-start*/
5613
5795
  ${FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
5614
5796
  // Wrap a page element with applicable layouts
5615
5797
  function wrapWithLayouts(pageElement, pathname, params) {
@@ -5675,15 +5857,9 @@ function prepareFarmTreeLayouts(pathname, params, source) {
5675
5857
  );
5676
5858
  }` : `function farmTreeLayoutsReady() { return true; }
5677
5859
  async function prepareFarmTreeLayouts() { return true; }`}
5860
+ /*farm-root-end*/
5678
5861
 
5679
- // Match pathname to client route
5680
- function matchRoute(pathname) {
5681
- const matched = clientRouteMatcher.match(getFarmRoutePathname(pathname));
5682
- return matched
5683
- ? { route: matched.route.meta, params: matched.params }
5684
- : null;
5685
- }
5686
-
5862
+ /*farm-root-start*/
5687
5863
  async function loadRouteComponent(route) {
5688
5864
  if (!route.load) return null;${lazyRenderer ? `
5689
5865
  // A page component renders with React DOM, which loads beside it (RFC 0010).
@@ -5795,7 +5971,16 @@ function createFarmRouteState(page, pathname, params, includeLayouts) {
5795
5971
 
5796
5972
  function hydrateFarmRoute(container, route) {
5797
5973
  farmLastRouteState = route;
5798
- ${isReactRenderer(renderer) ? "return hydrateRoot(container, route.element);" : "return route.layouts.length > 0 ? hydrateRoot(container, route.element, route) : hydrateRoot(container, route.element);"}
5974
+ ${getFarmRendererCapabilities(renderer).hydrationFallback ? `try {
5975
+ ${hydrateFarmRouteCall}
5976
+ } catch (error) {
5977
+ // The renderer opted in with capabilities.hydrationFallback, as development always does. The
5978
+ // page still works, but the server's DOM, focus, and typed input are gone, so say so.
5979
+ console.error("[Farm.js] Hydration error; rendering the page on the client instead:", error);
5980
+ const root = createRoot(container);
5981
+ renderFarmRoute(root, route);
5982
+ return root;
5983
+ }` : hydrateFarmRouteCall}
5799
5984
  }
5800
5985
 
5801
5986
  function renderFarmRoute(root, route) {
@@ -5803,6 +5988,7 @@ function renderFarmRoute(root, route) {
5803
5988
  if (route.layouts.length > 0 && typeof root.renderRoute === "function") root.renderRoute(route);
5804
5989
  else root.render(route.element);
5805
5990
  }
5991
+ /*farm-root-end*/
5806
5992
 
5807
5993
  /*farm-router-start*/
5808
5994
  function matchesRoutePrefix(pathname, pattern) {
@@ -5953,6 +6139,26 @@ function renderClientRouteSlot(slot, registration, mode) {
5953
6139
  return true;
5954
6140
  }
5955
6141
 
6142
+ // The document's pre-hydration hold keeps clicks and submits until what they target hydrates, as in
6143
+ // development. A hydrated route slot stops holding its own and replays what it held, as the page's
6144
+ // scheduler does for the page.
6145
+ function replayPreHydrationClicks(container) {
6146
+ container.dataset.farmIslandHydrated = "true";
6147
+ const queue = Array.isArray(window.__FARM_PREHYDRATION_CLICK_QUEUE__)
6148
+ ? window.__FARM_PREHYDRATION_CLICK_QUEUE__
6149
+ : [];
6150
+ const held = queue.filter(function(item) {
6151
+ return item && item.target instanceof Element && container.contains(item.target);
6152
+ });
6153
+ if (held.length === 0) return;
6154
+ queue.splice(0, queue.length, ...queue.filter(function(item) { return held.indexOf(item) === -1; }));
6155
+ for (const item of held) {
6156
+ setTimeout(function() {
6157
+ if (item.target.isConnected) replayFarmQueuedInteraction(item.target, item.kind);
6158
+ }, 0);
6159
+ }
6160
+ }
6161
+
5956
6162
  function hydrateInitialRouteSlots() {
5957
6163
  const slots = Array.isArray(window.__FARM_ROUTE_SLOTS__)
5958
6164
  ? window.__FARM_ROUTE_SLOTS__
@@ -5961,7 +6167,9 @@ function hydrateInitialRouteSlots() {
5961
6167
  const registration = findClientRouteSlot(slot);
5962
6168
  if (!registration) continue;
5963
6169
  try {
5964
- renderClientRouteSlot(slot, registration, "hydrate");
6170
+ if (renderClientRouteSlot(slot, registration, "hydrate")) {
6171
+ replayPreHydrationClicks(document.getElementById(slot.containerId));
6172
+ }
5965
6173
  } catch (error) {
5966
6174
  console.warn("[Farm.js] Could not hydrate route slot:", slot.name, error);
5967
6175
  }
@@ -6030,6 +6238,15 @@ function setFarmHydrated() {
6030
6238
  isHydrated = true;
6031
6239
  }
6032
6240
 
6241
+ // The document's head script holds clicks and submits until the page hydrates. Once the first
6242
+ // hydration settles it holds nothing more, as in development: each root that hydrated replayed
6243
+ // what it held, and a navigation's page renders in a React root that takes its own clicks.
6244
+ function markFarmHydrated() {
6245
+ if (window.__FARM_HYDRATED__ !== false) return;
6246
+ window.__FARM_HYDRATED__ = true;
6247
+ document.documentElement.dataset.farmHydrated = "true";
6248
+ }
6249
+
6033
6250
  ${generateUniversalRouterStateRuntime(islandValues)}
6034
6251
 
6035
6252
  function cancelPendingPageHydration() {
@@ -6155,7 +6372,10 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6155
6372
  }
6156
6373
  const searchParams = searchParamsToObject(new URLSearchParams(window.location.search));
6157
6374
  const shouldHydrate = !isHydrated && Boolean(container.innerHTML.trim());
6158
- 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(
6159
6379
  matched,
6160
6380
  pathname,
6161
6381
  searchParams,
@@ -6175,7 +6395,7 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6175
6395
  // navigation, that is not a failure, so error hooks never see it.
6176
6396
  if (hydrationController.signal.aborted || !container.isConnected) return;
6177
6397
  if (shouldHydrate) {
6178
- reactRoot = hydrateFarmRoute(container, routeState);
6398
+ reactRoot = farmRoot.hydrateFarmRoute(container, routeState);
6179
6399
  reactRootContainer = container;
6180
6400
  isHydrated = true;
6181
6401
  } else {
@@ -6183,7 +6403,7 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6183
6403
  reactRoot = createRoot(container);
6184
6404
  reactRootContainer = container;
6185
6405
  }
6186
- renderFarmRoute(reactRoot, routeState);
6406
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6187
6407
  }
6188
6408
  await farmClientRuntime.completeHydration(hydrationSession);
6189
6409
  } catch (error) {
@@ -6198,6 +6418,14 @@ function scheduleFarmRouteHydration(matched, pathname, container, serverProps) {
6198
6418
  });
6199
6419
  }
6200
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
+
6201
6429
  /*farm-router-start*/
6202
6430
  // A layout boundary is the same layout when its key matches: islands mode keys it by pattern and
6203
6431
  // params, so a layout whose params change renders again. Other modes compare patterns.
@@ -6271,9 +6499,12 @@ async function streamFarmNavigation(stream, root, isCurrent) {
6271
6499
  for (let flush = await stream.next(); flush !== null; flush = await stream.next()) {
6272
6500
  if (!isCurrent()) return stream.cancel();
6273
6501
  html += flush;
6274
- const parsed = new DOMParser().parseFromString('<div id="root">' + flush, "text/html");
6502
+ const parsed = new DOMParser()
6503
+ .parseFromString('<div id="root">' + flush, "text/html")
6504
+ .getElementById("root");
6505
+ adoptFarmParsedNodes(parsed);
6275
6506
  const fragment = document.createDocumentFragment();
6276
- for (const node of Array.from(parsed.getElementById("root").childNodes)) fragment.appendChild(node);
6507
+ for (const node of Array.from(parsed.childNodes)) fragment.appendChild(node);
6277
6508
  activateNavigationScripts(fragment);
6278
6509
  root.appendChild(fragment);
6279
6510
  }
@@ -6369,6 +6600,8 @@ ${islandValues ? FARM_REFRESH_FIELDS_SOURCE : ""}function replaceSharedLayoutBou
6369
6600
  ${isolatedHydrationEnabled ? `${islandValues ? `// A refresh keeps the islands still on the page, with their state and new props.
6370
6601
  if (refresh) farmIsolatedHydrationRuntime.carryOver(currentTarget, nextTarget);
6371
6602
  ` : ""}disposeFarmIsolatedClientBoundaries(currentTarget);` : ""}
6603
+ // After the comparison: a noscript turned to text serializes escaped in the parsed document.
6604
+ adoptFarmParsedNodes(nextRoot);
6372
6605
  currentTarget.replaceWith(nextTarget);${islandValues ? "\n if (fields) restoreFarmServerFields(fields, nextTarget);" : ""}
6373
6606
  activateNavigationScripts(nextTarget);
6374
6607
  if (nextTreeRoot && nextTreeRoot !== nextTarget) nextTreeRoot.remove();
@@ -6468,6 +6701,14 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6468
6701
  }
6469
6702
  const pathname = url.pathname;
6470
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
+ }
6471
6712
  const from = this.currentPath;
6472
6713
  if (await this.shouldBlockNavigation({ from, to, action })) {
6473
6714
  if (action === "pop") this.revertBlockedPopState(from);
@@ -6557,23 +6798,22 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6557
6798
  }
6558
6799
  }
6559
6800
 
6560
- if (
6561
- !options.refresh &&
6562
- matched?.route.navigation === "client-render" &&
6563
- farmTreeLayoutsReady(pathname, matched.params)
6564
- ) {
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)) {
6565
6805
  // Navigation itself signals intent, so destination routes load eagerly even
6566
6806
  // when their initial document hydration strategy is deferred.
6567
- const Component = await loadRouteComponent(matched.route);
6807
+ const Component = await farmRoot.loadRouteComponent(matched.route);
6568
6808
  if (!this.isCurrentNavigation(navigation, clientNavigation)) return;
6569
6809
  const params = matched.params;
6570
6810
  const searchParams = searchParamsToObject(url.searchParams);
6571
6811
  const props = { params: params, searchParams: createFarmSearchParams(searchParams) };
6572
6812
  let pageElement = React.createElement(Component, props);
6573
6813
  if (hasHydratableLayout(pathname)) {
6574
- pageElement = createLayoutPageBoundary(matched.route, pageElement);
6814
+ pageElement = farmRoot.createLayoutPageBoundary(matched.route, pageElement);
6575
6815
  }
6576
- const routeState = createFarmRouteState(
6816
+ const routeState = farmRoot.createFarmRouteState(
6577
6817
  pageElement,
6578
6818
  pathname,
6579
6819
  params,
@@ -6596,7 +6836,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6596
6836
  if (!reactRoot) {
6597
6837
  setFarmReactRoot(createRoot(container), container);
6598
6838
  }
6599
- renderFarmRoute(reactRoot, routeState);
6839
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6600
6840
  }
6601
6841
  this.currentPath = to;
6602
6842
  });
@@ -6744,12 +6984,22 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6744
6984
  const matched = matchRoute(newPathname);
6745
6985
  const hydrateLayouts = hasHydratableLayout(newPathname);
6746
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;
6747
6997
 
6748
6998
  // If React already owns the shared layout, update that root. React keeps
6749
6999
  // matching layout component instances and their state mounted.
6750
- if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot) {
7000
+ if (matched && hydrateLayouts && reactRoot && reactRootContainer === currentRoot && farmRoot) {
6751
7001
  const searchParams = searchParamsToObject(targetUrl.searchParams);
6752
- const routeState = await createMatchedHydrationRoute(
7002
+ const routeState = await farmRoot.createMatchedHydrationRoute(
6753
7003
  matched,
6754
7004
  newPathname,
6755
7005
  searchParams,
@@ -6759,7 +7009,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6759
7009
  );
6760
7010
  if (!isNavigationCurrent()) return false;
6761
7011
  if (routeState) {
6762
- renderFarmRoute(reactRoot, routeState);
7012
+ farmRoot.renderFarmRoute(reactRoot, routeState);
6763
7013
  window.__FARM_ROUTE_SLOTS__ = nextRouteSlots;
6764
7014
  setFarmHydrated();
6765
7015
  return true;
@@ -6781,7 +7031,9 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6781
7031
  ${islandValues ? 'if (!replacedSharedBoundary && isSegment) return "segment-mismatch";' : ""}
6782
7032
  if (!replacedSharedBoundary) {
6783
7033
  ${isolatedHydrationEnabled ? "disposeFarmIsolatedClientBoundaries(currentRoot);" : ""}
6784
- currentRoot.innerHTML = newRoot.innerHTML;
7034
+ // The parsed nodes themselves, not markup the page parses again.
7035
+ adoptFarmParsedNodes(newRoot);
7036
+ currentRoot.replaceChildren(...newRoot.childNodes);
6785
7037
  activateNavigationScripts(currentRoot);
6786
7038
  isolatedHydrationScope = currentRoot;
6787
7039
  }
@@ -6806,7 +7058,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6806
7058
  );
6807
7059
  } else {
6808
7060
  const searchParams = searchParamsToObject(targetUrl.searchParams);
6809
- 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(
6810
7063
  matched,
6811
7064
  newPathname,
6812
7065
  searchParams,
@@ -6817,7 +7070,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6817
7070
  );
6818
7071
  if (!isNavigationCurrent()) return false;
6819
7072
  if (routeState) {
6820
- setFarmReactRoot(hydrateFarmRoute(pageContainer, routeState), pageContainer);
7073
+ setFarmReactRoot(farmRoot.hydrateFarmRoute(pageContainer, routeState), pageContainer);
6821
7074
  setFarmHydrated();
6822
7075
  }
6823
7076
  }
@@ -6863,7 +7116,8 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
6863
7116
  });
6864
7117
 
6865
7118
  document.head.innerHTML = doc.head ? doc.head.innerHTML : "";
6866
- document.body.innerHTML = doc.body.innerHTML;
7119
+ adoptFarmParsedNodes(doc.body);
7120
+ document.body.replaceChildren(...doc.body.childNodes);
6867
7121
  delete window.__farmDocsRuntime;
6868
7122
  delete window.__farmDocsPageActionsRuntime;
6869
7123
 
@@ -6982,7 +7236,7 @@ document.addEventListener("click", function(e) {
6982
7236
  if (isFarmDocsSearchPage()) {
6983
7237
  mountFarmDocsSearch();
6984
7238
  }
6985
- void hydrate();
7239
+ void hydrate().finally(markFarmHydrated);
6986
7240
  `.trim();
6987
7241
  }
6988
7242
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime, sourceSnapshot) {
@@ -6993,7 +7247,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6993
7247
  farmPlugin,
6994
7248
  farmServerOnlyEntriesPlugin
6995
7249
  } = await import("./vite.mjs");
6996
- const { PluginManager: PluginManager2 } = await import("./plugin-33I3V42N.mjs");
7250
+ const { PluginManager: PluginManager2 } = await import("./plugin-QOTAPTVV.mjs");
6997
7251
  const fs5 = await import("fs/promises");
6998
7252
  const pluginManager = new PluginManager2({
6999
7253
  config,
@@ -7121,7 +7375,11 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
7121
7375
  }))
7122
7376
  );
7123
7377
  const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
7124
- const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
7378
+ const notFoundPath = resolveFarmNotFoundComponentPath(
7379
+ config,
7380
+ appDirs,
7381
+ routeManager.getRendererNotFoundPath()
7382
+ );
7125
7383
  if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
7126
7384
  layoutRoutes.sort((a, b) => {
7127
7385
  const depthA = a.pattern.split("/").filter(Boolean).length;
@@ -7788,7 +8046,7 @@ function getFarmBufferedPreloadMarker(html) {
7788
8046
  // Prove eligibility while Farm still owns the complete document string.
7789
8047
  // Candidate-bearing or unknown bodies must retain the full parser path.
7790
8048
  // Response.text() strips a leading UTF-8 BOM; retain that legacy behavior.
7791
- return typeof html === "string" && html.charCodeAt(0) !== 0xfeff && !/\\bpreload\\b/i.test(html) ? "none" : "1";
8049
+ return typeof html === "string" && html.charCodeAt(0) !== 0xfeff && !hasFarmHtmlPreloadToken(html) ? "none" : "1";
7792
8050
  }
7793
8051
 
7794
8052
  async function applyFarmPreloadBudget(response, pathname, request) {
@@ -7880,7 +8138,7 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
7880
8138
  const farmClientBoot = canBootFarmIslandsClient(config);
7881
8139
  const farmMobileClient = shouldBuildFarmMobileClient(config);
7882
8140
  const farmMobileShells = farmMobileClient && config.mobileShells ? config.mobileShells : null;
7883
- const hasCompressionRuntime = config.compress && resolveFarmInstrumentationRuntime(preset) === "nodejs";
8141
+ const hasCompressionRuntime = config.compress && resolveFarmInstrumentationRuntime(preset) !== "edge";
7884
8142
  const servesAgentRobotsTxt = Boolean(config.agent?.crawlers?.enabled) && !applicationMetadataRoutes.some(
7885
8143
  (metadata) => metadata.kind === "robots" && metadata.pattern === "/"
7886
8144
  );
@@ -7891,13 +8149,12 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
7891
8149
  const servesAiCatalog = config.agent?.aiCatalog !== false;
7892
8150
  const hasPluginRuntime = hasRuntimeIntegrationConfig || hasServerRuntimePlugins;
7893
8151
  const hasInfraAnalyticsRuntime = config.analytics !== false && resolveFarmInstrumentationRuntime(preset) === "nodejs";
8152
+ const reportsWebMCPCalls = hasInfraAnalyticsRuntime && _farmWebMCPReportsEnabled(config.plugins);
7894
8153
  const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
7895
- const adapterOwnsDocsRuntime = Boolean(
7896
- isReactRenderer(config.renderer) && config.docs?.enabled && config.docs.adapter?.server && config.docs.adapter.react
7897
- );
8154
+ const adapterOwnsDocsRuntime = hasFarmDocsRuntimeAdapter(config.docs);
7898
8155
  if (config.docs?.enabled && config.docs.roots?.length && !adapterOwnsDocsRuntime) {
7899
8156
  throw new Error(
7900
- "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."
7901
8158
  );
7902
8159
  }
7903
8160
  const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
@@ -8282,6 +8539,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
8282
8539
  applyFarmBasePath,
8283
8540
  applyFarmCspNonceToResponse,
8284
8541
  createFarmCspNonce,
8542
+ createPreHydrationClickQueueScript,
8285
8543
  stampFarmCspNonce,
8286
8544
  isDeferred,
8287
8545
  prepareDeferredData,
@@ -8341,6 +8599,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
8341
8599
  isFarmNotFoundError,
8342
8600
  isFarmRedirectError,
8343
8601
  localizeFarmHref,
8602
+ hasFarmHtmlPreloadToken,
8344
8603
  manageFarmDocumentPreloads,
8345
8604
  mergeRouteRenderingDirectiveConfig,
8346
8605
  resolveRouteSharedCacheControl,
@@ -8460,7 +8719,7 @@ const isFarmDocsAPIRequest = (requestOrPathname) => {
8460
8719
  return pathname === apiPath || pathname.startsWith(apiPath + "/");
8461
8720
  };` : adapterOwnsDocsRuntime ? `import { ${docsConfigModulePath ? "getFarmDocsConfigModuleRoot, " : ""}isFarmDocsAPIRequest } from "@farm.js/core/docs";
8462
8721
  import { ${config.docs.roots?.length ? "createFarmDocsMultiRuntimeHandler as createFarmDocsAdapterMultiRuntimeHandler" : "createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler"} } from ${JSON.stringify(config.docs.adapter.server)};
8463
- import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
8722
+ import * as FarmDocsAdapterUI from ${JSON.stringify(getFarmDocsAdapterUIModule(config.docs.adapter))};${docsConfigModulePath ? `
8464
8723
  import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
8465
8724
  const docsFontImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
8466
8725
  const docsRuntimeImport = config.docs?.enabled && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
@@ -8785,6 +9044,12 @@ function wrapWithFarmIntegrationProviders(element) {
8785
9044
  }
8786
9045
  return wrapped;
8787
9046
  }
9047
+ // The browser hydrates a page island or a route slot as its own root, inside the integration
9048
+ // providers, so the server renders them inside it too. React lines an island up with its tree
9049
+ // position instead, and its providers render no markup.
9050
+ function wrapFarmIslandIntegrationProviders(element) {
9051
+ return ${isReactRenderer(config.renderer) ? "element" : "wrapWithFarmIntegrationProviders(element)"};
9052
+ }
8788
9053
  const serverRuntimeIntegrations = Object.fromEntries(
8789
9054
  Object.entries(configuredIntegrations).filter(([, integration]) =>
8790
9055
  integration && typeof integration === "object" && integration.serverRuntime !== false
@@ -8794,7 +9059,14 @@ const integrationRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs, {
8794
9059
  integrations: configuredIntegrations,
8795
9060
  ${JSON.stringify(FARM_INTEGRATION_API_BASE_PATH_KEY)}: ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))},
8796
9061
  });
8797
- const farmInfraAnalytics = ${hasInfraAnalyticsRuntime ? hasPluginRuntime ? "createFarmInfraAnalyticsPlugin()" : "createFarmInfraAnalyticsRecorder()" : "null"};
9062
+ const farmInfraAnalytics = ${hasInfraAnalyticsRuntime ? `${hasPluginRuntime ? "createFarmInfraAnalyticsPlugin" : "createFarmInfraAnalyticsRecorder"}(${reportsWebMCPCalls ? "{ webmcp: { route: farmWebMCPCallRoute } }" : ""})` : "null"};${reportsWebMCPCalls ? `
9063
+ // A WebMCP tool call a page reports goes under that page's route, matched and labeled as a
9064
+ // request for the page is.
9065
+ function farmWebMCPCallRoute(pathname) {
9066
+ return labelFarmRequestOptions(
9067
+ getFarmPluginRequestOptions(new Request(new URL(pathname, "http://farm.invalid"))),
9068
+ ).route;
9069
+ }` : ""}
8798
9070
  const configuredPlugins = [
8799
9071
  ${hasCompressionRuntime && hasPluginRuntime ? "createCompressionPlugin()," : ""}
8800
9072
  ${hasRuntimeIntegrationConfig ? "...resolveIntegrationPlugins(serverRuntimeIntegrations)," : ""}
@@ -8963,7 +9235,9 @@ const farmDocsModulePreloadPaths = farmDocsModulePreloads
8963
9235
  ),
8964
9236
  }
8965
9237
  : undefined;
8966
- 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}, {
8967
9241
  rootDir: farmDocsRuntimeRoot,
8968
9242
  // A production build's content cannot change, so the adapter reads its
8969
9243
  // navigation once instead of scanning the content directory per request.
@@ -8979,7 +9253,10 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
8979
9253
  resolveFarmLayoutFonts(
8980
9254
  getApplicableLayouts(getFarmRoutePathname(pathname)).map((layout) => layout.module),
8981
9255
  ),
8982
- 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,` : ""}
8983
9260
  // Lists the docs MCP endpoint in /.well-known/ai-catalog.json for the server's lifetime.
8984
9261
  registerMCPServer: registerFarmMCPServer,
8985
9262
  // A page built with this keeps its HTML string, so the preload budget and the response
@@ -9172,7 +9449,7 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
9172
9449
  'window[Symbol.for("farm.searchPreserveRoutes")]=' + serializeFarmInlineValue(farmSearchPreserveRoutes) + ';'` : ""};
9173
9450
  // The client boots at the canonical path when the script below moves it there.
9174
9451
  const bootRoutes = statusDocument
9175
- ? typeof routePathname === "string" ? { path: routePathname, routes: [] } : undefined
9452
+ ? typeof routePathname === "string" ? getFarmClientStatusBootRoutes(routePathname) : undefined
9176
9453
  : getFarmClientBootRoutes(
9177
9454
  typeof canonicalPath === "string" && canonicalPath.startsWith("/")
9178
9455
  ? getFarmRoutePathname(canonicalPath.split(/[?#]/)[0])
@@ -9976,7 +10253,7 @@ function createFarmErrorDocument(html, title, routePathname) {
9976
10253
  ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
9977
10254
  ' <link rel="icon" href="data:,">\\n' +
9978
10255
  ' <title>' + escapedTitle + '</title>\\n' +
9979
- ' <link rel="stylesheet" href="/__farm_client_css_href__">' + renderFarmClientModulePreloads(html) + '\\n' +
10256
+ ' ' + renderFarmClientStylesheet() + renderFarmClientModulePreloads(html) + '\\n' +
9980
10257
  renderFarmRendererHydrationScript() + '\\n' +
9981
10258
  '</head>\\n<body>\\n' +
9982
10259
  ' <div id="root">' + html + '</div>\\n' +
@@ -9987,7 +10264,7 @@ function createFarmErrorDocument(html, title, routePathname) {
9987
10264
 
9988
10265
  let fullHtml = ensureFarmDocumentRoot(ensureFarmDocumentHead(fullDocument));
9989
10266
  fullHtml = fullHtml
9990
- .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); })
9991
10268
  // Function replacements: dynamic markup may contain $-sequences ($&, $', $$)
9992
10269
  // that a string replacement would expand, corrupting the document.
9993
10270
  .replace(/<\\/head>/i, function() { return renderFarmRendererHydrationScript() + '\\n</head>'; })
@@ -10011,6 +10288,23 @@ function createFarmErrorDocument(html, title, routePathname) {
10011
10288
  : "<!DOCTYPE html>\\n" + fullHtml;
10012
10289
  }
10013
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
+
10014
10308
  // The client modules a page needs before it hydrates, filled in from the client
10015
10309
  // build once it has finished (see buildNitroUniversal).
10016
10310
  const farmClientModulePreloads = (() => {
@@ -10020,7 +10314,10 @@ const farmClientModulePreloads = (() => {
10020
10314
  return null;
10021
10315
  }
10022
10316
  })();
10023
- ${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
+ )}
10024
10321
 
10025
10322
  const farmClientEntryPreloadTags = farmClientModulePreloads
10026
10323
  ? farmClientModulePreloads.entry.map(renderFarmClientModulePreload).join("")
@@ -10030,10 +10327,18 @@ const farmClientEntryPreloadTags = farmClientModulePreloads
10030
10327
  const farmClientRendererPreloadTags = farmClientModulePreloads
10031
10328
  ? (farmClientModulePreloads.renderer || []).map(renderFarmClientModulePreload).join("")
10032
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
+ : "";
10033
10335
  // The client modules a document's markup loads: its islands' boundaries and the
10034
10336
  // client references of its server tree. An island with a deferred strategy loads its
10035
10337
  // module on its own trigger, so it is not preloaded.
10036
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_/;
10037
10342
 
10038
10343
  function renderFarmClientModulePreload(index) {
10039
10344
  return '\\n <link rel="modulepreload" href="/' +
@@ -10064,15 +10369,28 @@ function collectFarmClientDocumentModules(markup, pageModule, listed) {
10064
10369
  return indexes;
10065
10370
  }
10066
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
+
10067
10381
  // The modulepreload links for a document: the entry's static imports and, unless it answers a
10068
- // client navigation, the renderer, then the modules its hydrating page and its markup load.
10069
- 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) {
10070
10385
  // A nonce policy blocks parser-inserted links without the nonce, and the
10071
10386
  // response filter manages nonces on script elements only, so CSP nonce mode
10072
10387
  // keeps the documents it had.
10073
10388
  if (!farmClientModulePreloads || (farmSecurityConfig.csp && farmSecurityConfig.csp.nonce)) return "";
10389
+ const listed = new Set();
10074
10390
  return farmClientEntryPreloadTags + (navigation ? "" : farmClientRendererPreloadTags) +
10075
- collectFarmClientDocumentModules(markup, pageModule, new Set())
10391
+ (hydratesRoot && !navigation ? farmClientRootPreloadTags : "") +
10392
+ collectFarmClientDocumentModules(markup, pageModule, listed)
10393
+ .concat(collectFarmClientActionModules(markup, listed))
10076
10394
  .map(renderFarmClientModulePreload)
10077
10395
  .join("");
10078
10396
  }
@@ -10094,13 +10412,26 @@ function renderFarmClientBootPreloads(markup, pageModule, root, rootStrategy, na
10094
10412
  ) + '"';
10095
10413
  };
10096
10414
  const entry = farmClientModulePreloads.entry;
10415
+ // The root hydrates with the code that hydrates roots (RFC 0013) and its page's modules.
10097
10416
  const rootModules = root
10098
- ? 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
+ )
10099
10424
  : [];
10100
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
+ );
10101
10432
  return attribute("data-farm-preload", waitsForClick ? entry : entry.concat(rootModules)) +
10102
10433
  attribute("data-farm-preload-router", farmClientModulePreloads.router || []) +
10103
- attribute("data-farm-preload-renderer", navigation ? [] : farmClientModulePreloads.renderer || []) +
10434
+ attribute("data-farm-preload-renderer", renderer) +
10104
10435
  (waitsForClick ? attribute("data-farm-preload-root", rootModules) : "");
10105
10436
  }
10106
10437
 
@@ -11082,8 +11413,8 @@ ${config.docs?.enabled ? `async function wrapFarmDocsResponseWithLayouts(request
11082
11413
  }
11083
11414
  html = html.replace(/<[/]head>/i, function() { return renderedRoot.head + "\\n</head>"; });
11084
11415
  }
11085
- if (!html.includes('href="/__farm_client_css_href__"')) {
11086
- const clientStylesheet = ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n';
11416
+ if (farmClientStylesheetHref && !html.includes('href="' + farmClientStylesheetHref + '"')) {
11417
+ const clientStylesheet = ' ' + renderFarmClientStylesheet() + '\\n';
11087
11418
  const firstStyleIndex = html.search(/<style(?:\\s|>)/i);
11088
11419
  html =
11089
11420
  firstStyleIndex >= 0
@@ -12264,7 +12595,7 @@ ${hasServerRuntimeIntegrations ? `
12264
12595
  }
12265
12596
 
12266
12597
  if (route.shouldHydrate && !shouldHydrateLayout) {
12267
- pageElement = wrapFarmRouteClientGraph(pageElement);
12598
+ pageElement = wrapFarmRouteClientGraph(wrapFarmIslandIntegrationProviders(pageElement));
12268
12599
  } else if (shouldHydrateLayout && !route.shouldHydrate) {
12269
12600
  pageElement = route.serverTree
12270
12601
  ? await renderFarmRouteServerTree(
@@ -12325,7 +12656,9 @@ ${hasServerRuntimeIntegrations ? `
12325
12656
  },
12326
12657
  slot.hydrates
12327
12658
  ? wrapFarmRouteClientGraph(
12328
- React.createElement(slot.module.default, slot.props),
12659
+ wrapFarmIslandIntegrationProviders(
12660
+ React.createElement(slot.module.default, slot.props),
12661
+ ),
12329
12662
  )
12330
12663
  : React.createElement(slot.module.default, slot.props),
12331
12664
  );
@@ -12539,6 +12872,17 @@ ${hasServerRuntimeIntegrations ? `
12539
12872
  // Set once the whole document is rendered: whether it starts with the boot entry, which
12540
12873
  // preloads nothing.
12541
12874
  let farmBootsClient = false;
12875
+ // A document something hydrates over holds the clicks and submits made before it hydrates,
12876
+ // for the client entry to replay, as development does. One that starts with the boot entry
12877
+ // holds its own.
12878
+ const farmHydratesRoot = route.shouldHydrate || shouldHydrateLayout;
12879
+ const farmHoldsInteractions =
12880
+ farmHydratesRoot || renderedRouteSlots.some(function(slot) { return slot.hydrates; });
12881
+ const renderFarmPreHydrationHoldScript = function() {
12882
+ return farmHoldsInteractions && !farmBootsClient
12883
+ ? stampFarmCspNonce(createPreHydrationClickQueueScript()) + '\\n'
12884
+ : '';
12885
+ };
12542
12886
  // A client navigation swaps this document in without running its scripts. A route a
12543
12887
  // shared cache stores renders the same for every request.
12544
12888
  const farmNavigationRequest = ${farmIslandsMode ? `!farmSharedCacheableRoute &&
@@ -12552,8 +12896,8 @@ ${hasServerRuntimeIntegrations ? `
12552
12896
  );
12553
12897
  composed = composed
12554
12898
  // Inject CSS link after opening head tag or first meta tag
12555
- .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n <link rel="stylesheet" href="/__farm_client_css_href__">' + (farmBootsClient ? "" : renderFarmClientModulePreloads(composed, route.clientModule, farmNavigationRequest)); })
12556
- .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
12899
+ .replace(/<head([^>]*)>/i, function(match, attrs) { return '<head' + attrs + '>\\n ' + renderFarmClientStylesheet() + (farmBootsClient ? "" : renderFarmClientModulePreloads(composed, route.clientModule, farmNavigationRequest, farmHydratesRoot)); })
12900
+ .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n' + renderFarmPreHydrationHoldScript() + '</head>')
12557
12901
  // Explicit metadata wins over renderer and layout titles. Without
12558
12902
  // explicit metadata, a renderer title wins over the layout title.
12559
12903
  .replace(/<head([^>]*)>([\\s\\S]*?)<\\/head>/i, (match, attrs, headContent) => {
@@ -12625,9 +12969,10 @@ ${hasServerRuntimeIntegrations ? `
12625
12969
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
12626
12970
  (suppressDefaultTitle ? '' : ' <title>' + title + '</title>') + metaTags +
12627
12971
  (rendererHead ? '\\n ' + rendererHead : '') + '\\n' +
12628
- ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
12629
- ' <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' +
12630
12974
  renderFarmRendererHydrationScript() + '\\n' +
12975
+ renderFarmPreHydrationHoldScript() +
12631
12976
  '</head>\\n<body>\\n' + farmEarlyClientScripts + ' <div id="root">';
12632
12977
  const streamClientScripts = farmEarlyClientScripts ? '' : farmClientScripts();
12633
12978
  const streamSuffix = function() {
@@ -12739,7 +13084,6 @@ ${hasServerRuntimeIntegrations ? `
12739
13084
  }
12740
13085
  }
12741
13086
  // A route that hydrates as one root starts with the boot entry only when that root waits.
12742
- const farmHydratesRoot = route.shouldHydrate || shouldHydrateLayout;
12743
13087
  farmBootsClient = farmDocumentBootsClient(
12744
13088
  html,
12745
13089
  (farmHydratesRoot && !route.rootStrategy) || Boolean(pprCacheKey),
@@ -12782,9 +13126,9 @@ ${hasServerRuntimeIntegrations ? `
12782
13126
  \${viewportTags}
12783
13127
  \${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
12784
13128
  \${suppressDefaultTitle ? "" : "<title>" + title + "</title>"}\${metaTags}\${rendererHead ? "\\n " + rendererHead : ""}
12785
- <link rel="stylesheet" href="/__farm_client_css_href__">\${farmBootsClient ? "" : renderFarmClientModulePreloads(html, route.clientModule, farmNavigationRequest)}
13129
+ \${renderFarmClientStylesheet()}\${farmBootsClient ? "" : renderFarmClientModulePreloads(html, route.clientModule, farmNavigationRequest, farmHydratesRoot)}
12786
13130
  \${renderFarmRendererHydrationScript()}
12787
- </head>
13131
+ \${renderFarmPreHydrationHoldScript()}</head>
12788
13132
  <body>
12789
13133
  <div id="root">\${html}</div>
12790
13134
  \${renderFarmClientBootstrapScript(pageProps.__farmCanonicalPath, farmDeferredData.data.slots, farmDeferredData.data.page, routePathname)}\${renderFarmDeferredDataScript(farmDeferredData.records)}
@@ -13143,7 +13487,7 @@ ${farmRendererDisabled ? `
13143
13487
  "<head" + attrs + ">" +
13144
13488
  headContent.replace(/<title\\b[^>]*>[\\s\\S]*?<\\/title>\\s*/gi, "") +
13145
13489
  "\\n <title>" + notFoundMetadata.title + "</title>" + notFoundMetadata.tags + "\\n</head>")
13146
- .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); })
13147
13491
  .replace(/<\\/head>/i, () => renderFarmRendererHydrationScript() + '\\n</head>')
13148
13492
  .replace(
13149
13493
  /<\\/body>/i,
@@ -13161,7 +13505,7 @@ ${farmRendererDisabled ? `
13161
13505
  <meta charset="UTF-8">
13162
13506
  \${notFoundMetadata.viewport}
13163
13507
  \${notFoundMetadata.hasFavicon ? "" : '<link rel="icon" href="data:,">'}
13164
- <link rel="stylesheet" href="/__farm_client_css_href__">\${renderFarmClientModulePreloads(html)}
13508
+ \${renderFarmClientStylesheet()}\${renderFarmClientModulePreloads(html)}
13165
13509
  <title>\${notFoundMetadata.title}</title>\${notFoundMetadata.tags}
13166
13510
  \${renderFarmRendererHydrationScript()}
13167
13511
  </head>
@@ -13584,12 +13928,6 @@ async function getFarmDocsPrerenderPages(config, root, preset) {
13584
13928
  }
13585
13929
  return pages2;
13586
13930
  }
13587
- if (!isReactRenderer(config.renderer)) {
13588
- logger.warn(
13589
- `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.`
13590
- );
13591
- return [];
13592
- }
13593
13931
  const pages = await listFarmDocsAdapterPages(config.docs, { root, srcDir: config.srcDir });
13594
13932
  if (!pages) {
13595
13933
  logger.warn(
@@ -13607,7 +13945,7 @@ async function listFarmDocsAnalyticsPages(config, root, preset) {
13607
13945
  return await listFarmDocsPagePaths(config.docs, {
13608
13946
  root,
13609
13947
  srcDir: config.srcDir,
13610
- adapter: isReactRenderer(config.renderer) && hasFarmDocsRuntimeAdapter(config.docs)
13948
+ adapter: hasFarmDocsRuntimeAdapter(config.docs)
13611
13949
  });
13612
13950
  } catch (error) {
13613
13951
  logger.warn(
@@ -13776,6 +14114,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
13776
14114
  const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
13777
14115
  const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
13778
14116
  const encodedClientRouteTable = encodeFarmBuildJSONPlaceholder(clientRouteTable);
14117
+ const encodedClientStylesheet = encodeFarmBuildJSONPlaceholder(
14118
+ await resolveClientStylesheetLinkHref(clientOutputDir, clientCssHref)
14119
+ );
13779
14120
  const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
13780
14121
  await finalizeFarmMobileClient({
13781
14122
  buildDir: path17.join(root, distDir),
@@ -13800,6 +14141,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
13800
14141
  if (output.code.includes(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER)) {
13801
14142
  output.code = output.code.split(FARM_CLIENT_ROUTE_TABLE_PLACEHOLDER).join(encodedClientRouteTable);
13802
14143
  }
14144
+ if (output.code.includes(FARM_CLIENT_STYLESHEET_PLACEHOLDER)) {
14145
+ output.code = output.code.split(FARM_CLIENT_STYLESHEET_PLACEHOLDER).join(encodedClientStylesheet);
14146
+ }
13803
14147
  if (output.code.includes(FARM_CLIENT_CSS_HREF_PLACEHOLDER)) {
13804
14148
  output.code = output.code.split(FARM_CLIENT_CSS_HREF_PLACEHOLDER).join(clientCssHref);
13805
14149
  }
@@ -14134,7 +14478,9 @@ function toFarmNodeResponse(request, response) {
14134
14478
  ];
14135
14479
  })
14136
14480
  );
14137
- if (preset === "node-server") await writeFarmClientBrotliAssets(clientOutputDir);
14481
+ if (preset === "node-server" || preset === "bun") {
14482
+ await writeFarmClientBrotliAssets(clientOutputDir);
14483
+ }
14138
14484
  const immutableAssets = isVercel ? { publicAssets: [], routeRules: {} } : planFarmImmutableAssets({
14139
14485
  clientOutputDir,
14140
14486
  files: await listFarmClientOutputFiles(clientOutputDir),
@@ -14171,9 +14517,8 @@ function toFarmNodeResponse(request, response) {
14171
14517
  // A self-hosted Node or Bun server sends static files itself, so precompress
14172
14518
  // them with gzip and let Nitro serve that by Accept-Encoding. Brotli at Nitro's
14173
14519
  // fixed top quality on every file cost a docs app ~20 s of build CPU, so only
14174
- // client scripts and stylesheets get a brotli copy, on node-server
14175
- // (writeFarmClientBrotliAssets). Serverless and edge targets sit behind a CDN
14176
- // that compresses.
14520
+ // client scripts and stylesheets get a brotli copy (writeFarmClientBrotliAssets).
14521
+ // Serverless and edge targets sit behind a CDN that compresses.
14177
14522
  ...preset === "node-server" || preset === "bun" ? { compressPublicAssets: { gzip: true } } : {},
14178
14523
  // Nitro gzips every server output file at level 9, node_modules included, to
14179
14524
  // print sizes after the build. A self-hosted server is never shipped compressed,
@@ -15159,6 +15504,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
15159
15504
  ],
15160
15505
  suppressLintOnLink: config.suppressLintOnLink,
15161
15506
  componentExtensions: config.renderer.componentExtensions,
15507
+ renderer: config.renderer,
15162
15508
  i18nConfig: config.i18n
15163
15509
  }).catch((error) => {
15164
15510
  const message = error instanceof Error ? error.message : String(error);
@@ -15340,7 +15686,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
15340
15686
  farmPlugin,
15341
15687
  farmServerOnlyEntriesPlugin
15342
15688
  } = await import("./vite.mjs");
15343
- const { PluginManager: PluginManager2 } = await import("./plugin-33I3V42N.mjs");
15689
+ const { PluginManager: PluginManager2 } = await import("./plugin-QOTAPTVV.mjs");
15344
15690
  const pluginManager = new PluginManager2({
15345
15691
  config,
15346
15692
  isDev: false,
@@ -15369,7 +15715,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
15369
15715
  }
15370
15716
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
15371
15717
  const { farmI18nClientBridgePlugin, farmIslandContainersPlugin, farmPlugin } = await import("./vite.mjs");
15372
- const { PluginManager: PluginManager2 } = await import("./plugin-33I3V42N.mjs");
15718
+ const { PluginManager: PluginManager2 } = await import("./plugin-QOTAPTVV.mjs");
15373
15719
  const pluginManager = new PluginManager2({
15374
15720
  config,
15375
15721
  isDev: false,
@@ -15411,7 +15757,7 @@ function resolveLegacyPageEntry(config, root, srcDir) {
15411
15757
  }
15412
15758
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
15413
15759
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
15414
- import("./nitro-YLTGVGK4.mjs"),
15760
+ import("./nitro-FK3SZM4H.mjs"),
15415
15761
  import("nitro/builder")
15416
15762
  ]);
15417
15763
  let nitroConfig = await createNitroConfig(