@farm.js/core 0.1.69 → 0.1.71

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 (314) hide show
  1. package/dist/{agent-mcp-handler-FER4MQDF.cjs → agent-mcp-handler-KE4J3W7S.cjs} +8 -5
  2. package/dist/{agent-mcp-handler-AZ7QW4UP.mjs → agent-mcp-handler-VIT4GOSR.mjs} +7 -4
  3. package/dist/{agent-mcp.d-DOfBMEzP.d.mts → agent-mcp.d-BzNw6JI8.d.ts} +24 -5
  4. package/dist/{agent-mcp.d-DnIgriX1.d.ts → agent-mcp.d-CgFen3EH.d.mts} +24 -5
  5. package/dist/agent-runtime.cjs +3 -3
  6. package/dist/agent-runtime.d.mts +3 -2
  7. package/dist/agent-runtime.d.ts +3 -2
  8. package/dist/agent-runtime.mjs +2 -2
  9. package/dist/analyzer-LPIVRSTJ.cjs +16 -0
  10. package/dist/{analyzer-NAL5TJUP.mjs → analyzer-VK3BAOFI.mjs} +2 -2
  11. package/dist/api/node.d.mts +5 -4
  12. package/dist/api/node.d.ts +5 -4
  13. package/dist/api/route-manager.cjs +4 -4
  14. package/dist/api/route-manager.d.mts +16 -7
  15. package/dist/api/route-manager.d.ts +16 -7
  16. package/dist/api/route-manager.mjs +3 -3
  17. package/dist/api/runtime.d.mts +4 -3
  18. package/dist/api/runtime.d.ts +4 -3
  19. package/dist/api.cjs +6 -6
  20. package/dist/api.d.mts +8 -7
  21. package/dist/api.d.ts +8 -7
  22. package/dist/api.mjs +5 -5
  23. package/dist/{app-manifest.d-CaAcaukR.d.ts → app-manifest.d-DY4JfJxi.d.ts} +1 -1
  24. package/dist/{app-manifest.d-_BVbI0xp.d.mts → app-manifest.d-DpDK_B1k.d.mts} +1 -1
  25. package/dist/app-markdown.cjs +7 -4
  26. package/dist/app-markdown.d.mts +5 -4
  27. package/dist/app-markdown.d.ts +5 -4
  28. package/dist/app-markdown.mjs +6 -3
  29. package/dist/{app.d-BWeDqOaF.d.ts → app.d-BeK6bb1c.d.ts} +22 -10
  30. package/dist/{app.d-CaPwtytN.d.mts → app.d-D-5UNrFd.d.mts} +22 -10
  31. package/dist/{base-path.d-CTDVF0Fc.d.mts → base-path.d-BJ3SYpB8.d.mts} +6 -1
  32. package/dist/{base-path.d-CTDVF0Fc.d.ts → base-path.d-BJ3SYpB8.d.ts} +6 -1
  33. package/dist/{chunk-4ZXKYCYK.mjs → chunk-255J7K4X.mjs} +1 -1
  34. package/dist/{chunk-RVGLYMJM.cjs → chunk-2AM26UGI.cjs} +2 -2
  35. package/dist/{chunk-5TOWKGV3.mjs → chunk-2CQC5CMD.mjs} +1 -1
  36. package/dist/{chunk-VO65MYJD.cjs → chunk-2IFT2CSA.cjs} +4 -4
  37. package/dist/{chunk-UPOYKX4S.cjs → chunk-2MR4MABG.cjs} +4 -4
  38. package/dist/chunk-2RCCFB2Y.cjs +129 -0
  39. package/dist/{chunk-K6VFYFOY.cjs → chunk-2W4GNXGX.cjs} +2 -2
  40. package/dist/{chunk-CV6MFQ4Y.mjs → chunk-3AUINHFG.mjs} +1 -1
  41. package/dist/{chunk-TKYOJ5G2.cjs → chunk-3BQ7QHUH.cjs} +5 -5
  42. package/dist/{chunk-MMDKYJ5V.cjs → chunk-3GNVIYPO.cjs} +7 -7
  43. package/dist/{chunk-65Y5SIBH.cjs → chunk-3QM74STY.cjs} +1 -1
  44. package/dist/{chunk-FJMC24KG.cjs → chunk-42KMUIWZ.cjs} +0 -3
  45. package/dist/{chunk-YVPX5PI5.mjs → chunk-4O26BPUY.mjs} +8 -0
  46. package/dist/{chunk-PDQ6EGPK.mjs → chunk-4OD2LXF2.mjs} +2 -2
  47. package/dist/{chunk-LENKRGBV.mjs → chunk-5CFHQ7HM.mjs} +1 -1
  48. package/dist/{chunk-3Y52TWYU.mjs → chunk-62ZRA7XU.mjs} +0 -3
  49. package/dist/{chunk-K76CBYQM.mjs → chunk-7A3URI2F.mjs} +20 -0
  50. package/dist/{chunk-UHU4QALN.mjs → chunk-7BUE2GM6.mjs} +294 -164
  51. package/dist/{chunk-L6NWQ3DR.cjs → chunk-7OHJWFLB.cjs} +600 -469
  52. package/dist/{chunk-VX2HZGC7.cjs → chunk-ACGBXN3U.cjs} +2 -2
  53. package/dist/{chunk-MV7NWU23.mjs → chunk-AYVGD3PK.mjs} +1 -1
  54. package/dist/{chunk-FT6KJHS3.cjs → chunk-C2JOS77Z.cjs} +4 -1
  55. package/dist/{chunk-CRVSYDHV.mjs → chunk-CKQAQFF6.mjs} +2 -2
  56. package/dist/{chunk-QOGIZKSO.cjs → chunk-CSQPMV3Q.cjs} +21 -11
  57. package/dist/chunk-DC2AXGNZ.mjs +129 -0
  58. package/dist/{chunk-Q4HH5Q6A.cjs → chunk-DMXMIE2C.cjs} +2 -2
  59. package/dist/{chunk-MAGFDK4Q.mjs → chunk-DPIGYXSV.mjs} +1 -1
  60. package/dist/{chunk-GUMKIQJL.cjs → chunk-DPYBVVL3.cjs} +2 -2
  61. package/dist/{chunk-23VJEGKC.cjs → chunk-DVJM55D2.cjs} +9 -1
  62. package/dist/{chunk-QSUYB3RH.cjs → chunk-DZHTNSQ5.cjs} +14 -14
  63. package/dist/{chunk-OIOPQ25L.mjs → chunk-E77IA5IF.mjs} +46 -33
  64. package/dist/{chunk-EZTKXD6P.cjs → chunk-FDGYDQGL.cjs} +8 -1
  65. package/dist/{chunk-PLJKJJ2H.mjs → chunk-FETMUBIA.mjs} +27 -82
  66. package/dist/{chunk-HJZZSBVK.cjs → chunk-FILXOEWD.cjs} +2 -2
  67. package/dist/{chunk-PDFFYZAT.cjs → chunk-GF22VGMS.cjs} +2 -2
  68. package/dist/{chunk-IYLZZTP6.mjs → chunk-GUU3IZSM.mjs} +167 -77
  69. package/dist/{chunk-OOJBBHYW.cjs → chunk-GVYZCJZH.cjs} +30 -1
  70. package/dist/{chunk-YOHHL2UE.mjs → chunk-I4KPA2C6.mjs} +1 -1
  71. package/dist/{chunk-PEYDQMSA.mjs → chunk-IGXS54GC.mjs} +6 -6
  72. package/dist/{chunk-NVOMQLI2.mjs → chunk-IWJONXPF.mjs} +11 -0
  73. package/dist/{chunk-SZORL7EW.mjs → chunk-IYDJNCR7.mjs} +6 -6
  74. package/dist/{chunk-HEJM46HQ.mjs → chunk-J5ASGNKF.mjs} +28 -2
  75. package/dist/{chunk-RLH5AH2M.mjs → chunk-JDO346NV.mjs} +1 -1
  76. package/dist/{chunk-K6SXMVXO.mjs → chunk-JMFTKNBA.mjs} +22 -7
  77. package/dist/{chunk-YIHRZBD7.cjs → chunk-JRGR5Z4K.cjs} +1 -1
  78. package/dist/{chunk-4W4ZWSV2.cjs → chunk-JVA4PIYN.cjs} +604 -434
  79. package/dist/{chunk-UKZ6AWKZ.cjs → chunk-JWY66PID.cjs} +44 -1
  80. package/dist/{chunk-BDYM2TN3.cjs → chunk-JX5VOLAV.cjs} +8 -8
  81. package/dist/{chunk-WMLSZAKN.mjs → chunk-JZQS3ZOI.mjs} +1 -1
  82. package/dist/{chunk-OFBLGH6V.cjs → chunk-K66JILV3.cjs} +47 -34
  83. package/dist/{chunk-6GQJVY4E.cjs → chunk-KEB7AGS6.cjs} +17 -17
  84. package/dist/{chunk-IFR74W6S.mjs → chunk-KPJYBSHL.mjs} +4 -1
  85. package/dist/{chunk-TEJ67GD2.mjs → chunk-KQAB5LML.mjs} +28 -6
  86. package/dist/{chunk-DHR2WDSL.cjs → chunk-KWST2O22.cjs} +387 -297
  87. package/dist/{chunk-3EEINK7G.cjs → chunk-L6E4SHUB.cjs} +41 -15
  88. package/dist/{chunk-KI3MU7B5.mjs → chunk-LDVJIBGN.mjs} +1 -1
  89. package/dist/{chunk-5FBZJJGA.mjs → chunk-LXEJNWF5.mjs} +2 -2
  90. package/dist/{chunk-AKIQ54FK.cjs → chunk-MBCRWU3P.cjs} +26 -81
  91. package/dist/{chunk-22LGTSBA.cjs → chunk-MEJCP2LX.cjs} +1 -1
  92. package/dist/{chunk-ZR2QB45W.mjs → chunk-MITIAOUQ.mjs} +4 -4
  93. package/dist/{chunk-OCNV4CI2.cjs → chunk-MQ4DYVFS.cjs} +26 -0
  94. package/dist/{chunk-P2NBQ5JI.mjs → chunk-MWUDEYBI.mjs} +1 -1
  95. package/dist/{chunk-LR4KP3I7.cjs → chunk-N3XO5AL5.cjs} +2 -2
  96. package/dist/{chunk-ZPKJPM7K.mjs → chunk-NA77GEIU.mjs} +2 -2
  97. package/dist/{chunk-FVYBEMOD.cjs → chunk-NAXKOTPP.cjs} +6 -6
  98. package/dist/{chunk-I7J5RLGO.cjs → chunk-NLBHLPEO.cjs} +12 -1
  99. package/dist/{chunk-R2ZHU37O.mjs → chunk-NLRAQXAA.mjs} +26 -0
  100. package/dist/{chunk-QO43L7Z4.cjs → chunk-O32QPFVV.cjs} +25 -7
  101. package/dist/{chunk-CO6UYM2D.mjs → chunk-O5QUJEWT.mjs} +1 -1
  102. package/dist/{chunk-JL2YW5KX.mjs → chunk-OAEDVXVE.mjs} +44 -1
  103. package/dist/{chunk-F6YLXK5L.cjs → chunk-PLXD2MJV.cjs} +19 -19
  104. package/dist/{chunk-JFPKARWM.cjs → chunk-PMU4U2W2.cjs} +1 -0
  105. package/dist/{chunk-GTQOEEE7.cjs → chunk-Q5HMVGR5.cjs} +13 -13
  106. package/dist/{chunk-ZYCEEE3V.mjs → chunk-QUFENL7Q.mjs} +2 -2
  107. package/dist/{chunk-QOSDWGKT.mjs → chunk-QVBXTSIZ.mjs} +1 -1
  108. package/dist/{chunk-OGVTUGMU.mjs → chunk-REP6HWJN.mjs} +13 -3
  109. package/dist/{chunk-ANMIR6US.mjs → chunk-RJUCNO7R.mjs} +1 -1
  110. package/dist/{chunk-WYL4ODZ4.mjs → chunk-SE7HPBYK.mjs} +30 -1
  111. package/dist/{chunk-GQ6QOH7T.cjs → chunk-SXMWVP2L.cjs} +12 -12
  112. package/dist/{chunk-D5F7RPZP.mjs → chunk-THG2TVDH.mjs} +3 -3
  113. package/dist/{chunk-X3MHKLCO.cjs → chunk-TP4RAV7Y.cjs} +25 -10
  114. package/dist/{chunk-DWLNLU55.cjs → chunk-TPYAYFMF.cjs} +2 -2
  115. package/dist/{chunk-Y6KHPJDB.cjs → chunk-U7VH3Q5E.cjs} +2 -2
  116. package/dist/{chunk-4JRAMCUP.cjs → chunk-UISZLYKY.cjs} +22 -22
  117. package/dist/{chunk-CKCKCUYO.mjs → chunk-UQUOSNRN.mjs} +511 -341
  118. package/dist/{chunk-2P7UYHZP.mjs → chunk-V25GSH43.mjs} +1 -1
  119. package/dist/{chunk-437QZIC2.cjs → chunk-VNBDN5W2.cjs} +5 -5
  120. package/dist/{chunk-ABIBASLJ.cjs → chunk-VXB5CMNC.cjs} +2 -2
  121. package/dist/{chunk-G7NBPP7H.mjs → chunk-W2T6NDNP.mjs} +11 -1
  122. package/dist/{chunk-AJNBTOVQ.mjs → chunk-WW3LRNQV.mjs} +1 -1
  123. package/dist/{chunk-GFPS7MNE.mjs → chunk-WX63N6C5.mjs} +4 -4
  124. package/dist/{chunk-ULMXZYOA.mjs → chunk-X7LGLF33.mjs} +1 -1
  125. package/dist/{chunk-VOQ7XZZT.cjs → chunk-Y2SZVIVH.cjs} +20 -0
  126. package/dist/{chunk-XCAQTCGK.mjs → chunk-YBY34UHB.mjs} +1 -1
  127. package/dist/{chunk-5NFQ6AZI.cjs → chunk-YCNHUIPR.cjs} +33 -11
  128. package/dist/{chunk-YGJ5P3TJ.mjs → chunk-Z3GPAFIA.mjs} +21 -3
  129. package/dist/{chunk-PJQ5W356.mjs → chunk-Z5ZZAGIH.mjs} +1 -0
  130. package/dist/{chunk-L5OZN6YW.cjs → chunk-ZPUAOKHV.cjs} +3 -3
  131. package/dist/{chunk-4E57QHPW.cjs → chunk-ZUVAGMQ5.cjs} +17 -7
  132. package/dist/{chunk-23LVFSID.mjs → chunk-ZXDX7VYZ.mjs} +7 -0
  133. package/dist/{client-component.d-CnEeVvGG.d.mts → client-component.d-DwpH251K.d.mts} +2 -2
  134. package/dist/{client-component.d-CfJxuXZl.d.ts → client-component.d-fYupugbZ.d.ts} +2 -2
  135. package/dist/{client-plugins.d-D7dHV1Nf.d.ts → client-plugins.d-BxqFfHpM.d.ts} +39 -3
  136. package/dist/{client-plugins.d-Do5ULA0x.d.mts → client-plugins.d-k3bOT5gz.d.mts} +39 -3
  137. package/dist/client-plugins.d.mts +3 -2
  138. package/dist/client-plugins.d.ts +3 -2
  139. package/dist/client.cjs +6 -6
  140. package/dist/client.d.mts +8 -7
  141. package/dist/client.d.ts +8 -7
  142. package/dist/client.mjs +5 -5
  143. package/dist/config.d.mts +3 -2
  144. package/dist/config.d.ts +3 -2
  145. package/dist/deployment.cjs +4 -2
  146. package/dist/deployment.d.mts +7 -1
  147. package/dist/deployment.d.ts +7 -1
  148. package/dist/deployment.mjs +5 -3
  149. package/dist/desktop.d.mts +4 -3
  150. package/dist/desktop.d.ts +4 -3
  151. package/dist/{dev-guard-ONNMVQUN.mjs → dev-guard-ZDIELV6Q.mjs} +1 -1
  152. package/dist/{dev-guard-2UW2KERP.cjs → dev-guard-ZLLKVO5T.cjs} +2 -2
  153. package/dist/{devtools-BP4EBTKQ.mjs → devtools-6MXPFPNJ.mjs} +9 -8
  154. package/dist/{devtools-7HNDS4SY.cjs → devtools-O5625KCK.cjs} +10 -9
  155. package/dist/docs.cjs +13 -12
  156. package/dist/docs.d.mts +4 -3
  157. package/dist/docs.d.ts +4 -3
  158. package/dist/docs.mjs +12 -11
  159. package/dist/environment/vite.cjs +3 -3
  160. package/dist/environment/vite.mjs +2 -2
  161. package/dist/headers.d-DalIGbVO.d.ts +18 -0
  162. package/dist/headers.d-sNT7ZQiU.d.mts +18 -0
  163. package/dist/i18n/client.cjs +2 -2
  164. package/dist/i18n/client.d.mts +2 -2
  165. package/dist/i18n/client.d.ts +2 -2
  166. package/dist/i18n/client.mjs +1 -1
  167. package/dist/i18n/index.cjs +2 -2
  168. package/dist/i18n/index.d.mts +3 -3
  169. package/dist/i18n/index.d.ts +3 -3
  170. package/dist/i18n/index.mjs +1 -1
  171. package/dist/i18n/server.cjs +3 -3
  172. package/dist/i18n/server.d.mts +5 -5
  173. package/dist/i18n/server.d.ts +5 -5
  174. package/dist/i18n/server.mjs +2 -2
  175. package/dist/index.cjs +50 -45
  176. package/dist/{index.d-CVFk37uX.d.ts → index.d-BcA-secm.d.ts} +1 -1
  177. package/dist/{index.d-B1MpEJAo.d.mts → index.d-DDHHAv7j.d.mts} +1 -1
  178. package/dist/index.d.mts +26 -24
  179. package/dist/index.d.ts +26 -24
  180. package/dist/index.mjs +63 -58
  181. package/dist/integrations/orm.d.mts +3 -2
  182. package/dist/integrations/orm.d.ts +3 -2
  183. package/dist/integrations.cjs +3 -3
  184. package/dist/integrations.d.mts +3 -2
  185. package/dist/integrations.d.ts +3 -2
  186. package/dist/integrations.mjs +2 -2
  187. package/dist/internal/app-markdown-runtime.cjs +6 -3
  188. package/dist/internal/app-markdown-runtime.d.mts +13 -4
  189. package/dist/internal/app-markdown-runtime.d.ts +13 -4
  190. package/dist/internal/app-markdown-runtime.mjs +5 -2
  191. package/dist/internal/build-runtime.cjs +37 -37
  192. package/dist/internal/build-runtime.d.mts +5 -4
  193. package/dist/internal/build-runtime.d.ts +5 -4
  194. package/dist/internal/build-runtime.mjs +36 -36
  195. package/dist/internal/cli-runtime.cjs +18 -15
  196. package/dist/internal/cli-runtime.mjs +17 -14
  197. package/dist/internal/client-error-overlay.cjs +4 -4
  198. package/dist/internal/client-error-overlay.mjs +1 -1
  199. package/dist/internal/client-runtime.cjs +5 -3
  200. package/dist/internal/client-runtime.d.mts +17 -7
  201. package/dist/internal/client-runtime.d.ts +17 -7
  202. package/dist/internal/client-runtime.mjs +4 -2
  203. package/dist/internal/compression-runtime.d.mts +3 -2
  204. package/dist/internal/compression-runtime.d.ts +3 -2
  205. package/dist/internal/config-runtime.cjs +11 -10
  206. package/dist/internal/config-runtime.d.mts +6 -5
  207. package/dist/internal/config-runtime.d.ts +6 -5
  208. package/dist/internal/config-runtime.mjs +10 -9
  209. package/dist/internal/infra-analytics-runtime.cjs +12 -9
  210. package/dist/internal/infra-analytics-runtime.mjs +10 -7
  211. package/dist/internal/native-server-fns.cjs +4 -4
  212. package/dist/internal/native-server-fns.mjs +3 -3
  213. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  214. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  215. package/dist/internal/production-runtime.cjs +48 -17
  216. package/dist/internal/production-runtime.d.mts +53 -18
  217. package/dist/internal/production-runtime.d.ts +53 -18
  218. package/dist/internal/production-runtime.mjs +50 -19
  219. package/dist/internal/vercel-edge-middleware.cjs +3 -2
  220. package/dist/internal/vercel-edge-middleware.d.mts +2 -2
  221. package/dist/internal/vercel-edge-middleware.d.ts +2 -2
  222. package/dist/internal/vercel-edge-middleware.mjs +2 -1
  223. package/dist/markdown.cjs +3 -2
  224. package/dist/markdown.d.mts +3 -2
  225. package/dist/markdown.d.ts +3 -2
  226. package/dist/markdown.mjs +2 -1
  227. package/dist/middleware.cjs +6 -5
  228. package/dist/middleware.d.mts +4 -3
  229. package/dist/middleware.d.ts +4 -3
  230. package/dist/middleware.mjs +5 -4
  231. package/dist/mobile.d.mts +3 -3
  232. package/dist/mobile.d.ts +3 -3
  233. package/dist/{mount.d-CBqr-LfI.d.mts → mount.d-C1PONsEe.d.mts} +1 -1
  234. package/dist/{mount.d-CGzN61Kq.d.ts → mount.d-D3JOux2V.d.ts} +1 -1
  235. package/dist/{native-tree-W2SSJB3Y.cjs → native-tree-GF4BH33L.cjs} +4 -3
  236. package/dist/{native-tree-Y5YQANW7.mjs → native-tree-L2IIEBXH.mjs} +3 -2
  237. package/dist/{navigation-delegate.d-BwCOhpj7.d.mts → navigation-delegate.d-CJQQHboA.d.mts} +1 -1
  238. package/dist/{navigation-delegate.d-CLH2dXjy.d.ts → navigation-delegate.d-CQQPbdkE.d.ts} +1 -1
  239. package/dist/navigation.cjs +5 -5
  240. package/dist/navigation.d.mts +6 -5
  241. package/dist/navigation.d.ts +6 -5
  242. package/dist/navigation.mjs +4 -4
  243. package/dist/{nitro-Y3LGITW3.cjs → nitro-2LMOMIST.cjs} +2 -2
  244. package/dist/{nitro-NSTXT7LB.mjs → nitro-72TFIGGO.mjs} +1 -1
  245. package/dist/{plugin-F2O4BFTK.cjs → plugin-5PIQQVRP.cjs} +2 -2
  246. package/dist/{plugin-VEBRN7A3.mjs → plugin-QZT747YW.mjs} +1 -1
  247. package/dist/plugin.cjs +30 -29
  248. package/dist/plugin.d.mts +6 -4
  249. package/dist/plugin.d.ts +6 -4
  250. package/dist/plugin.mjs +29 -28
  251. package/dist/{production-runtime.d-DMZY3OgV.d.mts → production-runtime.d-B0IeWWyO.d.mts} +23 -2
  252. package/dist/{production-runtime.d-BMyyLGBB.d.ts → production-runtime.d-q3aHIv5Y.d.ts} +23 -2
  253. package/dist/query/client.cjs +6 -6
  254. package/dist/query/client.mjs +2 -2
  255. package/dist/{render-plan.d-CzGDjcT0.d.mts → render-plan.d-CiUj0rq5.d.mts} +1 -1
  256. package/dist/{render-plan.d-W6LmjD6y.d.ts → render-plan.d-DHuJMJRP.d.ts} +1 -1
  257. package/dist/renderer-client.cjs +7 -7
  258. package/dist/renderer-client.d.mts +6 -5
  259. package/dist/renderer-client.d.ts +6 -5
  260. package/dist/renderer-client.mjs +3 -3
  261. package/dist/{request.d-CgNVderU.d.mts → request.d-D-F7o7tb.d.mts} +1 -1
  262. package/dist/{request.d-CTVRZiQv.d.ts → request.d-DRUbOmYD.d.ts} +1 -1
  263. package/dist/request.d.mts +4 -3
  264. package/dist/request.d.ts +4 -3
  265. package/dist/{resolver.d-JnZKKsc5.d.mts → resolver.d-9iKC79CU.d.mts} +1 -1
  266. package/dist/{resolver.d-BHyZgpa7.d.ts → resolver.d-CY6mEa_F.d.ts} +1 -1
  267. package/dist/response.d-B_MtBCnF.d.mts +12 -0
  268. package/dist/response.d-B_MtBCnF.d.ts +12 -0
  269. package/dist/{route-rendering.d-D0bmZVJA.d.mts → route-rendering.d-6smgwT2t.d.mts} +9 -2
  270. package/dist/{route-rendering.d-FDSNtCMg.d.ts → route-rendering.d-KwqM_mlK.d.ts} +9 -2
  271. package/dist/{router.d-DZ3ldniI.d.ts → router.d-B6sesMRD.d.ts} +1 -1
  272. package/dist/{router.d-GRKm_uAV.d.mts → router.d-BYmDeDlp.d.mts} +1 -1
  273. package/dist/{routes.d-CrEy0lJS.d.mts → routes.d-D3aJw1H5.d.mts} +1 -1
  274. package/dist/{routes.d-9GFFNioh.d.ts → routes.d-K-Qg79AA.d.ts} +1 -1
  275. package/dist/routes.d.mts +3 -2
  276. package/dist/routes.d.ts +3 -2
  277. package/dist/{index.d-BNNDpql4.d.ts → routing.d-BxOZ2YWc.d.ts} +1 -2
  278. package/dist/{index.d-BqcfqJvt.d.mts → routing.d-DwSUVZbF.d.mts} +1 -2
  279. package/dist/{rsc-pipeline-J4KKBSCH.cjs → rsc-pipeline-P4PCWDO2.cjs} +14 -13
  280. package/dist/{rsc-pipeline-PJZOVYSY.mjs → rsc-pipeline-R2GOKIMU.mjs} +13 -12
  281. package/dist/{runtime-QDBSE4H6.mjs → runtime-DP5DYGW5.mjs} +12 -11
  282. package/dist/{runtime-OLEO5NXF.cjs → runtime-WA2Q4SLG.cjs} +20 -19
  283. package/dist/{runtime.d-DqXihlxm.d.mts → runtime.d-BFSJf-ww.d.mts} +1 -1
  284. package/dist/{runtime.d-BtL3PCL3.d.ts → runtime.d-B_uPfMjA.d.ts} +2 -2
  285. package/dist/{runtime.d-pqFQBU2N.d.ts → runtime.d-CbdMI0Oy.d.ts} +1 -1
  286. package/dist/{runtime.d-3iJAKptR.d.mts → runtime.d-nUz0HAL4.d.mts} +2 -2
  287. package/dist/server-plugins.cjs +3 -2
  288. package/dist/server-plugins.d.mts +6 -12
  289. package/dist/server-plugins.d.ts +6 -12
  290. package/dist/server-plugins.mjs +2 -1
  291. package/dist/server.cjs +64 -56
  292. package/dist/server.d.mts +23 -14
  293. package/dist/server.d.ts +23 -14
  294. package/dist/server.mjs +40 -32
  295. package/dist/{spa-router.d-Dhvy60p4.d.mts → spa-router.d-D4EDwR20.d.mts} +3 -3
  296. package/dist/{spa-router.d-DhOhaQ-7.d.ts → spa-router.d-mC1D5cTN.d.ts} +3 -3
  297. package/dist/testing.cjs +3 -3
  298. package/dist/testing.d.mts +3 -2
  299. package/dist/testing.d.ts +3 -2
  300. package/dist/testing.mjs +3 -3
  301. package/dist/{types.d-C41ePjvP.d.ts → types.d-wVRlLtBf.d.mts} +1 -1
  302. package/dist/{types.d-C41ePjvP.d.mts → types.d-wVRlLtBf.d.ts} +1 -1
  303. package/dist/{utils.d-BVCMRRau.d.ts → utils.d-A2X3a6z_.d.ts} +1 -1
  304. package/dist/{utils.d-Q8EHCpkF.d.mts → utils.d-DxMzteqE.d.mts} +1 -1
  305. package/dist/version.cjs +2 -2
  306. package/dist/version.mjs +1 -1
  307. package/dist/vite.cjs +37 -29
  308. package/dist/vite.d.mts +28 -6
  309. package/dist/vite.d.ts +28 -6
  310. package/dist/vite.mjs +36 -28
  311. package/package.json +3 -3
  312. package/dist/analyzer-SAJSV6SP.cjs +0 -16
  313. package/dist/response.d-BolW0Vx_.d.mts +0 -10
  314. package/dist/response.d-BolW0Vx_.d.ts +0 -10
@@ -2,7 +2,7 @@ import {
2
2
  createFarmReactRefreshPlugins,
3
3
  farmDesktopDevGuardPlugin,
4
4
  isFarmReactRefreshActive
5
- } from "./chunk-QOSDWGKT.mjs";
5
+ } from "./chunk-QVBXTSIZ.mjs";
6
6
  import {
7
7
  createFarmImageHandler
8
8
  } from "./chunk-OEL5EPOJ.mjs";
@@ -24,28 +24,29 @@ import {
24
24
  generateFarmIntegrationProviderClientCode,
25
25
  inferFarmIslandStrategy,
26
26
  isFarmDocsClientConfigModule,
27
+ mergeFarmViteAlias,
27
28
  redactFarmDocsClientConfig,
28
29
  resolveDevGlobalStylesheetHref,
29
30
  resolveFarmAppPackages,
30
31
  resolveFarmClientCacheAdapterEntry,
31
32
  resolveFarmImageProviderForRuntime,
32
33
  resolveFarmRouteRootStrategy
33
- } from "./chunk-IYLZZTP6.mjs";
34
+ } from "./chunk-GUU3IZSM.mjs";
34
35
  import {
35
36
  generateFarmClientPluginEntryCode,
36
37
  hasFarmServerRuntimePlugins,
37
38
  loadTailwindVitePlugin
38
- } from "./chunk-YOHHL2UE.mjs";
39
+ } from "./chunk-I4KPA2C6.mjs";
39
40
  import {
40
41
  FARM_NODE_RESPONSE_END_PENDING
41
- } from "./chunk-PJQ5W356.mjs";
42
+ } from "./chunk-Z5ZZAGIH.mjs";
42
43
  import {
43
44
  resolveFarmPlatform
44
45
  } from "./chunk-SMUW7UST.mjs";
45
46
  import {
46
47
  generateFarmTypeArtifacts,
47
48
  resolveRouteRenderingConfig
48
- } from "./chunk-G7NBPP7H.mjs";
49
+ } from "./chunk-W2T6NDNP.mjs";
49
50
  import {
50
51
  createFarmServerFnBoundaryModule,
51
52
  isFarmServerFnBoundaryId,
@@ -61,7 +62,7 @@ import {
61
62
  parseFarmLayoutChainHeader,
62
63
  renderFarmLocaleAlternateLinks,
63
64
  stripRouteGroups
64
- } from "./chunk-ZPKJPM7K.mjs";
65
+ } from "./chunk-NA77GEIU.mjs";
65
66
  import {
66
67
  FARM_NATIVE_TREE_CONTENT_TYPE
67
68
  } from "./chunk-LLZSYFOM.mjs";
@@ -79,13 +80,13 @@ import {
79
80
  resolveFarmMCPRouteLabel,
80
81
  resolveFarmMarkdownRouteLabel,
81
82
  setFarmRouteLabel
82
- } from "./chunk-ZR2QB45W.mjs";
83
+ } from "./chunk-MITIAOUQ.mjs";
83
84
  import {
84
85
  FARM_DEFAULT_MCP_PATH
85
- } from "./chunk-K6SXMVXO.mjs";
86
+ } from "./chunk-JMFTKNBA.mjs";
86
87
  import {
87
88
  isFarmPreviewDeploymentEnvironment
88
- } from "./chunk-2P7UYHZP.mjs";
89
+ } from "./chunk-V25GSH43.mjs";
89
90
  import {
90
91
  resolveFarmLayoutFonts
91
92
  } from "./chunk-HZOMT5DY.mjs";
@@ -120,7 +121,7 @@ import {
120
121
  rewriteFarmReactServerClientModuleImports,
121
122
  rewriteFarmReactServerImports,
122
123
  stripUseClientDirective
123
- } from "./chunk-ULMXZYOA.mjs";
124
+ } from "./chunk-X7LGLF33.mjs";
124
125
  import {
125
126
  generateFarmDocsAdapterClientRuntime,
126
127
  getFarmDocsAdapterConfigModule
@@ -134,7 +135,7 @@ import {
134
135
  } from "./chunk-TPA2PV5J.mjs";
135
136
  import {
136
137
  resolveRouteRuleCorsPreflightHeaders
137
- } from "./chunk-R2ZHU37O.mjs";
138
+ } from "./chunk-NLRAQXAA.mjs";
138
139
  import {
139
140
  FARM_DEVTOOLS_LAUNCH_PARAM,
140
141
  FARM_DEVTOOLS_PATH,
@@ -144,10 +145,10 @@ import {
144
145
  FARM_PREVIEW_ROBOTS_TAG,
145
146
  resolveFarmAgentCrawlers,
146
147
  resolveFarmAgentSitemap
147
- } from "./chunk-OGVTUGMU.mjs";
148
+ } from "./chunk-REP6HWJN.mjs";
148
149
  import {
149
150
  resolveFarmLlmsTxtConfig
150
- } from "./chunk-YGJ5P3TJ.mjs";
151
+ } from "./chunk-Z3GPAFIA.mjs";
151
152
  import {
152
153
  resolveFarmServerComponentsMode
153
154
  } from "./chunk-4QENVMG7.mjs";
@@ -177,7 +178,7 @@ import {
177
178
  createFarmMarkdownSourceResponse,
178
179
  isFarmMarkdownPageFile,
179
180
  normalizeFarmMarkdownRoutePath
180
- } from "./chunk-HEJM46HQ.mjs";
181
+ } from "./chunk-J5ASGNKF.mjs";
181
182
  import {
182
183
  FARM_MARKDOWN_CONTENT_TYPE,
183
184
  createFarmMarkdownErrorBody,
@@ -185,21 +186,21 @@ import {
185
186
  farmRequestWantsMarkdown,
186
187
  getFarmMarkdownAlternatePath,
187
188
  resolveMarkdownMirrorTarget
188
- } from "./chunk-IFR74W6S.mjs";
189
+ } from "./chunk-KPJYBSHL.mjs";
189
190
  import {
190
191
  dispatchIntegrationRequest,
191
192
  getFarmIntegrationPluginOwner,
192
193
  getIntegrationDocumentNavigationMatchers,
193
194
  getIntegrationProviders,
194
195
  matchIntegrationRoute
195
- } from "./chunk-AJNBTOVQ.mjs";
196
+ } from "./chunk-WW3LRNQV.mjs";
196
197
  import {
197
198
  resolveFarmRouteContext,
198
199
  withFarmRouteContext
199
200
  } from "./chunk-BMQAPZXD.mjs";
200
201
  import {
201
202
  MiddlewareManager
202
- } from "./chunk-WMLSZAKN.mjs";
203
+ } from "./chunk-JZQS3ZOI.mjs";
203
204
  import {
204
205
  _runWithMiddlewareContext,
205
206
  _runWithMiddlewareData
@@ -215,10 +216,10 @@ import {
215
216
  } from "./chunk-IYEY3JWJ.mjs";
216
217
  import {
217
218
  APIRouteManager
218
- } from "./chunk-OIOPQ25L.mjs";
219
+ } from "./chunk-E77IA5IF.mjs";
219
220
  import {
220
221
  getFarmI18nClientSnapshot
221
- } from "./chunk-CV6MFQ4Y.mjs";
222
+ } from "./chunk-3AUINHFG.mjs";
222
223
  import {
223
224
  VERCEL_OG_INSTALL_HINT,
224
225
  isOptionalPeerInstalled
@@ -243,7 +244,7 @@ import {
243
244
  applyWebResponseHeaders,
244
245
  fetchFarmExternalRewrite,
245
246
  sendWebResponse
246
- } from "./chunk-CO6UYM2D.mjs";
247
+ } from "./chunk-O5QUJEWT.mjs";
247
248
  import {
248
249
  invalidateFailedFarmDevModules,
249
250
  invalidateFarmDevDependents,
@@ -278,7 +279,10 @@ import {
278
279
  } from "./chunk-2DA7CLY7.mjs";
279
280
  import {
280
281
  FARM_VERSION
281
- } from "./chunk-ANMIR6US.mjs";
282
+ } from "./chunk-RJUCNO7R.mjs";
283
+ import {
284
+ toFarmTrailingSlashPageRequest
285
+ } from "./chunk-4O26BPUY.mjs";
282
286
  import {
283
287
  DEFAULT_FARM_API_BASE_PATH
284
288
  } from "./chunk-W6QLRQ3V.mjs";
@@ -291,21 +295,21 @@ import {
291
295
  mergeMetadata,
292
296
  mergeModuleViewport
293
297
  } from "./chunk-S6O2L47H.mjs";
298
+ import {
299
+ createDeferredDataResponse
300
+ } from "./chunk-7BIW7VCW.mjs";
294
301
  import {
295
302
  FARM_DEPLOYMENT_ID_HEADER,
296
303
  createFarmDeploymentMismatchResponse,
297
304
  getFarmDeploymentMismatch,
298
305
  withFarmDeploymentResponse
299
- } from "./chunk-NVOMQLI2.mjs";
300
- import {
301
- createDeferredDataResponse
302
- } from "./chunk-7BIW7VCW.mjs";
306
+ } from "./chunk-IWJONXPF.mjs";
303
307
  import {
304
308
  FARM_CONFIG_HEADERS_PLUGIN_NAME,
305
309
  FARM_CONFIG_REDIRECTS_PLUGIN_NAME,
306
310
  FARM_CONFIG_REWRITES_PLUGIN_NAME,
307
311
  getConfigRedirectMatcher
308
- } from "./chunk-PLJKJJ2H.mjs";
312
+ } from "./chunk-FETMUBIA.mjs";
309
313
  import {
310
314
  parseFarmRequestTarget,
311
315
  resolveFarmRequestURL
@@ -326,6 +330,7 @@ import { createHash } from "crypto";
326
330
  import { transformActions } from "@farm.js/islx/compiler";
327
331
  import path from "path";
328
332
  function transformFarmFormActionModule(options) {
333
+ const runtimeModule = options.runtimeModule ?? ((specifier) => specifier);
329
334
  const result = transformActions({
330
335
  code: options.code,
331
336
  id: options.id,
@@ -333,8 +338,8 @@ function transformFarmFormActionModule(options) {
333
338
  environment: options.ssr ? "server" : "client",
334
339
  parse: options.parse,
335
340
  runtime: {
336
- server: "@farm.js/core/internal/islx-server",
337
- client: "@farm.js/core/internal/islx-client"
341
+ server: runtimeModule("@farm.js/core/internal/islx-server"),
342
+ client: runtimeModule("@farm.js/core/internal/islx-client")
338
343
  }
339
344
  });
340
345
  return result ? result.code : null;
@@ -500,7 +505,7 @@ function createFarmDevViteCorsMiddleware() {
500
505
  // src/vite.ts
501
506
  import * as fs2 from "fs";
502
507
  import * as path6 from "path";
503
- import { pathToFileURL } from "url";
508
+ import { fileURLToPath, pathToFileURL } from "url";
504
509
 
505
510
  // src/dev-static.ts
506
511
  import * as fs from "fs";
@@ -890,7 +895,7 @@ var REACT_CACHE_APIS = {
890
895
  cache: REACT_CACHE_LOCAL,
891
896
  cacheSignal: "__farm_react_cache_signal__"
892
897
  };
893
- function rewriteFarmReactCacheImport(code, file) {
898
+ function rewriteFarmReactCacheImport(code, file, cacheModule = FARM_REACT_CACHE_MODULE) {
894
899
  if (!code.includes("cache") || !code.includes("react")) return null;
895
900
  const extension = path5.extname(file).slice(1);
896
901
  const lang = extension === "ts" || extension === "mts" || extension === "cts" ? "ts" : "tsx";
@@ -931,7 +936,7 @@ function rewriteFarmReactCacheImport(code, file) {
931
936
  ].join(", ");
932
937
  const lines = [
933
938
  ...clause ? [`import ${clause} from "react";`] : [],
934
- `import { ${caches.map((specifier) => `${specifier.imported?.name ?? specifier.imported?.value} as ${specifier.local.name}`).join(", ")} } from ${JSON.stringify(FARM_REACT_CACHE_MODULE)};`
939
+ `import { ${caches.map((specifier) => `${specifier.imported?.name ?? specifier.imported?.value} as ${specifier.local.name}`).join(", ")} } from ${JSON.stringify(cacheModule)};`
935
940
  ];
936
941
  edits.push({ start: node.start, end: node.end, text: lines.join("\n") });
937
942
  }
@@ -963,7 +968,7 @@ function rewriteFarmReactCacheImport(code, file) {
963
968
  start: memberImportAt,
964
969
  end: memberImportAt,
965
970
  text: `
966
- import { ${[...used].map((name) => `${name} as ${REACT_CACHE_APIS[name]}`).join(", ")} } from ${JSON.stringify(FARM_REACT_CACHE_MODULE)};`
971
+ import { ${[...used].map((name) => `${name} as ${REACT_CACHE_APIS[name]}`).join(", ")} } from ${JSON.stringify(cacheModule)};`
967
972
  });
968
973
  }
969
974
  }
@@ -1068,7 +1073,7 @@ function loadFarmWorkflowsDevRuntime() {
1068
1073
  return import("./workflows.mjs");
1069
1074
  }
1070
1075
  function loadFarmDevtoolsSnapshotRuntime() {
1071
- return import("./devtools-BP4EBTKQ.mjs");
1076
+ return import("./devtools-6MXPFPNJ.mjs");
1072
1077
  }
1073
1078
  function loadFarmDevtoolsUIRuntime() {
1074
1079
  return import("./devtools-ui-CYBVFLPH.mjs");
@@ -1329,7 +1334,7 @@ async function proxyFarmExternalRewrite(req, res, bodySizeLimit) {
1329
1334
  let request = createRequestFromNodeRequest(req, new URL(destination));
1330
1335
  if (request.method !== "GET" && request.method !== "HEAD") {
1331
1336
  const body = await readNodeRequestBody(req, bodySizeLimit);
1332
- request = new Request(request, { body: toRequestBody(body) });
1337
+ request = new Request(request, { method: request.method, body: toRequestBody(body) });
1333
1338
  }
1334
1339
  await sendWebResponse(res, await fetchFarmExternalRewrite(request));
1335
1340
  return true;
@@ -1795,13 +1800,18 @@ function rewriteEarlySsrRelativeImports(options) {
1795
1800
  return output + options.code.slice(copied);
1796
1801
  }
1797
1802
  function transformIsolatedClientBoundaryModule(options) {
1803
+ const runtimeModule = options.runtimeModule ?? ((specifier) => specifier);
1804
+ const islxReact = JSON.stringify(runtimeModule("@farm.js/core/internal/islx-react"));
1805
+ const isolatedBoundary = JSON.stringify(
1806
+ runtimeModule("@farm.js/core/internal/isolated-boundary")
1807
+ );
1798
1808
  if (options.slots) {
1799
1809
  try {
1800
1810
  const rewritten = rewriteFormStatusImports({
1801
1811
  code: options.code,
1802
1812
  id: options.moduleReference,
1803
1813
  parse: options.parse,
1804
- from: "@farm.js/core/internal/islx-react"
1814
+ from: runtimeModule("@farm.js/core/internal/islx-react")
1805
1815
  });
1806
1816
  if (rewritten) options = { ...options, code: rewritten.code };
1807
1817
  } catch {
@@ -1913,10 +1923,10 @@ function transformIsolatedClientBoundaryModule(options) {
1913
1923
  output = output.slice(0, replacement.start) + replacement.code + output.slice(replacement.end);
1914
1924
  }
1915
1925
  const isComponent = `(value) => typeof value === "function" || (typeof value === "object" && value !== null && [Symbol.for("react.memo"), Symbol.for("react.forward_ref"), Symbol.for("react.lazy")].includes(value.$$typeof))`;
1916
- const runtimeImport = options.slots ? options.browser ? "const __farm_islx_island__ = (component) => component;" : `import { createIsland as __farm_islx_create_island__ } from "@farm.js/core/internal/islx-react";
1926
+ const runtimeImport = options.slots ? options.browser ? "const __farm_islx_island__ = (component) => component;" : `import { createIsland as __farm_islx_create_island__ } from ${islxReact};
1917
1927
  const __farm_is_component__ = ${isComponent};
1918
1928
  const __farm_islx_island__ = (component, ...rest) => __farm_is_component__(component) ? __farm_islx_create_island__(component, ...rest) : component;` : `import * as __farm_isolated_react__ from "react";
1919
- import { createFarmIsolatedClientBoundary as __farm_create_boundary__ } from "@farm.js/core/internal/isolated-boundary";
1929
+ import { createFarmIsolatedClientBoundary as __farm_create_boundary__ } from ${isolatedBoundary};
1920
1930
  const __farm_is_component__ = ${isComponent};
1921
1931
  const __farm_create_isolated_boundary__ = (react, component, ...rest) => __farm_is_component__(component) ? __farm_create_boundary__(react, component, ...rest) : component;`;
1922
1932
  return `${runtimeImport}
@@ -1972,11 +1982,32 @@ function warnClientBoundaryOnce(context, id, code, config) {
1972
1982
  function shouldEmitFarmClientRootHmr(renderer) {
1973
1983
  return getFarmRendererCapabilities(resolveFarmRenderer(renderer)).reconcilesRerenders;
1974
1984
  }
1975
- function hasViteAlias(alias, find) {
1985
+ var FARM_RUNTIME_MODULE_PREFIX = "/@farm/runtime/";
1986
+ function toFarmRuntimeModuleId(specifier) {
1987
+ return FARM_RUNTIME_MODULE_PREFIX + specifier;
1988
+ }
1989
+ function getFarmCoreFile() {
1990
+ return typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
1991
+ }
1992
+ var FARM_SOURCE_ALIAS_PROBES = [
1993
+ "@/x",
1994
+ "@/index.ts",
1995
+ "@/components/button",
1996
+ "@/lib/utils/format.ts",
1997
+ "@/__farm__/probe"
1998
+ ];
1999
+ function matchesViteAlias(find, specifier) {
2000
+ if (typeof find === "string") return specifier === find || specifier.startsWith(`${find}/`);
2001
+ find.lastIndex = 0;
2002
+ const matched = find.test(specifier);
2003
+ find.lastIndex = 0;
2004
+ return matched;
2005
+ }
2006
+ function hasFarmSourceAliasOverride(alias) {
1976
2007
  if (!alias) return false;
1977
- if (!Array.isArray(alias)) return Object.prototype.hasOwnProperty.call(alias, find);
1978
- return alias.some(
1979
- (entry) => typeof entry.find === "string" ? entry.find === find : entry.find.test(`${find}/`)
2008
+ const finds = Array.isArray(alias) ? alias.map((entry) => entry.find) : Object.keys(alias);
2009
+ return finds.some(
2010
+ (find) => FARM_SOURCE_ALIAS_PROBES.every((probe) => matchesViteAlias(find, probe))
1980
2011
  );
1981
2012
  }
1982
2013
  function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
@@ -2021,13 +2052,25 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
2021
2052
  console.log(log);
2022
2053
  };
2023
2054
  const getProgrammaticClientRoutes = () => options.programmaticClientRoutes ?? farmApp?.getRouteManager().getProgrammaticClientRoutes();
2055
+ const isOutsideAppRoot = (file) => {
2056
+ const root = farmApp?.getConfig().root || server?.config.root || options.root;
2057
+ if (!root) return false;
2058
+ const relative4 = path6.relative(root, file.split("?", 1)[0]);
2059
+ return relative4.startsWith("..") || path6.isAbsolute(relative4);
2060
+ };
2024
2061
  const plugin = {
2025
2062
  name: "farm",
2026
2063
  api: { getProgrammaticClientRoutes },
2027
2064
  config(userConfig, configEnv) {
2028
2065
  isBuild = configEnv.command === "build";
2029
- const layerAliases = getFarmLayerAliases(options.layers);
2030
- const sourceAlias = hasViteAlias(userConfig.resolve?.alias, "@") ? {} : createFarmSourceAlias(options.root || process.cwd(), options.srcDir);
2066
+ const farmAliases = {
2067
+ ...getFarmLayerAliases(options.layers),
2068
+ ...hasFarmSourceAliasOverride(userConfig.resolve?.alias) ? {} : createFarmSourceAlias(options.root || process.cwd(), options.srcDir)
2069
+ };
2070
+ if (Object.keys(farmAliases).length > 0) {
2071
+ userConfig.resolve ?? (userConfig.resolve = {});
2072
+ userConfig.resolve.alias = mergeFarmViteAlias(farmAliases, userConfig.resolve.alias);
2073
+ }
2031
2074
  const layerRoots = (options.layers ?? []).map((layer) => layer.root);
2032
2075
  farmOwnsDevCors = !isBuild && userConfig.server?.cors === void 0;
2033
2076
  return {
@@ -2038,9 +2081,6 @@ function farmPlugin(options = {}, initialPluginManager, deferredSetup) {
2038
2081
  // Keep development module ownership explicit; the RSC plugin adds its
2039
2082
  // environment only when enabled. Production environment setup is unchanged.
2040
2083
  ...!isBuild ? { environments: { client: {}, ssr: {} } } : {},
2041
- resolve: {
2042
- alias: { ...layerAliases, ...sourceAlias }
2043
- },
2044
2084
  server: {
2045
2085
  ...farmOwnsDevCors ? { cors: false } : {},
2046
2086
  fs: {
@@ -2809,15 +2849,65 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2809
2849
  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]));
2810
2850
  const configRewriteSource = req[FARM_DEV_CONFIG_REWRITE_SOURCE];
2811
2851
  const runtimeHookErrorAnswersJSON = rendererDisabled || isFarmAPIPathname(requestPathname, apiServerBasePath);
2812
- if (pm && configRewriteSource === void 0 && !deferredDottedRequests.has(req) && (configRoutePlugins.has(FARM_CONFIG_HEADERS_PLUGIN_NAME) || configRedirectMatchers.length > 0) && !isViteOwnedRequest()) {
2813
- let redirect = null;
2852
+ const requestedPagePathname = configRewriteSource === void 0 ? requestPathname : new URL(configRewriteSource).pathname;
2853
+ let pageHookRouteMatch;
2854
+ const pageHookRoute = () => {
2855
+ if (pageHookRouteMatch) return pageHookRouteMatch;
2856
+ const pathname2 = requestedPagePathname;
2857
+ const match = farmApp.getRouteManager().matchRoute(pathname2);
2858
+ pageHookRouteMatch = {
2859
+ render: {
2860
+ pathname: pathname2,
2861
+ method: requestMethod,
2862
+ routePattern: match?.route?.pattern || null,
2863
+ params: match?.params || {}
2864
+ },
2865
+ layoutPatterns: (match?.layouts || []).map((layout) => layout.pattern)
2866
+ };
2867
+ return pageHookRouteMatch;
2868
+ };
2869
+ const matchAppMetadataRoute = (pathname2) => {
2870
+ const routeManager3 = farmApp.getRouteManager();
2871
+ const image = routeManager3.matchMetadataImage(pathname2);
2872
+ if (image) return { pattern: image.image.pattern, params: image.params };
2873
+ const metadata = routeManager3.matchMetadataRoute(pathname2);
2874
+ return metadata ? { pattern: metadata.metadata.pattern, params: metadata.params } : null;
2875
+ };
2876
+ const runFarmDevPageHooks = async () => {
2877
+ if (!pm || !pm.hasHook("beforeRouteMatch") && !pm.hasHook("afterRouteMatch") && !pm.hasHook("beforeRender")) {
2878
+ return;
2879
+ }
2880
+ const { render, layoutPatterns } = pageHookRoute();
2881
+ if (matchAppMetadataRoute(render.pathname) || // A path no page route matches is a page only for a GET or HEAD request.
2882
+ !render.routePattern && requestMethod !== "GET" && requestMethod !== "HEAD") {
2883
+ return;
2884
+ }
2885
+ await pm.runHookParallel("beforeRouteMatch", {
2886
+ pathname: render.pathname,
2887
+ method: requestMethod
2888
+ });
2889
+ await pm.runHookParallel("afterRouteMatch", {
2890
+ pathname: render.pathname,
2891
+ matched: Boolean(render.routePattern),
2892
+ routePattern: render.routePattern,
2893
+ params: render.params,
2894
+ layoutPatterns
2895
+ });
2896
+ await pm.runHookParallel("beforeRender", render);
2897
+ };
2898
+ const meetsRequestedURLRoutes = configRewriteSource === void 0 && !deferredDottedRequests.has(req);
2899
+ const routeRedirect = meetsRequestedURLRoutes ? farmApp.getRouteManager().matchRedirect(requestPathname, parsedRequestUrl.search) : null;
2900
+ if (meetsRequestedURLRoutes && (routeRedirect || pm && (configRoutePlugins.has(FARM_CONFIG_HEADERS_PLUGIN_NAME) || configRedirectMatchers.length > 0)) && !isViteOwnedRequest()) {
2901
+ let redirect = routeRedirect;
2814
2902
  try {
2815
- await pm.runHookParallelFiltered(
2816
- "beforeRequest",
2817
- (plugin2) => plugin2.name === FARM_CONFIG_HEADERS_PLUGIN_NAME,
2818
- req,
2819
- res
2820
- );
2903
+ if (pm) {
2904
+ await pm.runHookParallelFiltered(
2905
+ "beforeRequest",
2906
+ (plugin2) => plugin2.name === FARM_CONFIG_HEADERS_PLUGIN_NAME,
2907
+ req,
2908
+ res
2909
+ );
2910
+ }
2821
2911
  for (const matchRedirect of configRedirectMatchers) {
2822
2912
  redirect ?? (redirect = matchRedirect(parsedRequestUrl));
2823
2913
  }
@@ -2835,16 +2925,18 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2835
2925
  status: redirect.statusCode,
2836
2926
  headers: { Location: redirect.destination }
2837
2927
  });
2838
- if (opensFarmDevRuntimeSession(pm)) {
2928
+ if (pm && opensFarmDevRuntimeSession(pm)) {
2839
2929
  const redirectResponse = response;
2840
2930
  try {
2931
+ const metadataRoute = matchAppMetadataRoute(requestPathname);
2932
+ const kind = metadataRoute ? "asset" : isFarmAPIPathname(requestPathname, apiServerBasePath) ? "api" : requestMethod === "GET" || requestMethod === "HEAD" ? "page" : "request";
2841
2933
  response = await pm.runRuntimeRequest(
2842
2934
  createRequestFromNodeRequest(req, parsedRequestUrl),
2843
- () => redirectResponse,
2844
- {
2845
- kind: isFarmAPIPathname(requestPathname, apiServerBasePath) ? "api" : requestMethod === "GET" || requestMethod === "HEAD" ? "page" : "request",
2846
- route: { pathname: requestPathname }
2847
- }
2935
+ async () => {
2936
+ if (kind === "page") await runFarmDevPageHooks();
2937
+ return redirectResponse;
2938
+ },
2939
+ { kind, route: { pathname: requestPathname, ...metadataRoute } }
2848
2940
  );
2849
2941
  } catch {
2850
2942
  sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
@@ -2977,6 +3069,16 @@ window.__FARM_MANIFEST__ = ${inlineValue({
2977
3069
  }
2978
3070
  pm.copyRequestContext(runtimeSession2.request, req);
2979
3071
  applyWebRequestToNodeRequest(runtimeSession2.request, req);
3072
+ if (kind === "page") {
3073
+ try {
3074
+ await runFarmDevPageHooks();
3075
+ } catch (error) {
3076
+ await discard();
3077
+ await pm.failRuntimeRequest(runtimeSession2, error);
3078
+ sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
3079
+ return;
3080
+ }
3081
+ }
2980
3082
  }
2981
3083
  let response;
2982
3084
  let responding = false;
@@ -3125,8 +3227,28 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3125
3227
  const docsBodyInit = requestMethod === "GET" || requestMethod === "HEAD" ? {} : { body: createFarmNodeRequestBodyStream(req), duplex: "half" };
3126
3228
  const docsResponse = await farmDocsHandler(new Request(docsRequest, docsBodyInit));
3127
3229
  if (docsResponse) {
3230
+ const docsPage = docsResponse.headers.get("content-type")?.toLowerCase().includes("text/html");
3128
3231
  await serveBuiltInRoute(
3129
- () => wrapFarmDocsResponseWithLayouts(docsRequest, docsResponse),
3232
+ async (request) => {
3233
+ if (!docsPage) return wrapFarmDocsResponseWithLayouts(docsRequest, docsResponse);
3234
+ const deploymentMismatch = getFarmDeploymentMismatch(
3235
+ request,
3236
+ farmConfig.deploymentId
3237
+ );
3238
+ if (deploymentMismatch) {
3239
+ await docsResponse.body?.cancel();
3240
+ return createFarmDeploymentMismatchResponse(deploymentMismatch);
3241
+ }
3242
+ return withFarmDeploymentResponse(
3243
+ await wrapFarmDocsResponseWithLayouts(docsRequest, docsResponse),
3244
+ farmConfig.deploymentId,
3245
+ {
3246
+ setCookie: request.method.toUpperCase() === "GET",
3247
+ cookiePath: farmConfig.basePath || "/",
3248
+ secureCookie: new URL(request.url).protocol === "https:"
3249
+ }
3250
+ );
3251
+ },
3130
3252
  {
3131
3253
  kind: "docs",
3132
3254
  computed: docsResponse,
@@ -3144,7 +3266,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3144
3266
  }
3145
3267
  }
3146
3268
  if (options.mobileClient && !viteModuleRequest && (requestMethod === "GET" || requestMethod === "HEAD" || requestMethod === "POST") && req.headers.accept?.includes(FARM_NATIVE_TREE_CONTENT_TYPE)) {
3147
- const { createFarmNativeTreeResponse } = await import("./native-tree-Y5YQANW7.mjs");
3269
+ const { createFarmNativeTreeResponse } = await import("./native-tree-L2IIEBXH.mjs");
3148
3270
  const treeBodyInit = requestMethod === "POST" ? { body: createFarmNodeRequestBodyStream(req), duplex: "half" } : {};
3149
3271
  const treeResponse = await createFarmNativeTreeResponse({
3150
3272
  request: new Request(fullUrl, {
@@ -3192,11 +3314,18 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3192
3314
  },
3193
3315
  // The anonymous check goes through this server, so its guards and
3194
3316
  // middleware see the page's own path, as in production. It connects to
3195
- // this server's own listener, never the host the caller's Host names.
3317
+ // this server's own listener, never the host the caller's Host names. The
3318
+ // page is asked for at the URL it answers at, not through the trailing-slash 308.
3196
3319
  renderPage: async (request) => createFarmDevServerDispatch(server)(
3197
- new Request(request, {
3198
- signal: res.destroyed ? AbortSignal.abort() : createFarmNodeRequestAbortSignal(req, res)
3199
- })
3320
+ new Request(
3321
+ toFarmTrailingSlashPageRequest(
3322
+ request,
3323
+ farmApp.getConfig().trailingSlash === true
3324
+ ),
3325
+ {
3326
+ signal: res.destroyed ? AbortSignal.abort() : createFarmNodeRequestAbortSignal(req, res)
3327
+ }
3328
+ )
3200
3329
  )
3201
3330
  });
3202
3331
  if (markdownSourceResponse) {
@@ -3216,17 +3345,24 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3216
3345
  routeExists: (pathname2) => Boolean(farmApp.getRouteManager().matchRoute(pathname2).route),
3217
3346
  // The page is rendered by this server's own listener, never the host the
3218
3347
  // caller's Host names. Redirects are not followed, so the mirror answers with
3219
- // the page's own (a sign-in gate, say), as production does.
3348
+ // the page's own (a sign-in gate, say), as production does. The page is read
3349
+ // at the URL it answers at ('/about/' with trailingSlash), not through the 308.
3220
3350
  renderPage: async (request) => {
3221
3351
  const headers = new Headers(request.headers);
3222
3352
  headers.delete("accept-encoding");
3223
3353
  return createFarmDevServerDispatch(server)(
3224
- new Request(request, {
3225
- headers,
3226
- // Only accepted mirrors need disconnect listeners. An earlier
3227
- // close (for example while the docs handler ran) must also abort.
3228
- signal: res.destroyed ? AbortSignal.abort() : createFarmNodeRequestAbortSignal(req, res)
3229
- })
3354
+ new Request(
3355
+ toFarmTrailingSlashPageRequest(
3356
+ request,
3357
+ farmApp.getConfig().trailingSlash === true
3358
+ ),
3359
+ {
3360
+ headers,
3361
+ // Only accepted mirrors need disconnect listeners. An earlier
3362
+ // close (for example while the docs handler ran) must also abort.
3363
+ signal: res.destroyed ? AbortSignal.abort() : createFarmNodeRequestAbortSignal(req, res)
3364
+ }
3365
+ )
3230
3366
  );
3231
3367
  },
3232
3368
  apiServerBasePath
@@ -3404,7 +3540,10 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3404
3540
  });
3405
3541
  }
3406
3542
  logger.error(`Integration route error: ${error}`);
3407
- if (!res.writableEnded) {
3543
+ if (runtimeReportsErrors) {
3544
+ if (!res.headersSent) sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
3545
+ else if (!res.writableEnded) res.end();
3546
+ } else if (!res.writableEnded) {
3408
3547
  res.statusCode = 500;
3409
3548
  res.setHeader("Content-Type", "application/json");
3410
3549
  res.end(FARM_INTERNAL_SERVER_ERROR_BODY);
@@ -3451,13 +3590,6 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3451
3590
  if (await tryConfiguredIntegrationRoute()) {
3452
3591
  return;
3453
3592
  }
3454
- const redirectMatch = farmApp.getRouteManager().matchRedirect(requestPathname, parsedRequestUrl.search);
3455
- if (redirectMatch) {
3456
- res.statusCode = redirectMatch.statusCode;
3457
- res.setHeader("Location", redirectMatch.destination);
3458
- res.end(`Redirecting to ${redirectMatch.destination}`);
3459
- return;
3460
- }
3461
3593
  const matchedApiRoute = apiRouteManager.matchRoute(requestPathname);
3462
3594
  const hasMatchedApiRoute = Boolean(matchedApiRoute);
3463
3595
  if (hasMatchedApiRoute || isFarmAPIPathname(requestPathname, apiServerBasePath)) {
@@ -3613,6 +3745,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3613
3745
  route: apiRoutePattern,
3614
3746
  method: method2
3615
3747
  });
3748
+ let apiOutcomeReported = false;
3616
3749
  try {
3617
3750
  const url = `http://${req.headers.host || "localhost:3000"}${req.url}`;
3618
3751
  const request = await createHandlerRequest();
@@ -3621,7 +3754,6 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3621
3754
  method: method2,
3622
3755
  routePath: apiRoutePattern
3623
3756
  };
3624
- let apiHandlerFailed = false;
3625
3757
  const invokeAPIHandler = async (runtimeRequest, runtime) => {
3626
3758
  const handledRequest = pm ? await pm.runHookSerial(
3627
3759
  "beforeApiHandler",
@@ -3631,8 +3763,17 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3631
3763
  let response;
3632
3764
  try {
3633
3765
  response = await apiHandler(handledRequest);
3766
+ apiOutcomeReported = true;
3767
+ emitFarmEvent({
3768
+ type: "api.request.complete",
3769
+ pathname: pathname2,
3770
+ route: apiRoutePattern,
3771
+ method: method2,
3772
+ status: response.status,
3773
+ durationMs: Date.now() - startTime2
3774
+ });
3634
3775
  } catch (error) {
3635
- apiHandlerFailed = true;
3776
+ apiOutcomeReported = true;
3636
3777
  emitFarmEvent({
3637
3778
  type: "api.error",
3638
3779
  pathname: pathname2,
@@ -3655,29 +3796,21 @@ window.__FARM_MANIFEST__ = ${inlineValue({
3655
3796
  }
3656
3797
  });
3657
3798
  const duration = Date.now() - startTime2;
3658
- if (!apiHandlerFailed) {
3799
+ logResponse(method2, urlPath2, handledResponse.status, duration, "API");
3800
+ await sendWebResponse(res, handledResponse);
3801
+ return;
3802
+ } catch (error) {
3803
+ const duration = Date.now() - startTime2;
3804
+ if (!apiOutcomeReported) {
3659
3805
  emitFarmEvent({
3660
- type: "api.request.complete",
3806
+ type: "api.error",
3661
3807
  pathname: pathname2,
3662
3808
  route: apiRoutePattern,
3663
3809
  method: method2,
3664
- status: handledResponse.status,
3665
- durationMs: duration
3810
+ durationMs: duration,
3811
+ error
3666
3812
  });
3667
3813
  }
3668
- logResponse(method2, urlPath2, handledResponse.status, duration, "API");
3669
- await sendWebResponse(res, handledResponse);
3670
- return;
3671
- } catch (error) {
3672
- const duration = Date.now() - startTime2;
3673
- emitFarmEvent({
3674
- type: "api.error",
3675
- pathname: pathname2,
3676
- route: apiRoutePattern,
3677
- method: method2,
3678
- durationMs: duration,
3679
- error
3680
- });
3681
3814
  const bodyErrorResponse = createFarmRequestBodyErrorResponse(error);
3682
3815
  if (bodyErrorResponse) {
3683
3816
  logResponse(method2, urlPath2, bodyErrorResponse.status, duration, "API");
@@ -4122,15 +4255,11 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4122
4255
  trustProxy: currentServerConfig.trustProxy
4123
4256
  }).pathname;
4124
4257
  const routeManager2 = farmApp.getRouteManager();
4125
- const hasBeforeRouteMatchHook = pm?.hasHook("beforeRouteMatch") ?? false;
4126
- const hasAfterRouteMatchHook = pm?.hasHook("afterRouteMatch") ?? false;
4127
4258
  const hasBeforeRequestHook = pm?.hasHook("beforeRequest") ?? false;
4128
- const hasBeforeRenderHook = pm?.hasHook("beforeRender") ?? false;
4129
4259
  const hasAfterResponseHook = pm?.hasHook("afterResponse") ?? false;
4130
4260
  const hasHTMLTransformHook = (pm?.hasHook("transformHTML") ?? false) || (pm?.hasHook("afterRender") ?? false);
4131
4261
  const opensRuntimeSession = pm ? opensFarmDevRuntimeSession(pm) : false;
4132
4262
  const hasRuntimeAfterHook = pm?.hasRuntimeHook("after") ?? false;
4133
- const requestedMatch = routeManager2.matchRoute(requestedPathname);
4134
4263
  const pageBuiltInRouteLabel = (pathname2) => {
4135
4264
  const routePathname = stripFarmBasePath(pathname2, farmConfig.basePath);
4136
4265
  const mcpLabel = resolveFarmMCPRouteLabel(routePathname, apiServerBasePath);
@@ -4138,29 +4267,37 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4138
4267
  if (farmAgentGeneratedPaths(farmConfig).includes(routePathname)) return routePathname;
4139
4268
  return routePathname === FARM_DEFAULT_MCP_PATH && farmApp.getServerRenderer().getDefaultMCPServer() ? FARM_DEFAULT_MCP_PATH : null;
4140
4269
  };
4270
+ const pageRuntimeOptions = (pathname2) => {
4271
+ const match = routeManager2.matchRoute(pathname2);
4272
+ return {
4273
+ kind: "page",
4274
+ route: setFarmRouteLabel(
4275
+ {
4276
+ pathname: pathname2,
4277
+ pattern: match?.route?.pattern || null,
4278
+ params: match?.params || {}
4279
+ },
4280
+ match?.route ? null : pageBuiltInRouteLabel(pathname2)
4281
+ )
4282
+ };
4283
+ };
4141
4284
  let runtimeSession;
4142
4285
  let pathname = requestedPathname;
4143
4286
  if (pm && opensRuntimeSession) {
4144
4287
  try {
4145
- const sessionOptions = {
4146
- kind: "page",
4147
- route: setFarmRouteLabel(
4148
- {
4149
- pathname: requestedPathname,
4150
- pattern: requestedMatch?.route?.pattern || null,
4151
- params: requestedMatch?.params || {}
4152
- },
4153
- requestedMatch?.route ? null : pageBuiltInRouteLabel(requestedPathname)
4154
- )
4155
- };
4288
+ const metadataRoute = configRewriteSource === void 0 ? matchAppMetadataRoute(requestedPathname) : null;
4289
+ const sessionOptions = metadataRoute ? { kind: "asset", route: { pathname: requestedPathname, ...metadataRoute } } : pageRuntimeOptions(
4290
+ configRewriteSource === void 0 ? requestedPathname : requestedPagePathname
4291
+ );
4156
4292
  runtimeSession = await pm.beginRuntimeRequest(
4157
4293
  createRequestFromNodeRequest(req, new URL(configRewriteSource ?? fullUrl)),
4158
4294
  sessionOptions
4159
4295
  );
4296
+ if (!runtimeSession.response) await runFarmDevPageHooks();
4160
4297
  const routedRequest = runtimeSession.response ?? (configRewriteSource === void 0 ? runtimeSession.request : await pm.runRuntimeBeforeForRewrite(
4161
4298
  runtimeSession.request,
4162
4299
  createRequestFromNodeRequest(req, new URL(fullUrl)),
4163
- sessionOptions
4300
+ pageRuntimeOptions(requestedPathname)
4164
4301
  ));
4165
4302
  if (routedRequest instanceof Response) {
4166
4303
  const response = await pm.endRuntimeRequest(runtimeSession, routedRequest);
@@ -4176,9 +4313,7 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4176
4313
  return;
4177
4314
  }
4178
4315
  }
4179
- const routeMatch = pathname === requestedPathname ? requestedMatch : routeManager2.matchRoute(pathname);
4180
- const failPageHook = async (error, interceptor) => {
4181
- interceptor?.release();
4316
+ const failPageHook = async (error) => {
4182
4317
  logResponse(method, urlPath, 500, Date.now() - startTime, "PAGE");
4183
4318
  if (runtimeSession) {
4184
4319
  await pm.failRuntimeRequest(runtimeSession, error);
@@ -4191,32 +4326,14 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4191
4326
  }
4192
4327
  if (!res.headersSent) sendFarmDevRuntimeHookError(res, runtimeHookErrorAnswersJSON);
4193
4328
  };
4194
- try {
4195
- if (pm && hasBeforeRouteMatchHook) {
4196
- await pm.runHookParallel("beforeRouteMatch", {
4197
- pathname,
4198
- method
4199
- });
4200
- }
4201
- if (pm && hasAfterRouteMatchHook) {
4202
- await pm.runHookParallel("afterRouteMatch", {
4203
- pathname,
4204
- matched: !!routeMatch?.route,
4205
- routePattern: routeMatch?.route?.pattern || null,
4206
- params: routeMatch?.params || {},
4207
- layoutPatterns: (routeMatch?.layouts || []).map((l) => l.pattern)
4208
- });
4329
+ if (!runtimeSession) {
4330
+ try {
4331
+ await runFarmDevPageHooks();
4332
+ } catch (error) {
4333
+ await failPageHook(error);
4334
+ return;
4209
4335
  }
4210
- } catch (error) {
4211
- await failPageHook(error);
4212
- return;
4213
4336
  }
4214
- const renderPayload = {
4215
- pathname,
4216
- method,
4217
- routePattern: routeMatch?.route?.pattern || null,
4218
- params: routeMatch?.params || {}
4219
- };
4220
4337
  const shouldInterceptResponse = Boolean(
4221
4338
  pm && (hasAfterResponseHook || hasHTMLTransformHook || runtimeSession && hasRuntimeAfterHook)
4222
4339
  );
@@ -4228,7 +4345,8 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4228
4345
  hasRuntimeAfterHook,
4229
4346
  hasAfterResponseHook,
4230
4347
  hasHTMLTransformHook,
4231
- renderPayload,
4348
+ // render.html gets the render info render.before got.
4349
+ renderPayload: pageHookRoute().render,
4232
4350
  method,
4233
4351
  urlPath,
4234
4352
  pathname,
@@ -4275,14 +4393,6 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4275
4393
  return;
4276
4394
  }
4277
4395
  const renderer = farmApp.getServerRenderer();
4278
- if (pm && hasBeforeRenderHook) {
4279
- try {
4280
- await pm.runHookParallel("beforeRender", renderPayload);
4281
- } catch (error) {
4282
- await failPageHook(error, responseInterceptor);
4283
- return;
4284
- }
4285
- }
4286
4396
  await renderer.renderPage(req, res);
4287
4397
  if (!shouldInterceptResponse) {
4288
4398
  logResponse(method, urlPath, res.statusCode || 200, Date.now() - startTime, "PAGE");
@@ -4335,15 +4445,18 @@ window.__FARM_MANIFEST__ = ${inlineValue({
4335
4445
  };
4336
4446
  },
4337
4447
  async resolveId(id, importer, resolveOptions) {
4338
- if (id.startsWith("@farm.js/core/internal/") && importer) {
4448
+ if (id.startsWith(FARM_RUNTIME_MODULE_PREFIX)) {
4449
+ return this.resolve(id.slice(FARM_RUNTIME_MODULE_PREFIX.length), getFarmCoreFile(), {
4450
+ ...resolveOptions,
4451
+ skipSelf: true
4452
+ });
4453
+ }
4454
+ if (id.startsWith("@farm.js/core/internal/") && importer && isOutsideAppRoot(importer)) {
4339
4455
  const root = farmApp?.getConfig().root || server?.config.root || options.root;
4340
- const relative4 = root ? path6.relative(root, importer.split("?", 1)[0]) : "";
4341
- if (root && (relative4.startsWith("..") || path6.isAbsolute(relative4))) {
4342
- return this.resolve(id, path6.join(root, "package.json"), {
4343
- ...resolveOptions,
4344
- skipSelf: true
4345
- });
4346
- }
4456
+ return this.resolve(id, path6.join(root, "package.json"), {
4457
+ ...resolveOptions,
4458
+ skipSelf: true
4459
+ });
4347
4460
  }
4348
4461
  if (typeof fontImports.resolveId === "function") {
4349
4462
  const fontId = await fontImports.resolveId.call(this, id, importer, resolveOptions);
@@ -4534,6 +4647,7 @@ export const manifest = getManifest();
4534
4647
  if (pendingClientSetup && !transformOptions?.ssr && !farmSetupContext.getStore()) {
4535
4648
  await pendingClientSetup;
4536
4649
  }
4650
+ const runtimeModule = !isBuild && transformOptions?.ssr === true && isOutsideAppRoot(id) ? toFarmRuntimeModuleId : void 0;
4537
4651
  const actionConfig = farmApp?.getConfig() ?? options;
4538
4652
  let rewrotePackageImports = false;
4539
4653
  if (resolveFarmServerComponentsMode(actionConfig.experimental?.serverComponents) === "islands" && (!id.includes("/node_modules/") || transformOptions?.ssr === true && farmReactServerFiles.has(id.split("?", 1)[0])) && !id.startsWith("\0") && /\.[cm]?[jt]sx?(?:$|\?)/.test(id) && !hasUseClientDirective(code)) {
@@ -4579,7 +4693,11 @@ export const manifest = getManifest();
4579
4693
  rewrotePackageImports = true;
4580
4694
  }
4581
4695
  if (transformOptions?.ssr === true) {
4582
- const cached = rewriteFarmReactCacheImport(code, file);
4696
+ const cached = rewriteFarmReactCacheImport(
4697
+ code,
4698
+ file,
4699
+ runtimeModule?.(FARM_REACT_CACHE_MODULE)
4700
+ );
4583
4701
  if (cached !== null) {
4584
4702
  code = cached;
4585
4703
  rewrotePackageImports = true;
@@ -4603,7 +4721,8 @@ export const manifest = getManifest();
4603
4721
  root: actionConfig.root || server?.config.root || process.cwd(),
4604
4722
  ssr: transformOptions?.ssr === true,
4605
4723
  // Parsed by file type: page components are TSX.
4606
- parse: (source) => parseSync(file, source).program
4724
+ parse: (source) => parseSync(file, source).program,
4725
+ runtimeModule
4607
4726
  });
4608
4727
  if (actionModule) return { code: actionModule, map: null };
4609
4728
  }
@@ -4690,7 +4809,8 @@ export const manifest = getManifest();
4690
4809
  parse: (source) => this.parse(source),
4691
4810
  slots: islandsMode,
4692
4811
  browser: transformOptions?.ssr !== true,
4693
- inferredInteraction: inference?.strategy === "interaction"
4812
+ inferredInteraction: inference?.strategy === "interaction",
4813
+ runtimeModule
4694
4814
  });
4695
4815
  if (!transformedBoundary) {
4696
4816
  this.error(
@@ -5046,10 +5166,17 @@ if (import.meta.hot) {
5046
5166
  }
5047
5167
  function runFarmMiddlewareWithNavigation(renderer, middlewareRequest, req, res, execute) {
5048
5168
  return renderer.runWithRequestContext(middlewareRequest, async () => {
5169
+ const headersBeforeMiddleware = res.getHeaders();
5049
5170
  try {
5050
5171
  return await execute();
5051
5172
  } catch (error) {
5052
5173
  if (await renderer.respondToNavigationError(req, res, error)) return true;
5174
+ if (!res.headersSent) {
5175
+ for (const name of res.getHeaderNames()) res.removeHeader(name);
5176
+ for (const [name, value] of Object.entries(headersBeforeMiddleware)) {
5177
+ if (value !== void 0) res.setHeader(name, value);
5178
+ }
5179
+ }
5053
5180
  throw error;
5054
5181
  }
5055
5182
  });
@@ -5568,7 +5695,8 @@ async function createFarmServerTreePageElement(source, pathname) {
5568
5695
  return await createFarmServerTreeElement(React, source, {
5569
5696
  load: (reference) => import(/* @vite-ignore */ farmModuleUrl(reference)),
5570
5697
  ServerHtml: FarmServerPage,
5571
- key: pathname,
5698
+ // No key: the next page of the same layout updates this one in place, as React Server
5699
+ // Components do, instead of unmounting it and building every node again.
5572
5700
  });
5573
5701
  } catch (error) {
5574
5702
  console.warn('[Farm.js] Could not rebuild the server tree of ' + pathname + '; its server HTML was kept.', error);
@@ -7720,6 +7848,8 @@ async function defineConfig(config = {}) {
7720
7848
  }
7721
7849
 
7722
7850
  export {
7851
+ isViteModuleRequest,
7852
+ isViteDevClientRequest,
7723
7853
  farmImageImportsPlugin,
7724
7854
  farmI18nClientBridgePlugin,
7725
7855
  farmServerOnlyEntriesPlugin,