@farm.js/core 0.1.66 → 0.1.67

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 (433) hide show
  1. package/dist/{agent-mcp-handler-QLFDDTYN.mjs → agent-mcp-handler-AZ7QW4UP.mjs} +5 -5
  2. package/dist/{agent-mcp-handler-OXT73ZBY.cjs → agent-mcp-handler-FER4MQDF.cjs} +6 -6
  3. package/dist/{agent-mcp.d-QD2WZ9BS.d.ts → agent-mcp.d-BFu9xHAi.d.ts} +1 -1
  4. package/dist/{agent-mcp.d-CO_ABmNK.d.mts → agent-mcp.d-DWyWkTSy.d.mts} +1 -1
  5. package/dist/agent-runtime.cjs +6 -5
  6. package/dist/agent-runtime.d.mts +6 -6
  7. package/dist/agent-runtime.d.ts +6 -6
  8. package/dist/agent-runtime.mjs +5 -4
  9. package/dist/analyzer-KVZGVY5Q.cjs +16 -0
  10. package/dist/{analyzer-4UFP4HVP.mjs → analyzer-TTIIXXMQ.mjs} +2 -2
  11. package/dist/api/client.cjs +12 -2
  12. package/dist/api/client.d.mts +4 -4
  13. package/dist/api/client.d.ts +4 -4
  14. package/dist/api/client.mjs +12 -2
  15. package/dist/api/client.native.cjs +12 -2
  16. package/dist/api/client.native.d.mts +5 -5
  17. package/dist/api/client.native.d.ts +5 -5
  18. package/dist/api/client.native.mjs +12 -2
  19. package/dist/api/node.cjs +223 -0
  20. package/dist/api/node.d.mts +59 -0
  21. package/dist/api/node.d.ts +59 -0
  22. package/dist/api/node.mjs +223 -0
  23. package/dist/api/route-manager.cjs +11 -11
  24. package/dist/api/route-manager.d.mts +10 -9
  25. package/dist/api/route-manager.d.ts +10 -9
  26. package/dist/api/route-manager.mjs +10 -10
  27. package/dist/api/runtime.cjs +11 -7
  28. package/dist/api/runtime.d.mts +7 -7
  29. package/dist/api/runtime.d.ts +7 -7
  30. package/dist/api/runtime.mjs +10 -6
  31. package/dist/{api-client.d-BNLXNCXJ.d.mts → api-client.d-Bp35zMqR.d.mts} +1 -1
  32. package/dist/{api-client.d-ddQBNGtu.d.ts → api-client.d-CFI_xL0V.d.ts} +1 -1
  33. package/dist/api.cjs +17 -13
  34. package/dist/api.d.mts +11 -10
  35. package/dist/api.d.ts +11 -10
  36. package/dist/api.mjs +16 -12
  37. package/dist/{app-manifest.d-BpKxiU_E.d.mts → app-manifest.d-CRmjN5j9.d.mts} +1 -1
  38. package/dist/{app-manifest.d-DDmNkYQQ.d.ts → app-manifest.d-CwfhGrVR.d.ts} +1 -1
  39. package/dist/app-markdown.cjs +5 -5
  40. package/dist/app-markdown.d.mts +7 -7
  41. package/dist/app-markdown.d.ts +7 -7
  42. package/dist/app-markdown.mjs +4 -4
  43. package/dist/{app.d-x68Cwr0_.d.ts → app.d-BX9LVTiP.d.ts} +50 -9
  44. package/dist/{app.d-kuoVWhWM.d.mts → app.d-uBBUxwyV.d.mts} +50 -9
  45. package/dist/{chunk-V56632LA.cjs → chunk-22IWL4YD.cjs} +19 -5
  46. package/dist/{chunk-RY4ABNPE.cjs → chunk-23PVOIPT.cjs} +3 -3
  47. package/dist/{chunk-5C7XMKQ4.cjs → chunk-2AFW7673.cjs} +6 -1
  48. package/dist/{chunk-SYW346ZN.cjs → chunk-2LHZD3OP.cjs} +1 -21
  49. package/dist/{chunk-ZZI56IUY.mjs → chunk-2ZOYOYEE.mjs} +13 -13
  50. package/dist/{chunk-RVGSVQWT.mjs → chunk-3T5TLFCQ.mjs} +10 -5
  51. package/dist/{chunk-XBSKPLHF.cjs → chunk-3T7ALZJF.cjs} +2 -2
  52. package/dist/{chunk-7ONGIFYX.cjs → chunk-4DRINDGN.cjs} +319 -138
  53. package/dist/{chunk-O6L3YYPM.cjs → chunk-4E57QHPW.cjs} +8 -16
  54. package/dist/{chunk-WKPBIT5Q.cjs → chunk-4HGLJOXZ.cjs} +6 -6
  55. package/dist/{chunk-JGAE5XPL.cjs → chunk-4JX3M4C6.cjs} +2 -1
  56. package/dist/{chunk-CJNAUEVC.mjs → chunk-4QENVMG7.mjs} +1 -1
  57. package/dist/{chunk-CHYTADNK.cjs → chunk-556H7JCE.cjs} +65 -48
  58. package/dist/{chunk-OLIGNTWU.cjs → chunk-5NFQ6AZI.cjs} +7 -7
  59. package/dist/{chunk-6HRAK7I5.mjs → chunk-5OFNUETM.mjs} +8 -2
  60. package/dist/{chunk-TZVUF5JJ.mjs → chunk-5TA63JD3.mjs} +4 -4
  61. package/dist/{chunk-RD623KW4.cjs → chunk-67MZTLTF.cjs} +21 -3
  62. package/dist/chunk-6I4BFRE7.cjs +51 -0
  63. package/dist/{chunk-4TVPYN32.cjs → chunk-6R53ZWX2.cjs} +7 -7
  64. package/dist/{chunk-MGKW5XZE.cjs → chunk-6SQZXRJ2.cjs} +7 -7
  65. package/dist/{chunk-MPJEIHW2.cjs → chunk-6V5YWI4W.cjs} +2 -2
  66. package/dist/{chunk-BM2LH2JM.mjs → chunk-6YBYX4K4.mjs} +13 -12
  67. package/dist/{chunk-X3XUZWRB.mjs → chunk-724MGMIL.mjs} +17 -3
  68. package/dist/{chunk-K5EW7GUU.mjs → chunk-7BIW7VCW.mjs} +13 -5
  69. package/dist/{chunk-HPP2II4Z.mjs → chunk-7PJARAQQ.mjs} +1 -1
  70. package/dist/{chunk-LEJDW34D.cjs → chunk-7PPLTD3P.cjs} +3 -3
  71. package/dist/{chunk-TGULJSHD.mjs → chunk-AJNBTOVQ.mjs} +20 -9
  72. package/dist/{chunk-FBEBSAVI.cjs → chunk-AKIQ54FK.cjs} +82 -63
  73. package/dist/{chunk-2NGZFOKG.mjs → chunk-AOIUYHPH.mjs} +2 -2
  74. package/dist/{chunk-ZEXE4TGY.mjs → chunk-AQDLVHNF.mjs} +230 -110
  75. package/dist/{chunk-NKRZLQUK.mjs → chunk-AQIO3RNL.mjs} +1 -1
  76. package/dist/chunk-AQIRXBBY.cjs +26 -0
  77. package/dist/chunk-AZ6IW6SF.mjs +28 -0
  78. package/dist/{chunk-QMDU6QHN.mjs → chunk-B6RBJJ5G.mjs} +1 -1
  79. package/dist/{chunk-I32V5CZL.cjs → chunk-BDYM2TN3.cjs} +28 -17
  80. package/dist/{chunk-JLDNXURZ.cjs → chunk-BZWTBELF.cjs} +32 -32
  81. package/dist/{chunk-ITV4QQL2.cjs → chunk-C6CUUBY5.cjs} +14 -3
  82. package/dist/{chunk-YN6BHOYY.cjs → chunk-CL52PD6D.cjs} +10 -3
  83. package/dist/{chunk-UBMHQVWN.mjs → chunk-CO3YMZFD.mjs} +1 -1
  84. package/dist/{chunk-XURDCXNH.cjs → chunk-CSLHNBPS.cjs} +6 -6
  85. package/dist/{chunk-CNNBFGL5.cjs → chunk-DB2HSHQA.cjs} +14 -14
  86. package/dist/{chunk-XQSYOVCW.cjs → chunk-DBYNZIIQ.cjs} +13 -5
  87. package/dist/{chunk-DVKH2RVN.cjs → chunk-DCXSIEFE.cjs} +40 -41
  88. package/dist/{chunk-D4MRNBVF.cjs → chunk-DGOFR7D5.cjs} +2 -2
  89. package/dist/{chunk-QTD6EMN2.mjs → chunk-DQ2DI3Y7.mjs} +11 -4
  90. package/dist/chunk-DXZ57EPE.mjs +375 -0
  91. package/dist/{chunk-SA7MLSP4.mjs → chunk-E3HDJCWF.mjs} +3 -3
  92. package/dist/{chunk-BYRZ5VTH.mjs → chunk-E6CD45JK.mjs} +30 -31
  93. package/dist/{chunk-752XUZIM.cjs → chunk-EGIY4A7V.cjs} +6 -6
  94. package/dist/chunk-EIVGPQN5.mjs +51 -0
  95. package/dist/{chunk-KPAJWD3N.mjs → chunk-EYPSKXO4.mjs} +1 -1
  96. package/dist/{chunk-E552H232.cjs → chunk-F43OG25P.cjs} +1 -1
  97. package/dist/{chunk-UAQD67HM.mjs → chunk-F7JKVHU2.mjs} +1 -1
  98. package/dist/{chunk-QISW423S.cjs → chunk-FPBOAG6N.cjs} +2 -2
  99. package/dist/{chunk-2C5L5RPM.cjs → chunk-FT6KJHS3.cjs} +71 -38
  100. package/dist/{chunk-ES2LD2YD.mjs → chunk-GCRT6GJG.mjs} +18 -0
  101. package/dist/{chunk-5OJVKXFV.cjs → chunk-GDM3ZD2O.cjs} +10 -8
  102. package/dist/{chunk-EMDGXYUD.mjs → chunk-GJ7QVFAG.mjs} +16 -7
  103. package/dist/{chunk-TGSEVBPO.mjs → chunk-GJEC5S4V.mjs} +11 -0
  104. package/dist/{chunk-672ISQIG.mjs → chunk-GTV2ABO7.mjs} +218 -37
  105. package/dist/{chunk-MPIGW42F.mjs → chunk-H37MDCPR.mjs} +1 -1
  106. package/dist/{chunk-HNAISJFD.cjs → chunk-HDPT6OYE.cjs} +9 -3
  107. package/dist/{chunk-25T5VXOE.mjs → chunk-HFHJJXSV.mjs} +106 -19
  108. package/dist/{chunk-ZNH6NR3H.cjs → chunk-HJZZSBVK.cjs} +2 -2
  109. package/dist/{chunk-BIF5MLTH.cjs → chunk-HM7AGSKU.cjs} +1 -1
  110. package/dist/{chunk-GL7N5UHF.cjs → chunk-HNVAZGQD.cjs} +20 -9
  111. package/dist/{chunk-SK7QSNWE.mjs → chunk-HP2DQGQH.mjs} +1 -1
  112. package/dist/{chunk-435QJNC2.mjs → chunk-HRPTMX5C.mjs} +4 -4
  113. package/dist/{chunk-K7OZAVOI.mjs → chunk-IFR74W6S.mjs} +46 -13
  114. package/dist/{chunk-5A77OEIG.cjs → chunk-IHTDLCDJ.cjs} +5 -5
  115. package/dist/{chunk-VQJHT2ND.mjs → chunk-IRA2CZAY.mjs} +2 -2
  116. package/dist/{chunk-OYZXVBZP.cjs → chunk-IUKBPBM7.cjs} +2 -1
  117. package/dist/chunk-J6TZRYCO.cjs +22 -0
  118. package/dist/{chunk-WYAXRIYP.cjs → chunk-J7JHVCWA.cjs} +8 -8
  119. package/dist/chunk-JSOCDYER.cjs +375 -0
  120. package/dist/{chunk-TKK5QHKZ.mjs → chunk-JVM3DKZE.mjs} +3 -3
  121. package/dist/{chunk-UPYIFH2H.cjs → chunk-JWLRBDDC.cjs} +2 -2
  122. package/dist/{chunk-BQWBHWEW.mjs → chunk-JWSI5WO4.mjs} +1 -1
  123. package/dist/{chunk-OLGQZRW6.mjs → chunk-JZBU7V4D.mjs} +37 -17
  124. package/dist/{chunk-ONG4RDW3.mjs → chunk-JZGL2PIH.mjs} +13 -3
  125. package/dist/chunk-K63OWRY2.mjs +22 -0
  126. package/dist/{chunk-TUPKMMXT.mjs → chunk-K6HIIWUB.mjs} +1 -1
  127. package/dist/{chunk-MESQF2JC.mjs → chunk-K6SXMVXO.mjs} +2 -2
  128. package/dist/{chunk-L2JG337G.cjs → chunk-K6VFYFOY.cjs} +33 -31
  129. package/dist/{chunk-3CCAICF7.cjs → chunk-KCY52OUQ.cjs} +4 -4
  130. package/dist/{chunk-EZ34EHQP.mjs → chunk-KI3MU7B5.mjs} +1 -1
  131. package/dist/{chunk-GHNW564E.mjs → chunk-KSZK34HU.mjs} +30 -10
  132. package/dist/{chunk-RFKTJTWZ.mjs → chunk-KWFNUODD.mjs} +2 -1
  133. package/dist/{chunk-ECKQFEX2.mjs → chunk-LENKRGBV.mjs} +8 -6
  134. package/dist/{chunk-752IHQTD.cjs → chunk-LPIZMU7D.cjs} +12 -12
  135. package/dist/{chunk-HEPJIKKQ.cjs → chunk-MCSRMEQV.cjs} +2 -2
  136. package/dist/{chunk-DQF3QLOH.mjs → chunk-ME7RVELR.mjs} +3 -2
  137. package/dist/{chunk-E4UDLFWR.cjs → chunk-N5DQMOAG.cjs} +588 -677
  138. package/dist/{chunk-O4F3JUST.mjs → chunk-NDDRTFN4.mjs} +4 -0
  139. package/dist/{chunk-CBOEJ5Z4.cjs → chunk-OB3IFUK6.cjs} +133 -46
  140. package/dist/{chunk-R62SF5R4.mjs → chunk-OB45EAQL.mjs} +6 -1
  141. package/dist/{chunk-SYXPWJ7N.cjs → chunk-OFBLGH6V.cjs} +17 -18
  142. package/dist/{chunk-VQ4NWOWO.mjs → chunk-OGVTUGMU.mjs} +5 -13
  143. package/dist/{chunk-3UZVPO72.mjs → chunk-OIOPQ25L.mjs} +6 -7
  144. package/dist/{chunk-2XGBJSDV.cjs → chunk-OO7DYIJD.cjs} +73 -24
  145. package/dist/{chunk-27FPUFWR.mjs → chunk-P2NBQ5JI.mjs} +1 -1
  146. package/dist/{chunk-HZPKJRYA.cjs → chunk-PDFFYZAT.cjs} +2 -2
  147. package/dist/{chunk-GSVJ3IIF.cjs → chunk-PHCJJJZV.cjs} +2 -2
  148. package/dist/{chunk-EVMXPJCB.mjs → chunk-PKMUQ7LM.mjs} +2 -1
  149. package/dist/{chunk-4OSOLDPL.cjs → chunk-PL6RTBDE.cjs} +2 -2
  150. package/dist/{chunk-OAJOQU5J.mjs → chunk-PLJKJJ2H.mjs} +82 -63
  151. package/dist/{chunk-WMTBBQHY.cjs → chunk-PPX7UOFY.cjs} +271 -151
  152. package/dist/{chunk-6XQSPIN6.cjs → chunk-PWKAX5MS.cjs} +13 -3
  153. package/dist/{chunk-7XGWBPQQ.cjs → chunk-Q37INCXG.cjs} +13 -8
  154. package/dist/{chunk-OP7LHY4Y.cjs → chunk-Q5UX55YA.cjs} +1445 -601
  155. package/dist/{chunk-NHQM2Q4I.cjs → chunk-QGQP6QKO.cjs} +2 -2
  156. package/dist/{chunk-IT6WRNGB.cjs → chunk-QITSS4TD.cjs} +1381 -626
  157. package/dist/{chunk-4ZJ5C7UJ.cjs → chunk-QIXEU2WV.cjs} +19 -10
  158. package/dist/{chunk-HCGWDRZO.mjs → chunk-QJVW76JG.mjs} +17 -6
  159. package/dist/{chunk-FJWN7RV4.cjs → chunk-QO43L7Z4.cjs} +38 -8
  160. package/dist/{chunk-ZIHWAN55.cjs → chunk-RE5E2G5S.cjs} +1 -1
  161. package/dist/chunk-RWR7SMD7.cjs +50 -0
  162. package/dist/{chunk-7PTISZSQ.cjs → chunk-S7MWSFFP.cjs} +4 -0
  163. package/dist/chunk-SD6JGJOM.mjs +50 -0
  164. package/dist/{chunk-7H4SVNC4.cjs → chunk-SPP3EZTJ.cjs} +46 -26
  165. package/dist/{chunk-E4RDMG3K.mjs → chunk-TEG6HJVF.mjs} +4 -4
  166. package/dist/{chunk-WAY6LOQH.mjs → chunk-TEJ67GD2.mjs} +1 -1
  167. package/dist/{chunk-IFTGERT3.mjs → chunk-TTXIITYA.mjs} +49 -0
  168. package/dist/{chunk-ZFWYCVKS.mjs → chunk-TY5KCYDE.mjs} +22 -4
  169. package/dist/{chunk-W2ZXMMHA.mjs → chunk-UHE5JUKB.mjs} +1 -1
  170. package/dist/{chunk-OB7VKCUZ.mjs → chunk-UHNSY2PQ.mjs} +1302 -458
  171. package/dist/{chunk-UJ3R2AH2.cjs → chunk-UPOYKX4S.cjs} +5 -5
  172. package/dist/{chunk-2DLGV2ZG.mjs → chunk-UTUS6JUH.mjs} +1 -21
  173. package/dist/{chunk-WVYRLP5E.mjs → chunk-V5MQMQ2P.mjs} +1 -1
  174. package/dist/{chunk-VBCQ5WOI.cjs → chunk-V5RTHYJB.cjs} +30 -10
  175. package/dist/{chunk-WFWFECDW.mjs → chunk-VK54PDQ6.mjs} +25 -5
  176. package/dist/{chunk-LQNW3ABP.cjs → chunk-VX2HZGC7.cjs} +14 -14
  177. package/dist/{chunk-XBSLKXBL.mjs → chunk-WDD5CTZW.mjs} +49 -32
  178. package/dist/{chunk-EMNKZGF4.mjs → chunk-WGHY3OL5.mjs} +354 -443
  179. package/dist/{chunk-A2MN5PQJ.mjs → chunk-WMLSZAKN.mjs} +9 -9
  180. package/dist/{chunk-3EEET2Q5.cjs → chunk-WUTFJOV7.cjs} +32 -12
  181. package/dist/chunk-WVQNXXNE.cjs +28 -0
  182. package/dist/{chunk-Y5TOT5F6.cjs → chunk-X3MHKLCO.cjs} +5 -5
  183. package/dist/{chunk-Z7P2BTZ3.cjs → chunk-XGTFLG73.cjs} +30 -12
  184. package/dist/{chunk-AZUUKA66.mjs → chunk-XNZWMXCF.mjs} +1090 -335
  185. package/dist/{chunk-FIR62CR3.mjs → chunk-XUES6OET.mjs} +1 -1
  186. package/dist/{chunk-XCXHQBMM.mjs → chunk-Y2LU4LE5.mjs} +1 -1
  187. package/dist/{chunk-5J45H65F.mjs → chunk-Y5LEPEVH.mjs} +1 -1
  188. package/dist/{chunk-BT4SEFLC.cjs → chunk-YAEN3L2F.cjs} +3 -2
  189. package/dist/chunk-YFTGIHNC.mjs +26 -0
  190. package/dist/{chunk-KL7SHLQB.mjs → chunk-YGJ5P3TJ.mjs} +31 -1
  191. package/dist/{chunk-O75GQVUK.mjs → chunk-YQYTQJZN.mjs} +1 -1
  192. package/dist/{chunk-X4K7TYN6.cjs → chunk-YVTS3S3F.cjs} +24 -23
  193. package/dist/{chunk-72KABRWN.mjs → chunk-ZJGFAW5U.mjs} +5 -3
  194. package/dist/{chunk-TNBJ4LZG.mjs → chunk-ZPKJPM7K.mjs} +4 -4
  195. package/dist/client/lifecycle.cjs +2 -2
  196. package/dist/client/lifecycle.d.mts +1 -1
  197. package/dist/client/lifecycle.d.ts +1 -1
  198. package/dist/client/lifecycle.mjs +1 -1
  199. package/dist/{client-component.d-D74pqdea.d.mts → client-component.d-CDRvRmbU.d.mts} +2 -2
  200. package/dist/{client-component.d-D8VcypQA.d.ts → client-component.d-DWRKyAp5.d.ts} +2 -2
  201. package/dist/client-plugins.cjs +2 -2
  202. package/dist/{client-plugins.d-D4-6hNx7.d.mts → client-plugins.d-BNILjfX3.d.mts} +94 -140
  203. package/dist/{client-plugins.d-CXElzotB.d.ts → client-plugins.d-CrKZiNSN.d.ts} +94 -140
  204. package/dist/client-plugins.d.mts +6 -6
  205. package/dist/client-plugins.d.ts +6 -6
  206. package/dist/client-plugins.mjs +1 -1
  207. package/dist/client.cjs +11 -9
  208. package/dist/client.d.mts +13 -13
  209. package/dist/client.d.ts +13 -13
  210. package/dist/client.mjs +10 -8
  211. package/dist/{config.d-qt-mE8O5.d.mts → config.d-BKIhJtmr.d.mts} +7 -2
  212. package/dist/{config.d-qt-mE8O5.d.ts → config.d-BKIhJtmr.d.ts} +7 -2
  213. package/dist/config.d.mts +6 -6
  214. package/dist/config.d.ts +6 -6
  215. package/dist/cron.cjs +2 -2
  216. package/dist/cron.mjs +1 -1
  217. package/dist/deferred.cjs +2 -2
  218. package/dist/deferred.mjs +1 -1
  219. package/dist/deployment.cjs +2 -2
  220. package/dist/deployment.mjs +1 -1
  221. package/dist/desktop.d.mts +7 -7
  222. package/dist/desktop.d.ts +7 -7
  223. package/dist/{devtools-N2JQCMXB.cjs → devtools-RZVT4JVN.cjs} +36 -32
  224. package/dist/{devtools-NZUVNUP3.mjs → devtools-UFQYT3VA.mjs} +31 -27
  225. package/dist/docs.cjs +26 -25
  226. package/dist/docs.d.mts +20 -8
  227. package/dist/docs.d.ts +20 -8
  228. package/dist/docs.mjs +25 -24
  229. package/dist/env-types.cjs +3 -3
  230. package/dist/env-types.mjs +2 -2
  231. package/dist/environment/vite.cjs +5 -5
  232. package/dist/environment/vite.mjs +4 -4
  233. package/dist/headers.cjs +3 -3
  234. package/dist/headers.mjs +2 -2
  235. package/dist/image/server.d.mts +1 -1
  236. package/dist/image/server.d.ts +1 -1
  237. package/dist/image/sharp.d.mts +1 -1
  238. package/dist/image/sharp.d.ts +1 -1
  239. package/dist/{image-config.d-CeDgNyX4.d.mts → image-config.d-ByhQ0TT7.d.mts} +3 -1
  240. package/dist/{image-config.d-CeDgNyX4.d.ts → image-config.d-ByhQ0TT7.d.ts} +3 -1
  241. package/dist/image.cjs +6 -6
  242. package/dist/image.d.mts +1 -1
  243. package/dist/image.d.ts +1 -1
  244. package/dist/image.mjs +1 -1
  245. package/dist/index.cjs +142 -127
  246. package/dist/{index.d-SSgYDv4D.d.mts → index.d-Bdm6866n.d.mts} +1 -1
  247. package/dist/{index.d-A_x10zGS.d.ts → index.d-Dey5T14f.d.ts} +1 -1
  248. package/dist/index.d.mts +31 -82
  249. package/dist/index.d.ts +31 -82
  250. package/dist/index.mjs +213 -198
  251. package/dist/{integration-orm-52GPGTHO.cjs → integrations/orm.cjs} +5 -5
  252. package/dist/integrations/orm.d.mts +33 -0
  253. package/dist/integrations/orm.d.ts +33 -0
  254. package/dist/{integration-orm-CO23MSFE.mjs → integrations/orm.mjs} +5 -5
  255. package/dist/integrations.cjs +6 -5
  256. package/dist/integrations.d.mts +6 -6
  257. package/dist/integrations.d.ts +6 -6
  258. package/dist/integrations.mjs +5 -4
  259. package/dist/internal/app-markdown-runtime.cjs +4 -4
  260. package/dist/internal/app-markdown-runtime.d.mts +17 -8
  261. package/dist/internal/app-markdown-runtime.d.ts +17 -8
  262. package/dist/internal/app-markdown-runtime.mjs +3 -3
  263. package/dist/internal/build-runtime.cjs +68 -66
  264. package/dist/internal/build-runtime.d.mts +8 -8
  265. package/dist/internal/build-runtime.d.ts +8 -8
  266. package/dist/internal/build-runtime.mjs +67 -65
  267. package/dist/internal/cli-runtime.cjs +45 -44
  268. package/dist/internal/cli-runtime.mjs +44 -43
  269. package/dist/internal/client-error-overlay.cjs +6 -6
  270. package/dist/internal/client-error-overlay.mjs +2 -2
  271. package/dist/internal/client-runtime.cjs +60 -6
  272. package/dist/internal/client-runtime.d.mts +40 -11
  273. package/dist/internal/client-runtime.d.ts +40 -11
  274. package/dist/internal/client-runtime.mjs +58 -4
  275. package/dist/internal/compression-runtime.d.mts +6 -6
  276. package/dist/internal/compression-runtime.d.ts +6 -6
  277. package/dist/internal/config-runtime.cjs +25 -24
  278. package/dist/internal/config-runtime.d.mts +9 -9
  279. package/dist/internal/config-runtime.d.ts +9 -9
  280. package/dist/internal/config-runtime.mjs +24 -23
  281. package/dist/internal/docs-precompiled-runtime.cjs +16 -5
  282. package/dist/internal/docs-precompiled-runtime.d.mts +7 -0
  283. package/dist/internal/docs-precompiled-runtime.d.ts +7 -0
  284. package/dist/internal/docs-precompiled-runtime.mjs +15 -4
  285. package/dist/internal/infra-analytics-runtime.cjs +11 -11
  286. package/dist/internal/infra-analytics-runtime.mjs +9 -9
  287. package/dist/internal/islands-runtime.cjs +33 -4
  288. package/dist/internal/islands-runtime.d.mts +1 -1
  289. package/dist/internal/islands-runtime.d.ts +1 -1
  290. package/dist/internal/islands-runtime.mjs +31 -2
  291. package/dist/internal/native-server-fns.cjs +5 -5
  292. package/dist/internal/native-server-fns.mjs +4 -4
  293. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  294. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  295. package/dist/internal/production-runtime.cjs +53 -39
  296. package/dist/internal/production-runtime.d.mts +16 -15
  297. package/dist/internal/production-runtime.d.ts +16 -15
  298. package/dist/internal/production-runtime.mjs +68 -54
  299. package/dist/internal/react-cache.cjs +3 -3
  300. package/dist/internal/react-cache.mjs +1 -1
  301. package/dist/{lifecycle.d-C2aLBOwu.d.ts → lifecycle.d-keQs5Swc.d.mts} +7 -1
  302. package/dist/{lifecycle.d-C2aLBOwu.d.mts → lifecycle.d-keQs5Swc.d.ts} +7 -1
  303. package/dist/{manager-H5ZM3HAM.mjs → manager-JIA66YJ2.mjs} +4 -3
  304. package/dist/manager-JOHU6BQI.cjs +15 -0
  305. package/dist/markdown.cjs +7 -3
  306. package/dist/markdown.d.mts +6 -6
  307. package/dist/markdown.d.ts +6 -6
  308. package/dist/markdown.mjs +6 -2
  309. package/dist/middleware.cjs +10 -10
  310. package/dist/middleware.d.mts +8 -8
  311. package/dist/middleware.d.ts +8 -8
  312. package/dist/middleware.mjs +9 -9
  313. package/dist/mobile.d.mts +4 -4
  314. package/dist/mobile.d.ts +4 -4
  315. package/dist/mount.d-BP0nLYQO.d.mts +38 -0
  316. package/dist/mount.d-CkiPky_F.d.ts +38 -0
  317. package/dist/{native-server-fn-handler-GLRHAYWV.mjs → native-server-fn-handler-EP5AFJYE.mjs} +5 -5
  318. package/dist/{native-server-fn-handler-J5MYRXN6.cjs → native-server-fn-handler-QRTXGZA4.cjs} +6 -6
  319. package/dist/{native-tree-7LPH57Z4.cjs → native-tree-W2SSJB3Y.cjs} +4 -4
  320. package/dist/{native-tree-VV6WN3GX.mjs → native-tree-Y5YQANW7.mjs} +3 -3
  321. package/dist/{navigation-delegate.d-DQVYKoaZ.d.mts → navigation-delegate.d-CdBP-hkZ.d.mts} +1 -1
  322. package/dist/{navigation-delegate.d-GghbHJuK.d.ts → navigation-delegate.d-DchcGzAQ.d.ts} +1 -1
  323. package/dist/navigation.cjs +8 -7
  324. package/dist/navigation.d.mts +9 -9
  325. package/dist/navigation.d.ts +9 -9
  326. package/dist/navigation.mjs +7 -6
  327. package/dist/{nitro-DD4QCA66.mjs → nitro-55YOZWRA.mjs} +11 -11
  328. package/dist/{nitro-VRDX2H4M.cjs → nitro-EEX2J3KB.cjs} +13 -13
  329. package/dist/{plugin-53SY5YBS.mjs → plugin-SAS22JL7.mjs} +4 -3
  330. package/dist/{plugin-HZIBL3DW.cjs → plugin-WIU4GDD4.cjs} +5 -4
  331. package/dist/plugin.cjs +61 -59
  332. package/dist/plugin.d.mts +8 -8
  333. package/dist/plugin.d.ts +8 -8
  334. package/dist/plugin.mjs +60 -58
  335. package/dist/{production-runtime.d-Bzns3NW9.d.ts → production-runtime.d-Dou_Htas.d.ts} +1 -1
  336. package/dist/{production-runtime.d-DiFa5vHW.d.mts → production-runtime.d-VwsBzIee.d.mts} +1 -1
  337. package/dist/query/client.cjs +9 -7
  338. package/dist/query/client.mjs +5 -3
  339. package/dist/{render-plan.d-CL_Ikfg_.d.ts → render-plan.d-D8UakAIk.d.ts} +1 -1
  340. package/dist/{render-plan.d-CcF0MeCf.d.mts → render-plan.d-LKymStDJ.d.mts} +1 -1
  341. package/dist/renderer/none/server.cjs +35 -0
  342. package/dist/renderer/none/server.d.mts +21 -0
  343. package/dist/renderer/none/server.d.ts +21 -0
  344. package/dist/renderer/none/server.mjs +35 -0
  345. package/dist/renderer/react/server.cjs +2 -2
  346. package/dist/renderer/react/server.mjs +3 -3
  347. package/dist/renderer-client.cjs +8 -6
  348. package/dist/renderer-client.d.mts +9 -9
  349. package/dist/renderer-client.d.ts +9 -9
  350. package/dist/renderer-client.mjs +5 -3
  351. package/dist/renderer.cjs +6 -2
  352. package/dist/renderer.d.mts +20 -2
  353. package/dist/renderer.d.ts +20 -2
  354. package/dist/renderer.mjs +5 -1
  355. package/dist/request.cjs +2 -2
  356. package/dist/{request.d-B1RnTLri.d.ts → request.d-B928QjWy.d.ts} +1 -1
  357. package/dist/{request.d-DarDOCk9.d.mts → request.d-KG-4d2eG.d.mts} +1 -1
  358. package/dist/request.d.mts +7 -7
  359. package/dist/request.d.ts +7 -7
  360. package/dist/request.mjs +1 -1
  361. package/dist/{route-rendering.d-BTUYCIj4.d.ts → route-rendering.d-DoEe_w9t.d.ts} +1 -1
  362. package/dist/{route-rendering.d-D_2Ual0-.d.mts → route-rendering.d-NIHQeb4m.d.mts} +1 -1
  363. package/dist/{route.d-BaVH3V0w.d.mts → route.d-DrXkpvcg.d.mts} +1 -1
  364. package/dist/{route.d-DBTEqifW.d.ts → route.d-hs-_cyHn.d.ts} +1 -1
  365. package/dist/{router.d-Cuv1jntg.d.mts → router.d-B8PkJSGp.d.mts} +1 -1
  366. package/dist/{router.d-CMANF6da.d.ts → router.d-DYnRHQwz.d.ts} +1 -1
  367. package/dist/routes.cjs +3 -3
  368. package/dist/{routes.d-c2HKfrfL.d.mts → routes.d-DgZ_jgGG.d.mts} +1 -1
  369. package/dist/{routes.d-B6yFe6jm.d.ts → routes.d-uUBZyWoK.d.ts} +1 -1
  370. package/dist/routes.d.mts +6 -6
  371. package/dist/routes.d.ts +6 -6
  372. package/dist/routes.mjs +2 -2
  373. package/dist/{rsc-pipeline-7PNVJSTR.mjs → rsc-pipeline-4OJ5ZQNZ.mjs} +26 -25
  374. package/dist/{rsc-pipeline-Z7QBZOIJ.cjs → rsc-pipeline-7K5H2RPH.cjs} +27 -26
  375. package/dist/{runtime-QQHX4BP3.mjs → runtime-U7O3HZOZ.mjs} +60 -34
  376. package/dist/{runtime-FKFCUHSK.cjs → runtime-X52Q7JFR.cjs} +70 -44
  377. package/dist/{runtime.d-wvh4ngU0.d.mts → runtime.d-BxQIzwfy.d.mts} +11 -3
  378. package/dist/{runtime.d-C3RQUj6_.d.ts → runtime.d-DP7mEkEF.d.ts} +11 -3
  379. package/dist/{schema-dev-notice-JMXEQWIQ.mjs → schema-dev-notice-C2JINRZI.mjs} +3 -2
  380. package/dist/{schema-dev-notice-PLBFDTOF.cjs → schema-dev-notice-X7GG7QVB.cjs} +5 -4
  381. package/dist/schema.cjs +6 -2
  382. package/dist/schema.d-Dny9pnrm.d.mts +298 -0
  383. package/dist/schema.d-Dny9pnrm.d.ts +298 -0
  384. package/dist/schema.d.mts +1 -115
  385. package/dist/schema.d.ts +1 -115
  386. package/dist/schema.mjs +5 -1
  387. package/dist/server-fn-client.d.mts +2 -2
  388. package/dist/server-fn-client.d.ts +2 -2
  389. package/dist/server-fn.cjs +5 -5
  390. package/dist/server-fn.mjs +4 -4
  391. package/dist/server-plugins.cjs +7 -7
  392. package/dist/server-plugins.d.mts +16 -10
  393. package/dist/server-plugins.d.ts +16 -10
  394. package/dist/server-plugins.mjs +8 -8
  395. package/dist/server-query.cjs +6 -6
  396. package/dist/server-query.mjs +5 -5
  397. package/dist/server.cjs +160 -120
  398. package/dist/server.d.mts +20 -14
  399. package/dist/server.d.ts +20 -14
  400. package/dist/server.mjs +138 -98
  401. package/dist/{spa-router.d-WU_qS5gJ.d.mts → spa-router.d-BgHPVMhz.d.mts} +15 -5
  402. package/dist/{spa-router.d-m8H_Kl_B.d.ts → spa-router.d-DsFDHTsv.d.ts} +15 -5
  403. package/dist/testing.cjs +17 -17
  404. package/dist/testing.d.mts +6 -6
  405. package/dist/testing.d.ts +6 -6
  406. package/dist/testing.mjs +13 -13
  407. package/dist/theme/server.cjs +3 -3
  408. package/dist/theme/server.mjs +2 -2
  409. package/dist/{utils.d-W9IiEqmW.d.mts → utils.d-BKyKDBR1.d.mts} +1 -1
  410. package/dist/{utils.d-C9dQD5Zg.d.ts → utils.d-zxAVcf_V.d.ts} +1 -1
  411. package/dist/version.cjs +2 -2
  412. package/dist/version.mjs +1 -1
  413. package/dist/vite.cjs +63 -61
  414. package/dist/vite.d.mts +32 -12
  415. package/dist/vite.d.ts +32 -12
  416. package/dist/vite.mjs +62 -60
  417. package/dist/workflows.cjs +4 -4
  418. package/dist/workflows.mjs +3 -3
  419. package/package.json +31 -1
  420. package/dist/analyzer-H7SIX6BJ.cjs +0 -16
  421. package/dist/chunk-5YPBFMBN.cjs +0 -19
  422. package/dist/chunk-OM7WILES.mjs +0 -100
  423. package/dist/chunk-Q5B4LNON.mjs +0 -19
  424. package/dist/chunk-QPJ4MZTO.mjs +0 -60
  425. package/dist/chunk-R53QDV6T.cjs +0 -100
  426. package/dist/chunk-UYTAP4FQ.cjs +0 -60
  427. package/dist/manager-2LUKNX2N.cjs +0 -14
  428. /package/dist/{chunk-QGOZLGVP.mjs → chunk-I6FIAWNT.mjs} +0 -0
  429. /package/dist/{chunk-XPIPMWY3.cjs → chunk-K5NI5YQR.cjs} +0 -0
  430. /package/dist/{chunk-NWUHS6GV.cjs → chunk-QEJWNXRI.cjs} +0 -0
  431. /package/dist/{chunk-FSXSQQTV.mjs → chunk-TXE4SAMV.mjs} +0 -0
  432. /package/dist/{chunk-ZXK2EYQW.cjs → chunk-UUQNJDGH.cjs} +0 -0
  433. /package/dist/{chunk-46P5KNTE.mjs → chunk-VZBAW44S.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
@@ -27,39 +27,40 @@ var _chunk5IQ2ERQAcjs = require('./chunk-5IQ2ERQA.cjs');
27
27
 
28
28
 
29
29
 
30
+ var _chunkN5DQMOAGcjs = require('./chunk-N5DQMOAG.cjs');
30
31
 
31
- var _chunkE4UDLFWRcjs = require('./chunk-E4UDLFWR.cjs');
32
32
 
33
33
 
34
- var _chunkR53QDV6Tcjs = require('./chunk-R53QDV6T.cjs');
34
+ var _chunkJSOCDYERcjs = require('./chunk-JSOCDYER.cjs');
35
35
 
36
36
 
37
- var _chunk3EEET2Q5cjs = require('./chunk-3EEET2Q5.cjs');
37
+ var _chunkWUTFJOV7cjs = require('./chunk-WUTFJOV7.cjs');
38
38
 
39
39
 
40
- var _chunkAQLHD6HZcjs = require('./chunk-AQLHD6HZ.cjs');
41
40
 
41
+ var _chunkYVTS3S3Fcjs = require('./chunk-YVTS3S3F.cjs');
42
42
 
43
43
 
44
- var _chunkX4K7TYN6cjs = require('./chunk-X4K7TYN6.cjs');
44
+ var _chunkAQLHD6HZcjs = require('./chunk-AQLHD6HZ.cjs');
45
45
 
46
46
 
47
47
 
48
48
 
49
+ var _chunkPIUTGRDIcjs = require('./chunk-PIUTGRDI.cjs');
49
50
 
50
51
 
51
52
 
52
53
 
53
54
 
54
55
 
55
- var _chunkUJ3R2AH2cjs = require('./chunk-UJ3R2AH2.cjs');
56
56
 
57
57
 
58
- var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
59
58
 
60
59
 
60
+ var _chunkUPOYKX4Scjs = require('./chunk-UPOYKX4S.cjs');
61
61
 
62
62
 
63
+ var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
63
64
 
64
65
 
65
66
 
@@ -70,18 +71,17 @@ var _chunk3HLQTOVUcjs = require('./chunk-3HLQTOVU.cjs');
70
71
 
71
72
 
72
73
 
73
- var _chunk752IHQTDcjs = require('./chunk-752IHQTD.cjs');
74
74
 
75
75
 
76
- var _chunkY5TOT5F6cjs = require('./chunk-Y5TOT5F6.cjs');
77
76
 
78
77
 
79
- var _chunkMPJEIHW2cjs = require('./chunk-MPJEIHW2.cjs');
78
+ var _chunkLPIZMU7Dcjs = require('./chunk-LPIZMU7D.cjs');
80
79
 
81
80
 
81
+ var _chunkX3MHKLCOcjs = require('./chunk-X3MHKLCO.cjs');
82
82
 
83
83
 
84
- var _chunkPIUTGRDIcjs = require('./chunk-PIUTGRDI.cjs');
84
+ var _chunk6V5YWI4Wcjs = require('./chunk-6V5YWI4W.cjs');
85
85
 
86
86
 
87
87
  var _chunk7EPYN7GWcjs = require('./chunk-7EPYN7GW.cjs');
@@ -110,7 +110,10 @@ var _chunk7EPYN7GWcjs = require('./chunk-7EPYN7GW.cjs');
110
110
 
111
111
 
112
112
 
113
- var _chunk7ONGIFYXcjs = require('./chunk-7ONGIFYX.cjs');
113
+
114
+
115
+
116
+ var _chunk4DRINDGNcjs = require('./chunk-4DRINDGN.cjs');
114
117
 
115
118
 
116
119
 
@@ -124,6 +127,9 @@ var _chunkERMUL73Lcjs = require('./chunk-ERMUL73L.cjs');
124
127
  var _chunkUVV3I5QAcjs = require('./chunk-UVV3I5QA.cjs');
125
128
 
126
129
 
130
+ var _chunk22IWL4YDcjs = require('./chunk-22IWL4YD.cjs');
131
+
132
+
127
133
 
128
134
 
129
135
  var _chunkSTF6VDYQcjs = require('./chunk-STF6VDYQ.cjs');
@@ -131,13 +137,13 @@ var _chunkSTF6VDYQcjs = require('./chunk-STF6VDYQ.cjs');
131
137
 
132
138
 
133
139
 
134
- var _chunkO6L3YYPMcjs = require('./chunk-O6L3YYPM.cjs');
140
+ var _chunk4E57QHPWcjs = require('./chunk-4E57QHPW.cjs');
135
141
 
136
142
 
137
- var _chunkFJWN7RV4cjs = require('./chunk-FJWN7RV4.cjs');
143
+ var _chunkQO43L7Z4cjs = require('./chunk-QO43L7Z4.cjs');
138
144
 
139
145
 
140
- var _chunkZIHWAN55cjs = require('./chunk-ZIHWAN55.cjs');
146
+ var _chunkRE5E2G5Scjs = require('./chunk-RE5E2G5S.cjs');
141
147
 
142
148
 
143
149
 
@@ -151,20 +157,20 @@ var _chunk5Y2P454Ocjs = require('./chunk-5Y2P454O.cjs');
151
157
 
152
158
 
153
159
 
154
- var _chunkRD623KW4cjs = require('./chunk-RD623KW4.cjs');
155
160
 
161
+ var _chunk67MZTLTFcjs = require('./chunk-67MZTLTF.cjs');
156
162
 
157
163
 
158
- var _chunkHEPJIKKQcjs = require('./chunk-HEPJIKKQ.cjs');
159
164
 
165
+ var _chunkMCSRMEQVcjs = require('./chunk-MCSRMEQV.cjs');
160
166
 
161
- var _chunk3EIPOTZVcjs = require('./chunk-3EIPOTZV.cjs');
162
167
 
168
+ var _chunk3EIPOTZVcjs = require('./chunk-3EIPOTZV.cjs');
163
169
 
164
170
 
165
171
 
166
- var _chunk7XGWBPQQcjs = require('./chunk-7XGWBPQQ.cjs');
167
172
 
173
+ var _chunkQ37INCXGcjs = require('./chunk-Q37INCXG.cjs');
168
174
 
169
175
 
170
176
 
@@ -172,21 +178,21 @@ var _chunk7XGWBPQQcjs = require('./chunk-7XGWBPQQ.cjs');
172
178
 
173
179
 
174
180
 
175
- var _chunk2C5L5RPMcjs = require('./chunk-2C5L5RPM.cjs');
181
+ var _chunkFT6KJHS3cjs = require('./chunk-FT6KJHS3.cjs');
176
182
 
177
183
 
178
184
 
179
- var _chunkX333W5KVcjs = require('./chunk-X333W5KV.cjs');
180
185
 
181
186
 
182
187
 
188
+ var _chunkBDYM2TN3cjs = require('./chunk-BDYM2TN3.cjs');
183
189
 
184
190
 
185
191
 
186
- var _chunkI32V5CZLcjs = require('./chunk-I32V5CZL.cjs');
192
+ var _chunkX333W5KVcjs = require('./chunk-X333W5KV.cjs');
187
193
 
188
194
 
189
- var _chunkLQNW3ABPcjs = require('./chunk-LQNW3ABP.cjs');
195
+ var _chunkVX2HZGC7cjs = require('./chunk-VX2HZGC7.cjs');
190
196
 
191
197
 
192
198
 
@@ -202,7 +208,7 @@ var _chunkKBGZ5FD6cjs = require('./chunk-KBGZ5FD6.cjs');
202
208
  var _chunkP2355C6Ecjs = require('./chunk-P2355C6E.cjs');
203
209
 
204
210
 
205
- var _chunkSYXPWJ7Ncjs = require('./chunk-SYXPWJ7N.cjs');
211
+ var _chunkOFBLGH6Vcjs = require('./chunk-OFBLGH6V.cjs');
206
212
 
207
213
 
208
214
  var _chunkRVGLYMJMcjs = require('./chunk-RVGLYMJM.cjs');
@@ -212,7 +218,9 @@ var _chunkRVGLYMJMcjs = require('./chunk-RVGLYMJM.cjs');
212
218
  var _chunkKORZ6PREcjs = require('./chunk-KORZ6PRE.cjs');
213
219
 
214
220
 
215
- var _chunkZ7P2BTZ3cjs = require('./chunk-Z7P2BTZ3.cjs');
221
+
222
+
223
+ var _chunkXGTFLG73cjs = require('./chunk-XGTFLG73.cjs');
216
224
 
217
225
 
218
226
  var _chunkLRB5OVRTcjs = require('./chunk-LRB5OVRT.cjs');
@@ -228,6 +236,11 @@ var _chunkY3WG64CPcjs = require('./chunk-Y3WG64CP.cjs');
228
236
 
229
237
 
230
238
 
239
+ var _chunkYIHRZBD7cjs = require('./chunk-YIHRZBD7.cjs');
240
+
241
+
242
+
243
+
231
244
  var _chunkJYNNIGQOcjs = require('./chunk-JYNNIGQO.cjs');
232
245
 
233
246
 
@@ -240,33 +253,32 @@ var _chunkLNVGXUL3cjs = require('./chunk-LNVGXUL3.cjs');
240
253
  var _chunkQMNWKQL4cjs = require('./chunk-QMNWKQL4.cjs');
241
254
 
242
255
 
243
-
244
- var _chunkSUCDVKUBcjs = require('./chunk-SUCDVKUB.cjs');
256
+ var _chunk2OF5RPVUcjs = require('./chunk-2OF5RPVU.cjs');
245
257
 
246
258
 
247
259
 
248
- var _chunkEVIWKPJVcjs = require('./chunk-EVIWKPJV.cjs');
249
260
 
250
261
 
251
262
 
263
+ var _chunkCFG4QERRcjs = require('./chunk-CFG4QERR.cjs');
252
264
 
253
- var _chunkYIHRZBD7cjs = require('./chunk-YIHRZBD7.cjs');
254
265
 
255
266
 
256
- var _chunk2OF5RPVUcjs = require('./chunk-2OF5RPVU.cjs');
267
+ var _chunkSUCDVKUBcjs = require('./chunk-SUCDVKUB.cjs');
257
268
 
258
269
 
259
270
 
271
+ var _chunkEVIWKPJVcjs = require('./chunk-EVIWKPJV.cjs');
260
272
 
261
273
 
274
+ var _chunkHM7AGSKUcjs = require('./chunk-HM7AGSKU.cjs');
262
275
 
263
- var _chunkCFG4QERRcjs = require('./chunk-CFG4QERR.cjs');
264
276
 
277
+ var _chunkPMJSG4JScjs = require('./chunk-PMJSG4JS.cjs');
265
278
 
266
- var _chunkBIF5MLTHcjs = require('./chunk-BIF5MLTH.cjs');
267
279
 
268
280
 
269
- var _chunkPMJSG4JScjs = require('./chunk-PMJSG4JS.cjs');
281
+ var _chunkRWR7SMD7cjs = require('./chunk-RWR7SMD7.cjs');
270
282
 
271
283
 
272
284
 
@@ -276,19 +288,24 @@ var _chunk6IOZPJ3Icjs = require('./chunk-6IOZPJ3I.cjs');
276
288
 
277
289
 
278
290
 
279
- var _chunkE552H232cjs = require('./chunk-E552H232.cjs');
280
291
 
292
+ var _chunkF43OG25Pcjs = require('./chunk-F43OG25P.cjs');
281
293
 
282
- var _chunkXQSYOVCWcjs = require('./chunk-XQSYOVCW.cjs');
294
+
295
+ var _chunkDBYNZIIQcjs = require('./chunk-DBYNZIIQ.cjs');
283
296
 
284
297
 
285
- var _chunkUYTAP4FQcjs = require('./chunk-UYTAP4FQ.cjs');
286
298
 
287
299
 
288
- var _chunk7JUIK547cjs = require('./chunk-7JUIK547.cjs');
289
300
 
301
+ var _chunkAKIQ54FKcjs = require('./chunk-AKIQ54FK.cjs');
290
302
 
291
- var _chunkHNAISJFDcjs = require('./chunk-HNAISJFD.cjs');
303
+
304
+
305
+ var _chunkHDPT6OYEcjs = require('./chunk-HDPT6OYE.cjs');
306
+
307
+
308
+ var _chunk7JUIK547cjs = require('./chunk-7JUIK547.cjs');
292
309
 
293
310
 
294
311
 
@@ -300,7 +317,7 @@ var _chunkBTZ5O6VMcjs = require('./chunk-BTZ5O6VM.cjs');
300
317
  // src/form-actions-transform.ts
301
318
  var _crypto = require('crypto');
302
319
  var _compiler = require('@farm.js/islx/compiler');
303
- var _path = require('path'); var path2 = _interopRequireWildcard(_path); var path6 = _interopRequireWildcard(_path); var path3 = _interopRequireWildcard(_path);
320
+ var _path2 = require('path'); var path2 = _interopRequireWildcard(_path2); var path6 = _interopRequireWildcard(_path2); var path3 = _interopRequireWildcard(_path2);
304
321
  function transformFarmFormActionModule(options) {
305
322
  const result = _compiler.transformActions.call(void 0, {
306
323
  code: options.code,
@@ -318,6 +335,7 @@ function transformFarmFormActionModule(options) {
318
335
 
319
336
  // src/vite.ts
320
337
  var _vite = require('vite');
338
+ var _async_hooks = require('async_hooks');
321
339
  var _module = require('module');
322
340
 
323
341
  // src/dev-preview-guard.ts
@@ -393,8 +411,7 @@ async function isAllowedPreviewRequest(server, options, req) {
393
411
  if (server.config.publicDir && isInside(await realpathOr(server.config.publicDir), file)) {
394
412
  return true;
395
413
  }
396
- const isModuleOrAsset = MODULE_EXTENSION.test(file) || ASSET_EXTENSION.test(file) || query.has("import");
397
- if (!isModuleOrAsset) return false;
414
+ if (!MODULE_EXTENSION.test(file) && !ASSET_EXTENSION.test(file)) return false;
398
415
  for (const source of options.getSourceRoots()) {
399
416
  const sourceRoot = await realpathOr(source.root);
400
417
  const sourceDir = await realpathOr(path2.resolve(source.root, source.srcDir));
@@ -436,8 +453,40 @@ async function realpathOr(directory) {
436
453
  }
437
454
  }
438
455
  function isInside(directory, file) {
439
- const relative2 = path2.relative(directory, file);
440
- return relative2 !== "" && relative2 !== ".." && !relative2.startsWith(`..${path2.sep}`) && !path2.isAbsolute(relative2);
456
+ const relative3 = path2.relative(directory, file);
457
+ return relative3 !== "" && relative3 !== ".." && !relative3.startsWith(`..${path2.sep}`) && !path2.isAbsolute(relative3);
458
+ }
459
+
460
+ // src/server/dev-cors.ts
461
+ var VITE_DEFAULT_CORS_ORIGIN = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
462
+ var VITE_DEFAULT_CORS_METHODS = "GET,HEAD,PUT,PATCH,POST,DELETE";
463
+ function appendVary(res, value) {
464
+ const current = res.getHeader("Vary");
465
+ const values = String(_nullishCoalesce(current, () => ( ""))).split(",").map((entry) => entry.trim()).filter(Boolean);
466
+ if (values.includes("*") || values.some((entry) => entry.toLowerCase() === value.toLowerCase())) {
467
+ return;
468
+ }
469
+ res.setHeader("Vary", [...values, value].join(", "));
470
+ }
471
+ function createFarmDevViteCorsMiddleware() {
472
+ return function farmDevViteCors(req, res, next) {
473
+ const origin = req.headers.origin;
474
+ if (typeof origin === "string" && VITE_DEFAULT_CORS_ORIGIN.test(origin) && !res.hasHeader("Access-Control-Allow-Origin")) {
475
+ res.setHeader("Access-Control-Allow-Origin", origin);
476
+ }
477
+ appendVary(res, "Origin");
478
+ if (_optionalChain([req, 'access', _16 => _16.method, 'optionalAccess', _17 => _17.toUpperCase, 'call', _18 => _18()]) !== "OPTIONS") {
479
+ next();
480
+ return;
481
+ }
482
+ res.setHeader("Access-Control-Allow-Methods", VITE_DEFAULT_CORS_METHODS);
483
+ appendVary(res, "Access-Control-Request-Headers");
484
+ const requestHeaders = req.headers["access-control-request-headers"];
485
+ if (requestHeaders) res.setHeader("Access-Control-Allow-Headers", requestHeaders);
486
+ res.statusCode = 204;
487
+ res.setHeader("Content-Length", "0");
488
+ res.end();
489
+ };
441
490
  }
442
491
 
443
492
  // src/vite.ts
@@ -448,13 +497,87 @@ var _url = require('url');
448
497
  // src/dev-static.ts
449
498
 
450
499
 
451
- function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs, generatedPaths = []) {
500
+ function shouldBypassFarmRouterForDottedPath(pathname, routeManager, baseDirs, generatedPaths = [], method = "GET") {
452
501
  if (!pathname.includes(".") || pathname.endsWith(".html")) return false;
453
502
  const matchesAppRoute = Boolean(
454
- _optionalChain([routeManager, 'optionalAccess', _16 => _16.matchRoute, 'call', _17 => _17(pathname), 'optionalAccess', _18 => _18.route]) || _optionalChain([routeManager, 'optionalAccess', _19 => _19.matchMetadataRoute, 'call', _20 => _20(pathname)]) || _optionalChain([routeManager, 'optionalAccess', _21 => _21.matchMetadataImage, 'call', _22 => _22(pathname)]) || generatedPaths.includes(pathname)
503
+ _optionalChain([routeManager, 'optionalAccess', _19 => _19.matchRoute, 'call', _20 => _20(pathname), 'optionalAccess', _21 => _21.route]) || _optionalChain([routeManager, 'optionalAccess', _22 => _22.matchMetadataRoute, 'call', _23 => _23(pathname)]) || _optionalChain([routeManager, 'optionalAccess', _24 => _24.matchMetadataImage, 'call', _25 => _25(pathname)]) || generatedPaths.includes(pathname)
455
504
  );
505
+ if (method !== "GET" && method !== "HEAD") {
506
+ return !matchesAppRoute && !devServableFileExists(pathname, baseDirs);
507
+ }
456
508
  return !matchesAppRoute || devServableFileExists(pathname, baseDirs);
457
509
  }
510
+ function isMalformedFarmRequestPathname(pathname) {
511
+ if (!pathname.includes("%")) return false;
512
+ try {
513
+ decodeURI(pathname);
514
+ return false;
515
+ } catch (e5) {
516
+ return true;
517
+ }
518
+ }
519
+ var FARM_MALFORMED_REQUEST_BODY = JSON.stringify(
520
+ { error: true, status: 400, message: "Bad Request" },
521
+ null,
522
+ 2
523
+ );
524
+ function resolveFarmPublicFilePath(pathname, publicFiles) {
525
+ if (publicFiles.size === 0) return null;
526
+ let id = pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
527
+ if (id.includes("%")) {
528
+ const escaped = id.replace(/%2f/gi, "%252F");
529
+ try {
530
+ id = decodeURIComponent(escaped);
531
+ } catch (e6) {
532
+ id = escaped;
533
+ }
534
+ }
535
+ if (publicFiles.has(id)) return id;
536
+ const index = `${id === "/" ? "" : id}/index.html`;
537
+ return publicFiles.has(index) ? index : null;
538
+ }
539
+ function createFarmPublicFileIndex(getPublicDir) {
540
+ const none = /* @__PURE__ */ new Set();
541
+ let listing;
542
+ return {
543
+ get() {
544
+ const configured = getPublicDir();
545
+ if (typeof configured !== "string" || configured.length === 0) return none;
546
+ if (_optionalChain([listing, 'optionalAccess', _26 => _26.configured]) === configured) return listing.files;
547
+ const dir = path3.resolve(configured);
548
+ listing = { configured, dir, files: listFarmPublicFiles(dir) };
549
+ return listing.files;
550
+ },
551
+ invalidate(file) {
552
+ if (!listing) return;
553
+ const resolved = path3.resolve(file);
554
+ if (resolved === listing.dir || resolved.startsWith(listing.dir + path3.sep)) {
555
+ listing = void 0;
556
+ }
557
+ }
558
+ };
559
+ }
560
+ function listFarmPublicFiles(dir) {
561
+ const files = /* @__PURE__ */ new Set();
562
+ let entries;
563
+ try {
564
+ entries = fs.readdirSync(dir, { recursive: true, withFileTypes: true });
565
+ } catch (e7) {
566
+ return files;
567
+ }
568
+ for (const entry of entries) {
569
+ const filePath = path3.join(entry.parentPath, entry.name);
570
+ let isFile = entry.isFile();
571
+ if (!isFile && entry.isSymbolicLink()) {
572
+ try {
573
+ isFile = fs.statSync(filePath).isFile();
574
+ } catch (e8) {
575
+ }
576
+ }
577
+ if (isFile) files.add(`/${path3.relative(dir, filePath).split(path3.sep).join("/")}`);
578
+ }
579
+ return files;
580
+ }
458
581
  var VITE_MODULE_QUERY_FLAGS = [
459
582
  "import",
460
583
  "raw",
@@ -470,21 +593,36 @@ function isViteModuleRequest(url, headers) {
470
593
  const value = Array.isArray(destination) ? destination[0] : destination;
471
594
  return value !== void 0 && SCRIPT_FETCH_DESTINATIONS.has(value.toLowerCase());
472
595
  }
596
+ var VITE_CLIENT_QUERY_FLAGS = ["t", "v", "direct", "html-proxy", "worker_file"];
597
+ var NAVIGATION_FETCH_DESTINATIONS = /* @__PURE__ */ new Set(["document", "iframe", "frame", "embed", "object"]);
598
+ function isViteDevClientRequest(url, headers) {
599
+ if (isViteModuleRequest(url, headers)) return true;
600
+ if (VITE_CLIENT_QUERY_FLAGS.some((flag) => url.searchParams.has(flag))) return true;
601
+ const destination = firstHeaderValue(headers["sec-fetch-dest"]);
602
+ if (destination !== void 0) {
603
+ return !NAVIGATION_FETCH_DESTINATIONS.has(destination.toLowerCase());
604
+ }
605
+ return firstHeaderValue(headers.referer) !== void 0 && !(_nullishCoalesce(firstHeaderValue(headers.accept), () => ( ""))).includes("text/html");
606
+ }
607
+ function firstHeaderValue(value) {
608
+ return Array.isArray(value) ? value[0] : value;
609
+ }
473
610
  var DOCS_ENGINE_APP_OWNABLE_PATHS = /* @__PURE__ */ new Set([
474
611
  "/llms.txt",
475
612
  "/llms-full.txt",
476
613
  "/sitemap.xml",
477
614
  "/robots.txt"
478
615
  ]);
479
- function farmAppOwnsDocsEnginePath(pathname, options) {
616
+ function farmAppOwnsDocsEnginePath(routePathname, options) {
617
+ const pathname = routePathname.length > 1 ? routePathname.replace(/\/+$/, "") : routePathname;
480
618
  if (!DOCS_ENGINE_APP_OWNABLE_PATHS.has(pathname)) return false;
481
- return options.generatedPaths.includes(pathname) || Boolean(_optionalChain([options, 'access', _23 => _23.routeManager, 'optionalAccess', _24 => _24.matchMetadataRoute, 'call', _25 => _25(pathname)])) || devServableFileExists(pathname, [options.publicDir]);
619
+ return options.generatedPaths.includes(pathname) || Boolean(_optionalChain([options, 'access', _27 => _27.routeManager, 'optionalAccess', _28 => _28.matchMetadataRoute, 'call', _29 => _29(pathname)])) || devServableFileExists(pathname, [options.publicDir]);
482
620
  }
483
621
  function devServableFileExists(pathname, baseDirs) {
484
622
  let decodedPathname;
485
623
  try {
486
624
  decodedPathname = decodeURIComponent(pathname);
487
- } catch (e5) {
625
+ } catch (e9) {
488
626
  return false;
489
627
  }
490
628
  const relativePathname = decodedPathname.replace(/^\/+/, "");
@@ -498,7 +636,7 @@ function devServableFileExists(pathname, baseDirs) {
498
636
  if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
499
637
  return true;
500
638
  }
501
- } catch (e6) {
639
+ } catch (e10) {
502
640
  }
503
641
  }
504
642
  return false;
@@ -579,14 +717,14 @@ function analyzeClientBoundary(program, publicKeys) {
579
717
  }
580
718
  function readNodeBuiltinSource(node) {
581
719
  if (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ImportExpression") {
582
- const value = _optionalChain([node, 'access', _26 => _26.source, 'optionalAccess', _27 => _27.value]);
720
+ const value = _optionalChain([node, 'access', _30 => _30.source, 'optionalAccess', _31 => _31.value]);
583
721
  return typeof value === "string" && value.startsWith("node:") ? value : void 0;
584
722
  }
585
723
  if (node.type === "CallExpression") {
586
724
  const callee = node.callee;
587
- if (_optionalChain([callee, 'optionalAccess', _28 => _28.type]) === "Identifier" && callee.name === "require") {
588
- const arg = _optionalChain([node, 'access', _29 => _29.arguments, 'optionalAccess', _30 => _30[0]]);
589
- const value = _optionalChain([arg, 'optionalAccess', _31 => _31.type]) === "Literal" ? arg.value : void 0;
725
+ if (_optionalChain([callee, 'optionalAccess', _32 => _32.type]) === "Identifier" && callee.name === "require") {
726
+ const arg = _optionalChain([node, 'access', _33 => _33.arguments, 'optionalAccess', _34 => _34[0]]);
727
+ const value = _optionalChain([arg, 'optionalAccess', _35 => _35.type]) === "Literal" ? arg.value : void 0;
590
728
  return typeof value === "string" && value.startsWith("node:") ? value : void 0;
591
729
  }
592
730
  }
@@ -595,7 +733,7 @@ function readNodeBuiltinSource(node) {
595
733
  function readProcessEnvKey(node) {
596
734
  if (node.type !== "MemberExpression") return void 0;
597
735
  const object = node.object;
598
- if (!object || object.type !== "MemberExpression" || _optionalChain([object, 'access', _32 => _32.object, 'optionalAccess', _33 => _33.type]) !== "Identifier" || object.object.name !== "process" || _optionalChain([object, 'access', _34 => _34.property, 'optionalAccess', _35 => _35.name]) !== "env") {
736
+ if (!object || object.type !== "MemberExpression" || _optionalChain([object, 'access', _36 => _36.object, 'optionalAccess', _37 => _37.type]) !== "Identifier" || object.object.name !== "process" || _optionalChain([object, 'access', _38 => _38.property, 'optionalAccess', _39 => _39.name]) !== "env") {
599
737
  return void 0;
600
738
  }
601
739
  const property = node.property;
@@ -658,7 +796,7 @@ function farmImageImportsPlugin() {
658
796
  async transform(code, id) {
659
797
  const filePath = id.split("?", 1)[0];
660
798
  if (id.includes("?") || !STATIC_IMAGE_RE.test(filePath)) return null;
661
- const defaultExport = _optionalChain([code, 'access', _36 => _36.match, 'call', _37 => _37(/^\s*export\s+default\s+(.+?);?\s*$/s), 'optionalAccess', _38 => _38[1]]);
799
+ const defaultExport = _optionalChain([code, 'access', _40 => _40.match, 'call', _41 => _41(/^\s*export\s+default\s+(.+?);?\s*$/s), 'optionalAccess', _42 => _42[1]]);
662
800
  if (!defaultExport) return null;
663
801
  return createStaticImageModule(filePath, `const src = ${defaultExport};`);
664
802
  }
@@ -691,11 +829,47 @@ async function createBlurDataURL(bytes) {
691
829
  const { default: sharp } = await import("sharp");
692
830
  const placeholder = await sharp(bytes).rotate().resize({ width: 8, height: 8, fit: "inside", withoutEnlargement: true }).webp({ quality: 35 }).toBuffer();
693
831
  return `data:image/webp;base64,${placeholder.toString("base64")}`;
694
- } catch (e7) {
832
+ } catch (e11) {
695
833
  return void 0;
696
834
  }
697
835
  }
698
836
 
837
+ // src/dev/deferred-setup.ts
838
+ function createFarmDeferredMiddleware(ready) {
839
+ const stack = [];
840
+ const run = (req, res, next) => {
841
+ let index = 0;
842
+ const step = (error) => {
843
+ if (error !== void 0 && error !== null) return next(error);
844
+ const layer = stack[index++];
845
+ if (!layer) return next();
846
+ try {
847
+ layer.handle(req, res, step);
848
+ } catch (thrown) {
849
+ next(_nullishCoalesce(thrown, () => ( new Error("Middleware threw a nullish value"))));
850
+ }
851
+ };
852
+ step();
853
+ };
854
+ return {
855
+ handle(req, res, next) {
856
+ const pending = ready();
857
+ if (!pending) return run(req, res, next);
858
+ pending.then(
859
+ () => run(req, res, next),
860
+ (error) => next(_nullishCoalesce(error, () => ( new Error("Farm dev server setup failed"))))
861
+ );
862
+ },
863
+ target: {
864
+ stack,
865
+ use(handle) {
866
+ stack.push({ route: "", handle });
867
+ return this;
868
+ }
869
+ }
870
+ };
871
+ }
872
+
699
873
  // src/vite.ts
700
874
 
701
875
 
@@ -715,12 +889,12 @@ function rewriteFarmReactCacheImport(code, file) {
715
889
  let program;
716
890
  try {
717
891
  program = _parseAst.parseAst.call(void 0, code, { lang });
718
- } catch (e8) {
892
+ } catch (e12) {
719
893
  return null;
720
894
  }
721
895
  const edits = [];
722
896
  const declarations = (_nullishCoalesce(program.body, () => ( []))).filter(
723
- (node) => node.type === "ImportDeclaration" && _optionalChain([node, 'access', _39 => _39.source, 'optionalAccess', _40 => _40.value]) === "react" && node.importKind !== "type"
897
+ (node) => node.type === "ImportDeclaration" && _optionalChain([node, 'access', _43 => _43.source, 'optionalAccess', _44 => _44.value]) === "react" && node.importKind !== "type"
724
898
  );
725
899
  const namespaces = /* @__PURE__ */ new Set();
726
900
  let memberImportAt = null;
@@ -735,7 +909,7 @@ function rewriteFarmReactCacheImport(code, file) {
735
909
  const caches = specifiers.filter(
736
910
  (specifier) => specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && Object.prototype.hasOwnProperty.call(
737
911
  REACT_CACHE_APIS,
738
- _nullishCoalesce(_nullishCoalesce(_optionalChain([specifier, 'access', _41 => _41.imported, 'optionalAccess', _42 => _42.name]), () => ( _optionalChain([specifier, 'access', _43 => _43.imported, 'optionalAccess', _44 => _44.value]))), () => ( ""))
912
+ _nullishCoalesce(_nullishCoalesce(_optionalChain([specifier, 'access', _45 => _45.imported, 'optionalAccess', _46 => _46.name]), () => ( _optionalChain([specifier, 'access', _47 => _47.imported, 'optionalAccess', _48 => _48.value]))), () => ( ""))
739
913
  )
740
914
  );
741
915
  if (caches.length === 0) continue;
@@ -749,7 +923,7 @@ function rewriteFarmReactCacheImport(code, file) {
749
923
  ].join(", ");
750
924
  const lines = [
751
925
  ...clause ? [`import ${clause} from "react";`] : [],
752
- `import { ${caches.map((specifier) => `${_nullishCoalesce(_optionalChain([specifier, 'access', _45 => _45.imported, 'optionalAccess', _46 => _46.name]), () => ( _optionalChain([specifier, 'access', _47 => _47.imported, 'optionalAccess', _48 => _48.value])))} as ${specifier.local.name}`).join(", ")} } from ${JSON.stringify(FARM_REACT_CACHE_MODULE)};`
926
+ `import { ${caches.map((specifier) => `${_nullishCoalesce(_optionalChain([specifier, 'access', _49 => _49.imported, 'optionalAccess', _50 => _50.name]), () => ( _optionalChain([specifier, 'access', _51 => _51.imported, 'optionalAccess', _52 => _52.value])))} as ${specifier.local.name}`).join(", ")} } from ${JSON.stringify(FARM_REACT_CACHE_MODULE)};`
753
927
  ];
754
928
  edits.push({ start: node.start, end: node.end, text: lines.join("\n") });
755
929
  }
@@ -764,7 +938,7 @@ function rewriteFarmReactCacheImport(code, file) {
764
938
  const current = node;
765
939
  if (typeof current.type !== "string") return;
766
940
  if (current.type === "ImportDeclaration") return;
767
- if (current.type === "MemberExpression" && !current.computed && _optionalChain([current, 'access', _49 => _49.object, 'optionalAccess', _50 => _50.type]) === "Identifier" && namespaces.has(current.object.name) && Object.prototype.hasOwnProperty.call(REACT_CACHE_APIS, _nullishCoalesce(_optionalChain([current, 'access', _51 => _51.property, 'optionalAccess', _52 => _52.name]), () => ( "")))) {
941
+ if (current.type === "MemberExpression" && !current.computed && _optionalChain([current, 'access', _53 => _53.object, 'optionalAccess', _54 => _54.type]) === "Identifier" && namespaces.has(current.object.name) && Object.prototype.hasOwnProperty.call(REACT_CACHE_APIS, _nullishCoalesce(_optionalChain([current, 'access', _55 => _55.property, 'optionalAccess', _56 => _56.name]), () => ( "")))) {
768
942
  const name = current.property.name;
769
943
  edits.push({ start: current.start, end: current.end, text: REACT_CACHE_APIS[name] });
770
944
  used.add(name);
@@ -835,13 +1009,13 @@ function reportOpenAPIDevGenerationResult(spec, output = _chunkQMNWKQL4cjs.logge
835
1009
  // src/vite.ts
836
1010
  var SERVER_FN_TRANSFORM_PLUGIN = "@farm.js/plugin/rsc:server-fn-actions";
837
1011
  function farmLlmsTxtGeneratedPaths(config) {
838
- const llms = _chunkFJWN7RV4cjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([config, 'access', _53 => _53.agent, 'optionalAccess', _54 => _54.llmsTxt]));
1012
+ const llms = _chunkQO43L7Z4cjs.resolveFarmLlmsTxtConfig.call(void 0, _optionalChain([config, 'access', _57 => _57.agent, 'optionalAccess', _58 => _58.llmsTxt]));
839
1013
  if (!llms.enabled) return [];
840
1014
  return llms.full ? ["/llms.txt", "/llms-full.txt"] : ["/llms.txt"];
841
1015
  }
842
1016
  function farmAgentGeneratedPaths(config) {
843
- const crawlers = _chunkO6L3YYPMcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([config, 'access', _55 => _55.agent, 'optionalAccess', _56 => _56.crawlers]));
844
- const sitemap = _chunkO6L3YYPMcjs.resolveFarmAgentSitemap.call(void 0, _optionalChain([config, 'access', _57 => _57.agent, 'optionalAccess', _58 => _58.sitemap]));
1017
+ const crawlers = _chunk4E57QHPWcjs.resolveFarmAgentCrawlers.call(void 0, _optionalChain([config, 'access', _59 => _59.agent, 'optionalAccess', _60 => _60.crawlers]));
1018
+ const sitemap = _chunk4E57QHPWcjs.resolveFarmAgentSitemap.call(void 0, _optionalChain([config, 'access', _61 => _61.agent, 'optionalAccess', _62 => _62.sitemap]));
845
1019
  return [
846
1020
  ...farmLlmsTxtGeneratedPaths(config),
847
1021
  ...sitemap.enabled ? ["/sitemap.xml"] : [],
@@ -880,13 +1054,13 @@ function loadFarmDocsSearchDevRuntime() {
880
1054
  return import("./search-client-ZZLKVO5R.cjs");
881
1055
  }
882
1056
  function loadFarmOpenAPIDevRuntime() {
883
- return import("./manager-2LUKNX2N.cjs");
1057
+ return import("./manager-JOHU6BQI.cjs");
884
1058
  }
885
1059
  function loadFarmWorkflowsDevRuntime() {
886
1060
  return import("./workflows.cjs");
887
1061
  }
888
1062
  function loadFarmDevtoolsSnapshotRuntime() {
889
- return import("./devtools-N2JQCMXB.cjs");
1063
+ return import("./devtools-RZVT4JVN.cjs");
890
1064
  }
891
1065
  function loadFarmDevtoolsUIRuntime() {
892
1066
  return import("./devtools-ui-SYRUXUA7.cjs");
@@ -899,7 +1073,7 @@ function farmI18nClientBridgePlugin() {
899
1073
  name: "farm:i18n-client-bridge",
900
1074
  enforce: "pre",
901
1075
  resolveId(id, _importer, options) {
902
- if (id === "@farm.js/core/i18n/server" && !_optionalChain([options, 'optionalAccess', _59 => _59.ssr])) {
1076
+ if (id === "@farm.js/core/i18n/server" && !_optionalChain([options, 'optionalAccess', _63 => _63.ssr])) {
903
1077
  return FARM_I18N_CLIENT_BRIDGE_ID;
904
1078
  }
905
1079
  return null;
@@ -923,6 +1097,18 @@ export function appDataDir() {
923
1097
  }
924
1098
  `;
925
1099
  }
1100
+ function createFarmServerPrebundleConfig(bundledPackages) {
1101
+ const include = bundledPackages.filter(({ prebundle }) => prebundle).map(({ name }) => name);
1102
+ if (include.length === 0) return {};
1103
+ const isBare = (id) => /^(?![a-zA-Z]:)[\w@]/.test(id) && !id.includes(":");
1104
+ const isIncluded = (id) => include.some((name) => id === name || id.startsWith(`${name}/`));
1105
+ return {
1106
+ optimizeDeps: {
1107
+ include,
1108
+ rolldownOptions: { external: (id) => isBare(id) && !isIncluded(id) }
1109
+ }
1110
+ };
1111
+ }
926
1112
  function farmServerOnlyEntriesPlugin(options = {}) {
927
1113
  let root = process.cwd();
928
1114
  let vercelOgInstalled = false;
@@ -930,15 +1116,19 @@ function farmServerOnlyEntriesPlugin(options = {}) {
930
1116
  name: "farm:server-only-entries",
931
1117
  enforce: "pre",
932
1118
  config(config) {
1119
+ const bundledPackages = _chunk4DRINDGNcjs.collectFarmServerBundledPackageInfo.call(void 0,
1120
+ path6.resolve(_nullishCoalesce(config.root, () => ( process.cwd())))
1121
+ );
933
1122
  return {
934
- optimizeDeps: { rolldownOptions: { plugins: [_chunk7ONGIFYXcjs.farmBrowserBuiltinsOptimizerPlugin.call(void 0, )] } },
1123
+ optimizeDeps: { rolldownOptions: { plugins: [_chunk4DRINDGNcjs.farmBrowserBuiltinsOptimizerPlugin.call(void 0, )] } },
935
1124
  ssr: {
936
1125
  noExternal: [
937
1126
  // Resolve `server-only` here rather than in Node, which would load its throwing build.
938
1127
  SERVER_ONLY_PACKAGE,
939
1128
  // Packages Node cannot load as a bundler does (stylesheet imports, `module`-only ESM).
940
- ..._chunk7ONGIFYXcjs.collectFarmServerBundledPackages.call(void 0, path6.resolve(_nullishCoalesce(config.root, () => ( process.cwd()))))
941
- ]
1129
+ ...bundledPackages.map(({ name }) => name)
1130
+ ],
1131
+ ...options.prebundleServerPackages ? createFarmServerPrebundleConfig(bundledPackages) : {}
942
1132
  }
943
1133
  };
944
1134
  },
@@ -946,21 +1136,21 @@ function farmServerOnlyEntriesPlugin(options = {}) {
946
1136
  root = config.root;
947
1137
  },
948
1138
  resolveId(id, importer, options2) {
949
- if (id === FARM_PLATFORM_ENTRY) return _optionalChain([options2, 'optionalAccess', _60 => _60.ssr]) ? null : FARM_PLATFORM_CLIENT_ID;
1139
+ if (id === FARM_PLATFORM_ENTRY) return _optionalChain([options2, 'optionalAccess', _64 => _64.ssr]) ? null : FARM_PLATFORM_CLIENT_ID;
950
1140
  if (id === SERVER_ONLY_PACKAGE) {
951
- if (_optionalChain([options2, 'optionalAccess', _61 => _61.ssr]) || _optionalChain([options2, 'optionalAccess', _62 => _62.scan])) {
1141
+ if (_optionalChain([options2, 'optionalAccess', _65 => _65.ssr]) || _optionalChain([options2, 'optionalAccess', _66 => _66.scan])) {
952
1142
  return FARM_SERVER_ONLY_PACKAGE_ID;
953
1143
  }
954
1144
  this.error(
955
1145
  `${_nullishCoalesce(importer, () => ( "A module"))} imports "server-only", so it must not reach the browser, but client code imports it. Move what the client needs out of that module, or call it from a server component, server function or API route.`
956
1146
  );
957
1147
  }
958
- if (!_optionalChain([options2, 'optionalAccess', _63 => _63.ssr]) && _module.isBuiltin.call(void 0, id)) {
959
- return _chunk7ONGIFYXcjs.resolveFarmBrowserBuiltin.call(void 0, this, id, importer, options2);
1148
+ if (!_optionalChain([options2, 'optionalAccess', _67 => _67.ssr]) && _module.isBuiltin.call(void 0, id)) {
1149
+ return _chunk4DRINDGNcjs.resolveFarmBrowserBuiltin.call(void 0, this, id, importer, options2);
960
1150
  }
961
1151
  if (!FARM_SERVER_ONLY_ENTRIES.has(id)) return null;
962
1152
  const importedBy = importer ? ` (imported by ${importer})` : "";
963
- if (!_optionalChain([options2, 'optionalAccess', _64 => _64.ssr])) {
1153
+ if (!_optionalChain([options2, 'optionalAccess', _68 => _68.ssr])) {
964
1154
  this.error(
965
1155
  `${id} is server-only and cannot be imported into client code${importedBy}. Use it from an API route or another server module.`
966
1156
  );
@@ -978,7 +1168,7 @@ function farmServerOnlyEntriesPlugin(options = {}) {
978
1168
  if (id === FARM_PLATFORM_CLIENT_ID) {
979
1169
  return createFarmPlatformClientModule(_nullishCoalesce(options.platform, () => ( _chunkAQLHD6HZcjs.resolveFarmPlatform.call(void 0, ))));
980
1170
  }
981
- return _nullishCoalesce(_chunk7ONGIFYXcjs.loadFarmBrowserBuiltin.call(void 0, id), () => ( null));
1171
+ return _nullishCoalesce(_chunk4DRINDGNcjs.loadFarmBrowserBuiltin.call(void 0, id), () => ( null));
982
1172
  }
983
1173
  };
984
1174
  }
@@ -1010,10 +1200,10 @@ function renderFarmI18nStaticHead(requestPath, snapshot) {
1010
1200
  if (!snapshot) return "";
1011
1201
  const runtime = `<script>window.__FARM_I18N__ = ${serializeFarmInlineValue(snapshot)};</script>`;
1012
1202
  if (snapshot.routing === "none") return runtime;
1013
- return `${_chunkUJ3R2AH2cjs.renderFarmLocaleAlternateLinks.call(void 0, requestPath, snapshot)}${runtime}`;
1203
+ return `${_chunkUPOYKX4Scjs.renderFarmLocaleAlternateLinks.call(void 0, requestPath, snapshot)}${runtime}`;
1014
1204
  }
1015
1205
  function getPublicEnvDefine(config) {
1016
- const publicEnv = _optionalChain([config, 'access', _65 => _65.env, 'optionalAccess', _66 => _66.public]);
1206
+ const publicEnv = _optionalChain([config, 'access', _69 => _69.env, 'optionalAccess', _70 => _70.public]);
1017
1207
  if (!isResolvedEnvScope(publicEnv)) {
1018
1208
  return {};
1019
1209
  }
@@ -1034,7 +1224,7 @@ function createRequestFromNodeRequest(req, url, signal) {
1034
1224
  signal
1035
1225
  });
1036
1226
  }
1037
- function withFarmRequestTracing(handler, apiRuntime, resolveTraceUrl = (request) => _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, request)) {
1227
+ function withFarmRequestTracing(handler, apiRuntime, resolveTraceUrl = (request) => _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, request)) {
1038
1228
  const middleware = _chunkP2355C6Ecjs._withAfterNodeMiddleware.call(void 0, handler);
1039
1229
  return (req, res, next) => {
1040
1230
  const traceUrl = resolveTraceUrl(req);
@@ -1052,15 +1242,41 @@ function withFarmRequestTracing(handler, apiRuntime, resolveTraceUrl = (request)
1052
1242
  return;
1053
1243
  }
1054
1244
  if (res.headersSent) {
1055
- _optionalChain([res, 'access', _67 => _67.destroy, 'optionalCall', _68 => _68(error instanceof Error ? error : new Error(String(error)))]);
1245
+ _optionalChain([res, 'access', _71 => _71.destroy, 'optionalCall', _72 => _72(error instanceof Error ? error : new Error(String(error)))]);
1056
1246
  return;
1057
1247
  }
1058
1248
  res.statusCode = 500;
1059
1249
  res.setHeader("Content-Type", "application/json");
1060
- res.end(JSON.stringify({ error: "Internal server error" }));
1250
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
1061
1251
  });
1062
1252
  };
1063
1253
  }
1254
+ function sendFarmDevErrorJSON(res) {
1255
+ res.statusCode = 500;
1256
+ res.setHeader("Content-Type", "application/json");
1257
+ res.setHeader("Cache-Control", "private, no-store");
1258
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
1259
+ }
1260
+ function createFarmDevMiddlewareErrorResponse() {
1261
+ return new Response(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY, {
1262
+ status: 500,
1263
+ headers: { "Content-Type": "application/json", "Cache-Control": "private, no-store" }
1264
+ });
1265
+ }
1266
+ function sendFarmDevRuntimeHookError(res, json) {
1267
+ res.statusCode = 500;
1268
+ res.setHeader("Content-Type", json ? "application/json" : "text/plain; charset=utf-8");
1269
+ res.end(json ? _chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY : "Internal Server Error");
1270
+ }
1271
+ var FARM_CONFIG_ROUTE_PLUGIN_NAMES = /* @__PURE__ */ new Set([
1272
+ _chunkAKIQ54FKcjs.FARM_CONFIG_HEADERS_PLUGIN_NAME,
1273
+ _chunkAKIQ54FKcjs.FARM_CONFIG_REDIRECTS_PLUGIN_NAME,
1274
+ _chunkAKIQ54FKcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME
1275
+ ]);
1276
+ function isFarmConfigRoutePlugin(plugin) {
1277
+ return FARM_CONFIG_ROUTE_PLUGIN_NAMES.has(plugin.name);
1278
+ }
1279
+ var FARM_DEV_CONFIG_REWRITE_SOURCE = /* @__PURE__ */ Symbol.for("farm.devConfigRewriteSource");
1064
1280
  async function proxyFarmExternalRewrite(req, res, bodySizeLimit) {
1065
1281
  const destination = req.url;
1066
1282
  if (!destination || !/^https?:\/\//i.test(destination)) return false;
@@ -1155,9 +1371,35 @@ function interceptFarmDevPageResponse(options) {
1155
1371
  const originalWrite = res.write.bind(res);
1156
1372
  const originalEnd = res.end.bind(res);
1157
1373
  const originalWriteHead = res.writeHead.bind(res);
1158
- const originalFlushHeaders = _optionalChain([res, 'access', _69 => _69.flushHeaders, 'optionalAccess', _70 => _70.bind, 'call', _71 => _71(res)]);
1374
+ const originalFlushHeaders = _optionalChain([res, 'access', _73 => _73.flushHeaders, 'optionalAccess', _74 => _74.bind, 'call', _75 => _75(res)]);
1159
1375
  let afterResponseCalled = false;
1160
1376
  let interceptedEnd = false;
1377
+ const restore = () => {
1378
+ res.write = originalWrite;
1379
+ res.end = originalEnd;
1380
+ res.writeHead = originalWriteHead;
1381
+ if (originalFlushHeaders) res.flushHeaders = originalFlushHeaders;
1382
+ delete res[_chunkWUTFJOV7cjs.FARM_NODE_RESPONSE_END_PENDING];
1383
+ };
1384
+ let runtimeHookFailed = false;
1385
+ const endRuntimeRequest = (response) => pm.endRuntimeRequest(runtimeSession, response).catch((error) => {
1386
+ runtimeHookFailed = true;
1387
+ throw error;
1388
+ });
1389
+ const reportFailure = (error) => {
1390
+ if (!runtimeHookFailed) void options.emitError(error);
1391
+ console.error("Error in afterResponse hook:", error);
1392
+ };
1393
+ const writeRuntimeHookFailure = () => {
1394
+ res.statusCode = 500;
1395
+ res.removeHeader("Content-Length");
1396
+ res.setHeader(
1397
+ "Content-Type",
1398
+ options.jsonError ? "application/json" : "text/plain; charset=utf-8"
1399
+ );
1400
+ originalWriteHead(500);
1401
+ originalWrite(options.jsonError ? _chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY : "Internal Server Error");
1402
+ };
1161
1403
  const htmlChunks = [];
1162
1404
  const responseChunks = [];
1163
1405
  let didStreamHtml = false;
@@ -1188,8 +1430,7 @@ function interceptFarmDevPageResponse(options) {
1188
1430
  const status = res.statusCode || 200;
1189
1431
  const canHaveBody = method !== "HEAD" && status !== 204 && status !== 205 && status !== 304;
1190
1432
  pm.copyRequestContext(req, runtimeSession.request);
1191
- const done = pm.endRuntimeRequest(
1192
- runtimeSession,
1433
+ const done = endRuntimeRequest(
1193
1434
  new Response(canHaveBody ? body : null, {
1194
1435
  status,
1195
1436
  headers: createHeadersFromNodeResponse(res)
@@ -1197,7 +1438,7 @@ function interceptFarmDevPageResponse(options) {
1197
1438
  ).then(async (runtimeResponse) => {
1198
1439
  applyWebResponseToNodeResponse(runtimeResponse, res);
1199
1440
  if (!res.headersSent) originalWriteHead(res.statusCode);
1200
- _optionalChain([originalFlushHeaders, 'optionalCall', _72 => _72()]);
1441
+ _optionalChain([originalFlushHeaders, 'optionalCall', _76 => _76()]);
1201
1442
  if (!runtimeResponse.body) return;
1202
1443
  const reader = runtimeResponse.body.getReader();
1203
1444
  for (; ; ) {
@@ -1217,7 +1458,7 @@ function interceptFarmDevPageResponse(options) {
1217
1458
  if (!chunk || chunk.byteLength === 0) return;
1218
1459
  try {
1219
1460
  stream.controller.enqueue(new Uint8Array(chunk));
1220
- } catch (e9) {
1461
+ } catch (e13) {
1221
1462
  }
1222
1463
  };
1223
1464
  res.writeHead = ((statusCode, ...args) => {
@@ -1246,7 +1487,7 @@ function interceptFarmDevPageResponse(options) {
1246
1487
  if (streamsThroughRuntime()) {
1247
1488
  streamRuntimeChunk(bufferChunk);
1248
1489
  const callback = args.find((arg) => typeof arg === "function");
1249
- _optionalChain([callback, 'optionalCall', _73 => _73()]);
1490
+ _optionalChain([callback, 'optionalCall', _77 => _77()]);
1250
1491
  return true;
1251
1492
  }
1252
1493
  if (isHtmlResponse && bufferChunk) {
@@ -1258,7 +1499,7 @@ function interceptFarmDevPageResponse(options) {
1258
1499
  const shouldBufferResponse = isHtmlResponse ? bufferPluginResponse : Boolean(runtimeSession && hasRuntimeAfterHook);
1259
1500
  if (shouldBufferResponse) {
1260
1501
  const callback = args.find((arg) => typeof arg === "function");
1261
- _optionalChain([callback, 'optionalCall', _74 => _74()]);
1502
+ _optionalChain([callback, 'optionalCall', _78 => _78()]);
1262
1503
  return true;
1263
1504
  }
1264
1505
  const writeResult = originalWrite(chunk, ...args);
@@ -1267,38 +1508,24 @@ function interceptFarmDevPageResponse(options) {
1267
1508
  });
1268
1509
  res.end = ((...args) => {
1269
1510
  interceptedEnd = true;
1270
- res[_chunk3EEET2Q5cjs.FARM_NODE_RESPONSE_END_PENDING] = true;
1511
+ res[_chunkWUTFJOV7cjs.FARM_NODE_RESPONSE_END_PENDING] = true;
1271
1512
  if (afterResponseCalled) return res;
1272
1513
  afterResponseCalled = true;
1273
1514
  options.logResponse(method, urlPath, res.statusCode || 200, Date.now() - startTime, "PAGE");
1274
1515
  const originalEndArgs = [...args];
1275
1516
  const callback = typeof originalEndArgs[originalEndArgs.length - 1] === "function" ? originalEndArgs[originalEndArgs.length - 1] : void 0;
1276
- const restore = () => {
1277
- res.write = originalWrite;
1278
- res.end = originalEnd;
1279
- res.writeHead = originalWriteHead;
1280
- if (originalFlushHeaders) res.flushHeaders = originalFlushHeaders;
1281
- delete res[_chunk3EEET2Q5cjs.FARM_NODE_RESPONSE_END_PENDING];
1282
- };
1283
1517
  if (streamsThroughRuntime()) {
1284
1518
  const stream = startRuntimeStream();
1285
1519
  streamRuntimeChunk(toNodeResponseBuffer(args[0], args[1]));
1286
1520
  try {
1287
1521
  stream.controller.close();
1288
- } catch (e10) {
1522
+ } catch (e14) {
1289
1523
  }
1290
1524
  stream.done.then(
1291
1525
  () => hasAfterResponseHook ? pm.runHookParallel("afterResponse", req, res) : void 0
1292
1526
  ).catch((error) => {
1293
- void options.emitError(error);
1294
- console.error("Error in afterResponse hook:", error);
1295
- if (!res.headersSent) {
1296
- res.statusCode = 500;
1297
- res.removeHeader("Content-Length");
1298
- res.setHeader("Content-Type", "text/plain; charset=utf-8");
1299
- originalWriteHead(500);
1300
- originalWrite("Internal Server Error");
1301
- }
1527
+ reportFailure(error);
1528
+ if (!res.headersSent) writeRuntimeHookFailure();
1302
1529
  }).finally(() => {
1303
1530
  restore();
1304
1531
  if (callback) originalEnd(callback);
@@ -1317,15 +1544,23 @@ function interceptFarmDevPageResponse(options) {
1317
1544
  Promise.resolve().then(async () => {
1318
1545
  if (isHtmlResponse) {
1319
1546
  const fullHtml = Buffer.concat(htmlChunks).toString("utf8");
1320
- if (!didStreamHtml || bufferPluginResponse) {
1321
- let html = await pm.runHookSerial("transformHTML", fullHtml);
1322
- html = await pm.runHookSerial("afterRender", html, renderPayload);
1323
- originalEndArgs.length = 0;
1324
- originalEndArgs.push(html);
1325
- if (callback) originalEndArgs.push(callback);
1326
- } else {
1327
- await pm.runHookSerial("transformHTML", fullHtml);
1328
- await pm.runHookSerial("afterRender", fullHtml, renderPayload);
1547
+ try {
1548
+ if (!didStreamHtml || bufferPluginResponse) {
1549
+ let html = await pm.runHookSerial("transformHTML", fullHtml);
1550
+ html = await pm.runHookSerial("afterRender", html, renderPayload);
1551
+ originalEndArgs.length = 0;
1552
+ originalEndArgs.push(html);
1553
+ if (callback) originalEndArgs.push(callback);
1554
+ } else {
1555
+ await pm.runHookSerial("transformHTML", fullHtml);
1556
+ await pm.runHookSerial("afterRender", fullHtml, renderPayload);
1557
+ }
1558
+ } catch (error) {
1559
+ if (runtimeSession) {
1560
+ runtimeHookFailed = true;
1561
+ await pm.failRuntimeRequest(runtimeSession, error);
1562
+ }
1563
+ throw error;
1329
1564
  }
1330
1565
  }
1331
1566
  if (runtimeSession) {
@@ -1334,8 +1569,7 @@ function interceptFarmDevPageResponse(options) {
1334
1569
  const canHaveBody = method !== "HEAD" && status !== 204 && status !== 205 && status !== 304;
1335
1570
  const firstArg = originalEndArgs[0];
1336
1571
  const responseBody = canHaveBody ? isHtmlResponse ? didStreamHtml && !bufferPluginResponse ? Buffer.concat(htmlChunks) : toNodeResponseBuffer(firstArg, originalEndArgs[1]) : hasRuntimeAfterHook ? Buffer.concat(responseChunks) : toNodeResponseBuffer(firstArg, originalEndArgs[1]) : null;
1337
- const runtimeResponse = await pm.endRuntimeRequest(
1338
- runtimeSession,
1572
+ const runtimeResponse = await endRuntimeRequest(
1339
1573
  new Response(responseBody ? toRequestBody(responseBody) : responseBody, {
1340
1574
  status,
1341
1575
  headers: createHeadersFromNodeResponse(res)
@@ -1357,11 +1591,16 @@ function interceptFarmDevPageResponse(options) {
1357
1591
  res.end = originalEnd;
1358
1592
  res.writeHead = originalWriteHead;
1359
1593
  if (originalFlushHeaders) res.flushHeaders = originalFlushHeaders;
1360
- delete res[_chunk3EEET2Q5cjs.FARM_NODE_RESPONSE_END_PENDING];
1594
+ delete res[_chunkWUTFJOV7cjs.FARM_NODE_RESPONSE_END_PENDING];
1361
1595
  originalEnd(...originalEndArgs);
1362
1596
  }).catch((error) => {
1363
- void options.emitError(error);
1364
- console.error("Error in afterResponse hook:", error);
1597
+ reportFailure(error);
1598
+ if (runtimeHookFailed && !res.headersSent) {
1599
+ restore();
1600
+ writeRuntimeHookFailure();
1601
+ originalEnd(callback);
1602
+ return;
1603
+ }
1365
1604
  const shouldBufferResponse = isHtmlResponse ? bufferPluginResponse : Boolean(runtimeSession && hasRuntimeAfterHook);
1366
1605
  if (shouldBufferResponse) {
1367
1606
  const body = Buffer.concat(isHtmlResponse ? htmlChunks : responseChunks);
@@ -1369,21 +1608,24 @@ function interceptFarmDevPageResponse(options) {
1369
1608
  res.end = originalEnd;
1370
1609
  res.writeHead = originalWriteHead;
1371
1610
  if (originalFlushHeaders) res.flushHeaders = originalFlushHeaders;
1372
- delete res[_chunk3EEET2Q5cjs.FARM_NODE_RESPONSE_END_PENDING];
1611
+ delete res[_chunkWUTFJOV7cjs.FARM_NODE_RESPONSE_END_PENDING];
1373
1612
  originalEnd(body, callback);
1374
1613
  } else {
1375
1614
  res.write = originalWrite;
1376
1615
  res.end = originalEnd;
1377
1616
  res.writeHead = originalWriteHead;
1378
1617
  if (originalFlushHeaders) res.flushHeaders = originalFlushHeaders;
1379
- delete res[_chunk3EEET2Q5cjs.FARM_NODE_RESPONSE_END_PENDING];
1618
+ delete res[_chunkWUTFJOV7cjs.FARM_NODE_RESPONSE_END_PENDING];
1380
1619
  originalEnd(...originalEndArgs);
1381
1620
  }
1382
1621
  });
1383
1622
  return res;
1384
1623
  });
1385
1624
  return {
1386
- isEnded: () => interceptedEnd || res.writableEnded
1625
+ isEnded: () => interceptedEnd || res.writableEnded,
1626
+ release() {
1627
+ if (!interceptedEnd) restore();
1628
+ }
1387
1629
  };
1388
1630
  }
1389
1631
  function getFullEnvDefine(config) {
@@ -1401,16 +1643,21 @@ function getEnvDefines(config, configEnv) {
1401
1643
  __FARM_API_BASE_URL__: JSON.stringify(getFarmAPIBaseURLDefine(config)),
1402
1644
  __FARM_PUBLIC_ENV__: JSON.stringify(getPublicEnvDefine(config)),
1403
1645
  __FARM_IMAGE_CONFIG__: JSON.stringify(
1404
- _chunkHEPJIKKQcjs.getPublicFarmImageConfig.call(void 0, _chunkHEPJIKKQcjs.resolveFarmImageConfig.call(void 0, config.images))
1646
+ _chunkMCSRMEQVcjs.getPublicFarmImageConfig.call(void 0,
1647
+ _chunkMCSRMEQVcjs.resolveFarmImageConfig.call(void 0,
1648
+ config.images,
1649
+ _chunk67MZTLTFcjs.isFarmRendererDisabled.call(void 0, config.renderer) ? "none" : void 0
1650
+ )
1651
+ )
1405
1652
  )
1406
1653
  };
1407
- if (_optionalChain([configEnv, 'optionalAccess', _75 => _75.isSsrBuild])) {
1654
+ if (_optionalChain([configEnv, 'optionalAccess', _79 => _79.isSsrBuild])) {
1408
1655
  defines.__FARM_ENV__ = JSON.stringify(_chunk3EIPOTZVcjs.createBundledEnv.call(void 0, getFullEnvDefine(config)));
1409
1656
  }
1410
1657
  return defines;
1411
1658
  }
1412
1659
  function getFarmAPIBaseURLDefine(config) {
1413
- const baseURL = _optionalChain([config, 'access', _76 => _76.api, 'optionalAccess', _77 => _77.baseURL]);
1660
+ const baseURL = _optionalChain([config, 'access', _80 => _80.api, 'optionalAccess', _81 => _81.baseURL]);
1414
1661
  return typeof baseURL === "string" && baseURL ? baseURL : _chunkPMJSG4JScjs.DEFAULT_FARM_API_BASE_PATH;
1415
1662
  }
1416
1663
  function isResolvedEnvScope(value) {
@@ -1430,7 +1677,7 @@ function fileContainsProgrammaticPageRoute(file) {
1430
1677
  }
1431
1678
  try {
1432
1679
  return _chunkE7QOEV5Zcjs.scanProgrammaticPagePaths.call(void 0, fs2.readFileSync(file, "utf8")).length > 0;
1433
- } catch (e11) {
1680
+ } catch (e15) {
1434
1681
  return false;
1435
1682
  }
1436
1683
  }
@@ -1443,7 +1690,7 @@ function rewriteEarlySsrRelativeImports(options) {
1443
1690
  let ast;
1444
1691
  try {
1445
1692
  ast = options.parse(options.code);
1446
- } catch (e12) {
1693
+ } catch (e16) {
1447
1694
  return null;
1448
1695
  }
1449
1696
  walkModuleAst(ast, (node) => {
@@ -1482,18 +1729,18 @@ function transformIsolatedClientBoundaryModule(options) {
1482
1729
  from: "@farm.js/core/internal/islx-react"
1483
1730
  });
1484
1731
  if (rewritten) options = { ...options, code: rewritten.code };
1485
- } catch (e13) {
1732
+ } catch (e17) {
1486
1733
  return null;
1487
1734
  }
1488
1735
  }
1489
1736
  let ast;
1490
1737
  try {
1491
1738
  ast = options.parse(options.code);
1492
- } catch (e14) {
1739
+ } catch (e18) {
1493
1740
  return null;
1494
1741
  }
1495
1742
  const body = Array.isArray(ast.body) ? ast.body : [];
1496
- const everyExportIsComponent = options.code.includes(_chunk7ONGIFYXcjs.FARM_CLIENT_REFERENCE_PRAGMA) || options.moduleReference.includes(_chunk7ONGIFYXcjs.FARM_CLIENT_REFERENCE_DIRECTORY);
1743
+ const everyExportIsComponent = options.code.includes(_chunk4DRINDGNcjs.FARM_CLIENT_REFERENCE_PRAGMA) || options.moduleReference.includes(_chunk4DRINDGNcjs.FARM_CLIENT_REFERENCE_DIRECTORY);
1497
1744
  const replacements = [];
1498
1745
  const wrapperStatements = [];
1499
1746
  const originalEntries = [];
@@ -1512,9 +1759,9 @@ function transformIsolatedClientBoundaryModule(options) {
1512
1759
  transformedExports++;
1513
1760
  };
1514
1761
  for (const node of body) {
1515
- if (_optionalChain([node, 'optionalAccess', _78 => _78.type]) === "ExportDefaultDeclaration" && node.declaration) {
1762
+ if (_optionalChain([node, 'optionalAccess', _82 => _82.type]) === "ExportDefaultDeclaration" && node.declaration) {
1516
1763
  const declaration2 = node.declaration;
1517
- if ((declaration2.type === "FunctionDeclaration" || declaration2.type === "ClassDeclaration") && _optionalChain([declaration2, 'access', _79 => _79.id, 'optionalAccess', _80 => _80.name])) {
1764
+ if ((declaration2.type === "FunctionDeclaration" || declaration2.type === "ClassDeclaration") && _optionalChain([declaration2, 'access', _83 => _83.id, 'optionalAccess', _84 => _84.name])) {
1518
1765
  replacements.push({
1519
1766
  start: node.start,
1520
1767
  end: node.end,
@@ -1532,11 +1779,11 @@ function transformIsolatedClientBoundaryModule(options) {
1532
1779
  }
1533
1780
  continue;
1534
1781
  }
1535
- if (_optionalChain([node, 'optionalAccess', _81 => _81.type]) === "ExportNamedDeclaration" && !node.declaration && node.exportKind !== "type") {
1782
+ if (_optionalChain([node, 'optionalAccess', _85 => _85.type]) === "ExportNamedDeclaration" && !node.declaration && node.exportKind !== "type") {
1536
1783
  const specifiers = (node.specifiers || []).filter(
1537
1784
  (specifier) => specifier.type === "ExportSpecifier" && specifier.exportKind !== "type"
1538
1785
  );
1539
- const specifierName = (name) => _nullishCoalesce(_optionalChain([name, 'optionalAccess', _82 => _82.name]), () => ( String(_nullishCoalesce(_optionalChain([name, 'optionalAccess', _83 => _83.value]), () => ( "")))));
1786
+ const specifierName = (name) => _nullishCoalesce(_optionalChain([name, 'optionalAccess', _86 => _86.name]), () => ( String(_nullishCoalesce(_optionalChain([name, 'optionalAccess', _87 => _87.value]), () => ( "")))));
1540
1787
  const isComponentExport = (specifier) => {
1541
1788
  const exported = specifierName(specifier.exported);
1542
1789
  return everyExportIsComponent || exported === "default" || /^[A-Z]/.test(exported);
@@ -1563,14 +1810,14 @@ function transformIsolatedClientBoundaryModule(options) {
1563
1810
  if (kept.length > 0) wrapperStatements.push(`export { ${kept.join(", ")} };`);
1564
1811
  continue;
1565
1812
  }
1566
- if (_optionalChain([node, 'optionalAccess', _84 => _84.type]) !== "ExportNamedDeclaration" || !node.declaration) continue;
1813
+ if (_optionalChain([node, 'optionalAccess', _88 => _88.type]) !== "ExportNamedDeclaration" || !node.declaration) continue;
1567
1814
  const declaration = node.declaration;
1568
1815
  const declaredNames = [];
1569
- if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && _optionalChain([declaration, 'access', _85 => _85.id, 'optionalAccess', _86 => _86.name])) {
1816
+ if ((declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration") && _optionalChain([declaration, 'access', _89 => _89.id, 'optionalAccess', _90 => _90.name])) {
1570
1817
  declaredNames.push(declaration.id.name);
1571
1818
  } else if (declaration.type === "VariableDeclaration") {
1572
1819
  for (const declarator of declaration.declarations || []) {
1573
- if (_optionalChain([declarator, 'access', _87 => _87.id, 'optionalAccess', _88 => _88.type]) === "Identifier") declaredNames.push(declarator.id.name);
1820
+ if (_optionalChain([declarator, 'access', _91 => _91.id, 'optionalAccess', _92 => _92.type]) === "Identifier") declaredNames.push(declarator.id.name);
1574
1821
  }
1575
1822
  }
1576
1823
  const componentNames = declaredNames.filter((name) => /^[A-Z]/.test(name));
@@ -1590,7 +1837,7 @@ function transformIsolatedClientBoundaryModule(options) {
1590
1837
  for (const replacement of replacements.sort((left, right) => right.start - left.start)) {
1591
1838
  output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
1592
1839
  }
1593
- const runtimeImport = options.slots ? `import { createIsland as __farm_islx_island__ } from "@farm.js/core/internal/islx-react";` : `import * as __farm_isolated_react__ from "react";
1840
+ const runtimeImport = options.slots ? options.browser ? "const __farm_islx_island__ = (component) => component;" : `import { createIsland as __farm_islx_island__ } from "@farm.js/core/internal/islx-react";` : `import * as __farm_isolated_react__ from "react";
1594
1841
  import { createFarmIsolatedClientBoundary as __farm_create_isolated_boundary__ } from "@farm.js/core/internal/isolated-boundary";`;
1595
1842
  return `${runtimeImport}
1596
1843
  ${output}
@@ -1622,8 +1869,8 @@ function isFarmModuleAstNode(value) {
1622
1869
  function isFarmConfigFile(file, root) {
1623
1870
  const normalized = file.replace(/\\/g, "/");
1624
1871
  const rootSlug = root.replace(/\\/g, "/").replace(/\/+$/, "");
1625
- const relative2 = normalized.startsWith(`${rootSlug}/`) ? normalized.slice(rootSlug.length + 1) : normalized;
1626
- return FARM_CONFIG_FILENAMES.has(relative2);
1872
+ const relative3 = normalized.startsWith(`${rootSlug}/`) ? normalized.slice(rootSlug.length + 1) : normalized;
1873
+ return FARM_CONFIG_FILENAMES.has(relative3);
1627
1874
  }
1628
1875
  var warnedClientBoundaryIds = /* @__PURE__ */ new Set();
1629
1876
  function warnClientBoundaryOnce(context, id, code, config) {
@@ -1631,10 +1878,10 @@ function warnClientBoundaryOnce(context, id, code, config) {
1631
1878
  let program;
1632
1879
  try {
1633
1880
  program = context.parse(code);
1634
- } catch (e15) {
1881
+ } catch (e19) {
1635
1882
  return;
1636
1883
  }
1637
- const publicKeys = new Set(Object.keys(_nullishCoalesce(_optionalChain([config, 'access', _89 => _89.env, 'optionalAccess', _90 => _90.public]), () => ( {}))));
1884
+ const publicKeys = new Set(Object.keys(_nullishCoalesce(_optionalChain([config, 'access', _93 => _93.env, 'optionalAccess', _94 => _94.public]), () => ( {}))));
1638
1885
  const findings = analyzeClientBoundary(program, publicKeys);
1639
1886
  if (findings.envKeys.length === 0 && findings.publicEnvKeys.length === 0 && findings.builtinImports.length === 0) {
1640
1887
  return;
@@ -1643,7 +1890,7 @@ function warnClientBoundaryOnce(context, id, code, config) {
1643
1890
  _chunkQMNWKQL4cjs.logger.warn(formatClientBoundaryWarning(id, findings));
1644
1891
  }
1645
1892
  function shouldEmitFarmClientRootHmr(renderer) {
1646
- return _chunkRD623KW4cjs.getFarmRendererCapabilities.call(void 0, _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, renderer)).reconcilesRerenders;
1893
+ return _chunk67MZTLTFcjs.getFarmRendererCapabilities.call(void 0, _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, renderer)).reconcilesRerenders;
1647
1894
  }
1648
1895
  function hasViteAlias(alias, find) {
1649
1896
  if (!alias) return false;
@@ -1652,9 +1899,10 @@ function hasViteAlias(alias, find) {
1652
1899
  (entry) => typeof entry.find === "string" ? entry.find === find : entry.find.test(`${find}/`)
1653
1900
  );
1654
1901
  }
1655
- function farmPlugin(options = {}, initialPluginManager) {
1902
+ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
1903
+ const rendererDisabled = _chunk67MZTLTFcjs.isFarmRendererDisabled.call(void 0, options.renderer);
1656
1904
  const imageImports = farmImageImportsPlugin();
1657
- const fontImports = _chunkE4UDLFWRcjs.farmFontImportsPlugin.call(void 0, {
1905
+ const fontImports = _chunkN5DQMOAGcjs.farmFontImportsPlugin.call(void 0, {
1658
1906
  root: options.root,
1659
1907
  basePath: options.basePath,
1660
1908
  publicDir: options.publicDir
@@ -1662,17 +1910,21 @@ function farmPlugin(options = {}, initialPluginManager) {
1662
1910
  let farmApp;
1663
1911
  let serverFnTransformActive = false;
1664
1912
  const islandsServerFns = () => {
1665
- const config = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _91 => _91.getConfig, 'call', _92 => _92()]), () => ( options));
1666
- return _optionalChain([config, 'access', _93 => _93.experimental, 'optionalAccess', _94 => _94.serverActions]) === true && _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _95 => _95.experimental, 'optionalAccess', _96 => _96.serverComponents])) === "islands";
1913
+ const config = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _95 => _95.getConfig, 'call', _96 => _96()]), () => ( options));
1914
+ return _optionalChain([config, 'access', _97 => _97.experimental, 'optionalAccess', _98 => _98.serverActions]) === true && _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([config, 'access', _99 => _99.experimental, 'optionalAccess', _100 => _100.serverComponents])) === "islands";
1667
1915
  };
1668
1916
  let reactRefreshActive = false;
1669
1917
  let server;
1918
+ let deferredGates;
1919
+ let pendingClientSetup = null;
1920
+ const farmSetupContext = new (0, _async_hooks.AsyncLocalStorage)();
1670
1921
  let apiRouteManager;
1671
1922
  let openAPIManager = null;
1672
1923
  let middlewareManager;
1673
1924
  let refreshRouteDiscovery = null;
1674
1925
  let workflowHandler = null;
1675
1926
  let isBuild = false;
1927
+ let farmOwnsDevCors = false;
1676
1928
  const docsMCPServerDisposers = /* @__PURE__ */ new Set();
1677
1929
  const releaseDocsMCPServers = () => {
1678
1930
  for (const dispose of docsMCPServerDisposers) dispose();
@@ -1688,15 +1940,16 @@ function farmPlugin(options = {}, initialPluginManager) {
1688
1940
  ].join(" ");
1689
1941
  console.log(log);
1690
1942
  };
1691
- const getProgrammaticClientRoutes = () => _nullishCoalesce(options.programmaticClientRoutes, () => ( _optionalChain([farmApp, 'optionalAccess', _97 => _97.getRouteManager, 'call', _98 => _98(), 'access', _99 => _99.getProgrammaticClientRoutes, 'call', _100 => _100()])));
1692
- return {
1943
+ const getProgrammaticClientRoutes = () => _nullishCoalesce(options.programmaticClientRoutes, () => ( _optionalChain([farmApp, 'optionalAccess', _101 => _101.getRouteManager, 'call', _102 => _102(), 'access', _103 => _103.getProgrammaticClientRoutes, 'call', _104 => _104()])));
1944
+ const plugin = {
1693
1945
  name: "farm",
1694
1946
  api: { getProgrammaticClientRoutes },
1695
1947
  config(userConfig, configEnv) {
1696
1948
  isBuild = configEnv.command === "build";
1697
1949
  const layerAliases = _chunk5Y2P454Ocjs.getFarmLayerAliases.call(void 0, options.layers);
1698
- const sourceAlias = hasViteAlias(_optionalChain([userConfig, 'access', _101 => _101.resolve, 'optionalAccess', _102 => _102.alias]), "@") ? {} : _chunkE4UDLFWRcjs.createFarmSourceAlias.call(void 0, options.root || process.cwd(), options.srcDir);
1950
+ const sourceAlias = hasViteAlias(_optionalChain([userConfig, 'access', _105 => _105.resolve, 'optionalAccess', _106 => _106.alias]), "@") ? {} : _chunkN5DQMOAGcjs.createFarmSourceAlias.call(void 0, options.root || process.cwd(), options.srcDir);
1699
1951
  const layerRoots = (_nullishCoalesce(options.layers, () => ( []))).map((layer) => layer.root);
1952
+ farmOwnsDevCors = !isBuild && _optionalChain([userConfig, 'access', _107 => _107.server, 'optionalAccess', _108 => _108.cors]) === void 0;
1700
1953
  return {
1701
1954
  // Honor Farm's publicDir so the dev server serves the same static
1702
1955
  // directory the production client build emits.
@@ -1709,9 +1962,10 @@ function farmPlugin(options = {}, initialPluginManager) {
1709
1962
  alias: { ...layerAliases, ...sourceAlias }
1710
1963
  },
1711
1964
  server: {
1965
+ ...farmOwnsDevCors ? { cors: false } : {},
1712
1966
  fs: {
1713
1967
  ...layerRoots.length ? { allow: [path6.resolve(options.root || process.cwd()), ...layerRoots] } : {},
1714
- deny: getFarmDevFsDeny(_optionalChain([userConfig, 'access', _103 => _103.server, 'optionalAccess', _104 => _104.fs, 'optionalAccess', _105 => _105.deny]), options)
1968
+ deny: getFarmDevFsDeny(_optionalChain([userConfig, 'access', _109 => _109.server, 'optionalAccess', _110 => _110.fs, 'optionalAccess', _111 => _111.deny]), options)
1715
1969
  }
1716
1970
  }
1717
1971
  };
@@ -1721,10 +1975,10 @@ function farmPlugin(options = {}, initialPluginManager) {
1721
1975
  await fontImports.configResolved.call(this, config);
1722
1976
  }
1723
1977
  serverFnTransformActive = config.plugins.some(
1724
- (plugin) => plugin.name === SERVER_FN_TRANSFORM_PLUGIN
1978
+ (plugin2) => plugin2.name === SERVER_FN_TRANSFORM_PLUGIN
1725
1979
  );
1726
1980
  reactRefreshActive = _chunk65Y5SIBHcjs.isFarmReactRefreshActive.call(void 0, config);
1727
- if (_optionalChain([options, 'access', _106 => _106.experimental, 'optionalAccess', _107 => _107.serverActions]) === true && !serverFnTransformActive && !islandsServerFns()) {
1981
+ if (_optionalChain([options, 'access', _112 => _112.experimental, 'optionalAccess', _113 => _113.serverActions]) === true && !serverFnTransformActive && !islandsServerFns()) {
1728
1982
  _chunkQMNWKQL4cjs.logger.warn(
1729
1983
  "experimental.serverActions has no effect without @farm.js/plugin/rsc in the Vite plugins. Server functions stay server-only, and importing one from client code is a build error."
1730
1984
  );
@@ -1733,42 +1987,57 @@ function farmPlugin(options = {}, initialPluginManager) {
1733
1987
  async configureServer(viteServer) {
1734
1988
  viteServer.middlewares.use(
1735
1989
  createFarmDevPreviewGuard(viteServer, {
1736
- getSourceRoots: () => _chunk5Y2P454Ocjs.getFarmSourceRoots.call(void 0, _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _108 => _108.getConfig, 'call', _109 => _109()]), () => ( options)))
1990
+ getSourceRoots: () => _chunk5Y2P454Ocjs.getFarmSourceRoots.call(void 0, _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _114 => _114.getConfig, 'call', _115 => _115()]), () => ( options)))
1737
1991
  })
1738
1992
  );
1739
1993
  if (typeof fontImports.configureServer === "function") {
1740
1994
  await fontImports.configureServer.call(this, viteServer);
1741
1995
  }
1742
1996
  server = viteServer;
1997
+ const farmMiddlewares = _nullishCoalesce(_optionalChain([deferredGates, 'optionalAccess', _116 => _116.pre, 'access', _117 => _117.target]), () => ( viteServer.middlewares));
1998
+ const farmPostMiddlewares = _nullishCoalesce(_optionalChain([deferredGates, 'optionalAccess', _118 => _118.post, 'access', _119 => _119.target]), () => ( viteServer.middlewares));
1743
1999
  const pm = initialPluginManager;
2000
+ const configRoutePlugins = new Set(
2001
+ _optionalChain([pm, 'optionalAccess', _120 => _120.getPlugins, 'call', _121 => _121(), 'access', _122 => _122.filter, 'call', _123 => _123(isFarmConfigRoutePlugin), 'access', _124 => _124.map, 'call', _125 => _125((plugin2) => plugin2.name)])
2002
+ );
2003
+ const configRedirectMatchers = (_nullishCoalesce(_optionalChain([pm, 'optionalAccess', _126 => _126.getPlugins, 'call', _127 => _127()]), () => ( []))).flatMap((plugin2) => {
2004
+ const matcher = _chunkAKIQ54FKcjs.getConfigRedirectMatcher.call(void 0, plugin2);
2005
+ return matcher ? [matcher] : [];
2006
+ });
1744
2007
  const emitPluginError = async (phase, error, meta) => {
1745
2008
  if (!pm) return;
1746
2009
  try {
1747
2010
  await pm.runHookParallel("onError", { phase, error, meta });
1748
- } catch (e16) {
2011
+ } catch (e20) {
1749
2012
  }
1750
2013
  };
1751
- farmApp = new (0, _chunkE4UDLFWRcjs.FarmApp)(
2014
+ farmApp = new (0, _chunkN5DQMOAGcjs.FarmApp)(
1752
2015
  {
1753
2016
  ...options,
1754
2017
  root: resolveDevelopmentRoot(options.root, server.config.root)
1755
2018
  },
1756
2019
  server
1757
2020
  );
2021
+ farmApp.getRouteManager().usePackageClientBoundaryCacheFile(
2022
+ _chunk4DRINDGNcjs.resolvePackageClientBoundaryCacheFile.call(void 0,
2023
+ farmApp.getConfig().root,
2024
+ options.distDir || ".farm"
2025
+ )
2026
+ );
1758
2027
  await farmApp.initialize();
1759
2028
  const farmConfig = farmApp.getConfig();
1760
2029
  let farmAppPackages;
1761
- if (_optionalChain([farmConfig, 'access', _110 => _110.agent, 'optionalAccess', _111 => _111.noindexPreviews])) {
1762
- server.middlewares.use((_req, res, next) => {
1763
- if (_chunkMPJEIHW2cjs.isFarmPreviewDeploymentEnvironment.call(void 0, process.env)) {
1764
- res.setHeader("X-Robots-Tag", _chunkO6L3YYPMcjs.FARM_PREVIEW_ROBOTS_TAG);
2030
+ if (_optionalChain([farmConfig, 'access', _128 => _128.agent, 'optionalAccess', _129 => _129.noindexPreviews])) {
2031
+ farmMiddlewares.use((_req, res, next) => {
2032
+ if (_chunk6V5YWI4Wcjs.isFarmPreviewDeploymentEnvironment.call(void 0, process.env)) {
2033
+ res.setHeader("X-Robots-Tag", _chunk4E57QHPWcjs.FARM_PREVIEW_ROBOTS_TAG);
1765
2034
  }
1766
2035
  next();
1767
2036
  });
1768
2037
  }
1769
2038
  const apiServerBasePath = _chunk2OF5RPVUcjs.resolveFarmAPIServerBasePath.call(void 0, farmConfig.api);
1770
2039
  const devBuiltInRoutePaths = new Set(
1771
- _chunk752IHQTDcjs.listFarmBuiltInRoutePaths.call(void 0, {
2040
+ _chunkLPIZMU7Dcjs.listFarmBuiltInRoutePaths.call(void 0, {
1772
2041
  agent: {
1773
2042
  apiCatalog: true,
1774
2043
  mcp: true,
@@ -1780,7 +2049,7 @@ function farmPlugin(options = {}, initialPluginManager) {
1780
2049
  })
1781
2050
  );
1782
2051
  const serverConfig = _chunkCFG4QERRcjs.resolveFarmServerConfig.call(void 0, farmConfig.server);
1783
- globalThis.__FARM_IMAGE_CONFIG__ = _chunkHEPJIKKQcjs.getPublicFarmImageConfig.call(void 0, farmConfig.images);
2052
+ globalThis.__FARM_IMAGE_CONFIG__ = _chunkMCSRMEQVcjs.getPublicFarmImageConfig.call(void 0, farmConfig.images);
1784
2053
  let imageHandler = null;
1785
2054
  if (farmConfig.images.provider !== "none") {
1786
2055
  const { createNodeImageFetcher, createNodeImageUrlValidator, createSharpImageTransformer } = await import("./image/sharp.cjs");
@@ -1790,7 +2059,7 @@ function farmPlugin(options = {}, initialPluginManager) {
1790
2059
  validateRemoteUrl: createNodeImageUrlValidator(farmConfig.images),
1791
2060
  // Vite owns this address. Unlike request.url, it cannot be replaced by
1792
2061
  // a caller-controlled Host header.
1793
- trustedLocalOrigin: () => _optionalChain([server, 'access', _112 => _112.resolvedUrls, 'optionalAccess', _113 => _113.local, 'access', _114 => _114[0]]),
2062
+ trustedLocalOrigin: () => _optionalChain([server, 'access', _130 => _130.resolvedUrls, 'optionalAccess', _131 => _131.local, 'access', _132 => _132[0]]),
1794
2063
  onError(error) {
1795
2064
  _chunkQMNWKQL4cjs.logger.error(
1796
2065
  `Image optimization failed: ${error instanceof Error ? error.message : String(error)}`
@@ -1810,15 +2079,15 @@ function farmPlugin(options = {}, initialPluginManager) {
1810
2079
  const workflowConfig = farmConfig.workflows;
1811
2080
  const farmDocsDevRuntime = farmConfig.docs.enabled ? await loadFarmDocsDevRuntime() : null;
1812
2081
  const getExtraRouteTypes = () => [
1813
- ..._optionalChain([options, 'access', _115 => _115.openapi, 'optionalAccess', _116 => _116.enabled]) && options.openapi.route ? [options.openapi.route] : [],
1814
- ..._nullishCoalesce(_optionalChain([farmDocsDevRuntime, 'optionalAccess', _117 => _117.getFarmDocsRouteTypeEntries, 'call', _118 => _118(farmConfig.docs)]), () => ( []))
2082
+ ..._optionalChain([options, 'access', _133 => _133.openapi, 'optionalAccess', _134 => _134.enabled]) && options.openapi.route ? [options.openapi.route] : [],
2083
+ ..._nullishCoalesce(_optionalChain([farmDocsDevRuntime, 'optionalAccess', _135 => _135.getFarmDocsRouteTypeEntries, 'call', _136 => _136(farmConfig.docs)]), () => ( []))
1815
2084
  ];
1816
2085
  const appDirSlugs = sourceRoots.map(
1817
2086
  (source) => path6.join(source.root, source.srcDir, "app").replace(/\\/g, "/")
1818
2087
  );
1819
2088
  const generateTypeArtifacts = async (reason, selection = ALL_TYPE_ARTIFACTS, log = false) => {
1820
2089
  try {
1821
- const result = await _chunkX4K7TYN6cjs.generateFarmTypeArtifacts.call(void 0, {
2090
+ const result = await _chunkYVTS3S3Fcjs.generateFarmTypeArtifacts.call(void 0, {
1822
2091
  root: farmConfig.root,
1823
2092
  srcDir: farmConfig.srcDir,
1824
2093
  layers: farmConfig.layers,
@@ -1858,10 +2127,10 @@ function farmPlugin(options = {}, initialPluginManager) {
1858
2127
  (source) => path6.join(source.root, source.srcDir).replace(/\\/g, "/")
1859
2128
  );
1860
2129
  const layerConfigFiles = new Set(
1861
- farmConfig.layers.map((layer) => _optionalChain([layer, 'access', _119 => _119.configFile, 'optionalAccess', _120 => _120.replace, 'call', _121 => _121(/\\/g, "/")])).filter((file) => Boolean(file))
2130
+ farmConfig.layers.map((layer) => _optionalChain([layer, 'access', _137 => _137.configFile, 'optionalAccess', _138 => _138.replace, 'call', _139 => _139(/\\/g, "/")])).filter((file) => Boolean(file))
1862
2131
  );
1863
2132
  const routeModuleExtensions = /* @__PURE__ */ new Set([
1864
- ..._chunkRD623KW4cjs.resolveFarmComponentExtensions.call(void 0, farmConfig.renderer.componentExtensions),
2133
+ ..._chunk67MZTLTFcjs.resolveFarmComponentExtensions.call(void 0, farmConfig.renderer.componentExtensions),
1865
2134
  ".md",
1866
2135
  ".mdx"
1867
2136
  ]);
@@ -1937,7 +2206,7 @@ function farmPlugin(options = {}, initialPluginManager) {
1937
2206
  scheduleTypeArtifactGen(file, ev, typeArtifacts);
1938
2207
  }
1939
2208
  if (isI18nCatalogFile(file)) {
1940
- _optionalChain([farmApp, 'optionalAccess', _122 => _122.getI18nRuntime, 'call', _123 => _123(), 'access', _124 => _124.reload, 'call', _125 => _125(), 'access', _126 => _126.then, 'call', _127 => _127(() => server.ws.send({ type: "full-reload", path: "*" })), 'access', _128 => _128.catch, 'call', _129 => _129((error) => _chunkQMNWKQL4cjs.logger.warn(`i18n catalog reload failed: ${error.message}`))]);
2209
+ _optionalChain([farmApp, 'optionalAccess', _140 => _140.getI18nRuntime, 'call', _141 => _141(), 'access', _142 => _142.reload, 'call', _143 => _143(), 'access', _144 => _144.then, 'call', _145 => _145(() => server.ws.send({ type: "full-reload", path: "*" })), 'access', _146 => _146.catch, 'call', _147 => _147((error) => _chunkQMNWKQL4cjs.logger.warn(`i18n catalog reload failed: ${error.message}`))]);
1941
2210
  }
1942
2211
  const isRouteRefreshEvent = (ev !== "change" || isStaticMetadataImageFile(file)) && (isAppRuntimeFile(file) || isProgrammaticRouteFile(file) || isProgrammaticRouteSourceFile(file) && (ev === "unlink" || fileContainsProgrammaticPageRoute(file)));
1943
2212
  if (isRouteRefreshEvent) {
@@ -1950,8 +2219,8 @@ function farmPlugin(options = {}, initialPluginManager) {
1950
2219
  const reloadsMiddleware = pendingRouteRefreshIncludesMiddleware;
1951
2220
  pendingRouteRefreshIncludesMiddleware = false;
1952
2221
  Promise.all([
1953
- _optionalChain([refreshRouteDiscovery, 'optionalCall', _130 => _130(`${ev} ${file}`)]),
1954
- reloadsMiddleware ? _optionalChain([middlewareManager, 'optionalAccess', _131 => _131.reload, 'call', _132 => _132()]) : void 0
2222
+ _optionalChain([refreshRouteDiscovery, 'optionalCall', _148 => _148(`${ev} ${file}`)]),
2223
+ reloadsMiddleware ? _optionalChain([middlewareManager, 'optionalAccess', _149 => _149.reload, 'call', _150 => _150()]) : void 0
1955
2224
  ]).then(() => server.ws.send({ type: "full-reload", path: "*" })).catch((error) => _chunkQMNWKQL4cjs.logger.warn(`Route refresh failed: ${error.message}`));
1956
2225
  }, 50);
1957
2226
  }
@@ -1990,14 +2259,14 @@ function farmPlugin(options = {}, initialPluginManager) {
1990
2259
  const { FARM_DEV_SERVER_MODULE_LOADER } = await import("./internal/native-server-fns.cjs");
1991
2260
  const load = (file) => _chunkJYNNIGQOcjs.loadFarmDevModule.call(void 0, server, file);
1992
2261
  globalThis[FARM_DEV_SERVER_MODULE_LOADER] = load;
1993
- _optionalChain([server, 'access', _133 => _133.httpServer, 'optionalAccess', _134 => _134.once, 'call', _135 => _135("close", () => {
2262
+ _optionalChain([server, 'access', _151 => _151.httpServer, 'optionalAccess', _152 => _152.once, 'call', _153 => _153("close", () => {
1994
2263
  const globals = globalThis;
1995
2264
  if (globals[FARM_DEV_SERVER_MODULE_LOADER] === load) {
1996
2265
  delete globals[FARM_DEV_SERVER_MODULE_LOADER];
1997
2266
  }
1998
2267
  })]);
1999
2268
  }
2000
- apiRouteManager = new (0, _chunkSYXPWJ7Ncjs.APIRouteManager)(appDirs, server, {
2269
+ apiRouteManager = new (0, _chunkOFBLGH6Vcjs.APIRouteManager)(appDirs, server, {
2001
2270
  plugins: farmConfig.plugins,
2002
2271
  i18n: farmApp.getI18nRuntime(),
2003
2272
  bodySizeLimit: serverConfig.bodySizeLimit,
@@ -2043,7 +2312,7 @@ function farmPlugin(options = {}, initialPluginManager) {
2043
2312
  });
2044
2313
  }
2045
2314
  }
2046
- middlewareManager = new (0, _chunkLQNW3ABPcjs.MiddlewareManager)(
2315
+ middlewareManager = new (0, _chunkVX2HZGC7cjs.MiddlewareManager)(
2047
2316
  appDirs,
2048
2317
  server,
2049
2318
  farmConfig.middleware,
@@ -2064,11 +2333,12 @@ function farmPlugin(options = {}, initialPluginManager) {
2064
2333
  });
2065
2334
  }
2066
2335
  }
2067
- if (_optionalChain([options, 'access', _136 => _136.openapi, 'optionalAccess', _137 => _137.enabled])) {
2336
+ if (_optionalChain([options, 'access', _154 => _154.openapi, 'optionalAccess', _155 => _155.enabled])) {
2068
2337
  const { OpenAPIManager } = await loadFarmOpenAPIDevRuntime();
2069
2338
  openAPIManager = new OpenAPIManager(appDirs, options.openapi, {
2070
2339
  mode: "development",
2071
- apiBaseURL: typeof _optionalChain([options, 'access', _138 => _138.api, 'optionalAccess', _139 => _139.baseURL]) === "string" ? options.api.baseURL : void 0
2340
+ apiBaseURL: typeof _optionalChain([options, 'access', _156 => _156.api, 'optionalAccess', _157 => _157.baseURL]) === "string" ? options.api.baseURL : void 0,
2341
+ loadModule: (filePath) => apiRouteManager.loadModule(filePath)
2072
2342
  });
2073
2343
  const spec = await openAPIManager.generateSpec();
2074
2344
  reportOpenAPIDevGenerationResult(spec);
@@ -2097,7 +2367,7 @@ function farmPlugin(options = {}, initialPluginManager) {
2097
2367
  return _chunk7EPYN7GWcjs.resolveFarmLayoutFonts.call(void 0, layoutModules);
2098
2368
  };
2099
2369
  releaseDocsMCPServers();
2100
- const isFarmDocsPathGuarded = (href) => _chunkUJ3R2AH2cjs.farmPathGuardCoversPage.call(void 0,
2370
+ const isFarmDocsPathGuarded = (href) => _chunkUPOYKX4Scjs.farmPathGuardCoversPage.call(void 0,
2101
2371
  {
2102
2372
  config: farmConfig,
2103
2373
  middlewareRoutes: middlewareManager.getMiddlewares().filter((entry) => entry.source !== "config")
@@ -2110,19 +2380,20 @@ function farmPlugin(options = {}, initialPluginManager) {
2110
2380
  clientEntry: "/@farm/client.js",
2111
2381
  resolveLayoutFonts: resolveDocsLayoutFonts,
2112
2382
  fontStylesheetHref: "/@farm/fonts.css",
2113
- globalStylesheetHref: _chunkE4UDLFWRcjs.resolveDevGlobalStylesheetHref.call(void 0,
2383
+ globalStylesheetHref: _chunkN5DQMOAGcjs.resolveDevGlobalStylesheetHref.call(void 0,
2114
2384
  farmConfig.root,
2115
2385
  farmConfig.srcDir
2116
2386
  ),
2117
2387
  loadModule: async (specifier) => {
2118
2388
  const resolved = await server.environments.ssr.pluginContainer.resolveId(specifier);
2119
- if (specifier === _optionalChain([farmConfig, 'access', _140 => _140.docs, 'access', _141 => _141.adapter, 'optionalAccess', _142 => _142.server]) && _optionalChain([resolved, 'optionalAccess', _143 => _143.id])) {
2389
+ if (specifier === _optionalChain([farmConfig, 'access', _158 => _158.docs, 'access', _159 => _159.adapter, 'optionalAccess', _160 => _160.server]) && _optionalChain([resolved, 'optionalAccess', _161 => _161.id])) {
2390
+ const file = resolved.id.split("?", 1)[0];
2120
2391
  return import(
2121
2392
  /* @vite-ignore */
2122
- _url.pathToFileURL.call(void 0, resolved.id).href
2393
+ _url.pathToFileURL.call(void 0, file).href
2123
2394
  );
2124
2395
  }
2125
- return _chunkJYNNIGQOcjs.loadFarmDevModule.call(void 0, server, _nullishCoalesce(_optionalChain([resolved, 'optionalAccess', _144 => _144.id]), () => ( specifier)));
2396
+ return _chunkJYNNIGQOcjs.loadFarmDevModule.call(void 0, server, _nullishCoalesce(_optionalChain([resolved, 'optionalAccess', _162 => _162.id]), () => ( specifier)));
2126
2397
  },
2127
2398
  registerMCPServer: (mcpServer) => {
2128
2399
  const dispose = _chunkLRB5OVRTcjs.registerFarmMCPServer.call(void 0, mcpServer);
@@ -2140,21 +2411,22 @@ function farmPlugin(options = {}, initialPluginManager) {
2140
2411
  fontAssets: _chunkERMUL73Lcjs.toFarmDocsPublicFontAssets.call(void 0, farmDocsFontAssetList),
2141
2412
  resolveLayoutFonts: resolveDocsLayoutFonts,
2142
2413
  fontStylesheetHref: "/@farm/fonts.css",
2143
- globalStylesheetHref: _chunkE4UDLFWRcjs.resolveDevGlobalStylesheetHref.call(void 0,
2414
+ globalStylesheetHref: _chunkN5DQMOAGcjs.resolveDevGlobalStylesheetHref.call(void 0,
2144
2415
  farmConfig.root,
2145
2416
  farmConfig.srcDir
2146
2417
  ),
2147
- isPathGuarded: isFarmDocsPathGuarded
2418
+ isPathGuarded: isFarmDocsPathGuarded,
2419
+ basePath: farmConfig.basePath
2148
2420
  }) : null;
2149
2421
  const wrapFarmDocsResponseWithLayouts = async (request, response) => {
2150
- if (request.method === "HEAD" || response.headers.has("x-farm-docs-adapter") || !_optionalChain([response, 'access', _145 => _145.headers, 'access', _146 => _146.get, 'call', _147 => _147("content-type"), 'optionalAccess', _148 => _148.toLowerCase, 'call', _149 => _149(), 'access', _150 => _150.includes, 'call', _151 => _151("text/html")])) {
2422
+ if (request.method === "HEAD" || response.headers.has("x-farm-docs-adapter") || !_optionalChain([response, 'access', _163 => _163.headers, 'access', _164 => _164.get, 'call', _165 => _165("content-type"), 'optionalAccess', _166 => _166.toLowerCase, 'call', _167 => _167(), 'access', _168 => _168.includes, 'call', _169 => _169("text/html")])) {
2151
2423
  return response;
2152
2424
  }
2153
2425
  const pathname = new URL(request.url).pathname;
2154
2426
  const matchedRoute = routeManager.matchRoute(pathname);
2155
2427
  const layoutEntries = matchedRoute.layouts.map((layout) => ({
2156
2428
  ...layout,
2157
- metadata: _chunk7ONGIFYXcjs.getClientModuleMetadata.call(void 0, layout.modulePath, farmConfig.root)
2429
+ metadata: _chunk4DRINDGNcjs.getClientModuleMetadata.call(void 0, layout.modulePath, farmConfig.root)
2158
2430
  }));
2159
2431
  if (!layoutEntries.some((layout) => layout.metadata.shouldHydrate)) {
2160
2432
  return response;
@@ -2168,9 +2440,9 @@ function farmPlugin(options = {}, initialPluginManager) {
2168
2440
  headers: response.headers
2169
2441
  });
2170
2442
  }
2171
- const docsRenderer = _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, (_nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _152 => _152.getConfig, 'call', _153 => _153()]), () => ( options))).renderer);
2443
+ const docsRenderer = _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, (_nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _170 => _170.getConfig, 'call', _171 => _171()]), () => ( options))).renderer);
2172
2444
  const [rendererRuntime, layoutModules] = await Promise.all([
2173
- _chunkRD623KW4cjs.isReactRenderer.call(void 0, docsRenderer) ? import("./renderer/react/server.cjs") : _chunkJYNNIGQOcjs.loadFarmDevModule.call(void 0, server, docsRenderer.server),
2445
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, docsRenderer) ? import("./renderer/react/server.cjs") : _chunkJYNNIGQOcjs.loadFarmDevModule.call(void 0, server, docsRenderer.server),
2174
2446
  Promise.all(
2175
2447
  layoutEntries.map((layout) => routeManager.loadLayoutModule(layout.modulePath))
2176
2448
  )
@@ -2197,7 +2469,7 @@ function farmPlugin(options = {}, initialPluginManager) {
2197
2469
  ])
2198
2470
  );
2199
2471
  const inlineValue = (value) => JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
2200
- const pageModulePath = _optionalChain([matchedRoute, 'access', _154 => _154.route, 'optionalAccess', _155 => _155.modulePath]) ? toUrlPath(matchedRoute.route.modulePath) : "";
2472
+ const pageModulePath = _optionalChain([matchedRoute, 'access', _172 => _172.route, 'optionalAccess', _173 => _173.modulePath]) ? toUrlPath(matchedRoute.route.modulePath) : "";
2201
2473
  const bootstrapScript = `<script>
2202
2474
  window.__FARM_PROPS__ = ${inlineValue({ params })};
2203
2475
  window.__FARM_ROUTE_SLOTS__ = [];
@@ -2253,7 +2525,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2253
2525
  srcDir: farmConfig.srcDir,
2254
2526
  docs: farmConfig.docs,
2255
2527
  diagnostics: true,
2256
- isPathGuarded: isFarmDocsPathGuarded
2528
+ isPathGuarded: isFarmDocsPathGuarded,
2529
+ basePath: farmConfig.basePath
2257
2530
  }) : null;
2258
2531
  const farmDocsFontAssets = new Map(
2259
2532
  farmDocsFontAssetList.map(({ url, sourcePath }) => [url, sourcePath])
@@ -2293,24 +2566,55 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2293
2566
  }
2294
2567
  },
2295
2568
  (request) => {
2296
- const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _156 => _156.getConfig, 'call', _157 => _157()]), () => ( options));
2569
+ const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _174 => _174.getConfig, 'call', _175 => _175()]), () => ( options));
2297
2570
  const currentServerConfig = _chunkCFG4QERRcjs.resolveFarmServerConfig.call(void 0, currentConfig.server);
2298
- return _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, request, {
2571
+ return _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, request, {
2299
2572
  trustProxy: currentServerConfig.trustProxy
2300
2573
  });
2301
2574
  }
2302
2575
  );
2303
- server.middlewares.use(
2304
- withAPIRequestTracing(async (req, res, next) => {
2576
+ const publicFileIndex = createFarmPublicFileIndex(() => server.config.publicDir);
2577
+ for (const event of ["add", "unlink", "addDir", "unlinkDir"]) {
2578
+ server.watcher.on(event, (file) => publicFileIndex.invalidate(file));
2579
+ }
2580
+ const deferredDottedRequests = /* @__PURE__ */ new WeakMap();
2581
+ farmMiddlewares.use(
2582
+ withAPIRequestTracing(async function handleFarmDevRequest(req, res, next) {
2305
2583
  const requestUrl = req.url || "/";
2306
2584
  const requestMethod = req.method || "GET";
2307
- const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _158 => _158.getConfig, 'call', _159 => _159()]), () => ( options));
2585
+ const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _176 => _176.getConfig, 'call', _177 => _177()]), () => ( options));
2308
2586
  const currentServerConfig = _chunkCFG4QERRcjs.resolveFarmServerConfig.call(void 0, currentConfig.server);
2309
- const parsedRequestUrl = _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, req, {
2587
+ const parsedRequestUrl = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, {
2310
2588
  trustProxy: currentServerConfig.trustProxy
2311
2589
  });
2312
2590
  const fullUrl = parsedRequestUrl.toString();
2313
2591
  const requestPathname = parsedRequestUrl.pathname;
2592
+ if (isMalformedFarmRequestPathname(requestPathname)) {
2593
+ res.statusCode = 400;
2594
+ res.setHeader("Content-Type", "application/json; charset=utf-8");
2595
+ res.end(requestMethod === "HEAD" ? void 0 : FARM_MALFORMED_REQUEST_BODY);
2596
+ return;
2597
+ }
2598
+ if ((requestMethod === "GET" || requestMethod === "HEAD") && req[FARM_DEV_CONFIG_REWRITE_SOURCE] === void 0 && !isViteModuleRequest(parsedRequestUrl, req.headers)) {
2599
+ const publicFile = resolveFarmPublicFilePath(requestPathname, publicFileIndex.get());
2600
+ if (publicFile) {
2601
+ if (publicFile !== requestPathname) {
2602
+ req.url = `${encodeURI(publicFile)}${parsedRequestUrl.search}`;
2603
+ }
2604
+ return next();
2605
+ }
2606
+ }
2607
+ if (requestMethod === "OPTIONS" && req.headers.origin && req.headers["access-control-request-method"]) {
2608
+ const preflightHeaders = _chunk22IWL4YDcjs.resolveRouteRuleCorsPreflightHeaders.call(void 0,
2609
+ currentConfig.routeRules,
2610
+ requestPathname
2611
+ );
2612
+ if (preflightHeaders) {
2613
+ res.writeHead(204, preflightHeaders);
2614
+ res.end();
2615
+ return;
2616
+ }
2617
+ }
2314
2618
  if (imageHandler && requestPathname === farmConfig.images.path) {
2315
2619
  const imageResponse = await imageHandler(
2316
2620
  createRequestFromNodeRequest(req, new URL(fullUrl))
@@ -2337,7 +2641,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2337
2641
  res.end("Farm DevTools are disabled.");
2338
2642
  return;
2339
2643
  }
2340
- if (requestPathname === _chunkSTF6VDYQcjs.FARM_DEVTOOLS_PATH && parsedRequestUrl.searchParams.get("embedded") !== "1") {
2644
+ if (requestPathname === _chunkSTF6VDYQcjs.FARM_DEVTOOLS_PATH && parsedRequestUrl.searchParams.get("embedded") !== "1" && !rendererDisabled) {
2341
2645
  let launchUrl = new URL(farmConfig.basePath || "/", parsedRequestUrl.origin);
2342
2646
  const referrer = req.headers.referer;
2343
2647
  if (referrer) {
@@ -2346,7 +2650,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2346
2650
  if (referrerUrl.origin === parsedRequestUrl.origin && !referrerUrl.pathname.startsWith(_chunkSTF6VDYQcjs.FARM_DEVTOOLS_PATH)) {
2347
2651
  launchUrl = referrerUrl;
2348
2652
  }
2349
- } catch (e17) {
2653
+ } catch (e21) {
2350
2654
  }
2351
2655
  }
2352
2656
  launchUrl.searchParams.set(_chunkSTF6VDYQcjs.FARM_DEVTOOLS_LAUNCH_PARAM, "1");
@@ -2372,7 +2676,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2372
2676
  openapi: options.openapi
2373
2677
  },
2374
2678
  workflows: discoveredWorkflows,
2375
- plugins: _optionalChain([pm, 'optionalAccess', _160 => _160.getSortedPlugins, 'call', _161 => _161()])
2679
+ plugins: _optionalChain([pm, 'optionalAccess', _178 => _178.getSortedPlugins, 'call', _179 => _179()])
2376
2680
  });
2377
2681
  res.statusCode = 200;
2378
2682
  res.setHeader(
@@ -2394,8 +2698,59 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2394
2698
  }
2395
2699
  return;
2396
2700
  }
2701
+ const isViteOwnedRequest = () => requestUrl.startsWith("/@") || requestUrl.startsWith("/node_modules/") || requestUrl.startsWith("/__farm/") || isViteModuleRequest(parsedRequestUrl, req.headers) || (requestMethod === "GET" || requestMethod === "HEAD") && requestPathname.includes(".") && (devServableFileExists(requestPathname, [server.config.publicDir]) || isViteDevClientRequest(parsedRequestUrl, req.headers) && devServableFileExists(requestPathname, [server.config.root]));
2702
+ const configRewriteSource = req[FARM_DEV_CONFIG_REWRITE_SOURCE];
2703
+ const runtimeHookErrorAnswersJSON = rendererDisabled || _chunkXGTFLG73cjs.isFarmAPIPathname.call(void 0, requestPathname, apiServerBasePath);
2704
+ if (pm && configRewriteSource === void 0 && !deferredDottedRequests.has(req) && (configRoutePlugins.has(_chunkAKIQ54FKcjs.FARM_CONFIG_HEADERS_PLUGIN_NAME) || configRedirectMatchers.length > 0) && !isViteOwnedRequest()) {
2705
+ let redirect = null;
2706
+ try {
2707
+ await pm.runHookParallelFiltered(
2708
+ "beforeRequest",
2709
+ (plugin2) => plugin2.name === _chunkAKIQ54FKcjs.FARM_CONFIG_HEADERS_PLUGIN_NAME,
2710
+ req,
2711
+ res
2712
+ );
2713
+ for (const matchRedirect of configRedirectMatchers) {
2714
+ _nullishCoalesce(redirect, () => ( (redirect = matchRedirect(parsedRequestUrl))));
2715
+ }
2716
+ } catch (error) {
2717
+ await emitPluginError("before-request", error, { urlPath: requestUrl });
2718
+ if (!res.headersSent) {
2719
+ res.statusCode = 500;
2720
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
2721
+ }
2722
+ res.end("Internal Server Error");
2723
+ return;
2724
+ }
2725
+ if (redirect) {
2726
+ let response = new Response(`Redirecting to ${redirect.destination}`, {
2727
+ status: redirect.statusCode,
2728
+ headers: { Location: redirect.destination }
2729
+ });
2730
+ if (pm.hasRuntimeRequestHooks()) {
2731
+ const redirectResponse = response;
2732
+ try {
2733
+ response = await pm.runRuntimeRequest(
2734
+ createRequestFromNodeRequest(req, parsedRequestUrl),
2735
+ () => redirectResponse,
2736
+ {
2737
+ kind: _chunkXGTFLG73cjs.isFarmAPIPathname.call(void 0, requestPathname, apiServerBasePath) ? "api" : requestMethod === "GET" || requestMethod === "HEAD" ? "page" : "request",
2738
+ route: { pathname: requestPathname }
2739
+ }
2740
+ );
2741
+ } catch (e22) {
2742
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
2743
+ logResponse(requestMethod, requestUrl, 500, 0, "PAGE");
2744
+ return;
2745
+ }
2746
+ }
2747
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
2748
+ logResponse(requestMethod, requestUrl, res.statusCode, 0, "PAGE");
2749
+ return;
2750
+ }
2751
+ }
2397
2752
  const runAppMiddlewareForContentRoute = async () => {
2398
- if (!_optionalChain([middlewareManager, 'optionalAccess', _162 => _162.hasMiddleware, 'call', _163 => _163()])) return false;
2753
+ if (!_optionalChain([middlewareManager, 'optionalAccess', _180 => _180.hasMiddleware, 'call', _181 => _181()])) return false;
2399
2754
  const middlewareRequest = createRequestFromNodeRequest(req, new URL(fullUrl));
2400
2755
  return runFarmMiddlewareWithNavigation(
2401
2756
  farmApp.getServerRenderer(),
@@ -2405,67 +2760,108 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2405
2760
  () => middlewareManager.execute(req, res)
2406
2761
  );
2407
2762
  };
2763
+ const runAppMiddlewareInRuntimeSession = async (runtimeSession2, logResponse2) => {
2764
+ const interceptor = runtimeSession2 && _optionalChain([pm, 'optionalAccess', _182 => _182.hasRuntimeHook, 'call', _183 => _183("after")]) && _optionalChain([middlewareManager, 'optionalAccess', _184 => _184.hasMiddleware, 'call', _185 => _185()]) ? interceptFarmDevPageResponse({
2765
+ req,
2766
+ res,
2767
+ pm,
2768
+ runtimeSession: runtimeSession2,
2769
+ hasRuntimeAfterHook: true,
2770
+ hasAfterResponseHook: false,
2771
+ hasHTMLTransformHook: false,
2772
+ renderPayload: {},
2773
+ method: requestMethod,
2774
+ urlPath: requestUrl,
2775
+ pathname: requestPathname,
2776
+ startTime: Date.now(),
2777
+ logResponse: (_method, _path, status) => _optionalChain([logResponse2, 'optionalCall', _186 => _186(status)]),
2778
+ // The runtime reports a runtime.after failure itself.
2779
+ emitError: async () => {
2780
+ },
2781
+ jsonError: runtimeHookErrorAnswersJSON
2782
+ }) : void 0;
2783
+ let handled;
2784
+ try {
2785
+ handled = await runAppMiddlewareForContentRoute();
2786
+ } catch (error) {
2787
+ _optionalChain([interceptor, 'optionalAccess', _187 => _187.release, 'call', _188 => _188()]);
2788
+ throw error;
2789
+ }
2790
+ if (!handled) {
2791
+ _optionalChain([interceptor, 'optionalAccess', _189 => _189.release, 'call', _190 => _190()]);
2792
+ return false;
2793
+ }
2794
+ if (!_optionalChain([interceptor, 'optionalAccess', _191 => _191.isEnded, 'call', _192 => _192()])) _optionalChain([logResponse2, 'optionalCall', _193 => _193(res.statusCode || 200)]);
2795
+ return true;
2796
+ };
2408
2797
  const serveBuiltInRoute = async (respond, {
2409
2798
  kind = requestMethod === "GET" || requestMethod === "HEAD" ? "page" : "request",
2410
2799
  computed,
2411
2800
  label
2412
2801
  } = {}) => {
2413
2802
  const discard = async () => {
2414
- await _optionalChain([computed, 'optionalAccess', _164 => _164.body, 'optionalAccess', _165 => _165.cancel, 'call', _166 => _166(), 'access', _167 => _167.catch, 'call', _168 => _168(() => {
2803
+ await _optionalChain([computed, 'optionalAccess', _194 => _194.body, 'optionalAccess', _195 => _195.cancel, 'call', _196 => _196(), 'access', _197 => _197.catch, 'call', _198 => _198(() => {
2415
2804
  })]);
2416
2805
  };
2806
+ const sendRuntimeResponse = async (runtimeSession3, response2) => {
2807
+ let runtimeResponse;
2808
+ try {
2809
+ runtimeResponse = await pm.endRuntimeRequest(runtimeSession3, response2);
2810
+ } catch (e23) {
2811
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
2812
+ return;
2813
+ }
2814
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, runtimeResponse);
2815
+ };
2417
2816
  let runtimeSession2;
2418
- if (_optionalChain([pm, 'optionalAccess', _169 => _169.hasRuntimeRequestHooks, 'call', _170 => _170()])) {
2817
+ if (_optionalChain([pm, 'optionalAccess', _199 => _199.hasRuntimeRequestHooks, 'call', _200 => _200()])) {
2419
2818
  try {
2420
2819
  const routePathname = _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath);
2421
- const route = _chunk752IHQTDcjs.setFarmRouteLabel.call(void 0,
2820
+ const route = _chunkLPIZMU7Dcjs.setFarmRouteLabel.call(void 0,
2422
2821
  { pathname: requestPathname },
2423
- label !== void 0 ? label : devBuiltInRoutePaths.has(routePathname) ? routePathname : _chunk752IHQTDcjs.resolveFarmMCPRouteLabel.call(void 0, routePathname, apiServerBasePath)
2822
+ label !== void 0 ? label : devBuiltInRoutePaths.has(routePathname) ? routePathname : _chunkLPIZMU7Dcjs.resolveFarmMCPRouteLabel.call(void 0, routePathname, apiServerBasePath)
2424
2823
  );
2425
2824
  runtimeSession2 = await pm.beginRuntimeRequest(
2426
2825
  createRequestFromNodeRequest(req, new URL(fullUrl)),
2427
2826
  { kind, route }
2428
2827
  );
2429
- } catch (error) {
2828
+ } catch (e24) {
2430
2829
  await discard();
2431
- await emitPluginError("runtime-before", error, { pathname: requestPathname });
2432
- res.statusCode = 500;
2433
- res.setHeader("Content-Type", "text/plain; charset=utf-8");
2434
- res.end("Internal Server Error");
2830
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
2435
2831
  return;
2436
2832
  }
2437
2833
  if (runtimeSession2.response) {
2438
2834
  await discard();
2439
- await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0,
2440
- res,
2441
- await pm.endRuntimeRequest(runtimeSession2, runtimeSession2.response)
2442
- );
2835
+ await sendRuntimeResponse(runtimeSession2, runtimeSession2.response);
2443
2836
  return;
2444
2837
  }
2445
2838
  pm.copyRequestContext(runtimeSession2.request, req);
2446
2839
  applyWebRequestToNodeRequest(runtimeSession2.request, req);
2447
2840
  }
2448
- if (await runAppMiddlewareForContentRoute()) {
2449
- await discard();
2450
- return;
2451
- }
2452
2841
  let response;
2842
+ let responding = false;
2453
2843
  try {
2844
+ if (await runAppMiddlewareInRuntimeSession(runtimeSession2)) {
2845
+ await discard();
2846
+ return;
2847
+ }
2848
+ responding = true;
2454
2849
  response = await respond(
2455
- _nullishCoalesce(_optionalChain([runtimeSession2, 'optionalAccess', _171 => _171.request]), () => ( createRequestFromNodeRequest(req, new URL(fullUrl))))
2850
+ _nullishCoalesce(_optionalChain([runtimeSession2, 'optionalAccess', _201 => _201.request]), () => ( createRequestFromNodeRequest(req, new URL(fullUrl))))
2456
2851
  );
2457
2852
  } catch (error) {
2458
2853
  if (runtimeSession2) await pm.failRuntimeRequest(runtimeSession2, error);
2459
- throw error;
2854
+ if (!runtimeSession2 || !responding || res.headersSent) throw error;
2855
+ console.error("[FARM] Built-in route error:", error);
2856
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
2857
+ return;
2460
2858
  }
2461
2859
  if (!response) return;
2462
- await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0,
2463
- res,
2464
- runtimeSession2 ? await pm.endRuntimeRequest(runtimeSession2, response) : response
2465
- );
2860
+ if (runtimeSession2) await sendRuntimeResponse(runtimeSession2, response);
2861
+ else await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
2466
2862
  };
2467
2863
  const openAPIRequestPathname = openAPIManager ? _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath) : requestPathname;
2468
- if (openAPIManager && _optionalChain([options, 'access', _172 => _172.openapi, 'optionalAccess', _173 => _173.specRoute]) && openAPIRequestPathname === options.openapi.specRoute) {
2864
+ if (openAPIManager && _optionalChain([options, 'access', _202 => _202.openapi, 'optionalAccess', _203 => _203.specRoute]) && openAPIRequestPathname === options.openapi.specRoute) {
2469
2865
  const specManager = openAPIManager;
2470
2866
  await serveBuiltInRoute(async () => {
2471
2867
  if (requestMethod !== "GET" && requestMethod !== "HEAD") {
@@ -2485,7 +2881,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2485
2881
  });
2486
2882
  return;
2487
2883
  }
2488
- if (openAPIManager && openAPIRequestPathname === _optionalChain([options, 'access', _174 => _174.openapi, 'optionalAccess', _175 => _175.route])) {
2884
+ if (openAPIManager && openAPIRequestPathname === _optionalChain([options, 'access', _204 => _204.openapi, 'optionalAccess', _205 => _205.route])) {
2489
2885
  const docsManager = openAPIManager;
2490
2886
  await serveBuiltInRoute(
2491
2887
  async () => {
@@ -2496,24 +2892,24 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2496
2892
  );
2497
2893
  return;
2498
2894
  }
2499
- if (_optionalChain([options, 'access', _176 => _176.agent, 'optionalAccess', _177 => _177.manifest]) !== false && _chunk752IHQTDcjs.isFarmAppManifestPath.call(void 0, _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath))) {
2895
+ if (_optionalChain([options, 'access', _206 => _206.agent, 'optionalAccess', _207 => _207.manifest]) !== false && _chunkLPIZMU7Dcjs.isFarmAppManifestPath.call(void 0, _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath))) {
2500
2896
  await serveBuiltInRoute(async () => {
2501
- _nullishCoalesce(farmAppPackages, () => ( (farmAppPackages = _chunkE4UDLFWRcjs.resolveFarmAppPackages.call(void 0, _nullishCoalesce(farmConfig.root, () => ( process.cwd()))))));
2502
- const manifest = await _chunk752IHQTDcjs.createFarmAppManifestResponse.call(void 0,
2897
+ _nullishCoalesce(farmAppPackages, () => ( (farmAppPackages = _chunkN5DQMOAGcjs.resolveFarmAppPackages.call(void 0, _nullishCoalesce(farmConfig.root, () => ( process.cwd()))))));
2898
+ const manifest = await _chunkLPIZMU7Dcjs.createFarmAppManifestResponse.call(void 0,
2503
2899
  new Request(parsedRequestUrl, {
2504
2900
  method: requestMethod,
2505
2901
  headers: { "if-none-match": String(_nullishCoalesce(req.headers["if-none-match"], () => ( ""))) }
2506
2902
  }),
2507
2903
  {
2508
- ..._chunk752IHQTDcjs.resolveFarmAppManifestInput.call(void 0, farmConfig, {
2904
+ ..._chunkLPIZMU7Dcjs.resolveFarmAppManifestInput.call(void 0, farmConfig, {
2509
2905
  build: "development",
2510
2906
  packages: farmAppPackages,
2511
2907
  // Read again on each request; unchanged files come from a cache.
2512
- webmcpTools: _optionalChain([farmConfig, 'access', _178 => _178.plugins, 'optionalAccess', _179 => _179.some, 'call', _180 => _180(({ name }) => name === "farm:webmcp")]) ? _chunkE4UDLFWRcjs.collectFarmWebMCPTools.call(void 0, _nullishCoalesce(farmConfig.root, () => ( process.cwd())), farmConfig.srcDir) : []
2908
+ webmcpTools: _optionalChain([farmConfig, 'access', _208 => _208.plugins, 'optionalAccess', _209 => _209.some, 'call', _210 => _210(({ name }) => name === "farm:webmcp")]) ? _chunkN5DQMOAGcjs.collectFarmWebMCPTools.call(void 0, _nullishCoalesce(farmConfig.root, () => ( process.cwd())), farmConfig.srcDir) : []
2513
2909
  }),
2514
2910
  defaultMCP: () => farmApp.getServerRenderer().getDefaultMCPServer(),
2515
2911
  // A guard written for an MCP server's path keeps its tools out of the public view.
2516
- guardCoversPath: (path7) => _chunkUJ3R2AH2cjs.farmPathGuardCoversEndpoint.call(void 0,
2912
+ guardCoversPath: (path7) => _chunkUPOYKX4Scjs.farmPathGuardCoversEndpoint.call(void 0,
2517
2913
  {
2518
2914
  config: farmConfig,
2519
2915
  middlewareRoutes: middlewareManager.getMiddlewares().filter((entry) => entry.source !== "config")
@@ -2527,11 +2923,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2527
2923
  });
2528
2924
  return;
2529
2925
  }
2530
- if (_optionalChain([options, 'access', _181 => _181.agent, 'optionalAccess', _182 => _182.apiCatalog]) && _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath) === _chunk752IHQTDcjs.FARM_API_CATALOG_PATH) {
2926
+ if (_optionalChain([options, 'access', _211 => _211.agent, 'optionalAccess', _212 => _212.apiCatalog]) && _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath) === _chunkLPIZMU7Dcjs.FARM_API_CATALOG_PATH) {
2531
2927
  await serveBuiltInRoute(
2532
- () => _chunk752IHQTDcjs.createFarmApiCatalogResponse.call(void 0,
2928
+ () => _chunkLPIZMU7Dcjs.createFarmApiCatalogResponse.call(void 0,
2533
2929
  requestMethod,
2534
- _chunk752IHQTDcjs.resolveFarmApiCatalogInput.call(void 0, { ...options, api: farmConfig.api }),
2930
+ _chunkLPIZMU7Dcjs.resolveFarmApiCatalogInput.call(void 0, { ...options, api: farmConfig.api }),
2535
2931
  new Request(parsedRequestUrl, {
2536
2932
  headers: { "user-agent": String(_nullishCoalesce(req.headers["user-agent"], () => ( ""))) }
2537
2933
  })
@@ -2539,8 +2935,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2539
2935
  );
2540
2936
  return;
2541
2937
  }
2542
- if (_optionalChain([options, 'access', _183 => _183.agent, 'optionalAccess', _184 => _184.aiCatalog]) !== false) {
2543
- const aiCatalog = _chunk752IHQTDcjs.createFarmAiCatalogResponse.call(void 0,
2938
+ if (_optionalChain([options, 'access', _213 => _213.agent, 'optionalAccess', _214 => _214.aiCatalog]) !== false) {
2939
+ const aiCatalog = _chunkLPIZMU7Dcjs.createFarmAiCatalogResponse.call(void 0,
2544
2940
  new Request(parsedRequestUrl, {
2545
2941
  method: requestMethod,
2546
2942
  headers: {
@@ -2549,7 +2945,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2549
2945
  }
2550
2946
  }),
2551
2947
  {
2552
- basePath: farmConfig.basePath,
2948
+ basePath: farmApp.getConfig().basePath,
2553
2949
  apiServerBasePath,
2554
2950
  defaultMCP: () => farmApp.getServerRenderer().getDefaultMCPServer()
2555
2951
  }
@@ -2566,11 +2962,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2566
2962
  }
2567
2963
  }
2568
2964
  const viteModuleRequest = isViteModuleRequest(parsedRequestUrl, req.headers);
2569
- const appOwnsDocsEnginePath = farmAppOwnsDocsEnginePath(requestPathname, {
2570
- generatedPaths: farmAgentGeneratedPaths(farmConfig),
2571
- routeManager: farmApp.getRouteManager(),
2572
- publicDir: server.config.publicDir
2573
- });
2965
+ const toRoutePathname = (pathname2) => farmApp.getRouteManager().toRoutePathname(pathname2);
2966
+ const appOwnsDocsEnginePath = farmAppOwnsDocsEnginePath(
2967
+ toRoutePathname(requestPathname),
2968
+ {
2969
+ generatedPaths: farmAgentGeneratedPaths(farmConfig),
2970
+ routeManager: farmApp.getRouteManager(),
2971
+ publicDir: server.config.publicDir
2972
+ }
2973
+ );
2574
2974
  if (farmDocsHandler && !appOwnsDocsEnginePath && !viteModuleRequest) {
2575
2975
  const docsRequest = new Request(fullUrl, {
2576
2976
  method: requestMethod,
@@ -2584,11 +2984,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2584
2984
  {
2585
2985
  kind: "docs",
2586
2986
  computed: docsResponse,
2587
- label: _chunk752IHQTDcjs.resolveFarmDocsEngineRouteLabel.call(void 0,
2987
+ label: _chunkLPIZMU7Dcjs.resolveFarmDocsEngineRouteLabel.call(void 0,
2588
2988
  _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath),
2589
2989
  {
2590
- path: _optionalChain([farmConfig, 'access', _185 => _185.docs, 'optionalAccess', _186 => _186.entry]) || "/docs",
2591
- roots: _optionalChain([farmConfig, 'access', _187 => _187.docs, 'optionalAccess', _188 => _188.roots, 'optionalAccess', _189 => _189.map, 'call', _190 => _190((root) => root.entry)])
2990
+ path: _optionalChain([farmConfig, 'access', _215 => _215.docs, 'optionalAccess', _216 => _216.entry]) || "/docs",
2991
+ roots: _optionalChain([farmConfig, 'access', _217 => _217.docs, 'optionalAccess', _218 => _218.roots, 'optionalAccess', _219 => _219.map, 'call', _220 => _220((root) => root.entry)])
2592
2992
  }
2593
2993
  )
2594
2994
  }
@@ -2596,8 +2996,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2596
2996
  return;
2597
2997
  }
2598
2998
  }
2599
- if (options.mobileClient && !viteModuleRequest && (requestMethod === "GET" || requestMethod === "HEAD" || requestMethod === "POST") && _optionalChain([req, 'access', _191 => _191.headers, 'access', _192 => _192.accept, 'optionalAccess', _193 => _193.includes, 'call', _194 => _194(_chunk3HLQTOVUcjs.FARM_NATIVE_TREE_CONTENT_TYPE)])) {
2600
- const { createFarmNativeTreeResponse } = await import("./native-tree-7LPH57Z4.cjs");
2999
+ if (options.mobileClient && !viteModuleRequest && (requestMethod === "GET" || requestMethod === "HEAD" || requestMethod === "POST") && _optionalChain([req, 'access', _221 => _221.headers, 'access', _222 => _222.accept, 'optionalAccess', _223 => _223.includes, 'call', _224 => _224(_chunk3HLQTOVUcjs.FARM_NATIVE_TREE_CONTENT_TYPE)])) {
3000
+ const { createFarmNativeTreeResponse } = await import("./native-tree-W2SSJB3Y.cjs");
2601
3001
  const treeBodyInit = requestMethod === "POST" ? { body: _chunkCFG4QERRcjs.createFarmNodeRequestBodyStream.call(void 0, req), duplex: "half" } : {};
2602
3002
  const treeResponse = await createFarmNativeTreeResponse({
2603
3003
  request: new Request(fullUrl, {
@@ -2614,23 +3014,27 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2614
3014
  });
2615
3015
  await serveBuiltInRoute(() => treeResponse, {
2616
3016
  computed: treeResponse,
2617
- label: _nullishCoalesce(_optionalChain([farmApp, 'access', _195 => _195.getRouteManager, 'call', _196 => _196(), 'access', _197 => _197.matchRoute, 'call', _198 => _198(_chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath)), 'access', _199 => _199.route, 'optionalAccess', _200 => _200.pattern]), () => ( null))
3017
+ label: _nullishCoalesce(_optionalChain([farmApp, 'access', _225 => _225.getRouteManager, 'call', _226 => _226(), 'access', _227 => _227.matchRoute, 'call', _228 => _228(_chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath)), 'access', _229 => _229.route, 'optionalAccess', _230 => _230.pattern]), () => ( null))
2618
3018
  });
2619
3019
  return;
2620
3020
  }
2621
- const markdownRouteLabel = () => _chunk752IHQTDcjs.resolveFarmMarkdownRouteLabel.call(void 0,
2622
- _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, requestPathname, farmConfig.basePath),
2623
- (page) => _optionalChain([farmApp, 'access', _201 => _201.getRouteManager, 'call', _202 => _202(), 'access', _203 => _203.matchRoute, 'call', _204 => _204(page), 'access', _205 => _205.route, 'optionalAccess', _206 => _206.pattern])
3021
+ const markdownRouteLabel = () => (
3022
+ // On the route path, as production labels it: /fr/index.md is /index.md.
3023
+ _chunkLPIZMU7Dcjs.resolveFarmMarkdownRouteLabel.call(void 0,
3024
+ toRoutePathname(requestPathname),
3025
+ (page) => _optionalChain([farmApp, 'access', _231 => _231.getRouteManager, 'call', _232 => _232(), 'access', _233 => _233.matchRoute, 'call', _234 => _234(page), 'access', _235 => _235.route, 'optionalAccess', _236 => _236.pattern])
3026
+ )
2624
3027
  );
2625
- const markdownSourceResponse = viteModuleRequest ? null : await _chunk7XGWBPQQcjs.createFarmMarkdownSourceResponse.call(void 0, {
3028
+ const markdownSourceResponse = viteModuleRequest ? null : await _chunkQ37INCXGcjs.createFarmMarkdownSourceResponse.call(void 0, {
2626
3029
  request: new Request(fullUrl, {
2627
3030
  method: requestMethod,
2628
3031
  headers: docsHeaders
2629
3032
  }),
2630
3033
  config: farmApp.getConfig().mdx,
3034
+ routePathname: toRoutePathname,
2631
3035
  resolveSource: async (pathname2) => {
2632
3036
  const match = farmApp.getRouteManager().matchRoute(pathname2);
2633
- const sourcePath = _optionalChain([match, 'access', _207 => _207.route, 'optionalAccess', _208 => _208.markdownSourcePath]) || (match.route && _chunk7XGWBPQQcjs.isFarmMarkdownPageFile.call(void 0, match.route.modulePath) ? match.route.modulePath : null);
3037
+ const sourcePath = _optionalChain([match, 'access', _237 => _237.route, 'optionalAccess', _238 => _238.markdownSourcePath]) || (match.route && _chunkQ37INCXGcjs.isFarmMarkdownPageFile.call(void 0, match.route.modulePath) ? match.route.modulePath : null);
2634
3038
  if (!sourcePath) {
2635
3039
  return null;
2636
3040
  }
@@ -2655,12 +3059,13 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2655
3059
  });
2656
3060
  return;
2657
3061
  }
2658
- const markdownResponse = viteModuleRequest ? null : await _chunk2C5L5RPMcjs.createMarkdownMirrorResponse.call(void 0, {
3062
+ const markdownResponse = viteModuleRequest ? null : await _chunkFT6KJHS3cjs.createMarkdownMirrorResponse.call(void 0, {
2659
3063
  request: new Request(fullUrl, {
2660
3064
  method: requestMethod,
2661
3065
  headers: docsHeaders
2662
3066
  }),
2663
3067
  config: farmApp.getConfig().md,
3068
+ routePathname: toRoutePathname,
2664
3069
  routeExists: (pathname2) => Boolean(farmApp.getRouteManager().matchRoute(pathname2).route),
2665
3070
  // The page is rendered by this server's own listener, never the host the
2666
3071
  // caller's Host names. Redirects are not followed, so the mirror answers with
@@ -2686,16 +3091,16 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2686
3091
  });
2687
3092
  return;
2688
3093
  }
2689
- if (!viteModuleRequest && _chunk2C5L5RPMcjs.farmRequestWantsMarkdown.call(void 0, requestPathname, req.headers.accept)) {
2690
- const markdownRoute = farmApp.getRouteManager().matchRoute(_chunk7XGWBPQQcjs.normalizeFarmMarkdownRoutePath.call(void 0, requestPathname));
3094
+ if (!viteModuleRequest && _chunkFT6KJHS3cjs.farmRequestWantsMarkdown.call(void 0, requestPathname, req.headers.accept)) {
3095
+ const markdownRoute = farmApp.getRouteManager().matchRoute(_chunkQ37INCXGcjs.normalizeFarmMarkdownRoutePath.call(void 0, requestPathname, toRoutePathname));
2691
3096
  if (!markdownRoute.route) {
2692
3097
  await serveBuiltInRoute(
2693
3098
  () => new Response(
2694
- _chunk2C5L5RPMcjs.createFarmMarkdownErrorBody.call(void 0, 404, requestPathname, farmConfig.basePath || "/"),
3099
+ _chunkFT6KJHS3cjs.createFarmMarkdownErrorBody.call(void 0, 404, requestPathname, farmConfig.basePath || "/"),
2695
3100
  {
2696
3101
  status: 404,
2697
3102
  headers: {
2698
- "Content-Type": _chunk2C5L5RPMcjs.FARM_MARKDOWN_CONTENT_TYPE,
3103
+ "Content-Type": _chunkFT6KJHS3cjs.FARM_MARKDOWN_CONTENT_TYPE,
2699
3104
  "X-Farm-Markdown-Error": "404",
2700
3105
  "Cache-Control": "no-store"
2701
3106
  }
@@ -2705,11 +3110,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2705
3110
  return;
2706
3111
  }
2707
3112
  }
2708
- const markdownPageTarget = _chunk2C5L5RPMcjs.resolveMarkdownMirrorTarget.call(void 0,
3113
+ const markdownPageTarget = _chunkFT6KJHS3cjs.resolveMarkdownMirrorTarget.call(void 0,
2709
3114
  farmApp.getConfig().md,
2710
3115
  requestPathname,
2711
3116
  {
2712
- accept: "text/markdown"
3117
+ accept: "text/markdown",
3118
+ routePathname: toRoutePathname
2713
3119
  }
2714
3120
  );
2715
3121
  if (markdownPageTarget && farmApp.getRouteManager().matchRoute(markdownPageTarget.pathname).route) {
@@ -2718,8 +3124,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2718
3124
  if (!varyValues.some((value) => value.toLowerCase() === "accept")) {
2719
3125
  res.setHeader("Vary", [...varyValues, "Accept"].join(", "));
2720
3126
  }
2721
- const alternatePath = _chunk2C5L5RPMcjs.getFarmMarkdownMirrorPath.call(void 0, markdownPageTarget.pathname);
2722
- const alternateLink = `<${alternatePath}>; rel="alternate"; type="text/markdown"`;
3127
+ const alternateLink = `<${markdownPageTarget.markdownPath}>; rel="alternate"; type="text/markdown"`;
2723
3128
  const currentLink = res.getHeader("Link");
2724
3129
  res.setHeader(
2725
3130
  "Link",
@@ -2756,7 +3161,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2756
3161
  }
2757
3162
  const configuredIntegrations = currentConfig.integrations;
2758
3163
  const tryConfiguredIntegrationRoute = async () => {
2759
- const matchedRoute = _chunkI32V5CZLcjs.matchIntegrationRoute.call(void 0, configuredIntegrations, {
3164
+ const matchedRoute = _chunkBDYM2TN3cjs.matchIntegrationRoute.call(void 0, configuredIntegrations, {
2760
3165
  pathname: requestPathname,
2761
3166
  method: requestMethod
2762
3167
  });
@@ -2764,13 +3169,14 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2764
3169
  return false;
2765
3170
  }
2766
3171
  const startTime2 = Date.now();
3172
+ let runtimeReportsErrors = false;
2767
3173
  try {
2768
3174
  if (pm) {
2769
3175
  await pm.runHookParallelFiltered(
2770
3176
  "beforeRequest",
2771
- (plugin) => {
2772
- const owner = _chunkI32V5CZLcjs.getFarmIntegrationPluginOwner.call(void 0, plugin);
2773
- return plugin.name !== _chunkUYTAP4FQcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME && (_optionalChain([owner, 'optionalAccess', _209 => _209.source]) !== "lifecycle" || owner.key !== matchedRoute.key);
3177
+ (plugin2) => {
3178
+ const owner = _chunkBDYM2TN3cjs.getFarmIntegrationPluginOwner.call(void 0, plugin2);
3179
+ return !isFarmConfigRoutePlugin(plugin2) && (_optionalChain([owner, 'optionalAccess', _239 => _239.source]) !== "lifecycle" || owner.key !== matchedRoute.key);
2774
3180
  },
2775
3181
  req,
2776
3182
  res
@@ -2797,22 +3203,29 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2797
3203
  body: toRequestBody(body),
2798
3204
  signal: _chunkCFG4QERRcjs.createFarmNodeRequestAbortSignal.call(void 0, req, res)
2799
3205
  });
2800
- const dispatchIntegration = async (request) => {
2801
- const result = await _chunkI32V5CZLcjs.dispatchIntegrationRequest.call(void 0,
2802
- {
2803
- integration: matchedRoute.integration,
2804
- config: currentConfig,
2805
- isDev: true,
2806
- isProd: false
2807
- },
2808
- request,
2809
- { clientAddress: _optionalChain([req, 'access', _210 => _210.socket, 'optionalAccess', _211 => _211.remoteAddress]) }
2810
- );
2811
- if (!result) {
2812
- throw new Error(`Matched integration route did not return a response`);
3206
+ const dispatchIntegration = async (request, runtime) => {
3207
+ try {
3208
+ const result = await _chunkBDYM2TN3cjs.dispatchIntegrationRequest.call(void 0,
3209
+ {
3210
+ integration: matchedRoute.integration,
3211
+ config: currentConfig,
3212
+ isDev: true,
3213
+ isProd: false
3214
+ },
3215
+ request,
3216
+ { clientAddress: _optionalChain([req, 'access', _240 => _240.socket, 'optionalAccess', _241 => _241.remoteAddress]) }
3217
+ );
3218
+ if (!result) {
3219
+ throw new Error(`Matched integration route did not return a response`);
3220
+ }
3221
+ return result;
3222
+ } catch (error) {
3223
+ _chunkQMNWKQL4cjs.logger.error(`Integration route error: ${error}`);
3224
+ await _optionalChain([runtime, 'optionalAccess', _242 => _242.reportError, 'call', _243 => _243(error)]);
3225
+ return _chunkXGTFLG73cjs.createFarmInternalServerErrorResponse.call(void 0, );
2813
3226
  }
2814
- return result;
2815
3227
  };
3228
+ runtimeReportsErrors = Boolean(pm);
2816
3229
  const response = pm ? await pm.runRuntimeRequest(integrationRequest, dispatchIntegration, {
2817
3230
  kind: "integration",
2818
3231
  route: {
@@ -2835,21 +3248,59 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2835
3248
  }
2836
3249
  const duration = Date.now() - startTime2;
2837
3250
  logResponse(requestMethod, requestUrl, 500, duration, "API");
2838
- await emitPluginError("integration-handler", error, {
2839
- pathname: requestPathname,
2840
- routePath: requestUrl,
2841
- method: requestMethod,
2842
- integration: matchedRoute.key
2843
- });
3251
+ if (!runtimeReportsErrors) {
3252
+ await emitPluginError("integration-handler", error, {
3253
+ pathname: requestPathname,
3254
+ routePath: requestUrl,
3255
+ method: requestMethod,
3256
+ integration: matchedRoute.key
3257
+ });
3258
+ }
2844
3259
  _chunkQMNWKQL4cjs.logger.error(`Integration route error: ${error}`);
2845
3260
  if (!res.writableEnded) {
2846
3261
  res.statusCode = 500;
2847
3262
  res.setHeader("Content-Type", "application/json");
2848
- res.end(JSON.stringify({ error: "Internal server error" }));
3263
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
2849
3264
  }
2850
3265
  return true;
2851
3266
  }
2852
3267
  };
3268
+ if (pm && configRewriteSource === void 0 && configRoutePlugins.has(_chunkAKIQ54FKcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME)) {
3269
+ const hasLocalDevRoute = () => {
3270
+ const routeManager3 = farmApp.getRouteManager();
3271
+ return Boolean(
3272
+ _chunkBDYM2TN3cjs.matchIntegrationRoute.call(void 0, configuredIntegrations, {
3273
+ pathname: requestPathname,
3274
+ method: requestMethod
3275
+ }) || routeManager3.matchRedirect(requestPathname) || apiRouteManager.matchRoute(requestPathname) || farmDocsAPIHandler && _optionalChain([farmDocsDevRuntime, 'optionalAccess', _244 => _244.isFarmDocsAPIRequest, 'call', _245 => _245(requestPathname)]) || routeManager3.matchRoute(requestPathname).route || routeManager3.matchMetadataRoute(requestPathname) || routeManager3.matchMetadataImage(requestPathname)
3276
+ );
3277
+ };
3278
+ try {
3279
+ await pm.runHookParallelFiltered(
3280
+ "beforeRequest",
3281
+ (plugin2) => plugin2.name === _chunkAKIQ54FKcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME,
3282
+ req,
3283
+ res
3284
+ );
3285
+ } catch (error) {
3286
+ await emitPluginError("before-request", error, { urlPath: requestUrl });
3287
+ res.statusCode = 500;
3288
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
3289
+ res.end("Internal Server Error");
3290
+ return;
3291
+ }
3292
+ if (req.url !== requestUrl) {
3293
+ if (isViteOwnedRequest() || hasLocalDevRoute()) {
3294
+ req.url = requestUrl;
3295
+ } else {
3296
+ if (await proxyFarmExternalRewrite(req, res, currentServerConfig.bodySizeLimit)) {
3297
+ return;
3298
+ }
3299
+ req[FARM_DEV_CONFIG_REWRITE_SOURCE] = fullUrl;
3300
+ return handleFarmDevRequest(req, res, next);
3301
+ }
3302
+ }
3303
+ }
2853
3304
  if (await tryConfiguredIntegrationRoute()) {
2854
3305
  return;
2855
3306
  }
@@ -2862,32 +3313,25 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2862
3313
  }
2863
3314
  const matchedApiRoute = apiRouteManager.matchRoute(requestPathname);
2864
3315
  const hasMatchedApiRoute = Boolean(matchedApiRoute);
2865
- if (hasMatchedApiRoute || _chunkZ7P2BTZ3cjs.isFarmAPIPathname.call(void 0, requestPathname, apiServerBasePath)) {
3316
+ if (hasMatchedApiRoute || _chunkXGTFLG73cjs.isFarmAPIPathname.call(void 0, requestPathname, apiServerBasePath)) {
2866
3317
  const startTime2 = Date.now();
2867
3318
  const method2 = req.method || "GET";
2868
3319
  const urlPath2 = req.url || "/";
2869
- const pathname2 = _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, req, {
3320
+ const pathname2 = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, {
2870
3321
  trustProxy: currentServerConfig.trustProxy
2871
3322
  }).pathname;
2872
- const servesLocalApiRoute = hasMatchedApiRoute || Boolean(
2873
- farmDocsAPIHandler && _optionalChain([farmDocsDevRuntime, 'optionalAccess', _212 => _212.isFarmDocsAPIRequest, 'call', _213 => _213(requestPathname)])
2874
- );
2875
3323
  try {
2876
3324
  if (pm) {
2877
- if (servesLocalApiRoute) {
2878
- await pm.runHookParallelFiltered(
2879
- "beforeRequest",
2880
- (plugin) => plugin.name !== _chunkUYTAP4FQcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME,
2881
- req,
2882
- res
2883
- );
2884
- } else {
2885
- await pm.runHookParallel("beforeRequest", req, res);
2886
- }
3325
+ await pm.runHookParallelFiltered(
3326
+ "beforeRequest",
3327
+ (plugin2) => !isFarmConfigRoutePlugin(plugin2),
3328
+ req,
3329
+ res
3330
+ );
2887
3331
  }
2888
- if (res.writableEnded || await proxyFarmExternalRewrite(req, res, currentServerConfig.bodySizeLimit)) {
2889
- const duration2 = Date.now() - startTime2;
2890
- logResponse(method2, urlPath2, res.statusCode || 200, duration2, "API");
3332
+ if (res.writableEnded) {
3333
+ const duration = Date.now() - startTime2;
3334
+ logResponse(method2, urlPath2, res.statusCode || 200, duration, "API");
2891
3335
  return;
2892
3336
  }
2893
3337
  } catch (error) {
@@ -2898,23 +3342,138 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2898
3342
  _chunkQMNWKQL4cjs.logger.error(`Request hook error: ${error}`);
2899
3343
  res.statusCode = 500;
2900
3344
  res.setHeader("Content-Type", "application/json");
2901
- res.end(JSON.stringify({ error: "Internal server error" }));
3345
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
2902
3346
  return;
2903
3347
  }
2904
- if (await runAppMiddlewareForContentRoute()) {
2905
- const duration2 = Date.now() - startTime2;
2906
- logResponse(method2, urlPath2, res.statusCode || 200, duration2, "API");
3348
+ const createAPIRequest = async () => {
3349
+ const headers = new Headers();
3350
+ for (const [key, value] of Object.entries(req.headers)) {
3351
+ if (value) {
3352
+ headers.set(key, Array.isArray(value) ? value.join(", ") : value);
3353
+ }
3354
+ }
3355
+ let body;
3356
+ if (req.method !== "GET" && req.method !== "HEAD") {
3357
+ body = await _chunkCFG4QERRcjs.readNodeRequestBody.call(void 0, req, currentServerConfig.bodySizeLimit);
3358
+ }
3359
+ return new Request(`http://${req.headers.host || "localhost:3000"}${req.url}`, {
3360
+ method: req.method,
3361
+ headers,
3362
+ body: toRequestBody(body),
3363
+ signal: _chunkCFG4QERRcjs.createFarmNodeRequestAbortSignal.call(void 0, req, res)
3364
+ });
3365
+ };
3366
+ const isDocsAPIRequest = Boolean(
3367
+ farmDocsAPIHandler && _optionalChain([farmDocsDevRuntime, 'optionalAccess', _246 => _246.isFarmDocsAPIRequest, 'call', _247 => _247(pathname2)])
3368
+ );
3369
+ const docsRuntimeOptions = () => ({
3370
+ kind: "docs",
3371
+ route: _chunkLPIZMU7Dcjs.setFarmRouteLabel.call(void 0,
3372
+ { pathname: pathname2, pattern: urlPath2 },
3373
+ _chunkLPIZMU7Dcjs.resolveFarmDocsRouteLabel.call(void 0, pathname2, {
3374
+ path: _optionalChain([farmConfig, 'access', _248 => _248.docs, 'optionalAccess', _249 => _249.entry]) || "/docs",
3375
+ roots: _optionalChain([farmConfig, 'access', _250 => _250.docs, 'optionalAccess', _251 => _251.roots, 'optionalAccess', _252 => _252.map, 'call', _253 => _253((root) => root.entry)])
3376
+ })
3377
+ )
3378
+ });
3379
+ let runtimeSession2;
3380
+ let sessionRequestUrl;
3381
+ if (_optionalChain([pm, 'optionalAccess', _254 => _254.hasRuntimeRequestHooks, 'call', _255 => _255()])) {
3382
+ try {
3383
+ runtimeSession2 = await pm.beginRuntimeRequest(
3384
+ await createAPIRequest(),
3385
+ !hasMatchedApiRoute && isDocsAPIRequest ? docsRuntimeOptions() : {
3386
+ kind: "api",
3387
+ route: matchedApiRoute ? { pathname: pathname2, pattern: matchedApiRoute.route.path } : { pathname: pathname2 }
3388
+ }
3389
+ );
3390
+ if (runtimeSession2.response) {
3391
+ const response = await pm.endRuntimeRequest(
3392
+ runtimeSession2,
3393
+ runtimeSession2.response
3394
+ );
3395
+ logResponse(method2, urlPath2, response.status, Date.now() - startTime2, "API");
3396
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
3397
+ return;
3398
+ }
3399
+ } catch (error) {
3400
+ const bodyErrorResponse = _chunkCFG4QERRcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
3401
+ if (bodyErrorResponse) {
3402
+ logResponse(
3403
+ method2,
3404
+ urlPath2,
3405
+ bodyErrorResponse.status,
3406
+ Date.now() - startTime2,
3407
+ "API"
3408
+ );
3409
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, bodyErrorResponse);
3410
+ return;
3411
+ }
3412
+ _chunkQMNWKQL4cjs.logger.error(`API route error: ${error}`);
3413
+ res.statusCode = 500;
3414
+ res.setHeader("Content-Type", "application/json");
3415
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
3416
+ return;
3417
+ }
3418
+ pm.copyRequestContext(runtimeSession2.request, req);
3419
+ applyWebRequestToNodeRequest(runtimeSession2.request, req);
3420
+ sessionRequestUrl = req.url;
3421
+ }
3422
+ try {
3423
+ if (await runAppMiddlewareInRuntimeSession(
3424
+ runtimeSession2,
3425
+ (status) => logResponse(method2, urlPath2, status, Date.now() - startTime2, "API")
3426
+ )) {
3427
+ return;
3428
+ }
3429
+ } catch (error) {
3430
+ if (res.headersSent) {
3431
+ if (runtimeSession2) await pm.failRuntimeRequest(runtimeSession2, error);
3432
+ throw error;
3433
+ }
3434
+ _chunkQMNWKQL4cjs.logger.error(`Middleware error: ${error}`);
3435
+ let response = createFarmDevMiddlewareErrorResponse();
3436
+ if (runtimeSession2) {
3437
+ const errorResponse = response;
3438
+ try {
3439
+ response = await pm.completeRuntimeRequest(
3440
+ runtimeSession2,
3441
+ async (_request, runtime) => {
3442
+ await runtime.reportError(error);
3443
+ return errorResponse;
3444
+ }
3445
+ );
3446
+ } catch (e25) {
3447
+ logResponse(method2, urlPath2, 500, Date.now() - startTime2, "API");
3448
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
3449
+ return;
3450
+ }
3451
+ }
3452
+ logResponse(method2, urlPath2, response.status, Date.now() - startTime2, "API");
3453
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
2907
3454
  return;
2908
3455
  }
3456
+ const createHandlerRequest = async () => {
3457
+ if (runtimeSession2 && req.url === sessionRequestUrl && !runtimeSession2.request.bodyUsed) {
3458
+ return runtimeSession2.request;
3459
+ }
3460
+ const request = await createAPIRequest();
3461
+ if (runtimeSession2) pm.copyRequestContext(runtimeSession2.request, request);
3462
+ return request;
3463
+ };
3464
+ const runInRuntime = (request, handler, options2) => runtimeSession2 ? pm.completeRuntimeRequest(
3465
+ runtimeSession2,
3466
+ (_request, runtime) => handler(request, runtime)
3467
+ ) : pm ? pm.runRuntimeRequest(request, handler, options2) : handler(request);
2909
3468
  const apiHandler = apiRouteManager.getHandler({ throwOnError: true });
2910
- const routedPathname = _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, req, {
3469
+ const routedPathname = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, {
2911
3470
  trustProxy: currentServerConfig.trustProxy
2912
3471
  }).pathname;
2913
3472
  const rewritten = routedPathname !== pathname2;
2914
3473
  const routedApiRoute = rewritten ? apiRouteManager.matchRoute(routedPathname) : matchedApiRoute || apiRouteManager.matchRoute(pathname2);
2915
3474
  const hasExplicitAPIRoute = Boolean(routedApiRoute);
2916
3475
  if (apiHandler && hasExplicitAPIRoute) {
2917
- const apiRoutePattern = _optionalChain([routedApiRoute, 'optionalAccess', _214 => _214.route, 'access', _215 => _215.path]) || urlPath2;
3476
+ const apiRoutePattern = _optionalChain([routedApiRoute, 'optionalAccess', _256 => _256.route, 'access', _257 => _257.path]) || urlPath2;
2918
3477
  _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0, {
2919
3478
  type: "route.matched",
2920
3479
  pathname: pathname2,
@@ -2928,101 +3487,85 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2928
3487
  });
2929
3488
  try {
2930
3489
  const url = `http://${req.headers.host || "localhost:3000"}${req.url}`;
2931
- const headers = new Headers();
2932
- for (const [key, value] of Object.entries(req.headers)) {
2933
- if (value) {
2934
- headers.set(key, Array.isArray(value) ? value.join(", ") : value);
2935
- }
2936
- }
2937
- let body;
2938
- if (req.method !== "GET" && req.method !== "HEAD") {
2939
- body = await _chunkCFG4QERRcjs.readNodeRequestBody.call(void 0, req, currentServerConfig.bodySizeLimit);
2940
- }
2941
- const request = new Request(url, {
2942
- method: req.method,
2943
- headers,
2944
- body: toRequestBody(body),
2945
- signal: _chunkCFG4QERRcjs.createFarmNodeRequestAbortSignal.call(void 0, req, res)
2946
- });
3490
+ const request = await createHandlerRequest();
2947
3491
  const apiLifecyclePayload = {
2948
3492
  pathname: new URL(url).pathname,
2949
3493
  method: method2,
2950
3494
  routePath: apiRoutePattern
2951
3495
  };
2952
- const invokeAPIHandler = async (runtimeRequest) => {
3496
+ let apiHandlerFailed = false;
3497
+ const invokeAPIHandler = async (runtimeRequest, runtime) => {
2953
3498
  const handledRequest = pm ? await pm.runHookSerial(
2954
3499
  "beforeApiHandler",
2955
3500
  runtimeRequest,
2956
3501
  apiLifecyclePayload
2957
3502
  ) : runtimeRequest;
2958
- const response = await apiHandler(handledRequest);
3503
+ let response;
3504
+ try {
3505
+ response = await apiHandler(handledRequest);
3506
+ } catch (error) {
3507
+ apiHandlerFailed = true;
3508
+ _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0, {
3509
+ type: "api.error",
3510
+ pathname: pathname2,
3511
+ route: apiRoutePattern,
3512
+ method: method2,
3513
+ durationMs: Date.now() - startTime2,
3514
+ error
3515
+ });
3516
+ _chunkQMNWKQL4cjs.logger.error(`API route error: ${error}`);
3517
+ await _optionalChain([runtime, 'optionalAccess', _258 => _258.reportError, 'call', _259 => _259(error)]);
3518
+ response = _chunkXGTFLG73cjs.createFarmInternalServerErrorResponse.call(void 0, );
3519
+ }
2959
3520
  return pm ? await pm.runHookSerial("afterApiHandler", response, apiLifecyclePayload) : response;
2960
3521
  };
2961
- const handledResponse = pm ? await pm.runRuntimeRequest(request, invokeAPIHandler, {
3522
+ const handledResponse = await runInRuntime(request, invokeAPIHandler, {
2962
3523
  kind: "api",
2963
3524
  route: {
2964
3525
  pathname: apiLifecyclePayload.pathname,
2965
3526
  pattern: apiLifecyclePayload.routePath
2966
3527
  }
2967
- }) : await invokeAPIHandler(request);
2968
- const duration2 = Date.now() - startTime2;
2969
- _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0, {
2970
- type: "api.request.complete",
2971
- pathname: pathname2,
2972
- route: apiRoutePattern,
2973
- method: method2,
2974
- status: handledResponse.status,
2975
- durationMs: duration2
2976
3528
  });
2977
- logResponse(method2, urlPath2, handledResponse.status, duration2, "API");
3529
+ const duration = Date.now() - startTime2;
3530
+ if (!apiHandlerFailed) {
3531
+ _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0, {
3532
+ type: "api.request.complete",
3533
+ pathname: pathname2,
3534
+ route: apiRoutePattern,
3535
+ method: method2,
3536
+ status: handledResponse.status,
3537
+ durationMs: duration
3538
+ });
3539
+ }
3540
+ logResponse(method2, urlPath2, handledResponse.status, duration, "API");
2978
3541
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, handledResponse);
2979
3542
  return;
2980
3543
  } catch (error) {
2981
- const duration2 = Date.now() - startTime2;
3544
+ const duration = Date.now() - startTime2;
2982
3545
  _chunkEVIWKPJVcjs.emitFarmEvent.call(void 0, {
2983
3546
  type: "api.error",
2984
3547
  pathname: pathname2,
2985
3548
  route: apiRoutePattern,
2986
3549
  method: method2,
2987
- durationMs: duration2,
3550
+ durationMs: duration,
2988
3551
  error
2989
3552
  });
2990
3553
  const bodyErrorResponse = _chunkCFG4QERRcjs.createFarmRequestBodyErrorResponse.call(void 0, error);
2991
3554
  if (bodyErrorResponse) {
2992
- logResponse(method2, urlPath2, bodyErrorResponse.status, duration2, "API");
3555
+ logResponse(method2, urlPath2, bodyErrorResponse.status, duration, "API");
2993
3556
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, bodyErrorResponse);
2994
3557
  return;
2995
3558
  }
2996
- await emitPluginError("api-handler", error, {
2997
- urlPath: urlPath2,
2998
- method: method2
2999
- });
3000
3559
  _chunkQMNWKQL4cjs.logger.error(`API route error: ${error}`);
3001
3560
  res.statusCode = 500;
3002
3561
  res.setHeader("Content-Type", "application/json");
3003
- res.end(JSON.stringify({ error: "Internal server error" }));
3562
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
3004
3563
  return;
3005
3564
  }
3006
3565
  }
3007
- if (farmDocsAPIHandler && _optionalChain([farmDocsDevRuntime, 'optionalAccess', _216 => _216.isFarmDocsAPIRequest, 'call', _217 => _217(pathname2)])) {
3566
+ if (farmDocsAPIHandler && isDocsAPIRequest) {
3008
3567
  try {
3009
- const url = `http://${req.headers.host || "localhost:3000"}${req.url}`;
3010
- const headers = new Headers();
3011
- for (const [key, value] of Object.entries(req.headers)) {
3012
- if (value) {
3013
- headers.set(key, Array.isArray(value) ? value.join(", ") : value);
3014
- }
3015
- }
3016
- let body;
3017
- if (req.method !== "GET" && req.method !== "HEAD") {
3018
- body = await _chunkCFG4QERRcjs.readNodeRequestBody.call(void 0, req, currentServerConfig.bodySizeLimit);
3019
- }
3020
- const request = new Request(url, {
3021
- method: req.method,
3022
- headers,
3023
- body: toRequestBody(body),
3024
- signal: _chunkCFG4QERRcjs.createFarmNodeRequestAbortSignal.call(void 0, req, res)
3025
- });
3568
+ const request = await createHandlerRequest();
3026
3569
  const apiLifecyclePayload = {
3027
3570
  pathname: pathname2,
3028
3571
  method: method2,
@@ -3040,19 +3583,14 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3040
3583
  }
3041
3584
  return pm ? await pm.runHookSerial("afterApiHandler", response, apiLifecyclePayload) : response;
3042
3585
  };
3043
- const docsResponse = pm ? await pm.runRuntimeRequest(request, invokeDocsAPIHandler, {
3044
- kind: "docs",
3045
- route: _chunk752IHQTDcjs.setFarmRouteLabel.call(void 0,
3046
- { pathname: pathname2, pattern: apiLifecyclePayload.routePath },
3047
- _chunk752IHQTDcjs.resolveFarmDocsRouteLabel.call(void 0, pathname2, {
3048
- path: _optionalChain([farmConfig, 'access', _218 => _218.docs, 'optionalAccess', _219 => _219.entry]) || "/docs",
3049
- roots: _optionalChain([farmConfig, 'access', _220 => _220.docs, 'optionalAccess', _221 => _221.roots, 'optionalAccess', _222 => _222.map, 'call', _223 => _223((root) => root.entry)])
3050
- })
3051
- )
3052
- }) : await invokeDocsAPIHandler(request);
3586
+ const docsResponse = await runInRuntime(
3587
+ request,
3588
+ invokeDocsAPIHandler,
3589
+ docsRuntimeOptions()
3590
+ );
3053
3591
  if (docsResponse) {
3054
- const duration2 = Date.now() - startTime2;
3055
- logResponse(method2, urlPath2, docsResponse.status, duration2, "API");
3592
+ const duration = Date.now() - startTime2;
3593
+ logResponse(method2, urlPath2, docsResponse.status, duration, "API");
3056
3594
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, docsResponse);
3057
3595
  return;
3058
3596
  }
@@ -3062,52 +3600,70 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3062
3600
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, bodyErrorResponse);
3063
3601
  return;
3064
3602
  }
3065
- await emitPluginError("docs-api-handler", error, {
3066
- urlPath: urlPath2,
3067
- method: method2
3068
- });
3069
3603
  _chunkQMNWKQL4cjs.logger.error(`Docs API route error: ${error}`);
3070
3604
  res.statusCode = 500;
3071
3605
  res.setHeader("Content-Type", "application/json");
3072
- res.end(JSON.stringify({ error: "Internal server error" }));
3606
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
3073
3607
  return;
3074
3608
  }
3075
3609
  }
3076
- const duration = Date.now() - startTime2;
3077
- logResponse(method2, urlPath2, 404, duration, "API");
3078
- res.statusCode = 404;
3079
- res.setHeader("Content-Type", "application/json");
3080
- res.end(JSON.stringify({ error: "API route not found", pathname: pathname2 }));
3610
+ const notFoundBody = JSON.stringify({ error: "API route not found", pathname: pathname2 });
3611
+ if (!runtimeSession2) {
3612
+ logResponse(method2, urlPath2, 404, Date.now() - startTime2, "API");
3613
+ res.statusCode = 404;
3614
+ res.setHeader("Content-Type", "application/json");
3615
+ res.end(notFoundBody);
3616
+ return;
3617
+ }
3618
+ try {
3619
+ const response = await pm.completeRuntimeRequest(
3620
+ runtimeSession2,
3621
+ () => new Response(notFoundBody, {
3622
+ status: 404,
3623
+ headers: { "Content-Type": "application/json" }
3624
+ })
3625
+ );
3626
+ logResponse(method2, urlPath2, response.status, Date.now() - startTime2, "API");
3627
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
3628
+ } catch (error) {
3629
+ _chunkQMNWKQL4cjs.logger.error(`API route error: ${error}`);
3630
+ res.statusCode = 500;
3631
+ res.setHeader("Content-Type", "application/json");
3632
+ res.end(_chunkXGTFLG73cjs.FARM_INTERNAL_SERVER_ERROR_BODY);
3633
+ }
3081
3634
  return;
3082
3635
  }
3083
- if (_optionalChain([req, 'access', _224 => _224.url, 'optionalAccess', _225 => _225.startsWith, 'call', _226 => _226("/@")]) || _optionalChain([req, 'access', _227 => _227.url, 'optionalAccess', _228 => _228.startsWith, 'call', _229 => _229("/node_modules")])) {
3636
+ if (_optionalChain([req, 'access', _260 => _260.url, 'optionalAccess', _261 => _261.startsWith, 'call', _262 => _262("/@")]) || _optionalChain([req, 'access', _263 => _263.url, 'optionalAccess', _264 => _264.startsWith, 'call', _265 => _265("/node_modules")])) {
3084
3637
  return next();
3085
3638
  }
3086
- if (shouldBypassFarmRouterForDottedPath(
3639
+ if (!deferredDottedRequests.has(req) && shouldBypassFarmRouterForDottedPath(
3087
3640
  requestPathname,
3088
- _optionalChain([farmApp, 'optionalAccess', _230 => _230.getRouteManager, 'call', _231 => _231()]),
3641
+ _optionalChain([farmApp, 'optionalAccess', _266 => _266.getRouteManager, 'call', _267 => _267()]),
3089
3642
  [server.config.publicDir, server.config.root],
3090
- farmAgentGeneratedPaths(farmConfig)
3643
+ farmAgentGeneratedPaths(farmConfig),
3644
+ requestMethod
3091
3645
  )) {
3646
+ if (!viteModuleRequest) deferredDottedRequests.set(req, requestUrl);
3092
3647
  return next();
3093
3648
  }
3094
- if (_optionalChain([req, 'access', _232 => _232.url, 'optionalAccess', _233 => _233.startsWith, 'call', _234 => _234("/__farm/page-data")])) {
3649
+ if (_optionalChain([req, 'access', _268 => _268.url, 'optionalAccess', _269 => _269.startsWith, 'call', _270 => _270("/__farm/page-data")])) {
3095
3650
  const urlObj = parsedRequestUrl;
3096
3651
  const targetPath = urlObj.searchParams.get("path") || "/";
3652
+ let renderedRequest;
3097
3653
  try {
3098
3654
  const request = createRequestFromNodeRequest(
3099
3655
  req,
3100
3656
  urlObj,
3101
3657
  _chunkCFG4QERRcjs.createFarmNodeRequestAbortSignal.call(void 0, req, res)
3102
3658
  );
3103
- const deploymentMismatch = _chunkE552H232cjs.getFarmDeploymentMismatch.call(void 0,
3659
+ const deploymentMismatch = _chunkF43OG25Pcjs.getFarmDeploymentMismatch.call(void 0,
3104
3660
  request,
3105
3661
  farmConfig.deploymentId
3106
3662
  );
3107
3663
  if (deploymentMismatch) {
3108
3664
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0,
3109
3665
  res,
3110
- _chunkE552H232cjs.createFarmDeploymentMismatchResponse.call(void 0, deploymentMismatch)
3666
+ _chunkF43OG25Pcjs.createFarmDeploymentMismatchResponse.call(void 0, deploymentMismatch)
3111
3667
  );
3112
3668
  return;
3113
3669
  }
@@ -3117,17 +3673,24 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3117
3673
  headers: request.headers,
3118
3674
  signal: request.signal
3119
3675
  });
3676
+ renderedRequest = targetRequest;
3120
3677
  let middlewareMap = /* @__PURE__ */ new Map();
3121
3678
  let middlewareContext = /* @__PURE__ */ new Map();
3122
- if (_optionalChain([middlewareManager, 'optionalAccess', _235 => _235.hasMiddleware, 'call', _236 => _236()])) {
3679
+ if (_optionalChain([middlewareManager, 'optionalAccess', _271 => _271.hasMiddleware, 'call', _272 => _272()])) {
3123
3680
  const targetNodeRequest = createPageDataMiddlewareRequest(req, targetRequestUrl);
3681
+ const targetNodeResponse = createPageDataMiddlewareResponse(res);
3124
3682
  const handled = await runFarmMiddlewareWithNavigation(
3125
3683
  farmApp.getServerRenderer(),
3126
3684
  targetRequest,
3127
3685
  targetNodeRequest,
3128
- res,
3129
- () => middlewareManager.execute(targetNodeRequest, res)
3686
+ targetNodeResponse.response,
3687
+ () => middlewareManager.execute(targetNodeRequest, targetNodeResponse.response)
3130
3688
  );
3689
+ const middlewareRedirect = targetNodeResponse.redirect();
3690
+ if (middlewareRedirect) {
3691
+ await sendFarmPageDataRedirect(res, middlewareRedirect, farmConfig.deploymentId);
3692
+ return;
3693
+ }
3131
3694
  if (handled) return;
3132
3695
  middlewareMap = _nullishCoalesce(targetNodeRequest.__FARM_MIDDLEWARE_DATA__, () => ( middlewareMap));
3133
3696
  middlewareContext = _nullishCoalesce(targetNodeRequest.__FARM_MIDDLEWARE_CONTEXT__, () => ( middlewareContext));
@@ -3147,10 +3710,10 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3147
3710
  if (pm) {
3148
3711
  await pm.runHookParallel("afterRouteMatch", {
3149
3712
  pathname: targetPath,
3150
- matched: !!_optionalChain([match, 'optionalAccess', _237 => _237.route]),
3151
- routePattern: _optionalChain([match, 'optionalAccess', _238 => _238.route, 'optionalAccess', _239 => _239.pattern]) || null,
3152
- params: _optionalChain([match, 'optionalAccess', _240 => _240.params]) || {},
3153
- layoutPatterns: (_optionalChain([match, 'optionalAccess', _241 => _241.layouts]) || []).map((l) => l.pattern)
3713
+ matched: !!_optionalChain([match, 'optionalAccess', _273 => _273.route]),
3714
+ routePattern: _optionalChain([match, 'optionalAccess', _274 => _274.route, 'optionalAccess', _275 => _275.pattern]) || null,
3715
+ params: _optionalChain([match, 'optionalAccess', _276 => _276.params]) || {},
3716
+ layoutPatterns: (_optionalChain([match, 'optionalAccess', _277 => _277.layouts]) || []).map((l) => l.pattern)
3154
3717
  });
3155
3718
  }
3156
3719
  if (!match) {
@@ -3173,7 +3736,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3173
3736
  );
3174
3737
  const loadingModule = loadingBoundary ? await routeManager3.loadRouteModule(loadingBoundary.modulePath) : null;
3175
3738
  const navigationManifest = routeManager3.generateClientManifest(server.config.root);
3176
- const moduleMetadata = _nullishCoalesce(navigationManifest.routes.find((entry) => entry.pattern === route.pattern), () => ( _chunk7ONGIFYXcjs.getClientModuleMetadata.call(void 0, route.modulePath, server.config.root)));
3739
+ const moduleMetadata = _nullishCoalesce(navigationManifest.routes.find((entry) => entry.pattern === route.pattern), () => ( _chunk4DRINDGNcjs.getClientModuleMetadata.call(void 0, route.modulePath, server.config.root)));
3177
3740
  const isClientComponent = moduleMetadata.isClientComponent;
3178
3741
  const shouldHydrate = moduleMetadata.shouldHydrate;
3179
3742
  let mergedMetadata = {};
@@ -3181,7 +3744,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3181
3744
  layouts.map((layout) => routeManager3.loadLayoutModule(layout.modulePath))
3182
3745
  );
3183
3746
  const layoutHydrationMetadata = layouts.map(
3184
- (layout) => _nullishCoalesce(navigationManifest.layouts.find((entry) => entry.pattern === layout.pattern), () => ( _chunk7ONGIFYXcjs.getClientModuleMetadata.call(void 0, layout.modulePath, server.config.root)))
3747
+ (layout) => _nullishCoalesce(navigationManifest.layouts.find((entry) => entry.pattern === layout.pattern), () => ( _chunk4DRINDGNcjs.getClientModuleMetadata.call(void 0, layout.modulePath, server.config.root)))
3185
3748
  );
3186
3749
  const shouldHydrateLayout = layoutHydrationMetadata.some(
3187
3750
  (metadata) => metadata.shouldHydrate
@@ -3192,18 +3755,18 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3192
3755
  (metadata) => metadata.shouldHydrate && metadata.islandStrategy ? [metadata.islandStrategy] : []
3193
3756
  )
3194
3757
  ];
3195
- const hydrationIslandStrategy = _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0,
3196
- _optionalChain([(_nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _242 => _242.getConfig, 'call', _243 => _243()]), () => ( options))), 'access', _244 => _244.experimental, 'optionalAccess', _245 => _245.serverComponents])
3197
- ) === "islands" ? _chunkE4UDLFWRcjs.resolveFarmRouteRootStrategy.call(void 0,
3758
+ const hydrationIslandStrategy = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0,
3759
+ _optionalChain([(_nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _278 => _278.getConfig, 'call', _279 => _279()]), () => ( options))), 'access', _280 => _280.experimental, 'optionalAccess', _281 => _281.serverComponents])
3760
+ ) === "islands" ? _chunkN5DQMOAGcjs.resolveFarmRouteRootStrategy.call(void 0,
3198
3761
  route,
3199
3762
  { shouldHydrate, islandStrategy: _nullishCoalesce(moduleMetadata.islandStrategy, () => ( null)) },
3200
3763
  layouts.map((layout, index) => ({
3201
3764
  pattern: layout.pattern,
3202
3765
  modulePath: layout.modulePath,
3203
- shouldHydrate: _optionalChain([layoutHydrationMetadata, 'access', _246 => _246[index], 'optionalAccess', _247 => _247.shouldHydrate]) === true,
3766
+ shouldHydrate: _optionalChain([layoutHydrationMetadata, 'access', _282 => _282[index], 'optionalAccess', _283 => _283.shouldHydrate]) === true,
3204
3767
  // Manifest entries carry it; metadata read from source does not.
3205
- hasIsolatedClientBoundaries: _optionalChain([layoutHydrationMetadata, 'access', _248 => _248[index], 'optionalAccess', _249 => _249.hasIsolatedClientBoundaries]) === true,
3206
- islandStrategy: _nullishCoalesce(_optionalChain([layoutHydrationMetadata, 'access', _250 => _250[index], 'optionalAccess', _251 => _251.islandStrategy]), () => ( null))
3768
+ hasIsolatedClientBoundaries: _optionalChain([layoutHydrationMetadata, 'access', _284 => _284[index], 'optionalAccess', _285 => _285.hasIsolatedClientBoundaries]) === true,
3769
+ islandStrategy: _nullishCoalesce(_optionalChain([layoutHydrationMetadata, 'access', _286 => _286[index], 'optionalAccess', _287 => _287.islandStrategy]), () => ( null))
3207
3770
  })),
3208
3771
  server.config.root,
3209
3772
  true
@@ -3251,14 +3814,16 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3251
3814
  mergedMetadata = await _chunk6IOZPJ3Icjs.mergeModuleViewport.call(void 0, mergedMetadata, routeModule, routeProps);
3252
3815
  mergedMetadata = _chunk6IOZPJ3Icjs.addMetadataMarkdownAlternate.call(void 0,
3253
3816
  mergedMetadata,
3254
- _chunk2C5L5RPMcjs.getFarmMarkdownAlternatePath.call(void 0, farmApp.getConfig().md, targetRequestUrl.pathname)
3817
+ _chunkFT6KJHS3cjs.getFarmMarkdownAlternatePath.call(void 0, farmApp.getConfig().md, targetRequestUrl.pathname, {
3818
+ routePathname: (pathname2) => routeManager3.toRoutePathname(pathname2)
3819
+ })
3255
3820
  );
3256
3821
  const routeSlots = await Promise.all(
3257
3822
  slots.map(async (slot) => {
3258
3823
  const slotModule = await routeManager3.loadRouteModule(slot.route.modulePath);
3259
3824
  const slotMetadata = _nullishCoalesce(navigationManifest.slots.find(
3260
3825
  (entry) => entry.name === slot.name && entry.ownerPattern === slot.ownerPattern && entry.pattern === slot.route.pattern
3261
- ), () => ( _chunk7ONGIFYXcjs.getClientModuleMetadata.call(void 0, slot.route.modulePath, server.config.root)));
3826
+ ), () => ( _chunk4DRINDGNcjs.getClientModuleMetadata.call(void 0, slot.route.modulePath, server.config.root)));
3262
3827
  const slotContext = await _chunkX333W5KVcjs.resolveFarmRouteContext.call(void 0, farmApp.getConfig(), {
3263
3828
  request: targetRequest,
3264
3829
  params: slot.params,
@@ -3304,15 +3869,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3304
3869
  );
3305
3870
  const projectRoot = server.config.root;
3306
3871
  const toUrlPath = (absolutePath) => _chunkQMNWKQL4cjs.toViteModuleId.call(void 0, absolutePath, projectRoot);
3307
- const renderPlan = _chunkUJ3R2AH2cjs.createFarmRouteRenderPlan.call(void 0, {
3872
+ const renderPlan = _chunkUPOYKX4Scjs.createFarmRouteRenderPlan.call(void 0, {
3308
3873
  pageShouldHydrate: shouldHydrate,
3309
3874
  layoutShouldHydrate: shouldHydrateLayout,
3310
3875
  islandStrategy: hydrationIslandStrategy,
3311
- rendering: _chunkX4K7TYN6cjs.resolveRouteRenderingConfig.call(void 0, routeModule)
3876
+ rendering: _chunkYVTS3S3Fcjs.resolveRouteRenderingConfig.call(void 0, routeModule)
3312
3877
  });
3313
3878
  const destinationLayoutPatterns = layouts.map((layout) => layout.pattern);
3314
- const layoutStartIndex = _chunkUJ3R2AH2cjs.getSharedLayoutPrefixLength.call(void 0,
3315
- _chunkUJ3R2AH2cjs.parseFarmLayoutChainHeader.call(void 0, request.headers.get("x-farm-layout-chain")),
3879
+ const layoutStartIndex = _chunkUPOYKX4Scjs.getSharedLayoutPrefixLength.call(void 0,
3880
+ _chunkUPOYKX4Scjs.parseFarmLayoutChainHeader.call(void 0, request.headers.get("x-farm-layout-chain")),
3316
3881
  destinationLayoutPatterns
3317
3882
  );
3318
3883
  const renderer = farmApp.getServerRenderer();
@@ -3322,7 +3887,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3322
3887
  middlewareContext,
3323
3888
  () => renderer.renderNavigationFragment({
3324
3889
  PageComponent: routeModule.default,
3325
- LoadingComponent: _optionalChain([loadingModule, 'optionalAccess', _252 => _252.default]),
3890
+ LoadingComponent: _optionalChain([loadingModule, 'optionalAccess', _288 => _288.default]),
3326
3891
  pageProps: routeProps,
3327
3892
  params,
3328
3893
  layouts: layouts.map((layout, index) => ({
@@ -3388,15 +3953,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3388
3953
  };
3389
3954
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0,
3390
3955
  res,
3391
- _chunkXQSYOVCWcjs.createDeferredDataResponse.call(void 0,
3956
+ _chunkDBYNZIIQcjs.createDeferredDataResponse.call(void 0,
3392
3957
  pageData,
3393
3958
  {
3394
3959
  status: 200,
3395
3960
  headers: {
3396
- "Cache-Control": _chunkUJ3R2AH2cjs.getFarmFragmentCacheControl.call(void 0, renderPlan),
3961
+ "Cache-Control": _chunkUPOYKX4Scjs.getFarmFragmentCacheControl.call(void 0, renderPlan),
3397
3962
  "X-Farm-Navigation": "html-fragment",
3398
3963
  Vary: "X-Farm-Layout-Chain",
3399
- [_chunkE552H232cjs.FARM_DEPLOYMENT_ID_HEADER]: farmConfig.deploymentId
3964
+ [_chunkF43OG25Pcjs.FARM_DEPLOYMENT_ID_HEADER]: farmConfig.deploymentId
3400
3965
  }
3401
3966
  },
3402
3967
  {
@@ -3410,6 +3975,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3410
3975
  });
3411
3976
  return;
3412
3977
  } catch (error) {
3978
+ const redirect = renderedRequest ? await farmApp.getServerRenderer().resolvePageDataRedirect(renderedRequest, error) : null;
3979
+ if (redirect && !res.headersSent) {
3980
+ await sendFarmPageDataRedirect(res, redirect, farmConfig.deploymentId);
3981
+ return;
3982
+ }
3413
3983
  const failure = resolveFarmPageDataFailure(error);
3414
3984
  if (failure.status >= 500) {
3415
3985
  await emitPluginError("page-data", error, {
@@ -3426,62 +3996,64 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3426
3996
  const startTime = Date.now();
3427
3997
  const method = req.method || "GET";
3428
3998
  const urlPath = req.url || "/";
3429
- const requestedPathname = _chunkHNAISJFDcjs.resolveFarmRequestURL.call(void 0, req, {
3999
+ const requestedPathname = _chunkHDPT6OYEcjs.resolveFarmRequestURL.call(void 0, req, {
3430
4000
  trustProxy: currentServerConfig.trustProxy
3431
4001
  }).pathname;
3432
4002
  const routeManager2 = farmApp.getRouteManager();
3433
- const hasBeforeRouteMatchHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _253 => _253.hasHook, 'call', _254 => _254("beforeRouteMatch")]), () => ( false));
3434
- const hasAfterRouteMatchHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _255 => _255.hasHook, 'call', _256 => _256("afterRouteMatch")]), () => ( false));
3435
- const hasBeforeRequestHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _257 => _257.hasHook, 'call', _258 => _258("beforeRequest")]), () => ( false));
3436
- const hasBeforeRenderHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _259 => _259.hasHook, 'call', _260 => _260("beforeRender")]), () => ( false));
3437
- const hasAfterResponseHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _261 => _261.hasHook, 'call', _262 => _262("afterResponse")]), () => ( false));
3438
- const hasHTMLTransformHook = (_nullishCoalesce(_optionalChain([pm, 'optionalAccess', _263 => _263.hasHook, 'call', _264 => _264("transformHTML")]), () => ( false))) || (_nullishCoalesce(_optionalChain([pm, 'optionalAccess', _265 => _265.hasHook, 'call', _266 => _266("afterRender")]), () => ( false)));
3439
- const hasRuntimeRequestHooks = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _267 => _267.hasRuntimeRequestHooks, 'call', _268 => _268()]), () => ( false));
3440
- const hasRuntimeAfterHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _269 => _269.hasRuntimeHook, 'call', _270 => _270("after")]), () => ( false));
4003
+ const hasBeforeRouteMatchHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _289 => _289.hasHook, 'call', _290 => _290("beforeRouteMatch")]), () => ( false));
4004
+ const hasAfterRouteMatchHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _291 => _291.hasHook, 'call', _292 => _292("afterRouteMatch")]), () => ( false));
4005
+ const hasBeforeRequestHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _293 => _293.hasHook, 'call', _294 => _294("beforeRequest")]), () => ( false));
4006
+ const hasBeforeRenderHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _295 => _295.hasHook, 'call', _296 => _296("beforeRender")]), () => ( false));
4007
+ const hasAfterResponseHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _297 => _297.hasHook, 'call', _298 => _298("afterResponse")]), () => ( false));
4008
+ const hasHTMLTransformHook = (_nullishCoalesce(_optionalChain([pm, 'optionalAccess', _299 => _299.hasHook, 'call', _300 => _300("transformHTML")]), () => ( false))) || (_nullishCoalesce(_optionalChain([pm, 'optionalAccess', _301 => _301.hasHook, 'call', _302 => _302("afterRender")]), () => ( false)));
4009
+ const hasRuntimeRequestHooks = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _303 => _303.hasRuntimeRequestHooks, 'call', _304 => _304()]), () => ( false));
4010
+ const hasRuntimeAfterHook = _nullishCoalesce(_optionalChain([pm, 'optionalAccess', _305 => _305.hasRuntimeHook, 'call', _306 => _306("after")]), () => ( false));
3441
4011
  const requestedMatch = routeManager2.matchRoute(requestedPathname);
3442
4012
  const pageBuiltInRouteLabel = (pathname2) => {
3443
4013
  const routePathname = _chunkD22BUQKWcjs.stripFarmBasePath.call(void 0, pathname2, farmConfig.basePath);
3444
- const mcpLabel = _chunk752IHQTDcjs.resolveFarmMCPRouteLabel.call(void 0, routePathname, apiServerBasePath);
4014
+ const mcpLabel = _chunkLPIZMU7Dcjs.resolveFarmMCPRouteLabel.call(void 0, routePathname, apiServerBasePath);
3445
4015
  if (mcpLabel) return mcpLabel;
3446
4016
  if (farmAgentGeneratedPaths(farmConfig).includes(routePathname)) return routePathname;
3447
- return routePathname === _chunkY5TOT5F6cjs.FARM_DEFAULT_MCP_PATH && farmApp.getServerRenderer().getDefaultMCPServer() ? _chunkY5TOT5F6cjs.FARM_DEFAULT_MCP_PATH : null;
4017
+ return routePathname === _chunkX3MHKLCOcjs.FARM_DEFAULT_MCP_PATH && farmApp.getServerRenderer().getDefaultMCPServer() ? _chunkX3MHKLCOcjs.FARM_DEFAULT_MCP_PATH : null;
3448
4018
  };
3449
4019
  let runtimeSession;
4020
+ let pathname = requestedPathname;
3450
4021
  if (pm && hasRuntimeRequestHooks) {
3451
4022
  try {
4023
+ const sessionOptions = {
4024
+ kind: "page",
4025
+ route: _chunkLPIZMU7Dcjs.setFarmRouteLabel.call(void 0,
4026
+ {
4027
+ pathname: requestedPathname,
4028
+ pattern: _optionalChain([requestedMatch, 'optionalAccess', _307 => _307.route, 'optionalAccess', _308 => _308.pattern]) || null,
4029
+ params: _optionalChain([requestedMatch, 'optionalAccess', _309 => _309.params]) || {}
4030
+ },
4031
+ _optionalChain([requestedMatch, 'optionalAccess', _310 => _310.route]) ? null : pageBuiltInRouteLabel(requestedPathname)
4032
+ )
4033
+ };
3452
4034
  runtimeSession = await pm.beginRuntimeRequest(
3453
- createRequestFromNodeRequest(req, new URL(fullUrl)),
3454
- {
3455
- kind: "page",
3456
- route: _chunk752IHQTDcjs.setFarmRouteLabel.call(void 0,
3457
- {
3458
- pathname: requestedPathname,
3459
- pattern: _optionalChain([requestedMatch, 'optionalAccess', _271 => _271.route, 'optionalAccess', _272 => _272.pattern]) || null,
3460
- params: _optionalChain([requestedMatch, 'optionalAccess', _273 => _273.params]) || {}
3461
- },
3462
- _optionalChain([requestedMatch, 'optionalAccess', _274 => _274.route]) ? null : pageBuiltInRouteLabel(requestedPathname)
3463
- )
3464
- }
4035
+ createRequestFromNodeRequest(req, new URL(_nullishCoalesce(configRewriteSource, () => ( fullUrl)))),
4036
+ sessionOptions
3465
4037
  );
3466
- pm.copyRequestContext(runtimeSession.request, req);
3467
- applyWebRequestToNodeRequest(runtimeSession.request, req);
3468
- if (runtimeSession.response) {
3469
- const response = await pm.endRuntimeRequest(
3470
- runtimeSession,
3471
- runtimeSession.response
3472
- );
4038
+ const routedRequest = await _asyncNullishCoalesce(runtimeSession.response, async () => ( (configRewriteSource === void 0 ? runtimeSession.request : await pm.runRuntimeBeforeForRewrite(
4039
+ runtimeSession.request,
4040
+ createRequestFromNodeRequest(req, new URL(fullUrl)),
4041
+ sessionOptions
4042
+ ))));
4043
+ if (routedRequest instanceof Response) {
4044
+ const response = await pm.endRuntimeRequest(runtimeSession, routedRequest);
3473
4045
  await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, response);
3474
4046
  return;
3475
4047
  }
4048
+ pm.copyRequestContext(routedRequest, req);
4049
+ applyWebRequestToNodeRequest(routedRequest, req);
4050
+ pathname = new URL(routedRequest.url).pathname;
3476
4051
  } catch (error) {
3477
- await emitPluginError("runtime-before", error, { pathname: requestedPathname });
3478
- res.statusCode = 500;
3479
- res.setHeader("Content-Type", "text/plain; charset=utf-8");
3480
- res.end("Internal Server Error");
4052
+ if (runtimeSession) await pm.failRuntimeRequest(runtimeSession, error);
4053
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
3481
4054
  return;
3482
4055
  }
3483
4056
  }
3484
- const pathname = runtimeSession ? new URL(runtimeSession.request.url).pathname : requestedPathname;
3485
4057
  const routeMatch = pathname === requestedPathname ? requestedMatch : routeManager2.matchRoute(pathname);
3486
4058
  if (pm && hasBeforeRouteMatchHook) {
3487
4059
  await pm.runHookParallel("beforeRouteMatch", {
@@ -3492,17 +4064,17 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3492
4064
  if (pm && hasAfterRouteMatchHook) {
3493
4065
  await pm.runHookParallel("afterRouteMatch", {
3494
4066
  pathname,
3495
- matched: !!_optionalChain([routeMatch, 'optionalAccess', _275 => _275.route]),
3496
- routePattern: _optionalChain([routeMatch, 'optionalAccess', _276 => _276.route, 'optionalAccess', _277 => _277.pattern]) || null,
3497
- params: _optionalChain([routeMatch, 'optionalAccess', _278 => _278.params]) || {},
3498
- layoutPatterns: (_optionalChain([routeMatch, 'optionalAccess', _279 => _279.layouts]) || []).map((l) => l.pattern)
4067
+ matched: !!_optionalChain([routeMatch, 'optionalAccess', _311 => _311.route]),
4068
+ routePattern: _optionalChain([routeMatch, 'optionalAccess', _312 => _312.route, 'optionalAccess', _313 => _313.pattern]) || null,
4069
+ params: _optionalChain([routeMatch, 'optionalAccess', _314 => _314.params]) || {},
4070
+ layoutPatterns: (_optionalChain([routeMatch, 'optionalAccess', _315 => _315.layouts]) || []).map((l) => l.pattern)
3499
4071
  });
3500
4072
  }
3501
4073
  const renderPayload = {
3502
4074
  pathname,
3503
4075
  method,
3504
- routePattern: _optionalChain([routeMatch, 'optionalAccess', _280 => _280.route, 'optionalAccess', _281 => _281.pattern]) || null,
3505
- params: _optionalChain([routeMatch, 'optionalAccess', _282 => _282.params]) || {}
4076
+ routePattern: _optionalChain([routeMatch, 'optionalAccess', _316 => _316.route, 'optionalAccess', _317 => _317.pattern]) || null,
4077
+ params: _optionalChain([routeMatch, 'optionalAccess', _318 => _318.params]) || {}
3506
4078
  };
3507
4079
  const shouldInterceptResponse = Boolean(
3508
4080
  pm && (hasAfterResponseHook || hasHTMLTransformHook || runtimeSession && hasRuntimeAfterHook)
@@ -3521,10 +4093,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3521
4093
  pathname,
3522
4094
  startTime,
3523
4095
  logResponse,
3524
- emitError: (error) => emitPluginError("response-end", error, { pathname })
4096
+ emitError: (error) => emitPluginError("response-end", error, { pathname }),
4097
+ jsonError: runtimeHookErrorAnswersJSON
3525
4098
  }) : void 0;
4099
+ let middlewareFailed = false;
3526
4100
  try {
3527
- if (_optionalChain([middlewareManager, 'optionalAccess', _283 => _283.hasMiddleware, 'call', _284 => _284()])) {
4101
+ if (_optionalChain([middlewareManager, 'optionalAccess', _319 => _319.hasMiddleware, 'call', _320 => _320()])) {
3528
4102
  const middlewareRequest = createRequestFromNodeRequest(req, new URL(fullUrl));
3529
4103
  const handled = await runFarmMiddlewareWithNavigation(
3530
4104
  farmApp.getServerRenderer(),
@@ -3532,9 +4106,12 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3532
4106
  req,
3533
4107
  res,
3534
4108
  () => middlewareManager.execute(req, res)
3535
- );
4109
+ ).catch((error) => {
4110
+ middlewareFailed = true;
4111
+ throw error;
4112
+ });
3536
4113
  if (handled) {
3537
- if (!_optionalChain([responseInterceptor, 'optionalAccess', _285 => _285.isEnded, 'call', _286 => _286()])) {
4114
+ if (!_optionalChain([responseInterceptor, 'optionalAccess', _321 => _321.isEnded, 'call', _322 => _322()])) {
3538
4115
  const duration = Date.now() - startTime;
3539
4116
  logResponse(method, urlPath, res.statusCode || 200, duration, "PAGE");
3540
4117
  }
@@ -3542,43 +4119,15 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3542
4119
  }
3543
4120
  }
3544
4121
  if (pm && hasBeforeRequestHook) {
3545
- const urlBeforeRequestHooks = req.url;
3546
- const currentPathname = new URL(
3547
- req.url || "/",
3548
- `http://${req.headers.host || "localhost:3000"}`
3549
- ).pathname;
3550
- const hasLocalPageRoute = Boolean(_optionalChain([routeManager2, 'access', _287 => _287.matchRoute, 'call', _288 => _288(currentPathname), 'optionalAccess', _289 => _289.route]));
3551
4122
  await pm.runHookParallelFiltered(
3552
4123
  "beforeRequest",
3553
- (plugin) => !hasLocalPageRoute || plugin.name !== _chunkUYTAP4FQcjs.FARM_CONFIG_REWRITES_PLUGIN_NAME,
4124
+ (plugin2) => !isFarmConfigRoutePlugin(plugin2),
3554
4125
  req,
3555
4126
  res
3556
4127
  );
3557
- if (runtimeSession && req.url !== urlBeforeRequestHooks && _optionalChain([req, 'access', _290 => _290.url, 'optionalAccess', _291 => _291.startsWith, 'call', _292 => _292("/")]) && !res.writableEnded) {
3558
- const destinationUrl = new URL(req.url, fullUrl);
3559
- const destinationMatch = routeManager2.matchRoute(destinationUrl.pathname);
3560
- const guarded = await pm.runRuntimeBeforeForRewrite(
3561
- runtimeSession.request,
3562
- createRequestFromNodeRequest(req, destinationUrl),
3563
- {
3564
- kind: "page",
3565
- route: {
3566
- pathname: destinationUrl.pathname,
3567
- pattern: _optionalChain([destinationMatch, 'optionalAccess', _293 => _293.route, 'optionalAccess', _294 => _294.pattern]) || null,
3568
- params: _optionalChain([destinationMatch, 'optionalAccess', _295 => _295.params]) || {}
3569
- }
3570
- }
3571
- );
3572
- if (guarded instanceof Response) {
3573
- await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0, res, guarded);
3574
- } else {
3575
- pm.copyRequestContext(guarded, req);
3576
- applyWebRequestToNodeRequest(guarded, req);
3577
- }
3578
- }
3579
4128
  }
3580
- if (res.writableEnded || _optionalChain([responseInterceptor, 'optionalAccess', _296 => _296.isEnded, 'call', _297 => _297()]) || await proxyFarmExternalRewrite(req, res, currentServerConfig.bodySizeLimit)) {
3581
- if (!_optionalChain([responseInterceptor, 'optionalAccess', _298 => _298.isEnded, 'call', _299 => _299()])) {
4129
+ if (res.writableEnded || _optionalChain([responseInterceptor, 'optionalAccess', _323 => _323.isEnded, 'call', _324 => _324()])) {
4130
+ if (!_optionalChain([responseInterceptor, 'optionalAccess', _325 => _325.isEnded, 'call', _326 => _326()])) {
3582
4131
  const duration = Date.now() - startTime;
3583
4132
  logResponse(method, urlPath, res.statusCode || 200, duration, "PAGE");
3584
4133
  }
@@ -3598,11 +4147,41 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3598
4147
  if (pm && runtimeSession) {
3599
4148
  await pm.failRuntimeRequest(runtimeSession, error);
3600
4149
  }
3601
- await emitPluginError("render-page", error, { pathname });
4150
+ if (!(middlewareFailed && runtimeSession)) {
4151
+ await emitPluginError("render-page", error, { pathname });
4152
+ }
4153
+ if (rendererDisabled && !res.headersSent) {
4154
+ sendFarmDevErrorJSON(res);
4155
+ return;
4156
+ }
4157
+ if (!res.headersSent) {
4158
+ res.setHeader("Content-Type", "text/html; charset=utf-8");
4159
+ res.setHeader("Cache-Control", "private, no-store");
4160
+ }
3602
4161
  next(error);
3603
4162
  }
3604
4163
  })
3605
4164
  );
4165
+ const farmRequestMiddleware = _optionalChain([farmMiddlewares, 'access', _327 => _327.stack, 'access', _328 => _328.at, 'call', _329 => _329(-1), 'optionalAccess', _330 => _330.handle]);
4166
+ if (farmOwnsDevCors && viteServer.config.server.cors === false) {
4167
+ farmMiddlewares.use(createFarmDevViteCorsMiddleware());
4168
+ }
4169
+ return () => {
4170
+ farmPostMiddlewares.use((req, res, next) => {
4171
+ if (res.headersSent || res.writableEnded) return next();
4172
+ const deferredUrl = deferredDottedRequests.get(req);
4173
+ if (deferredUrl !== void 0) {
4174
+ req.url = deferredUrl;
4175
+ return farmRequestMiddleware(req, res, next);
4176
+ }
4177
+ if (!rendererDisabled) return next();
4178
+ const requested = _nullishCoalesce(_nullishCoalesce(req.originalUrl, () => ( req.url)), () => ( "/"));
4179
+ const pathname = _chunkHDPT6OYEcjs.parseFarmRequestTarget.call(void 0, requested, "http://localhost").pathname;
4180
+ res.statusCode = 404;
4181
+ res.setHeader("Content-Type", "application/json");
4182
+ res.end(JSON.stringify({ error: "Not found", pathname }));
4183
+ });
4184
+ };
3606
4185
  },
3607
4186
  async resolveId(id, importer, resolveOptions) {
3608
4187
  if (typeof fontImports.resolveId === "function") {
@@ -3627,6 +4206,9 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3627
4206
  }
3628
4207
  },
3629
4208
  async load(id, loadOptions) {
4209
+ if (pendingClientSetup && !_optionalChain([loadOptions, 'optionalAccess', _331 => _331.ssr]) && !farmSetupContext.getStore()) {
4210
+ await pendingClientSetup;
4211
+ }
3630
4212
  if (_chunkPIUTGRDIcjs.isFarmServerFnBoundaryId.call(void 0, id) && islandsServerFns()) {
3631
4213
  const file = id.split("?", 1)[0];
3632
4214
  this.addWatchFile(file);
@@ -3642,8 +4224,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3642
4224
  if (imageModule) return imageModule;
3643
4225
  }
3644
4226
  if (_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id)) {
3645
- const renderer = _optionalChain([farmApp, 'optionalAccess', _300 => _300.getConfig, 'call', _301 => _301(), 'access', _302 => _302.renderer]) || _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, options.renderer);
3646
- const root = _optionalChain([server, 'optionalAccess', _303 => _303.config, 'access', _304 => _304.root]) || options.root;
4227
+ const renderer = _optionalChain([farmApp, 'optionalAccess', _332 => _332.getConfig, 'call', _333 => _333(), 'access', _334 => _334.renderer]) || _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, options.renderer);
4228
+ const root = _optionalChain([server, 'optionalAccess', _335 => _335.config, 'access', _336 => _336.root]) || options.root;
3647
4229
  if (isClientEnvironment(this, loadOptions)) {
3648
4230
  return generateProgrammaticClientRouteModuleForId(
3649
4231
  id,
@@ -3659,65 +4241,65 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3659
4241
  return FARM_DEV_CLIENT_BOOT_MODULE;
3660
4242
  }
3661
4243
  if (isFarmClientVirtualId(id)) {
3662
- const resolvedConfig = _optionalChain([farmApp, 'optionalAccess', _305 => _305.getConfig, 'call', _306 => _306()]);
3663
- const renderer = _optionalChain([resolvedConfig, 'optionalAccess', _307 => _307.renderer]) || _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, options.renderer);
3664
- const integrations = _optionalChain([resolvedConfig, 'optionalAccess', _308 => _308.integrations]) || options.integrations;
3665
- const root = _optionalChain([resolvedConfig, 'optionalAccess', _309 => _309.root]) || _optionalChain([server, 'optionalAccess', _310 => _310.config, 'access', _311 => _311.root]) || process.cwd();
3666
- const docs = _optionalChain([resolvedConfig, 'optionalAccess', _312 => _312.docs]);
4244
+ const resolvedConfig = _optionalChain([farmApp, 'optionalAccess', _337 => _337.getConfig, 'call', _338 => _338()]);
4245
+ const renderer = _optionalChain([resolvedConfig, 'optionalAccess', _339 => _339.renderer]) || _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, options.renderer);
4246
+ const integrations = _optionalChain([resolvedConfig, 'optionalAccess', _340 => _340.integrations]) || options.integrations;
4247
+ const root = _optionalChain([resolvedConfig, 'optionalAccess', _341 => _341.root]) || _optionalChain([server, 'optionalAccess', _342 => _342.config, 'access', _343 => _343.root]) || process.cwd();
4248
+ const docs = _optionalChain([resolvedConfig, 'optionalAccess', _344 => _344.docs]);
3667
4249
  const adapterOwnsDocsRuntime = Boolean(
3668
- _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) && _optionalChain([docs, 'optionalAccess', _313 => _313.adapter, 'optionalAccess', _314 => _314.server]) && docs.adapter.react
4250
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) && _optionalChain([docs, 'optionalAccess', _345 => _345.adapter, 'optionalAccess', _346 => _346.server]) && docs.adapter.react
3669
4251
  );
3670
- const devtools = _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _315 => _315.devtools]), () => ( _chunkSTF6VDYQcjs.resolveFarmDevtoolsConfig.call(void 0, false, "production")));
4252
+ const devtools = _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _347 => _347.devtools]), () => ( _chunkSTF6VDYQcjs.resolveFarmDevtoolsConfig.call(void 0, false, "production")));
3671
4253
  const [docsRuntime, docsSearchRuntime, devtoolsClientRuntime] = await Promise.all([
3672
- _optionalChain([docs, 'optionalAccess', _316 => _316.enabled]) ? loadFarmDocsDevRuntime() : null,
3673
- _optionalChain([docs, 'optionalAccess', _317 => _317.enabled]) && !adapterOwnsDocsRuntime ? loadFarmDocsSearchDevRuntime() : null,
4254
+ _optionalChain([docs, 'optionalAccess', _348 => _348.enabled]) ? loadFarmDocsDevRuntime() : null,
4255
+ _optionalChain([docs, 'optionalAccess', _349 => _349.enabled]) && !adapterOwnsDocsRuntime ? loadFarmDocsSearchDevRuntime() : null,
3674
4256
  devtools.enabled ? loadFarmDevtoolsClientRuntime() : null
3675
4257
  ]);
3676
- const docsSearchEnabled = _nullishCoalesce(_optionalChain([docsSearchRuntime, 'optionalAccess', _318 => _318.isFarmDocsSearchEnabled, 'call', _319 => _319(docs)]), () => ( false));
4258
+ const docsSearchEnabled = _nullishCoalesce(_optionalChain([docsSearchRuntime, 'optionalAccess', _350 => _350.isFarmDocsSearchEnabled, 'call', _351 => _351(docs)]), () => ( false));
3677
4259
  const generatedDocsSearchRuntime = docsSearchRuntime ? docsSearchRuntime.generateFarmDocsSearchClientRuntime(
3678
4260
  docsSearchEnabled,
3679
4261
  docsSearchEnabled ? docsSearchRuntime.resolveFarmDocsSearchClientModule(root) : void 0
3680
4262
  ) : EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME;
3681
4263
  const generatedDevtoolsClientRuntime = devtoolsClientRuntime ? devtoolsClientRuntime.generateFarmDevtoolsClientRuntime(devtools) : "";
3682
4264
  const generatedDevIndicatorsClientRuntime = farmApp ? _chunkUVV3I5QAcjs.generateFarmDevIndicatorsClientRuntime.call(void 0, farmApp.getConfig().devIndicators) : "";
3683
- const integrationProviders = _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) ? _chunkI32V5CZLcjs.getIntegrationProviders.call(void 0, integrations) : [];
3684
- const isolatedHydrationMode = _chunk7ONGIFYXcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
3685
- _optionalChain([resolvedConfig, 'optionalAccess', _320 => _320.experimental, 'optionalAccess', _321 => _321.isolatedClientHydration]),
4265
+ const integrationProviders = _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) ? _chunkBDYM2TN3cjs.getIntegrationProviders.call(void 0, integrations) : [];
4266
+ const isolatedHydrationMode = _chunk4DRINDGNcjs.resolveFarmIsolatedClientHydrationMode.call(void 0,
4267
+ _optionalChain([resolvedConfig, 'optionalAccess', _352 => _352.experimental, 'optionalAccess', _353 => _353.isolatedClientHydration]),
3686
4268
  {
3687
- serverComponents: _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([resolvedConfig, 'optionalAccess', _322 => _322.experimental, 'optionalAccess', _323 => _323.serverComponents])) === "rsc",
4269
+ serverComponents: _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([resolvedConfig, 'optionalAccess', _354 => _354.experimental, 'optionalAccess', _355 => _355.serverComponents])) === "rsc",
3688
4270
  hasUnsupportedIntegrationProvider: integrationProviders.filter((provider) => provider.component || provider.type === "clerk").some((provider) => provider.supportsIsolatedHydration !== true)
3689
4271
  }
3690
4272
  );
3691
4273
  return generateClientCode(
3692
4274
  integrationProviders,
3693
4275
  [
3694
- ..._chunkI32V5CZLcjs.getIntegrationDocumentNavigationMatchers.call(void 0, integrations),
3695
- ..._nullishCoalesce(_optionalChain([docsRuntime, 'optionalAccess', _324 => _324.getFarmDocsDocumentNavigationMatchers, 'call', _325 => _325(docs)]), () => ( []))
4276
+ ..._chunkBDYM2TN3cjs.getIntegrationDocumentNavigationMatchers.call(void 0, integrations),
4277
+ ..._nullishCoalesce(_optionalChain([docsRuntime, 'optionalAccess', _356 => _356.getFarmDocsDocumentNavigationMatchers, 'call', _357 => _357(docs)]), () => ( []))
3696
4278
  ],
3697
4279
  generatedDocsSearchRuntime,
3698
4280
  `${generatedDevtoolsClientRuntime}
3699
4281
  ${generatedDevIndicatorsClientRuntime}`,
3700
- _optionalChain([resolvedConfig, 'optionalAccess', _326 => _326.plugins]) || [],
4282
+ _optionalChain([resolvedConfig, 'optionalAccess', _358 => _358.plugins]) || [],
3701
4283
  root,
3702
- _optionalChain([resolvedConfig, 'optionalAccess', _327 => _327.srcDir]) || options.srcDir || "src",
3703
- _optionalChain([resolvedConfig, 'optionalAccess', _328 => _328.publicRuntimeConfig]) || options.publicRuntimeConfig,
3704
- _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) ? _optionalChain([docs, 'optionalAccess', _329 => _329.adapter, 'optionalAccess', _330 => _330.react]) : void 0,
4284
+ _optionalChain([resolvedConfig, 'optionalAccess', _359 => _359.srcDir]) || options.srcDir || "src",
4285
+ _optionalChain([resolvedConfig, 'optionalAccess', _360 => _360.publicRuntimeConfig]) || options.publicRuntimeConfig,
4286
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) ? _optionalChain([docs, 'optionalAccess', _361 => _361.adapter, 'optionalAccess', _362 => _362.react]) : void 0,
3705
4287
  renderer,
3706
- isolatedHydrationMode === "enabled" || _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) && _optionalChain([(_nullishCoalesce(options.isolatedClientBoundaryModules, () => ( _optionalChain([farmApp, 'optionalAccess', _331 => _331.getRouteManager, 'call', _332 => _332(), 'access', _333 => _333.getIsolatedClientBoundaryModules, 'call', _334 => _334(root)])))), 'optionalAccess', _335 => _335.size]) > 0,
3707
- _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _336 => _336.trailingSlash]), () => ( false)),
3708
- _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _337 => _337.basePath]), () => ( "/")),
3709
- _chunkE4UDLFWRcjs.generateClientCachePersistenceCode.call(void 0,
3710
- _chunkE4UDLFWRcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, _optionalChain([resolvedConfig, 'optionalAccess', _338 => _338.cache]))
4288
+ isolatedHydrationMode === "enabled" || _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) && _optionalChain([(_nullishCoalesce(options.isolatedClientBoundaryModules, () => ( _optionalChain([farmApp, 'optionalAccess', _363 => _363.getRouteManager, 'call', _364 => _364(), 'access', _365 => _365.getIsolatedClientBoundaryModules, 'call', _366 => _366(root)])))), 'optionalAccess', _367 => _367.size]) > 0,
4289
+ _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _368 => _368.trailingSlash]), () => ( false)),
4290
+ _nullishCoalesce(_optionalChain([resolvedConfig, 'optionalAccess', _369 => _369.basePath]), () => ( "/")),
4291
+ _chunkN5DQMOAGcjs.generateClientCachePersistenceCode.call(void 0,
4292
+ _chunkN5DQMOAGcjs.resolveFarmClientCacheAdapterEntry.call(void 0, root, _optionalChain([resolvedConfig, 'optionalAccess', _370 => _370.cache]))
3711
4293
  ),
3712
- _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) ? _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, docs) : void 0,
3713
- _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([resolvedConfig, 'optionalAccess', _339 => _339.experimental, 'optionalAccess', _340 => _340.serverComponents])) === "islands"
4294
+ _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) ? _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, docs) : void 0,
4295
+ _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([resolvedConfig, 'optionalAccess', _371 => _371.experimental, 'optionalAccess', _372 => _372.serverComponents])) === "islands"
3714
4296
  );
3715
4297
  }
3716
4298
  if (id === "/@farm/server") {
3717
4299
  return generateServerCode();
3718
4300
  }
3719
4301
  if (id === "/@farm/manifest") {
3720
- const routeManager = _optionalChain([farmApp, 'optionalAccess', _341 => _341.getRouteManager, 'call', _342 => _342()]);
4302
+ const routeManager = _optionalChain([farmApp, 'optionalAccess', _373 => _373.getRouteManager, 'call', _374 => _374()]);
3721
4303
  if (!routeManager) {
3722
4304
  return `
3723
4305
  export const getManifest = () => ({
@@ -3730,9 +4312,9 @@ export const getManifest = () => ({
3730
4312
  `;
3731
4313
  }
3732
4314
  const manifest = routeManager.generateClientManifest(server.config.root);
3733
- const globalStylesheetHref = _chunkE4UDLFWRcjs.resolveDevGlobalStylesheetHref.call(void 0,
4315
+ const globalStylesheetHref = _chunkN5DQMOAGcjs.resolveDevGlobalStylesheetHref.call(void 0,
3734
4316
  server.config.root,
3735
- _optionalChain([farmApp, 'optionalAccess', _343 => _343.getConfig, 'call', _344 => _344(), 'access', _345 => _345.srcDir])
4317
+ _optionalChain([farmApp, 'optionalAccess', _375 => _375.getConfig, 'call', _376 => _376(), 'access', _377 => _377.srcDir])
3736
4318
  );
3737
4319
  const fullManifest = {
3738
4320
  clientEntry: "/@farm/client.js",
@@ -3758,11 +4340,11 @@ export const getManifest = () => ({
3758
4340
  };
3759
4341
  }
3760
4342
  for (const layout of manifest.layouts) {
3761
- const groupScope = _chunkUJ3R2AH2cjs.getRouteGroupScope.call(void 0, layout.pattern);
4343
+ const groupScope = _chunkUPOYKX4Scjs.getRouteGroupScope.call(void 0, layout.pattern);
3762
4344
  fullManifest.layouts[layout.pattern] = {
3763
4345
  modulePath: layout.modulePath,
3764
4346
  pattern: layout.pattern,
3765
- ...groupScope ? { urlPattern: _chunkUJ3R2AH2cjs.stripRouteGroups.call(void 0, layout.pattern), groupScope } : {},
4347
+ ...groupScope ? { urlPattern: _chunkUPOYKX4Scjs.stripRouteGroups.call(void 0, layout.pattern), groupScope } : {},
3766
4348
  shouldHydrate: layout.shouldHydrate,
3767
4349
  islandStrategy: layout.islandStrategy,
3768
4350
  // Islands mode: rebuilt from its server tree, so its module is never preloaded.
@@ -3788,42 +4370,54 @@ export const manifest = getManifest();
3788
4370
  }
3789
4371
  },
3790
4372
  async transform(code, id, transformOptions) {
3791
- const actionConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _346 => _346.getConfig, 'call', _347 => _347()]), () => ( options));
4373
+ if (pendingClientSetup && !_optionalChain([transformOptions, 'optionalAccess', _378 => _378.ssr]) && !farmSetupContext.getStore()) {
4374
+ await pendingClientSetup;
4375
+ }
4376
+ const actionConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _379 => _379.getConfig, 'call', _380 => _380()]), () => ( options));
3792
4377
  let rewrotePackageImports = false;
3793
- if (_chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([actionConfig, 'access', _348 => _348.experimental, 'optionalAccess', _349 => _349.serverComponents])) === "islands" && (!id.includes("/node_modules/") || _optionalChain([transformOptions, 'optionalAccess', _350 => _350.ssr]) === true && farmReactServerFiles.has(id.split("?", 1)[0])) && !id.startsWith("\0") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id) && !_chunk7ONGIFYXcjs.hasUseClientDirective.call(void 0, code)) {
4378
+ if (_chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([actionConfig, 'access', _381 => _381.experimental, 'optionalAccess', _382 => _382.serverComponents])) === "islands" && (!id.includes("/node_modules/") || _optionalChain([transformOptions, 'optionalAccess', _383 => _383.ssr]) === true && farmReactServerFiles.has(id.split("?", 1)[0])) && !id.startsWith("\0") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id) && !_chunk4DRINDGNcjs.hasUseClientDirective.call(void 0, code)) {
3794
4379
  const file = id.split("?", 1)[0];
3795
- const projectRoot = actionConfig.root || _optionalChain([server, 'optionalAccess', _351 => _351.config, 'access', _352 => _352.root]) || process.cwd();
3796
- if (_optionalChain([transformOptions, 'optionalAccess', _353 => _353.ssr]) === true) {
4380
+ const projectRoot = actionConfig.root || _optionalChain([server, 'optionalAccess', _384 => _384.config, 'access', _385 => _385.root]) || process.cwd();
4381
+ if (_optionalChain([transformOptions, 'optionalAccess', _386 => _386.ssr]) === true) {
3797
4382
  if (farmReactServerFiles.has(file)) {
3798
- for (const child of _chunk7ONGIFYXcjs.farmRelativeImportFiles.call(void 0, code, file))
4383
+ for (const child of _chunk4DRINDGNcjs.farmRelativeImportFiles.call(void 0, code, file))
3799
4384
  farmReactServerFiles.add(child);
3800
4385
  }
3801
- const serverModule = farmReactServerFiles.has(file) || !_chunk7ONGIFYXcjs.getFarmClientReachableModules.call(void 0,
4386
+ const serverModule = farmReactServerFiles.has(file) || !_chunk4DRINDGNcjs.getFarmClientReachableModules.call(void 0,
3802
4387
  path6.resolve(projectRoot, actionConfig.srcDir || "src"),
3803
4388
  projectRoot
3804
4389
  ).has(path6.resolve(file));
3805
- const reactServer = !serverModule ? null : _chunk7ONGIFYXcjs.rewriteFarmReactServerImports.call(void 0, {
4390
+ const reactServer = !serverModule ? null : _chunk4DRINDGNcjs.rewriteFarmReactServerImports.call(void 0, {
3806
4391
  code,
3807
4392
  file,
3808
- reference: (specifier, exportName) => _chunk7ONGIFYXcjs.ensureFarmPackageClientReference.call(void 0, projectRoot, specifier, exportName),
4393
+ reference: (specifier, exportName) => _chunk4DRINDGNcjs.ensureFarmPackageClientReference.call(void 0, projectRoot, specifier, exportName),
3809
4394
  onServerFile: (serverFile) => farmReactServerFiles.add(serverFile)
3810
4395
  });
3811
4396
  if (reactServer !== null) {
3812
4397
  code = reactServer;
3813
4398
  rewrotePackageImports = true;
3814
4399
  }
4400
+ const internal = farmReactServerFiles.has(file) ? _chunk4DRINDGNcjs.rewriteFarmReactServerClientModuleImports.call(void 0, {
4401
+ code,
4402
+ file,
4403
+ reference: (clientFile) => _chunk4DRINDGNcjs.ensureFarmInternalClientReference.call(void 0, projectRoot, clientFile)
4404
+ }) : null;
4405
+ if (internal !== null) {
4406
+ code = internal;
4407
+ rewrotePackageImports = true;
4408
+ }
3815
4409
  }
3816
- const referenced = _chunk7ONGIFYXcjs.rewriteFarmPackageClientImports.call(void 0, {
4410
+ const referenced = _chunk4DRINDGNcjs.rewriteFarmPackageClientImports.call(void 0, {
3817
4411
  code,
3818
4412
  file,
3819
4413
  root: projectRoot,
3820
- isClientPackage: (specifier) => _chunk7ONGIFYXcjs.isFarmPackageClientBoundary.call(void 0, file, specifier, projectRoot)
4414
+ isClientPackage: (specifier) => _chunk4DRINDGNcjs.isFarmPackageClientBoundary.call(void 0, file, specifier, projectRoot)
3821
4415
  });
3822
4416
  if (referenced !== null) {
3823
4417
  code = referenced;
3824
4418
  rewrotePackageImports = true;
3825
4419
  }
3826
- if (_optionalChain([transformOptions, 'optionalAccess', _354 => _354.ssr]) === true) {
4420
+ if (_optionalChain([transformOptions, 'optionalAccess', _387 => _387.ssr]) === true) {
3827
4421
  const cached = rewriteFarmReactCacheImport(code, file);
3828
4422
  if (cached !== null) {
3829
4423
  code = cached;
@@ -3833,43 +4427,43 @@ export const manifest = getManifest();
3833
4427
  }
3834
4428
  if (islandsServerFns() && !_chunkPIUTGRDIcjs.isFarmServerFnBoundaryId.call(void 0, id) && !id.includes("/node_modules/") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id)) {
3835
4429
  const serverFns = _chunkPIUTGRDIcjs.transformFarmServerFns.call(void 0, code, id, {
3836
- environment: _optionalChain([transformOptions, 'optionalAccess', _355 => _355.ssr]) === true ? "rsc" : "client"
4430
+ environment: _optionalChain([transformOptions, 'optionalAccess', _388 => _388.ssr]) === true ? "rsc" : "client"
3837
4431
  });
3838
4432
  if (serverFns) {
3839
4433
  if (!serverFns.code.includes("use server")) return { code: serverFns.code, map: null };
3840
4434
  code = serverFns.code;
3841
4435
  }
3842
4436
  }
3843
- if (_chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([actionConfig, 'access', _356 => _356.experimental, 'optionalAccess', _357 => _357.serverComponents])) === "islands" && code.includes("use server") && !id.includes("/node_modules/") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id)) {
4437
+ if (_chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([actionConfig, 'access', _389 => _389.experimental, 'optionalAccess', _390 => _390.serverComponents])) === "islands" && code.includes("use server") && !id.includes("/node_modules/") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id)) {
3844
4438
  const file = id.split("?", 1)[0];
3845
4439
  const actionModule = transformFarmFormActionModule({
3846
4440
  code,
3847
4441
  id,
3848
- root: actionConfig.root || _optionalChain([server, 'optionalAccess', _358 => _358.config, 'access', _359 => _359.root]) || process.cwd(),
3849
- ssr: _optionalChain([transformOptions, 'optionalAccess', _360 => _360.ssr]) === true,
4442
+ root: actionConfig.root || _optionalChain([server, 'optionalAccess', _391 => _391.config, 'access', _392 => _392.root]) || process.cwd(),
4443
+ ssr: _optionalChain([transformOptions, 'optionalAccess', _393 => _393.ssr]) === true,
3850
4444
  // Parsed by file type: page components are TSX.
3851
4445
  parse: (source) => _vite.parseSync.call(void 0, file, source).program
3852
4446
  });
3853
4447
  if (actionModule) return { code: actionModule, map: null };
3854
4448
  }
3855
- if (!_optionalChain([transformOptions, 'optionalAccess', _361 => _361.ssr])) {
3856
- const docsConfigModule = _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, _optionalChain([farmApp, 'optionalAccess', _362 => _362.getConfig, 'call', _363 => _363(), 'optionalAccess', _364 => _364.docs]));
3857
- if (_chunkE4UDLFWRcjs.isFarmDocsClientConfigModule.call(void 0, id, docsConfigModule)) {
3858
- const redacted = _chunkE4UDLFWRcjs.redactFarmDocsClientConfig.call(void 0, code, id.split("?")[0]);
4449
+ if (!_optionalChain([transformOptions, 'optionalAccess', _394 => _394.ssr])) {
4450
+ const docsConfigModule = _chunkSM2SYWARcjs.getFarmDocsAdapterConfigModule.call(void 0, _optionalChain([farmApp, 'optionalAccess', _395 => _395.getConfig, 'call', _396 => _396(), 'optionalAccess', _397 => _397.docs]));
4451
+ if (_chunkN5DQMOAGcjs.isFarmDocsClientConfigModule.call(void 0, id, docsConfigModule)) {
4452
+ const redacted = _chunkN5DQMOAGcjs.redactFarmDocsClientConfig.call(void 0, code, id.split("?")[0]);
3859
4453
  if (redacted !== null) return { code: redacted, map: null };
3860
4454
  }
3861
4455
  }
3862
- if (!_optionalChain([transformOptions, 'optionalAccess', _365 => _365.ssr])) {
3863
- const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _366 => _366.getConfig, 'call', _367 => _367()]), () => ( options));
3864
- if ((_optionalChain([currentConfig, 'access', _368 => _368.experimental, 'optionalAccess', _369 => _369.serverActions]) !== true || !serverFnTransformActive) && !islandsServerFns()) {
4456
+ if (!_optionalChain([transformOptions, 'optionalAccess', _398 => _398.ssr])) {
4457
+ const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _399 => _399.getConfig, 'call', _400 => _400()]), () => ( options));
4458
+ if ((_optionalChain([currentConfig, 'access', _401 => _401.experimental, 'optionalAccess', _402 => _402.serverActions]) !== true || !serverFnTransformActive) && !islandsServerFns()) {
3865
4459
  const violation = findClientServerFnViolation(code, id);
3866
4460
  if (violation) {
3867
4461
  this.error(formatServerFnBoundaryError(violation, id));
3868
4462
  }
3869
4463
  }
3870
4464
  }
3871
- if (!_optionalChain([transformOptions, 'optionalAccess', _370 => _370.ssr]) && shouldInspectClientBoundary(id, code)) {
3872
- warnClientBoundaryOnce(this, id, code, _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _371 => _371.getConfig, 'call', _372 => _372()]), () => ( options)));
4465
+ if (!_optionalChain([transformOptions, 'optionalAccess', _403 => _403.ssr]) && shouldInspectClientBoundary(id, code)) {
4466
+ warnClientBoundaryOnce(this, id, code, _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _404 => _404.getConfig, 'call', _405 => _405()]), () => ( options)));
3873
4467
  }
3874
4468
  if (typeof imageImports.transform === "function") {
3875
4469
  const imageModule = await imageImports.transform.call(this, code, id, transformOptions);
@@ -3884,13 +4478,13 @@ export const manifest = getManifest();
3884
4478
  id,
3885
4479
  transformOptions
3886
4480
  );
3887
- const fontCode = typeof fontResult === "string" ? fontResult : _optionalChain([fontResult, 'optionalAccess', _373 => _373.code, 'optionalAccess', _374 => _374.toString, 'call', _375 => _375()]);
4481
+ const fontCode = typeof fontResult === "string" ? fontResult : _optionalChain([fontResult, 'optionalAccess', _406 => _406.code, 'optionalAccess', _407 => _407.toString, 'call', _408 => _408()]);
3888
4482
  if (fontCode) {
3889
4483
  transformedCode = fontCode;
3890
4484
  transformed = true;
3891
4485
  }
3892
4486
  }
3893
- if (_optionalChain([transformOptions, 'optionalAccess', _376 => _376.ssr]) && server) {
4487
+ if (_optionalChain([transformOptions, 'optionalAccess', _409 => _409.ssr]) && server) {
3894
4488
  const rewrittenImports = rewriteEarlySsrRelativeImports({
3895
4489
  code: transformedCode,
3896
4490
  id,
@@ -3902,26 +4496,26 @@ export const manifest = getManifest();
3902
4496
  transformed = true;
3903
4497
  }
3904
4498
  }
3905
- if (_chunk7ONGIFYXcjs.hasUseClientDirective.call(void 0, transformedCode)) {
4499
+ if (_chunk4DRINDGNcjs.hasUseClientDirective.call(void 0, transformedCode)) {
3906
4500
  const clientBoundarySource = transformedCode;
3907
4501
  const moduleInfo = this.getModuleInfo(id);
3908
4502
  if (moduleInfo) {
3909
4503
  moduleInfo.isClientComponent = true;
3910
4504
  }
3911
- transformedCode = _chunk7ONGIFYXcjs.stripUseClientDirective.call(void 0, transformedCode);
4505
+ transformedCode = _chunk4DRINDGNcjs.stripUseClientDirective.call(void 0, transformedCode);
3912
4506
  transformed = true;
3913
- const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _377 => _377.getConfig, 'call', _378 => _378()]), () => ( options));
4507
+ const currentConfig = _nullishCoalesce(_optionalChain([farmApp, 'optionalAccess', _410 => _410.getConfig, 'call', _411 => _411()]), () => ( options));
3914
4508
  let isolatedModuleReference = null;
3915
- const root = currentConfig.root || _optionalChain([server, 'optionalAccess', _379 => _379.config, 'access', _380 => _380.root]) || process.cwd();
4509
+ const root = currentConfig.root || _optionalChain([server, 'optionalAccess', _412 => _412.config, 'access', _413 => _413.root]) || process.cwd();
3916
4510
  const cleanId = id.split("?", 1)[0];
3917
- const selectedIsolatedModules = _nullishCoalesce(options.isolatedClientBoundaryModules, () => ( _optionalChain([farmApp, 'optionalAccess', _381 => _381.getRouteManager, 'call', _382 => _382(), 'access', _383 => _383.getIsolatedClientBoundaryModules, 'call', _384 => _384(root)])));
3918
- const selectedForIsolatedHydration = _optionalChain([selectedIsolatedModules, 'optionalAccess', _385 => _385.has, 'call', _386 => _386(path6.resolve(cleanId))]) === true;
3919
- if (_chunkRD623KW4cjs.isReactRenderer.call(void 0, _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, currentConfig.renderer)) && selectedForIsolatedHydration && (_chunk7ONGIFYXcjs.isIsolatableClientBoundarySource.call(void 0, clientBoundarySource) || // A generated client reference, whose marker comment compiled TSX no longer has.
3920
- cleanId.replace(/\\/g, "/").includes(_chunk7ONGIFYXcjs.FARM_CLIENT_REFERENCE_DIRECTORY))) {
4511
+ const selectedIsolatedModules = _nullishCoalesce(options.isolatedClientBoundaryModules, () => ( _optionalChain([farmApp, 'optionalAccess', _414 => _414.getRouteManager, 'call', _415 => _415(), 'access', _416 => _416.getIsolatedClientBoundaryModules, 'call', _417 => _417(root)])));
4512
+ const selectedForIsolatedHydration = _optionalChain([selectedIsolatedModules, 'optionalAccess', _418 => _418.has, 'call', _419 => _419(path6.resolve(cleanId))]) === true;
4513
+ if (_chunk67MZTLTFcjs.isReactRenderer.call(void 0, _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, currentConfig.renderer)) && selectedForIsolatedHydration && (_chunk4DRINDGNcjs.isIsolatableClientBoundarySource.call(void 0, clientBoundarySource) || // A generated client reference, whose marker comment compiled TSX no longer has.
4514
+ cleanId.replace(/\\/g, "/").includes(_chunk4DRINDGNcjs.FARM_CLIENT_REFERENCE_DIRECTORY))) {
3921
4515
  isolatedModuleReference = _chunkQMNWKQL4cjs.toViteModuleId.call(void 0, cleanId, root);
3922
- const islandsMode = _chunkZIHWAN55cjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([currentConfig, 'access', _387 => _387.experimental, 'optionalAccess', _388 => _388.serverComponents])) === "islands";
3923
- const explicitStrategy = _chunk7ONGIFYXcjs.getIslandStrategyExport.call(void 0, clientBoundarySource);
3924
- const inference = islandsMode && explicitStrategy === null ? _chunkE4UDLFWRcjs.inferFarmIslandStrategy.call(void 0, cleanId, root) : null;
4516
+ const islandsMode = _chunkRE5E2G5Scjs.resolveFarmServerComponentsMode.call(void 0, _optionalChain([currentConfig, 'access', _420 => _420.experimental, 'optionalAccess', _421 => _421.serverComponents])) === "islands";
4517
+ const explicitStrategy = _chunk4DRINDGNcjs.getIslandStrategyExport.call(void 0, clientBoundarySource);
4518
+ const inference = islandsMode && explicitStrategy === null ? _chunkN5DQMOAGcjs.inferFarmIslandStrategy.call(void 0, cleanId, root) : null;
3925
4519
  if (inference) {
3926
4520
  for (const file of inference.files) {
3927
4521
  if (file !== path6.resolve(cleanId)) this.addWatchFile(file);
@@ -3934,7 +4528,8 @@ export const manifest = getManifest();
3934
4528
  islandStrategy: _nullishCoalesce(explicitStrategy, () => ( "load")),
3935
4529
  parse: (source) => this.parse(source),
3936
4530
  slots: islandsMode,
3937
- inferredInteraction: _optionalChain([inference, 'optionalAccess', _389 => _389.strategy]) === "interaction"
4531
+ browser: _optionalChain([transformOptions, 'optionalAccess', _422 => _422.ssr]) !== true,
4532
+ inferredInteraction: _optionalChain([inference, 'optionalAccess', _423 => _423.strategy]) === "interaction"
3938
4533
  });
3939
4534
  if (!transformedBoundary) {
3940
4535
  this.error(
@@ -3964,7 +4559,7 @@ export const manifest = getManifest();
3964
4559
  );
3965
4560
  return;
3966
4561
  }` : "";
3967
- const hmrCode = _optionalChain([transformOptions, 'optionalAccess', _390 => _390.ssr]) || reactRefreshActive || !shouldEmitFarmClientRootHmr(currentConfig.renderer) ? "" : `
4562
+ const hmrCode = _optionalChain([transformOptions, 'optionalAccess', _424 => _424.ssr]) || reactRefreshActive || !shouldEmitFarmClientRootHmr(currentConfig.renderer) ? "" : `
3968
4563
  if (import.meta.hot) {
3969
4564
  import.meta.hot.accept((newModule) => {
3970
4565
  ${isolatedHmrUpdate}
@@ -3999,6 +4594,7 @@ if (import.meta.hot) {
3999
4594
  if (typeof fontImports.generateBundle === "function") {
4000
4595
  await fontImports.generateBundle.call(this, options2, bundle, false);
4001
4596
  }
4597
+ if (rendererDisabled) return;
4002
4598
  const clientManifest = generateClientManifest(bundle);
4003
4599
  this.emitFile({
4004
4600
  type: "asset",
@@ -4019,14 +4615,14 @@ if (import.meta.hot) {
4019
4615
  }
4020
4616
  _chunkQMNWKQL4cjs.logger.info(`Found ${ssgPages.length} SSG pages, ${ssrRoutes.length} SSR routes`);
4021
4617
  _chunkQMNWKQL4cjs.logger.info("Pre-rendering SSG pages...");
4022
- const outDir = path6.join(_optionalChain([server, 'optionalAccess', _391 => _391.config, 'access', _392 => _392.root]) || process.cwd(), options.outDir || "dist");
4618
+ const outDir = path6.join(_optionalChain([server, 'optionalAccess', _425 => _425.config, 'access', _426 => _426.root]) || process.cwd(), options.outDir || "dist");
4023
4619
  const clientDir = path6.join(outDir, "client");
4024
4620
  for (const page of ssgPages) {
4025
4621
  try {
4026
4622
  const staticRequest = new Request(new URL(page.urlPath, "http://farm.static"));
4027
4623
  await farmApp.getServerRenderer().runWithRequestContext(staticRequest, async () => {
4028
4624
  const mod = await routeManager.loadRouteModule(page.filePath);
4029
- if (!_optionalChain([mod, 'optionalAccess', _393 => _393.default])) return;
4625
+ if (!_optionalChain([mod, 'optionalAccess', _427 => _427.default])) return;
4030
4626
  const { layouts } = routeManager.matchRoute(page.urlPath);
4031
4627
  const layoutModules = await Promise.all(
4032
4628
  layouts.map((l) => routeManager.loadLayoutModule(l.modulePath))
@@ -4058,7 +4654,7 @@ if (import.meta.hot) {
4058
4654
  const i18nSnapshot = _chunkRVGLYMJMcjs.getFarmI18nClientSnapshot.call(void 0, );
4059
4655
  const i18nHead = renderFarmI18nStaticHead(page.urlPath, i18nSnapshot);
4060
4656
  const fullHtml = `<!DOCTYPE html>
4061
- <html lang="${escapeFarmHtmlAttribute(_optionalChain([i18nSnapshot, 'optionalAccess', _394 => _394.locale]) || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
4657
+ <html lang="${escapeFarmHtmlAttribute(_optionalChain([i18nSnapshot, 'optionalAccess', _428 => _428.locale]) || "en")}"${i18nSnapshot ? ` dir="${i18nSnapshot.direction}"` : ""}>
4062
4658
  <head>
4063
4659
  <meta charset="utf-8">
4064
4660
  <meta name="viewport" content="width=device-width, initial-scale=1">
@@ -4101,10 +4697,11 @@ if (import.meta.hot) {
4101
4697
  }
4102
4698
  },
4103
4699
  watchChange() {
4104
- _chunk7ONGIFYXcjs.invalidateFarmClientReachableModules.call(void 0, );
4105
- _chunk7ONGIFYXcjs.invalidateFarmClientOnlyScan.call(void 0, );
4700
+ _chunk4DRINDGNcjs.invalidateFarmClientReachableModules.call(void 0, );
4701
+ _chunk4DRINDGNcjs.invalidateFarmClientOnlyScan.call(void 0, );
4106
4702
  },
4107
4703
  async handleHotUpdate(ctx) {
4704
+ if (pendingClientSetup && !farmSetupContext.getStore()) await pendingClientSetup;
4108
4705
  const { file, server: server2, modules } = ctx;
4109
4706
  if (initialPluginManager) {
4110
4707
  try {
@@ -4126,13 +4723,13 @@ if (import.meta.hot) {
4126
4723
  server2.moduleGraph.invalidateModule(mod);
4127
4724
  }
4128
4725
  }
4129
- const currentFarmConfig = _optionalChain([farmApp, 'optionalAccess', _395 => _395.getConfig, 'call', _396 => _396()]);
4726
+ const currentFarmConfig = _optionalChain([farmApp, 'optionalAccess', _429 => _429.getConfig, 'call', _430 => _430()]);
4130
4727
  const normalizedFile = file.replace(/\\/g, "/");
4131
4728
  if (currentFarmConfig && /\/route\.(?:ts|tsx|js|jsx)$/.test(normalizedFile) && _chunk5Y2P454Ocjs.getFarmAppDirectories.call(void 0, currentFarmConfig).some(
4132
4729
  (appDir) => normalizedFile.startsWith(`${_chunkQMNWKQL4cjs.toPosixPath.call(void 0, appDir)}/api/`)
4133
4730
  )) {
4134
4731
  for (const mod of modules) server2.moduleGraph.invalidateModule(mod);
4135
- await _optionalChain([refreshRouteDiscovery, 'optionalCall', _397 => _397(`updated ${file}`)]);
4732
+ await _optionalChain([refreshRouteDiscovery, 'optionalCall', _431 => _431(`updated ${file}`)]);
4136
4733
  server2.ws.send({ type: "full-reload", path: "*" });
4137
4734
  return [];
4138
4735
  }
@@ -4142,7 +4739,7 @@ if (import.meta.hot) {
4142
4739
  for (const mod of modules) {
4143
4740
  server2.moduleGraph.invalidateModule(mod);
4144
4741
  }
4145
- await _optionalChain([refreshRouteDiscovery, 'optionalCall', _398 => _398(`updated ${file}`)]);
4742
+ await _optionalChain([refreshRouteDiscovery, 'optionalCall', _432 => _432(`updated ${file}`)]);
4146
4743
  server2.ws.send({
4147
4744
  type: "full-reload",
4148
4745
  path: "*"
@@ -4155,7 +4752,7 @@ if (import.meta.hot) {
4155
4752
  for (const mod of modules) {
4156
4753
  server2.moduleGraph.invalidateModule(mod);
4157
4754
  }
4158
- await _optionalChain([refreshRouteDiscovery, 'optionalCall', _399 => _399(`updated ${file}`)]);
4755
+ await _optionalChain([refreshRouteDiscovery, 'optionalCall', _433 => _433(`updated ${file}`)]);
4159
4756
  server2.ws.send({
4160
4757
  type: "full-reload",
4161
4758
  path: "*"
@@ -4163,12 +4760,12 @@ if (import.meta.hot) {
4163
4760
  return [];
4164
4761
  }
4165
4762
  if (apiRouteManager && _chunkJYNNIGQOcjs.invalidateFarmDevDependents.call(void 0, server2, file, apiRouteManager.getSourceFiles()).length > 0) {
4166
- await _optionalChain([refreshRouteDiscovery, 'optionalCall', _400 => _400(`updated ${file}`)]);
4763
+ await _optionalChain([refreshRouteDiscovery, 'optionalCall', _434 => _434(`updated ${file}`)]);
4167
4764
  }
4168
- const isolatedHydrationMode = _optionalChain([currentFarmConfig, 'optionalAccess', _401 => _401.experimental, 'optionalAccess', _402 => _402.isolatedClientHydration]);
4169
- const planRouteManager = _optionalChain([farmApp, 'optionalAccess', _403 => _403.getRouteManager, 'call', _404 => _404()]);
4765
+ const isolatedHydrationMode = _optionalChain([currentFarmConfig, 'optionalAccess', _435 => _435.experimental, 'optionalAccess', _436 => _436.isolatedClientHydration]);
4766
+ const planRouteManager = _optionalChain([farmApp, 'optionalAccess', _437 => _437.getRouteManager, 'call', _438 => _438()]);
4170
4767
  const isHydrationPlanSource = currentSrcRoot !== null && normalizedFile.startsWith(`${currentSrcRoot}/`) && /\.[cm]?[jt]sx?$/.test(normalizedFile);
4171
- const tracksAsyncOwnerIslands = _chunkRD623KW4cjs.isReactRenderer.call(void 0, _optionalChain([currentFarmConfig, 'optionalAccess', _405 => _405.renderer])) && planRouteManager !== void 0;
4768
+ const tracksAsyncOwnerIslands = _chunk67MZTLTFcjs.isReactRenderer.call(void 0, _optionalChain([currentFarmConfig, 'optionalAccess', _439 => _439.renderer])) && planRouteManager !== void 0;
4172
4769
  if (isHydrationPlanSource && (isolatedHydrationMode === "enabled" || isolatedHydrationMode === "analyze" || tracksAsyncOwnerIslands)) {
4173
4770
  const routeManager = planRouteManager;
4174
4771
  if (routeManager) {
@@ -4228,7 +4825,7 @@ if (import.meta.hot) {
4228
4825
  }
4229
4826
  return [];
4230
4827
  }
4231
- _optionalChain([farmApp, 'optionalAccess', _406 => _406.getRouteManager, 'call', _407 => _407(), 'access', _408 => _408.invalidateClientManifest, 'call', _409 => _409()]);
4828
+ _optionalChain([farmApp, 'optionalAccess', _440 => _440.getRouteManager, 'call', _441 => _441(), 'access', _442 => _442.invalidateClientManifest, 'call', _443 => _443()]);
4232
4829
  const manifestModule = server2.moduleGraph.getModuleById("/@farm/manifest");
4233
4830
  if (manifestModule) {
4234
4831
  server2.moduleGraph.invalidateModule(manifestModule);
@@ -4249,6 +4846,40 @@ if (import.meta.hot) {
4249
4846
  return modules;
4250
4847
  }
4251
4848
  };
4849
+ if (!deferredSetup) return plugin;
4850
+ const setUpDevServer = plugin.configureServer;
4851
+ let deferred = false;
4852
+ plugin.configureServer = function(viteServer) {
4853
+ if (deferred) {
4854
+ deferredGates = void 0;
4855
+ return setUpDevServer.call(this, viteServer);
4856
+ }
4857
+ deferred = true;
4858
+ const ready = () => deferredSetup.ready;
4859
+ deferredGates = {
4860
+ pre: createFarmDeferredMiddleware(ready),
4861
+ post: createFarmDeferredMiddleware(ready)
4862
+ };
4863
+ const setup = farmSetupContext.run(true, () => setUpDevServer.call(this, viteServer)).then((registerPostMiddleware) => {
4864
+ registerPostMiddleware();
4865
+ });
4866
+ viteServer.middlewares.use(deferredGates.pre.handle);
4867
+ deferredSetup.setup = setup;
4868
+ deferredSetup.ready = setup;
4869
+ pendingClientSetup = setup.then(
4870
+ () => {
4871
+ pendingClientSetup = null;
4872
+ },
4873
+ () => {
4874
+ pendingClientSetup = null;
4875
+ }
4876
+ );
4877
+ const post = deferredGates.post.handle;
4878
+ return () => {
4879
+ viteServer.middlewares.use(post);
4880
+ };
4881
+ };
4882
+ return plugin;
4252
4883
  }
4253
4884
  function runFarmMiddlewareWithNavigation(renderer, middlewareRequest, req, res, execute) {
4254
4885
  return renderer.runWithRequestContext(middlewareRequest, async () => {
@@ -4267,6 +4898,75 @@ function createPageDataMiddlewareRequest(req, target) {
4267
4898
  targetNodeRequest.method = "GET";
4268
4899
  return targetNodeRequest;
4269
4900
  }
4901
+ function createPageDataMiddlewareResponse(res) {
4902
+ let redirect = null;
4903
+ let passthrough = false;
4904
+ const captures = (status, location) => {
4905
+ if (redirect) return true;
4906
+ if (passthrough) return false;
4907
+ redirect = _chunkRWR7SMD7cjs.getFarmPageDataRedirectFromResponse.call(void 0,
4908
+ status,
4909
+ Array.isArray(location) ? location[0] : typeof location === "string" ? location : null
4910
+ );
4911
+ passthrough = !redirect;
4912
+ return !passthrough;
4913
+ };
4914
+ const response = new Proxy(res, {
4915
+ get(target, property) {
4916
+ if (property === "writeHead") {
4917
+ return (status, ...args) => {
4918
+ const headers = args.find((arg) => arg && typeof arg === "object");
4919
+ if (captures(status, _nullishCoalesce(readWriteHeadLocation(headers), () => ( target.getHeader("location"))))) {
4920
+ return response;
4921
+ }
4922
+ return target.writeHead(
4923
+ status,
4924
+ ...args
4925
+ );
4926
+ };
4927
+ }
4928
+ if (property === "write" || property === "end") {
4929
+ return (...args) => {
4930
+ if (captures(target.statusCode, target.getHeader("location"))) {
4931
+ const callback = args.find((arg) => typeof arg === "function");
4932
+ _optionalChain([callback, 'optionalCall', _444 => _444()]);
4933
+ return property === "write" ? true : response;
4934
+ }
4935
+ return target[property](...args);
4936
+ };
4937
+ }
4938
+ if (redirect && (property === "headersSent" || property === "writableEnded" || property === "finished")) {
4939
+ return true;
4940
+ }
4941
+ const value = Reflect.get(target, property, target);
4942
+ return typeof value === "function" ? value.bind(target) : value;
4943
+ },
4944
+ set(target, property, value) {
4945
+ return Reflect.set(target, property, value, target);
4946
+ }
4947
+ });
4948
+ return { response, redirect: () => redirect };
4949
+ }
4950
+ function readWriteHeadLocation(headers) {
4951
+ if (Array.isArray(headers)) {
4952
+ for (let index = 0; index + 1 < headers.length; index += 2) {
4953
+ if (String(headers[index]).toLowerCase() === "location") return headers[index + 1];
4954
+ }
4955
+ return void 0;
4956
+ }
4957
+ if (!headers || typeof headers !== "object") return void 0;
4958
+ for (const [name, value] of Object.entries(headers)) {
4959
+ if (name.toLowerCase() === "location") return value;
4960
+ }
4961
+ return void 0;
4962
+ }
4963
+ async function sendFarmPageDataRedirect(res, redirect, deploymentId) {
4964
+ for (const name of ["location", "content-length", "content-type"]) res.removeHeader(name);
4965
+ await _chunkYIHRZBD7cjs.sendWebResponse.call(void 0,
4966
+ res,
4967
+ _chunkF43OG25Pcjs.withFarmDeploymentResponse.call(void 0, _chunkRWR7SMD7cjs.createFarmPageDataRedirectResponse.call(void 0, redirect), deploymentId)
4968
+ );
4969
+ }
4270
4970
  function resolveDevelopmentRoot(farmRoot, viteRoot) {
4271
4971
  if (!farmRoot) return viteRoot;
4272
4972
  if (path6.resolve(farmRoot) === path6.resolve(viteRoot)) return farmRoot;
@@ -4274,7 +4974,7 @@ function resolveDevelopmentRoot(farmRoot, viteRoot) {
4274
4974
  if (fs2.realpathSync(farmRoot) === fs2.realpathSync(viteRoot)) {
4275
4975
  return path6.resolve(viteRoot);
4276
4976
  }
4277
- } catch (e18) {
4977
+ } catch (e26) {
4278
4978
  }
4279
4979
  return farmRoot;
4280
4980
  }
@@ -4293,12 +4993,12 @@ function isFarmClientVirtualId(id) {
4293
4993
  }
4294
4994
  function isClientEnvironment(context, loadOptions) {
4295
4995
  const environment = context.environment;
4296
- if (_optionalChain([environment, 'optionalAccess', _410 => _410.config, 'optionalAccess', _411 => _411.consumer])) return environment.config.consumer === "client";
4297
- if (_optionalChain([environment, 'optionalAccess', _412 => _412.name])) return environment.name === "client";
4298
- return _optionalChain([loadOptions, 'optionalAccess', _413 => _413.ssr]) !== true;
4996
+ if (_optionalChain([environment, 'optionalAccess', _445 => _445.config, 'optionalAccess', _446 => _446.consumer])) return environment.config.consumer === "client";
4997
+ if (_optionalChain([environment, 'optionalAccess', _447 => _447.name])) return environment.name === "client";
4998
+ return _optionalChain([loadOptions, 'optionalAccess', _448 => _448.ssr]) !== true;
4299
4999
  }
4300
5000
  function invalidateProgrammaticClientRouteModules(server) {
4301
- const graph = _optionalChain([server, 'access', _414 => _414.environments, 'optionalAccess', _415 => _415.client, 'optionalAccess', _416 => _416.moduleGraph]);
5001
+ const graph = _optionalChain([server, 'access', _449 => _449.environments, 'optionalAccess', _450 => _450.client, 'optionalAccess', _451 => _451.moduleGraph]);
4302
5002
  if (!graph) return;
4303
5003
  for (const [id, module] of graph.idToModuleMap) {
4304
5004
  if (_chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, id)) graph.invalidateModule(module);
@@ -4308,26 +5008,26 @@ function generateProgrammaticClientRouteModuleForId(moduleId, root, renderer, cl
4308
5008
  const parsed = _chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, moduleId);
4309
5009
  const routesFile = resolveRealModuleFile(parsed.filePath, root);
4310
5010
  watchFile(routesFile);
4311
- return _chunk7ONGIFYXcjs.generateProgrammaticClientRouteModule.call(void 0, {
5011
+ return _chunk4DRINDGNcjs.generateProgrammaticClientRouteModule.call(void 0, {
4312
5012
  kind: parsed.kind,
4313
5013
  routePath: parsed.routePath,
4314
5014
  routesFile,
4315
- route: parsed.kind === "api" ? void 0 : _optionalChain([clientRoutes, 'optionalAccess', _417 => _417.routes, 'access', _418 => _418.get, 'call', _419 => _419(
4316
- _chunk7ONGIFYXcjs.programmaticClientRouteKey.call(void 0, routesFile, parsed.kind, parsed.routePath)
5015
+ route: parsed.kind === "api" ? void 0 : _optionalChain([clientRoutes, 'optionalAccess', _452 => _452.routes, 'access', _453 => _453.get, 'call', _454 => _454(
5016
+ _chunk4DRINDGNcjs.programmaticClientRouteKey.call(void 0, routesFile, parsed.kind, parsed.routePath)
4317
5017
  )]),
4318
5018
  rendererServer: renderer.server,
4319
5019
  toImportSpecifier: (file) => toProgrammaticRouteImportSpecifier(file, root)
4320
5020
  });
4321
5021
  }
4322
5022
  function resolveRealModuleFile(filePath, root) {
4323
- const resolved = _nullishCoalesce(_chunk7ONGIFYXcjs.resolveModuleSourcePath.call(void 0, filePath, root), () => ( filePath));
5023
+ const resolved = _nullishCoalesce(_chunk4DRINDGNcjs.resolveModuleSourcePath.call(void 0, filePath, root), () => ( filePath));
4324
5024
  try {
4325
5025
  return _chunkQMNWKQL4cjs.toPosixPath.call(void 0, fs2.realpathSync(resolved));
4326
- } catch (e19) {
5026
+ } catch (e27) {
4327
5027
  return _chunkQMNWKQL4cjs.toPosixPath.call(void 0, resolved);
4328
5028
  }
4329
5029
  }
4330
- function generateProgrammaticRouteModule(moduleId, root, renderer = _chunkRD623KW4cjs.REACT_RENDERER) {
5030
+ function generateProgrammaticRouteModule(moduleId, root, renderer = _chunk67MZTLTFcjs.REACT_RENDERER) {
4331
5031
  const parsed = _chunkE7QOEV5Zcjs.parseProgrammaticRouteModuleId.call(void 0, moduleId);
4332
5032
  if (!parsed) {
4333
5033
  return "";
@@ -4634,12 +5334,12 @@ async function parseRouteModuleProps(routeModule, input) {
4634
5334
  }
4635
5335
  const schemas = routeModule.__farmRouteSchemas;
4636
5336
  const params = parseRouteModuleSchema(
4637
- _optionalChain([schemas, 'optionalAccess', _420 => _420.params]),
5337
+ _optionalChain([schemas, 'optionalAccess', _455 => _455.params]),
4638
5338
  input.props.params,
4639
5339
  "params",
4640
5340
  input.routePath
4641
5341
  );
4642
- const search = parseRouteModuleSchema(_optionalChain([schemas, 'optionalAccess', _421 => _421.search]), input.search, "search", input.routePath);
5342
+ const search = parseRouteModuleSchema(_optionalChain([schemas, 'optionalAccess', _456 => _456.search]), input.search, "search", input.routePath);
4643
5343
  return {
4644
5344
  ...input.props,
4645
5345
  params,
@@ -4658,20 +5358,20 @@ function parseRouteModuleSchema(schema, value, label, routePath) {
4658
5358
  throw new Error(`Invalid ${label} for route "${routePath}": ${message}`);
4659
5359
  }
4660
5360
  }
4661
- function generateClientCode(integrationProviders = [], documentNavigationMatchers = [], docsSearchClientRuntime = EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, devtoolsClientRuntime = "", plugins = [], root = process.cwd(), srcDir = "src", publicRuntimeConfig = void 0, docsAdapterReact, renderer = _chunkRD623KW4cjs.REACT_RENDERER, isolatedHydrationEnabled = false, trailingSlash = false, basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule, islandValues = false) {
4662
- const providerClientCode = _chunkE4UDLFWRcjs.generateFarmIntegrationProviderClientCode.call(void 0,
5361
+ function generateClientCode(integrationProviders = [], documentNavigationMatchers = [], docsSearchClientRuntime = EMPTY_FARM_DOCS_SEARCH_CLIENT_RUNTIME, devtoolsClientRuntime = "", plugins = [], root = process.cwd(), srcDir = "src", publicRuntimeConfig = void 0, docsAdapterReact, renderer = _chunk67MZTLTFcjs.REACT_RENDERER, isolatedHydrationEnabled = false, trailingSlash = false, basePath = "/", clientCachePersistence = { imports: "", init: "" }, docsConfigModule, islandValues = false) {
5362
+ const providerClientCode = _chunkN5DQMOAGcjs.generateFarmIntegrationProviderClientCode.call(void 0,
4663
5363
  integrationProviders,
4664
5364
  root,
4665
5365
  _nullishCoalesce(renderer.componentExtensions, () => ( []))
4666
5366
  );
4667
- const clientPluginEntry = _chunkE4UDLFWRcjs.generateFarmClientPluginEntryCode.call(void 0,
5367
+ const clientPluginEntry = _chunkJSOCDYERcjs.generateFarmClientPluginEntryCode.call(void 0,
4668
5368
  plugins,
4669
5369
  root,
4670
5370
  srcDir,
4671
5371
  publicRuntimeConfig
4672
5372
  );
4673
- const appSetupPath = _chunkRD623KW4cjs.resolveFarmRendererAppSetup.call(void 0, root, renderer);
4674
- const rendererClientImports = _chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) ? `import React from 'react'
5373
+ const appSetupPath = _chunk67MZTLTFcjs.resolveFarmRendererAppSetup.call(void 0, root, renderer);
5374
+ const rendererClientImports = _chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) ? `import React from 'react'
4675
5375
  import { hydrateRoot, createRoot } from 'react-dom/client'` : appSetupPath ? `import React, { hydrateRoot, createRoot, configureApp as __farmConfigureApp } from ${JSON.stringify(renderer.client)}
4676
5376
  import __farmAppSetup from ${JSON.stringify(_chunkQMNWKQL4cjs.toViteModuleId.call(void 0, appSetupPath, root))}
4677
5377
  __farmConfigureApp(__farmAppSetup)` : `import React, { hydrateRoot, createRoot } from ${JSON.stringify(renderer.client)}`;
@@ -4712,7 +5412,7 @@ async function createFarmServerTreePageElement(source, pathname) {
4712
5412
  return null;
4713
5413
  }
4714
5414
  }
4715
- ${islandValues ? `${_chunkE4UDLFWRcjs.FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE}
5415
+ ${islandValues ? `${_chunkN5DQMOAGcjs.FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE}
4716
5416
  let farmLastRouteState = null;
4717
5417
 
4718
5418
  // A hot update to a layout tree's client module renders the route again.
@@ -5523,7 +6223,7 @@ async function loadLayoutComponents(layouts = [], params = {}, source) {
5523
6223
  return loadedLayouts;
5524
6224
  }
5525
6225
 
5526
- ${_chunkE4UDLFWRcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
6226
+ ${_chunkN5DQMOAGcjs.FARM_LAYOUT_ELEMENT_CLIENT_SOURCE}
5527
6227
  function wrapWithLoadedLayouts(element, loadedLayouts, params) {
5528
6228
  let wrapped = element;
5529
6229
  for (let index = loadedLayouts.length - 1; index >= 0; index--) {
@@ -5602,7 +6302,7 @@ async function buildWrappedHydrationElement(PageComponent, pageProps, layouts =
5602
6302
 
5603
6303
  function hydrateFarmRoute(container, route) {
5604
6304
  farmLastRouteState = route;
5605
- ${_chunkRD623KW4cjs.isReactRenderer.call(void 0, renderer) ? "return hydrateRoot(container, route.element);" : "return route.layouts.length > 0 ? hydrateRoot(container, route.element, route) : hydrateRoot(container, route.element);"}
6305
+ ${_chunk67MZTLTFcjs.isReactRenderer.call(void 0, renderer) ? "return hydrateRoot(container, route.element);" : "return route.layouts.length > 0 ? hydrateRoot(container, route.element, route) : hydrateRoot(container, route.element);"}
5606
6306
  }
5607
6307
 
5608
6308
  function renderFarmRoute(root, route) {
@@ -5825,6 +6525,45 @@ function parseNavigationFragment(html) {
5825
6525
  return template.content;
5826
6526
  }
5827
6527
 
6528
+ // Suspense content streams, so a fresh response holds its fallback where the live DOM holds the
6529
+ // result. Compare without it.
6530
+ function removeSuspenseContent(root) {
6531
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
6532
+ const comments = [];
6533
+ while (walker.nextNode()) comments.push(walker.currentNode);
6534
+ let depth = 0;
6535
+ let start = null;
6536
+ for (const comment of comments) {
6537
+ if (comment.data === "$" || comment.data === "$?" || comment.data === "$!") {
6538
+ if (depth++ === 0) start = comment;
6539
+ } else if (comment.data === "/$" && depth > 0 && --depth === 0) {
6540
+ const range = document.createRange();
6541
+ range.setStartAfter(start);
6542
+ range.setEndBefore(comment);
6543
+ range.deleteContents();
6544
+ start.data = "$";
6545
+ }
6546
+ }
6547
+ }
6548
+
6549
+ // A layout's own server output, without what it wraps and without its islands, whose live DOM
6550
+ // always differs from fresh HTML.
6551
+ function getLayoutShell(root, patterns, index, find) {
6552
+ const shell = find(root, patterns[index])?.cloneNode(true);
6553
+ if (!shell) return null;
6554
+ const inner = index + 1 < patterns.length
6555
+ ? find(shell, patterns[index + 1])
6556
+ : shell.querySelector('#__farm_page__');
6557
+ inner?.replaceChildren();
6558
+ removeSuspenseContent(shell);
6559
+ shell.querySelectorAll('script').forEach((script) => script.remove());
6560
+ shell.querySelectorAll('f-island').forEach((island) => {
6561
+ island.replaceChildren();
6562
+ Array.from(island.attributes).forEach((attribute) => island.removeAttribute(attribute.name));
6563
+ });
6564
+ return shell.innerHTML;
6565
+ }
6566
+
5828
6567
  function replaceNavigationBoundary(
5829
6568
  container,
5830
6569
  fragment,
@@ -5837,7 +6576,11 @@ function replaceNavigationBoundary(
5837
6576
  while (
5838
6577
  sharedCount < currentPatterns.length &&
5839
6578
  sharedCount < nextPatterns.length &&
5840
- currentPatterns[sharedCount] === nextPatterns[sharedCount]
6579
+ currentPatterns[sharedCount] === nextPatterns[sharedCount] &&
6580
+ // A refresh renders every layout again: start at the first one whose output changed.
6581
+ (!refresh ||
6582
+ getLayoutShell(container, currentPatterns, sharedCount, find) ===
6583
+ getLayoutShell(fragment, nextPatterns, sharedCount, find))
5841
6584
  ) {
5842
6585
  sharedCount++;
5843
6586
  }
@@ -5880,7 +6623,7 @@ function replaceNavigationBoundary(
5880
6623
  return nextTarget;
5881
6624
  }
5882
6625
 
5883
- ${islandValues ? `${_chunkE4UDLFWRcjs.FARM_NAVIGATION_STREAM_READER_SOURCE}
6626
+ ${islandValues ? `${_chunkN5DQMOAGcjs.FARM_NAVIGATION_STREAM_READER_SOURCE}
5884
6627
 
5885
6628
  // Islands mode navigates as the production client does: it fetches the page itself, names the
5886
6629
  // layouts it shows by key (F-Layouts), and asks for flush markers (F-Stream), so the shell arrives
@@ -5938,7 +6681,8 @@ function farmDocumentNavigationRoute(pathname) {
5938
6681
  }
5939
6682
 
5940
6683
  async function fetchFarmNavigationDocument(path, context) {
5941
- farmNavigationStreamGeneration++;
6684
+ // A prefetch reads the page whole for the router's cache, and leaves a page that streams alone.
6685
+ if (!context.prefetch) farmNavigationStreamGeneration++;
5942
6686
  const url = new URL(path, window.location.href);
5943
6687
  const match = farmDocumentNavigationRoute(url.pathname);
5944
6688
  const container = document.getElementById('root');
@@ -5956,9 +6700,11 @@ async function fetchFarmNavigationDocument(path, context) {
5956
6700
  redirect: 'manual',
5957
6701
  headers: createFarmDeploymentRequestHeaders(deploymentId, {
5958
6702
  Accept: 'text/html',
5959
- 'F-Stream': 'flush',
6703
+ ...(context.prefetch ? {} : { 'F-Stream': 'flush' }),
5960
6704
  ...getFarmIslandValueHeaders(),
5961
- ...(identities.length ? { 'F-Layouts': JSON.stringify(identities) } : {}),
6705
+ // A prefetch names its layouts even when it keeps none: that marks it as a navigation,
6706
+ // which the server answers without loading.tsx.
6707
+ ...(identities.length || context.prefetch ? { 'F-Layouts': JSON.stringify(identities) } : {}),
5962
6708
  }),
5963
6709
  });
5964
6710
  if (isFarmDeploymentMismatchResponse(response, deploymentId)) {
@@ -5966,7 +6712,9 @@ async function fetchFarmNavigationDocument(path, context) {
5966
6712
  window.dispatchEvent(new CustomEvent('farm:deployment-mismatch', { detail: error }));
5967
6713
  throw error;
5968
6714
  }
5969
- // A redirect, an error or anything but HTML: the router loads the document instead.
6715
+ // A manual redirect hides its target, so page data answers this navigation and follows it.
6716
+ if (response.type === 'opaqueredirect') return null;
6717
+ // An error or anything but HTML: the router loads the document instead.
5970
6718
  if (
5971
6719
  !response.ok ||
5972
6720
  !response.body ||
@@ -5979,10 +6727,11 @@ async function fetchFarmNavigationDocument(path, context) {
5979
6727
  return { stream, doc, nextRoot: doc.getElementById('root') };
5980
6728
  };
5981
6729
  let result = await request(true);
5982
- if (result.nextRoot && !fitsFarmSegment(container, result.nextRoot)) {
6730
+ if (result && result.nextRoot && !fitsFarmSegment(container, result.nextRoot)) {
5983
6731
  result.stream.cancel?.();
5984
6732
  result = await request(false);
5985
6733
  }
6734
+ if (!result) return null;
5986
6735
  if (!result.nextRoot) {
5987
6736
  result.stream.cancel?.();
5988
6737
  throw new Error('The page has no #root');
@@ -6342,7 +7091,13 @@ function farmIslandsOnlyDocument() {
6342
7091
  // Islands mode hydrates the document, as production does, so islx also watches the islands
6343
7092
  // that stream in after this runs. Not cancelled by a navigation: an island it removes is
6344
7093
  // disposed with its DOM, and one in a layout it keeps still waits for its trigger.
7094
+ const hydrationSession = await farmClientRuntime.beginHydration({
7095
+ container: rootContainer || document.body,
7096
+ mode: 'hydrate',
7097
+ });
7098
+ // Each island reports and recovers its own failure, so this resolves once they are live.
6345
7099
  await hydrateFarmIsolatedClientBoundaries(${islandValues ? "document" : "rootContainer"});
7100
+ await farmClientRuntime.completeHydration(hydrationSession);
6346
7101
  // The rest of the document is static server HTML with nothing to hydrate, so
6347
7102
  // stop holding its clicks and submits once the load-strategy islands are live.
6348
7103
  // Deferred islands capture their own interactions, and held targets outside an
@@ -6562,9 +7317,9 @@ function generateClientManifest(bundle) {
6562
7317
  return manifest;
6563
7318
  }
6564
7319
  async function defineConfig(config = {}) {
6565
- const tailwindVitePlugin = await _chunkR53QDV6Tcjs.loadTailwindVitePlugin.call(void 0, );
7320
+ const tailwindVitePlugin = await _chunkJSOCDYERcjs.loadTailwindVitePlugin.call(void 0, );
6566
7321
  const appRoot = path6.resolve(config.root || process.cwd());
6567
- if (_optionalChain([config, 'access', _422 => _422.extends, 'optionalAccess', _423 => _423.length])) {
7322
+ if (_optionalChain([config, 'access', _457 => _457.extends, 'optionalAccess', _458 => _458.length])) {
6568
7323
  const { config: layeredConfig } = await import("./layers-DMRXRL7F.cjs").then(
6569
7324
  ({ resolveFarmLayers }) => resolveFarmLayers(config, {
6570
7325
  root: appRoot,
@@ -6573,12 +7328,12 @@ async function defineConfig(config = {}) {
6573
7328
  );
6574
7329
  config = layeredConfig;
6575
7330
  }
6576
- config.renderer = _chunkRD623KW4cjs.resolveFarmRenderer.call(void 0, config.renderer);
6577
- config.images = _chunkE4UDLFWRcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, { root: appRoot, dev: true });
6578
- const rendererVitePlugins = await _chunkRD623KW4cjs.loadFarmRendererVitePlugins.call(void 0, config.renderer, appRoot, {
7331
+ config.renderer = _chunk67MZTLTFcjs.resolveFarmRenderer.call(void 0, config.renderer);
7332
+ config.images = _chunkN5DQMOAGcjs.resolveFarmImageProviderForRuntime.call(void 0, config.images, { root: appRoot, dev: true });
7333
+ const rendererVitePlugins = await _chunk67MZTLTFcjs.loadFarmRendererVitePlugins.call(void 0, config.renderer, appRoot, {
6579
7334
  ssr: true
6580
7335
  });
6581
- const reactRefreshPlugins = _chunkRD623KW4cjs.isReactRenderer.call(void 0, config.renderer) ? await _chunk65Y5SIBHcjs.createFarmReactRefreshPlugins.call(void 0, ) : [];
7336
+ const reactRefreshPlugins = _chunk67MZTLTFcjs.isReactRenderer.call(void 0, config.renderer) ? await _chunk65Y5SIBHcjs.createFarmReactRefreshPlugins.call(void 0, ) : [];
6582
7337
  const nodeBuiltinStubs = {
6583
7338
  "node:string_decoder": "data:text/javascript,export class StringDecoder { write(buf) { return ''; } end() { return ''; } }; export default StringDecoder;",
6584
7339
  "node:buffer": "data:text/javascript,export const Buffer = { from: () => ({}), alloc: () => ({}), isBuffer: () => false }; export default { Buffer };",
@@ -6666,13 +7421,13 @@ async function defineConfig(config = {}) {
6666
7421
  if (!serverStarted) {
6667
7422
  serverStarted = true;
6668
7423
  const elapsed = Date.now() - startTime;
6669
- const address = _optionalChain([server, 'access', _424 => _424.httpServer, 'optionalAccess', _425 => _425.address, 'call', _426 => _426()]);
7424
+ const address = _optionalChain([server, 'access', _459 => _459.httpServer, 'optionalAccess', _460 => _460.address, 'call', _461 => _461()]);
6670
7425
  const resolvedPort = typeof address === "object" && address ? address.port : server.config.server.port || port || 3e3;
6671
7426
  const hostConfig = server.config.server.host;
6672
7427
  const isExposed = hostConfig === true || hostConfig === "0.0.0.0";
6673
7428
  console.log("");
6674
7429
  console.log(
6675
- ` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(`v${_chunkBIF5MLTHcjs.FARM_VERSION}`)} ${pc.dim(`ready in ${elapsed}ms`)}`
7430
+ ` ${pc.bold(pc.green("Farm.js"))} ${pc.dim(`v${_chunkHM7AGSKUcjs.FARM_VERSION}`)} ${pc.dim(`ready in ${elapsed}ms`)}`
6676
7431
  );
6677
7432
  console.log("");
6678
7433
  console.log(
@@ -6706,7 +7461,7 @@ async function defineConfig(config = {}) {
6706
7461
  plugins: [
6707
7462
  // `farm dev --desktop`: only the desktop window gets an answer, as in the packaged app.
6708
7463
  _chunk65Y5SIBHcjs.farmDesktopDevGuardPlugin.call(void 0, config.basePath),
6709
- _chunkE4UDLFWRcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
7464
+ _chunkN5DQMOAGcjs.createFarmThemeCssPlugin.call(void 0, config.theme, config.basePath),
6710
7465
  tailwindVitePlugin,
6711
7466
  ...rendererVitePlugins,
6712
7467
  ...reactRefreshPlugins,
@@ -6714,14 +7469,14 @@ async function defineConfig(config = {}) {
6714
7469
  farmI18nClientBridgePlugin(),
6715
7470
  farmServerOnlyEntriesPlugin(),
6716
7471
  farmPlugin(config),
6717
- _chunk7ONGIFYXcjs.farmEnvironmentFunctionsPlugin.call(void 0, config),
7472
+ _chunk4DRINDGNcjs.farmEnvironmentFunctionsPlugin.call(void 0, config),
6718
7473
  farmBrandingPlugin
6719
7474
  ],
6720
7475
  customLogger: farmLogger,
6721
7476
  clearScreen: false,
6722
7477
  optimizeDeps: {
6723
- ..._chunkE4UDLFWRcjs.createFarmClientOptimizeDepsConfig.call(void 0,
6724
- _chunkE4UDLFWRcjs.createFarmClientOptimizeDepsEntries.call(void 0,
7478
+ ..._chunkN5DQMOAGcjs.createFarmClientOptimizeDepsConfig.call(void 0,
7479
+ _chunkN5DQMOAGcjs.createFarmClientOptimizeDepsEntries.call(void 0,
6725
7480
  appRoot,
6726
7481
  _chunk5Y2P454Ocjs.getFarmAppDirectories.call(void 0, { ...config, root: appRoot })
6727
7482
  ),
@@ -6764,7 +7519,7 @@ async function defineConfig(config = {}) {
6764
7519
  // Stub out problematic server-only modules during dev mode
6765
7520
  alias: {
6766
7521
  ..._chunk5Y2P454Ocjs.getFarmLayerAliases.call(void 0, config.layers),
6767
- ..._chunkE4UDLFWRcjs.createFarmSourceAlias.call(void 0, appRoot, config.srcDir),
7522
+ ..._chunkN5DQMOAGcjs.createFarmSourceAlias.call(void 0, appRoot, config.srcDir),
6768
7523
  // Nitro internals that should not be resolved in browser
6769
7524
  "supports-color": "data:text/javascript,export default false; export const supportsColor = false; export const stdout = false; export const stderr = false;",
6770
7525
  "@poppinss/dumper": "data:text/javascript,export default {};",