@farm.js/core 0.1.31 → 0.1.35

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 (352) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-runtime.cjs +70 -15
  3. package/dist/agent-runtime.d.mts +4 -5
  4. package/dist/agent-runtime.d.ts +4 -5
  5. package/dist/agent-runtime.mjs +59 -4
  6. package/dist/api/route-manager.cjs +17 -14
  7. package/dist/api/route-manager.d.mts +6 -7
  8. package/dist/api/route-manager.d.ts +6 -7
  9. package/dist/api/route-manager.mjs +16 -13
  10. package/dist/api/runtime.cjs +12 -8
  11. package/dist/api/runtime.d.mts +4 -5
  12. package/dist/api/runtime.d.ts +4 -5
  13. package/dist/api/runtime.mjs +12 -8
  14. package/dist/api.cjs +20 -17
  15. package/dist/api.d.mts +7 -8
  16. package/dist/api.d.ts +7 -8
  17. package/dist/api.mjs +19 -16
  18. package/dist/{app-sUJ3jnTZ.d.ts → app-BXB3JZYc.d.ts} +38 -12
  19. package/dist/{app-DAuUTIZf.d.mts → app-D_j9AAVL.d.mts} +38 -12
  20. package/dist/app-markdown.cjs +8 -6
  21. package/dist/app-markdown.d.mts +6 -7
  22. package/dist/app-markdown.d.ts +6 -7
  23. package/dist/app-markdown.mjs +7 -5
  24. package/dist/cache.cjs +2 -2
  25. package/dist/cache.d.mts +10 -1
  26. package/dist/cache.d.ts +10 -1
  27. package/dist/cache.mjs +1 -1
  28. package/dist/{chunk-BXFWA23T.mjs → chunk-22LTEMGQ.mjs} +3 -3
  29. package/dist/{chunk-YZTASLPQ.cjs → chunk-27ZWSI3W.cjs} +2 -2
  30. package/dist/{chunk-WBIH66JK.mjs → chunk-2ELDTQRN.mjs} +5 -2
  31. package/dist/{chunk-K7CELQLK.cjs → chunk-2F2ER724.cjs} +54 -29
  32. package/dist/{chunk-O3DTUAX2.mjs → chunk-2G2NNLE2.mjs} +6 -77
  33. package/dist/{chunk-NRVGEI5I.mjs → chunk-2NNMOPDN.mjs} +4 -210
  34. package/dist/{chunk-CTV2TTNP.cjs → chunk-3BHT4WMP.cjs} +16 -87
  35. package/dist/chunk-3BU22U3M.cjs +237 -0
  36. package/dist/{chunk-MM5D6VLP.mjs → chunk-3KZS4SUS.mjs} +33 -14
  37. package/dist/{chunk-VA62MHFV.mjs → chunk-3PXS2MHU.mjs} +1 -1
  38. package/dist/chunk-3SDFA7UF.cjs +701 -0
  39. package/dist/{chunk-4IEPYMHF.mjs → chunk-3UEVPCGW.mjs} +1 -1
  40. package/dist/{chunk-MXDTKXO6.cjs → chunk-3UH7MRCP.cjs} +73 -26
  41. package/dist/{chunk-7QOCTYBS.mjs → chunk-4JHOT46A.mjs} +37 -1
  42. package/dist/{chunk-6L6DQR5W.mjs → chunk-4KU5Q7C2.mjs} +917 -305
  43. package/dist/{chunk-3FCFQP5V.cjs → chunk-4MMGO7YW.cjs} +25 -25
  44. package/dist/{chunk-5HGR3W6O.mjs → chunk-5SJWVY6R.mjs} +8 -0
  45. package/dist/{chunk-KZLND3D2.cjs → chunk-62XKI4Z3.cjs} +7 -5
  46. package/dist/{chunk-FJZ3DQLK.mjs → chunk-6DU6UFUE.mjs} +13 -12
  47. package/dist/{chunk-TEN4FIZU.mjs → chunk-6ETPZTJI.mjs} +513 -3
  48. package/dist/{chunk-VUMAE7NC.mjs → chunk-6TJOML4E.mjs} +92 -31
  49. package/dist/{chunk-3ATMYLLJ.mjs → chunk-6WCPV6G2.mjs} +1 -1
  50. package/dist/{chunk-FYRBX5IY.cjs → chunk-73MC7ZL6.cjs} +2 -2
  51. package/dist/chunk-75RZHGLS.cjs +135 -0
  52. package/dist/{chunk-QZRVZSPN.cjs → chunk-77GNHH2Z.cjs} +3 -3
  53. package/dist/{chunk-FXUUWYAX.cjs → chunk-7GLPRTTF.cjs} +12 -2
  54. package/dist/{chunk-A777V5WU.cjs → chunk-7L5V3KQO.cjs} +2 -2
  55. package/dist/{chunk-4ZQQL4IU.mjs → chunk-AHGECQEW.mjs} +1 -1
  56. package/dist/{chunk-RG3ZOTG5.cjs → chunk-AI7QMY7O.cjs} +10 -3
  57. package/dist/{chunk-YMCXWPWK.mjs → chunk-BCMSYSN2.mjs} +4 -1
  58. package/dist/{chunk-I6XDAKWQ.mjs → chunk-BTHHUD7Q.mjs} +14 -0
  59. package/dist/{chunk-LI2LMOLR.mjs → chunk-C35ZBVRD.mjs} +12 -3
  60. package/dist/chunk-C4SPBWFM.cjs +26 -0
  61. package/dist/{chunk-YQVSHTMR.mjs → chunk-CP6X4AEU.mjs} +1 -1
  62. package/dist/{chunk-QZCT2CQ4.mjs → chunk-CXEN47J3.mjs} +64 -2
  63. package/dist/{chunk-WNLBF77X.cjs → chunk-D227TIEN.cjs} +28 -16
  64. package/dist/{chunk-ROUTX2E5.cjs → chunk-DBNKI4NF.cjs} +12 -3
  65. package/dist/{chunk-J3LOGE4T.cjs → chunk-DQQOKWYA.cjs} +5 -5
  66. package/dist/chunk-E5GNDG5F.mjs +701 -0
  67. package/dist/{chunk-X7KZBF63.cjs → chunk-EFCQPQMG.cjs} +40 -4
  68. package/dist/{chunk-K3F2E6GS.cjs → chunk-EJQT6KZN.cjs} +2 -2
  69. package/dist/{chunk-3LUF2PE2.cjs → chunk-EK4QAEFZ.cjs} +67 -5
  70. package/dist/{chunk-VVBO3QH7.mjs → chunk-ENLZ4R3Y.mjs} +10 -1
  71. package/dist/{chunk-KJ2TIHZZ.cjs → chunk-EUV4YR3V.cjs} +3 -2
  72. package/dist/{chunk-E76XC6ZG.mjs → chunk-EZDQRNQ7.mjs} +2 -2
  73. package/dist/{chunk-TOVMYGYW.mjs → chunk-F2SE2VDO.mjs} +1 -1
  74. package/dist/{chunk-MNUGPHLN.mjs → chunk-F6Z3Y5KL.mjs} +5 -3
  75. package/dist/{chunk-DFLLARUK.cjs → chunk-F7JZENPF.cjs} +35 -34
  76. package/dist/{chunk-BSPQVJ4A.mjs → chunk-FDR64H6B.mjs} +13 -0
  77. package/dist/{chunk-5OVTOKGH.cjs → chunk-FFFW3OQ7.cjs} +2 -2
  78. package/dist/{chunk-D4JE5NNV.cjs → chunk-FNO7A7CM.cjs} +5 -5
  79. package/dist/{chunk-Z5HIWVDP.cjs → chunk-FTFYRMQQ.cjs} +80 -91
  80. package/dist/chunk-FZ6YYU2W.mjs +65 -0
  81. package/dist/{chunk-X7WVQMIB.mjs → chunk-G5RT7EXW.mjs} +11 -5
  82. package/dist/{chunk-IXUY2F5U.mjs → chunk-GCXWJJKH.mjs} +4 -7
  83. package/dist/{chunk-ES4B2IXW.cjs → chunk-GFHLGIYC.cjs} +8 -8
  84. package/dist/{chunk-SORB3MAR.cjs → chunk-GQ3Z3IZI.cjs} +17 -17
  85. package/dist/{chunk-75WGQVQA.cjs → chunk-HITLGIAO.cjs} +10 -1
  86. package/dist/{chunk-HBTUGXHS.cjs → chunk-HLJ6MBUZ.cjs} +7 -4
  87. package/dist/{chunk-JLCQGPXE.mjs → chunk-HMIJDL7S.mjs} +51 -62
  88. package/dist/{chunk-F6XEGFHO.mjs → chunk-HUMR6LSU.mjs} +11 -1
  89. package/dist/{chunk-IMB4PIAR.cjs → chunk-ICUQICNC.cjs} +1441 -828
  90. package/dist/{chunk-ZCU4NZ3M.cjs → chunk-IE7XCHH3.cjs} +4 -4
  91. package/dist/{chunk-I26CZYPV.cjs → chunk-IHNIDL6H.cjs} +50 -7
  92. package/dist/{chunk-2FQHH5SC.mjs → chunk-IHNMMXHV.mjs} +49 -24
  93. package/dist/{chunk-YVGAEAA5.cjs → chunk-IPXLADVO.cjs} +522 -12
  94. package/dist/{chunk-VHJGDMCG.cjs → chunk-IWZKTWHZ.cjs} +2 -2
  95. package/dist/chunk-JG6DJF5A.mjs +238 -0
  96. package/dist/{chunk-KROWKCUH.cjs → chunk-JGLC4TO3.cjs} +8 -1
  97. package/dist/{chunk-5TISYEQF.mjs → chunk-JM5XPKWH.mjs} +10 -3
  98. package/dist/{chunk-BJJATPEC.mjs → chunk-KN7K4VQN.mjs} +1 -1
  99. package/dist/{chunk-WPYFSQKK.cjs → chunk-KNBBQHO2.cjs} +15 -1
  100. package/dist/{chunk-XWAWFQFS.cjs → chunk-KXWRO25S.cjs} +7 -4
  101. package/dist/chunk-LSKZMJMP.cjs +65 -0
  102. package/dist/{chunk-2N5PX3LS.mjs → chunk-LYV44OIR.mjs} +7 -1
  103. package/dist/chunk-M7MKQXAF.cjs +87 -0
  104. package/dist/{chunk-IV6CQY7O.mjs → chunk-MSSFIQGM.mjs} +63 -13
  105. package/dist/{chunk-KH7BN726.cjs → chunk-N4UOK6ZI.cjs} +8 -2
  106. package/dist/{chunk-JNGIWIY6.mjs → chunk-NPC7VWJE.mjs} +2 -2
  107. package/dist/chunk-NRDBW4MP.mjs +45 -0
  108. package/dist/{chunk-ILWLPEVO.mjs → chunk-NRSN7G7E.mjs} +2 -2
  109. package/dist/chunk-OFZUJMCU.mjs +601 -0
  110. package/dist/{chunk-L4DVIHOC.mjs → chunk-OKZUAXHF.mjs} +1 -1
  111. package/dist/{chunk-EM6SBQKM.cjs → chunk-OMVAU7NT.cjs} +27 -2
  112. package/dist/{chunk-AHAJGAYD.mjs → chunk-PDOCJ6RY.mjs} +2 -2
  113. package/dist/{chunk-IFI5FXEZ.cjs → chunk-PFQKNERH.cjs} +562 -251
  114. package/dist/{chunk-S5GDHOE4.mjs → chunk-PZNL3WEG.mjs} +48 -5
  115. package/dist/{chunk-GZYH4OER.mjs → chunk-Q3VLETLE.mjs} +2 -2
  116. package/dist/{chunk-WG2KHOMN.mjs → chunk-QAU5JD57.mjs} +571 -260
  117. package/dist/{chunk-FV45CKBC.mjs → chunk-QCFBDFRS.mjs} +1 -1
  118. package/dist/{chunk-75BRBIFP.cjs → chunk-QCVE2OCI.cjs} +5 -8
  119. package/dist/{chunk-6ZCMSZ5U.mjs → chunk-QE6VAKLT.mjs} +1 -1
  120. package/dist/{chunk-QG5HNS7P.mjs → chunk-QORUJDIV.mjs} +2 -2
  121. package/dist/chunk-RHAZ22ZN.mjs +87 -0
  122. package/dist/{chunk-CUMINO7Z.cjs → chunk-RU3M2FIK.cjs} +18 -14
  123. package/dist/{chunk-DGXN3L4D.mjs → chunk-SAZVVAJH.mjs} +5 -5
  124. package/dist/{chunk-MKMBQSNQ.mjs → chunk-SC2WYWPF.mjs} +3 -3
  125. package/dist/{chunk-QCFFHV5H.mjs → chunk-SMHH4VDG.mjs} +1 -1
  126. package/dist/{chunk-UAFSBWNT.mjs → chunk-SOMHP6GF.mjs} +63 -16
  127. package/dist/{chunk-ND224OE2.cjs → chunk-TKSCR644.cjs} +34 -15
  128. package/dist/{chunk-4V7GIE2U.mjs → chunk-UAORZ7QA.mjs} +3 -3
  129. package/dist/{chunk-IQXFRNY2.cjs → chunk-UFDAAQFX.cjs} +2 -2
  130. package/dist/{chunk-6VYZOPOT.mjs → chunk-UJD4PHYB.mjs} +15 -11
  131. package/dist/{chunk-ZHVYQL3H.cjs → chunk-ULAWS2PA.cjs} +97 -36
  132. package/dist/{chunk-5ZSWG4UX.cjs → chunk-UXFQ3UDA.cjs} +14 -1
  133. package/dist/{chunk-MPEYMSCF.cjs → chunk-VFQT3LAO.cjs} +5 -5
  134. package/dist/{chunk-2FXWWUE5.cjs → chunk-VZJR7UTG.cjs} +6 -6
  135. package/dist/{chunk-2AKFKCHA.mjs → chunk-W7LF2J2S.mjs} +1 -1
  136. package/dist/chunk-WWFTAUFG.cjs +45 -0
  137. package/dist/{chunk-JBC2FKRW.mjs → chunk-WWIKMBRN.mjs} +2 -1
  138. package/dist/{chunk-75DYEVXI.cjs → chunk-X6W5FFH6.cjs} +11 -11
  139. package/dist/{chunk-EXLKRR4U.cjs → chunk-XBML5KMG.cjs} +12 -12
  140. package/dist/{chunk-PZNCMPJF.cjs → chunk-XCACDAZZ.cjs} +18 -12
  141. package/dist/{chunk-JATSG2ZO.mjs → chunk-XCMCS4DA.mjs} +15 -3
  142. package/dist/{chunk-UJ2C4ICS.cjs → chunk-XJXBIP67.cjs} +4 -4
  143. package/dist/{chunk-XF7Q24PF.mjs → chunk-Y7RKTKYI.mjs} +25 -0
  144. package/dist/{chunk-VYZSOYR4.cjs → chunk-YC6V7PWE.cjs} +1 -1
  145. package/dist/{chunk-F6OHXPWR.mjs → chunk-YFILVET3.mjs} +8 -1
  146. package/dist/{chunk-JLRDISQL.cjs → chunk-YKX5BK66.cjs} +7 -7
  147. package/dist/{chunk-DYEJQTDN.cjs → chunk-YSCV4SJF.cjs} +4 -4
  148. package/dist/chunk-YSLWRWWP.cjs +601 -0
  149. package/dist/{chunk-5LJCOSKT.mjs → chunk-YULD7ICZ.mjs} +1 -1
  150. package/dist/{chunk-2SDO73HK.cjs → chunk-YWN746US.cjs} +64 -14
  151. package/dist/chunk-Z2HLU4IX.cjs +238 -0
  152. package/dist/chunk-ZLAT2CWY.mjs +135 -0
  153. package/dist/{chunk-T5CERMEH.cjs → chunk-ZXGAFZDO.cjs} +2 -2
  154. package/dist/{client-plugins-BX2ptm4H.d.mts → client-plugins-CvIslxWi.d.mts} +232 -8
  155. package/dist/{client-plugins-BmxM5KW_.d.ts → client-plugins-HIyulDym.d.ts} +232 -8
  156. package/dist/client-plugins.d.mts +4 -5
  157. package/dist/client-plugins.d.ts +4 -5
  158. package/dist/client.cjs +10 -10
  159. package/dist/client.d.mts +8 -9
  160. package/dist/client.d.ts +8 -9
  161. package/dist/client.mjs +9 -9
  162. package/dist/config.d.mts +4 -5
  163. package/dist/config.d.ts +4 -5
  164. package/dist/{devtools-EWRDHCD5.cjs → devtools-EAUY43BS.cjs} +14 -12
  165. package/dist/{devtools-BPBCYOU6.mjs → devtools-EE5RIBTH.mjs} +13 -11
  166. package/dist/docs.cjs +17 -15
  167. package/dist/docs.d.mts +46 -4
  168. package/dist/docs.d.ts +46 -4
  169. package/dist/docs.mjs +16 -14
  170. package/dist/environment/vite.cjs +2 -2
  171. package/dist/environment/vite.mjs +1 -1
  172. package/dist/headers.cjs +4 -4
  173. package/dist/headers.mjs +3 -3
  174. package/dist/i18n/client.cjs +14 -13
  175. package/dist/i18n/client.d.mts +2 -2
  176. package/dist/i18n/client.d.ts +2 -2
  177. package/dist/i18n/client.mjs +5 -4
  178. package/dist/i18n/index.cjs +3 -2
  179. package/dist/i18n/index.d.mts +3 -3
  180. package/dist/i18n/index.d.ts +3 -3
  181. package/dist/i18n/index.mjs +2 -1
  182. package/dist/i18n/server.cjs +6 -5
  183. package/dist/i18n/server.d.mts +5 -5
  184. package/dist/i18n/server.d.ts +5 -5
  185. package/dist/i18n/server.mjs +5 -4
  186. package/dist/image/server.cjs +3 -3
  187. package/dist/image/server.mjs +2 -2
  188. package/dist/image/sharp.cjs +10 -10
  189. package/dist/image/sharp.mjs +2 -2
  190. package/dist/{index-a-8Z5kZU.d.mts → index-BJJfLxJo.d.mts} +2 -2
  191. package/dist/{index-BWVfxIsO.d.ts → index-CwoOP-MW.d.ts} +2 -2
  192. package/dist/index.cjs +75 -60
  193. package/dist/index.d.mts +21 -22
  194. package/dist/index.d.ts +21 -22
  195. package/dist/index.mjs +79 -64
  196. package/dist/integrations.cjs +7 -4
  197. package/dist/integrations.d.mts +4 -5
  198. package/dist/integrations.d.ts +4 -5
  199. package/dist/integrations.mjs +8 -5
  200. package/dist/internal/app-markdown-runtime.cjs +7 -5
  201. package/dist/internal/app-markdown-runtime.d.mts +17 -7
  202. package/dist/internal/app-markdown-runtime.d.ts +17 -7
  203. package/dist/internal/app-markdown-runtime.mjs +6 -4
  204. package/dist/internal/build-runtime.cjs +44 -41
  205. package/dist/internal/build-runtime.d.mts +6 -7
  206. package/dist/internal/build-runtime.d.ts +6 -7
  207. package/dist/internal/build-runtime.mjs +43 -40
  208. package/dist/internal/cli-runtime.cjs +23 -20
  209. package/dist/internal/cli-runtime.mjs +22 -19
  210. package/dist/internal/client-error-overlay.cjs +6 -6
  211. package/dist/internal/client-error-overlay.mjs +2 -2
  212. package/dist/internal/client-runtime.cjs +5 -3
  213. package/dist/internal/client-runtime.d.mts +9 -1
  214. package/dist/internal/client-runtime.d.ts +9 -1
  215. package/dist/internal/client-runtime.mjs +4 -2
  216. package/dist/internal/compression-runtime.d.mts +4 -5
  217. package/dist/internal/compression-runtime.d.ts +4 -5
  218. package/dist/internal/config-runtime.cjs +14 -12
  219. package/dist/internal/config-runtime.d.mts +5 -6
  220. package/dist/internal/config-runtime.d.ts +5 -6
  221. package/dist/internal/config-runtime.mjs +13 -11
  222. package/dist/internal/infra-analytics-runtime.cjs +4 -4
  223. package/dist/internal/infra-analytics-runtime.mjs +2 -2
  224. package/dist/internal/isolated-boundary.cjs +3 -2
  225. package/dist/internal/isolated-boundary.d.mts +1 -0
  226. package/dist/internal/isolated-boundary.d.ts +1 -0
  227. package/dist/internal/isolated-boundary.mjs +2 -1
  228. package/dist/internal/metadata-image-runtime.cjs +3 -3
  229. package/dist/internal/metadata-image-runtime.mjs +2 -2
  230. package/dist/internal/product-telemetry-runtime.cjs +2 -2
  231. package/dist/internal/product-telemetry-runtime.mjs +1 -1
  232. package/dist/internal/production-runtime.cjs +61 -31
  233. package/dist/internal/production-runtime.d.mts +165 -18
  234. package/dist/internal/production-runtime.d.ts +165 -18
  235. package/dist/internal/production-runtime.mjs +57 -27
  236. package/dist/internal/request-cookies.cjs +4 -2
  237. package/dist/internal/request-cookies.d.mts +9 -1
  238. package/dist/internal/request-cookies.d.ts +9 -1
  239. package/dist/internal/request-cookies.mjs +3 -1
  240. package/dist/internal/server-tree.cjs +12 -0
  241. package/dist/internal/server-tree.d.mts +27 -0
  242. package/dist/internal/server-tree.d.ts +27 -0
  243. package/dist/internal/server-tree.mjs +12 -0
  244. package/dist/markdown.cjs +4 -4
  245. package/dist/markdown.d.mts +4 -5
  246. package/dist/markdown.d.ts +4 -5
  247. package/dist/markdown.mjs +3 -3
  248. package/dist/{metadata-DsEaK7mQ.d.mts → metadata-BnLDsUOS.d.ts} +16 -2
  249. package/dist/{metadata-fwZ3gfG6.d.ts → metadata-WGpBYcGn.d.mts} +16 -2
  250. package/dist/middleware.cjs +18 -8
  251. package/dist/middleware.d.mts +27 -9
  252. package/dist/middleware.d.ts +27 -9
  253. package/dist/middleware.mjs +18 -8
  254. package/dist/navigation.cjs +7 -7
  255. package/dist/navigation.d.mts +7 -8
  256. package/dist/navigation.d.ts +7 -8
  257. package/dist/navigation.mjs +6 -6
  258. package/dist/{nitro-NAKCRVHX.mjs → nitro-MXRDCXWZ.mjs} +5 -5
  259. package/dist/{nitro-VYDZGYFY.cjs → nitro-OVPLKPE2.cjs} +7 -7
  260. package/dist/{observability-BupkiN0m.d.mts → observability-CoXunYhS.d.mts} +4 -3
  261. package/dist/{observability-BupkiN0m.d.ts → observability-CoXunYhS.d.ts} +4 -3
  262. package/dist/observability.d.mts +1 -1
  263. package/dist/observability.d.ts +1 -1
  264. package/dist/plugin.cjs +39 -36
  265. package/dist/plugin.d.mts +4 -5
  266. package/dist/plugin.d.ts +4 -5
  267. package/dist/plugin.mjs +38 -35
  268. package/dist/{production-runtime-Baqgwtvc.d.mts → production-runtime-0sRnuYc-.d.mts} +11 -4
  269. package/dist/{production-runtime-DNkpFnmg.d.ts → production-runtime-Crq6CJ-2.d.ts} +11 -4
  270. package/dist/query/client.cjs +8 -8
  271. package/dist/query/client.mjs +4 -4
  272. package/dist/{render-plan-rkIK9wd9.d.ts → render-plan-8ozZh2Qv.d.ts} +1 -1
  273. package/dist/{render-plan-DhwQnmmX.d.mts → render-plan-gs9GGPzw.d.mts} +1 -1
  274. package/dist/renderer/react/server.cjs +10 -4
  275. package/dist/renderer/react/server.d.mts +2 -1
  276. package/dist/renderer/react/server.d.ts +2 -1
  277. package/dist/renderer/react/server.mjs +7 -1
  278. package/dist/renderer-client.cjs +40 -20
  279. package/dist/renderer-client.d.mts +6 -7
  280. package/dist/renderer-client.d.ts +6 -7
  281. package/dist/renderer-client.mjs +29 -9
  282. package/dist/renderer.d.mts +2 -0
  283. package/dist/renderer.d.ts +2 -0
  284. package/dist/{request-BcY4RYPC.d.ts → request-B5G8rLBH.d.ts} +7 -2
  285. package/dist/{request-CFy1BltJ.d.mts → request-fkhiynXe.d.mts} +7 -2
  286. package/dist/request.cjs +2 -2
  287. package/dist/request.d.mts +5 -6
  288. package/dist/request.d.ts +5 -6
  289. package/dist/request.mjs +1 -1
  290. package/dist/{resolver-PPEeiJ6M.d.ts → resolver-DadfRL6F.d.ts} +1 -1
  291. package/dist/{resolver-DhW0CqZN.d.mts → resolver-khasx3fU.d.mts} +1 -1
  292. package/dist/{route-rendering-BkS0TBlB.d.mts → route-rendering-CLnS7AZj.d.mts} +1 -1
  293. package/dist/{route-rendering-D4XpMjam.d.ts → route-rendering-lS5nUMua.d.ts} +1 -1
  294. package/dist/{router-Cq7BcZxg.d.ts → router-4iuiYnOW.d.ts} +1 -1
  295. package/dist/{router-C4zPlC3V.d.mts → router-ifU8Dui1.d.mts} +1 -1
  296. package/dist/routes.cjs +3 -3
  297. package/dist/routes.d.mts +4 -5
  298. package/dist/routes.d.ts +4 -5
  299. package/dist/routes.mjs +2 -2
  300. package/dist/{runtime-BirxPwbZ.d.ts → runtime-BgDQzBiu.d.ts} +2 -2
  301. package/dist/{runtime-AOJge4vQ.d.mts → runtime-CV2UCV-5.d.mts} +2 -2
  302. package/dist/server-action-security.cjs +3 -3
  303. package/dist/server-action-security.mjs +2 -2
  304. package/dist/server-fn.cjs +5 -5
  305. package/dist/server-fn.mjs +4 -4
  306. package/dist/server-plugins.cjs +4 -4
  307. package/dist/server-plugins.d.mts +5 -6
  308. package/dist/server-plugins.d.ts +5 -6
  309. package/dist/server-plugins.mjs +3 -3
  310. package/dist/server-query-client.cjs +3 -3
  311. package/dist/server-query-client.mjs +2 -2
  312. package/dist/server-query.cjs +6 -6
  313. package/dist/server-query.mjs +5 -5
  314. package/dist/server.cjs +66 -63
  315. package/dist/server.d.mts +13 -14
  316. package/dist/server.d.ts +13 -14
  317. package/dist/server.mjs +43 -40
  318. package/dist/{spa-router-DzPZH-AO.d.mts → spa-router-Bq7VCOwx.d.mts} +3 -3
  319. package/dist/{spa-router-B1HI3X9k.d.ts → spa-router-DaJk5Re4.d.ts} +3 -3
  320. package/dist/testing.cjs +22 -20
  321. package/dist/testing.d.mts +4 -5
  322. package/dist/testing.d.ts +4 -5
  323. package/dist/testing.mjs +18 -16
  324. package/dist/theme/server.cjs +4 -3
  325. package/dist/theme/server.mjs +3 -2
  326. package/dist/{types-Z0aotQ8w.d.mts → types-CnH8DOqo.d.mts} +1 -1
  327. package/dist/{types-Z0aotQ8w.d.ts → types-CnH8DOqo.d.ts} +1 -1
  328. package/dist/{utils-DMD1Hzta.d.ts → utils-BXLmFsVR.d.ts} +1 -1
  329. package/dist/{utils-CEBktlBG.d.mts → utils-XJn0c9bj.d.mts} +1 -1
  330. package/dist/version.cjs +2 -2
  331. package/dist/version.mjs +1 -1
  332. package/dist/vite.cjs +39 -36
  333. package/dist/vite.d.mts +4 -5
  334. package/dist/vite.d.ts +4 -5
  335. package/dist/vite.mjs +38 -35
  336. package/dist/{workflows-CR9ex-gz.d.ts → workflows-jZ4BcdoZ.d.mts} +1 -1
  337. package/dist/{workflows-CR9ex-gz.d.mts → workflows-jZ4BcdoZ.d.ts} +1 -1
  338. package/dist/workflows.cjs +3 -3
  339. package/dist/workflows.d.mts +1 -1
  340. package/dist/workflows.d.ts +1 -1
  341. package/dist/workflows.mjs +2 -2
  342. package/package.json +10 -2
  343. package/dist/chunk-22GUSVNJ.cjs +0 -351
  344. package/dist/chunk-5MKEDGLD.cjs +0 -53
  345. package/dist/chunk-O6XNAMBV.mjs +0 -53
  346. package/dist/chunk-SWN467MP.cjs +0 -18
  347. package/dist/chunk-XGC343EY.cjs +0 -443
  348. package/dist/chunk-ZSH2Y4LN.mjs +0 -351
  349. package/dist/types-DFbjpjXX.d.mts +0 -105
  350. package/dist/types-DFbjpjXX.d.ts +0 -105
  351. /package/dist/{chunk-SUIBNSNO.cjs → chunk-SJNMVDDF.cjs} +0 -0
  352. /package/dist/{chunk-LNZ7JZUS.mjs → chunk-UDNPLXW7.mjs} +0 -0
@@ -1,12 +1,10 @@
1
1
  import {
2
2
  collectSSGPages,
3
- createRouteSlotContainerId,
4
3
  generateFarmTypeArtifacts,
5
4
  matchSSGPage,
6
- parseRouteSlotFile,
7
5
  resolveRouteRenderingConfig,
8
6
  resolveRouteRenderingConfigFromFile
9
- } from "./chunk-O3DTUAX2.mjs";
7
+ } from "./chunk-2G2NNLE2.mjs";
10
8
  import {
11
9
  collectSchemaExtensions,
12
10
  declareSchemaTables,
@@ -17,26 +15,42 @@ import {
17
15
  } from "./chunk-ZMSZZXOR.mjs";
18
16
  import {
19
17
  FARM_API_CATALOG_PATH,
18
+ FARM_APP_MANIFEST_PATH,
19
+ classifyFarmDocumentPrefix,
20
+ composeFarmFullDocument,
20
21
  createDefaultErrorMarkup,
22
+ createFarmAiCatalogResponse,
21
23
  createFarmApiCatalogResponse,
24
+ createFarmAppManifestResponse,
22
25
  createFarmMetadataRouteResponse,
23
26
  createFarmThemeDocumentParts,
24
27
  createLateNotFoundRecovery,
25
28
  createLateRedirectRecovery,
29
+ createRouteDirectoryPattern,
30
+ extractFarmFullDocument,
31
+ formatRouteSegment,
26
32
  getDefaultErrorStatusText,
33
+ getRouteDirectoryDepth,
34
+ getRouteGroupScope,
35
+ isInRouteGroupScope,
36
+ listFarmMCPLlmsTxtLinks,
37
+ removeFarmDocumentTitles,
27
38
  renderFarmLocaleAlternateLinks,
28
39
  resolveDefaultErrorStatus,
29
- resolveFarmApiCatalogInput
30
- } from "./chunk-TEN4FIZU.mjs";
40
+ resolveFarmApiCatalogInput,
41
+ resolveFarmAppManifestInput,
42
+ routeBoundaryCoversDirectory,
43
+ stripRouteGroups
44
+ } from "./chunk-6ETPZTJI.mjs";
31
45
  import {
32
46
  isFarmPreviewDeploymentEnvironment
33
47
  } from "./chunk-BOYNDCZL.mjs";
34
48
  import {
35
49
  createFarmMetadataImageResponse
36
- } from "./chunk-YQVSHTMR.mjs";
50
+ } from "./chunk-CP6X4AEU.mjs";
37
51
  import {
38
52
  createFarmImageHandler
39
- } from "./chunk-F6XEGFHO.mjs";
53
+ } from "./chunk-HUMR6LSU.mjs";
40
54
  import {
41
55
  FARM_ISLAND_REPLAYABLE_SELECTOR,
42
56
  isFarmIslandStrategy
@@ -46,15 +60,16 @@ import {
46
60
  } from "./chunk-PNGWZFUQ.mjs";
47
61
  import {
48
62
  farmEnvironmentFunctionsPlugin
49
- } from "./chunk-ZSH2Y4LN.mjs";
63
+ } from "./chunk-E5GNDG5F.mjs";
50
64
  import {
51
65
  _setDefaultFarmThemeConfig,
52
66
  getTheme
53
- } from "./chunk-WBIH66JK.mjs";
67
+ } from "./chunk-2ELDTQRN.mjs";
54
68
  import {
55
69
  generateFarmDocsAdapterClientRuntime,
56
- getFarmDocsAdapterConfigModule
57
- } from "./chunk-VVBO3QH7.mjs";
70
+ getFarmDocsAdapterConfigModule,
71
+ isSecretDocsConfigKey
72
+ } from "./chunk-ENLZ4R3Y.mjs";
58
73
  import {
59
74
  resolveFarmDocsFontAssets,
60
75
  toFarmDocsPublicFontAssets
@@ -108,7 +123,7 @@ import {
108
123
  resolveFarmLlmsTxtConfig,
109
124
  resolveFarmPerformanceConfig,
110
125
  resolveFarmSecurityConfig
111
- } from "./chunk-6VYZOPOT.mjs";
126
+ } from "./chunk-UJD4PHYB.mjs";
112
127
  import {
113
128
  getPublicFarmImageConfig,
114
129
  resolveFarmImageConfig
@@ -118,7 +133,7 @@ import {
118
133
  } from "./chunk-YHOCRI4H.mjs";
119
134
  import {
120
135
  resolveServerActionsConfig
121
- } from "./chunk-QCFFHV5H.mjs";
136
+ } from "./chunk-SMHH4VDG.mjs";
122
137
  import {
123
138
  createBundledEnv,
124
139
  getResolvedEnv
@@ -126,12 +141,12 @@ import {
126
141
  import {
127
142
  createFarmMarkdownRouteModuleFromFile,
128
143
  loadFarmMdxComponents
129
- } from "./chunk-5LJCOSKT.mjs";
144
+ } from "./chunk-YULD7ICZ.mjs";
130
145
  import {
131
146
  createFarmMarkdownSourceResponse,
132
147
  isFarmMarkdownPageFile,
133
148
  normalizeFarmMarkdownRoutePath
134
- } from "./chunk-7QOCTYBS.mjs";
149
+ } from "./chunk-4JHOT46A.mjs";
135
150
  import {
136
151
  resolveFarmMdxComponentsModulePath,
137
152
  resolveMdxConfig
@@ -145,10 +160,10 @@ import {
145
160
  getFarmMarkdownMirrorPath,
146
161
  resolveMarkdownConfig,
147
162
  resolveMarkdownMirrorTarget
148
- } from "./chunk-JBC2FKRW.mjs";
163
+ } from "./chunk-WWIKMBRN.mjs";
149
164
  import {
150
165
  resolveWorkflowsConfig
151
- } from "./chunk-3ATMYLLJ.mjs";
166
+ } from "./chunk-6WCPV6G2.mjs";
152
167
  import {
153
168
  initStorage
154
169
  } from "./chunk-UWPLULNK.mjs";
@@ -168,16 +183,20 @@ import {
168
183
  getRegisteredIntegrationAPIManifest,
169
184
  isFarmIntegrationProviderComponentReference,
170
185
  matchIntegrationRoute
171
- } from "./chunk-JLCQGPXE.mjs";
186
+ } from "./chunk-HMIJDL7S.mjs";
172
187
  import {
173
188
  MiddlewareManager
174
- } from "./chunk-VUMAE7NC.mjs";
189
+ } from "./chunk-6TJOML4E.mjs";
190
+ import {
191
+ createRouteSlotContainerId,
192
+ parseRouteSlotFile
193
+ } from "./chunk-RHAZ22ZN.mjs";
175
194
  import {
176
195
  _clearCurrentMiddlewareContext,
177
196
  _clearCurrentMiddlewareData,
178
197
  _runWithMiddlewareContext,
179
198
  _runWithMiddlewareData
180
- } from "./chunk-NRVGEI5I.mjs";
199
+ } from "./chunk-2NNMOPDN.mjs";
181
200
  import {
182
201
  _runWithAPIRequestRuntime
183
202
  } from "./chunk-R3DS7A2T.mjs";
@@ -186,17 +205,17 @@ import {
186
205
  } from "./chunk-IOEH4VWN.mjs";
187
206
  import {
188
207
  APIRouteManager
189
- } from "./chunk-BXFWA23T.mjs";
208
+ } from "./chunk-22LTEMGQ.mjs";
190
209
  import {
191
210
  findProgrammaticRouteFiles,
192
211
  loadProgrammaticRouteManifests
193
- } from "./chunk-LNZ7JZUS.mjs";
212
+ } from "./chunk-UDNPLXW7.mjs";
194
213
  import {
195
214
  _runWithFarmI18nRequest,
196
215
  _setDefaultFarmI18nRuntime,
197
216
  createFarmI18nRuntime,
198
217
  getFarmI18nClientSnapshot
199
- } from "./chunk-JNGIWIY6.mjs";
218
+ } from "./chunk-NPC7VWJE.mjs";
200
219
  import {
201
220
  VERCEL_OG_INSTALL_HINT,
202
221
  formatOptionalPeerInstallHint,
@@ -205,10 +224,10 @@ import {
205
224
  } from "./chunk-YOZYCI6Z.mjs";
206
225
  import {
207
226
  isFarmAPIPathname
208
- } from "./chunk-X7WVQMIB.mjs";
227
+ } from "./chunk-G5RT7EXW.mjs";
209
228
  import {
210
- resolveFarmAPIServerBasePath
211
- } from "./chunk-I6XDAKWQ.mjs";
229
+ registerFarmMCPServer
230
+ } from "./chunk-ZLAT2CWY.mjs";
212
231
  import {
213
232
  createProgrammaticRouteModuleId,
214
233
  getProgrammaticRouteSearchClientOptions,
@@ -228,11 +247,12 @@ import {
228
247
  configureFarmCache,
229
248
  getFarmDataCache,
230
249
  normalizeRevalidatePath
231
- } from "./chunk-IV6CQY7O.mjs";
250
+ } from "./chunk-MSSFIQGM.mjs";
232
251
  import {
233
252
  clearRequestContext,
234
253
  copyRequestContext,
235
254
  createFarmNodeRequestAbortSignal,
255
+ createFarmNodeRequestBodyStream,
236
256
  createFarmRequestBodyErrorResponse,
237
257
  deleteRequestContext,
238
258
  getRequestContext,
@@ -242,7 +262,7 @@ import {
242
262
  readNodeRequestBody,
243
263
  resolveFarmServerConfig,
244
264
  setRequestContext
245
- } from "./chunk-XF7Q24PF.mjs";
265
+ } from "./chunk-Y7RKTKYI.mjs";
246
266
  import {
247
267
  createCliColors
248
268
  } from "./chunk-I2BHUNBU.mjs";
@@ -255,7 +275,7 @@ import {
255
275
  isFarmI18nCatalogFile,
256
276
  resolveFarmI18nConfig,
257
277
  resolveFarmI18nMessagePath
258
- } from "./chunk-YMCXWPWK.mjs";
278
+ } from "./chunk-BCMSYSN2.mjs";
259
279
  import {
260
280
  fileExists,
261
281
  globFiles,
@@ -274,6 +294,9 @@ import {
274
294
  import {
275
295
  searchParamsToObject
276
296
  } from "./chunk-QVKYGNVM.mjs";
297
+ import {
298
+ resolveFarmAPIServerBasePath
299
+ } from "./chunk-BTHHUD7Q.mjs";
277
300
  import {
278
301
  configureFarmObservability,
279
302
  emitFarmEvent,
@@ -285,7 +308,7 @@ import {
285
308
  } from "./chunk-Z2RZJZIZ.mjs";
286
309
  import {
287
310
  FARM_VERSION
288
- } from "./chunk-VA62MHFV.mjs";
311
+ } from "./chunk-3PXS2MHU.mjs";
289
312
  import {
290
313
  resolveFarmTrailingSlashRedirect,
291
314
  setFarmTrailingSlashPreference
@@ -297,14 +320,16 @@ import {
297
320
  import {
298
321
  createFarmLocaleCookie,
299
322
  getFarmLocaleVaryHeaders
300
- } from "./chunk-IXUY2F5U.mjs";
323
+ } from "./chunk-GCXWJJKH.mjs";
301
324
  import {
302
325
  addMetadataImageReference,
303
326
  addMetadataMarkdownAlternate,
304
327
  mergeMetadata,
328
+ mergeModuleViewport,
305
329
  renderMetadataHead,
330
+ renderViewportHead,
306
331
  resolveFarmNotFoundMetadata
307
- } from "./chunk-QZCT2CQ4.mjs";
332
+ } from "./chunk-CXEN47J3.mjs";
308
333
  import {
309
334
  FARM_DEPLOYMENT_ID_HEADER,
310
335
  createFarmDeploymentCookie,
@@ -321,7 +346,7 @@ import {
321
346
  } from "./chunk-CNOQY6Z7.mjs";
322
347
  import {
323
348
  FARM_CONFIG_REWRITES_PLUGIN_NAME
324
- } from "./chunk-2AKFKCHA.mjs";
349
+ } from "./chunk-W7LF2J2S.mjs";
325
350
  import {
326
351
  appendFarmRedirectQuery
327
352
  } from "./chunk-BRYHOB4X.mjs";
@@ -331,10 +356,14 @@ import {
331
356
  isFarmRedirectError
332
357
  } from "./chunk-CBBLJMR5.mjs";
333
358
  import {
359
+ _getRequestReadCount,
334
360
  _runWithCurrentRequest,
335
361
  createWebRequestFromFarmRequest,
336
362
  resolveFarmRequestURL
337
- } from "./chunk-BSPQVJ4A.mjs";
363
+ } from "./chunk-FDR64H6B.mjs";
364
+ import {
365
+ _resolveCurrentRequest
366
+ } from "./chunk-IZY3V5XW.mjs";
338
367
  import {
339
368
  localizeFarmHref,
340
369
  localizeFarmPathname,
@@ -743,6 +772,26 @@ function parseClientModuleMetadata(content, inspectIslandExport) {
743
772
  };
744
773
  }
745
774
  __name(parseClientModuleMetadata, "parseClientModuleMetadata");
775
+ var DEFAULT_REEXPORT = /export\s*\{\s*default(?:\s+as\s+default)?\s*\}\s*from\s*(["'])([^"']+)\1/;
776
+ function resolveDefaultReexport(ownerPath, content, root) {
777
+ const match = content ? DEFAULT_REEXPORT.exec(content) : null;
778
+ if (!match) return null;
779
+ const imported = resolveImportedModule(ownerPath, match[2], root);
780
+ return imported.local ? imported.path : null;
781
+ }
782
+ __name(resolveDefaultReexport, "resolveDefaultReexport");
783
+ function resolveOwnerSourcePath(resolvedPath, root) {
784
+ const seen = /* @__PURE__ */ new Set();
785
+ let current = resolvedPath;
786
+ while (current && !seen.has(current)) {
787
+ seen.add(current);
788
+ const target = resolveDefaultReexport(current, readIfExists(current), root);
789
+ if (!target) return current;
790
+ current = target;
791
+ }
792
+ return current;
793
+ }
794
+ __name(resolveOwnerSourcePath, "resolveOwnerSourcePath");
746
795
  function getClientModuleMetadata(modulePath, root) {
747
796
  const resolvedPath = resolveModuleSourcePath(modulePath, root);
748
797
  return inspectClientModuleMetadata(resolvedPath, root, /* @__PURE__ */ new Set(), true);
@@ -764,7 +813,7 @@ function getClientModuleHydrationPlan(modulePath, root, mode = "off", options =
764
813
  }), "emptyPlan");
765
814
  const asyncOwner = metadata.suppressedAsyncHydration === true && options.asyncOwnerIslands === true;
766
815
  if (mode === "off" && !asyncOwner) return emptyPlan();
767
- const resolvedPath = resolveModuleSourcePath(modulePath, root);
816
+ const resolvedPath = resolveOwnerSourcePath(resolveModuleSourcePath(modulePath, root), root);
768
817
  const content = readIfExists(resolvedPath ?? "");
769
818
  const parsed = parseClientModuleMetadata(content, true);
770
819
  if (!resolvedPath) return emptyPlan("the owner source could not be resolved");
@@ -818,6 +867,10 @@ function getClientModuleHydrationPlan(modulePath, root, mode = "off", options =
818
867
  return plan;
819
868
  }
820
869
  __name(getClientModuleHydrationPlan, "getClientModuleHydrationPlan");
870
+ function usesFarmServerTree(plan) {
871
+ return plan?.asyncOwnerIslands === true && plan.isolatedBoundaries.length > 0 && plan.isolatedBoundaries.every((boundary) => boundary.islandStrategy === "load");
872
+ }
873
+ __name(usesFarmServerTree, "usesFarmServerTree");
821
874
  function getMarkdownPageHydrationPlan(componentsModulePath, root, mode = "off", options = {}) {
822
875
  const plan = {
823
876
  isClientComponent: false,
@@ -1305,6 +1358,10 @@ function inspectClientModuleMetadata(resolvedPath, root, visited, inspectIslandE
1305
1358
  }
1306
1359
  visited.add(resolvedPath);
1307
1360
  const content = readIfExists(resolvedPath);
1361
+ if (inspectIslandExport) {
1362
+ const target = resolveDefaultReexport(resolvedPath, content, root);
1363
+ if (target) return inspectClientModuleMetadata(target, root, visited, true);
1364
+ }
1308
1365
  const parsed = parseClientModuleMetadata(content, inspectIslandExport);
1309
1366
  if (parsed.isClientComponent) {
1310
1367
  return {
@@ -1771,14 +1828,14 @@ function createFarmRouteRenderPlan(input = {}) {
1771
1828
  const layoutShouldHydrate = input.layoutShouldHydrate === true;
1772
1829
  const hydration = pageShouldHydrate ? layoutShouldHydrate ? "route-and-layout-islands" : "route-island" : layoutShouldHydrate ? "layout-island" : "none";
1773
1830
  const rendering = input.rendering;
1774
- const cache = rendering?.ssg ? typeof rendering.revalidate === "number" && rendering.revalidate > 0 ? { mode: "revalidate", revalidate: rendering.revalidate } : { mode: "static" } : { mode: "dynamic" };
1831
+ const cache2 = rendering?.ssg ? typeof rendering.revalidate === "number" && rendering.revalidate > 0 ? { mode: "revalidate", revalidate: rendering.revalidate } : { mode: "static" } : { mode: "dynamic" };
1775
1832
  return {
1776
1833
  version: 1,
1777
1834
  output: "html",
1778
1835
  navigation: "html-fragment",
1779
1836
  hydration,
1780
1837
  islandStrategy: hydration === "none" ? null : input.islandStrategy ?? "load",
1781
- cache
1838
+ cache: cache2
1782
1839
  };
1783
1840
  }
1784
1841
  __name(createFarmRouteRenderPlan, "createFarmRouteRenderPlan");
@@ -1886,6 +1943,10 @@ async function readAltText(filePath) {
1886
1943
  __name(readAltText, "readAltText");
1887
1944
 
1888
1945
  // src/routing/route-manager.ts
1946
+ function getRouteEntryDirectory(entry) {
1947
+ return entry.directory ?? entry.pattern;
1948
+ }
1949
+ __name(getRouteEntryDirectory, "getRouteEntryDirectory");
1889
1950
  function shouldSuggestStaticRenderingForI18n(i18n) {
1890
1951
  return !i18n || i18n.routing === "prefix-always" || i18n.routing === "prefix-except-default" && i18n.detection.every((signal) => signal === "url");
1891
1952
  }
@@ -1963,8 +2024,8 @@ var _RouteManager = class _RouteManager {
1963
2024
  )
1964
2025
  );
1965
2026
  this.orderedLayouts = Array.from(this.layouts.values()).sort(
1966
- (left, right) => left.route.segments.length - right.route.segments.length
1967
- );
2027
+ (left, right) => getRouteDirectoryDepth(left.pattern) - getRouteDirectoryDepth(right.pattern)
2028
+ ).map((entry) => ({ entry, groupScope: getRouteGroupScope(entry.pattern) }));
1968
2029
  for (const slot of this.routeSlots.values()) {
1969
2030
  if (!this.routeSlotOwnerSegments.has(slot.ownerPattern)) {
1970
2031
  this.routeSlotOwnerSegments.set(
@@ -1999,7 +2060,7 @@ var _RouteManager = class _RouteManager {
1999
2060
  break;
2000
2061
  }
2001
2062
  }
2002
- const layouts = this.findMatchingLayouts(normalizedPath, pathParts);
2063
+ const layouts = this.findMatchingLayouts(pathParts, matchedRoute);
2003
2064
  const slots = this.findMatchingRouteSlots(normalizedPath, pathParts, options.interceptFrom);
2004
2065
  return {
2005
2066
  route: matchedRoute,
@@ -2030,7 +2091,7 @@ var _RouteManager = class _RouteManager {
2030
2091
  throw new Error(`Cannot resolve runtime configuration for unknown route "${pattern}"`);
2031
2092
  }
2032
2093
  const inherited = resolveFarmRouteRuleRuntimeConfig(pattern, this.config.routeRules);
2033
- const layouts = this.findMatchingLayouts(pattern);
2094
+ const layouts = this.findMatchingLayouts(splitRoutePath(pattern), routeEntry);
2034
2095
  const layoutConfigs = [];
2035
2096
  for (const layout of layouts) {
2036
2097
  const layoutModule = await this.loadLayoutModule(layout.modulePath);
@@ -2097,16 +2158,19 @@ var _RouteManager = class _RouteManager {
2097
2158
  return null;
2098
2159
  }
2099
2160
  /**
2100
- * Return the nearest matching loading boundary for a pathname.
2161
+ * Return the nearest matching loading boundary for a pathname. Pass the page
2162
+ * `matchRoute` selected when it is known (`null` for none); otherwise the page is
2163
+ * matched only if a boundary inside a route group needs it.
2101
2164
  */
2102
- getMatchingLoading(pathname) {
2103
- return this.findNearestBoundary(this.toRoutePathname(pathname), this.loadings);
2165
+ getMatchingLoading(pathname, route) {
2166
+ return this.findNearestBoundary(this.toRoutePathname(pathname), this.loadings, route);
2104
2167
  }
2105
2168
  /**
2106
- * Return the nearest matching error boundary for a pathname.
2169
+ * Return the nearest matching error boundary for a pathname. `route` works as it
2170
+ * does for `getMatchingLoading`.
2107
2171
  */
2108
- getMatchingError(pathname) {
2109
- return this.findNearestBoundary(this.toRoutePathname(pathname), this.errors);
2172
+ getMatchingError(pathname, route) {
2173
+ return this.findNearestBoundary(this.toRoutePathname(pathname), this.errors, route);
2110
2174
  }
2111
2175
  matchMetadataImage(pathname) {
2112
2176
  const routePathname = this.toRoutePathname(pathname);
@@ -2274,15 +2338,15 @@ var _RouteManager = class _RouteManager {
2274
2338
  enforceFarmIsolatedHydrationRouteBudget(
2275
2339
  layoutEntries.map(({ entry, metadata }) => ({
2276
2340
  pattern: entry.pattern,
2277
- depth: entry.route.segments.length,
2341
+ depth: getRouteDirectoryDepth(entry.pattern),
2278
2342
  metadata
2279
2343
  })),
2280
2344
  routeEntries.map(({ entry, metadata }) => ({
2281
- pattern: entry.pattern,
2282
- depth: entry.route.segments.length,
2345
+ pattern: getRouteEntryDirectory(entry),
2346
+ depth: getRouteDirectoryDepth(getRouteEntryDirectory(entry)),
2283
2347
  metadata
2284
2348
  })),
2285
- (layoutPattern, routePattern) => layoutPattern === "/" || routePattern === layoutPattern || routePattern.startsWith(`${layoutPattern.replace(/\/$/, "")}/`)
2349
+ routeBoundaryCoversDirectory
2286
2350
  );
2287
2351
  for (const { entry, metadata } of [...layoutEntries, ...routeEntries]) {
2288
2352
  if (!metadata.costGuardExceeded) continue;
@@ -2301,10 +2365,11 @@ var _RouteManager = class _RouteManager {
2301
2365
  const routes = routeEntries.map(({ entry, metadata }) => {
2302
2366
  const programmaticPage = this.programmaticPages.get(entry.modulePath);
2303
2367
  const layoutShouldHydrate = layoutEntries.some(
2304
- ({ entry: layout, metadata: layoutMetadata }) => layoutMetadata.shouldHydrate && (layout.pattern === "/" || entry.pattern === layout.pattern || entry.pattern.startsWith(`${layout.pattern.replace(/\/$/, "")}/`))
2368
+ ({ entry: layout, metadata: layoutMetadata }) => layoutMetadata.shouldHydrate && routeBoundaryCoversDirectory(layout.pattern, getRouteEntryDirectory(entry))
2305
2369
  );
2306
2370
  return {
2307
2371
  pattern: entry.pattern,
2372
+ ...entry.directory ? { directory: entry.directory } : {},
2308
2373
  modulePath: toUrlPath(entry.modulePath),
2309
2374
  shouldHydrate: metadata.shouldHydrate,
2310
2375
  isClientComponent: metadata.isClientComponent,
@@ -2316,6 +2381,7 @@ var _RouteManager = class _RouteManager {
2316
2381
  modulePath: toUrlPath(boundary.modulePath)
2317
2382
  }))
2318
2383
  } : {},
2384
+ ...usesFarmServerTree(metadata) ? { serverTree: true } : {},
2319
2385
  renderPlan: createFarmRouteRenderPlan({
2320
2386
  pageShouldHydrate: metadata.shouldHydrate,
2321
2387
  layoutShouldHydrate,
@@ -2474,13 +2540,7 @@ var _RouteManager = class _RouteManager {
2474
2540
  */
2475
2541
  createRoutePattern(route) {
2476
2542
  if (route.segments.length === 0) return "/";
2477
- return "/" + route.segments.map((segment) => {
2478
- if (!segment.isDynamic) return segment.segment;
2479
- if (segment.isCatchAll) {
2480
- return segment.isOptional ? `[[...${segment.segment}]]` : `[...${segment.segment}]`;
2481
- }
2482
- return `[${segment.segment}]`;
2483
- }).join("/");
2543
+ return "/" + route.segments.map(formatRouteSegment).join("/");
2484
2544
  }
2485
2545
  registerPageRoute(entry) {
2486
2546
  assertUniqueRouteParameters(entry.pattern);
@@ -2561,6 +2621,7 @@ var _RouteManager = class _RouteManager {
2561
2621
  markdownSourcePath: path3.join(appDir, markdownFile)
2562
2622
  } : {},
2563
2623
  pattern,
2624
+ ...getPageDirectoryField(group.route, pattern),
2564
2625
  source: "file",
2565
2626
  sourceRoot: source.root
2566
2627
  });
@@ -2573,7 +2634,7 @@ var _RouteManager = class _RouteManager {
2573
2634
  for (const file of files) {
2574
2635
  const route = parseRoutePath(file);
2575
2636
  const modulePath = path3.join(appDir, file);
2576
- const pattern = this.createRoutePattern(route);
2637
+ const pattern = createRouteDirectoryPattern(route);
2577
2638
  const existing = target.get(pattern);
2578
2639
  if (existing?.sourceRoot === source.root) {
2579
2640
  throw new Error(
@@ -2595,6 +2656,7 @@ var _RouteManager = class _RouteManager {
2595
2656
  const modulePath = path3.join(appDir, file);
2596
2657
  const pattern = this.createRoutePattern(slot.route);
2597
2658
  const ownerPattern = this.createRoutePattern(slot.ownerRoute);
2659
+ const ownerDirectory = createRouteDirectoryPattern(slot.ownerRoute);
2598
2660
  const key = `${ownerPattern}:${slot.name}:${slot.interception ? "intercept" : "slot"}:${slot.fallback ? "default" : pattern}`;
2599
2661
  const existing = this.routeSlots.get(key);
2600
2662
  if (existing?.sourceRoot === source.root) {
@@ -2610,6 +2672,7 @@ var _RouteManager = class _RouteManager {
2610
2672
  sourceRoot: source.root,
2611
2673
  name: slot.name,
2612
2674
  ownerPattern,
2675
+ ...ownerDirectory === ownerPattern ? {} : { ownerDirectory },
2613
2676
  interception: slot.interception,
2614
2677
  fallback: slot.fallback,
2615
2678
  containerId: createRouteSlotContainerId(slot.name, ownerPattern)
@@ -2691,13 +2754,14 @@ var _RouteManager = class _RouteManager {
2691
2754
  route,
2692
2755
  modulePath,
2693
2756
  pattern,
2757
+ ...getPageDirectoryField(route, pattern),
2694
2758
  source: "programmatic",
2695
2759
  sourceRoot: source.root
2696
2760
  });
2697
2761
  }
2698
2762
  if (definition.kind === "layout") {
2699
2763
  const route = parseProgrammaticRoutePath(definition.path, "layout");
2700
- const pattern = this.createRoutePattern(route);
2764
+ const pattern = createRouteDirectoryPattern(route);
2701
2765
  const existing = this.layouts.get(pattern);
2702
2766
  if (existing?.sourceRoot === source.root) {
2703
2767
  throw new Error(
@@ -2737,17 +2801,26 @@ var _RouteManager = class _RouteManager {
2737
2801
  );
2738
2802
  }
2739
2803
  /**
2740
- * Find all layouts that should wrap a given path
2804
+ * Find all layouts that should wrap a given path. A layout inside a route group
2805
+ * wraps only the pages in that group, so it needs the selected page.
2741
2806
  */
2742
- findMatchingLayouts(pathname, pathnameParts = splitRoutePath(pathname)) {
2807
+ findMatchingLayouts(pathnameParts, route) {
2743
2808
  const matchingLayouts = [];
2744
- for (const layoutEntry of this.orderedLayouts) {
2745
- if (matchRoutePrefixParts(pathnameParts, layoutEntry.route.segments)) {
2746
- matchingLayouts.push(layoutEntry);
2809
+ for (const { entry, groupScope } of this.orderedLayouts) {
2810
+ if (!matchRoutePrefixParts(pathnameParts, entry.route.segments)) continue;
2811
+ if (groupScope !== null && !isInRouteGroupScope(route && getRouteEntryDirectory(route), groupScope)) {
2812
+ continue;
2747
2813
  }
2814
+ matchingLayouts.push(entry);
2748
2815
  }
2749
2816
  return matchingLayouts;
2750
2817
  }
2818
+ matchPageRoute(pathnameParts) {
2819
+ for (const routeEntry of this.routes.values()) {
2820
+ if (matchRouteParts(pathnameParts, routeEntry.route.segments).matches) return routeEntry;
2821
+ }
2822
+ return null;
2823
+ }
2751
2824
  findMatchingRouteSlots(pathname, pathnameParts, interceptFrom) {
2752
2825
  const groups = /* @__PURE__ */ new Map();
2753
2826
  for (const entry of this.routeSlots.values()) {
@@ -2777,6 +2850,7 @@ var _RouteManager = class _RouteManager {
2777
2850
  matches.push({
2778
2851
  name: selected.entry.name,
2779
2852
  ownerPattern: selected.entry.ownerPattern,
2853
+ ...selected.entry.ownerDirectory ? { ownerDirectory: selected.entry.ownerDirectory } : {},
2780
2854
  containerId: selected.entry.containerId,
2781
2855
  interception: selected.entry.interception,
2782
2856
  fallback: false,
@@ -2790,6 +2864,7 @@ var _RouteManager = class _RouteManager {
2790
2864
  matches.push({
2791
2865
  name: fallback.name,
2792
2866
  ownerPattern: fallback.ownerPattern,
2867
+ ...fallback.ownerDirectory ? { ownerDirectory: fallback.ownerDirectory } : {},
2793
2868
  containerId: fallback.containerId,
2794
2869
  interception: false,
2795
2870
  fallback: true,
@@ -2808,12 +2883,20 @@ var _RouteManager = class _RouteManager {
2808
2883
  const patternSegments = this.routeSlotOwnerSegments.get(pattern) ?? parseRoutePath(`${pattern}/page.tsx`).segments;
2809
2884
  return matchRoutePrefixParts(pathnameParts, patternSegments);
2810
2885
  }
2811
- findNearestBoundary(pathname, boundaries) {
2886
+ findNearestBoundary(pathname, boundaries, route) {
2812
2887
  const normalizedPath = pathname === "/" ? "/" : pathname.replace(/\/$/, "");
2813
2888
  let bestMatch = null;
2889
+ let page = route;
2814
2890
  for (const boundaryEntry of boundaries.values()) {
2815
2891
  if (!matchRoutePrefix(normalizedPath, boundaryEntry.route.segments)) continue;
2816
- if (!bestMatch || boundaryEntry.route.segments.length > bestMatch.route.segments.length) {
2892
+ const groupScope = getRouteGroupScope(boundaryEntry.pattern);
2893
+ if (groupScope !== null) {
2894
+ if (page === void 0) page = this.matchPageRoute(splitRoutePath(normalizedPath));
2895
+ if (!isInRouteGroupScope(page && getRouteEntryDirectory(page), groupScope)) continue;
2896
+ }
2897
+ const depth = boundaryEntry.route.segments.length;
2898
+ const bestDepth = bestMatch?.route.segments.length ?? -1;
2899
+ if (!bestMatch || depth > bestDepth || depth === bestDepth && getRouteDirectoryDepth(boundaryEntry.pattern) > getRouteDirectoryDepth(bestMatch.pattern)) {
2817
2900
  bestMatch = boundaryEntry;
2818
2901
  }
2819
2902
  }
@@ -2928,6 +3011,11 @@ var _RouteManager = class _RouteManager {
2928
3011
  };
2929
3012
  __name(_RouteManager, "RouteManager");
2930
3013
  var RouteManager = _RouteManager;
3014
+ function getPageDirectoryField(route, pattern) {
3015
+ const directory = createRouteDirectoryPattern(route);
3016
+ return directory === pattern ? {} : { directory };
3017
+ }
3018
+ __name(getPageDirectoryField, "getPageDirectoryField");
2931
3019
  function interpolateRedirectDestination(destination, params) {
2932
3020
  let result = destination;
2933
3021
  for (const [key, value] of Object.entries(params)) {
@@ -3045,112 +3133,6 @@ function collectDevStylesheetUrls(modules, alreadyLinked = ALREADY_LINKED) {
3045
3133
  }
3046
3134
  __name(collectDevStylesheetUrls, "collectDevStylesheetUrls");
3047
3135
 
3048
- // src/server/full-document.ts
3049
- var CONTENTS_WRAPPER = /^<div\b[^>]*style="display\s*:\s*contents"[^>]*>/i;
3050
- var HOISTED_HEAD_ELEMENT = /^(?:<(?:meta|link|base)\b[^>]*>|<title\b[^>]*>[\s\S]*?<\/title>|<script\b[^>]*\basync\b[^>]*><\/script>|<style\b[^>]*\bdata-precedence\b[^>]*>[\s\S]*?<\/style>)/i;
3051
- function peelDocumentPrefix(markup) {
3052
- let inner = markup.replace(/^\s+/, "");
3053
- let hoisted = "";
3054
- let match;
3055
- while (match = CONTENTS_WRAPPER.exec(inner) ?? HOISTED_HEAD_ELEMENT.exec(inner)) {
3056
- if (!/^<div/i.test(match[0])) hoisted += match[0];
3057
- inner = inner.slice(match[0].length).replace(/^\s+/, "");
3058
- }
3059
- return { inner, hoisted };
3060
- }
3061
- __name(peelDocumentPrefix, "peelDocumentPrefix");
3062
- function restoreHoistedHead(document, hoisted) {
3063
- if (!hoisted) return document;
3064
- if (/<head[\s>]/i.test(document)) {
3065
- return document.replace(/<head\b[^>]*>/i, (open) => open + hoisted);
3066
- }
3067
- return document.replace(/<html\b[^>]*>/i, (open) => `${open}<head>${hoisted}</head>`);
3068
- }
3069
- __name(restoreHoistedHead, "restoreHoistedHead");
3070
- function extractFarmFullDocument(markup) {
3071
- const { inner, hoisted } = peelDocumentPrefix(markup);
3072
- if (!/^<!doctype/i.test(inner) && !/^<html[\s>]/i.test(inner)) return null;
3073
- const start = markup.search(/<!doctype|<html[\s>]/i);
3074
- const lower = markup.toLowerCase();
3075
- let closeIndex = lower.lastIndexOf("</html>");
3076
- if (lower.length !== markup.length) {
3077
- closeIndex = -1;
3078
- const closing = /<\/html>/gi;
3079
- let match;
3080
- while (match = closing.exec(markup)) closeIndex = match.index;
3081
- }
3082
- if (start < 0 || closeIndex < 0) return null;
3083
- const closeEnd = closeIndex + "</html>".length;
3084
- let document = markup.slice(start, closeEnd);
3085
- const streamedTail = markup.slice(closeEnd).replace(/^(?:\s*<\/div>)+/i, "").trim();
3086
- if (streamedTail) {
3087
- document = document.replace(/<\/body>/i, () => `${streamedTail}</body>`);
3088
- }
3089
- return restoreHoistedHead(document, hoisted);
3090
- }
3091
- __name(extractFarmFullDocument, "extractFarmFullDocument");
3092
- function classifyFarmDocumentPrefix(markup) {
3093
- const { inner } = peelDocumentPrefix(markup);
3094
- if (/^<!doctype/i.test(inner) || /^<html[\s>]/i.test(inner)) return "document";
3095
- return inner === "" ? "pending" : "fragment";
3096
- }
3097
- __name(classifyFarmDocumentPrefix, "classifyFarmDocumentPrefix");
3098
- function ensureFarmDocumentHead(markup) {
3099
- if (/<head[\s>]/i.test(markup)) return markup;
3100
- return markup.replace(/<html([^>]*)>/i, (_match, attributes) => {
3101
- return `<html${attributes}><head></head>`;
3102
- });
3103
- }
3104
- __name(ensureFarmDocumentHead, "ensureFarmDocumentHead");
3105
- function ensureFarmDocumentRoot(markup) {
3106
- if (/\sid=["']root["']/i.test(markup)) return markup;
3107
- return markup.replace(
3108
- /<body\b([^>]*)>/i,
3109
- (_match, attributes) => `<body${attributes}><div id="root">`
3110
- ).replace(/<\/body>/i, () => "</div></body>");
3111
- }
3112
- __name(ensureFarmDocumentRoot, "ensureFarmDocumentRoot");
3113
- function hasFarmDocumentIcon(markup) {
3114
- return /<link\b[^>]*\brel=["']?(?:shortcut )?icon\b/i.test(markup);
3115
- }
3116
- __name(hasFarmDocumentIcon, "hasFarmDocumentIcon");
3117
- function removeFarmDocumentTitles(markup) {
3118
- return markup.replace(/<title\b[^>]*>[\s\S]*?<\/title>\s*/gi, "");
3119
- }
3120
- __name(removeFarmDocumentTitles, "removeFarmDocumentTitles");
3121
- function composeFarmFullDocument(documentHtml, assets) {
3122
- let html = ensureFarmDocumentHead(documentHtml);
3123
- if (assets.htmlAttributes) {
3124
- html = html.replace(/<html\b([^>]*)>/i, (_match, attrs) => {
3125
- let nextAttributes = attrs;
3126
- for (const name of assets.replaceHtmlAttributes ?? []) {
3127
- const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3128
- nextAttributes = nextAttributes.replace(
3129
- new RegExp("\\s+" + escapedName + `=(?:"[^"]*"|'[^']*'|[^\\s>]+)`, "gi"),
3130
- ""
3131
- );
3132
- }
3133
- return `<html${nextAttributes}${assets.htmlAttributes}>`;
3134
- });
3135
- }
3136
- html = ensureFarmDocumentRoot(html);
3137
- const headAssets = [
3138
- assets.fallbackIcon && !hasFarmDocumentIcon(html) ? '<link rel="icon" href="data:,">' : "",
3139
- assets.headAssets
3140
- ].filter(Boolean).join("\n ");
3141
- if (headAssets) {
3142
- html = html.replace(/<\/head>/i, () => ` ${headAssets}
3143
- </head>`);
3144
- }
3145
- if (assets.bodyFooter) {
3146
- html = html.replace(/<\/body>/i, () => ` ${assets.bodyFooter}
3147
- </body>`);
3148
- }
3149
- return /^\s*<!doctype/i.test(html) ? html : `<!DOCTYPE html>
3150
- ${html}`;
3151
- }
3152
- __name(composeFarmFullDocument, "composeFarmFullDocument");
3153
-
3154
3136
  // src/server/renderer.ts
3155
3137
  import { Readable, Writable } from "stream";
3156
3138
 
@@ -3784,15 +3766,15 @@ __name(readFontOptions, "readFontOptions");
3784
3766
  function evaluateStaticObject(code, id, node) {
3785
3767
  const result = {};
3786
3768
  const properties = Array.isArray(node.properties) ? node.properties : [];
3787
- for (const property of properties) {
3788
- if (!isAstNode(property) || property.type !== "Property" || property.computed === true) {
3769
+ for (const property2 of properties) {
3770
+ if (!isAstNode(property2) || property2.type !== "Property" || property2.computed === true) {
3789
3771
  throw fontError(id, "font options do not support spreads or computed properties");
3790
3772
  }
3791
- const key = readPropertyName(property.key);
3792
- if (!key || !isAstNode(property.value)) {
3773
+ const key = readPropertyName(property2.key);
3774
+ if (!key || !isAstNode(property2.value)) {
3793
3775
  throw fontError(id, "font options must use static property names and values");
3794
3776
  }
3795
- result[key] = evaluateStaticValue(code, id, property.value);
3777
+ result[key] = evaluateStaticValue(code, id, property2.value);
3796
3778
  }
3797
3779
  return result;
3798
3780
  }
@@ -4058,8 +4040,8 @@ function normalizePublicFontPath(source, moduleId) {
4058
4040
  }
4059
4041
  __name(normalizePublicFontPath, "normalizePublicFontPath");
4060
4042
  function isPathInside(parent, child) {
4061
- const relative3 = path6.relative(parent, child);
4062
- return relative3 === "" || !relative3.startsWith("..") && !path6.isAbsolute(relative3);
4043
+ const relative4 = path6.relative(parent, child);
4044
+ return relative4 === "" || !relative4.startsWith("..") && !path6.isAbsolute(relative4);
4063
4045
  }
4064
4046
  __name(isPathInside, "isPathInside");
4065
4047
  function normalizeBasePath(value) {
@@ -4513,8 +4495,8 @@ function redactErrorText(value) {
4513
4495
  }
4514
4496
  __name(redactErrorText, "redactErrorText");
4515
4497
  function isPathInsideRoot(root, filePath) {
4516
- const relative3 = path8.relative(root, filePath);
4517
- return relative3 === "" || !relative3.startsWith("..") && !path8.isAbsolute(relative3);
4498
+ const relative4 = path8.relative(root, filePath);
4499
+ return relative4 === "" || !relative4.startsWith("..") && !path8.isAbsolute(relative4);
4518
4500
  }
4519
4501
  __name(isPathInsideRoot, "isPathInsideRoot");
4520
4502
  function normalizeStackPath(value) {
@@ -4733,7 +4715,7 @@ __name(toMiddlewareMap, "toMiddlewareMap");
4733
4715
  function requestOwnHttpsServer(request2, address) {
4734
4716
  const url = new URL(request2.url);
4735
4717
  const hostname = url.hostname.replace(/^\[|\]$/g, "");
4736
- return new Promise((resolve5, reject) => {
4718
+ return new Promise((resolve6, reject) => {
4737
4719
  const outgoing = https.request(
4738
4720
  {
4739
4721
  host: address.host,
@@ -4755,7 +4737,7 @@ function requestOwnHttpsServer(request2, address) {
4755
4737
  const status = incoming.statusCode ?? 502;
4756
4738
  const hasBody = ![204, 205, 304].includes(status);
4757
4739
  if (!hasBody) incoming.resume();
4758
- resolve5(
4740
+ resolve6(
4759
4741
  new Response(hasBody ? Readable.toWeb(incoming) : null, {
4760
4742
  status,
4761
4743
  headers
@@ -4951,7 +4933,7 @@ var _ServerRenderer = class _ServerRenderer {
4951
4933
  const streaming = getFarmRendererStreamingCapabilitiesForRuntime(this.config.renderer, "node");
4952
4934
  const renderToPipeableStream = streaming.node ? this.rendererRuntime.renderToPipeableStream : void 0;
4953
4935
  if (renderToPipeableStream) {
4954
- return await new Promise((resolve5, reject) => {
4936
+ return await new Promise((resolve6, reject) => {
4955
4937
  const chunks = [];
4956
4938
  let started = false;
4957
4939
  const writable = new Writable({
@@ -4960,7 +4942,7 @@ var _ServerRenderer = class _ServerRenderer {
4960
4942
  callback();
4961
4943
  }
4962
4944
  });
4963
- writable.once("finish", () => resolve5(Buffer.concat(chunks).toString("utf8")));
4945
+ writable.once("finish", () => resolve6(Buffer.concat(chunks).toString("utf8")));
4964
4946
  writable.once("error", reject);
4965
4947
  const stream = renderToPipeableStream(element, {
4966
4948
  onShellReady() {
@@ -5019,7 +5001,7 @@ var _ServerRenderer = class _ServerRenderer {
5019
5001
  if (input.pageShouldHydrate && !input.layoutShouldHydrate) {
5020
5002
  element = this.wrapClientGraph(element);
5021
5003
  } else if (input.layoutShouldHydrate && !input.pageShouldHydrate && this.rendererRuntime.isolateServerPageGraph) {
5022
- element = this.rendererRuntime.isolateServerPageGraph(element);
5004
+ element = input.serverTree && this.rendererRuntime.renderServerTreePage ? await this.rendererRuntime.renderServerTreePage(element) : this.rendererRuntime.isolateServerPageGraph(element);
5023
5005
  }
5024
5006
  element = this.createPageBoundary(element, {
5025
5007
  pageShouldHydrate: input.pageShouldHydrate,
@@ -5036,7 +5018,9 @@ var _ServerRenderer = class _ServerRenderer {
5036
5018
  if (!LayoutComponent) continue;
5037
5019
  const slotProps = {};
5038
5020
  for (const slot of input.slots || []) {
5039
- if (slot.ownerPattern !== layout.pattern || !slot.module.default) continue;
5021
+ if ((slot.ownerDirectory ?? slot.ownerPattern) !== layout.pattern || !slot.module.default) {
5022
+ continue;
5023
+ }
5040
5024
  let slotElement = this.rendererRuntime.createElement(slot.module.default, slot.props);
5041
5025
  slotElement = this.wrapClientGraph(slotElement);
5042
5026
  slotProps[slot.name] = this.rendererRuntime.createElement(
@@ -5451,8 +5435,8 @@ var _ServerRenderer = class _ServerRenderer {
5451
5435
  route: route.pattern,
5452
5436
  params
5453
5437
  });
5454
- const loadingBoundaryEntry = this.routeManager.getMatchingLoading(pathname);
5455
- errorBoundaryEntry = this.routeManager.getMatchingError(pathname);
5438
+ const loadingBoundaryEntry = this.routeManager.getMatchingLoading(pathname, route);
5439
+ errorBoundaryEntry = this.routeManager.getMatchingError(pathname, route);
5456
5440
  middlewareMap = toMiddlewareMap(req.__FARM_MIDDLEWARE_DATA__);
5457
5441
  middlewareContext = toMiddlewareMap(req.__FARM_MIDDLEWARE_CONTEXT__);
5458
5442
  pluginExposedContext = getRequestContextSnapshot(req, {
@@ -5485,6 +5469,7 @@ var _ServerRenderer = class _ServerRenderer {
5485
5469
  const programmaticRouteComponents = routeModule.__farmRouteComponents;
5486
5470
  let PageComponent = routeModule.default;
5487
5471
  let pageProps;
5472
+ let routeStateRejected = false;
5488
5473
  try {
5489
5474
  pageProps = await parseRouteModuleProps(routeModule, {
5490
5475
  props: rawPageProps,
@@ -5493,6 +5478,7 @@ var _ServerRenderer = class _ServerRenderer {
5493
5478
  });
5494
5479
  } catch (error) {
5495
5480
  if (isFarmRedirectError(error)) throw error;
5481
+ routeStateRejected = true;
5496
5482
  const routeStateProps = {
5497
5483
  ...rawPageProps,
5498
5484
  search: searchParamsObject,
@@ -5571,6 +5557,9 @@ var _ServerRenderer = class _ServerRenderer {
5571
5557
  key: pprCacheKey
5572
5558
  });
5573
5559
  }
5560
+ const outerRequest = _resolveCurrentRequest();
5561
+ const countRequestReads = /* @__PURE__ */ __name(() => (outerRequest ? _getRequestReadCount(outerRequest) : 0) + _getRequestReadCount(currentRequest), "countRequestReads");
5562
+ const requestReadsBeforeRender = countRequestReads();
5574
5563
  let LoadingFallbackComponent = null;
5575
5564
  if (loadingBoundaryEntry) {
5576
5565
  const loadingModule = await this.routeManager.loadRouteModule(
@@ -5746,7 +5735,8 @@ var _ServerRenderer = class _ServerRenderer {
5746
5735
  layoutModules,
5747
5736
  routeModule,
5748
5737
  pageProps,
5749
- pathname
5738
+ pathname,
5739
+ skipGeneratedRouteMetadata: routeStateRejected
5750
5740
  });
5751
5741
  req.__FARM_METADATA__ = mergedMetadata;
5752
5742
  const middlewareDataForContext = middlewareMap;
@@ -5773,7 +5763,7 @@ var _ServerRenderer = class _ServerRenderer {
5773
5763
  if ((isClientComponent || shouldHydrate) && !shouldHydrateLayout) {
5774
5764
  pageElement = this.wrapClientGraph(pageElement);
5775
5765
  } else if (shouldHydrateLayout && !(isClientComponent || shouldHydrate) && this.rendererRuntime.isolateServerPageGraph) {
5776
- pageElement = this.rendererRuntime.isolateServerPageGraph(pageElement);
5766
+ pageElement = routeManifestEntry?.serverTree === true && this.rendererRuntime.renderServerTreePage ? await this.rendererRuntime.renderServerTreePage(pageElement) : this.rendererRuntime.isolateServerPageGraph(pageElement);
5777
5767
  }
5778
5768
  pageElement = this.createPageBoundary(pageElement, {
5779
5769
  pageShouldHydrate: isClientComponent || shouldHydrate,
@@ -5787,7 +5777,7 @@ var _ServerRenderer = class _ServerRenderer {
5787
5777
  const LayoutComponent = layoutModule.default;
5788
5778
  const slotProps = {};
5789
5779
  for (const slot of renderedRouteSlots) {
5790
- if (slot.ownerPattern !== layoutEntry.pattern) continue;
5780
+ if ((slot.ownerDirectory ?? slot.ownerPattern) !== layoutEntry.pattern) continue;
5791
5781
  let slotElement = this.rendererRuntime.createElement(
5792
5782
  slot.module.default,
5793
5783
  slot.props
@@ -5851,7 +5841,22 @@ var _ServerRenderer = class _ServerRenderer {
5851
5841
  type: "ppr.suspense.holeDetected",
5852
5842
  route: pathname
5853
5843
  }) : void 0,
5854
- onComplete: pprShellOptions && req.method !== "HEAD" ? (html) => this.cachePPRShell(pprShellOptions, html) : void 0
5844
+ onComplete: pprShellOptions && req.method !== "HEAD" ? (html) => {
5845
+ if (countRequestReads() !== requestReadsBeforeRender) {
5846
+ emitFarmEvent({
5847
+ type: "ppr.shell.bypass",
5848
+ route: pathname,
5849
+ reason: "request-read"
5850
+ });
5851
+ emitFarmEvent({
5852
+ type: "cache.bypass",
5853
+ route: pathname,
5854
+ reason: "request-read"
5855
+ });
5856
+ return;
5857
+ }
5858
+ return this.cachePPRShell(pprShellOptions, html);
5859
+ } : void 0
5855
5860
  }
5856
5861
  );
5857
5862
  if (pprRefreshRoute) {
@@ -6023,14 +6028,22 @@ var _ServerRenderer = class _ServerRenderer {
6023
6028
  })
6024
6029
  );
6025
6030
  }
6031
+ metadata = await mergeModuleViewport(metadata, layoutModule, {
6032
+ params: options.pageProps.params
6033
+ });
6026
6034
  }
6027
6035
  metadata = mergeMetadata(metadata, options.routeModule.metadata);
6028
- if (typeof options.routeModule.generateMetadata === "function") {
6036
+ if (!options.skipGeneratedRouteMetadata && typeof options.routeModule.generateMetadata === "function") {
6029
6037
  metadata = mergeMetadata(
6030
6038
  metadata,
6031
6039
  await options.routeModule.generateMetadata(options.pageProps)
6032
6040
  );
6033
6041
  }
6042
+ metadata = await mergeModuleViewport(
6043
+ metadata,
6044
+ options.skipGeneratedRouteMetadata ? { viewport: options.routeModule.viewport } : options.routeModule,
6045
+ options.pageProps
6046
+ );
6034
6047
  if (!metadata.manifest) {
6035
6048
  const manifestMatch = this.routeManager.getMatchingMetadataRoute(
6036
6049
  options.pathname,
@@ -6248,7 +6261,20 @@ var _ServerRenderer = class _ServerRenderer {
6248
6261
  });
6249
6262
  return {
6250
6263
  pages,
6251
- defaults: createFarmDefaultLlmsTxt({ origin, pages, config, rootMetadata }),
6264
+ defaults: createFarmDefaultLlmsTxt({
6265
+ origin,
6266
+ pages,
6267
+ config,
6268
+ rootMetadata,
6269
+ mcp: this.config.agent?.aiCatalog === false ? [] : listFarmMCPLlmsTxtLinks(origin, {
6270
+ basePath: this.config.basePath,
6271
+ apiServerBasePath: resolveFarmAPIServerBasePath(
6272
+ normalizeFarmAPIConfig(
6273
+ this.config.api
6274
+ )
6275
+ )
6276
+ })
6277
+ }),
6252
6278
  ...options.full ? { markdown: this.createDevMarkdownReader(options.req) } : {}
6253
6279
  };
6254
6280
  }
@@ -6510,7 +6536,8 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6510
6536
  title,
6511
6537
  tags: metaTags,
6512
6538
  hasFavicon,
6513
- hasExplicitTitle
6539
+ hasExplicitTitle,
6540
+ viewport: viewportTags
6514
6541
  } = renderMetadataHead(req.__FARM_METADATA__, {
6515
6542
  pathname: getFarmMetadataPathname(req),
6516
6543
  jsonLd: this.config.agent?.jsonLd
@@ -6536,6 +6563,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6536
6563
  const effectiveRendererHead = hasExplicitTitle ? removeFarmDocumentTitles(rendererHead) : rendererHead;
6537
6564
  html = composeFarmFullDocument(documentHtml, {
6538
6565
  fallbackIcon: !hasFavicon,
6566
+ viewport: viewportTags,
6539
6567
  htmlAttributes: `${i18nSnapshot ? ` lang="${escapeHtmlAttribute2(i18nSnapshot.locale)}" dir="${escapeHtmlAttribute2(i18nSnapshot.direction)}"` : ""}${themeDocument.attributes}`,
6540
6568
  replaceHtmlAttributes: [
6541
6569
  ...i18nSnapshot ? ["lang", "dir"] : [],
@@ -6563,7 +6591,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6563
6591
  <head>
6564
6592
  ${themeDocument.head}
6565
6593
  <meta charset="utf-8">
6566
- <meta name="viewport" content="width=device-width, initial-scale=1">
6594
+ ${viewportTags}
6567
6595
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">
6568
6596
  ${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
6569
6597
  ${documentTitleTag}${metaTags}${alternateTags}${rendererHead ? `
@@ -6642,7 +6670,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6642
6670
  if (!renderToPipeableStream || fullDocumentRoutes.has(fullDocumentRouteKey) || await this.rootLayoutRendersDocument()) {
6643
6671
  return this.renderBufferedSSR(element, req, res, clearMiddlewareData, options);
6644
6672
  }
6645
- return new Promise((resolve5, reject) => {
6673
+ return new Promise((resolve6, reject) => {
6646
6674
  const streamStartTime = Date.now();
6647
6675
  const observabilityRoute = options.observabilityRoute || req.__FARM_ROUTE__ || req.url || "/";
6648
6676
  const deploymentId = this.getDeploymentId();
@@ -6748,7 +6776,8 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6748
6776
  const {
6749
6777
  title,
6750
6778
  tags: metaTags,
6751
- hasFavicon
6779
+ hasFavicon,
6780
+ viewport: viewportTags
6752
6781
  } = renderMetadataHead(req.__FARM_METADATA__, {
6753
6782
  pathname: getFarmMetadataPathname(req),
6754
6783
  jsonLd: this.config.agent?.jsonLd
@@ -6797,7 +6826,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6797
6826
  <head>
6798
6827
  ${themeDocument.head}
6799
6828
  <meta charset="utf-8">
6800
- <meta name="viewport" content="width=device-width, initial-scale=1">
6829
+ ${viewportTags}
6801
6830
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(deploymentId)}">
6802
6831
  ${hasFavicon ? "" : '<link rel="icon" href="data:,">'}
6803
6832
  <title>${title}</title>${metaTags}${i18nAlternateTags}
@@ -6922,7 +6951,7 @@ window.__FARM_I18N__ = ${getFarmI18nClientSnapshot() ? serializeInlineValue(getF
6922
6951
  route: observabilityRoute,
6923
6952
  durationMs: Date.now() - streamStartTime
6924
6953
  });
6925
- resolve5();
6954
+ resolve6();
6926
6955
  }, "finishStream");
6927
6956
  res.write(securedShell);
6928
6957
  if (typeof res.flush === "function") {
@@ -7172,12 +7201,14 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};`
7172
7201
  getTheme()
7173
7202
  );
7174
7203
  const rendererHydrationScript = this.rendererRuntime.generateHydrationScript?.() || "";
7204
+ const viewportTags = renderViewportHead(alternates.metadata?.viewport);
7175
7205
  const fullDocument = extractFarmFullDocument(content);
7176
7206
  if (fullDocument) {
7177
7207
  return composeFarmFullDocument(
7178
7208
  metadataHead ? removeFarmDocumentTitles(fullDocument) : fullDocument,
7179
7209
  {
7180
7210
  fallbackIcon: !metadataHead,
7211
+ viewport: viewportTags,
7181
7212
  htmlAttributes: `${i18nSnapshot ? ` lang="${escapeHtmlAttribute2(i18nSnapshot.locale)}" dir="${escapeHtmlAttribute2(i18nSnapshot.direction)}"` : ""}${themeDocument.attributes}`,
7182
7213
  replaceHtmlAttributes: [
7183
7214
  ...i18nSnapshot ? ["lang", "dir"] : [],
@@ -7204,7 +7235,7 @@ ${i18nSnapshot ? `window.__FARM_I18N__ = ${serializeInlineValue(i18nSnapshot)};`
7204
7235
  <head>
7205
7236
  ${themeDocument.head}
7206
7237
  <meta charset="utf-8">
7207
- <meta name="viewport" content="width=device-width, initial-scale=1">
7238
+ ${viewportTags}
7208
7239
  <meta name="farm-deployment-id" content="${escapeHtmlAttribute2(this.getDeploymentId())}">
7209
7240
  ${metadataHead ?? '<link rel="icon" href="data:,">\n <title>Farm.js App</title>'}${alternateLinks}
7210
7241
  ${fontHead}
@@ -7470,9 +7501,9 @@ __name(isVitePluginHook, "isVitePluginHook");
7470
7501
  function withVite5TransformContext(handler) {
7471
7502
  return function(...args) {
7472
7503
  const context = new Proxy(this, {
7473
- get(target, property, receiver) {
7474
- if (property === "environment") return void 0;
7475
- return Reflect.get(target, property, receiver);
7504
+ get(target, property2, receiver) {
7505
+ if (property2 === "environment") return void 0;
7506
+ return Reflect.get(target, property2, receiver);
7476
7507
  }
7477
7508
  });
7478
7509
  return handler.apply(context, args);
@@ -7632,8 +7663,8 @@ __name(validateSchemaSteps, "validateSchemaSteps");
7632
7663
  var _FarmPluginOptionsError = class _FarmPluginOptionsError extends TypeError {
7633
7664
  constructor(issues) {
7634
7665
  const lines = issues.map((issue) => {
7635
- const path18 = formatIssuePath(issue.path);
7636
- return ` - ${path18 ? `${path18}: ` : ""}${issue.message}`;
7666
+ const path22 = formatIssuePath(issue.path);
7667
+ return ` - ${path22 ? `${path22}: ` : ""}${issue.message}`;
7637
7668
  });
7638
7669
  super(`Invalid plugin options:
7639
7670
  ${lines.join("\n")}`);
@@ -7643,9 +7674,9 @@ ${lines.join("\n")}`);
7643
7674
  };
7644
7675
  __name(_FarmPluginOptionsError, "FarmPluginOptionsError");
7645
7676
  var FarmPluginOptionsError = _FarmPluginOptionsError;
7646
- function formatIssuePath(path18) {
7647
- if (!path18?.length) return "";
7648
- return path18.map((segment) => {
7677
+ function formatIssuePath(path22) {
7678
+ if (!path22?.length) return "";
7679
+ return path22.map((segment) => {
7649
7680
  const key = typeof segment === "object" && segment !== null ? segment.key : segment;
7650
7681
  return typeof key === "symbol" ? key.toString() : String(key);
7651
7682
  }).join(".");
@@ -7881,23 +7912,23 @@ var _PluginManager = class _PluginManager {
7881
7912
  `Farm plugin "${plugin.name}" runtime.endpoints must contain endpoint objects`
7882
7913
  );
7883
7914
  }
7884
- const path18 = normalizeFarmPluginRuntimeEndpointPath(
7915
+ const path22 = normalizeFarmPluginRuntimeEndpointPath(
7885
7916
  endpoint.path,
7886
7917
  `Farm plugin "${plugin.name}" runtime endpoint`
7887
7918
  );
7888
7919
  if (typeof endpoint.handler !== "function") {
7889
7920
  throw new TypeError(
7890
- `Farm plugin "${plugin.name}" runtime endpoint ${path18} requires a handler`
7921
+ `Farm plugin "${plugin.name}" runtime endpoint ${path22} requires a handler`
7891
7922
  );
7892
7923
  }
7893
- const owner = owners.get(path18);
7924
+ const owner = owners.get(path22);
7894
7925
  if (owner) {
7895
7926
  throw new Error(
7896
- `Farm plugin runtime endpoint ${path18} from "${plugin.name}" conflicts with "${owner}"`
7927
+ `Farm plugin runtime endpoint ${path22} from "${plugin.name}" conflicts with "${owner}"`
7897
7928
  );
7898
7929
  }
7899
- owners.set(path18, plugin.name);
7900
- endpoints.push({ plugin, endpoint, path: path18 });
7930
+ owners.set(path22, plugin.name);
7931
+ endpoints.push({ plugin, endpoint, path: path22 });
7901
7932
  }
7902
7933
  }
7903
7934
  this.runtimeEndpoints = endpoints;
@@ -8870,8 +8901,8 @@ __name(isArrayIndex, "isArrayIndex");
8870
8901
  import fs7 from "fs";
8871
8902
  import path13 from "path";
8872
8903
  var ADAPTER_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "mjs"];
8873
- function resolveFarmClientCacheAdapterEntry(root, cache) {
8874
- const client = cache?.client;
8904
+ function resolveFarmClientCacheAdapterEntry(root, cache2) {
8905
+ const client = cache2?.client;
8875
8906
  const adapter = client?.adapter;
8876
8907
  if (adapter === void 0) return void 0;
8877
8908
  if (typeof adapter !== "string" || adapter.trim().length === 0) {
@@ -8913,6 +8944,233 @@ function generateClientCachePersistenceCode(entry) {
8913
8944
  }
8914
8945
  __name(generateClientCachePersistenceCode, "generateClientCachePersistenceCode");
8915
8946
 
8947
+ // src/app-manifest-packages.ts
8948
+ import fs8 from "fs";
8949
+ import path14 from "path";
8950
+ var FARM_PACKAGE = /^@(?:farm\.js|farming-labs)\/[a-z0-9._-]+$/;
8951
+ function resolveFarmAppPackages(root) {
8952
+ let manifest;
8953
+ try {
8954
+ manifest = JSON.parse(fs8.readFileSync(path14.join(root, "package.json"), "utf8"));
8955
+ } catch {
8956
+ return {};
8957
+ }
8958
+ const names = new Set(
8959
+ [
8960
+ ...Object.keys(manifest.dependencies ?? {}),
8961
+ ...Object.keys(manifest.devDependencies ?? {})
8962
+ ].filter((name) => FARM_PACKAGE.test(name))
8963
+ );
8964
+ const versions = {};
8965
+ for (const name of [...names].sort()) {
8966
+ for (let dir = root; ; ) {
8967
+ try {
8968
+ const { version } = JSON.parse(
8969
+ fs8.readFileSync(path14.join(dir, "node_modules", name, "package.json"), "utf8")
8970
+ );
8971
+ if (typeof version === "string" && /^[0-9A-Za-z.+-]{1,64}$/.test(version))
8972
+ versions[name] = version;
8973
+ break;
8974
+ } catch {
8975
+ const parent = path14.dirname(dir);
8976
+ if (parent === dir) break;
8977
+ dir = parent;
8978
+ }
8979
+ }
8980
+ }
8981
+ return versions;
8982
+ }
8983
+ __name(resolveFarmAppPackages, "resolveFarmAppPackages");
8984
+
8985
+ // src/app-manifest-webmcp.ts
8986
+ import fs9 from "fs";
8987
+ import { createRequire as createRequire2 } from "module";
8988
+ import path15 from "path";
8989
+ import fg from "fast-glob";
8990
+ var WEBMCP_CLIENT = "@farm.js/webmcp/client";
8991
+ var DEFINERS = /* @__PURE__ */ new Set(["defineWebMCPTool", "registerWebMCPTool", "registerWebMCPTools"]);
8992
+ var HINTS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
8993
+ var MAX_TOOLS = 500;
8994
+ var MAX_SCHEMA_BYTES = 64 * 1024;
8995
+ var NOT_STATIC = /* @__PURE__ */ Symbol("not static");
8996
+ var LANGS = {
8997
+ ts: "ts",
8998
+ mts: "ts",
8999
+ cts: "ts",
9000
+ tsx: "tsx",
9001
+ js: "jsx",
9002
+ mjs: "jsx",
9003
+ cjs: "jsx",
9004
+ jsx: "jsx"
9005
+ };
9006
+ var parseAst;
9007
+ function staticValue(node) {
9008
+ if (!node) return NOT_STATIC;
9009
+ switch (node.type) {
9010
+ case "Literal":
9011
+ return node.regex || typeof node.value === "bigint" ? NOT_STATIC : node.value;
9012
+ case "TemplateLiteral":
9013
+ return node.expressions.length ? NOT_STATIC : node.quasis[0].value.cooked;
9014
+ case "UnaryExpression":
9015
+ if (node.operator === "-" && node.argument.type === "Literal" && typeof node.argument.value === "number")
9016
+ return -node.argument.value;
9017
+ return NOT_STATIC;
9018
+ case "ArrayExpression": {
9019
+ const items = [];
9020
+ for (const element of node.elements) {
9021
+ const value = staticValue(element);
9022
+ if (value === NOT_STATIC) return NOT_STATIC;
9023
+ items.push(value);
9024
+ }
9025
+ return items;
9026
+ }
9027
+ case "ObjectExpression": {
9028
+ const object = {};
9029
+ for (const property2 of node.properties) {
9030
+ if (property2.type !== "Property" || property2.computed || property2.kind !== "init")
9031
+ return NOT_STATIC;
9032
+ const key = property2.key.type === "Identifier" ? property2.key.name : staticValue(property2.key);
9033
+ if (typeof key !== "string" || key === "__proto__") return NOT_STATIC;
9034
+ const value = staticValue(property2.value);
9035
+ if (value === NOT_STATIC) return NOT_STATIC;
9036
+ object[key] = value;
9037
+ }
9038
+ return object;
9039
+ }
9040
+ case "TSAsExpression":
9041
+ case "TSSatisfiesExpression":
9042
+ case "TSNonNullExpression":
9043
+ case "ParenthesizedExpression":
9044
+ return staticValue(node.expression);
9045
+ default:
9046
+ return NOT_STATIC;
9047
+ }
9048
+ }
9049
+ __name(staticValue, "staticValue");
9050
+ function property(object, name) {
9051
+ return object.properties.find(
9052
+ (entry) => entry.type === "Property" && !entry.computed && (entry.key.name === name || entry.key.value === name)
9053
+ )?.value;
9054
+ }
9055
+ __name(property, "property");
9056
+ function toolFromObject(object) {
9057
+ const name = staticValue(property(object, "name"));
9058
+ if (typeof name !== "string" || !/^[A-Za-z0-9_.-]{1,128}$/.test(name)) return null;
9059
+ const text = /* @__PURE__ */ __name((key) => {
9060
+ const value = staticValue(property(object, key));
9061
+ return typeof value === "string" && value.length <= 2e3 ? value : void 0;
9062
+ }, "text");
9063
+ const annotations = staticValue(property(object, "annotations"));
9064
+ const hints = annotations && typeof annotations === "object" && !Array.isArray(annotations) ? Object.fromEntries(
9065
+ HINTS.filter(
9066
+ (hint) => typeof annotations[hint] === "boolean"
9067
+ ).map((hint) => [hint, annotations[hint]])
9068
+ ) : {};
9069
+ const schemaNode = property(object, "inputSchema");
9070
+ const schema = staticValue(schemaNode);
9071
+ const literal = schema !== NOT_STATIC && schema !== null && typeof schema === "object" && !Array.isArray(schema) && Buffer.byteLength(JSON.stringify(schema)) <= MAX_SCHEMA_BYTES;
9072
+ const title = text("title");
9073
+ const description = text("description");
9074
+ return {
9075
+ name,
9076
+ ...title ? { title } : {},
9077
+ ...description ? { description } : {},
9078
+ ...hints,
9079
+ ...literal ? { inputSchema: schema } : {},
9080
+ inputSchemaSource: literal ? "literal" : schemaNode ? "computed" : "none"
9081
+ };
9082
+ }
9083
+ __name(toolFromObject, "toolFromObject");
9084
+ function findFarmWebMCPTools(code, filename = "module.tsx") {
9085
+ if (!code.includes(WEBMCP_CLIENT)) return [];
9086
+ const lang = LANGS[path15.extname(filename).slice(1)] ?? "tsx";
9087
+ parseAst ?? (parseAst = createRequire2(typeof __filename === "string" ? __filename : import.meta.url)(
9088
+ "rolldown/parseAst"
9089
+ ).parseAst);
9090
+ let program;
9091
+ try {
9092
+ program = parseAst(code, { lang });
9093
+ } catch {
9094
+ return [];
9095
+ }
9096
+ const locals = /* @__PURE__ */ new Map();
9097
+ for (const statement of program.body) {
9098
+ if (statement.type !== "ImportDeclaration" || statement.source.value !== WEBMCP_CLIENT)
9099
+ continue;
9100
+ for (const specifier of statement.specifiers) {
9101
+ const imported = specifier.imported?.name ?? specifier.imported?.value;
9102
+ if (specifier.type === "ImportSpecifier" && DEFINERS.has(imported))
9103
+ locals.set(specifier.local.name, imported);
9104
+ }
9105
+ }
9106
+ if (!locals.size) return [];
9107
+ const found = [];
9108
+ const visit = /* @__PURE__ */ __name((node) => {
9109
+ if (!node || typeof node !== "object") return;
9110
+ if (Array.isArray(node)) return node.forEach(visit);
9111
+ const current = node;
9112
+ if (current.type === "CallExpression" && current.callee.type === "Identifier") {
9113
+ const definer = locals.get(current.callee.name);
9114
+ const [argument] = current.arguments;
9115
+ if (definer && argument) {
9116
+ const objects = definer === "registerWebMCPTools" ? argument.type === "ArrayExpression" ? argument.elements.filter(
9117
+ (element) => element?.type === "ObjectExpression"
9118
+ ) : [] : argument.type === "ObjectExpression" ? [argument] : [];
9119
+ for (const object of objects) {
9120
+ const tool = toolFromObject(object);
9121
+ if (tool) found.push({ start: object.start, tool });
9122
+ }
9123
+ }
9124
+ }
9125
+ for (const [key, value] of Object.entries(current))
9126
+ if (key !== "type" && value && typeof value === "object") visit(value);
9127
+ }, "visit");
9128
+ visit(program.body);
9129
+ return found.sort((a, b) => a.start - b.start).map(({ tool }) => tool);
9130
+ }
9131
+ __name(findFarmWebMCPTools, "findFarmWebMCPTools");
9132
+ var cache = /* @__PURE__ */ new Map();
9133
+ function collectFarmWebMCPTools(root, srcDir = "src") {
9134
+ const base = path15.resolve(root, srcDir);
9135
+ let files;
9136
+ try {
9137
+ files = fg.sync("**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}", {
9138
+ cwd: base,
9139
+ absolute: true,
9140
+ ignore: ["**/node_modules/**", "**/*.d.ts", "**/*.{test,spec}.*", "**/__tests__/**"]
9141
+ });
9142
+ } catch {
9143
+ return [];
9144
+ }
9145
+ const seen = /* @__PURE__ */ new Set();
9146
+ const tools = [];
9147
+ for (const file of files.sort()) {
9148
+ let mtimeMs;
9149
+ try {
9150
+ mtimeMs = fs9.statSync(file).mtimeMs;
9151
+ } catch {
9152
+ continue;
9153
+ }
9154
+ let entry = cache.get(file);
9155
+ if (!entry || entry.mtimeMs !== mtimeMs) {
9156
+ let code = "";
9157
+ try {
9158
+ code = fs9.readFileSync(file, "utf8");
9159
+ } catch {
9160
+ }
9161
+ entry = { mtimeMs, tools: findFarmWebMCPTools(code, file) };
9162
+ cache.set(file, entry);
9163
+ }
9164
+ for (const tool of entry.tools) {
9165
+ if (seen.has(tool.name) || tools.length >= MAX_TOOLS) continue;
9166
+ seen.add(tool.name);
9167
+ tools.push(tool);
9168
+ }
9169
+ }
9170
+ return tools;
9171
+ }
9172
+ __name(collectFarmWebMCPTools, "collectFarmWebMCPTools");
9173
+
8916
9174
  // src/document-layout-client.ts
8917
9175
  var FARM_LAYOUT_ELEMENT_CLIENT_SOURCE = String.raw`
8918
9176
  const farmLayoutComponentKeys = new WeakMap();
@@ -8979,14 +9237,136 @@ function createFarmLayoutElement(Component, pattern, children, params) {
8979
9237
  }
8980
9238
  `;
8981
9239
 
9240
+ // src/dev-preview-guard.ts
9241
+ import { promises as fsp } from "fs";
9242
+ import * as path16 from "path";
9243
+ var FARM_PREVIEW_REQUEST_HEADER = "x-farm-preview";
9244
+ function isFarmPreviewTunnelRequest(headers) {
9245
+ return headers[FARM_PREVIEW_REQUEST_HEADER] !== void 0;
9246
+ }
9247
+ __name(isFarmPreviewTunnelRequest, "isFarmPreviewTunnelRequest");
9248
+ var VITE_DEFAULT_FS_DENY = [
9249
+ ".env",
9250
+ ".env.*",
9251
+ "*.{crt,pem,key,p12,pfx,cer,der}",
9252
+ ".npmrc",
9253
+ ".yarnrc.yml",
9254
+ "**/.git/**"
9255
+ ];
9256
+ function getFarmDevFsDeny(userDeny, options) {
9257
+ const deny = ["**/.farm/**"];
9258
+ const root = path16.resolve(options.root || process.cwd());
9259
+ const distDir = options.distDir ? path16.resolve(root, options.distDir) : void 0;
9260
+ const relativeDistDir = distDir ? path16.relative(root, distDir) : "";
9261
+ if (distDir && relativeDistDir && relativeDistDir !== ".farm" && relativeDistDir !== ".." && !relativeDistDir.startsWith(`..${path16.sep}`) && !/[*?[\]{}()!+@]/.test(distDir)) {
9262
+ deny.push(`${distDir.replace(/\\/g, "/")}/**`);
9263
+ }
9264
+ return userDeny ? deny : [...VITE_DEFAULT_FS_DENY, ...deny];
9265
+ }
9266
+ __name(getFarmDevFsDeny, "getFarmDevFsDeny");
9267
+ var SOURCE_QUERY_FLAGS = ["raw", "inline", "url"];
9268
+ var MODULE_EXTENSION = /\.(?:[cm]?[jt]sx?|vue|svelte|astro|mdx?|css|scss|sass|less|styl|stylus|pcss|postcss|sss)$/i;
9269
+ var ASSET_EXTENSION = /\.(?:apng|bmp|png|jpe?g|jfif|pjpeg|pjp|gif|svg|ico|webp|avif|cur|jxl|mp4|webm|ogg|mp3|wav|flac|aac|opus|mov|m4a|vtt|woff2?|eot|ttf|otf|webmanifest|pdf|txt|wasm)$/i;
9270
+ var INTERNAL_PREFIXES = ["/@vite/", "/@farm/", "/@react-refresh", "/__vite_ping"];
9271
+ var DEVELOPER_ONLY_PREFIXES = ["/__farm/devtools", "/__open-in-editor"];
9272
+ function createFarmDevPreviewGuard(server, options) {
9273
+ return /* @__PURE__ */ __name(async function farmDevPreviewGuard(req, res, next) {
9274
+ if (!isFarmPreviewTunnelRequest(req.headers)) return next();
9275
+ try {
9276
+ if (await isAllowedPreviewRequest(server, options, req)) return next();
9277
+ } catch {
9278
+ }
9279
+ res.statusCode = 403;
9280
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
9281
+ res.setHeader("Cache-Control", "no-store");
9282
+ res.end("This development file is not available through farm preview.");
9283
+ }, "farmDevPreviewGuard");
9284
+ }
9285
+ __name(createFarmDevPreviewGuard, "createFarmDevPreviewGuard");
9286
+ async function isAllowedPreviewRequest(server, options, req) {
9287
+ const rawUrl = req.url || "/";
9288
+ const queryIndex = rawUrl.indexOf("?");
9289
+ const rawPath = queryIndex === -1 ? rawUrl : rawUrl.slice(0, queryIndex);
9290
+ const query = new URLSearchParams(queryIndex === -1 ? "" : rawUrl.slice(queryIndex + 1));
9291
+ let pathname = decodeURI(rawPath);
9292
+ const base = (server.config.base || "/").replace(/\/$/, "");
9293
+ if (base.startsWith("/") && (pathname === base || pathname.startsWith(`${base}/`))) {
9294
+ pathname = pathname.slice(base.length) || "/";
9295
+ }
9296
+ const url = `${pathname}${queryIndex === -1 ? "" : rawUrl.slice(queryIndex)}`;
9297
+ if (DEVELOPER_ONLY_PREFIXES.some((prefix) => pathname.startsWith(prefix))) return false;
9298
+ if (INTERNAL_PREFIXES.some((prefix) => pathname.startsWith(prefix))) return true;
9299
+ const method = (req.method || "GET").toUpperCase();
9300
+ if (method !== "GET" && method !== "HEAD") return true;
9301
+ const file = await resolveRequestedFile(server, pathname);
9302
+ if (!file) return true;
9303
+ const client = server.environments?.client;
9304
+ const inClientGraph = /* @__PURE__ */ __name(async () => Boolean(await client?.moduleGraph.getModuleByUrl(url)), "inClientGraph");
9305
+ if (SOURCE_QUERY_FLAGS.some((flag) => query.has(flag))) return inClientGraph();
9306
+ if (await inClientGraph()) return true;
9307
+ if (file.split(path16.sep).includes("node_modules")) return true;
9308
+ if (server.config.publicDir && isInside(await realpathOr(server.config.publicDir), file)) {
9309
+ return true;
9310
+ }
9311
+ const isModuleOrAsset = MODULE_EXTENSION.test(file) || ASSET_EXTENSION.test(file) || query.has("import");
9312
+ if (!isModuleOrAsset) return false;
9313
+ for (const source of options.getSourceRoots()) {
9314
+ const sourceRoot = await realpathOr(source.root);
9315
+ const sourceDir = await realpathOr(path16.resolve(source.root, source.srcDir));
9316
+ if (sourceRoot === sourceDir && path16.dirname(file) === sourceDir) continue;
9317
+ if (isInside(sourceDir, file)) return true;
9318
+ }
9319
+ return false;
9320
+ }
9321
+ __name(isAllowedPreviewRequest, "isAllowedPreviewRequest");
9322
+ async function resolveRequestedFile(server, pathname) {
9323
+ let candidate;
9324
+ if (pathname.startsWith("/@fs/")) {
9325
+ candidate = pathname.slice("/@fs".length);
9326
+ if (/^\/[A-Za-z]:/.test(candidate)) candidate = candidate.slice(1);
9327
+ } else {
9328
+ let id = pathname;
9329
+ if (id.startsWith("/@id/")) {
9330
+ id = id.slice("/@id/".length).replace(/^__x00__/, "\0");
9331
+ if (id.startsWith("\0")) return void 0;
9332
+ }
9333
+ const resolved = await server.environments?.client?.pluginContainer.resolveId(id, void 0);
9334
+ const resolvedId = resolved?.id.replace(/[?#].*$/, "");
9335
+ if (resolvedId && path16.isAbsolute(resolvedId)) candidate = resolvedId;
9336
+ else if (resolvedId?.startsWith("\0")) return void 0;
9337
+ else if (id.startsWith("/")) candidate = path16.join(server.config.root, id);
9338
+ }
9339
+ if (!candidate) return void 0;
9340
+ try {
9341
+ const real = await fsp.realpath(candidate);
9342
+ return (await fsp.stat(real)).isFile() ? real : void 0;
9343
+ } catch {
9344
+ return void 0;
9345
+ }
9346
+ }
9347
+ __name(resolveRequestedFile, "resolveRequestedFile");
9348
+ async function realpathOr(directory) {
9349
+ try {
9350
+ return await fsp.realpath(directory);
9351
+ } catch {
9352
+ return path16.resolve(directory);
9353
+ }
9354
+ }
9355
+ __name(realpathOr, "realpathOr");
9356
+ function isInside(directory, file) {
9357
+ const relative4 = path16.relative(directory, file);
9358
+ return relative4 !== "" && relative4 !== ".." && !relative4.startsWith(`..${path16.sep}`) && !path16.isAbsolute(relative4);
9359
+ }
9360
+ __name(isInside, "isInside");
9361
+
8982
9362
  // src/vite.ts
8983
- import * as fs9 from "fs";
8984
- import * as path17 from "path";
9363
+ import * as fs11 from "fs";
9364
+ import * as path21 from "path";
8985
9365
  import { pathToFileURL as pathToFileURL3 } from "url";
8986
9366
 
8987
9367
  // src/dev-static.ts
8988
- import * as fs8 from "fs";
8989
- import * as path14 from "path";
9368
+ import * as fs10 from "fs";
9369
+ import * as path17 from "path";
8990
9370
  function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs, generatedPaths = []) {
8991
9371
  if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
8992
9372
  const matchesAppRoute = Boolean(
@@ -9033,11 +9413,11 @@ function devServableFileExists(pathname, baseDirs) {
9033
9413
  if (!relativePathname) return false;
9034
9414
  for (const baseDir of baseDirs) {
9035
9415
  if (typeof baseDir !== "string" || baseDir.length === 0) continue;
9036
- const resolvedBase = path14.resolve(baseDir);
9037
- const candidate = path14.resolve(resolvedBase, relativePathname);
9038
- if (!candidate.startsWith(resolvedBase + path14.sep)) continue;
9416
+ const resolvedBase = path17.resolve(baseDir);
9417
+ const candidate = path17.resolve(resolvedBase, relativePathname);
9418
+ if (!candidate.startsWith(resolvedBase + path17.sep)) continue;
9039
9419
  try {
9040
- if (fs8.existsSync(candidate) && fs8.statSync(candidate).isFile()) {
9420
+ if (fs10.existsSync(candidate) && fs10.statSync(candidate).isFile()) {
9041
9421
  return true;
9042
9422
  }
9043
9423
  } catch {
@@ -9146,13 +9526,13 @@ function readProcessEnvKey(node) {
9146
9526
  if (!object || object.type !== "MemberExpression" || object.object?.type !== "Identifier" || object.object.name !== "process" || object.property?.name !== "env") {
9147
9527
  return void 0;
9148
9528
  }
9149
- const property = node.property;
9150
- if (!property) return void 0;
9151
- if (!node.computed && property.type === "Identifier") {
9152
- return property.name;
9529
+ const property2 = node.property;
9530
+ if (!property2) return void 0;
9531
+ if (!node.computed && property2.type === "Identifier") {
9532
+ return property2.name;
9153
9533
  }
9154
- if (node.computed && property.type === "Literal") {
9155
- const value = property.value;
9534
+ if (node.computed && property2.type === "Literal") {
9535
+ const value = property2.value;
9156
9536
  return typeof value === "string" ? value : void 0;
9157
9537
  }
9158
9538
  return void 0;
@@ -9182,7 +9562,7 @@ __name(formatClientBoundaryWarning, "formatClientBoundaryWarning");
9182
9562
 
9183
9563
  // src/image-vite.ts
9184
9564
  import { readFile as readFile3 } from "fs/promises";
9185
- import path15 from "path";
9565
+ import path18 from "path";
9186
9566
  import { imageSize as imageSize2 } from "image-size";
9187
9567
  var FARM_IMAGE_ID_PREFIX = "\0farm:image:";
9188
9568
  var STATIC_IMAGE_RE = /\.(?:avif|gif|jpe?g|png|webp)$/i;
@@ -9250,7 +9630,7 @@ async function createBlurDataURL(bytes) {
9250
9630
  __name(createBlurDataURL, "createBlurDataURL");
9251
9631
 
9252
9632
  // src/server/vite-config.ts
9253
- import path16 from "path";
9633
+ import path19 from "path";
9254
9634
  var FARM_CLIENT_ENTRY_PATTERN = "**/{page,layout,loading,error,not-found,default}.{js,jsx,ts,tsx}";
9255
9635
  var FARM_CLIENT_OPTIMIZE_DEPS_INCLUDE = [
9256
9636
  "react",
@@ -9274,9 +9654,9 @@ function getFarmClientOptimizeDepsInclude(renderer) {
9274
9654
  }
9275
9655
  __name(getFarmClientOptimizeDepsInclude, "getFarmClientOptimizeDepsInclude");
9276
9656
  function createFarmClientOptimizeDepsEntries(projectRoot, appDirectories) {
9277
- const resolvedProjectRoot = path16.resolve(projectRoot);
9657
+ const resolvedProjectRoot = path19.resolve(projectRoot);
9278
9658
  return appDirectories.map((appDirectory) => {
9279
- const relativeAppDirectory = path16.relative(resolvedProjectRoot, path16.resolve(appDirectory)).replace(/\\/g, "/");
9659
+ const relativeAppDirectory = path19.relative(resolvedProjectRoot, path19.resolve(appDirectory)).replace(/\\/g, "/");
9280
9660
  const prefix = relativeAppDirectory || ".";
9281
9661
  return `${prefix}/${FARM_CLIENT_ENTRY_PATTERN}`;
9282
9662
  });
@@ -9300,7 +9680,7 @@ function createFarmClientOptimizeDepsConfig(entries, renderer) {
9300
9680
  __name(createFarmClientOptimizeDepsConfig, "createFarmClientOptimizeDepsConfig");
9301
9681
  function createFarmSourceAlias(projectRoot, srcDir = "src") {
9302
9682
  return {
9303
- "@": path16.resolve(projectRoot, srcDir)
9683
+ "@": path19.resolve(projectRoot, srcDir)
9304
9684
  };
9305
9685
  }
9306
9686
  __name(createFarmSourceAlias, "createFarmSourceAlias");
@@ -9431,6 +9811,87 @@ function mergeFarmProductionViteConfig(farmConfig, userConfig = {}) {
9431
9811
  }
9432
9812
  __name(mergeFarmProductionViteConfig, "mergeFarmProductionViteConfig");
9433
9813
 
9814
+ // src/docs/client-config.ts
9815
+ import { realpathSync } from "fs";
9816
+ import { createRequire as createRequire3 } from "module";
9817
+ import path20 from "path";
9818
+ var parseAst2;
9819
+ function propertyKeyName(property2) {
9820
+ if (property2.computed) return void 0;
9821
+ const key = property2.key;
9822
+ if (key.type === "Identifier") return key.name;
9823
+ if (key.type === "Literal" && typeof key.value === "string") return key.value;
9824
+ return void 0;
9825
+ }
9826
+ __name(propertyKeyName, "propertyKeyName");
9827
+ function redactFarmDocsClientConfig(code, filename) {
9828
+ parseAst2 ?? (parseAst2 = createRequire3(typeof __filename === "string" ? __filename : import.meta.url)(
9829
+ "rolldown/parseAst"
9830
+ ).parseAst);
9831
+ const extension = path20.extname(filename);
9832
+ const program = parseAst2(code, {
9833
+ lang: extension === ".tsx" || extension === ".jsx" ? "tsx" : "ts"
9834
+ });
9835
+ const edits = [];
9836
+ const visit = /* @__PURE__ */ __name((node) => {
9837
+ if (Array.isArray(node)) {
9838
+ for (const child of node) visit(child);
9839
+ return;
9840
+ }
9841
+ if (!node || typeof node !== "object") return;
9842
+ const current = node;
9843
+ if (current.type === "Property") {
9844
+ const name = propertyKeyName(current);
9845
+ const valueType = current.value?.type;
9846
+ const credential = name !== void 0 && (name.toLowerCase() === "headers" || isSecretDocsConfigKey(name) && valueType !== "ObjectExpression" && valueType !== "ArrayExpression");
9847
+ if (name && credential) {
9848
+ edits.push(
9849
+ current.shorthand || current.method || current.kind !== "init" ? { start: current.start, end: current.end, text: `${JSON.stringify(name)}: undefined` } : {
9850
+ start: current.value.start,
9851
+ end: current.value.end,
9852
+ text: "undefined"
9853
+ }
9854
+ );
9855
+ return;
9856
+ }
9857
+ }
9858
+ for (const [key, value] of Object.entries(current)) {
9859
+ if (key !== "start" && key !== "end" && value && typeof value === "object") visit(value);
9860
+ }
9861
+ }, "visit");
9862
+ visit(program);
9863
+ if (edits.length === 0) return null;
9864
+ let redacted = code;
9865
+ for (const edit of edits.sort((left, right) => right.start - left.start)) {
9866
+ redacted = redacted.slice(0, edit.start) + edit.text + redacted.slice(edit.end);
9867
+ }
9868
+ return redacted;
9869
+ }
9870
+ __name(redactFarmDocsClientConfig, "redactFarmDocsClientConfig");
9871
+ function isFarmDocsClientConfigModule(id, configModule) {
9872
+ if (!configModule) return false;
9873
+ const file = id.split("?")[0].replace(/\\/g, "/");
9874
+ if (file === configModule) return true;
9875
+ try {
9876
+ return file === realpathSync(configModule).replace(/\\/g, "/");
9877
+ } catch {
9878
+ return false;
9879
+ }
9880
+ }
9881
+ __name(isFarmDocsClientConfigModule, "isFarmDocsClientConfigModule");
9882
+ function farmDocsClientConfigPlugin(configModule) {
9883
+ return {
9884
+ name: "farm:docs-client-config",
9885
+ enforce: "pre",
9886
+ transform(code, id, options) {
9887
+ if (options?.ssr || !isFarmDocsClientConfigModule(id, configModule)) return null;
9888
+ const redacted = redactFarmDocsClientConfig(code, id.split("?")[0]);
9889
+ return redacted === null ? null : { code: redacted, map: null };
9890
+ }
9891
+ };
9892
+ }
9893
+ __name(farmDocsClientConfigPlugin, "farmDocsClientConfigPlugin");
9894
+
9434
9895
  // src/theme/vite.ts
9435
9896
  var FARM_DARK_VARIANT = '@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));';
9436
9897
  function createFarmThemeCssPlugin(input, basePath = "/") {
@@ -9550,7 +10011,7 @@ function loadFarmWorkflowsDevRuntime() {
9550
10011
  }
9551
10012
  __name(loadFarmWorkflowsDevRuntime, "loadFarmWorkflowsDevRuntime");
9552
10013
  function loadFarmDevtoolsSnapshotRuntime() {
9553
- return import("./devtools-BPBCYOU6.mjs");
10014
+ return import("./devtools-EE5RIBTH.mjs");
9554
10015
  }
9555
10016
  __name(loadFarmDevtoolsSnapshotRuntime, "loadFarmDevtoolsSnapshotRuntime");
9556
10017
  function loadFarmDevtoolsUIRuntime() {
@@ -9961,11 +10422,11 @@ function isPotentialProgrammaticRouteSourceFile(normalizedFile, srcDirSlug) {
9961
10422
  }
9962
10423
  __name(isPotentialProgrammaticRouteSourceFile, "isPotentialProgrammaticRouteSourceFile");
9963
10424
  function fileContainsProgrammaticPageRoute(file) {
9964
- if (!fs9.existsSync(file)) {
10425
+ if (!fs11.existsSync(file)) {
9965
10426
  return false;
9966
10427
  }
9967
10428
  try {
9968
- return scanProgrammaticPagePaths(fs9.readFileSync(file, "utf8")).length > 0;
10429
+ return scanProgrammaticPagePaths(fs11.readFileSync(file, "utf8")).length > 0;
9969
10430
  } catch {
9970
10431
  return false;
9971
10432
  }
@@ -9973,7 +10434,7 @@ function fileContainsProgrammaticPageRoute(file) {
9973
10434
  __name(fileContainsProgrammaticPageRoute, "fileContainsProgrammaticPageRoute");
9974
10435
  function rewriteEarlySsrRelativeImports(options) {
9975
10436
  const cleanId = options.id.split("?", 1)[0];
9976
- if (!path17.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
10437
+ if (!path21.isAbsolute(cleanId) || cleanId.replace(/\\/g, "/").includes("/node_modules/")) {
9977
10438
  return null;
9978
10439
  }
9979
10440
  const replacements = [];
@@ -9993,7 +10454,7 @@ function rewriteEarlySsrRelativeImports(options) {
9993
10454
  const suffixIndex = source.value.search(/[?#]/);
9994
10455
  const sourcePath = suffixIndex === -1 ? source.value : source.value.slice(0, suffixIndex);
9995
10456
  const suffix = suffixIndex === -1 ? "" : source.value.slice(suffixIndex);
9996
- const resolvedPath = path17.resolve(path17.dirname(cleanId), sourcePath);
10457
+ const resolvedPath = path21.resolve(path21.dirname(cleanId), sourcePath);
9997
10458
  replacements.push({
9998
10459
  start: source.start,
9999
10460
  end: source.end,
@@ -10111,8 +10572,8 @@ __name(isFarmModuleAstNode, "isFarmModuleAstNode");
10111
10572
  function isFarmConfigFile(file, root) {
10112
10573
  const normalized = file.replace(/\\/g, "/");
10113
10574
  const rootSlug = root.replace(/\\/g, "/").replace(/\/+$/, "");
10114
- const relative3 = normalized.startsWith(`${rootSlug}/`) ? normalized.slice(rootSlug.length + 1) : normalized;
10115
- return FARM_CONFIG_FILENAMES.has(relative3);
10575
+ const relative4 = normalized.startsWith(`${rootSlug}/`) ? normalized.slice(rootSlug.length + 1) : normalized;
10576
+ return FARM_CONFIG_FILENAMES.has(relative4);
10116
10577
  }
10117
10578
  __name(isFarmConfigFile, "isFarmConfigFile");
10118
10579
  var warnedClientBoundaryIds = /* @__PURE__ */ new Set();
@@ -10161,6 +10622,11 @@ function farmPlugin(options = {}, initialPluginManager) {
10161
10622
  let refreshRouteDiscovery = null;
10162
10623
  let workflowHandler = null;
10163
10624
  let isBuild = false;
10625
+ const docsMCPServerDisposers = /* @__PURE__ */ new Set();
10626
+ const releaseDocsMCPServers = /* @__PURE__ */ __name(() => {
10627
+ for (const dispose of docsMCPServerDisposers) dispose();
10628
+ docsMCPServerDisposers.clear();
10629
+ }, "releaseDocsMCPServers");
10164
10630
  const logUpdate = /* @__PURE__ */ __name((tag, message) => {
10165
10631
  const pc = createCliColors();
10166
10632
  const log = [
@@ -10189,13 +10655,12 @@ function farmPlugin(options = {}, initialPluginManager) {
10189
10655
  resolve: {
10190
10656
  alias: { ...layerAliases, ...sourceAlias }
10191
10657
  },
10192
- ...layerRoots.length ? {
10193
- server: {
10194
- fs: {
10195
- allow: [path17.resolve(options.root || process.cwd()), ...layerRoots]
10196
- }
10658
+ server: {
10659
+ fs: {
10660
+ ...layerRoots.length ? { allow: [path21.resolve(options.root || process.cwd()), ...layerRoots] } : {},
10661
+ deny: getFarmDevFsDeny(userConfig.server?.fs?.deny, options)
10197
10662
  }
10198
- } : {}
10663
+ }
10199
10664
  };
10200
10665
  },
10201
10666
  async configResolved(config) {
@@ -10212,6 +10677,11 @@ function farmPlugin(options = {}, initialPluginManager) {
10212
10677
  }
10213
10678
  },
10214
10679
  async configureServer(viteServer) {
10680
+ viteServer.middlewares.use(
10681
+ createFarmDevPreviewGuard(viteServer, {
10682
+ getSourceRoots: /* @__PURE__ */ __name(() => getFarmSourceRoots(farmApp?.getConfig() ?? options), "getSourceRoots")
10683
+ })
10684
+ );
10215
10685
  if (typeof fontImports.configureServer === "function") {
10216
10686
  await fontImports.configureServer.call(this, viteServer);
10217
10687
  }
@@ -10233,6 +10703,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10233
10703
  );
10234
10704
  await farmApp.initialize();
10235
10705
  const farmConfig = farmApp.getConfig();
10706
+ let farmAppPackages;
10236
10707
  if (farmConfig.agent?.noindexPreviews) {
10237
10708
  server.middlewares.use((_req, res, next) => {
10238
10709
  if (isFarmPreviewDeploymentEnvironment(process.env)) {
@@ -10262,7 +10733,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10262
10733
  });
10263
10734
  }
10264
10735
  const sourceRoots = getFarmSourceRoots(farmConfig);
10265
- server.watcher.add(sourceRoots.map((source) => path17.join(source.root, source.srcDir)));
10736
+ server.watcher.add(sourceRoots.map((source) => path21.join(source.root, source.srcDir)));
10266
10737
  if (farmConfig.i18n.enabled) {
10267
10738
  server.watcher.add(
10268
10739
  farmConfig.i18n.locales.map(
@@ -10277,7 +10748,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10277
10748
  ...farmDocsDevRuntime?.getFarmDocsRouteTypeEntries(farmConfig.docs) ?? []
10278
10749
  ], "getExtraRouteTypes");
10279
10750
  const appDirSlugs = sourceRoots.map(
10280
- (source) => path17.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
10751
+ (source) => path21.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
10281
10752
  );
10282
10753
  const generateTypeArtifacts = /* @__PURE__ */ __name(async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
10283
10754
  try {
@@ -10318,7 +10789,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10318
10789
  }, "generateTypeArtifacts");
10319
10790
  await generateTypeArtifacts("startup");
10320
10791
  const srcDirSlugs = sourceRoots.map(
10321
- (source) => path17.join(source.root, source.srcDir).replace(/\\/g, "/")
10792
+ (source) => path21.join(source.root, source.srcDir).replace(/\\/g, "/")
10322
10793
  );
10323
10794
  const layerConfigFiles = new Set(
10324
10795
  farmConfig.layers.map((layer) => layer.configFile?.replace(/\\/g, "/")).filter((file) => Boolean(file))
@@ -10457,7 +10928,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10457
10928
  await apiRouteManager.discoverRoutes();
10458
10929
  let discoveredWorkflows = [];
10459
10930
  const hasWorkflowDirectory = workflowConfig.enabled && workflowConfig.dirs.some(
10460
- (dir) => fs9.existsSync(path17.isAbsolute(dir) ? dir : path17.join(farmConfig.root, dir))
10931
+ (dir) => fs11.existsSync(path21.isAbsolute(dir) ? dir : path21.join(farmConfig.root, dir))
10461
10932
  );
10462
10933
  if (hasWorkflowDirectory) {
10463
10934
  const { createFarmWorkflowRequestHandler, discoverFarmWorkflows } = await loadFarmWorkflowsDevRuntime();
@@ -10491,7 +10962,8 @@ function farmPlugin(options = {}, initialPluginManager) {
10491
10962
  server,
10492
10963
  farmConfig.middleware,
10493
10964
  farmConfig.i18n,
10494
- farmConfig.server
10965
+ farmConfig.server,
10966
+ apiServerBasePath
10495
10967
  );
10496
10968
  await middlewareManager.discover();
10497
10969
  if (pm) {
@@ -10534,6 +11006,7 @@ function farmPlugin(options = {}, initialPluginManager) {
10534
11006
  );
10535
11007
  return resolveFarmLayoutFonts(layoutModules);
10536
11008
  }, "resolveDocsLayoutFonts");
11009
+ releaseDocsMCPServers();
10537
11010
  const farmDocsHandler = farmDocsDevRuntime ? farmDocsDevRuntime.hasFarmDocsRuntimeAdapter(farmConfig.docs) ? await farmDocsDevRuntime.createFarmDocsAdapterHandler(farmConfig.docs, {
10538
11011
  root: farmConfig.root,
10539
11012
  srcDir: farmConfig.srcDir,
@@ -10553,7 +11026,15 @@ function farmPlugin(options = {}, initialPluginManager) {
10553
11026
  );
10554
11027
  }
10555
11028
  return loadFarmDevModule(server, resolved?.id ?? specifier);
10556
- }, "loadModule")
11029
+ }, "loadModule"),
11030
+ registerMCPServer: /* @__PURE__ */ __name((mcpServer) => {
11031
+ const dispose = registerFarmMCPServer(mcpServer);
11032
+ docsMCPServerDisposers.add(dispose);
11033
+ return () => {
11034
+ docsMCPServerDisposers.delete(dispose);
11035
+ dispose();
11036
+ };
11037
+ }, "registerMCPServer")
10557
11038
  }) : farmDocsDevRuntime.createFarmDocsHandler(farmConfig.docs, {
10558
11039
  root: farmConfig.root,
10559
11040
  srcDir: farmConfig.srcDir,
@@ -10671,7 +11152,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10671
11152
  const farmDocsAPIHandler = farmDocsDevRuntime && !farmDocsDevRuntime.hasFarmDocsRuntimeAdapter(farmConfig.docs) ? farmDocsDevRuntime.createFarmDocsAPIHandler({
10672
11153
  rootDir: farmConfig.root,
10673
11154
  srcDir: farmConfig.srcDir,
10674
- docs: farmConfig.docs
11155
+ docs: farmConfig.docs,
11156
+ diagnostics: true
10675
11157
  }) : null;
10676
11158
  const farmDocsFontAssets = new Map(
10677
11159
  farmDocsFontAssetList.map(({ url, sourcePath }) => [url, sourcePath])
@@ -10739,12 +11221,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10739
11221
  }
10740
11222
  }
10741
11223
  const farmDocsFontPath = farmDocsFontAssets.get(requestPathname);
10742
- if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs9.existsSync(farmDocsFontPath)) {
11224
+ if ((requestMethod === "GET" || requestMethod === "HEAD") && farmDocsFontPath && fs11.existsSync(farmDocsFontPath)) {
10743
11225
  res.statusCode = 200;
10744
11226
  res.setHeader("Content-Type", "font/woff2");
10745
11227
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
10746
11228
  if (requestMethod === "HEAD") res.end();
10747
- else fs9.createReadStream(farmDocsFontPath).pipe(res);
11229
+ else fs11.createReadStream(farmDocsFontPath).pipe(res);
10748
11230
  return;
10749
11231
  }
10750
11232
  if (requestMethod === "GET" && (requestPathname === FARM_DEVTOOLS_PATH || requestPathname === `${FARM_DEVTOOLS_PATH}.json`)) {
@@ -10846,6 +11328,23 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10846
11328
  const docsHandler = openAPIManager.getDocsRouteHandler(parsedRequestUrl.origin);
10847
11329
  return docsHandler(req, res);
10848
11330
  }
11331
+ if (stripFarmBasePath(requestPathname, farmConfig.basePath) === FARM_APP_MANIFEST_PATH) {
11332
+ farmAppPackages ?? (farmAppPackages = resolveFarmAppPackages(farmConfig.root ?? process.cwd()));
11333
+ const manifest = await createFarmAppManifestResponse(
11334
+ new Request(parsedRequestUrl, { method: requestMethod }),
11335
+ resolveFarmAppManifestInput(farmConfig, {
11336
+ build: "development",
11337
+ packages: farmAppPackages,
11338
+ // Read again on each request; unchanged files come from a cache.
11339
+ webmcpTools: farmConfig.plugins?.some(({ name }) => name === "farm:webmcp") ? collectFarmWebMCPTools(farmConfig.root ?? process.cwd(), farmConfig.srcDir) : []
11340
+ }),
11341
+ { development: true }
11342
+ );
11343
+ if (manifest) {
11344
+ await sendWebResponse(res, manifest);
11345
+ return;
11346
+ }
11347
+ }
10849
11348
  if (options.agent?.apiCatalog && stripFarmBasePath(requestPathname, farmConfig.basePath) === FARM_API_CATALOG_PATH) {
10850
11349
  if (await runAppMiddlewareForContentRoute()) return;
10851
11350
  await sendWebResponse(
@@ -10860,6 +11359,23 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10860
11359
  );
10861
11360
  return;
10862
11361
  }
11362
+ if (options.agent?.aiCatalog !== false) {
11363
+ const aiCatalog = createFarmAiCatalogResponse(
11364
+ new Request(parsedRequestUrl, {
11365
+ method: requestMethod,
11366
+ headers: {
11367
+ "user-agent": String(req.headers["user-agent"] ?? ""),
11368
+ "if-none-match": String(req.headers["if-none-match"] ?? "")
11369
+ }
11370
+ }),
11371
+ { basePath: farmConfig.basePath, apiServerBasePath }
11372
+ );
11373
+ if (aiCatalog) {
11374
+ if (await runAppMiddlewareForContentRoute()) return;
11375
+ await sendWebResponse(res, aiCatalog);
11376
+ return;
11377
+ }
11378
+ }
10863
11379
  const docsHeaders = new Headers();
10864
11380
  for (const [key, value] of Object.entries(req.headers)) {
10865
11381
  if (value) {
@@ -10877,7 +11393,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10877
11393
  method: requestMethod,
10878
11394
  headers: docsHeaders
10879
11395
  });
10880
- const docsResponse = await farmDocsHandler(docsRequest.clone());
11396
+ const docsBodyInit = requestMethod === "GET" || requestMethod === "HEAD" ? {} : { body: createFarmNodeRequestBodyStream(req), duplex: "half" };
11397
+ const docsResponse = await farmDocsHandler(new Request(docsRequest, docsBodyInit));
10881
11398
  if (docsResponse) {
10882
11399
  if (await runAppMiddlewareForContentRoute()) return;
10883
11400
  await sendWebResponse(
@@ -10900,10 +11417,16 @@ window.__FARM_MANIFEST__ = ${inlineValue({
10900
11417
  return null;
10901
11418
  }
10902
11419
  return {
10903
- source: await fs9.promises.readFile(sourcePath, "utf8"),
11420
+ source: await fs11.promises.readFile(sourcePath, "utf8"),
10904
11421
  filePath: sourcePath
10905
11422
  };
10906
- }, "resolveSource")
11423
+ }, "resolveSource"),
11424
+ // The anonymous check goes through this server, so its guards and
11425
+ // middleware see the page's own path, as in production.
11426
+ renderPage: /* @__PURE__ */ __name(async (request2) => fetch(request2, {
11427
+ redirect: "manual",
11428
+ signal: res.destroyed ? AbortSignal.abort() : createFarmNodeRequestAbortSignal(req, res)
11429
+ }), "renderPage")
10907
11430
  });
10908
11431
  if (markdownSourceResponse) {
10909
11432
  if (await runAppMiddlewareForContentRoute()) return;
@@ -11391,7 +11914,10 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11391
11914
  return;
11392
11915
  }
11393
11916
  const routeModule = await routeManager3.loadRouteModule(route.modulePath);
11394
- const loadingBoundary = routeManager3.getMatchingLoading(targetRequestUrl.pathname);
11917
+ const loadingBoundary = routeManager3.getMatchingLoading(
11918
+ targetRequestUrl.pathname,
11919
+ route
11920
+ );
11395
11921
  const loadingModule = loadingBoundary ? await routeManager3.loadRouteModule(loadingBoundary.modulePath) : null;
11396
11922
  const navigationManifest = routeManager3.generateClientManifest(server.config.root);
11397
11923
  const moduleMetadata = navigationManifest.routes.find((entry) => entry.pattern === route.pattern) ?? getClientModuleMetadata(route.modulePath, server.config.root);
@@ -11445,6 +11971,9 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11445
11971
  await layoutModule.generateMetadata({ params: routeProps.params })
11446
11972
  );
11447
11973
  }
11974
+ mergedMetadata = await mergeModuleViewport(mergedMetadata, layoutModule, {
11975
+ params: routeProps.params
11976
+ });
11448
11977
  }
11449
11978
  mergedMetadata = mergeMetadata(mergedMetadata, routeModule.metadata);
11450
11979
  if (typeof routeModule.generateMetadata === "function") {
@@ -11453,6 +11982,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11453
11982
  await routeModule.generateMetadata(routeProps)
11454
11983
  );
11455
11984
  }
11985
+ mergedMetadata = await mergeModuleViewport(mergedMetadata, routeModule, routeProps);
11456
11986
  mergedMetadata = addMetadataMarkdownAlternate(
11457
11987
  mergedMetadata,
11458
11988
  getFarmMarkdownAlternatePath(farmApp.getConfig().md, targetRequestUrl.pathname)
@@ -11484,6 +12014,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11484
12014
  return {
11485
12015
  name: slot.name,
11486
12016
  ownerPattern: slot.ownerPattern,
12017
+ ...slot.ownerDirectory ? { ownerDirectory: slot.ownerDirectory } : {},
11487
12018
  containerId: slot.containerId,
11488
12019
  interception: slot.interception,
11489
12020
  fallback: slot.fallback,
@@ -11536,13 +12067,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
11536
12067
  slots: routeSlots.map((slot) => ({
11537
12068
  name: slot.name,
11538
12069
  ownerPattern: slot.ownerPattern,
12070
+ ownerDirectory: slot.ownerDirectory,
11539
12071
  containerId: slot.containerId,
11540
12072
  module: slot.renderModule,
11541
12073
  props: slot.props
11542
12074
  })),
11543
12075
  pageShouldHydrate: shouldHydrate,
11544
12076
  layoutShouldHydrate: shouldHydrateLayout,
11545
- islandStrategy: hydrationIslandStrategy
12077
+ islandStrategy: hydrationIslandStrategy,
12078
+ serverTree: "serverTree" in moduleMetadata && moduleMetadata.serverTree === true
11546
12079
  })
11547
12080
  )
11548
12081
  );
@@ -11893,6 +12426,7 @@ export const getManifest = () => ({
11893
12426
  fullManifest.routes[route.pattern] = {
11894
12427
  modulePath: route.modulePath,
11895
12428
  pattern: route.pattern,
12429
+ ...route.directory ? { directory: route.directory } : {},
11896
12430
  segments: route.segments,
11897
12431
  search: route.search,
11898
12432
  isClientComponent: route.isClientComponent,
@@ -11905,9 +12439,11 @@ export const getManifest = () => ({
11905
12439
  };
11906
12440
  }
11907
12441
  for (const layout of manifest.layouts) {
12442
+ const groupScope = getRouteGroupScope(layout.pattern);
11908
12443
  fullManifest.layouts[layout.pattern] = {
11909
12444
  modulePath: layout.modulePath,
11910
12445
  pattern: layout.pattern,
12446
+ ...groupScope ? { urlPattern: stripRouteGroups(layout.pattern), groupScope } : {},
11911
12447
  shouldHydrate: layout.shouldHydrate,
11912
12448
  islandStrategy: layout.islandStrategy,
11913
12449
  preloads: [layout.modulePath],
@@ -11931,6 +12467,13 @@ export const manifest = getManifest();
11931
12467
  }
11932
12468
  },
11933
12469
  async transform(code, id, transformOptions) {
12470
+ if (!transformOptions?.ssr) {
12471
+ const docsConfigModule = getFarmDocsAdapterConfigModule(farmApp?.getConfig()?.docs);
12472
+ if (isFarmDocsClientConfigModule(id, docsConfigModule)) {
12473
+ const redacted = redactFarmDocsClientConfig(code, id.split("?")[0]);
12474
+ if (redacted !== null) return { code: redacted, map: null };
12475
+ }
12476
+ }
11934
12477
  if (!transformOptions?.ssr) {
11935
12478
  const currentConfig = farmApp?.getConfig() ?? options;
11936
12479
  if (currentConfig.experimental?.serverActions !== true || !serverFnTransformActive) {
@@ -11987,7 +12530,7 @@ export const manifest = getManifest();
11987
12530
  const root = currentConfig.root || server?.config.root || process.cwd();
11988
12531
  const cleanId = id.split("?", 1)[0];
11989
12532
  const selectedIsolatedModules = options.isolatedClientBoundaryModules ?? farmApp?.getRouteManager().getIsolatedClientBoundaryModules(root);
11990
- const selectedForIsolatedHydration = selectedIsolatedModules?.has(path17.resolve(cleanId)) === true;
12533
+ const selectedForIsolatedHydration = selectedIsolatedModules?.has(path21.resolve(cleanId)) === true;
11991
12534
  if (isReactRenderer(resolveFarmRenderer(currentConfig.renderer)) && selectedForIsolatedHydration && isIsolatableClientBoundarySource(clientBoundarySource)) {
11992
12535
  isolatedModuleReference = toViteModuleId(cleanId, root);
11993
12536
  const transformedBoundary = transformIsolatedClientBoundaryModule({
@@ -12067,6 +12610,7 @@ if (import.meta.hot) {
12067
12610
  });
12068
12611
  },
12069
12612
  async closeBundle() {
12613
+ if (!isBuild) releaseDocsMCPServers();
12070
12614
  if (!farmApp || !isBuild) return;
12071
12615
  try {
12072
12616
  const routeManager = farmApp.getRouteManager();
@@ -12078,8 +12622,8 @@ if (import.meta.hot) {
12078
12622
  }
12079
12623
  logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
12080
12624
  logger.info("Pre-rendering SSG pages...");
12081
- const outDir = path17.join(server?.config.root || process.cwd(), options.outDir || "dist");
12082
- const clientDir = path17.join(outDir, "client");
12625
+ const outDir = path21.join(server?.config.root || process.cwd(), options.outDir || "dist");
12626
+ const clientDir = path21.join(outDir, "client");
12083
12627
  for (const page of ssgPages) {
12084
12628
  try {
12085
12629
  const staticRequest = new Request(new URL(page.urlPath, "http://farm.static"));
@@ -12131,9 +12675,9 @@ if (import.meta.hot) {
12131
12675
  <script type="module" src="/assets/client.js"></script>
12132
12676
  </body>
12133
12677
  </html>`;
12134
- const outputPath = page.urlPath === "/" ? path17.join(clientDir, "index.html") : path17.join(clientDir, page.urlPath + ".html");
12135
- fs9.mkdirSync(path17.dirname(outputPath), { recursive: true });
12136
- fs9.writeFileSync(outputPath, fullHtml);
12678
+ const outputPath = page.urlPath === "/" ? path21.join(clientDir, "index.html") : path21.join(clientDir, page.urlPath + ".html");
12679
+ fs11.mkdirSync(path21.dirname(outputPath), { recursive: true });
12680
+ fs11.writeFileSync(outputPath, fullHtml);
12137
12681
  const revalidateInfo = page.revalidate ? ` (revalidate: ${page.revalidate}s)` : "";
12138
12682
  logger.success(` \u2713 ${page.urlPath}${revalidateInfo}`);
12139
12683
  });
@@ -12141,8 +12685,8 @@ if (import.meta.hot) {
12141
12685
  logger.error(` \u2717 ${page.urlPath}: ${error}`);
12142
12686
  }
12143
12687
  }
12144
- const manifestPath = path17.join(outDir, "__ssg_manifest.json");
12145
- fs9.writeFileSync(
12688
+ const manifestPath = path21.join(outDir, "__ssg_manifest.json");
12689
+ fs11.writeFileSync(
12146
12690
  manifestPath,
12147
12691
  JSON.stringify(
12148
12692
  ssgPages.map((p) => ({
@@ -12185,9 +12729,9 @@ if (import.meta.hot) {
12185
12729
  server2.ws.send({ type: "full-reload", path: "*" });
12186
12730
  return [];
12187
12731
  }
12188
- const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path17.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
12732
+ const currentSrcRoot = currentFarmConfig ? getFarmSourceRoots(currentFarmConfig).map((source) => path21.join(source.root, source.srcDir).replace(/\\/g, "/")).find((sourceRoot) => normalizedFile.startsWith(`${sourceRoot}/`)) || null : null;
12189
12733
  if (currentSrcRoot && normalizedFile.startsWith(`${currentSrcRoot}/`) && isProgrammaticRoutesFileName(normalizedFile)) {
12190
- logUpdate("PAGE", `updated ${path17.basename(file)}`);
12734
+ logUpdate("PAGE", `updated ${path21.basename(file)}`);
12191
12735
  for (const mod of modules) {
12192
12736
  server2.moduleGraph.invalidateModule(mod);
12193
12737
  }
@@ -12318,10 +12862,10 @@ function createPageDataMiddlewareRequest(req, target) {
12318
12862
  __name(createPageDataMiddlewareRequest, "createPageDataMiddlewareRequest");
12319
12863
  function resolveDevelopmentRoot(farmRoot, viteRoot) {
12320
12864
  if (!farmRoot) return viteRoot;
12321
- if (path17.resolve(farmRoot) === path17.resolve(viteRoot)) return farmRoot;
12865
+ if (path21.resolve(farmRoot) === path21.resolve(viteRoot)) return farmRoot;
12322
12866
  try {
12323
- if (fs9.realpathSync(farmRoot) === fs9.realpathSync(viteRoot)) {
12324
- return path17.resolve(viteRoot);
12867
+ if (fs11.realpathSync(farmRoot) === fs11.realpathSync(viteRoot)) {
12868
+ return path21.resolve(viteRoot);
12325
12869
  }
12326
12870
  } catch {
12327
12871
  }
@@ -12686,7 +13230,8 @@ function generateClientCode(integrationProviders = [], documentNavigationMatcher
12686
13230
  import { hydrateRoot, createRoot } from 'react-dom/client'` : appSetupPath ? `import React, { hydrateRoot, createRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)}
12687
13231
  import __farmAppSetup from ${JSON.stringify(toViteModuleId(appSetupPath, root))}
12688
13232
  __farmConfigureApp(__farmAppSetup)` : `import React, { hydrateRoot, createRoot } from ${JSON.stringify(renderer.client)}`;
12689
- const isolatedHydrationImport = isolatedHydrationEnabled ? `import { createFarmIsolatedHydrationRuntime, createFarmServerPageBoundary, wrapFarmIsolatedClientGraph } from '@farm.js/core/internal/isolated-boundary'` : "";
13233
+ const isolatedHydrationImport = isolatedHydrationEnabled ? `import { createFarmIsolatedHydrationRuntime, createFarmServerPageBoundary, wrapFarmIsolatedClientGraph } from '@farm.js/core/internal/isolated-boundary'
13234
+ import { createFarmServerTreeElement } from '@farm.js/core/internal/server-tree'` : "";
12690
13235
  const docsAdapterImportBlock = generateFarmDocsAdapterClientRuntime(
12691
13236
  docsAdapterReact,
12692
13237
  docsConfigModule
@@ -12708,14 +13253,28 @@ function disposeFarmIsolatedClientBoundaries(scope) {
12708
13253
 
12709
13254
  async function hydrateFarmIsolatedClientBoundaries(scope = document, signal) {
12710
13255
  await farmIsolatedHydrationRuntime.hydrate(scope, signal);
12711
- }` : "";
13256
+ }
13257
+
13258
+ // A server-tree page (an async page below a hydrating layout) rebuilds in the layout's root.
13259
+ async function createFarmServerTreePageElement(source, pathname) {
13260
+ try {
13261
+ return await createFarmServerTreeElement(React, source, {
13262
+ load: (reference) => import(/* @vite-ignore */ reference),
13263
+ ServerHtml: FarmServerPage,
13264
+ key: pathname,
13265
+ });
13266
+ } catch (error) {
13267
+ console.warn('[Farm.js] Could not rebuild the server tree of ' + pathname + '; its server HTML was kept.', error);
13268
+ return null;
13269
+ }
13270
+ }` : `async function createFarmServerTreePageElement() { return null; }`;
12712
13271
  return `
12713
13272
  ${rendererClientImports}
12714
13273
  ${isolatedHydrationImport}
12715
13274
  import { installChunkErrorRecovery, SPARouter } from '@farm.js/core/client'
12716
13275
  import { createClientPluginManager } from '@farm.js/core/plugin/client'
12717
13276
  import { isFarmRouteActive } from '@farm.js/core/router'
12718
- import { replayFarmQueuedInteraction, scheduleFarmIslandHydration, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from '@farm.js/core/internal/client-runtime'
13277
+ import { isFarmBlockedNavigationURL, replayFarmQueuedInteraction, scheduleFarmIslandHydration, searchParamsToObject, setFarmBasePath, setFarmTrailingSlashPreference, stripFarmBasePath } from '@farm.js/core/internal/client-runtime'
12719
13278
  import { reviveDeferredData } from '@farm.js/core/deferred'
12720
13279
  import {
12721
13280
  createFarmDeploymentMismatchError,
@@ -12849,14 +13408,29 @@ function findLayouts(pathname) {
12849
13408
  const manifest = getManifest();
12850
13409
  const layouts = Object.values(manifest.layouts);
12851
13410
  const matchingLayouts = [];
13411
+ let directory;
12852
13412
 
12853
13413
  for (const layout of layouts) {
12854
- if (layout.pattern === '/' || isFarmRouteActive(layout.pattern, pathname, { exact: false })) {
12855
- matchingLayouts.push(layout);
13414
+ // Route groups add no URL segment: match the layout's URL, then keep a
13415
+ // grouped layout to the pages inside its group directory.
13416
+ const urlPattern = layout.urlPattern || layout.pattern;
13417
+ if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, pathname, { exact: false })) continue;
13418
+ if (layout.groupScope) {
13419
+ if (directory === undefined) {
13420
+ const route = findRoute(pathname)?.route;
13421
+ directory = route ? route.directory || route.pattern : null;
13422
+ }
13423
+ if (
13424
+ typeof directory !== 'string' ||
13425
+ (directory !== layout.groupScope && !directory.startsWith(layout.groupScope + '/'))
13426
+ ) continue;
12856
13427
  }
13428
+ matchingLayouts.push(layout);
12857
13429
  }
12858
13430
 
12859
- return matchingLayouts.sort((a, b) => a.pattern.length - b.pattern.length);
13431
+ return matchingLayouts.sort(
13432
+ (a, b) => a.pattern.split('/').filter(Boolean).length - b.pattern.split('/').filter(Boolean).length,
13433
+ );
12860
13434
  }
12861
13435
 
12862
13436
  // ====== SPA ROUTER ======
@@ -12886,6 +13460,7 @@ class LegacyManifestSPARouter {
12886
13460
  async navigate(href, options = {}) {
12887
13461
  const { replace = false, scroll = true } = options;
12888
13462
  const url = new URL(href, window.location.origin);
13463
+ if (isFarmBlockedNavigationURL(url)) return;
12889
13464
  const pathname = url.pathname;
12890
13465
  const search = url.search;
12891
13466
  const fullPath = pathname + search;
@@ -13615,6 +14190,12 @@ async function tryHydrateImportedPage(
13615
14190
  return false;
13616
14191
  }
13617
14192
 
14193
+ if (PageComponent.__farmServerProps === true && existingProps?.__farmRoutePropsResolved !== true) {
14194
+ // This route's guard and data run only on the server, and it did not
14195
+ // resolve them (it rendered error or notFound UI): keep its HTML.
14196
+ return false;
14197
+ }
14198
+
13618
14199
  currentPageComponent = PageComponent;
13619
14200
  currentPageProps = await buildRouteComponentProps(
13620
14201
  pageModule,
@@ -13631,14 +14212,23 @@ async function tryHydrateImportedPage(
13631
14212
  } else if (layoutShouldHydrate) {
13632
14213
  currentPageProps = existingProps || { params };
13633
14214
  const serverPage = document.getElementById('__farm_page__');
13634
- pageElement = createLayoutPageBoundary(
13635
- false,
13636
- islandStrategy,
13637
- null,
13638
- typeof hydrationOptions.serverHtml === 'string'
13639
- ? hydrationOptions.serverHtml
13640
- : serverPage ? serverPage.innerHTML : '',
13641
- );
14215
+ const pageSource = typeof hydrationOptions.serverHtml === 'string'
14216
+ ? hydrationOptions.serverHtml
14217
+ : serverPage;
14218
+ const serverTree = pageSource
14219
+ ? await createFarmServerTreePageElement(pageSource, window.location.pathname)
14220
+ : null;
14221
+ if (signal?.aborted || !container?.isConnected) return false;
14222
+ pageElement = serverTree
14223
+ ? createLayoutPageBoundary(false, islandStrategy, serverTree)
14224
+ : createLayoutPageBoundary(
14225
+ false,
14226
+ islandStrategy,
14227
+ null,
14228
+ typeof hydrationOptions.serverHtml === 'string'
14229
+ ? hydrationOptions.serverHtml
14230
+ : serverPage ? serverPage.innerHTML : '',
14231
+ );
13642
14232
  }
13643
14233
  if (signal?.aborted || !container?.isConnected || !pageElement) return false;
13644
14234
 
@@ -13824,6 +14414,8 @@ async function renderPage(pageData) {
13824
14414
  loadingModulePath: pageData.loadingModulePath,
13825
14415
  };
13826
14416
  const params = pageData.props?.params || {};
14417
+ // Page data carries middleware data as JSON, the way a full load embeds it.
14418
+ const pageProps = pageData.props ? normalizeServerProps(pageData.props) : pageData.props;
13827
14419
  const nextLayoutPatterns = Array.isArray(pageData.fragment?.layoutPatterns)
13828
14420
  ? pageData.fragment.layoutPatterns
13829
14421
  : [];
@@ -13840,6 +14432,20 @@ async function renderPage(pageData) {
13840
14432
  let fragmentHtml = pageData.fragment?.html;
13841
14433
  let layoutPatterns = nextLayoutPatterns;
13842
14434
 
14435
+ // The fragment leaves out the layouts both routes share. When React owns the
14436
+ // current layouts and will not keep rendering them, the swap below replaces the
14437
+ // whole container, so a fragment without its outer layouts would drop them.
14438
+ // Load the complete route for that swap instead.
14439
+ if (
14440
+ typeof fragmentHtml === 'string' &&
14441
+ activeLayoutShouldHydrate &&
14442
+ !(route.layoutShouldHydrate && (appRoot || reactRoot)) &&
14443
+ nextLayoutPatterns.length > 0 &&
14444
+ !findLayoutBoundary(parseNavigationFragment(fragmentHtml), nextLayoutPatterns[0])
14445
+ ) {
14446
+ fragmentHtml = undefined;
14447
+ }
14448
+
13843
14449
  if (typeof fragmentHtml !== 'string') {
13844
14450
  const deploymentId = window.__FARM_DEPLOYMENT_ID__;
13845
14451
  const response = await fetch(path, {
@@ -13880,7 +14486,7 @@ async function renderPage(pageData) {
13880
14486
  params,
13881
14487
  layouts,
13882
14488
  false,
13883
- pageData.props,
14489
+ pageProps,
13884
14490
  null,
13885
14491
  {
13886
14492
  pageShouldHydrate,
@@ -13926,7 +14532,7 @@ async function renderPage(pageData) {
13926
14532
  params,
13927
14533
  layouts,
13928
14534
  true,
13929
- pageData.props,
14535
+ pageProps,
13930
14536
  hydrationController.signal,
13931
14537
  {
13932
14538
  pageShouldHydrate,
@@ -14040,17 +14646,20 @@ async function hydrate() {
14040
14646
  return
14041
14647
  }
14042
14648
 
14043
- // Get props - either from server-injected props or by matching the current URL
14044
- if (!pageProps || !pageProps.params || Object.keys(pageProps.params).length === 0) {
14045
- // Extract params from URL using manifest route matching (fallback)
14649
+ // Use the server-injected props. A document that carries no params (a route
14650
+ // without any, or generated HTML) takes them from the current URL, keeping
14651
+ // what the server rendered with, such as middleware data.
14652
+ if (!pageProps.params || Object.keys(pageProps.params).length === 0) {
14046
14653
  const pathname = window.location.pathname;
14047
14654
  const foundRoute = findRoute(pathname);
14048
- pageProps = normalizeServerProps({
14049
- params: foundRoute?.params || {},
14050
- search: getCurrentSearchParams(),
14051
- searchParams: getCurrentSearchParams(),
14655
+ const search = getCurrentSearchParams();
14656
+ pageProps = {
14657
+ search,
14658
+ searchParams: search,
14052
14659
  path: pathname,
14053
- });
14660
+ ...pageProps,
14661
+ params: foundRoute?.params || {},
14662
+ };
14054
14663
  }
14055
14664
  currentPageProps = pageProps;
14056
14665
 
@@ -14243,7 +14852,7 @@ function generateClientManifest(bundle) {
14243
14852
  __name(generateClientManifest, "generateClientManifest");
14244
14853
  async function defineConfig(config = {}) {
14245
14854
  const tailwindVitePlugin = await loadTailwindVitePlugin();
14246
- const appRoot = path17.resolve(config.root || process.cwd());
14855
+ const appRoot = path21.resolve(config.root || process.cwd());
14247
14856
  if (config.extends?.length) {
14248
14857
  const { config: layeredConfig } = await import("./layers-BRQF5ETU.mjs").then(
14249
14858
  ({ resolveFarmLayers }) => resolveFarmLayers(config, {
@@ -14466,10 +15075,10 @@ export {
14466
15075
  resolveFarmIsolatedClientHydrationMode,
14467
15076
  getClientModuleMetadata,
14468
15077
  getClientModuleHydrationPlan,
15078
+ usesFarmServerTree,
14469
15079
  createMarkdownPageHydrationPlanner,
14470
15080
  enforceFarmIsolatedHydrationRouteBudget,
14471
15081
  RouteManager,
14472
- HOISTED_HEAD_ELEMENT,
14473
15082
  resolveFarmNotFoundComponentPath,
14474
15083
  farmFontImportsPlugin,
14475
15084
  mergeFarmFontCss,
@@ -14487,12 +15096,15 @@ export {
14487
15096
  generateFarmClientPluginEntryCode,
14488
15097
  resolveFarmClientCacheAdapterEntry,
14489
15098
  generateClientCachePersistenceCode,
15099
+ resolveFarmAppPackages,
15100
+ collectFarmWebMCPTools,
14490
15101
  FARM_LAYOUT_ELEMENT_CLIENT_SOURCE,
14491
15102
  createFarmClientOptimizeDepsEntries,
14492
15103
  createFarmClientOptimizeDepsConfig,
14493
15104
  createFarmSourceAlias,
14494
15105
  mergeFarmViteConfig,
14495
15106
  mergeFarmProductionViteConfig,
15107
+ farmDocsClientConfigPlugin,
14496
15108
  createFarmThemeCssPlugin,
14497
15109
  farmI18nClientBridgePlugin,
14498
15110
  farmServerOnlyEntriesPlugin,