@farm.js/core 0.1.34 → 0.1.36

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 (282) hide show
  1. package/dist/agent-mcp-BVExL8rZ.d.mts +109 -0
  2. package/dist/agent-mcp-handler-LPJ2CADR.mjs +19 -0
  3. package/dist/agent-mcp-handler-SJAHFSPI.cjs +19 -0
  4. package/dist/agent-mcp-luzfXK-P.d.ts +109 -0
  5. package/dist/agent-runtime.cjs +5 -3
  6. package/dist/agent-runtime.d.mts +4 -5
  7. package/dist/agent-runtime.d.ts +4 -5
  8. package/dist/agent-runtime.mjs +4 -2
  9. package/dist/api/route-manager.cjs +7 -7
  10. package/dist/api/route-manager.d.mts +15 -10
  11. package/dist/api/route-manager.d.ts +15 -10
  12. package/dist/api/route-manager.mjs +6 -6
  13. package/dist/api/runtime.cjs +7 -5
  14. package/dist/api/runtime.d.mts +7 -66
  15. package/dist/api/runtime.d.ts +7 -66
  16. package/dist/api/runtime.mjs +7 -5
  17. package/dist/api.cjs +9 -9
  18. package/dist/api.d.mts +8 -9
  19. package/dist/api.d.ts +8 -9
  20. package/dist/api.mjs +8 -8
  21. package/dist/{app-q4rmZlXK.d.mts → app-BukwkFIu.d.mts} +52 -12
  22. package/dist/{app-DgotYGbq.d.ts → app-Yfa2dsFy.d.ts} +52 -12
  23. package/dist/app-markdown.cjs +6 -6
  24. package/dist/app-markdown.d.mts +5 -6
  25. package/dist/app-markdown.d.ts +5 -6
  26. package/dist/app-markdown.mjs +5 -5
  27. package/dist/{chunk-XV5DJTBX.mjs → chunk-276VJSM6.mjs} +627 -260
  28. package/dist/{chunk-36MK5YCW.cjs → chunk-2YTDKNH3.cjs} +547 -240
  29. package/dist/{chunk-VHANUNEG.mjs → chunk-35GKZR22.mjs} +2 -2
  30. package/dist/{chunk-LR5QSC2P.mjs → chunk-35WV46VL.mjs} +399 -92
  31. package/dist/{chunk-UX5S4JEO.cjs → chunk-42NHY7HW.cjs} +57 -7
  32. package/dist/{chunk-U4PTAHW3.mjs → chunk-4E5AEDKY.mjs} +7 -11
  33. package/dist/{chunk-NGVORZVZ.mjs → chunk-4E5WBPEG.mjs} +73 -351
  34. package/dist/{chunk-AQZFOP7S.mjs → chunk-4GLOOWKE.mjs} +5 -5
  35. package/dist/{chunk-7BT4H4P7.cjs → chunk-4NU4GGTC.cjs} +2 -2
  36. package/dist/{chunk-AGC75XAE.mjs → chunk-4WCZJQUO.mjs} +55 -5
  37. package/dist/chunk-4WQ6PGSJ.cjs +367 -0
  38. package/dist/{chunk-QCFFHV5H.mjs → chunk-4WVJLURN.mjs} +1 -1
  39. package/dist/chunk-6SJ2KJTA.mjs +314 -0
  40. package/dist/chunk-75RZHGLS.cjs +135 -0
  41. package/dist/{chunk-P64MIF5B.cjs → chunk-ADEA7PN3.cjs} +483 -60
  42. package/dist/{chunk-YQVSHTMR.mjs → chunk-AJQTP4OO.mjs} +1 -1
  43. package/dist/{chunk-TA5G2HWD.cjs → chunk-AO6RYU5N.cjs} +31 -28
  44. package/dist/{chunk-MOKLYNHV.cjs → chunk-BO36SELV.cjs} +6 -6
  45. package/dist/{chunk-7Y6ZNFPX.mjs → chunk-BPOF5U4N.mjs} +17 -7
  46. package/dist/{chunk-JHWOVJ3M.mjs → chunk-BUGNQIHC.mjs} +5 -0
  47. package/dist/{chunk-TDFPACVX.cjs → chunk-CBJJH36A.cjs} +50 -25
  48. package/dist/{chunk-VKNHTSAP.cjs → chunk-CGBDNNSM.cjs} +2 -2
  49. package/dist/chunk-CI6E3UOH.cjs +314 -0
  50. package/dist/{chunk-QZCT2CQ4.mjs → chunk-CXEN47J3.mjs} +64 -2
  51. package/dist/{chunk-ATK2R4CH.cjs → chunk-D227TIEN.cjs} +14 -4
  52. package/dist/{chunk-QGYRXFU2.cjs → chunk-D2BB47NB.cjs} +8 -8
  53. package/dist/chunk-DTSROJ5J.mjs +367 -0
  54. package/dist/{chunk-ODBZYBAB.cjs → chunk-DZ5ZVB2K.cjs} +1 -1
  55. package/dist/{chunk-ROUTX2E5.cjs → chunk-ECKF2BAM.cjs} +18 -5
  56. package/dist/{chunk-3LUF2PE2.cjs → chunk-EK4QAEFZ.cjs} +67 -5
  57. package/dist/{chunk-VVBO3QH7.mjs → chunk-ENLZ4R3Y.mjs} +10 -1
  58. package/dist/{chunk-XXJU7FCC.cjs → chunk-EUV4YR3V.cjs} +2 -2
  59. package/dist/{chunk-HR5KPHC2.mjs → chunk-EWET4D2Y.mjs} +1 -1
  60. package/dist/{chunk-PXKIEXZD.mjs → chunk-F5QO4FNE.mjs} +1 -1
  61. package/dist/{chunk-MIDIZJZC.cjs → chunk-FO427P6I.cjs} +22 -12
  62. package/dist/{chunk-AWC4VUZL.cjs → chunk-GQ3Z3IZI.cjs} +14 -14
  63. package/dist/{chunk-JDPAKVS4.mjs → chunk-GQRWBCWK.mjs} +8 -5
  64. package/dist/{chunk-75WGQVQA.cjs → chunk-HITLGIAO.cjs} +10 -1
  65. package/dist/{chunk-WNNYOOIB.mjs → chunk-HOXTWRGB.mjs} +1 -1
  66. package/dist/{chunk-KROWKCUH.cjs → chunk-JGLC4TO3.cjs} +8 -1
  67. package/dist/{chunk-QJ3J6MZT.cjs → chunk-JNUWCDTF.cjs} +8 -8
  68. package/dist/{chunk-BTAG7LI7.cjs → chunk-JZVADIOD.cjs} +2 -2
  69. package/dist/{chunk-EM6SBQKM.cjs → chunk-KIIMAWOJ.cjs} +37 -2
  70. package/dist/{chunk-43FMW62B.mjs → chunk-KMTGADN3.mjs} +28 -0
  71. package/dist/{chunk-GOABMOX3.mjs → chunk-LSZAVSGY.mjs} +468 -45
  72. package/dist/{chunk-2NQQ5H5G.cjs → chunk-M7MKQXAF.cjs} +2 -1
  73. package/dist/{chunk-GNSDTTWZ.mjs → chunk-MKYBIIAQ.mjs} +30 -5
  74. package/dist/{chunk-ZHPHJPQP.cjs → chunk-MRMI32SN.cjs} +88 -366
  75. package/dist/{chunk-7M52YUMY.cjs → chunk-N2NAS2AM.cjs} +2 -2
  76. package/dist/{chunk-SJVKK4JE.cjs → chunk-NMHWYWDR.cjs} +1144 -777
  77. package/dist/chunk-NRDBW4MP.mjs +45 -0
  78. package/dist/{chunk-657WJNRY.mjs → chunk-O6I6VWKK.mjs} +20 -5
  79. package/dist/{chunk-O27L4YAA.mjs → chunk-O6WAEAX3.mjs} +2 -2
  80. package/dist/chunk-OFZUJMCU.mjs +601 -0
  81. package/dist/{chunk-ZKP7C2B6.mjs → chunk-OHLSEQ57.mjs} +22 -13
  82. package/dist/{chunk-X242HVD5.mjs → chunk-OO7GXVSR.mjs} +1 -1
  83. package/dist/chunk-PTZ2TVNE.cjs +178 -0
  84. package/dist/{chunk-3ATMYLLJ.mjs → chunk-Q2KB32T4.mjs} +1 -1
  85. package/dist/{chunk-LHODW25H.mjs → chunk-QORUJDIV.mjs} +2 -2
  86. package/dist/{chunk-UBO4SGH4.mjs → chunk-RHAZ22ZN.mjs} +2 -1
  87. package/dist/{chunk-G26MUMKL.cjs → chunk-S6VYG6XU.cjs} +23 -8
  88. package/dist/{chunk-6VVL3MHY.mjs → chunk-SC2WYWPF.mjs} +1 -1
  89. package/dist/{chunk-MPEYMSCF.cjs → chunk-SDOTRX3V.cjs} +5 -5
  90. package/dist/{chunk-BMWDEBXO.cjs → chunk-SHLXACIO.cjs} +31 -3
  91. package/dist/{chunk-LMJ7VRHZ.mjs → chunk-T4OGRVNS.mjs} +13 -3
  92. package/dist/{chunk-T5CERMEH.cjs → chunk-T5OJPTVN.cjs} +2 -2
  93. package/dist/{chunk-Z2YLTERK.cjs → chunk-TE2G5ION.cjs} +6 -6
  94. package/dist/chunk-UH6QN5NL.mjs +178 -0
  95. package/dist/{chunk-PQDFUSXD.cjs → chunk-UVW64BCB.cjs} +44 -35
  96. package/dist/{chunk-VCCUOMQN.mjs → chunk-VILIPRS6.mjs} +1 -1
  97. package/dist/{chunk-A5FGU2WU.cjs → chunk-VQLJWDVW.cjs} +19 -23
  98. package/dist/{chunk-VPTDD5XF.cjs → chunk-WBKEZXWE.cjs} +5 -0
  99. package/dist/{chunk-K3F2E6GS.cjs → chunk-WC5UV2HQ.cjs} +2 -2
  100. package/dist/chunk-WWFTAUFG.cjs +45 -0
  101. package/dist/{chunk-ZUSJDQ2Q.mjs → chunk-WWIKMBRN.mjs} +1 -1
  102. package/dist/{chunk-3VSKDFAT.mjs → chunk-WZ77PUAM.mjs} +1 -1
  103. package/dist/{chunk-CLJYVZAD.mjs → chunk-XCMCS4DA.mjs} +11 -1
  104. package/dist/{chunk-F6OHXPWR.mjs → chunk-YFILVET3.mjs} +8 -1
  105. package/dist/{chunk-DZ4DTRJ5.cjs → chunk-YKX5BK66.cjs} +7 -7
  106. package/dist/chunk-YSLWRWWP.cjs +601 -0
  107. package/dist/{chunk-LI2LMOLR.mjs → chunk-YWMZUGIS.mjs} +18 -5
  108. package/dist/chunk-ZLAT2CWY.mjs +135 -0
  109. package/dist/{chunk-XF7Q24PF.mjs → chunk-ZMMBIVQM.mjs} +35 -0
  110. package/dist/{chunk-U74I55WB.cjs → chunk-ZWM5KGAA.cjs} +19 -9
  111. package/dist/{client-plugins-CLObcuCq.d.mts → client-plugins-C3mK9Pol.d.mts} +300 -7
  112. package/dist/{client-plugins-DZjHC4Mi.d.ts → client-plugins-r1mOtSC1.d.ts} +300 -7
  113. package/dist/client-plugins.d.mts +4 -5
  114. package/dist/client-plugins.d.ts +4 -5
  115. package/dist/client.cjs +5 -5
  116. package/dist/client.d.mts +8 -9
  117. package/dist/client.d.ts +8 -9
  118. package/dist/client.mjs +4 -4
  119. package/dist/config.d.mts +4 -5
  120. package/dist/config.d.ts +4 -5
  121. package/dist/{devtools-RNXCTS4R.mjs → devtools-ERIKFEXX.mjs} +11 -10
  122. package/dist/{devtools-HU6Y2MNV.cjs → devtools-JZJJY5CK.cjs} +12 -11
  123. package/dist/docs.cjs +15 -14
  124. package/dist/docs.d.mts +41 -4
  125. package/dist/docs.d.ts +41 -4
  126. package/dist/docs.mjs +14 -13
  127. package/dist/i18n/client.d.mts +2 -2
  128. package/dist/i18n/client.d.ts +2 -2
  129. package/dist/i18n/index.d.mts +3 -3
  130. package/dist/i18n/index.d.ts +3 -3
  131. package/dist/i18n/server.d.mts +5 -5
  132. package/dist/i18n/server.d.ts +5 -5
  133. package/dist/image/server.cjs +3 -3
  134. package/dist/image/server.mjs +2 -2
  135. package/dist/image/sharp.cjs +10 -10
  136. package/dist/image/sharp.mjs +2 -2
  137. package/dist/{index-a-8Z5kZU.d.mts → index-BJJfLxJo.d.mts} +2 -2
  138. package/dist/{index-BWVfxIsO.d.ts → index-CwoOP-MW.d.ts} +2 -2
  139. package/dist/index.cjs +51 -44
  140. package/dist/index.d.mts +20 -21
  141. package/dist/index.d.ts +20 -21
  142. package/dist/index.mjs +50 -43
  143. package/dist/integrations.cjs +7 -3
  144. package/dist/integrations.d.mts +4 -5
  145. package/dist/integrations.d.ts +4 -5
  146. package/dist/integrations.mjs +6 -2
  147. package/dist/internal/app-markdown-runtime.cjs +5 -5
  148. package/dist/internal/app-markdown-runtime.d.mts +5 -6
  149. package/dist/internal/app-markdown-runtime.d.ts +5 -6
  150. package/dist/internal/app-markdown-runtime.mjs +4 -4
  151. package/dist/internal/build-runtime.cjs +32 -30
  152. package/dist/internal/build-runtime.d.mts +6 -7
  153. package/dist/internal/build-runtime.d.ts +6 -7
  154. package/dist/internal/build-runtime.mjs +31 -29
  155. package/dist/internal/cli-runtime.cjs +17 -16
  156. package/dist/internal/cli-runtime.mjs +16 -15
  157. package/dist/internal/client-error-overlay.cjs +6 -6
  158. package/dist/internal/client-error-overlay.mjs +2 -2
  159. package/dist/internal/client-runtime.cjs +2 -2
  160. package/dist/internal/client-runtime.mjs +1 -1
  161. package/dist/internal/compression-runtime.d.mts +4 -5
  162. package/dist/internal/compression-runtime.d.ts +4 -5
  163. package/dist/internal/config-runtime.cjs +12 -11
  164. package/dist/internal/config-runtime.d.mts +5 -6
  165. package/dist/internal/config-runtime.d.ts +5 -6
  166. package/dist/internal/config-runtime.mjs +11 -10
  167. package/dist/internal/isolated-boundary.cjs +3 -2
  168. package/dist/internal/isolated-boundary.d.mts +1 -1
  169. package/dist/internal/isolated-boundary.d.ts +1 -1
  170. package/dist/internal/isolated-boundary.mjs +2 -1
  171. package/dist/internal/metadata-image-runtime.cjs +3 -3
  172. package/dist/internal/metadata-image-runtime.mjs +2 -2
  173. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  174. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  175. package/dist/internal/production-runtime.cjs +63 -25
  176. package/dist/internal/production-runtime.d.mts +117 -37
  177. package/dist/internal/production-runtime.d.ts +117 -37
  178. package/dist/internal/production-runtime.mjs +65 -27
  179. package/dist/internal/server-tree.cjs +12 -0
  180. package/dist/internal/server-tree.d.mts +27 -0
  181. package/dist/internal/server-tree.d.ts +27 -0
  182. package/dist/internal/server-tree.mjs +12 -0
  183. package/dist/{layers-BRQF5ETU.mjs → layers-UTB43B7A.mjs} +1 -1
  184. package/dist/layers-VUWIOFEO.cjs +18 -0
  185. package/dist/markdown.cjs +4 -4
  186. package/dist/markdown.d.mts +4 -5
  187. package/dist/markdown.d.ts +4 -5
  188. package/dist/markdown.mjs +3 -3
  189. package/dist/middleware.cjs +7 -7
  190. package/dist/middleware.d.mts +6 -7
  191. package/dist/middleware.d.ts +6 -7
  192. package/dist/middleware.mjs +6 -6
  193. package/dist/navigation.cjs +5 -5
  194. package/dist/navigation.d.mts +7 -8
  195. package/dist/navigation.d.ts +7 -8
  196. package/dist/navigation.mjs +4 -4
  197. package/dist/{nitro-HSAQFXSS.cjs → nitro-7F65EZZS.cjs} +3 -3
  198. package/dist/{nitro-4XGPNIK4.mjs → nitro-MPZJGPXK.mjs} +2 -2
  199. package/dist/{observability-BupkiN0m.d.mts → observability-CoXunYhS.d.mts} +4 -3
  200. package/dist/{observability-BupkiN0m.d.ts → observability-CoXunYhS.d.ts} +4 -3
  201. package/dist/observability.d.mts +1 -1
  202. package/dist/observability.d.ts +1 -1
  203. package/dist/plugin.cjs +28 -26
  204. package/dist/plugin.d.mts +4 -5
  205. package/dist/plugin.d.ts +4 -5
  206. package/dist/plugin.mjs +27 -25
  207. package/dist/{production-runtime-CysZl3EV.d.mts → production-runtime-CCeVZXst.d.mts} +4 -4
  208. package/dist/{production-runtime-BU5ETAK9.d.ts → production-runtime-DPnsggY3.d.ts} +4 -4
  209. package/dist/query/client.cjs +6 -6
  210. package/dist/query/client.mjs +2 -2
  211. package/dist/{render-plan-CKr4ltOd.d.mts → render-plan-BuGaPFe6.d.mts} +1 -1
  212. package/dist/{render-plan-D72O1qm4.d.ts → render-plan-Cw4f5E_R.d.ts} +1 -1
  213. package/dist/renderer/react/server.cjs +10 -4
  214. package/dist/renderer/react/server.d.mts +2 -1
  215. package/dist/renderer/react/server.d.ts +2 -1
  216. package/dist/renderer/react/server.mjs +7 -1
  217. package/dist/renderer-client.cjs +5 -5
  218. package/dist/renderer-client.d.mts +6 -7
  219. package/dist/renderer-client.d.ts +6 -7
  220. package/dist/renderer-client.mjs +2 -2
  221. package/dist/renderer.d.mts +2 -0
  222. package/dist/renderer.d.ts +2 -0
  223. package/dist/{request-DbyOYI2j.d.ts → request-Bkg-hERy.d.ts} +1 -1
  224. package/dist/{request-Be83WafN.d.mts → request-CsGARcAw.d.mts} +1 -1
  225. package/dist/request.d.mts +5 -6
  226. package/dist/request.d.ts +5 -6
  227. package/dist/{resolver-PPEeiJ6M.d.ts → resolver-DadfRL6F.d.ts} +1 -1
  228. package/dist/{resolver-DhW0CqZN.d.mts → resolver-khasx3fU.d.mts} +1 -1
  229. package/dist/{route-rendering-CtVMpV-k.d.ts → route-rendering-BUZMH_64.d.ts} +1 -1
  230. package/dist/{route-rendering-BG56SzvJ.d.mts → route-rendering-f11yh5dp.d.mts} +1 -1
  231. package/dist/{router-D94-SDlW.d.ts → router-B8CR9GbD.d.ts} +1 -1
  232. package/dist/{router-ALUvm8gC.d.mts → router-Cp6yRE8A.d.mts} +1 -1
  233. package/dist/routes.d.mts +4 -5
  234. package/dist/routes.d.ts +4 -5
  235. package/dist/{runtime-BirxPwbZ.d.ts → runtime-BgDQzBiu.d.ts} +2 -2
  236. package/dist/runtime-CAEv36S_.d.mts +69 -0
  237. package/dist/runtime-CQVsT330.d.ts +69 -0
  238. package/dist/{runtime-AOJge4vQ.d.mts → runtime-CV2UCV-5.d.mts} +2 -2
  239. package/dist/server-action-security.cjs +3 -3
  240. package/dist/server-action-security.mjs +2 -2
  241. package/dist/server-fn.cjs +4 -4
  242. package/dist/server-fn.mjs +3 -3
  243. package/dist/server-plugins.d.mts +5 -6
  244. package/dist/server-plugins.d.ts +5 -6
  245. package/dist/server-query.cjs +5 -5
  246. package/dist/server-query.mjs +4 -4
  247. package/dist/server.cjs +47 -45
  248. package/dist/server.d.mts +13 -14
  249. package/dist/server.d.ts +13 -14
  250. package/dist/server.mjs +30 -28
  251. package/dist/{spa-router-CxK3USIz.d.ts → spa-router-BuciWGCZ.d.ts} +3 -3
  252. package/dist/{spa-router-DbxNRKOB.d.mts → spa-router-DwbqGkGj.d.mts} +3 -3
  253. package/dist/testing.cjs +9 -9
  254. package/dist/testing.d.mts +4 -5
  255. package/dist/testing.d.ts +4 -5
  256. package/dist/testing.mjs +7 -7
  257. package/dist/{types-Z0aotQ8w.d.mts → types-CnH8DOqo.d.mts} +1 -1
  258. package/dist/{types-Z0aotQ8w.d.ts → types-CnH8DOqo.d.ts} +1 -1
  259. package/dist/{utils-4wVRcpOw.d.mts → utils-B9V0S_yL.d.mts} +1 -1
  260. package/dist/{utils-311Y8eoK.d.ts → utils-CaoWKtYM.d.ts} +1 -1
  261. package/dist/version.cjs +2 -2
  262. package/dist/version.mjs +1 -1
  263. package/dist/vite.cjs +28 -26
  264. package/dist/vite.d.mts +4 -5
  265. package/dist/vite.d.ts +4 -5
  266. package/dist/vite.mjs +27 -25
  267. package/dist/{workflows-CR9ex-gz.d.ts → workflows-jZ4BcdoZ.d.mts} +1 -1
  268. package/dist/{workflows-CR9ex-gz.d.mts → workflows-jZ4BcdoZ.d.ts} +1 -1
  269. package/dist/workflows.cjs +3 -3
  270. package/dist/workflows.d.mts +1 -1
  271. package/dist/workflows.d.ts +1 -1
  272. package/dist/workflows.mjs +2 -2
  273. package/package.json +9 -1
  274. package/dist/chunk-M64YUMA4.cjs +0 -58
  275. package/dist/chunk-QLQ32WC4.mjs +0 -58
  276. package/dist/layers-4PNE2HOY.cjs +0 -18
  277. package/dist/metadata-2HSU2i_w.d.mts +0 -52
  278. package/dist/metadata-Cjs8JMRM.d.ts +0 -52
  279. package/dist/types-DFbjpjXX.d.mts +0 -105
  280. package/dist/types-DFbjpjXX.d.ts +0 -105
  281. package/dist/{chunk-2F2ER724.cjs → chunk-BPMATOP2.cjs} +2 -2
  282. package/dist/{chunk-IHNMMXHV.mjs → chunk-OTC5BDGO.mjs} +3 -3
@@ -10,7 +10,7 @@ var _chunkXD32KALFcjs = require('./chunk-XD32KALF.cjs');
10
10
 
11
11
 
12
12
 
13
- var _chunkA5FGU2WUcjs = require('./chunk-A5FGU2WU.cjs');
13
+ var _chunkVQLJWDVWcjs = require('./chunk-VQLJWDVW.cjs');
14
14
 
15
15
 
16
16
 
@@ -20,7 +20,7 @@ var _chunkA5FGU2WUcjs = require('./chunk-A5FGU2WU.cjs');
20
20
 
21
21
 
22
22
 
23
- var _chunkZ2YLTERKcjs = require('./chunk-Z2YLTERK.cjs');
23
+ var _chunkTE2G5IONcjs = require('./chunk-TE2G5ION.cjs');
24
24
 
25
25
 
26
26
 
@@ -37,7 +37,7 @@ var _chunkIK6LVLKCcjs = require('./chunk-IK6LVLKC.cjs');
37
37
 
38
38
 
39
39
 
40
- var _chunkPQDFUSXDcjs = require('./chunk-PQDFUSXD.cjs');
40
+ var _chunkUVW64BCBcjs = require('./chunk-UVW64BCB.cjs');
41
41
 
42
42
 
43
43
  var _chunkKCMTCM6Icjs = require('./chunk-KCMTCM6I.cjs');
@@ -75,19 +75,31 @@ var _chunk2SJ4RQ6Pcjs = require('./chunk-2SJ4RQ6P.cjs');
75
75
 
76
76
 
77
77
 
78
- var _chunkSJVKK4JEcjs = require('./chunk-SJVKK4JE.cjs');
79
78
 
79
+ var _chunkNMHWYWDRcjs = require('./chunk-NMHWYWDR.cjs');
80
80
 
81
81
 
82
82
 
83
83
 
84
- var _chunkQJ3J6MZTcjs = require('./chunk-QJ3J6MZT.cjs');
85
84
 
85
+ var _chunkJNUWCDTFcjs = require('./chunk-JNUWCDTF.cjs');
86
86
 
87
87
 
88
88
 
89
89
 
90
- var _chunkP64MIF5Bcjs = require('./chunk-P64MIF5B.cjs');
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ var _chunkADEA7PN3cjs = require('./chunk-ADEA7PN3.cjs');
98
+
99
+
100
+
101
+
102
+ var _chunkPTZ2TVNEcjs = require('./chunk-PTZ2TVNE.cjs');
91
103
 
92
104
 
93
105
  var _chunkCXP5U3RWcjs = require('./chunk-CXP5U3RW.cjs');
@@ -97,7 +109,7 @@ var _chunk3SDFA7UFcjs = require('./chunk-3SDFA7UF.cjs');
97
109
 
98
110
 
99
111
 
100
- var _chunk75WGQVQAcjs = require('./chunk-75WGQVQA.cjs');
112
+ var _chunkHITLGIAOcjs = require('./chunk-HITLGIAO.cjs');
101
113
 
102
114
 
103
115
 
@@ -107,7 +119,7 @@ var _chunkHREOKQWTcjs = require('./chunk-HREOKQWT.cjs');
107
119
  var _chunkQ5B3KJBPcjs = require('./chunk-Q5B3KJBP.cjs');
108
120
 
109
121
 
110
- var _chunkVPTDD5XFcjs = require('./chunk-VPTDD5XF.cjs');
122
+ var _chunkWBKEZXWEcjs = require('./chunk-WBKEZXWE.cjs');
111
123
 
112
124
 
113
125
 
@@ -119,7 +131,7 @@ var _chunkVPTDD5XFcjs = require('./chunk-VPTDD5XF.cjs');
119
131
  var _chunkPSV6XKPOcjs = require('./chunk-PSV6XKPO.cjs');
120
132
 
121
133
 
122
- var _chunkZHPHJPQPcjs = require('./chunk-ZHPHJPQP.cjs');
134
+ var _chunkMRMI32SNcjs = require('./chunk-MRMI32SN.cjs');
123
135
 
124
136
 
125
137
 
@@ -131,27 +143,28 @@ var _chunk6EXBPJ24cjs = require('./chunk-6EXBPJ24.cjs');
131
143
  var _chunkVEKFLAQMcjs = require('./chunk-VEKFLAQM.cjs');
132
144
 
133
145
 
134
- var _chunkUX5S4JEOcjs = require('./chunk-UX5S4JEO.cjs');
146
+ var _chunk42NHY7HWcjs = require('./chunk-42NHY7HW.cjs');
135
147
 
136
148
 
137
149
 
138
150
  var _chunkOHY2ZWUGcjs = require('./chunk-OHY2ZWUG.cjs');
139
151
 
140
152
 
141
- var _chunkXXJU7FCCcjs = require('./chunk-XXJU7FCC.cjs');
153
+ var _chunkEUV4YR3Vcjs = require('./chunk-EUV4YR3V.cjs');
142
154
 
143
155
 
144
156
 
145
- var _chunkMPEYMSCFcjs = require('./chunk-MPEYMSCF.cjs');
157
+ var _chunkSDOTRX3Vcjs = require('./chunk-SDOTRX3V.cjs');
146
158
 
147
159
 
148
160
 
149
- var _chunkTDFPACVXcjs = require('./chunk-TDFPACVX.cjs');
150
161
 
162
+ var _chunkCBJJH36Acjs = require('./chunk-CBJJH36A.cjs');
151
163
 
152
164
 
153
165
 
154
- var _chunkU74I55WBcjs = require('./chunk-U74I55WB.cjs');
166
+
167
+ var _chunkZWM5KGAAcjs = require('./chunk-ZWM5KGAA.cjs');
155
168
 
156
169
 
157
170
 
@@ -159,7 +172,7 @@ var _chunkU74I55WBcjs = require('./chunk-U74I55WB.cjs');
159
172
  var _chunkZ2HLU4IXcjs = require('./chunk-Z2HLU4IX.cjs');
160
173
 
161
174
 
162
- var _chunkMIDIZJZCcjs = require('./chunk-MIDIZJZC.cjs');
175
+ var _chunkFO427P6Icjs = require('./chunk-FO427P6I.cjs');
163
176
 
164
177
 
165
178
  var _chunkUFDAAQFXcjs = require('./chunk-UFDAAQFX.cjs');
@@ -186,6 +199,9 @@ var _chunk5QIKR7RRcjs = require('./chunk-5QIKR7RR.cjs');
186
199
  var _chunkKNBBQHO2cjs = require('./chunk-KNBBQHO2.cjs');
187
200
 
188
201
 
202
+ var _chunkDZ5ZVB2Kcjs = require('./chunk-DZ5ZVB2K.cjs');
203
+
204
+
189
205
  var _chunkC5GUTBZKcjs = require('./chunk-C5GUTBZK.cjs');
190
206
 
191
207
 
@@ -293,7 +309,7 @@ function getDocsTitle(docs) {
293
309
  }
294
310
  _chunkS3JO3N4Hcjs.__name.call(void 0, getDocsTitle, "getDocsTitle");
295
311
  function loadPages(contentDir, docs) {
296
- return _chunkZ2YLTERKcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkZ2YLTERKcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
312
+ return _chunkTE2G5IONcjs.discoverFarmDocsPages.call(void 0, contentDir, docs).map((page) => _chunkTE2G5IONcjs.loadFarmDocsPage.call(void 0, contentDir, docs, page.slug)).filter((page) => Boolean(page)).sort((a, b) => a.href.localeCompare(b.href));
297
313
  }
298
314
  _chunkS3JO3N4Hcjs.__name.call(void 0, loadPages, "loadPages");
299
315
  function findSocialImagePath(html) {
@@ -314,14 +330,14 @@ async function addHandlerRoute(routes, pathname, handler, absolutePaths) {
314
330
  }
315
331
  _chunkS3JO3N4Hcjs.__name.call(void 0, addHandlerRoute, "addHandlerRoute");
316
332
  async function compileFarmDocsManifest(docs, options) {
317
- const contentDir = _chunkZ2YLTERKcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
333
+ const contentDir = _chunkTE2G5IONcjs.resolveFarmDocsContentDir.call(void 0, docs, options);
318
334
  const pages = loadPages(contentDir, docs);
319
335
  const absolutePaths = [
320
336
  _path2.default.resolve(options.root),
321
337
  _path2.default.resolve(contentDir),
322
338
  docs.configPath || ""
323
339
  ];
324
- const handler = _chunkZ2YLTERKcjs.createFarmDocsHandler.call(void 0, docs, {
340
+ const handler = _chunkTE2G5IONcjs.createFarmDocsHandler.call(void 0, docs, {
325
341
  root: options.root,
326
342
  srcDir: options.srcDir,
327
343
  clientEntry: options.clientEntry,
@@ -329,7 +345,7 @@ async function compileFarmDocsManifest(docs, options) {
329
345
  fontStylesheetHref: options.fontStylesheetHref,
330
346
  globalStylesheetHref: options.globalStylesheetHref
331
347
  });
332
- const apiHandler = _chunkA5FGU2WUcjs.createFarmDocsAPIHandler.call(void 0, {
348
+ const apiHandler = _chunkVQLJWDVWcjs.createFarmDocsAPIHandler.call(void 0, {
333
349
  rootDir: options.root,
334
350
  srcDir: options.srcDir,
335
351
  docs
@@ -421,7 +437,7 @@ async function compileFarmDocsManifest(docs, options) {
421
437
  post: await compileResponse(postResponse, absolutePaths),
422
438
  search: {
423
439
  pages: pages.map((page) => ({
424
- ..._chunkZ2YLTERKcjs.toFarmDocsMarkdownPage.call(void 0, page),
440
+ ..._chunkTE2G5IONcjs.toFarmDocsMarkdownPage.call(void 0, page),
425
441
  sourcePath: `farm-docs:${page.slug || "index"}`
426
442
  })),
427
443
  search: _nullishCoalesce(searchConfig, () => ( true)),
@@ -441,7 +457,7 @@ async function createFarmRouteRuntimeManifest(options) {
441
457
  const routes = [];
442
458
  for (const [pattern, entry] of options.routeManager.getRoutes()) {
443
459
  const routeModule = await options.routeManager.loadRouteModule(entry.modulePath);
444
- const rendering = await _chunkQJ3J6MZTcjs.resolveRouteRenderingConfigFromFile.call(void 0, routeModule, entry.modulePath);
460
+ const rendering = await _chunkJNUWCDTFcjs.resolveRouteRenderingConfigFromFile.call(void 0, routeModule, entry.modulePath);
445
461
  const runtimeConfig = await options.routeManager.resolveRouteRuntimeConfig(pattern);
446
462
  routes.push({
447
463
  kind: "page",
@@ -761,10 +777,14 @@ export default async function farmNetlifyHandler(request, context) {
761
777
  _chunkS3JO3N4Hcjs.__name.call(void 0, createFarmNetlifyEntry, "createFarmNetlifyEntry");
762
778
 
763
779
  // src/nitro/node-server-entry.ts
780
+ var FARM_NODE_ENV_MODULE_FILE = "farm-node-env.mjs";
781
+ var FARM_NODE_ENV_MODULE_SOURCE = `if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
782
+ `;
764
783
  function createFarmNodeServerEntry(options) {
765
784
  const serverConfig = JSON.stringify(options.server);
766
785
  const nitroEntryImport = `./${options.nitroEntryFile.replace(/^\.\//, "")}`;
767
786
  return `
787
+ import "./${FARM_NODE_ENV_MODULE_FILE}";
768
788
  import "#nitro/virtual/polyfills";
769
789
  import { NodeRequest, serve } from ${JSON.stringify(options.nodeAdapterModule)};
770
790
  import wsAdapter from ${JSON.stringify(options.websocketAdapterModule)};
@@ -1580,7 +1600,7 @@ function hasFarmMiddlewareConfig(config) {
1580
1600
  _chunkS3JO3N4Hcjs.__name.call(void 0, hasFarmMiddlewareConfig, "hasFarmMiddlewareConfig");
1581
1601
  function hasFarmServerRuntimePlugins(config) {
1582
1602
  return (config.plugins || []).some((plugin) => {
1583
- if (_chunkTDFPACVXcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) === false) return false;
1603
+ if (_chunkCBJJH36Acjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) === false) return false;
1584
1604
  return Boolean(
1585
1605
  plugin.setup || plugin.init || plugin.ready || plugin.shutdown || plugin.runtime || plugin.router || plugin.render || plugin.beforeRouteMatch || plugin.afterRouteMatch || plugin.beforeRender || plugin.afterRender || plugin.onError || plugin.transformHTML
1586
1606
  );
@@ -1593,7 +1613,7 @@ function hasFarmPluginRoutes(config) {
1593
1613
  _chunkS3JO3N4Hcjs.__name.call(void 0, hasFarmPluginRoutes, "hasFarmPluginRoutes");
1594
1614
  function farmServerRuntimePluginsMayHandlePath(config, pathname) {
1595
1615
  return (config.plugins || []).some(
1596
- (plugin) => _chunkTDFPACVXcjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && _chunkSJVKK4JEcjs.farmPluginMayAffectRuntimePath.call(void 0, plugin, pathname)
1616
+ (plugin) => _chunkCBJJH36Acjs.getFarmIntegrationPluginServerRuntime.call(void 0, plugin) !== false && _chunkNMHWYWDRcjs.farmPluginMayAffectRuntimePath.call(void 0, plugin, pathname)
1597
1617
  );
1598
1618
  }
1599
1619
  _chunkS3JO3N4Hcjs.__name.call(void 0, farmServerRuntimePluginsMayHandlePath, "farmServerRuntimePluginsMayHandlePath");
@@ -1619,13 +1639,13 @@ async function discoverMiddlewareRoutes(appDir) {
1619
1639
  });
1620
1640
  }
1621
1641
  for (const entry of entries) {
1622
- if (!entry.isDirectory() || entry.name.startsWith(".") || entry.name.startsWith("_")) {
1642
+ if (!entry.isDirectory() || entry.name.startsWith(".")) {
1623
1643
  continue;
1624
1644
  }
1625
1645
  await walk(
1626
1646
  _path2.default.join(dir, entry.name),
1627
- _chunkU74I55WBcjs.appendMiddlewareRoutePath.call(void 0, routePath, entry.name),
1628
- _chunkU74I55WBcjs.appendMiddlewareDirectory.call(void 0, directory, entry.name),
1647
+ _chunkZWM5KGAAcjs.appendMiddlewareRoutePath.call(void 0, routePath, entry.name),
1648
+ _chunkZWM5KGAAcjs.appendMiddlewareDirectory.call(void 0, directory, entry.name),
1629
1649
  discovered
1630
1650
  );
1631
1651
  }
@@ -1638,7 +1658,7 @@ async function discoverMiddlewareRoutes(appDir) {
1638
1658
  routes.set(route.directory, route);
1639
1659
  }
1640
1660
  }
1641
- return Array.from(routes.values()).sort(_chunkU74I55WBcjs.compareMiddlewareRouteLocations).map(({ path: routePath, filePath }) => ({ path: routePath, filePath }));
1661
+ return Array.from(routes.values()).sort(_chunkZWM5KGAAcjs.compareMiddlewareRouteLocations).map(({ path: routePath, filePath }) => ({ path: routePath, filePath }));
1642
1662
  }
1643
1663
  _chunkS3JO3N4Hcjs.__name.call(void 0, discoverMiddlewareRoutes, "discoverMiddlewareRoutes");
1644
1664
  function assertFarmDocsRuntimeSupported(config, preset) {
@@ -1656,7 +1676,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1656
1676
  assertFarmDocsRuntimeSupported(config, preset);
1657
1677
  const srcDir = config.srcDir || "src";
1658
1678
  const distDir = config.distDir || ".farm";
1659
- const deployOutputDir = _chunkPQDFUSXDcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
1679
+ const deployOutputDir = _chunkUVW64BCBcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
1660
1680
  const lifecyclePluginManager = options.pluginManager;
1661
1681
  const productionViteResultPromise = Promise.allSettled([
1662
1682
  Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))
@@ -1675,9 +1695,10 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1675
1695
  const routeRuntimeManifestResultPromise = Promise.allSettled([routeRuntimeManifestPromise]);
1676
1696
  const pageRoutes = [];
1677
1697
  for (const [pattern, entry] of routeManager.getRoutes()) {
1678
- const markdownSourcePath = entry.markdownSourcePath || (_chunkUX5S4JEOcjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
1698
+ const markdownSourcePath = entry.markdownSourcePath || (_chunk42NHY7HWcjs.isFarmMarkdownPageFile.call(void 0, entry.modulePath) ? entry.modulePath : void 0);
1679
1699
  pageRoutes.push({
1680
1700
  pattern,
1701
+ ...entry.directory ? { directory: entry.directory } : {},
1681
1702
  modulePath: entry.modulePath,
1682
1703
  ...markdownSourcePath ? {
1683
1704
  source: _fs.readFileSync.call(void 0, markdownSourcePath, "utf8"),
@@ -1690,6 +1711,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
1690
1711
  (entry) => ({
1691
1712
  name: entry.name,
1692
1713
  ownerPattern: entry.ownerPattern,
1714
+ ...entry.ownerDirectory ? { ownerDirectory: entry.ownerDirectory } : {},
1693
1715
  pattern: entry.pattern,
1694
1716
  modulePath: entry.modulePath,
1695
1717
  containerId: entry.containerId,
@@ -1904,7 +1926,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
1904
1926
  }
1905
1927
  const normalizedFontCss = typeof fontCss === "string" ? fontCss : Buffer.from(fontCss).toString("utf8");
1906
1928
  await fs.writeFile(fontCssPath, normalizedFontCss);
1907
- await fs.writeFile(clientCssPath, _chunkSJVKK4JEcjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
1929
+ await fs.writeFile(clientCssPath, _chunkNMHWYWDRcjs.mergeFarmFontCss.call(void 0, clientCss, normalizedFontCss));
1908
1930
  }
1909
1931
  _chunkS3JO3N4Hcjs.__name.call(void 0, mergeBuiltFontCss, "mergeBuiltFontCss");
1910
1932
  var _IncompleteClientBuildOutputError = class _IncompleteClientBuildOutputError extends Error {
@@ -1954,7 +1976,7 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
1954
1976
  const key = `${_path2.default.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${_path2.default.resolve(modulePath)}`;
1955
1977
  let plan = cache.get(key);
1956
1978
  if (!plan) {
1957
- plan = _chunkSJVKK4JEcjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
1979
+ plan = _chunkNMHWYWDRcjs.getClientModuleHydrationPlan.call(void 0, modulePath, root, mode, options);
1958
1980
  cache.set(key, plan);
1959
1981
  }
1960
1982
  return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
@@ -1972,7 +1994,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
1972
1994
  });
1973
1995
  pluginManager.addPlugins(config.plugins || []);
1974
1996
  const clientPages = [];
1975
- const integrationProviders = _chunkTDFPACVXcjs.getIntegrationProviders.call(void 0, config.integrations).filter(
1997
+ const integrationProviders = _chunkCBJJH36Acjs.getIntegrationProviders.call(void 0, config.integrations).filter(
1976
1998
  (provider) => provider.component || provider.type === "clerk"
1977
1999
  );
1978
2000
  const unsupportedIntegrationProvider = integrationProviders.find(
@@ -1983,14 +2005,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
1983
2005
  `[Farm.js] isolated hydration kept route-wide because integration provider "${unsupportedIntegrationProvider.name}" does not declare supportsIsolatedHydration: true.`
1984
2006
  );
1985
2007
  }
1986
- const isolatedMode = _chunkSJVKK4JEcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
2008
+ const isolatedMode = _chunkNMHWYWDRcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
1987
2009
  _optionalChain([config, 'access', _35 => _35.experimental, 'optionalAccess', _36 => _36.isolatedClientHydration]),
1988
2010
  {
1989
2011
  serverComponents: _optionalChain([config, 'access', _37 => _37.experimental, 'optionalAccess', _38 => _38.serverComponents]) === true,
1990
2012
  hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
1991
2013
  }
1992
2014
  );
1993
- const planOptions = _chunkSJVKK4JEcjs.getFarmClientHydrationPlanOptions.call(void 0,
2015
+ const planOptions = _chunkNMHWYWDRcjs.getFarmClientHydrationPlanOptions.call(void 0,
1994
2016
  config.renderer,
1995
2017
  Boolean(unsupportedIntegrationProvider)
1996
2018
  );
@@ -2037,7 +2059,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2037
2059
  };
2038
2060
  }
2039
2061
  });
2040
- const layoutAppliesToRoute = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (layoutPattern, routePattern) => layoutPattern === "/" || routePattern === layoutPattern || routePattern.startsWith(`${layoutPattern}/`), "layoutAppliesToRoute");
2062
+ const layoutAppliesToRoute = _chunkADEA7PN3cjs.routeBoundaryCoversDirectory;
2063
+ const routeDirectory = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (route) => _nullishCoalesce(route.directory, () => ( route.pattern)), "routeDirectory");
2041
2064
  const adapterOwnsDocsRuntime = Boolean(
2042
2065
  _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _39 => _39.docs, 'optionalAccess', _40 => _40.enabled]) && _optionalChain([config, 'access', _41 => _41.docs, 'access', _42 => _42.adapter, 'optionalAccess', _43 => _43.server]) && config.docs.adapter.react
2043
2066
  );
@@ -2047,7 +2070,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2047
2070
  ), "isAdapterDocsRoute");
2048
2071
  const syntheticDocsEntry = _optionalChain([config, 'access', _46 => _46.docs, 'optionalAccess', _47 => _47.enabled]) && !adapterOwnsDocsRuntime ? adapterDocsEntry : null;
2049
2072
  const syntheticDocsPatterns = syntheticDocsEntry ? syntheticDocsEntry === "/" ? ["/", "/[...slug]"] : [syntheticDocsEntry, `${syntheticDocsEntry}/[...slug]`] : [];
2050
- const markdownPagePlan = _chunkSJVKK4JEcjs.createMarkdownPageHydrationPlanner.call(void 0,
2073
+ const markdownPagePlan = _chunkNMHWYWDRcjs.createMarkdownPageHydrationPlanner.call(void 0,
2051
2074
  _chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), root),
2052
2075
  root,
2053
2076
  isolatedMode,
@@ -2055,7 +2078,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2055
2078
  );
2056
2079
  const routePlans = pageRoutes.map((route) => ({
2057
2080
  route,
2058
- metadata: _chunkUX5S4JEOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2081
+ metadata: _chunk42NHY7HWcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
2059
2082
  route.modulePath,
2060
2083
  root,
2061
2084
  isolatedMode,
@@ -2063,7 +2086,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2063
2086
  planOptions
2064
2087
  )
2065
2088
  }));
2066
- _chunkSJVKK4JEcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
2089
+ _chunkNMHWYWDRcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
2067
2090
  clientLayouts.map((layout) => ({
2068
2091
  pattern: layout.pattern,
2069
2092
  depth: layout.pattern.split("/").filter(Boolean).length,
@@ -2071,8 +2094,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2071
2094
  })),
2072
2095
  [
2073
2096
  ...routePlans.map(({ route, metadata }) => ({
2074
- pattern: route.pattern,
2075
- depth: route.pattern.split("/").filter(Boolean).length,
2097
+ pattern: routeDirectory(route),
2098
+ depth: _chunkADEA7PN3cjs.getRouteDirectoryDepth.call(void 0, routeDirectory(route)),
2076
2099
  metadata
2077
2100
  })),
2078
2101
  ...syntheticDocsPatterns.map((pattern) => ({
@@ -2093,9 +2116,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2093
2116
  layoutAppliesToRoute
2094
2117
  );
2095
2118
  for (const layout of clientLayouts) {
2096
- const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, route.pattern)) || Boolean(adapterDocsEntry && layoutAppliesToRoute(layout.pattern, adapterDocsEntry));
2119
+ const matchesBuiltRoute = pageRoutes.some((route) => layoutAppliesToRoute(layout.pattern, routeDirectory(route))) || Boolean(adapterDocsEntry && layoutAppliesToRoute(layout.pattern, adapterDocsEntry));
2097
2120
  if (matchesBuiltRoute && layout.suppressedAsyncHydration) {
2098
- _chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${_chunkSJVKK4JEcjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`);
2121
+ _chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F ${_chunkNMHWYWDRcjs.describeSuppressedAsyncHydration.call(void 0, layout.pattern, layout.fallbackReason)}`);
2099
2122
  }
2100
2123
  }
2101
2124
  if (isolatedMode === "analyze") {
@@ -2115,11 +2138,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2115
2138
  if (isAdapterDocsRoute(route.pattern)) continue;
2116
2139
  try {
2117
2140
  const applicableClientLayouts = clientLayouts.filter(
2118
- (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, route.pattern)
2141
+ (layout) => (layout.shouldHydrate || layout.hasIsolatedClientBoundaries) && layoutAppliesToRoute(layout.pattern, routeDirectory(route))
2119
2142
  );
2120
2143
  if (metadata.suppressedAsyncHydration) {
2121
2144
  _chunk5QIKR7RRcjs.logger.warn(
2122
- `\u26A0\uFE0F ${_chunkSJVKK4JEcjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
2145
+ `\u26A0\uFE0F ${_chunkNMHWYWDRcjs.describeSuppressedAsyncHydration.call(void 0, route.pattern, metadata.fallbackReason)}`
2123
2146
  );
2124
2147
  }
2125
2148
  if (metadata.shouldHydrate || metadata.hasIsolatedClientBoundaries || applicableClientLayouts.length > 0) {
@@ -2142,7 +2165,9 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2142
2165
  isolatedBoundaries: [
2143
2166
  ...metadata.hasIsolatedClientBoundaries ? metadata.isolatedBoundaries : [],
2144
2167
  ...applicableClientLayouts.filter((layout) => layout.hasIsolatedClientBoundaries).flatMap((layout) => layout.isolatedBoundaries)
2145
- ]
2168
+ ],
2169
+ // The server renders a server tree only below a hydrating layout.
2170
+ ..._chunkNMHWYWDRcjs.usesFarmServerTree.call(void 0, metadata) && applicableClientLayouts.some((layout) => layout.shouldHydrate) ? { serverTree: true } : {}
2146
2171
  });
2147
2172
  _chunk5QIKR7RRcjs.logger.info(`\u{1F4F1} Found hydratable route: ${route.pattern} -> ${route.modulePath}`);
2148
2173
  }
@@ -2178,7 +2203,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2178
2203
  }
2179
2204
  const clientRouteSlots = routeSlots.filter((slot) => {
2180
2205
  try {
2181
- return _chunkSJVKK4JEcjs.getClientModuleMetadata.call(void 0, slot.modulePath, root).shouldHydrate;
2206
+ return _chunkNMHWYWDRcjs.getClientModuleMetadata.call(void 0, slot.modulePath, root).shouldHydrate;
2182
2207
  } catch (error) {
2183
2208
  _chunk5QIKR7RRcjs.logger.warn(`\u26A0\uFE0F Could not inspect route slot ${slot.modulePath}: ${error}`);
2184
2209
  return false;
@@ -2206,10 +2231,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2206
2231
  config.renderer,
2207
2232
  config.publicRuntimeConfig,
2208
2233
  config.trailingSlash,
2209
- _chunkTDFPACVXcjs.getIntegrationProviders.call(void 0, config.integrations),
2234
+ _chunkCBJJH36Acjs.getIntegrationProviders.call(void 0, config.integrations),
2210
2235
  config.basePath,
2211
- _chunkSJVKK4JEcjs.generateClientCachePersistenceCode.call(void 0, _chunkSJVKK4JEcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
2212
- adapterOwnsDocsRuntime ? _chunk75WGQVQAcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
2236
+ _chunkNMHWYWDRcjs.generateClientCachePersistenceCode.call(void 0, _chunkNMHWYWDRcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, config.cache)),
2237
+ adapterOwnsDocsRuntime ? _chunkHITLGIAOcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
2213
2238
  );
2214
2239
  await fs.writeFile(clientEntryPath, clientHydrationCode);
2215
2240
  const hasScopedPostcssConfig = hasProjectPostcssConfig(root);
@@ -2225,7 +2250,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2225
2250
  const postcssConfigPath = _path2.default.join(clientEntryDir, "postcss.config.cjs");
2226
2251
  await fs.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
2227
2252
  postcssSearchPath = clientEntryDir;
2228
- tailwindVitePlugin = await _chunkSJVKK4JEcjs.loadTailwindVitePlugin.call(void 0, {
2253
+ tailwindVitePlugin = await _chunkNMHWYWDRcjs.loadTailwindVitePlugin.call(void 0, {
2229
2254
  builder: productionVite.builder,
2230
2255
  announce: true
2231
2256
  });
@@ -2294,11 +2319,14 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2294
2319
  }
2295
2320
  },
2296
2321
  plugins: [
2297
- _chunkSJVKK4JEcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
2322
+ _chunkNMHWYWDRcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
2298
2323
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
2299
2324
  ...rendererVitePlugins,
2300
2325
  ...config.vite.plugins || [],
2301
2326
  farmServerOnlyEntriesPlugin(),
2327
+ _chunkNMHWYWDRcjs.farmDocsClientConfigPlugin.call(void 0,
2328
+ adapterOwnsDocsRuntime ? _chunkHITLGIAOcjs.getFarmDocsAdapterConfigModule.call(void 0, config.docs) : void 0
2329
+ ),
2302
2330
  // Plugin to redirect @farm.js/core imports to client-only exports
2303
2331
  {
2304
2332
  name: "farm-client-only-imports",
@@ -2355,7 +2383,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2355
2383
  } : void 0,
2356
2384
  // Ensure React is bundled for client
2357
2385
  resolve: {
2358
- alias: _chunkSJVKK4JEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
2386
+ alias: _chunkNMHWYWDRcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
2359
2387
  dedupe: [...config.renderer.dedupe || []]
2360
2388
  },
2361
2389
  // Optimize dependencies - exclude server-side code from client bundle
@@ -2368,7 +2396,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2368
2396
  ]
2369
2397
  }
2370
2398
  };
2371
- await viteBuild(_chunkSJVKK4JEcjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite));
2399
+ await viteBuild(_chunkNMHWYWDRcjs.mergeFarmProductionViteConfig.call(void 0, clientViteConfig, config.vite));
2372
2400
  await mergeBuiltFontCss(outputDir);
2373
2401
  await validateClientBuildOutput(root, srcDir, outputDir);
2374
2402
  } finally {
@@ -3127,7 +3155,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
3127
3155
  direction: {}
3128
3156
  }, plugins = [], renderer = _chunkPSV6XKPOcjs.REACT_RENDERER, publicRuntimeConfig = void 0, trailingSlash = false, integrationProviders = [], basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule) {
3129
3157
  const toImportPath = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (targetPath) => targetPath.replace(/\\/g, "/"), "toImportPath");
3130
- const clientPluginEntry = _chunkSJVKK4JEcjs.generateFarmClientPluginEntryCode.call(void 0,
3158
+ const clientPluginEntry = _chunkNMHWYWDRcjs.generateFarmClientPluginEntryCode.call(void 0,
3131
3159
  plugins,
3132
3160
  root,
3133
3161
  srcDir,
@@ -3138,7 +3166,7 @@ function generateClientHydrationEntry(clientPages, layoutRoutes, clientRouteSlot
3138
3166
  import { createRoot, hydrateRoot } from "react-dom/client";` : appSetupPath ? `import React, { createRoot, hydrateRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)};
3139
3167
  import __farmAppSetup from ${JSON.stringify(_chunk5QIKR7RRcjs.toPosixPath.call(void 0, appSetupPath))};
3140
3168
  __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot } from ${JSON.stringify(renderer.client)};`;
3141
- const providerClientCode = _chunkSJVKK4JEcjs.generateFarmIntegrationProviderClientCode.call(void 0,
3169
+ const providerClientCode = _chunkNMHWYWDRcjs.generateFarmIntegrationProviderClientCode.call(void 0,
3142
3170
  integrationProviders,
3143
3171
  root,
3144
3172
  _nullishCoalesce(renderer.componentExtensions, () => ( []))
@@ -3152,8 +3180,10 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
3152
3180
  if (!layout.hasIsolatedClientBoundaries) {
3153
3181
  layoutImportStatements.push(`import Layout${index} from "${relativePath}";`);
3154
3182
  }
3183
+ const groupScope = _chunkADEA7PN3cjs.getRouteGroupScope.call(void 0, layout.pattern);
3184
+ const groupFields = groupScope ? `, urlPattern: ${JSON.stringify(_chunkADEA7PN3cjs.stripRouteGroups.call(void 0, layout.pattern))}, groupScope: ${JSON.stringify(groupScope)}` : "";
3155
3185
  layoutRegistrations.push(
3156
- ` { pattern: ${JSON.stringify(layout.pattern)}, Component: ${layout.hasIsolatedClientBoundaries ? "null" : `Layout${index}`}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)} }`
3186
+ ` { pattern: ${JSON.stringify(layout.pattern)}${groupFields}, Component: ${layout.hasIsolatedClientBoundaries ? "null" : `Layout${index}`}, shouldHydrate: ${JSON.stringify(layout.shouldHydrate)}, islandStrategy: ${JSON.stringify(layout.islandStrategy)} }`
3157
3187
  );
3158
3188
  });
3159
3189
  const layoutImports = layoutImportStatements.join("\n");
@@ -3201,7 +3231,7 @@ function isFarmDocsPath() {
3201
3231
  return false;
3202
3232
  }
3203
3233
  `;
3204
- const docsAdapterRuntime = _chunk75WGQVQAcjs.generateFarmDocsAdapterClientRuntime.call(void 0,
3234
+ const docsAdapterRuntime = _chunkHITLGIAOcjs.generateFarmDocsAdapterClientRuntime.call(void 0,
3205
3235
  docsAdapterReact,
3206
3236
  docsConfigModule
3207
3237
  );
@@ -3498,7 +3528,8 @@ document.addEventListener("click", function(e) {
3498
3528
  }
3499
3529
  const load = page.pageShouldHydrate ? `() => import(${JSON.stringify(toImportPath(page.modulePath))}).then((module) => module.default)` : "null";
3500
3530
  routeEntries.push(` {
3501
- pattern: ${JSON.stringify(page.pattern)},
3531
+ pattern: ${JSON.stringify(page.pattern)},${page.directory ? `
3532
+ directory: ${JSON.stringify(page.directory)},` : ""}
3502
3533
  pageShouldHydrate: ${JSON.stringify(page.pageShouldHydrate)},
3503
3534
  ${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
3504
3535
  islandStrategy: ${JSON.stringify(page.islandStrategy)},
@@ -3507,20 +3538,22 @@ document.addEventListener("click", function(e) {
3507
3538
  }`);
3508
3539
  });
3509
3540
  const isolatedHydrationEnabled = isolatedBoundaryModules.size > 0;
3510
- const isolatedHydrationImport = isolatedHydrationEnabled ? `import { createFarmIsolatedHydrationRuntime, createFarmServerPageBoundary, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";` : "";
3541
+ const serverTreeEnabled = isolatedHydrationEnabled && clientPages.some((page) => page.serverTree);
3542
+ const isolatedHydrationImport = isolatedHydrationEnabled ? `import { createFarmIsolatedHydrationRuntime, createFarmServerPageBoundary, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";${serverTreeEnabled ? '\nimport { createFarmServerTreeElement } from "@farm.js/core/internal/server-tree";' : ""}` : "";
3511
3543
  const isolatedHydrationRuntime = isolatedHydrationEnabled ? `const farmIsolatedBoundaryLoaders = {
3512
3544
  ${Array.from(isolatedBoundaryModules.entries()).map(
3513
3545
  ([reference, modulePath]) => ` ${JSON.stringify(reference)}: () => import(${JSON.stringify(modulePath)}),`
3514
3546
  ).join("\n")}
3515
3547
  };
3548
+ async function loadFarmIsolatedBoundary(reference) {
3549
+ const loader = farmIsolatedBoundaryLoaders[reference];
3550
+ if (!loader) throw new Error("isolated client boundary loader was not found: " + reference);
3551
+ return loader();
3552
+ }
3516
3553
  const farmIsolatedHydrationRuntime = createFarmIsolatedHydrationRuntime({
3517
3554
  ReactRuntime: React,
3518
3555
  hydrateRoot,
3519
- load: async function(reference) {
3520
- const loader = farmIsolatedBoundaryLoaders[reference];
3521
- if (!loader) throw new Error("isolated client boundary loader was not found: " + reference);
3522
- return loader();
3523
- },
3556
+ load: loadFarmIsolatedBoundary,
3524
3557
  schedule: scheduleFarmIslandHydration,
3525
3558
  wrap: wrapWithIntegrationProviders,
3526
3559
  });
@@ -3534,7 +3567,21 @@ function disposeFarmIsolatedClientBoundaries(scope) {
3534
3567
 
3535
3568
  async function hydrateFarmIsolatedClientBoundaries(scope = document, signal) {
3536
3569
  await farmIsolatedHydrationRuntime.hydrate(scope, signal);
3537
- }` : "";
3570
+ }
3571
+ ${serverTreeEnabled ? `
3572
+ // A server-tree page (an async page below a hydrating layout) rebuilds in the layout's root.
3573
+ async function createFarmServerTreePageElement(source, pathname) {
3574
+ try {
3575
+ return await createFarmServerTreeElement(React, source, {
3576
+ load: loadFarmIsolatedBoundary,
3577
+ ServerHtml: FarmServerPage,
3578
+ key: pathname,
3579
+ });
3580
+ } catch (error) {
3581
+ console.warn("[Farm.js] Could not rebuild the server tree of " + pathname + "; its server HTML was kept.", error);
3582
+ return null;
3583
+ }
3584
+ }` : "async function createFarmServerTreePageElement() { return null; }"}` : `async function createFarmServerTreePageElement() { return null; }`;
3538
3585
  const routeClientGraphRuntime = isolatedHydrationEnabled ? `function wrapFarmRouteClientGraph(element) {
3539
3586
  return wrapFarmIsolatedClientGraph(React, element);
3540
3587
  }` : `function wrapFarmRouteClientGraph(element) { return element; }`;
@@ -3601,11 +3648,24 @@ ${layoutRegistrations.join(",\n")}
3601
3648
  function getApplicableLayouts(pathname) {
3602
3649
  const applicable = [];
3603
3650
  const normalizedPath = getFarmRoutePathname(pathname).replace(/\\/$/, '') || '/';
3651
+ let directory;
3604
3652
 
3605
3653
  for (const layout of layoutRoutes) {
3606
- if (layout.pattern === '/' || isFarmRouteActive(layout.pattern, normalizedPath, { exact: false })) {
3607
- applicable.push(layout);
3654
+ // Route groups add no URL segment: match the layout's URL, then keep a
3655
+ // grouped layout to the pages inside its group directory.
3656
+ const urlPattern = layout.urlPattern || layout.pattern;
3657
+ if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, normalizedPath, { exact: false })) continue;
3658
+ if (layout.groupScope) {
3659
+ if (directory === undefined) {
3660
+ const matched = matchRoute(pathname);
3661
+ directory = matched ? matched.route.directory || matched.route.pattern : null;
3662
+ }
3663
+ if (
3664
+ typeof directory !== 'string' ||
3665
+ (directory !== layout.groupScope && !directory.startsWith(layout.groupScope + '/'))
3666
+ ) continue;
3608
3667
  }
3668
+ applicable.push(layout);
3609
3669
  }
3610
3670
 
3611
3671
  // Sort by depth (root first)
@@ -3624,7 +3684,7 @@ function hasHydratableLayout(pathname) {
3624
3684
  });
3625
3685
  }
3626
3686
 
3627
- ${_chunkSJVKK4JEcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
3687
+ ${_chunkNMHWYWDRcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
3628
3688
  // Wrap a page element with applicable layouts
3629
3689
  function wrapWithLayouts(pageElement, pathname, params) {
3630
3690
  const layouts = getApplicableLayouts(pathname);
@@ -3674,6 +3734,16 @@ async function loadRouteComponent(route) {
3674
3734
  return route.Component;
3675
3735
  }
3676
3736
 
3737
+ // The props the server rendered this document with, as the page receives them:
3738
+ // middleware data arrives as a plain object and is a Map again here.
3739
+ function reviveServerPageProps(serverProps) {
3740
+ if (!serverProps || typeof serverProps !== "object") return {};
3741
+ const middleware = serverProps.middleware;
3742
+ return middleware && middleware.data && !(middleware.data instanceof Map)
3743
+ ? { ...serverProps, middleware: { ...middleware, data: new Map(Object.entries(middleware.data)) } }
3744
+ : serverProps;
3745
+ }
3746
+
3677
3747
  async function createMatchedHydrationRoute(matched, pathname, searchParams, serverHtml, serverProps) {
3678
3748
  const hydrateLayouts = hasHydratableLayout(pathname);
3679
3749
  const params = matched.params;
@@ -3687,12 +3757,8 @@ async function createMatchedHydrationRoute(matched, pathname, searchParams, serv
3687
3757
  // rejected guard, deferred data) its server-rendered HTML is kept.
3688
3758
  if (Component.__farmServerProps === true) {
3689
3759
  if (!serverProps || serverProps.__farmRoutePropsResolved !== true) return null;
3690
- const middleware = serverProps.middleware;
3691
3760
  const props = {
3692
- ...serverProps,
3693
- ...(middleware && middleware.data && !(middleware.data instanceof Map)
3694
- ? { middleware: { ...middleware, data: new Map(Object.entries(middleware.data)) } }
3695
- : {}),
3761
+ ...reviveServerPageProps(serverProps),
3696
3762
  searchParams: Promise.resolve(serverProps.search ?? searchParams),
3697
3763
  };
3698
3764
  pageElement = React.createElement(Component, props);
@@ -3703,16 +3769,26 @@ async function createMatchedHydrationRoute(matched, pathname, searchParams, serv
3703
3769
  );
3704
3770
  return null;
3705
3771
  } else {
3706
- const props = { params: params, searchParams: Promise.resolve(searchParams) };
3772
+ // Keep what the server rendered with, such as middleware data, so the
3773
+ // first render matches the HTML. A navigation passes the fetched document's props.
3774
+ const props = {
3775
+ ...reviveServerPageProps(serverProps),
3776
+ params: params,
3777
+ searchParams: Promise.resolve(searchParams),
3778
+ };
3707
3779
  pageElement = React.createElement(Component, props);
3708
3780
  }
3709
3781
  } else if (hydrateLayouts) {
3710
3782
  const serverPage = document.getElementById("__farm_page__");
3711
- pageElement = createLayoutPageBoundary(
3712
- matched.route,
3713
- null,
3714
- typeof serverHtml === "string" ? serverHtml : serverPage ? serverPage.innerHTML : "",
3715
- );
3783
+ const pageSource = typeof serverHtml === "string" ? serverHtml : serverPage;
3784
+ const serverTree = pageSource ? await createFarmServerTreePageElement(pageSource, pathname) : null;
3785
+ pageElement = serverTree
3786
+ ? createLayoutPageBoundary(matched.route, serverTree)
3787
+ : createLayoutPageBoundary(
3788
+ matched.route,
3789
+ null,
3790
+ typeof serverHtml === "string" ? serverHtml : serverPage ? serverPage.innerHTML : "",
3791
+ );
3716
3792
  }
3717
3793
 
3718
3794
  if (!pageElement) return null;
@@ -4587,7 +4663,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4587
4663
  _path2.default.join(postcssConfigDir, "postcss.config.cjs"),
4588
4664
  "module.exports = { plugins: [] };\n"
4589
4665
  );
4590
- tailwindVitePlugin = await _chunkSJVKK4JEcjs.loadTailwindVitePlugin.call(void 0, {
4666
+ tailwindVitePlugin = await _chunkNMHWYWDRcjs.loadTailwindVitePlugin.call(void 0, {
4591
4667
  builder: productionVite.builder,
4592
4668
  label: "for SSR"
4593
4669
  });
@@ -4662,7 +4738,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4662
4738
  })
4663
4739
  );
4664
4740
  const i18nCatalogs = config.i18n.enabled ? (await _chunkUFDAAQFXcjs.readFarmI18nCatalogs.call(void 0, config.i18n)).catalogs : {};
4665
- const appDirs = _chunkVPTDD5XFcjs.getFarmAppDirectories.call(void 0, config);
4741
+ const appDirs = _chunkWBKEZXWEcjs.getFarmAppDirectories.call(void 0, config);
4666
4742
  let openAPIReference = null;
4667
4743
  if (config.openapi.enabled && config.openapi.route) {
4668
4744
  const { OpenAPIManager, renderOpenAPIReferenceHTML } = await import("./manager-XZ5TX7AO.cjs");
@@ -4683,7 +4759,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4683
4759
  }
4684
4760
  const middlewareRoutes = await discoverMiddlewareRoutes(appDirs);
4685
4761
  const instrumentationPath = _chunkKCMTCM6Icjs.resolveFarmInstrumentationFile.call(void 0, root, config.srcDir || "src");
4686
- const notFoundPath = _chunkSJVKK4JEcjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
4762
+ const notFoundPath = _chunkNMHWYWDRcjs.resolveFarmNotFoundComponentPath.call(void 0, config, appDirs);
4687
4763
  if (notFoundPath) _chunk5QIKR7RRcjs.logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
4688
4764
  layoutRoutes.sort((a, b) => {
4689
4765
  const depthA = a.pattern.split("/").filter(Boolean).length;
@@ -4700,13 +4776,13 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4700
4776
  const hasServerRuntimeIntegrations = configuredIntegrationValues.some(
4701
4777
  (integration) => typeof integration === "object" && integration !== null && (!("serverRuntime" in integration) || integration.serverRuntime !== false)
4702
4778
  );
4703
- const hasIntegrationProviders = _chunkTDFPACVXcjs.getIntegrationProviders.call(void 0, config.integrations).some(
4779
+ const hasIntegrationProviders = _chunkCBJJH36Acjs.getIntegrationProviders.call(void 0, config.integrations).some(
4704
4780
  (provider) => provider.component || provider.type === "clerk"
4705
4781
  );
4706
4782
  const hasObservabilityHandler = !!config.observability && typeof config.observability === "object" && "onEvent" in config.observability;
4707
4783
  const hasMdxComponentConfig = Boolean(_optionalChain([config, 'access', _56 => _56.mdx, 'optionalAccess', _57 => _57.components]));
4708
4784
  const hasMiddlewareConfig = hasFarmMiddlewareConfig(config.middleware);
4709
- const hasRouteContextConfig = _chunkPQDFUSXDcjs.hasCustomFarmRouteContext.call(void 0, config);
4785
+ const hasRouteContextConfig = _chunkUVW64BCBcjs.hasCustomFarmRouteContext.call(void 0, config);
4710
4786
  const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
4711
4787
  const hasPluginRoutes = hasFarmPluginRoutes(config);
4712
4788
  const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
@@ -4716,7 +4792,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4716
4792
  const hasConfiguredRuntimePlugins = Boolean(
4717
4793
  hasRuntimeConfigModule && (config.plugins || []).length > 0
4718
4794
  );
4719
- const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _58 => _58.docs, 'optionalAccess', _59 => _59.enabled]) && _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? _optionalChain([config, 'access', _60 => _60.docs, 'access', _61 => _61.adapter, 'optionalAccess', _62 => _62.server]) ? await _chunkA5FGU2WUcjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
4795
+ const farmDocsPrecompiledManifest = _optionalChain([config, 'access', _58 => _58.docs, 'optionalAccess', _59 => _59.enabled]) && _chunkC5GUTBZKcjs.getFarmPresetRuntime.call(void 0, preset) === "edge" ? _optionalChain([config, 'access', _60 => _60.docs, 'access', _61 => _61.adapter, 'optionalAccess', _62 => _62.server]) ? await _chunkVQLJWDVWcjs.compileFarmDocsAdapterEdgeManifest.call(void 0, config.docs, {
4720
4796
  root,
4721
4797
  srcDir: config.srcDir,
4722
4798
  clientEntry: FARM_CLIENT_JS_SRC_PLACEHOLDER,
@@ -4866,7 +4942,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4866
4942
  __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _68 => _68.env, 'optionalAccess', _69 => _69.public]) || {})
4867
4943
  },
4868
4944
  plugins: [
4869
- _chunkSJVKK4JEcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
4945
+ _chunkNMHWYWDRcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
4870
4946
  ...tailwindVitePlugin ? [tailwindVitePlugin] : [],
4871
4947
  ...rendererVitePlugins,
4872
4948
  ...config.vite.plugins || [],
@@ -4913,7 +4989,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4913
4989
  resolve: {
4914
4990
  alias: [
4915
4991
  ...shouldAliasReactServerToWebBuild(config.renderer, preset) ? [createFarmReactWebServerAlias(hasReactDomEdgeServerBuild(root))] : [],
4916
- ...Object.entries(_chunkSJVKK4JEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
4992
+ ...Object.entries(_chunkNMHWYWDRcjs.createFarmSourceAlias.call(void 0, root, config.srcDir)).map(
4917
4993
  ([find, replacement]) => ({ find, replacement })
4918
4994
  )
4919
4995
  ],
@@ -4921,7 +4997,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4921
4997
  dedupe: [...config.renderer.dedupe || []]
4922
4998
  }
4923
4999
  };
4924
- await viteBuild(_chunkSJVKK4JEcjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
5000
+ await viteBuild(_chunkNMHWYWDRcjs.mergeFarmProductionViteConfig.call(void 0, serverViteConfig, config.vite));
4925
5001
  } finally {
4926
5002
  if (postcssConfigDir) {
4927
5003
  try {
@@ -4937,6 +5013,28 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
4937
5013
  };
4938
5014
  }
4939
5015
  _chunkS3JO3N4Hcjs.__name.call(void 0, buildSSRInMemory, "buildSSRInMemory");
5016
+ function readFarmAppPackageIdentity(root) {
5017
+ try {
5018
+ return JSON.parse(_fs.readFileSync.call(void 0, _path2.default.join(root, "package.json"), "utf8"));
5019
+ } catch (e22) {
5020
+ return {};
5021
+ }
5022
+ }
5023
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readFarmAppPackageIdentity, "readFarmAppPackageIdentity");
5024
+ function readFarmPageLastModified(pageRoutes) {
5025
+ const lastModified = {};
5026
+ for (const route of pageRoutes) {
5027
+ if (route.pattern.includes("[")) continue;
5028
+ try {
5029
+ lastModified[route.pattern] = _fs.statSync.call(void 0,
5030
+ _nullishCoalesce(route.markdownSourcePath, () => ( route.modulePath))
5031
+ ).mtime.toISOString();
5032
+ } catch (e23) {
5033
+ }
5034
+ }
5035
+ return lastModified;
5036
+ }
5037
+ _chunkS3JO3N4Hcjs.__name.call(void 0, readFarmPageLastModified, "readFarmPageLastModified");
4940
5038
  function getFarmAppOwnedDocsEnginePaths(agent, applicationMetadataRoutes) {
4941
5039
  const llmsTxt = _optionalChain([agent, 'optionalAccess', _70 => _70.llmsTxt]);
4942
5040
  const ownedByFile = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (kind) => applicationMetadataRoutes.some(
@@ -4945,8 +5043,8 @@ function getFarmAppOwnedDocsEnginePaths(agent, applicationMetadataRoutes) {
4945
5043
  return [
4946
5044
  ..._optionalChain([llmsTxt, 'optionalAccess', _71 => _71.enabled]) || ownedByFile("llms") ? ["/llms.txt"] : [],
4947
5045
  ..._optionalChain([llmsTxt, 'optionalAccess', _72 => _72.enabled]) && llmsTxt.full || ownedByFile("llms-full") ? ["/llms-full.txt"] : [],
4948
- ...ownedByFile("sitemap") ? ["/sitemap.xml"] : [],
4949
- ..._optionalChain([agent, 'optionalAccess', _73 => _73.crawlers, 'optionalAccess', _74 => _74.enabled]) || ownedByFile("robots") ? ["/robots.txt"] : []
5046
+ ..._optionalChain([agent, 'optionalAccess', _73 => _73.sitemap, 'optionalAccess', _74 => _74.enabled]) || ownedByFile("sitemap") ? ["/sitemap.xml"] : [],
5047
+ ..._optionalChain([agent, 'optionalAccess', _75 => _75.crawlers, 'optionalAccess', _76 => _76.enabled]) || ownedByFile("robots") ? ["/robots.txt"] : []
4950
5048
  ];
4951
5049
  }
4952
5050
  _chunkS3JO3N4Hcjs.__name.call(void 0, getFarmAppOwnedDocsEnginePaths, "getFarmAppOwnedDocsEnginePaths");
@@ -4988,7 +5086,7 @@ function toVirtualEntryImportSpecifier(modulePath) {
4988
5086
  }
4989
5087
  _chunkS3JO3N4Hcjs.__name.call(void 0, toVirtualEntryImportSpecifier, "toVirtualEntryImportSpecifier");
4990
5088
  function generateNativeAuthIntegrationSource(auth) {
4991
- if (_optionalChain([auth, 'optionalAccess', _75 => _75.enabled]) !== true) {
5089
+ if (_optionalChain([auth, 'optionalAccess', _77 => _77.enabled]) !== true) {
4992
5090
  return { importSource: "", registerSource: "" };
4993
5091
  }
4994
5092
  return {
@@ -5011,7 +5109,7 @@ function matchLocalIntegrationRequest(request) {
5011
5109
  });` : "return null;"}
5012
5110
  }
5013
5111
 
5014
- async function handleIntegrationRequest(request) {
5112
+ async function handleIntegrationRequest(request, ranMiddleware) {
5015
5113
  ${options.hasServerRuntimeIntegrations ? `return dispatchIntegrationRequests(
5016
5114
  serverRuntimeIntegrations,
5017
5115
  {
@@ -5020,6 +5118,7 @@ async function handleIntegrationRequest(request) {
5020
5118
  isProd: true,
5021
5119
  },
5022
5120
  request,
5121
+ { ranMiddleware },
5023
5122
  );` : `return { response: null, setCookies: [] };`}
5024
5123
  }
5025
5124
 
@@ -5107,10 +5206,10 @@ _chunkS3JO3N4Hcjs.__name.call(void 0, generateConfiguredResponseHeadersRuntimeSo
5107
5206
  function parseRouteRenderingDirectiveFromDisk(modulePath) {
5108
5207
  try {
5109
5208
  const source = _fs.readFileSync.call(void 0, modulePath, "utf8");
5110
- const directive = _chunkQJ3J6MZTcjs.parseRouteRenderingDirective.call(void 0, source);
5111
- if (_chunkQJ3J6MZTcjs.findRequestBoundSourceBlockers.call(void 0, source).length === 0) return directive;
5209
+ const directive = _chunkJNUWCDTFcjs.parseRouteRenderingDirective.call(void 0, source);
5210
+ if (_chunkJNUWCDTFcjs.findRequestBoundSourceBlockers.call(void 0, source).length === 0) return directive;
5112
5211
  return { ..._nullishCoalesce(directive, () => ( { ssg: false, ppr: false, directive: "" })), requestBound: true };
5113
- } catch (e22) {
5212
+ } catch (e24) {
5114
5213
  return void 0;
5115
5214
  }
5116
5215
  }
@@ -5297,14 +5396,19 @@ ReactDOMServer.configureApp(__farmAppSetup);`;
5297
5396
  _chunkS3JO3N4Hcjs.__name.call(void 0, generateFarmRendererAppSetupServerCode, "generateFarmRendererAppSetupServerCode");
5298
5397
  function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache) {
5299
5398
  const hasCompressionRuntime = config.compress && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
5300
- const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _76 => _76.agent, 'optionalAccess', _77 => _77.crawlers, 'optionalAccess', _78 => _78.enabled])) && !applicationMetadataRoutes.some(
5399
+ const servesAgentRobotsTxt = Boolean(_optionalChain([config, 'access', _78 => _78.agent, 'optionalAccess', _79 => _79.crawlers, 'optionalAccess', _80 => _80.enabled])) && !applicationMetadataRoutes.some(
5301
5400
  (metadata) => metadata.kind === "robots" && metadata.pattern === "/"
5302
5401
  );
5402
+ const servesAgentSitemap = Boolean(_optionalChain([config, 'access', _81 => _81.agent, 'optionalAccess', _82 => _82.sitemap, 'optionalAccess', _83 => _83.enabled])) && !applicationMetadataRoutes.some(
5403
+ (metadata) => metadata.kind === "sitemap" && metadata.pattern === "/"
5404
+ );
5405
+ const servesDefaultMCP = _optionalChain([config, 'access', _84 => _84.agent, 'optionalAccess', _85 => _85.mcp]) === true && !_chunkPTZ2TVNEcjs.farmConfigMountsMCP.call(void 0, config) && !apiRoutes.some((route) => route.path === "/api/mcp");
5406
+ const servesAiCatalog = _optionalChain([config, 'access', _86 => _86.agent, 'optionalAccess', _87 => _87.aiCatalog]) !== false;
5303
5407
  const hasPluginRuntime = hasRuntimeIntegrationConfig || hasServerRuntimePlugins;
5304
5408
  const hasInfraAnalyticsRuntime = config.analytics !== false && _chunk2SJ4RQ6Pcjs.resolveFarmInstrumentationRuntime.call(void 0, preset) === "nodejs";
5305
5409
  const hasPrecompiledDocs = Boolean(farmDocsPrecompiledManifest);
5306
5410
  const adapterOwnsDocsRuntime = Boolean(
5307
- _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _79 => _79.docs, 'optionalAccess', _80 => _80.enabled]) && _optionalChain([config, 'access', _81 => _81.docs, 'access', _82 => _82.adapter, 'optionalAccess', _83 => _83.server]) && config.docs.adapter.react
5411
+ _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && _optionalChain([config, 'access', _88 => _88.docs, 'optionalAccess', _89 => _89.enabled]) && _optionalChain([config, 'access', _90 => _90.docs, 'access', _91 => _91.adapter, 'optionalAccess', _92 => _92.server]) && config.docs.adapter.react
5308
5412
  );
5309
5413
  const docsConfigModulePath = adapterOwnsDocsRuntime && !hasPrecompiledDocs && config.docs.configPath && !config.docs.configPath.endsWith(".json") ? config.docs.configPath : void 0;
5310
5414
  const hasIsolatedClientGraphRuntime = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) && isolatedClientBoundaryModules.size > 0;
@@ -5314,7 +5418,7 @@ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlot
5314
5418
  );
5315
5419
  const hasReactSyncRender = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer);
5316
5420
  const rendererServerImports = _chunkPSV6XKPOcjs.isReactRenderer.call(void 0, config.renderer) ? `import * as React from "react";
5317
- import * as ReactDOMServer from "react-dom/server";${hasIsolatedClientGraphRuntime ? '\nimport { isolateFarmServerPageGraph, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";' : ""}` : `import React, * as ReactDOMServer from ${JSON.stringify(config.renderer.server)};${generateFarmRendererAppSetupServerCode(config)}`;
5421
+ import * as ReactDOMServer from "react-dom/server";${hasIsolatedClientGraphRuntime ? '\nimport { isolateFarmServerPageGraph, wrapFarmIsolatedClientGraph } from "@farm.js/core/internal/isolated-boundary";\nimport { renderFarmServerTreePage } from "@farm.js/core/internal/server-tree";' : ""}` : `import React, * as ReactDOMServer from ${JSON.stringify(config.renderer.server)};${generateFarmRendererAppSetupServerCode(config)}`;
5318
5422
  const routeClientGraphServerRuntime = hasIsolatedClientGraphRuntime ? `function wrapFarmRouteClientGraph(element) {
5319
5423
  return wrapFarmIsolatedClientGraph(React, element);
5320
5424
  }
@@ -5323,15 +5427,23 @@ import * as ReactDOMServer from "react-dom/server";${hasIsolatedClientGraphRunti
5323
5427
  // components render as their own islands instead of joining the layout's React tree.
5324
5428
  function isolateFarmRouteServerPage(element) {
5325
5429
  return isolateFarmServerPageGraph(React, element);
5430
+ }
5431
+
5432
+ // An async page below a hydrating layout renders as a serialized tree the browser rebuilds in
5433
+ // the layout's React root, so its client components read the layout's context.
5434
+ function renderFarmRouteServerTree(element) {
5435
+ return renderFarmServerTreePage(React, element, { isolate: isolateFarmRouteServerPage });
5326
5436
  }` : `function wrapFarmRouteClientGraph(element) { return element; }
5327
5437
 
5328
- function isolateFarmRouteServerPage(element) { return element; }`;
5438
+ function isolateFarmRouteServerPage(element) { return element; }
5439
+
5440
+ function renderFarmRouteServerTree(element) { return element; }`;
5329
5441
  const hasGeneratedMetadataImages = metadataImageRoutes.some(
5330
5442
  (image) => image.sourceType === "module"
5331
5443
  );
5332
5444
  const hasMiddlewareRuntime = middlewareRoutes.length > 0 || hasFarmMiddlewareConfig(config.middleware);
5333
- const farmDocsFontAssets = _optionalChain([config, 'access', _84 => _84.docs, 'optionalAccess', _85 => _85.enabled]) ? _chunkHREOKQWTcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
5334
- const integrationProviders = _chunkTDFPACVXcjs.getIntegrationProviders.call(void 0, config.integrations);
5445
+ const farmDocsFontAssets = _optionalChain([config, 'access', _93 => _93.docs, 'optionalAccess', _94 => _94.enabled]) ? _chunkHREOKQWTcjs.toFarmDocsPublicFontAssets.call(void 0, _chunkHREOKQWTcjs.resolveFarmDocsFontAssets.call(void 0, config.root)) : [];
5446
+ const integrationProviders = _chunkCBJJH36Acjs.getIntegrationProviders.call(void 0, config.integrations);
5335
5447
  const renderedIntegrationProviders = integrationProviders.filter(
5336
5448
  (provider) => provider.component || provider.type === "clerk"
5337
5449
  );
@@ -5340,16 +5452,16 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5340
5452
  `Integration provider components are not supported by the "${config.renderer.name}" renderer.`
5341
5453
  );
5342
5454
  }
5343
- const providerServerModules = _chunkSJVKK4JEcjs.generateFarmIntegrationProviderServerModules.call(void 0,
5455
+ const providerServerModules = _chunkNMHWYWDRcjs.generateFarmIntegrationProviderServerModules.call(void 0,
5344
5456
  renderedIntegrationProviders,
5345
5457
  config.root,
5346
5458
  _nullishCoalesce(config.renderer.componentExtensions, () => ( []))
5347
5459
  );
5348
5460
  const resolvedIntegrationProviderFallback = Object.fromEntries(
5349
5461
  Object.entries(config.integrations).flatMap(([name, integration]) => {
5350
- const configuredProviders = _optionalChain([integration, 'optionalAccess', _86 => _86.providers]);
5462
+ const configuredProviders = _optionalChain([integration, 'optionalAccess', _95 => _95.providers]);
5351
5463
  const providers = Array.isArray(configuredProviders) ? configuredProviders : [];
5352
- if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _87 => _87.component]) === "function")) {
5464
+ if (providers.some((provider) => typeof _optionalChain([provider, 'optionalAccess', _96 => _96.component]) === "function")) {
5353
5465
  throw new Error(
5354
5466
  `Integration provider components in production must use an importable component reference, for example component: { module: "@/components/provider" }.`
5355
5467
  );
@@ -5360,18 +5472,17 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5360
5472
  const unsupportedIntegrationProvider = renderedIntegrationProviders.find(
5361
5473
  (provider) => provider.supportsIsolatedHydration !== true
5362
5474
  );
5363
- const isolatedHydrationMode = _chunkSJVKK4JEcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
5364
- _optionalChain([config, 'access', _88 => _88.experimental, 'optionalAccess', _89 => _89.isolatedClientHydration]),
5475
+ const isolatedHydrationMode = _chunkNMHWYWDRcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
5476
+ _optionalChain([config, 'access', _97 => _97.experimental, 'optionalAccess', _98 => _98.isolatedClientHydration]),
5365
5477
  {
5366
- serverComponents: _optionalChain([config, 'access', _90 => _90.experimental, 'optionalAccess', _91 => _91.serverComponents]) === true,
5478
+ serverComponents: _optionalChain([config, 'access', _99 => _99.experimental, 'optionalAccess', _100 => _100.serverComponents]) === true,
5367
5479
  hasUnsupportedIntegrationProvider: Boolean(unsupportedIntegrationProvider)
5368
5480
  }
5369
5481
  );
5370
- const hydrationPlanOptions = _chunkSJVKK4JEcjs.getFarmClientHydrationPlanOptions.call(void 0,
5482
+ const hydrationPlanOptions = _chunkNMHWYWDRcjs.getFarmClientHydrationPlanOptions.call(void 0,
5371
5483
  config.renderer,
5372
5484
  Boolean(unsupportedIntegrationProvider)
5373
5485
  );
5374
- const layoutAppliesToRoute = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, (layoutPattern, routePattern) => layoutPattern === "/" || routePattern === layoutPattern || routePattern.startsWith(`${layoutPattern}/`), "layoutAppliesToRoute");
5375
5486
  const layoutHydrationPlans = layoutRoutes.map((layout) => ({
5376
5487
  ...layout,
5377
5488
  hydration: getCachedClientModuleHydrationPlan(
@@ -5382,7 +5493,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5382
5493
  hydrationPlanOptions
5383
5494
  )
5384
5495
  }));
5385
- const markdownPagePlan = _chunkSJVKK4JEcjs.createMarkdownPageHydrationPlanner.call(void 0,
5496
+ const markdownPagePlan = _chunkNMHWYWDRcjs.createMarkdownPageHydrationPlanner.call(void 0,
5386
5497
  _chunkOHY2ZWUGcjs.resolveFarmMdxComponentsModulePath.call(void 0, _chunkOHY2ZWUGcjs.resolveMdxConfig.call(void 0, config.mdx), config.root),
5387
5498
  config.root,
5388
5499
  isolatedHydrationMode,
@@ -5391,7 +5502,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5391
5502
  const pageHydrationPlans = new Map(
5392
5503
  pageRoutes.map((route) => [
5393
5504
  route.modulePath,
5394
- _chunkUX5S4JEOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
5505
+ _chunk42NHY7HWcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath) ? markdownPagePlan() : getCachedClientModuleHydrationPlan(
5395
5506
  route.modulePath,
5396
5507
  config.root,
5397
5508
  isolatedHydrationMode,
@@ -5400,18 +5511,19 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5400
5511
  )
5401
5512
  ])
5402
5513
  );
5403
- _chunkSJVKK4JEcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
5514
+ _chunkNMHWYWDRcjs.enforceFarmIsolatedHydrationRouteBudget.call(void 0,
5404
5515
  layoutHydrationPlans.map((layout) => ({
5405
5516
  pattern: layout.pattern,
5406
5517
  depth: layout.pattern.split("/").filter(Boolean).length,
5407
5518
  metadata: layout.hydration
5408
5519
  })),
5409
5520
  pageRoutes.map((route) => ({
5410
- pattern: route.pattern,
5411
- depth: route.pattern.split("/").filter(Boolean).length,
5521
+ // Compared by directory so a grouped layout applies only inside its group.
5522
+ pattern: _nullishCoalesce(route.directory, () => ( route.pattern)),
5523
+ depth: _chunkADEA7PN3cjs.getRouteDirectoryDepth.call(void 0, _nullishCoalesce(route.directory, () => ( route.pattern))),
5412
5524
  metadata: pageHydrationPlans.get(route.modulePath)
5413
5525
  })),
5414
- layoutAppliesToRoute
5526
+ _chunkADEA7PN3cjs.routeBoundaryCoversDirectory
5415
5527
  );
5416
5528
  const providerServerImports = [
5417
5529
  providerServerModules.hasClerkProvider ? `import { ClerkProvider as FarmClerkProvider } from "@clerk/react";` : "",
@@ -5428,7 +5540,7 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5428
5540
  apiRegistrations.push(`
5429
5541
  {
5430
5542
  path: ${JSON.stringify(route.path)},
5431
- methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _92 => _92.pluginMethods, 'optionalAccess', _93 => _93.includes, 'call', _94 => _94(method)])))},
5543
+ methods: ${JSON.stringify(route.methods.filter((method) => !_optionalChain([route, 'access', _101 => _101.pluginMethods, 'optionalAccess', _102 => _102.includes, 'call', _103 => _103(method)])))},
5432
5544
  endpoints: ${varName},
5433
5545
  }`);
5434
5546
  });
@@ -5441,10 +5553,11 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5441
5553
  }).map(({ route }) => route);
5442
5554
  orderedPageRoutes.forEach((route, index) => {
5443
5555
  const varName = `pageRoute${index}`;
5444
- if (_chunkUX5S4JEOcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
5556
+ if (_chunk42NHY7HWcjs.isFarmMarkdownPageFile.call(void 0, route.modulePath)) {
5445
5557
  pageRegistrations.push(`
5446
5558
  {
5447
- pattern: ${JSON.stringify(route.pattern)},
5559
+ pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
5560
+ directory: ${JSON.stringify(route.directory)},` : ""}
5448
5561
  module: createFarmMarkdownRouteModule({
5449
5562
  source: ${JSON.stringify(_nullishCoalesce(route.source, () => ( "")))},
5450
5563
  filePath: ${JSON.stringify(toBakedMarkdownSourcePath(config.root, route.modulePath))},
@@ -5467,10 +5580,11 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5467
5580
  const renderingDirective = parseRouteRenderingDirectiveFromDisk(route.modulePath);
5468
5581
  pageRegistrations.push(`
5469
5582
  {
5470
- pattern: ${JSON.stringify(route.pattern)},
5583
+ pattern: ${JSON.stringify(route.pattern)},${route.directory ? `
5584
+ directory: ${JSON.stringify(route.directory)},` : ""}
5471
5585
  module: ${varName},
5472
5586
  shouldHydrate: ${JSON.stringify(clientMetadata.shouldHydrate)},
5473
- islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${renderingDirective ? `
5587
+ islandStrategy: ${JSON.stringify(clientMetadata.islandStrategy)},${_chunkNMHWYWDRcjs.usesFarmServerTree.call(void 0, clientMetadata) ? "\n serverTree: true," : ""}${renderingDirective ? `
5474
5588
  rendering: ${JSON.stringify(renderingDirective)},` : ""}
5475
5589
  ${route.source !== void 0 ? `markdownSource: {
5476
5590
  source: ${JSON.stringify(route.source)},
@@ -5511,7 +5625,8 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5511
5625
  routeSlotRegistrations.push(`
5512
5626
  {
5513
5627
  name: ${JSON.stringify(slot.name)},
5514
- ownerPattern: ${JSON.stringify(slot.ownerPattern)},
5628
+ ownerPattern: ${JSON.stringify(slot.ownerPattern)},${slot.ownerDirectory ? `
5629
+ ownerDirectory: ${JSON.stringify(slot.ownerDirectory)},` : ""}
5515
5630
  pattern: ${JSON.stringify(slot.pattern)},
5516
5631
  containerId: ${JSON.stringify(slot.containerId)},
5517
5632
  interception: ${JSON.stringify(slot.interception)},
@@ -5526,9 +5641,12 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5526
5641
  errorImports.push(
5527
5642
  `import * as ${varName} from ${toVirtualEntryImportSpecifier(errorRoute.modulePath)};`
5528
5643
  );
5644
+ const groupScope = _chunkADEA7PN3cjs.getRouteGroupScope.call(void 0, errorRoute.pattern);
5529
5645
  errorRegistrations.push(`
5530
5646
  {
5531
- pattern: ${JSON.stringify(errorRoute.pattern)},
5647
+ pattern: ${JSON.stringify(_chunkADEA7PN3cjs.stripRouteGroups.call(void 0, errorRoute.pattern))},${groupScope ? `
5648
+ groupScope: ${JSON.stringify(groupScope)},
5649
+ directoryDepth: ${_chunkADEA7PN3cjs.getRouteDirectoryDepth.call(void 0, errorRoute.pattern)},` : ""}
5532
5650
  module: ${varName},
5533
5651
  }`);
5534
5652
  });
@@ -5606,14 +5724,22 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5606
5724
  createDefaultErrorMarkup,
5607
5725
  createFarmInstrumentationLifecycle,
5608
5726
  createFarmLayoutSelector,
5727
+ isInFarmRouteGroupScope,
5609
5728
  createFarmCacheKey,
5610
5729
  createFarmMetadataRouteResponse,
5611
5730
  createFarmAgentRobots,
5731
+ createFarmDefaultSitemap,
5732
+ collectFarmDefaultMCPPages,
5733
+ resolveFarmDefaultMCPServer,
5734
+ handleFarmDefaultMCPRequest,
5735
+ createFarmAiCatalogResponse,
5612
5736
  createFarmApiCatalogResponse,
5613
5737
  createFarmAppManifestResponse,
5614
5738
  collectFarmLlmsTxtPages,
5615
5739
  createFarmDefaultLlmsTxt,
5616
5740
  createFarmLlmsMarkdownReader,
5741
+ listFarmMCPLlmsTxtLinks,
5742
+ registerFarmMCPServer,
5617
5743
  renderFarmLlmsFullTxt,
5618
5744
  createFarmLlmsFullRenderer,
5619
5745
  createFarmThemeDocumentParts,
@@ -5634,6 +5760,9 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5634
5760
  mergeRouteRenderingDirectiveConfig,
5635
5761
  manageFarmLinkHeaderPreloads,
5636
5762
  mergeMetadata,
5763
+ mergeModuleViewport,
5764
+ ensureFarmDocumentMeta,
5765
+ renderViewportHead,
5637
5766
  matchesFarmIfNoneMatch,
5638
5767
  normalizeRevalidatePath,
5639
5768
  reportFarmPreloadWarnings,
@@ -5663,25 +5792,25 @@ function isolateFarmRouteServerPage(element) { return element; }`;
5663
5792
  const infraAnalyticsImport = hasInfraAnalyticsRuntime ? `import { ${hasPluginRuntime ? "createFarmInfraAnalyticsPlugin" : "createFarmInfraAnalyticsRecorder"} } from "@farm.js/core/internal/infra-analytics-runtime";` : "";
5664
5793
  const compressionRuntimeImport = hasCompressionRuntime ? `import { compressFarmResponse${hasPluginRuntime ? ", createCompressionPlugin" : ""} } from "@farm.js/core/internal/compression-runtime";` : "";
5665
5794
  const i18nServerImport = config.i18n.enabled ? `import { _runWithFarmI18nRequest, _setDefaultFarmI18nRuntime, createFarmI18nRuntime, getFarmI18nClientSnapshot } from "@farm.js/core/i18n/server";` : "";
5666
- const docsHandlerImport = _optionalChain([config, 'access', _95 => _95.docs, 'optionalAccess', _96 => _96.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
5795
+ const docsHandlerImport = _optionalChain([config, 'access', _104 => _104.docs, 'optionalAccess', _105 => _105.enabled]) ? hasPrecompiledDocs ? `import { createFarmDocsPrecompiledRuntime } from "@farm.js/core/internal/docs-precompiled-runtime";
5667
5796
  const isFarmDocsAPIRequest = (requestOrPathname) => {
5668
5797
  const pathname = typeof requestOrPathname === "string"
5669
5798
  ? requestOrPathname
5670
5799
  : new URL(requestOrPathname.url).pathname;
5671
- const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _97 => _97.apiPath]) || "/api/docs")};
5800
+ const apiPath = ${JSON.stringify(_optionalChain([farmDocsPrecompiledManifest, 'optionalAccess', _106 => _106.apiPath]) || "/api/docs")};
5672
5801
  return pathname === apiPath || pathname.startsWith(apiPath + "/");
5673
5802
  };` : adapterOwnsDocsRuntime ? `import { isFarmDocsAPIRequest } from "@farm.js/core/docs";
5674
5803
  import { createFarmDocsRuntimeHandler as createFarmDocsAdapterRuntimeHandler } from ${JSON.stringify(config.docs.adapter.server)};
5675
5804
  import * as FarmDocsAdapterReact from ${JSON.stringify(config.docs.adapter.react)};${docsConfigModulePath ? `
5676
5805
  import * as farmDocsConfigModule from ${toVirtualEntryImportSpecifier(docsConfigModulePath)};` : ""}` : `import { createFarmDocsAPIHandler, createFarmDocsHandler, isFarmDocsAPIRequest } from "@farm.js/core/docs";` : "";
5677
- const docsFontImport = _optionalChain([config, 'access', _98 => _98.docs, 'optionalAccess', _99 => _99.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
5678
- const docsRuntimeImport = _optionalChain([config, 'access', _100 => _100.docs, 'optionalAccess', _101 => _101.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
5806
+ const docsFontImport = _optionalChain([config, 'access', _107 => _107.docs, 'optionalAccess', _108 => _108.enabled]) && !hasPrecompiledDocs ? `import { resolveFarmLayoutFonts } from "@farm.js/core/font";` : "";
5807
+ const docsRuntimeImport = _optionalChain([config, 'access', _109 => _109.docs, 'optionalAccess', _110 => _110.enabled]) && !hasPrecompiledDocs ? `import { existsSync as farmDocsExistsSync } from "node:fs";
5679
5808
  import { dirname as farmDocsDirname, join as farmDocsJoin } from "node:path";
5680
5809
  import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
5681
- const markdownHandlerImport = _optionalChain([config, 'access', _102 => _102.md, 'optionalAccess', _103 => _103.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
5810
+ const markdownHandlerImport = _optionalChain([config, 'access', _111 => _111.md, 'optionalAccess', _112 => _112.enabled]) ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
5682
5811
  const appMarkdownImport = hasMarkdownPages ? `import { createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
5683
5812
  const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
5684
- const mdxComponentsPath = typeof _optionalChain([config, 'access', _104 => _104.mdx, 'optionalAccess', _105 => _105.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
5813
+ const mdxComponentsPath = typeof _optionalChain([config, 'access', _113 => _113.mdx, 'optionalAccess', _114 => _114.components]) === "string" ? _path2.default.isAbsolute(config.mdx.components) ? config.mdx.components : _path2.default.join(config.root, config.mdx.components) : null;
5685
5814
  const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
5686
5815
  const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
5687
5816
  const layerConfigImports = layerConfigPaths.map(
@@ -5886,7 +6015,7 @@ const farmResolvedRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs);
5886
6015
 
5887
6016
  function FarmDefault404Page() {
5888
6017
  return React.createElement(React.Fragment, null,
5889
- React.createElement("style", null, ${JSON.stringify(_chunkSJVKK4JEcjs.DEFAULT_NOT_FOUND_STYLES)}),
6018
+ React.createElement("style", null, ${JSON.stringify(_chunkNMHWYWDRcjs.DEFAULT_NOT_FOUND_STYLES)}),
5890
6019
  React.createElement("main", {
5891
6020
  className: "farm-default-not-found",
5892
6021
  "aria-labelledby": "farm-default-not-found-title",
@@ -5979,6 +6108,7 @@ const serverRuntimeIntegrations = Object.fromEntries(
5979
6108
  );
5980
6109
  const integrationRuntimeConfig = Object.assign({}, ...farmRuntimeConfigs, {
5981
6110
  integrations: configuredIntegrations,
6111
+ ${JSON.stringify(_chunkCBJJH36Acjs.FARM_INTEGRATION_API_BASE_PATH_KEY)}: ${JSON.stringify(_chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, config.api))},
5982
6112
  });
5983
6113
  const farmInfraAnalytics = ${hasInfraAnalyticsRuntime ? hasPluginRuntime ? "createFarmInfraAnalyticsPlugin()" : "createFarmInfraAnalyticsRecorder()" : "null"};
5984
6114
  const configuredPlugins = [
@@ -6014,14 +6144,14 @@ const farmImageHandler = ${imageRuntime === "none" ? "null" : imageRuntime === "
6014
6144
  onError(error) { console.error("[Farm Image]", error); },
6015
6145
  })`};
6016
6146
  const farmMarkdownConfig = ${JSON.stringify(config.md)};
6017
- const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _106 => _106.agent, 'optionalAccess', _107 => _107.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
6018
- ${_optionalChain([config, 'access', _108 => _108.agent, 'optionalAccess', _109 => _109.llmsTxt, 'optionalAccess', _110 => _110.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
6147
+ const farmLlmsTxtConfig = ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _115 => _115.agent, 'optionalAccess', _116 => _116.llmsTxt]), () => ( { enabled: false, include: [], exclude: [] })))};
6148
+ ${_optionalChain([config, 'access', _117 => _117.agent, 'optionalAccess', _118 => _118.llmsTxt, 'optionalAccess', _119 => _119.enabled]) ? "const farmLlmsFullRenderer = createFarmLlmsFullRenderer({ revalidate: farmLlmsTxtConfig.revalidate });\n" : ""}${servesAgentRobotsTxt ? `const farmAgentCrawlers = ${JSON.stringify(config.agent.crawlers)};` : ""}
6019
6149
  const farmMdxConfig = ${JSON.stringify({
6020
6150
  ...config.mdx,
6021
- components: typeof _optionalChain([config, 'access', _111 => _111.mdx, 'optionalAccess', _112 => _112.components]) === "string" ? config.mdx.components : void 0
6151
+ components: typeof _optionalChain([config, 'access', _120 => _120.mdx, 'optionalAccess', _121 => _121.components]) === "string" ? config.mdx.components : void 0
6022
6152
  })};
6023
6153
  const configuredFarmMdxComponents = farmUserConfig?.mdx?.components;
6024
- ${_optionalChain([config, 'access', _113 => _113.agent, 'optionalAccess', _114 => _114.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
6154
+ ${_optionalChain([config, 'access', _122 => _122.agent, 'optionalAccess', _123 => _123.noindexPreviews]) ? `// agent.noindexPreviews: the runtime environment decides, falling back to the
6025
6155
  // environment this was built in, since Netlify exposes its deploy context only
6026
6156
  // to the build.
6027
6157
  const farmNoindexPreview = resolveFarmPreviewDeployment(
@@ -6069,7 +6199,7 @@ export const farmProductionLifecycle = createFarmProductionLifecycle({
6069
6199
  });
6070
6200
  const farmI18nRuntime = ${config.i18n.enabled ? `createFarmI18nRuntime(farmI18nConfig, ${JSON.stringify(i18nCatalogs)})` : "null"};
6071
6201
  ${config.i18n.enabled ? "_setDefaultFarmI18nRuntime(farmI18nRuntime);" : ""}
6072
- const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _115 => _115.docs, 'optionalAccess', _116 => _116.enabled]) && !hasPrecompiledDocs ? `(() => {
6202
+ const farmDocsBundledContentDir = ${_optionalChain([config, 'access', _124 => _124.docs, 'optionalAccess', _125 => _125.enabled]) && !hasPrecompiledDocs ? `(() => {
6073
6203
  try {
6074
6204
  const currentDir = farmDocsDirname(farmDocsFileURLToPath(import.meta.url));
6075
6205
  const candidates = [
@@ -6090,7 +6220,7 @@ globalThis.__FARM_DOCS_RUNTIME_CONFIG__ = {
6090
6220
  docs: farmDocsResolvedConfig,
6091
6221
  };
6092
6222
  const farmDocsPrecompiledRuntime = ${hasPrecompiledDocs ? `createFarmDocsPrecompiledRuntime(${JSON.stringify(farmDocsPrecompiledManifest)})` : "null"};
6093
- const farmDocsHandler = ${_optionalChain([config, 'access', _117 => _117.docs, 'optionalAccess', _118 => _118.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
6223
+ const farmDocsHandler = ${_optionalChain([config, 'access', _126 => _126.docs, 'optionalAccess', _127 => _127.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleDocsRequest" : adapterOwnsDocsRuntime ? `createFarmDocsAdapterRuntimeHandler({
6094
6224
  ${docsConfigModulePath ? "...(farmDocsConfigModule.default || farmDocsConfigModule),\n ...farmDocsResolvedConfig.configOverrides," : "...farmDocsResolvedConfig.config,"}
6095
6225
  entry: farmDocsResolvedConfig.config?.entry || String(farmDocsResolvedConfig.entry || "/docs").replace(/^\\/+|\\/+$/g, "") || "docs",
6096
6226
  docsPath: farmDocsResolvedConfig.entry,
@@ -6109,6 +6239,8 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _117 => _117.docs, '
6109
6239
  getApplicableLayouts(getFarmRoutePathname(pathname)).map((layout) => layout.module),
6110
6240
  ),
6111
6241
  loadReactModule: async () => FarmDocsAdapterReact,
6242
+ // Lists the docs MCP endpoint in /.well-known/ai-catalog.json for the server's lifetime.
6243
+ registerMCPServer: registerFarmMCPServer,
6112
6244
  })` : `createFarmDocsHandler(farmDocsResolvedConfig, {
6113
6245
  root: farmDocsRuntimeRoot,
6114
6246
  srcDir: ${JSON.stringify(config.srcDir)},
@@ -6121,22 +6253,29 @@ const farmDocsHandler = ${_optionalChain([config, 'access', _117 => _117.docs, '
6121
6253
  fontStylesheetHref: "/farm-fonts.css",
6122
6254
  globalStylesheetHref: "/assets/globals.css",
6123
6255
  })` : "null"};
6124
- const farmDocsAPIHandler = ${_optionalChain([config, 'access', _119 => _119.docs, 'optionalAccess', _120 => _120.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig })` : "null"};
6256
+ const farmDocsAPIHandler = ${_optionalChain([config, 'access', _128 => _128.docs, 'optionalAccess', _129 => _129.enabled]) ? hasPrecompiledDocs ? "farmDocsPrecompiledRuntime.handleAPIRequest" : adapterOwnsDocsRuntime ? "null" : `createFarmDocsAPIHandler({ rootDir: farmDocsRuntimeRoot, srcDir: ${JSON.stringify(config.srcDir)}, docs: farmDocsResolvedConfig })` : "null"};
6125
6257
 
6126
6258
  // API routes bundled at build time
6127
6259
  const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
6128
- ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path8, methods }) => ({ path: path8, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)} })` : ""};
6260
+ ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path8, methods }) => ({ path: path8, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
6261
+ // A plugin calling an app endpoint (an MCP tool, say) goes through the whole
6262
+ // pipeline, so the endpoint's middleware and integration guards run for it.
6263
+ function dispatchFarmPluginAPIRequest(request) {
6264
+ const url = new URL(request.url);
6265
+ url.pathname = applyFarmBasePath(url.pathname);
6266
+ return handleFarmRequest(url.href === request.url ? request : new Request(url, request));
6267
+ }
6129
6268
  const farmLocalAPIBasePath = ${JSON.stringify(_chunkKNBBQHO2cjs.resolveFarmAPIServerBasePath.call(void 0, config.api))};
6130
6269
  const farmOpenAPIReference = ${JSON.stringify(openAPIReference)};
6131
- ${_optionalChain([config, 'access', _121 => _121.agent, 'optionalAccess', _122 => _122.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunkP64MIF5Bcjs.resolveFarmApiCatalogInput.call(void 0, config))};
6132
- ` : ""}${config.analytics !== false ? `const farmAppManifestInput = ${JSON.stringify(
6133
- _chunkP64MIF5Bcjs.resolveFarmAppManifestInput.call(void 0, config, {
6270
+ ${_optionalChain([config, 'access', _130 => _130.agent, 'optionalAccess', _131 => _131.apiCatalog]) ? `const farmApiCatalogInput = ${JSON.stringify(_chunkADEA7PN3cjs.resolveFarmApiCatalogInput.call(void 0, config))};
6271
+ ` : ""}${_optionalChain([config, 'access', _132 => _132.agent, 'optionalAccess', _133 => _133.manifest]) !== false ? `const farmAppManifestInput = ${JSON.stringify(
6272
+ _chunkADEA7PN3cjs.resolveFarmAppManifestInput.call(void 0, config, {
6134
6273
  build: config.deploymentId,
6135
- packages: _chunkSJVKK4JEcjs.resolveFarmAppPackages.call(void 0, config.root),
6136
- webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? _chunkSJVKK4JEcjs.collectFarmWebMCPTools.call(void 0, config.root, config.srcDir) : []
6274
+ packages: _chunkNMHWYWDRcjs.resolveFarmAppPackages.call(void 0, config.root),
6275
+ webmcpTools: config.plugins.some(({ name }) => name === "farm:webmcp") ? _chunkNMHWYWDRcjs.collectFarmWebMCPTools.call(void 0, config.root, config.srcDir) : []
6137
6276
  })
6138
6277
  )};
6139
- ` : ""}
6278
+ ${servesDefaultMCP ? "farmAppManifestInput.defaultMCP = getFarmDefaultMCPServer;\n" : ""}` : ""}
6140
6279
  function isFarmLocalAPIPathname(pathname) {
6141
6280
  return farmLocalAPIBasePath !== "/" &&
6142
6281
  (pathname === farmLocalAPIBasePath ||
@@ -6161,7 +6300,7 @@ for (const route of pageRoutes) {
6161
6300
  // Layout routes bundled at build time (sorted by depth, root first)
6162
6301
  const layoutRoutes = [${layoutRegistrations.join(",")}
6163
6302
  ];
6164
- const selectApplicableLayouts = createFarmLayoutSelector(layoutRoutes);
6303
+ const selectApplicableLayouts = createFarmLayoutSelector(layoutRoutes, getMatchedPageDirectory);
6165
6304
 
6166
6305
  const routeSlots = [${routeSlotRegistrations.join(",")}
6167
6306
  ];
@@ -6578,7 +6717,7 @@ function peelFarmDocumentPrefix(markup) {
6578
6717
  let inner = markup.replace(/^\\s+/, "");
6579
6718
  let hoisted = "";
6580
6719
  const wrapper = /^<div\\b[^>]*style=["']display\\s*:\\s*contents["'][^>]*>/i;
6581
- const hoistable = /${_chunkSJVKK4JEcjs.HOISTED_HEAD_ELEMENT.source}/i;
6720
+ const hoistable = /${_chunkADEA7PN3cjs.HOISTED_HEAD_ELEMENT.source}/i;
6582
6721
  let match;
6583
6722
  while ((match = wrapper.exec(inner) || hoistable.exec(inner))) {
6584
6723
  if (!/^<div/i.test(match[0])) hoisted += match[0];
@@ -6643,7 +6782,8 @@ function ensureFarmDocumentHead(markup) {
6643
6782
  }
6644
6783
 
6645
6784
  function ensureFarmDocumentRoot(markup) {
6646
- if (/\\sid=["']root["']/i.test(markup)) return markup;
6785
+ // Only a #root that opens the body is the container; page content can have id="root" too.
6786
+ if (/<body\\b[^>]*>\\s*<div\\b[^>]*\\sid=["']root["']/i.test(markup)) return markup;
6647
6787
  return markup
6648
6788
  .replace(/<body\\b([^>]*)>/i, function(_match, attributes) {
6649
6789
  return "<body" + attributes + '><div id="root">';
@@ -6810,6 +6950,7 @@ ${generateRuntimePathMatcherSource()}
6810
6950
  function getMatchingErrorBoundary(pathname) {
6811
6951
  const pathSegments = splitRuntimePath(pathname);
6812
6952
  let bestMatch = null;
6953
+ let directory;
6813
6954
 
6814
6955
  for (const errorRoute of errorRoutes) {
6815
6956
  const patternDepth = splitRuntimePath(errorRoute.pattern).length;
@@ -6819,9 +6960,18 @@ function getMatchingErrorBoundary(pathname) {
6819
6960
  : "/" + pathSegments.slice(0, patternDepth).join("/");
6820
6961
  const params = matchRuntimePathPattern(errorRoute.pattern, candidatePath);
6821
6962
  if (params === null) continue;
6963
+ if (errorRoute.groupScope) {
6964
+ if (directory === undefined) directory = getMatchedPageDirectory(pathname);
6965
+ if (!isInFarmRouteGroupScope(directory, errorRoute.groupScope)) continue;
6966
+ }
6822
6967
 
6823
- if (!bestMatch || patternDepth > bestMatch.depth) {
6824
- bestMatch = { route: errorRoute, params, depth: patternDepth };
6968
+ const directoryDepth = errorRoute.directoryDepth ?? patternDepth;
6969
+ if (
6970
+ !bestMatch ||
6971
+ patternDepth > bestMatch.depth ||
6972
+ (patternDepth === bestMatch.depth && directoryDepth > bestMatch.directoryDepth)
6973
+ ) {
6974
+ bestMatch = { route: errorRoute, params, depth: patternDepth, directoryDepth };
6825
6975
  }
6826
6976
  }
6827
6977
 
@@ -7012,7 +7162,7 @@ function createFarmAgentRobotsResponse(request) {
7012
7162
  "robots",
7013
7163
  createFarmAgentRobots({
7014
7164
  crawlers: farmAgentCrawlers,
7015
- sitemapPath: ${applicationMetadataRoutes.some(
7165
+ sitemapPath: ${servesAgentSitemap || applicationMetadataRoutes.some(
7016
7166
  (metadata) => metadata.kind === "sitemap" && metadata.pattern === "/"
7017
7167
  ) ? JSON.stringify("/sitemap.xml") : "undefined"},
7018
7168
  metadataBase: rootLayout && rootLayout.module && rootLayout.module.metadata
@@ -7025,6 +7175,68 @@ function createFarmAgentRobotsResponse(request) {
7025
7175
  );
7026
7176
  }
7027
7177
  ` : ""}
7178
+ ${servesAgentSitemap ? `// sitemap.xml from agent.sitemap, built the same way as in development. Each page's
7179
+ // lastmod is its file's modification time, read at build time.
7180
+ const farmAgentSitemapConfig = ${JSON.stringify(config.agent.sitemap)};
7181
+ const farmAgentSitemapLastModified = ${JSON.stringify(readFarmPageLastModified(pageRoutes))};
7182
+ function createFarmAgentSitemapResponse(request) {
7183
+ const rootLayout = layoutRoutes.find((layout) => layout.pattern === "/");
7184
+ return createFarmMetadataRouteResponse(
7185
+ "sitemap",
7186
+ createFarmDefaultSitemap(
7187
+ pageRoutes.map((route) => ({
7188
+ pattern: route.pattern,
7189
+ module: route.module,
7190
+ lastModified: farmAgentSitemapLastModified[route.pattern],
7191
+ })),
7192
+ {
7193
+ origin: new URL(request.url).origin,
7194
+ config: farmAgentSitemapConfig,
7195
+ metadataBase: rootLayout && rootLayout.module && rootLayout.module.metadata
7196
+ ? rootLayout.module.metadata.metadataBase
7197
+ : undefined,
7198
+ basePath: ${JSON.stringify(config.basePath)},
7199
+ },
7200
+ ),
7201
+ {},
7202
+ { method: request.method },
7203
+ );
7204
+ }
7205
+ ` : ""}
7206
+ ${servesDefaultMCP ? `// agent.mcp: the default read-only MCP server at /mcp, as in development. It steps
7207
+ // aside for a page route that answers /mcp and for any MCP server published or
7208
+ // registered at runtime, such as the docs engine's.
7209
+ const farmDefaultMCPServer = ${JSON.stringify(
7210
+ _chunkPTZ2TVNEcjs.createFarmDefaultMCPServer.call(void 0, readFarmAppPackageIdentity(config.root), _chunkDZ5ZVB2Kcjs.FARM_VERSION)
7211
+ )};
7212
+ let farmDefaultMCPRouteFree;
7213
+ function getFarmDefaultMCPServer() {
7214
+ if (farmDefaultMCPRouteFree === undefined) {
7215
+ farmDefaultMCPRouteFree = !matchPageRoute(${JSON.stringify(_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PATH)});
7216
+ }
7217
+ return farmDefaultMCPRouteFree ? resolveFarmDefaultMCPServer(farmDefaultMCPServer) : undefined;
7218
+ }
7219
+ async function handleFarmDefaultMCP(request) {
7220
+ const origin = new URL(request.url).origin;
7221
+ return handleFarmDefaultMCPRequest(request, {
7222
+ server: getFarmDefaultMCPServer(),
7223
+ basePath: ${JSON.stringify(config.basePath)},
7224
+ listPages: () =>
7225
+ collectFarmDefaultMCPPages(
7226
+ pageRoutes.map((route) => ({ pattern: route.pattern, module: route.module })),
7227
+ { origin, basePath: ${JSON.stringify(config.basePath)}, markdown: farmMarkdownConfig },
7228
+ ),
7229
+ // A fresh request through this handler, so the caller's cookies never shape a page.
7230
+ // The handler sees paths below the base path, as the server passes them in.
7231
+ readMarkdown: (url) => {
7232
+ const page = new URL(url);
7233
+ page.pathname = stripFarmBasePath(page.pathname);
7234
+ return farmDefaultMCPReadMarkdown(page.href);
7235
+ },
7236
+ });
7237
+ }
7238
+ const farmDefaultMCPReadMarkdown = createFarmLlmsMarkdownReader((page) => handleFarmRequest(page));
7239
+ ` : ""}
7028
7240
  // Static pages and root metadata for llms.txt, built the same way as in development.
7029
7241
  function createFarmLlmsTxtContext(request, full) {
7030
7242
  const origin = new URL(request.url).origin;
@@ -7045,6 +7257,10 @@ function createFarmLlmsTxtContext(request, full) {
7045
7257
  pages,
7046
7258
  config: farmLlmsTxtConfig,
7047
7259
  rootMetadata: rootLayout && rootLayout.module && rootLayout.module.metadata,
7260
+ ${servesAiCatalog ? `mcp: listFarmMCPLlmsTxtLinks(origin, {
7261
+ basePath: ${JSON.stringify(config.basePath)},
7262
+ apiServerBasePath: farmLocalAPIBasePath,${servesDefaultMCP ? "\n defaultMCP: getFarmDefaultMCPServer," : ""}
7263
+ }),` : ""}
7048
7264
  }),
7049
7265
  // llms-full.txt reads each page's .md mirror through this same handler,
7050
7266
  // with a fresh request so the caller's cookies never shape its content.
@@ -7288,7 +7504,7 @@ function hasLocalRequestRoute(request, routePathname) {
7288
7504
  if (${imageRuntime === "none" ? "false" : `pathname === ${JSON.stringify(config.images.path)}`}) {
7289
7505
  return true;
7290
7506
  }
7291
- ${_optionalChain([config, 'access', _123 => _123.docs, 'optionalAccess', _124 => _124.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
7507
+ ${_optionalChain([config, 'access', _134 => _134.docs, 'optionalAccess', _135 => _135.enabled]) ? `const docsPath = normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs");
7292
7508
  if (
7293
7509
  isFarmDocsAPIRequest(pathname) ||
7294
7510
  docsPath === "/" ||
@@ -7314,7 +7530,7 @@ function getFarmPluginRequestOptions(request) {
7314
7530
  route: { ...route, pattern: normalizeRuntimePath(farmOpenAPIReference.route) },
7315
7531
  };
7316
7532
  }
7317
- const isDocsAPIRequest = ${_optionalChain([config, 'access', _125 => _125.docs, 'optionalAccess', _126 => _126.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
7533
+ const isDocsAPIRequest = ${_optionalChain([config, 'access', _136 => _136.docs, 'optionalAccess', _137 => _137.enabled]) ? "isFarmDocsAPIRequest(pathname)" : "false"};
7318
7534
  const integrationMatch = ${hasServerRuntimeIntegrations ? `matchIntegrationRoute(serverRuntimeIntegrations, {
7319
7535
  pathname,
7320
7536
  method: request.method,
@@ -7394,17 +7610,24 @@ function getFarmPluginRequestOptions(request) {
7394
7610
  return { kind: "request", route };
7395
7611
  }
7396
7612
 
7613
+ /** The directory of the page a pathname selects, or null; route groups confine layouts to it. */
7614
+ function getMatchedPageDirectory(pathname) {
7615
+ const match = matchPageRoute(pathname);
7616
+ return match ? match.route.directory || match.route.pattern : null;
7617
+ }
7618
+
7397
7619
  /**
7398
- * Get applicable layouts for a page path (from root to most specific)
7620
+ * Get applicable layouts for a page path (from root to most specific). Pass the
7621
+ * selected page's directory when it is known, or null when no page applies.
7399
7622
  */
7400
- function getApplicableLayouts(pathname) {
7401
- const applicable = selectApplicableLayouts(pathname);
7623
+ function getApplicableLayouts(pathname, directory) {
7624
+ const applicable = selectApplicableLayouts(pathname, directory);
7402
7625
  // buildSSRInMemory already emits these immutable descriptors in stable depth
7403
7626
  // order. Filtering preserves that order, including equal-depth ties.
7404
7627
  return applicable;
7405
7628
  }
7406
7629
 
7407
- ${_optionalChain([config, 'access', _127 => _127.docs, 'optionalAccess', _128 => _128.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
7630
+ ${_optionalChain([config, 'access', _138 => _138.docs, 'optionalAccess', _139 => _139.enabled]) ? `async function wrapFarmDocsResponseWithLayouts(request, response) {
7408
7631
  if (request.method === "HEAD") return response;
7409
7632
  if (response.headers.get("x-farm-docs-adapter")) return response;
7410
7633
 
@@ -7511,7 +7734,7 @@ ${_optionalChain([config, 'access', _127 => _127.docs, 'optionalAccess', _128 =>
7511
7734
  }` : ""}
7512
7735
 
7513
7736
  const pprShellCache = getFarmDataCache();
7514
- const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _129 => _129.experimental, 'optionalAccess', _130 => _130.ppr]) === true)};
7737
+ const experimentalPPREnabled = ${JSON.stringify(_optionalChain([config, 'access', _140 => _140.experimental, 'optionalAccess', _141 => _141.ppr]) === true)};
7515
7738
 
7516
7739
  function resolveRouteRenderingView(route) {
7517
7740
  // The same merge development uses: baked directive config under the
@@ -7640,7 +7863,7 @@ async function handleFarmRequest(request, adapterContext) {
7640
7863
  },
7641
7864
  { redirect: !isFarmLocalAPIPathname(requestUrl.pathname) }
7642
7865
  )` : "handleFarmRequestInContext(request, null, false, Date.now(), adapterContext, requestUrl)"};
7643
- ${_optionalChain([config, 'access', _131 => _131.md, 'optionalAccess', _132 => _132.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
7866
+ ${_optionalChain([config, 'access', _142 => _142.md, 'optionalAccess', _143 => _143.enabled]) ? `const pathname = getFarmRoutePathname(requestUrl.pathname);
7644
7867
  if (matchPageRoute(pathname)) {
7645
7868
  // The Link header advertises the public .md URL, like the head alternate.
7646
7869
  return applyMarkdownNegotiationHeaders(response, {
@@ -7717,7 +7940,11 @@ async function handleFarmRequestInContext(
7717
7940
  }
7718
7941
 
7719
7942
  ${hasServerRuntimeIntegrations ? `
7720
- const integrationDispatch = await handleIntegrationRequest(cloneFarmRequestWithContext(request));
7943
+ const farmIntegrationRanMiddleware = new Set();
7944
+ const integrationDispatch = await handleIntegrationRequest(
7945
+ cloneFarmRequestWithContext(request),
7946
+ farmIntegrationRanMiddleware,
7947
+ );
7721
7948
  if (integrationDispatch.response) {
7722
7949
  return integrationDispatch.response;
7723
7950
  }
@@ -7725,7 +7952,7 @@ async function handleFarmRequestInContext(
7725
7952
  // its rotated Set-Cookie values back here. They belong on whatever response
7726
7953
  // the page or API handler produces, so they ride the same deferred-header
7727
7954
  // channel the file middleware runner already uses.
7728
- const farmIntegrationSetCookies = integrationDispatch.setCookies;
7955
+ let farmIntegrationSetCookies = integrationDispatch.setCookies;
7729
7956
  ` : ""}
7730
7957
 
7731
7958
  ${hasMiddlewareRuntime ? `
@@ -7736,7 +7963,23 @@ async function handleFarmRequestInContext(
7736
7963
  if (middlewareResult.response) {
7737
7964
  return middlewareResult.response;
7738
7965
  }
7739
- request = middlewareResult.request;
7966
+ request = middlewareResult.request;${hasServerRuntimeIntegrations ? `
7967
+ // A ctx.rewrite() target is guarded as a direct request for it is: integration
7968
+ // guards (protectedRoutes) and routes see the rewritten URL, as in dev. Guards
7969
+ // that already ran for the original URL are skipped, so each runs once.
7970
+ if (request.url !== url.href) {
7971
+ const rewrittenDispatch = await handleIntegrationRequest(
7972
+ cloneFarmRequestWithContext(request),
7973
+ farmIntegrationRanMiddleware,
7974
+ );
7975
+ farmIntegrationSetCookies = [...farmIntegrationSetCookies, ...rewrittenDispatch.setCookies];
7976
+ if (rewrittenDispatch.response) {
7977
+ return applyProductionMiddlewareHeaders(
7978
+ rewrittenDispatch.response,
7979
+ withFarmIntegrationSetCookies(middlewareResult.headers, integrationDispatch.setCookies),
7980
+ );
7981
+ }
7982
+ }` : ""}
7740
7983
  const middlewareData = middlewareResult.data;
7741
7984
  const middlewareContext = middlewareResult.context;
7742
7985
  const middlewareHeaders = ${hasServerRuntimeIntegrations ? "withFarmIntegrationSetCookies(middlewareResult.headers, farmIntegrationSetCookies)" : "middlewareResult.headers"};
@@ -7759,7 +8002,24 @@ async function handleFarmRequestInContext(
7759
8002
  const middlewareHeaders = ${hasServerRuntimeIntegrations ? "withFarmIntegrationSetCookies(undefined, farmIntegrationSetCookies)" : "undefined"};
7760
8003
  `}
7761
8004
 
7762
- ${_optionalChain([config, 'access', _133 => _133.docs, 'optionalAccess', _134 => _134.enabled]) ? `
8005
+ ${servesAiCatalog ? `
8006
+ // agent.aiCatalog: the AI catalog of MCP servers and each server's card. Cards
8007
+ // live below the MCP endpoint, so this answers before the docs runtime and the
8008
+ // API routes, as in dev.
8009
+ const farmAiCatalogResponse = createFarmAiCatalogResponse(
8010
+ request,
8011
+ {
8012
+ basePath: ${JSON.stringify(config.basePath)},
8013
+ apiServerBasePath: farmLocalAPIBasePath,${servesDefaultMCP ? "\n defaultMCP: getFarmDefaultMCPServer," : ""}
8014
+ },
8015
+ url,
8016
+ );
8017
+ if (farmAiCatalogResponse) {
8018
+ return applyProductionMiddlewareHeaders(farmAiCatalogResponse, middlewareHeaders);
8019
+ }
8020
+ ` : ""}
8021
+
8022
+ ${_optionalChain([config, 'access', _144 => _144.docs, 'optionalAccess', _145 => _145.enabled]) ? `
7763
8023
  // Docs responses are served after app middleware so route guards and
7764
8024
  // middleware headers apply to the docs engine like any other page content.
7765
8025
  // An app's own llms.txt, llms-full.txt, sitemap.xml, and robots.txt take
@@ -7808,7 +8068,7 @@ async function handleFarmRequestInContext(
7808
8068
  }
7809
8069
  ` : ""}
7810
8070
 
7811
- ${_optionalChain([config, 'access', _135 => _135.md, 'optionalAccess', _136 => _136.enabled]) ? `
8071
+ ${_optionalChain([config, 'access', _146 => _146.md, 'optionalAccess', _147 => _147.enabled]) ? `
7812
8072
  if (farmMarkdownConfig?.enabled) {
7813
8073
  const markdownResponse = await createMarkdownMirrorResponse({
7814
8074
  // The mirror helper only reads metadata and creates its own GET request.
@@ -7907,20 +8167,23 @@ async function handleFarmRequestInContext(
7907
8167
  return applyProductionMiddlewareHeaders(applicationMetadataResponse, middlewareHeaders);
7908
8168
  }
7909
8169
  ` : ""}
7910
- ${config.analytics !== false ? `
7911
- // /.well-known/farmjs: the app's manifest, only for a request Farm Infra signed.
7912
- if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkP64MIF5Bcjs.FARM_APP_MANIFEST_PATH)}) {
7913
- const farmAppManifest = await createFarmAppManifestResponse(request, farmAppManifestInput, {
7914
- development: false,
7915
- });
7916
- if (farmAppManifest) {
7917
- return applyProductionMiddlewareHeaders(farmAppManifest, middlewareHeaders);
7918
- }
8170
+ ${_optionalChain([config, 'access', _148 => _148.agent, 'optionalAccess', _149 => _149.manifest]) !== false ? `
8171
+ // agent.manifest: /.well-known/farmjs.json (and 0.1.34's /.well-known/farmjs), the app's
8172
+ // public manifest; Farm Infra's signed request gets the full view.
8173
+ if (
8174
+ [${JSON.stringify(_chunkADEA7PN3cjs.FARM_APP_MANIFEST_PATH)}, ${JSON.stringify(_chunkADEA7PN3cjs.FARM_APP_MANIFEST_LEGACY_PATH)}].includes(
8175
+ normalizeRuntimePath(routePathname),
8176
+ )
8177
+ ) {
8178
+ return applyProductionMiddlewareHeaders(
8179
+ await createFarmAppManifestResponse(request, farmAppManifestInput),
8180
+ middlewareHeaders,
8181
+ );
7919
8182
  }
7920
8183
  ` : ""}
7921
- ${_optionalChain([config, 'access', _137 => _137.agent, 'optionalAccess', _138 => _138.apiCatalog]) ? `
8184
+ ${_optionalChain([config, 'access', _150 => _150.agent, 'optionalAccess', _151 => _151.apiCatalog]) ? `
7922
8185
  // agent.apiCatalog: list the OpenAPI and MCP surfaces at the RFC 9727 path.
7923
- if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkP64MIF5Bcjs.FARM_API_CATALOG_PATH)}) {
8186
+ if (normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkADEA7PN3cjs.FARM_API_CATALOG_PATH)}) {
7924
8187
  return applyProductionMiddlewareHeaders(
7925
8188
  createFarmApiCatalogResponse(request.method, farmApiCatalogInput, request),
7926
8189
  middlewareHeaders,
@@ -7936,11 +8199,20 @@ async function handleFarmRequestInContext(
7936
8199
  );
7937
8200
  }
7938
8201
  ` : ""}
7939
- ${_optionalChain([config, 'access', _139 => _139.agent, 'optionalAccess', _140 => _140.llmsTxt, 'optionalAccess', _141 => _141.enabled]) ? `
8202
+ ${servesAgentSitemap ? `
8203
+ // agent.sitemap with no sitemap.ts: serve the generated file.
8204
+ if (normalizeRuntimePath(routePathname) === "/sitemap.xml") {
8205
+ return applyProductionMiddlewareHeaders(
8206
+ createFarmAgentSitemapResponse(request),
8207
+ middlewareHeaders,
8208
+ );
8209
+ }
8210
+ ` : ""}
8211
+ ${_optionalChain([config, 'access', _152 => _152.agent, 'optionalAccess', _153 => _153.llmsTxt, 'optionalAccess', _154 => _154.enabled]) ? `
7940
8212
  // agent.llmsTxt with no llms.ts or llms-full.ts: serve the generated files.
7941
8213
  const farmGeneratedLlmsKind = normalizeRuntimePath(routePathname) === "/llms.txt"
7942
8214
  ? "llms"
7943
- : ${_optionalChain([config, 'access', _142 => _142.agent, 'optionalAccess', _143 => _143.llmsTxt, 'optionalAccess', _144 => _144.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
8215
+ : ${_optionalChain([config, 'access', _155 => _155.agent, 'optionalAccess', _156 => _156.llmsTxt, 'optionalAccess', _157 => _157.full]) ? `normalizeRuntimePath(routePathname) === "/llms-full.txt" ? "llms-full" : ` : ""}null;
7944
8216
  if (farmGeneratedLlmsKind) {
7945
8217
  const llmsContext = createFarmLlmsTxtContext(request, farmGeneratedLlmsKind === "llms-full");
7946
8218
  const llmsOrigin = new URL(request.url).origin;
@@ -7975,7 +8247,7 @@ async function handleFarmRequestInContext(
7975
8247
  }
7976
8248
  ` : ""}
7977
8249
 
7978
- ${_optionalChain([config, 'access', _145 => _145.docs, 'optionalAccess', _146 => _146.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
8250
+ ${_optionalChain([config, 'access', _158 => _158.docs, 'optionalAccess', _159 => _159.enabled]) ? `if (farmDocsAPIHandler && isFarmDocsAPIRequest(pathname)) {
7979
8251
  const docsAPIResponse = await farmDocsAPIHandler(cloneFarmRequestWithContext(request));
7980
8252
  if (docsAPIResponse) {
7981
8253
  return applyProductionMiddlewareHeaders(docsAPIResponse, middlewareHeaders);
@@ -8065,7 +8337,10 @@ async function handleFarmRequestInContext(
8065
8337
  const pageMetadata = route.module.metadata || {};
8066
8338
 
8067
8339
  // Get applicable layouts for this page
8068
- const applicableLayouts = getApplicableLayouts(routePathname);
8340
+ const applicableLayouts = getApplicableLayouts(
8341
+ routePathname,
8342
+ route.directory || route.pattern,
8343
+ );
8069
8344
  const shouldHydrateLayout = applicableLayouts.some(
8070
8345
  (layout) => layout.shouldHydrate === true,
8071
8346
  );
@@ -8298,7 +8573,9 @@ async function handleFarmRequestInContext(
8298
8573
  if (route.shouldHydrate && !shouldHydrateLayout) {
8299
8574
  pageElement = wrapFarmRouteClientGraph(pageElement);
8300
8575
  } else if (shouldHydrateLayout && !route.shouldHydrate) {
8301
- pageElement = isolateFarmRouteServerPage(pageElement);
8576
+ pageElement = route.serverTree
8577
+ ? await renderFarmRouteServerTree(pageElement)
8578
+ : isolateFarmRouteServerPage(pageElement);
8302
8579
  }
8303
8580
 
8304
8581
  pageElement = React.createElement(
@@ -8325,7 +8602,7 @@ async function handleFarmRequestInContext(
8325
8602
  if (LayoutComponent) {
8326
8603
  const slotProps = {};
8327
8604
  for (const slot of renderedRouteSlots) {
8328
- if (slot.ownerPattern !== layout.pattern) continue;
8605
+ if ((slot.ownerDirectory || slot.ownerPattern) !== layout.pattern) continue;
8329
8606
  slotProps[slot.name] = React.createElement(
8330
8607
  "div",
8331
8608
  {
@@ -8392,6 +8669,9 @@ async function handleFarmRequestInContext(
8392
8669
  await layout.module.generateMetadata({ params: pageProps.params }),
8393
8670
  );
8394
8671
  }
8672
+ mergedMetadata = await mergeModuleViewport(mergedMetadata, layout.module, {
8673
+ params: pageProps.params,
8674
+ });
8395
8675
  }
8396
8676
  mergedMetadata = mergeMetadata(mergedMetadata, pageMetadata);
8397
8677
  if (!routeStateRejected && typeof route.module.generateMetadata === "function") {
@@ -8400,6 +8680,11 @@ async function handleFarmRequestInContext(
8400
8680
  await route.module.generateMetadata(pageProps),
8401
8681
  );
8402
8682
  }
8683
+ mergedMetadata = await mergeModuleViewport(
8684
+ mergedMetadata,
8685
+ routeStateRejected ? { viewport: route.module.viewport } : route.module,
8686
+ pageProps,
8687
+ );
8403
8688
 
8404
8689
  if (!mergedMetadata.manifest) {
8405
8690
  const manifestMatch = getMatchingApplicationMetadataRoute(routePathname, "manifest");
@@ -8420,7 +8705,7 @@ async function handleFarmRequestInContext(
8420
8705
  );
8421
8706
  }
8422
8707
  }
8423
- ${_optionalChain([config, 'access', _147 => _147.md, 'optionalAccess', _148 => _148.enabled]) ? `
8708
+ ${_optionalChain([config, 'access', _160 => _160.md, 'optionalAccess', _161 => _161.enabled]) ? `
8424
8709
  // Advertise the Markdown mirror in the head as well as the Link header,
8425
8710
  // using the public path the .md request will be resolved against.
8426
8711
  mergedMetadata = addMetadataMarkdownAlternate(
@@ -8439,10 +8724,11 @@ async function handleFarmRequestInContext(
8439
8724
  emitFarmEvent({ type: "cache.bypass", route: pathname, reason: "request-read" });
8440
8725
  }
8441
8726
 
8442
- const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _149 => _149.agent, 'optionalAccess', _150 => _150.jsonLd]), () => ( false)))} });
8727
+ const renderedMetadata = renderMetadataHead(mergedMetadata, { pathname, jsonLd: ${JSON.stringify(_nullishCoalesce(_optionalChain([config, 'access', _162 => _162.agent, 'optionalAccess', _163 => _163.jsonLd]), () => ( false)))} });
8443
8728
  const title = renderedMetadata.title;
8444
8729
  const metaTags = renderedMetadata.tags;
8445
8730
  const hasFavicon = renderedMetadata.hasFavicon;
8731
+ const viewportTags = renderedMetadata.viewport;
8446
8732
 
8447
8733
  const hasPrivateRequestHeaders = hasPrivateFarmRequestHeaders(
8448
8734
  request,
@@ -8494,7 +8780,7 @@ async function handleFarmRequestInContext(
8494
8780
  const streamPrefix = '<!DOCTYPE html>\\n<html lang="en">\\n<head>\\n' +
8495
8781
  farmThemeDocument.head + '\\n' +
8496
8782
  ' <meta charset="utf-8">\\n' +
8497
- ' <meta name="viewport" content="width=device-width, initial-scale=1">\\n' +
8783
+ ' ' + viewportTags + '\\n' +
8498
8784
  (hasFavicon ? '' : ' <link rel="icon" href="data:,">\\n') +
8499
8785
  ' <title>' + title + '</title>' + metaTags + '\\n' +
8500
8786
  ' <link rel="stylesheet" href="/__farm_client_css_href__">\\n' +
@@ -8625,6 +8911,9 @@ async function handleFarmRequestInContext(
8625
8911
  ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
8626
8912
  );
8627
8913
 
8914
+ // Last, so the charset (and the viewport, unless the layout wrote one) open the head.
8915
+ fullHtml = ensureFarmDocumentMeta(fullHtml, viewportTags);
8916
+
8628
8917
  // Add DOCTYPE if not present
8629
8918
  if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
8630
8919
  fullHtml = '<!DOCTYPE html>\\n' + fullHtml;
@@ -8635,7 +8924,7 @@ async function handleFarmRequestInContext(
8635
8924
  <html lang="en">
8636
8925
  <head>
8637
8926
  <meta charset="utf-8">
8638
- <meta name="viewport" content="width=device-width, initial-scale=1">
8927
+ \${viewportTags}
8639
8928
  \${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
8640
8929
  \${suppressDefaultTitle ? "" : "<title>" + title + "</title>"}\${metaTags}\${rendererHead ? "\\n " + rendererHead : ""}
8641
8930
  <link rel="stylesheet" href="/__farm_client_css_href__">
@@ -8852,6 +9141,18 @@ async function handleFarmRequestInContext(
8852
9141
  }
8853
9142
  }
8854
9143
 
9144
+ ${servesDefaultMCP ? `
9145
+ // agent.mcp: no app route answered /mcp, so the default read-only server may.
9146
+ if (
9147
+ normalizeRuntimePath(routePathname) === ${JSON.stringify(_chunkPTZ2TVNEcjs.FARM_DEFAULT_MCP_PATH)} &&
9148
+ getFarmDefaultMCPServer()
9149
+ ) {
9150
+ return applyProductionMiddlewareHeaders(
9151
+ await handleFarmDefaultMCP(request),
9152
+ middlewareHeaders,
9153
+ );
9154
+ }
9155
+ ` : ""}
8855
9156
  // 404 fallback - render proper HTML page
8856
9157
  return renderFarmNotFoundResponse();
8857
9158
 
@@ -8885,7 +9186,8 @@ async function handleFarmRequestInContext(
8885
9186
  try {
8886
9187
  // Wrap 404 page with root layout if available
8887
9188
  let notFoundElement = createFarmNotFoundElement(pathname);
8888
- const applicableLayouts = getApplicableLayouts("/");
9189
+ // No page matched, so a layout inside a route group cannot apply.
9190
+ const applicableLayouts = getApplicableLayouts("/", null);
8889
9191
 
8890
9192
  // Wrap with layouts (from innermost to outermost)
8891
9193
  for (let i = applicableLayouts.length - 1; i >= 0; i--) {
@@ -8929,6 +9231,7 @@ async function handleFarmRequestInContext(
8929
9231
  () => ' ' + renderFarmClientBootstrapScript() + '\\n' +
8930
9232
  ' <script type="module" src="/__farm_client_js_src__"></script>\\n</body>',
8931
9233
  );
9234
+ fullHtml = ensureFarmDocumentMeta(fullHtml, notFoundMetadata.viewport);
8932
9235
  if (!fullHtml.trim().startsWith('<!DOCTYPE')) {
8933
9236
  fullHtml = '<!DOCTYPE html>\\n' + fullHtml;
8934
9237
  }
@@ -8937,7 +9240,7 @@ async function handleFarmRequestInContext(
8937
9240
  <html lang="en">
8938
9241
  <head>
8939
9242
  <meta charset="UTF-8">
8940
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
9243
+ \${notFoundMetadata.viewport}
8941
9244
  \${notFoundMetadata.hasFavicon ? "" : '<link rel="icon" href="data:,">'}
8942
9245
  <link rel="stylesheet" href="/__farm_client_css_href__">
8943
9246
  <title>\${notFoundMetadata.title}</title>\${notFoundMetadata.tags}
@@ -9055,11 +9358,11 @@ ${generatePreloadResponseRuntimeSource()}
9055
9358
 
9056
9359
  // Export as Web Standard fetch API
9057
9360
  export async function fetch(request, context) {
9058
- ${_optionalChain([config, 'access', _151 => _151.agent, 'optionalAccess', _152 => _152.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
9361
+ ${_optionalChain([config, 'access', _164 => _164.agent, 'optionalAccess', _165 => _165.noindexPreviews]) ? "const response = await" : "return"} _runWithAPIRequestRuntime({
9059
9362
  basePath: farmLocalAPIBasePath,
9060
9363
  dispatch: async (localRequest) =>
9061
9364
  (await handleAPIRequest(localRequest)) ?? Response.json({ error: "Not Found" }, { status: 404 }),
9062
- }, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _153 => _153.agent, 'optionalAccess', _154 => _154.noindexPreviews]) ? `
9365
+ }, () => handleFarmFetch(request, context));${_optionalChain([config, 'access', _166 => _166.agent, 'optionalAccess', _167 => _167.noindexPreviews]) ? `
9063
9366
  // Keep every response of a preview deployment out of search indexes.
9064
9367
  return farmNoindexPreview ? applyFarmPreviewRobotsTag(response) : response;` : ""}
9065
9368
  }
@@ -9255,11 +9558,11 @@ function getPhysicalPrerenderBypassReason(options) {
9255
9558
  }
9256
9559
  if (appMiddlewareMayHandlePath(middlewareRoutes, pathname)) return "app middleware";
9257
9560
  if (configMiddlewareMayHandlePath(config.middleware, pathname)) return "configured middleware";
9258
- if (_chunkPQDFUSXDcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
9561
+ if (_chunkUVW64BCBcjs.hasCustomFarmRouteContext.call(void 0, config)) return "request context";
9259
9562
  if (farmServerRuntimePluginsMayHandlePath(config, pathname)) return "server runtime plugin";
9260
9563
  const manifestEntry = getManifestPageEntry(routeRuntimeManifest, pathname);
9261
- if (_optionalChain([manifestEntry, 'optionalAccess', _155 => _155.rendering]) === "dynamic") return "dynamic runtime manifest";
9262
- if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _156 => _156.regions, 'optionalAccess', _157 => _157.length])) || manifestEntry.maxDuration !== void 0)) {
9564
+ if (_optionalChain([manifestEntry, 'optionalAccess', _168 => _168.rendering]) === "dynamic") return "dynamic runtime manifest";
9565
+ if (manifestEntry && (manifestEntry.runtime !== "auto" || Boolean(_optionalChain([manifestEntry, 'access', _169 => _169.regions, 'optionalAccess', _170 => _170.length])) || manifestEntry.maxDuration !== void 0)) {
9263
9566
  return "route runtime controls";
9264
9567
  }
9265
9568
  const routeRule = getEffectiveRouteRule(config, pathname);
@@ -9281,7 +9584,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
9281
9584
  const nitroBuilder = nitroBuilderResult.value;
9282
9585
  const isVercel = preset === "vercel" || preset === "vercel-edge";
9283
9586
  const isCloudflareWorker = preset === "cloudflare-module";
9284
- const outputDir = _chunkPQDFUSXDcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
9587
+ const outputDir = _chunkUVW64BCBcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
9285
9588
  const runtimeServerOutputDir = isVercel ? _path2.default.join(outputDir, "functions", "__nitro.func") : _path2.default.join(outputDir, "server");
9286
9589
  const ssrOutputDir = _path2.default.join(root, distDir, "ssr");
9287
9590
  const imageRuntime = resolveImageRuntime(config, preset);
@@ -9303,9 +9606,9 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
9303
9606
  _chunk5QIKR7RRcjs.logger.info(`\u{1F4E6} SSR entry file: ${ssrEntryFile}`);
9304
9607
  _chunk5QIKR7RRcjs.logger.info(`\u{1F4E6} Preset: ${preset}`);
9305
9608
  const ssgCollectionPromise = routeManager.collectSSGPages();
9306
- const middlewareRoutesPromise = discoverMiddlewareRoutes(_chunkVPTDD5XFcjs.getFarmAppDirectories.call(void 0, config));
9609
+ const middlewareRoutesPromise = discoverMiddlewareRoutes(_chunkWBKEZXWEcjs.getFarmAppDirectories.call(void 0, config));
9307
9610
  const configuredResponseRoutesPromise = Promise.all([config.redirects(), config.rewrites()]);
9308
- const farmWorkflows = await _chunkMPEYMSCFcjs.prepareFarmWorkflowsForNitro.call(void 0, config);
9611
+ const farmWorkflows = await _chunkSDOTRX3Vcjs.prepareFarmWorkflowsForNitro.call(void 0, config);
9309
9612
  const farmCron = await _chunk6EXBPJ24cjs.prepareFarmCronForNitro.call(void 0, config);
9310
9613
  const [{ ssg: ssgPages }, middlewareRoutes, [configuredRedirects, configuredRewrites]] = await Promise.all([
9311
9614
  ssgCollectionPromise,
@@ -9526,6 +9829,10 @@ function toFarmNodeResponse(request, response) {
9526
9829
  await fs.writeFile(nitroEntryPath, nitroEntryCode);
9527
9830
  const farmNodeServerEntryPath = preset === "node-server" ? _path2.default.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
9528
9831
  if (farmNodeServerEntryPath && nodeAdapterModule) {
9832
+ await fs.writeFile(
9833
+ _path2.default.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
9834
+ FARM_NODE_ENV_MODULE_SOURCE
9835
+ );
9529
9836
  await fs.writeFile(
9530
9837
  farmNodeServerEntryPath,
9531
9838
  createFarmNodeServerEntry({
@@ -9667,20 +9974,20 @@ function toFarmNodeResponse(request, response) {
9667
9974
  snapshotSSRRebundleOptions(nitroConfig)
9668
9975
  );
9669
9976
  const requestedBuilder = _nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER));
9670
- const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _158 => _158.rollupConfig, 'optionalAccess', _159 => _159.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _160 => _160.rollupConfig, 'optionalAccess', _161 => _161.plugins])) && customRollupKeys.length === 0 && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _162 => _162.output, 'optionalAccess', _163 => _163.serverDir]) || "") === _path2.default.resolve(expectedServerDir) && Boolean(
9671
- _optionalChain([nitroConfig, 'access', _164 => _164.handlers, 'optionalAccess', _165 => _165.some, 'call', _166 => _166(
9672
- (handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _167 => _167.handler]) || "") === nitroEntryPath
9977
+ const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && _optionalChain([nitroConfig, 'access', _171 => _171.rollupConfig, 'optionalAccess', _172 => _172.external]) === nitroRollupExternal && !hasRollupPlugins(_optionalChain([nitroConfig, 'access', _173 => _173.rollupConfig, 'optionalAccess', _174 => _174.plugins])) && customRollupKeys.length === 0 && _path2.default.resolve(_optionalChain([nitroConfig, 'access', _175 => _175.output, 'optionalAccess', _176 => _176.serverDir]) || "") === _path2.default.resolve(expectedServerDir) && Boolean(
9978
+ _optionalChain([nitroConfig, 'access', _177 => _177.handlers, 'optionalAccess', _178 => _178.some, 'call', _179 => _179(
9979
+ (handler) => _path2.default.resolve(_optionalChain([handler, 'optionalAccess', _180 => _180.handler]) || "") === nitroEntryPath
9673
9980
  )])
9674
9981
  );
9675
9982
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
9676
9983
  if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
9677
9984
  const useRolldownBuilder = canReusePrebuiltSSR && (_nullishCoalesce(nitroConfig.builder, () => ( process.env.NITRO_BUILDER))) === "rolldown";
9678
9985
  const shouldMinify = nitroConfig.minify !== false;
9679
- const keepServerNames = !(_optionalChain([config, 'access', _168 => _168.docs, 'optionalAccess', _169 => _169.enabled]) && _optionalChain([config, 'access', _170 => _170.docs, 'access', _171 => _171.adapter, 'optionalAccess', _172 => _172.server]));
9986
+ const keepServerNames = !(_optionalChain([config, 'access', _181 => _181.docs, 'optionalAccess', _182 => _182.enabled]) && _optionalChain([config, 'access', _183 => _183.docs, 'access', _184 => _184.adapter, 'optionalAccess', _185 => _185.server]));
9680
9987
  const useFarmServerMinifier = shouldMinify && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig;
9681
9988
  const serverChunkMinifier = useFarmServerMinifier ? createServerChunkMinifyPlugin({ keepNames: keepServerNames, target: "esnext" }) : null;
9682
9989
  if (canReusePrebuiltSSR) {
9683
- const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _173 => _173.rollupConfig, 'optionalAccess', _174 => _174.plugins]);
9990
+ const configuredRollupPlugins = _optionalChain([nitroConfig, 'access', _186 => _186.rollupConfig, 'optionalAccess', _187 => _187.plugins]);
9684
9991
  nitroConfig.rollupConfig = {
9685
9992
  ...nitroConfig.rollupConfig,
9686
9993
  plugins: [
@@ -9691,10 +9998,10 @@ function toFarmNodeResponse(request, response) {
9691
9998
  }
9692
9999
  nitroConfig.minify = useFarmServerMinifier ? false : shouldMinify;
9693
10000
  const nitroInstance = await nitroBuilder.createNitro(nitroConfig);
9694
- if (_optionalChain([config, 'access', _175 => _175.md, 'optionalAccess', _176 => _176.enabled])) {
10001
+ if (_optionalChain([config, 'access', _188 => _188.md, 'optionalAccess', _189 => _189.enabled])) {
9695
10002
  nitroInstance.hooks.hook("prerender:generate", (route) => {
9696
- if (!route.contents || !_optionalChain([route, 'access', _177 => _177.contentType, 'optionalAccess', _178 => _178.toLowerCase, 'call', _179 => _179(), 'access', _180 => _180.includes, 'call', _181 => _181("html")])) return;
9697
- const alternatePath = _chunkXXJU7FCCcjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route);
10003
+ if (!route.contents || !_optionalChain([route, 'access', _190 => _190.contentType, 'optionalAccess', _191 => _191.toLowerCase, 'call', _192 => _192(), 'access', _193 => _193.includes, 'call', _194 => _194("html")])) return;
10004
+ const alternatePath = _chunkEUV4YR3Vcjs.getFarmMarkdownAlternatePath.call(void 0, config.md, route.route);
9698
10005
  if (!alternatePath) return;
9699
10006
  const routeRule = nitroInstance.options.routeRules[route.route] || {};
9700
10007
  const alternate = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
@@ -9714,8 +10021,8 @@ function toFarmNodeResponse(request, response) {
9714
10021
  }
9715
10022
  if (config.security.csp && config.security.csp.nonce) {
9716
10023
  nitroInstance.hooks.hook("prerender:generate", async (route) => {
9717
- if (!route.contents || !_optionalChain([route, 'access', _182 => _182.contentType, 'optionalAccess', _183 => _183.toLowerCase, 'call', _184 => _184(), 'access', _185 => _185.includes, 'call', _186 => _186("html")])) return;
9718
- const staticCsp = await _chunkZHPHJPQPcjs.applyFarmCspHashesToHtml.call(void 0, route.contents, config.security);
10024
+ if (!route.contents || !_optionalChain([route, 'access', _195 => _195.contentType, 'optionalAccess', _196 => _196.toLowerCase, 'call', _197 => _197(), 'access', _198 => _198.includes, 'call', _199 => _199("html")])) return;
10025
+ const staticCsp = await _chunkMRMI32SNcjs.applyFarmCspHashesToHtml.call(void 0, route.contents, config.security);
9719
10026
  if (!staticCsp) return;
9720
10027
  route.contents = staticCsp.html;
9721
10028
  const routeRule = nitroInstance.options.routeRules[route.route] || {};
@@ -9922,7 +10229,7 @@ async function moveVercelOutputPath(src, dest, fs) {
9922
10229
  await fs.rename(src, dest);
9923
10230
  return;
9924
10231
  } catch (error) {
9925
- const code = _optionalChain([error, 'optionalAccess', _187 => _187.code]);
10232
+ const code = _optionalChain([error, 'optionalAccess', _200 => _200.code]);
9926
10233
  if (code !== "EPERM" && code !== "EACCES" && code !== "EXDEV" && code !== "ENOTEMPTY") {
9927
10234
  throw error;
9928
10235
  }
@@ -9949,7 +10256,7 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
9949
10256
  try {
9950
10257
  await moveVercelOutputPath(publicDir, staticDir, fs);
9951
10258
  } catch (error) {
9952
- if (_optionalChain([error, 'optionalAccess', _188 => _188.code]) !== "ENOENT") throw error;
10259
+ if (_optionalChain([error, 'optionalAccess', _201 => _201.code]) !== "ENOENT") throw error;
9953
10260
  }
9954
10261
  await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs);
9955
10262
  await copyPrismaClientForVercel(root, nitroFuncDir, fs);
@@ -9966,7 +10273,7 @@ async function postProcessVercelOutput(root, outputDir, fs, config, farmWorkflow
9966
10273
  presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
9967
10274
  runtimeRoutes
9968
10275
  });
9969
- const vercelConfigWithWorkflowCrons = _chunkMPEYMSCFcjs.applyFarmWorkflowVercelCrons.call(void 0,
10276
+ const vercelConfigWithWorkflowCrons = _chunkSDOTRX3Vcjs.applyFarmWorkflowVercelCrons.call(void 0,
9970
10277
  vercelConfig,
9971
10278
  farmWorkflows.workflows
9972
10279
  );
@@ -9982,7 +10289,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
9982
10289
  const docsContentDir = resolveBuildDocsContentDir(config, root);
9983
10290
  if (!docsContentDir) return;
9984
10291
  const bundledContentDir = _path2.default.join(nitroFuncDir, "farm-docs-content");
9985
- const lastModifiedManifest = _chunkZ2YLTERKcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
10292
+ const lastModifiedManifest = _chunkTE2G5IONcjs.createFarmDocsLastModifiedManifest.call(void 0, docsContentDir, {
9986
10293
  fallback: "now"
9987
10294
  });
9988
10295
  await fs.rm(bundledContentDir, { recursive: true, force: true });
@@ -9992,7 +10299,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs) {
9992
10299
  force: true
9993
10300
  });
9994
10301
  await fs.writeFile(
9995
- _path2.default.join(bundledContentDir, _chunkZ2YLTERKcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
10302
+ _path2.default.join(bundledContentDir, _chunkTE2G5IONcjs.FARM_DOCS_LAST_MODIFIED_MANIFEST),
9996
10303
  `${JSON.stringify(lastModifiedManifest, null, 2)}
9997
10304
  `
9998
10305
  );
@@ -10022,7 +10329,7 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
10022
10329
  if (!resolvePackageJson(projectRequire, "sharp")) {
10023
10330
  try {
10024
10331
  sharpRequire = _module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core"));
10025
- } catch (e23) {
10332
+ } catch (e25) {
10026
10333
  }
10027
10334
  }
10028
10335
  const copiedPackages = /* @__PURE__ */ new Map();
@@ -10069,7 +10376,7 @@ async function stageSharpRuntime(config, root, distDir, fs, preset) {
10069
10376
  try {
10070
10377
  await copyPackage("sharp", sharpRequire);
10071
10378
  if (!copiedPackages.has("sharp")) {
10072
- throw new Error(`Farm image optimization requires sharp. ${_chunkSJVKK4JEcjs.SHARP_INSTALL_HINT}`);
10379
+ throw new Error(`Farm image optimization requires sharp. ${_chunkNMHWYWDRcjs.SHARP_INSTALL_HINT}`);
10073
10380
  }
10074
10381
  } catch (error) {
10075
10382
  await fs.rm(stageDir, { recursive: true, force: true });
@@ -10156,7 +10463,7 @@ function resolveMetadataImageRuntimePackageJson(root) {
10156
10463
  if (packageJsonPath) return packageJsonPath;
10157
10464
  try {
10158
10465
  return resolvePackageJson(_module.createRequire.call(void 0, projectRequire.resolve("@farm.js/core")), "@vercel/og");
10159
- } catch (e24) {
10466
+ } catch (e26) {
10160
10467
  return null;
10161
10468
  }
10162
10469
  }
@@ -10207,7 +10514,7 @@ function resolvePackageJson(parentRequire, packageName) {
10207
10514
  const resolved = parentRequire.resolve(request);
10208
10515
  if (resolved.endsWith(".json")) return resolved;
10209
10516
  _nullishCoalesce(metadataModule, () => ( (metadataModule = resolved)));
10210
- } catch (e25) {
10517
+ } catch (e27) {
10211
10518
  }
10212
10519
  }
10213
10520
  try {
@@ -10218,13 +10525,13 @@ function resolvePackageJson(parentRequire, packageName) {
10218
10525
  try {
10219
10526
  const manifest = JSON.parse(_fs.readFileSync.call(void 0, candidate, "utf8"));
10220
10527
  if (manifest.name === packageName) return candidate;
10221
- } catch (e26) {
10528
+ } catch (e28) {
10222
10529
  }
10223
10530
  }
10224
10531
  if (_path2.default.basename(directory) === "node_modules") break;
10225
10532
  directory = _path2.default.dirname(directory);
10226
10533
  }
10227
- } catch (e27) {
10534
+ } catch (e29) {
10228
10535
  }
10229
10536
  return null;
10230
10537
  }
@@ -10234,13 +10541,13 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs) {
10234
10541
  let prismaClientDir;
10235
10542
  try {
10236
10543
  prismaClientDir = _path2.default.dirname(projectRequire.resolve("@prisma/client/default.js"));
10237
- } catch (e28) {
10544
+ } catch (e30) {
10238
10545
  return;
10239
10546
  }
10240
10547
  const generatedClientDir = _path2.default.join(prismaClientDir, "..", "..", ".prisma", "client");
10241
10548
  try {
10242
10549
  await fs.access(generatedClientDir);
10243
- } catch (e29) {
10550
+ } catch (e31) {
10244
10551
  return;
10245
10552
  }
10246
10553
  const targetNodeModules = _path2.default.join(nitroFuncDir, "node_modules");
@@ -10283,7 +10590,7 @@ function createBuildTargetBaseline(config) {
10283
10590
  preset,
10284
10591
  distDir,
10285
10592
  outputDir,
10286
- outputWasDerived: outputDir === _chunkPQDFUSXDcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
10593
+ outputWasDerived: outputDir === _chunkUVW64BCBcjs.getDefaultDeployOutputDir.call(void 0, config.deploy.target, preset, distDir)
10287
10594
  };
10288
10595
  }
10289
10596
  _chunkS3JO3N4Hcjs.__name.call(void 0, createBuildTargetBaseline, "createBuildTargetBaseline");
@@ -10293,8 +10600,8 @@ function resolveBuildTargets(config, options, baseline) {
10293
10600
  const distDir = config.distDir || ".farm";
10294
10601
  const outputWasReplaced = config.deploy.outputDir !== baseline.outputDir;
10295
10602
  const shouldRefreshDerivedOutput = baseline.outputWasDerived && !outputWasReplaced && (preset !== baseline.preset || distDir !== baseline.distDir);
10296
- const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkPQDFUSXDcjs.getDeployTargetForPreset.call(void 0, preset);
10297
- const outputDir = shouldRefreshDerivedOutput ? _chunkPQDFUSXDcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
10603
+ const deployTarget = preset === config.deploy.preset ? config.deploy.target : _chunkUVW64BCBcjs.getDeployTargetForPreset.call(void 0, preset);
10604
+ const outputDir = shouldRefreshDerivedOutput ? _chunkUVW64BCBcjs.getDefaultDeployOutputDir.call(void 0, deployTarget, preset, distDir) : config.deploy.outputDir;
10298
10605
  return {
10299
10606
  root,
10300
10607
  preset,
@@ -10302,7 +10609,7 @@ function resolveBuildTargets(config, options, baseline) {
10302
10609
  distDir,
10303
10610
  deployTarget,
10304
10611
  outputDir,
10305
- deployOutputDir: _chunkPQDFUSXDcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
10612
+ deployOutputDir: _chunkUVW64BCBcjs.resolveDeployOutputPath.call(void 0, root, outputDir)
10306
10613
  };
10307
10614
  }
10308
10615
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveBuildTargets, "resolveBuildTargets");
@@ -10311,7 +10618,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10311
10618
  const targetBaseline = createBuildTargetBaseline(config);
10312
10619
  let targets;
10313
10620
  const productionViteResultPromise = options.universal === false ? void 0 : Promise.allSettled([Promise.resolve(_nullishCoalesce(options.productionVite, () => ( _chunkA6WIQH5Zcjs.loadFarmProductionVite.call(void 0, ))))]);
10314
- const pluginManager = new (0, _chunkSJVKK4JEcjs.PluginManager)({
10621
+ const pluginManager = new (0, _chunkNMHWYWDRcjs.PluginManager)({
10315
10622
  config,
10316
10623
  isDev: false,
10317
10624
  isProd: true
@@ -10340,12 +10647,12 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10340
10647
  };
10341
10648
  config = {
10342
10649
  ...config,
10343
- images: _chunkSJVKK4JEcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
10650
+ images: _chunkNMHWYWDRcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, {
10344
10651
  root: targets.root,
10345
10652
  preset: targets.preset
10346
10653
  })
10347
10654
  };
10348
- if (_optionalChain([config, 'access', _189 => _189.docs, 'optionalAccess', _190 => _190.enabled])) await _chunkIK6LVLKCcjs.loadFarmDocsEngine.call(void 0, );
10655
+ if (_optionalChain([config, 'access', _202 => _202.docs, 'optionalAccess', _203 => _203.enabled])) await _chunkIK6LVLKCcjs.loadFarmDocsEngine.call(void 0, );
10349
10656
  pluginManager.updateContext({ config });
10350
10657
  const { root, preset, srcDir, distDir, deployOutputDir } = targets;
10351
10658
  _chunk5QIKR7RRcjs.logger.info(`\u{1F69C} Building Farm.js application with preset: ${preset}...`);
@@ -10359,8 +10666,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10359
10666
  });
10360
10667
  _chunk5QIKR7RRcjs.logger.info("\u{1F50D} Discovering routes and API endpoints...");
10361
10668
  const productionViteResult = productionViteResultPromise ? (await productionViteResultPromise)[0] : void 0;
10362
- if (_optionalChain([productionViteResult, 'optionalAccess', _191 => _191.status]) === "rejected") throw productionViteResult.reason;
10363
- const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _192 => _192.value]);
10669
+ if (_optionalChain([productionViteResult, 'optionalAccess', _204 => _204.status]) === "rejected") throw productionViteResult.reason;
10670
+ const productionVite = _optionalChain([productionViteResult, 'optionalAccess', _205 => _205.value]);
10364
10671
  const createViteServer = productionVite ? productionVite.createServer : (await import("vite")).createServer;
10365
10672
  projectModuleServer = await createProjectModuleServer(
10366
10673
  createViteServer,
@@ -10368,18 +10675,18 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10368
10675
  root,
10369
10676
  rendererBuild.signal
10370
10677
  );
10371
- const farmApp = _chunkSJVKK4JEcjs.createFarmApp.call(void 0, config, projectModuleServer);
10678
+ const farmApp = _chunkNMHWYWDRcjs.createFarmApp.call(void 0, config, projectModuleServer);
10372
10679
  await farmApp.initialize();
10373
10680
  const routeManager = farmApp.getRouteManager();
10374
10681
  const serverRenderer = farmApp.getServerRenderer();
10375
- const typeArtifacts = _chunkQJ3J6MZTcjs.generateFarmTypeArtifacts.call(void 0, {
10682
+ const typeArtifacts = _chunkJNUWCDTFcjs.generateFarmTypeArtifacts.call(void 0, {
10376
10683
  root,
10377
10684
  srcDir,
10378
10685
  layers: config.layers,
10379
10686
  plugins: config.plugins,
10380
10687
  extraRoutes: [
10381
- ..._optionalChain([config, 'access', _193 => _193.openapi, 'optionalAccess', _194 => _194.enabled]) && config.openapi.route ? [config.openapi.route] : [],
10382
- ..._chunkZ2YLTERKcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
10688
+ ..._optionalChain([config, 'access', _206 => _206.openapi, 'optionalAccess', _207 => _207.enabled]) && config.openapi.route ? [config.openapi.route] : [],
10689
+ ..._chunkTE2G5IONcjs.getFarmDocsRouteTypeEntries.call(void 0, config.docs)
10383
10690
  ],
10384
10691
  suppressLintOnLink: config.suppressLintOnLink,
10385
10692
  componentExtensions: config.renderer.componentExtensions,
@@ -10388,8 +10695,8 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10388
10695
  const message = error instanceof Error ? error.message : String(error);
10389
10696
  _chunk5QIKR7RRcjs.logger.warn(`Route type generation failed (farm.d.ts may be stale): ${message}`);
10390
10697
  });
10391
- const apiRouteManager = new (0, _chunkMIDIZJZCcjs.APIRouteManager)(
10392
- _chunkVPTDD5XFcjs.getFarmAppDirectories.call(void 0, config),
10698
+ const apiRouteManager = new (0, _chunkFO427P6Icjs.APIRouteManager)(
10699
+ _chunkWBKEZXWEcjs.getFarmAppDirectories.call(void 0, config),
10393
10700
  projectModuleServer,
10394
10701
  {
10395
10702
  throwOnLoadError: true,
@@ -10463,7 +10770,7 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
10463
10770
  throw error;
10464
10771
  } finally {
10465
10772
  try {
10466
- await _optionalChain([projectModuleServer, 'optionalAccess', _195 => _195.close, 'call', _196 => _196()]);
10773
+ await _optionalChain([projectModuleServer, 'optionalAccess', _208 => _208.close, 'call', _209 => _209()]);
10467
10774
  } finally {
10468
10775
  rendererBuild.abort();
10469
10776
  }
@@ -10475,7 +10782,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
10475
10782
  ssr: true,
10476
10783
  buildLifetime
10477
10784
  });
10478
- const viteConfig = _chunkSJVKK4JEcjs.mergeFarmViteConfig.call(void 0,
10785
+ const viteConfig = _chunkNMHWYWDRcjs.mergeFarmViteConfig.call(void 0,
10479
10786
  {
10480
10787
  root,
10481
10788
  appType: "custom",
@@ -10487,7 +10794,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
10487
10794
  },
10488
10795
  plugins: [
10489
10796
  ...rendererVitePlugins,
10490
- _chunkSJVKK4JEcjs.farmFontImportsPlugin.call(void 0, {
10797
+ _chunkNMHWYWDRcjs.farmFontImportsPlugin.call(void 0, {
10491
10798
  root,
10492
10799
  basePath: config.basePath,
10493
10800
  publicDir: config.publicDir
@@ -10499,7 +10806,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
10499
10806
  hmr: false
10500
10807
  },
10501
10808
  resolve: {
10502
- alias: _chunkSJVKK4JEcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
10809
+ alias: _chunkNMHWYWDRcjs.createFarmSourceAlias.call(void 0, root, config.srcDir),
10503
10810
  dedupe: [...config.renderer.dedupe || []]
10504
10811
  },
10505
10812
  optimizeDeps: {
@@ -10585,7 +10892,7 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
10585
10892
  define: {
10586
10893
  __FARM_API_BASE_URL__: JSON.stringify(config.api.baseURL),
10587
10894
  __FARM_ENV__: JSON.stringify(_chunkVEKFLAQMcjs.createBundledEnv.call(void 0, config.env)),
10588
- __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _197 => _197.env, 'optionalAccess', _198 => _198.public]) || {})
10895
+ __FARM_PUBLIC_ENV__: JSON.stringify(_optionalChain([config, 'access', _210 => _210.env, 'optionalAccess', _211 => _211.public]) || {})
10589
10896
  },
10590
10897
  plugins: [
10591
10898
  farmI18nClientBridgePlugin(),
@@ -10607,7 +10914,7 @@ function resolveLegacyPageEntry(config, root, srcDir) {
10607
10914
  _chunkS3JO3N4Hcjs.__name.call(void 0, resolveLegacyPageEntry, "resolveLegacyPageEntry");
10608
10915
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
10609
10916
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
10610
- import("./nitro-HSAQFXSS.cjs"),
10917
+ import("./nitro-7F65EZZS.cjs"),
10611
10918
  import("nitro/builder")
10612
10919
  ]);
10613
10920
  let nitroConfig = await createNitroConfig(
@@ -10620,7 +10927,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
10620
10927
  if (pluginManager) {
10621
10928
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
10622
10929
  }
10623
- const outputDir = _chunkPQDFUSXDcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
10930
+ const outputDir = _chunkUVW64BCBcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir);
10624
10931
  const serverOutputDir = _path2.default.join(outputDir, "server");
10625
10932
  const publicOutputDir = _path2.default.join(outputDir, "public");
10626
10933
  const { mkdir, cp } = await import("fs/promises");
@@ -10679,7 +10986,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
10679
10986
  const { readFile } = await import("fs/promises");
10680
10987
  const manifestContent = await readFile(clientManifestPath, "utf-8");
10681
10988
  farmRegistry.clientManifest = JSON.parse(manifestContent);
10682
- } catch (e30) {
10989
+ } catch (e32) {
10683
10990
  farmRegistry.clientManifest = {};
10684
10991
  }
10685
10992
  } catch (error) {
@@ -10691,7 +10998,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
10691
10998
  root,
10692
10999
  preset,
10693
11000
  distDir,
10694
- outputDir: _chunkPQDFUSXDcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
11001
+ outputDir: _chunkUVW64BCBcjs.resolveDeployOutputPath.call(void 0, root, config.deploy.outputDir)
10695
11002
  });
10696
11003
  }
10697
11004
  }