@farm.js/core 0.1.67 → 0.1.69

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 (297) hide show
  1. package/dist/{agent-mcp.d-DWyWkTSy.d.mts → agent-mcp.d-DOfBMEzP.d.mts} +1 -1
  2. package/dist/{agent-mcp.d-BFu9xHAi.d.ts → agent-mcp.d-DnIgriX1.d.ts} +1 -1
  3. package/dist/agent-runtime.d.mts +5 -3
  4. package/dist/agent-runtime.d.ts +5 -3
  5. package/dist/{analyzer-TTIIXXMQ.mjs → analyzer-NAL5TJUP.mjs} +2 -2
  6. package/dist/analyzer-SAJSV6SP.cjs +16 -0
  7. package/dist/api/node.d.mts +7 -5
  8. package/dist/api/node.d.ts +7 -5
  9. package/dist/api/route-manager.d.mts +7 -5
  10. package/dist/api/route-manager.d.ts +7 -5
  11. package/dist/api/runtime.d.mts +6 -4
  12. package/dist/api/runtime.d.ts +6 -4
  13. package/dist/api.cjs +2 -2
  14. package/dist/api.d.mts +8 -23
  15. package/dist/api.d.ts +8 -23
  16. package/dist/api.mjs +1 -1
  17. package/dist/{app-manifest.d-CwfhGrVR.d.ts → app-manifest.d-CaAcaukR.d.ts} +1 -1
  18. package/dist/{app-manifest.d-CRmjN5j9.d.mts → app-manifest.d-_BVbI0xp.d.mts} +1 -1
  19. package/dist/app-markdown.cjs +3 -3
  20. package/dist/app-markdown.d.mts +10 -10
  21. package/dist/app-markdown.d.ts +10 -10
  22. package/dist/app-markdown.mjs +2 -2
  23. package/dist/{app.d-BX9LVTiP.d.ts → app.d-BWeDqOaF.d.ts} +6 -6
  24. package/dist/{app.d-uBBUxwyV.d.mts → app.d-CaPwtytN.d.mts} +6 -6
  25. package/dist/{base-path.d-BOUV5ozD.d.mts → base-path.d-CTDVF0Fc.d.mts} +2 -1
  26. package/dist/{base-path.d-BOUV5ozD.d.ts → base-path.d-CTDVF0Fc.d.ts} +2 -1
  27. package/dist/{chunk-HM7AGSKU.cjs → chunk-22LGTSBA.cjs} +1 -1
  28. package/dist/{chunk-4JX3M4C6.cjs → chunk-23VJEGKC.cjs} +2 -1
  29. package/dist/{chunk-V5MQMQ2P.mjs → chunk-2P7UYHZP.mjs} +1 -1
  30. package/dist/{chunk-Q37INCXG.cjs → chunk-3EEINK7G.cjs} +11 -2
  31. package/dist/{chunk-BRWIVOV4.cjs → chunk-3GNHJ3RN.cjs} +10 -8
  32. package/dist/{chunk-QJVW76JG.mjs → chunk-3Y52TWYU.mjs} +2 -2
  33. package/dist/{chunk-OB3IFUK6.cjs → chunk-437QZIC2.cjs} +4 -4
  34. package/dist/{chunk-DCXSIEFE.cjs → chunk-4JRAMCUP.cjs} +59 -38
  35. package/dist/{chunk-Q5UX55YA.cjs → chunk-4W4ZWSV2.cjs} +887 -485
  36. package/dist/{chunk-JWSI5WO4.mjs → chunk-4ZXKYCYK.mjs} +1 -1
  37. package/dist/{chunk-N35YPV4N.mjs → chunk-57QAQU4F.mjs} +9 -7
  38. package/dist/{chunk-AQDLVHNF.mjs → chunk-5FBZJJGA.mjs} +17 -0
  39. package/dist/{chunk-HP2DQGQH.mjs → chunk-5TOWKGV3.mjs} +1 -1
  40. package/dist/{chunk-556H7JCE.cjs → chunk-6GQJVY4E.cjs} +32 -27
  41. package/dist/{chunk-PL6RTBDE.cjs → chunk-ABIBASLJ.cjs} +2 -2
  42. package/dist/{chunk-H37MDCPR.mjs → chunk-ANMIR6US.mjs} +1 -1
  43. package/dist/{chunk-DQJ2CIH7.cjs → chunk-ASYOWPSR.cjs} +2 -1
  44. package/dist/{chunk-QGJ4FI2G.mjs → chunk-C6HGUTXB.mjs} +113 -29
  45. package/dist/{chunk-UHNSY2PQ.mjs → chunk-CKCKCUYO.mjs} +826 -424
  46. package/dist/{chunk-IRA2CZAY.mjs → chunk-CRVSYDHV.mjs} +2 -2
  47. package/dist/{chunk-2ZOYOYEE.mjs → chunk-D5F7RPZP.mjs} +71 -1
  48. package/dist/{chunk-N5DQMOAG.cjs → chunk-DHR2WDSL.cjs} +275 -92
  49. package/dist/{chunk-QGQP6QKO.cjs → chunk-DWLNLU55.cjs} +2 -2
  50. package/dist/{chunk-52Y3C3HG.mjs → chunk-E7VF3LQ5.mjs} +3 -2
  51. package/dist/{chunk-V5RTHYJB.cjs → chunk-F6YLXK5L.cjs} +93 -25
  52. package/dist/{chunk-HNVAZGQD.cjs → chunk-FJMC24KG.cjs} +2 -2
  53. package/dist/{chunk-KCY52OUQ.cjs → chunk-FSODPZRT.cjs} +1 -1
  54. package/dist/{chunk-PPX7UOFY.cjs → chunk-FVYBEMOD.cjs} +55 -38
  55. package/dist/{chunk-6YBYX4K4.mjs → chunk-G7NBPP7H.mjs} +1 -1
  56. package/dist/{chunk-HFHJJXSV.mjs → chunk-GFPS7MNE.mjs} +1 -1
  57. package/dist/{chunk-LPIZMU7D.cjs → chunk-GQ6QOH7T.cjs} +9 -5
  58. package/dist/{chunk-BZWTBELF.cjs → chunk-GTQOEEE7.cjs} +77 -7
  59. package/dist/{chunk-6V5YWI4W.cjs → chunk-GUMKIQJL.cjs} +2 -2
  60. package/dist/{chunk-3T5TLFCQ.mjs → chunk-HEJM46HQ.mjs} +11 -2
  61. package/dist/{chunk-F43OG25P.cjs → chunk-I7J5RLGO.cjs} +15 -1
  62. package/dist/chunk-ICFPTHXM.mjs +97 -0
  63. package/dist/{chunk-WGHY3OL5.mjs → chunk-IYLZZTP6.mjs} +233 -50
  64. package/dist/{chunk-WUTFJOV7.cjs → chunk-JFPKARWM.cjs} +16 -8
  65. package/dist/{chunk-TEG6HJVF.mjs → chunk-JL2YW5KX.mjs} +1 -0
  66. package/dist/{chunk-23PVOIPT.cjs → chunk-L5OZN6YW.cjs} +3 -3
  67. package/dist/{chunk-QITSS4TD.cjs → chunk-L6NWQ3DR.cjs} +537 -356
  68. package/dist/{chunk-3T7ALZJF.cjs → chunk-LR4KP3I7.cjs} +2 -2
  69. package/dist/{chunk-CO3YMZFD.mjs → chunk-MAGFDK4Q.mjs} +1 -1
  70. package/dist/{chunk-VFXE6NWR.mjs → chunk-MGKWYPE3.mjs} +2 -1
  71. package/dist/{chunk-5TA63JD3.mjs → chunk-MGZVDX4R.mjs} +1 -1
  72. package/dist/{chunk-6SQZXRJ2.cjs → chunk-MMDKYJ5V.cjs} +7 -7
  73. package/dist/{chunk-5Y2P454O.cjs → chunk-MTBDJ326.cjs} +6 -5
  74. package/dist/{chunk-XUES6OET.mjs → chunk-MV7NWU23.mjs} +1 -1
  75. package/dist/{chunk-4IHMHFQB.cjs → chunk-NG2EZ6QS.cjs} +28 -1
  76. package/dist/{chunk-F7JKVHU2.mjs → chunk-NVOMQLI2.mjs} +15 -1
  77. package/dist/{chunk-5IQ2ERQA.cjs → chunk-O47W53D3.cjs} +1 -1
  78. package/dist/{chunk-22IWL4YD.cjs → chunk-OCNV4CI2.cjs} +21 -2
  79. package/dist/{chunk-3TXKFRSO.mjs → chunk-OEL5EPOJ.mjs} +1 -1
  80. package/dist/{chunk-E6CD45JK.mjs → chunk-PDQ6EGPK.mjs} +26 -5
  81. package/dist/{chunk-VK54PDQ6.mjs → chunk-PEYDQMSA.mjs} +86 -18
  82. package/dist/{chunk-KSZK34HU.mjs → chunk-PJQ5W356.mjs} +16 -8
  83. package/dist/{chunk-72KCTHLV.cjs → chunk-PRL7FXG4.cjs} +113 -29
  84. package/dist/{chunk-JSOCDYER.cjs → chunk-Q4HH5Q6A.cjs} +15 -1
  85. package/dist/{chunk-YVTS3S3F.cjs → chunk-QOGIZKSO.cjs} +3 -3
  86. package/dist/{chunk-DB2HSHQA.cjs → chunk-QSUYB3RH.cjs} +14 -14
  87. package/dist/{chunk-724MGMIL.mjs → chunk-R2ZHU37O.mjs} +19 -0
  88. package/dist/{chunk-YQYTQJZN.mjs → chunk-RLH5AH2M.mjs} +1 -1
  89. package/dist/{chunk-WDD5CTZW.mjs → chunk-SZORL7EW.mjs} +24 -19
  90. package/dist/{chunk-6R53ZWX2.cjs → chunk-TKYOJ5G2.cjs} +3 -3
  91. package/dist/{chunk-XNZWMXCF.mjs → chunk-UHU4QALN.mjs} +330 -149
  92. package/dist/{chunk-J7JHVCWA.cjs → chunk-UKZ6AWKZ.cjs} +2 -1
  93. package/dist/{chunk-GTV2ABO7.mjs → chunk-ULMXZYOA.mjs} +162 -33
  94. package/dist/{chunk-4DRINDGN.cjs → chunk-VO65MYJD.cjs} +254 -125
  95. package/dist/chunk-W44X6IC2.cjs +97 -0
  96. package/dist/{chunk-UHE5JUKB.mjs → chunk-XCAQTCGK.mjs} +1 -1
  97. package/dist/{chunk-DGOFR7D5.cjs → chunk-Y6KHPJDB.cjs} +2 -2
  98. package/dist/{chunk-DXZ57EPE.mjs → chunk-YOHHL2UE.mjs} +14 -0
  99. package/dist/{chunk-KWFNUODD.mjs → chunk-YVPX5PI5.mjs} +1 -0
  100. package/dist/{chunk-HRPTMX5C.mjs → chunk-ZR2QB45W.mjs} +7 -3
  101. package/dist/{chunk-JVM3DKZE.mjs → chunk-ZYCEEE3V.mjs} +1 -1
  102. package/dist/{chunk-5FE5YT2N.mjs → chunk-ZZGQD3LL.mjs} +28 -1
  103. package/dist/{client-component.d-DWRKyAp5.d.ts → client-component.d-CfJxuXZl.d.ts} +2 -2
  104. package/dist/{client-component.d-CDRvRmbU.d.mts → client-component.d-CnEeVvGG.d.mts} +2 -2
  105. package/dist/{client-plugins.d-CrKZiNSN.d.ts → client-plugins.d-D7dHV1Nf.d.ts} +37 -236
  106. package/dist/{client-plugins.d-BNILjfX3.d.mts → client-plugins.d-Do5ULA0x.d.mts} +37 -236
  107. package/dist/client-plugins.d.mts +5 -3
  108. package/dist/client-plugins.d.ts +5 -3
  109. package/dist/client.cjs +6 -6
  110. package/dist/client.d.mts +10 -8
  111. package/dist/client.d.ts +10 -8
  112. package/dist/client.mjs +5 -5
  113. package/dist/config.d.mts +5 -3
  114. package/dist/config.d.ts +5 -3
  115. package/dist/deployment.cjs +4 -2
  116. package/dist/deployment.d.mts +15 -1
  117. package/dist/deployment.d.ts +15 -1
  118. package/dist/deployment.mjs +3 -1
  119. package/dist/desktop.d.mts +6 -4
  120. package/dist/desktop.d.ts +6 -4
  121. package/dist/{devtools-RZVT4JVN.cjs → devtools-7HNDS4SY.cjs} +7 -7
  122. package/dist/{devtools-UFQYT3VA.mjs → devtools-BP4EBTKQ.mjs} +6 -6
  123. package/dist/docs.cjs +11 -9
  124. package/dist/docs.d.mts +19 -5
  125. package/dist/docs.d.ts +19 -5
  126. package/dist/docs.mjs +11 -9
  127. package/dist/environment/vite.cjs +5 -5
  128. package/dist/environment/vite.d.mts +1 -1
  129. package/dist/environment/vite.d.ts +1 -1
  130. package/dist/environment/vite.mjs +4 -4
  131. package/dist/{generate-route-types.d-BL2pq6xC.d.ts → generate-route-types.d-B76M5R11.d.ts} +1 -1
  132. package/dist/{generate-route-types.d-BoVDU8qX.d.mts → generate-route-types.d-CaGMIaNI.d.mts} +1 -1
  133. package/dist/image/server.cjs +2 -2
  134. package/dist/image/server.mjs +1 -1
  135. package/dist/image/sharp.cjs +9 -9
  136. package/dist/image/sharp.mjs +1 -1
  137. package/dist/index.cjs +45 -39
  138. package/dist/{index.d-Bdm6866n.d.mts → index.d-B1MpEJAo.d.mts} +1 -1
  139. package/dist/{index.d-Dey5T14f.d.ts → index.d-CVFk37uX.d.ts} +1 -1
  140. package/dist/index.d.mts +26 -23
  141. package/dist/index.d.ts +26 -23
  142. package/dist/index.mjs +48 -42
  143. package/dist/instrumentation.cjs +3 -3
  144. package/dist/instrumentation.mjs +2 -2
  145. package/dist/integrations/orm.d.mts +5 -3
  146. package/dist/integrations/orm.d.ts +5 -3
  147. package/dist/integrations.d.mts +5 -3
  148. package/dist/integrations.d.ts +5 -3
  149. package/dist/internal/app-markdown-runtime.cjs +2 -2
  150. package/dist/internal/app-markdown-runtime.d.mts +12 -5
  151. package/dist/internal/app-markdown-runtime.d.ts +12 -5
  152. package/dist/internal/app-markdown-runtime.mjs +1 -1
  153. package/dist/internal/build-runtime.cjs +34 -32
  154. package/dist/internal/build-runtime.d.mts +7 -5
  155. package/dist/internal/build-runtime.d.ts +7 -5
  156. package/dist/internal/build-runtime.mjs +33 -31
  157. package/dist/internal/cli-runtime.cjs +10 -10
  158. package/dist/internal/cli-runtime.mjs +9 -9
  159. package/dist/internal/client-error-overlay.cjs +4 -4
  160. package/dist/internal/client-error-overlay.mjs +1 -1
  161. package/dist/internal/client-runtime.cjs +31 -36
  162. package/dist/internal/client-runtime.d.mts +9 -7
  163. package/dist/internal/client-runtime.d.ts +9 -7
  164. package/dist/internal/client-runtime.mjs +22 -27
  165. package/dist/internal/compression-runtime.d.mts +5 -3
  166. package/dist/internal/compression-runtime.d.ts +5 -3
  167. package/dist/internal/config-runtime.cjs +8 -8
  168. package/dist/internal/config-runtime.d.mts +9 -7
  169. package/dist/internal/config-runtime.d.ts +9 -7
  170. package/dist/internal/config-runtime.mjs +7 -7
  171. package/dist/internal/form-actions.cjs +7 -2
  172. package/dist/internal/form-actions.d.mts +10 -3
  173. package/dist/internal/form-actions.d.ts +10 -3
  174. package/dist/internal/form-actions.mjs +8 -3
  175. package/dist/internal/infra-analytics-runtime.cjs +6 -6
  176. package/dist/internal/infra-analytics-runtime.mjs +4 -4
  177. package/dist/internal/islands-boot.cjs +6 -1
  178. package/dist/internal/islands-boot.mjs +6 -1
  179. package/dist/internal/native-server-fns.cjs +4 -4
  180. package/dist/internal/native-server-fns.mjs +3 -3
  181. package/dist/internal/product-telemetry-runtime.cjs +3 -3
  182. package/dist/internal/product-telemetry-runtime.mjs +2 -2
  183. package/dist/internal/production-node-env.cjs +4 -2
  184. package/dist/internal/production-node-env.d.mts +22 -1
  185. package/dist/internal/production-node-env.d.ts +22 -1
  186. package/dist/internal/production-node-env.mjs +3 -1
  187. package/dist/internal/production-runtime.cjs +17 -9
  188. package/dist/internal/production-runtime.d.mts +31 -19
  189. package/dist/internal/production-runtime.d.ts +31 -19
  190. package/dist/internal/production-runtime.mjs +18 -10
  191. package/dist/internal/server-tree.cjs +2 -2
  192. package/dist/internal/server-tree.d.mts +0 -5
  193. package/dist/internal/server-tree.d.ts +0 -5
  194. package/dist/internal/server-tree.mjs +1 -1
  195. package/dist/internal/vercel-edge-middleware.cjs +87 -0
  196. package/dist/internal/vercel-edge-middleware.d.mts +39 -0
  197. package/dist/internal/vercel-edge-middleware.d.ts +39 -0
  198. package/dist/internal/vercel-edge-middleware.mjs +87 -0
  199. package/dist/layers-7P4RLKVX.cjs +20 -0
  200. package/dist/{layers-T55SA47E.mjs → layers-XQ7VFMWO.mjs} +4 -2
  201. package/dist/{layers.d-CcS42OGR.d.mts → layers.d-CH0bC4QL.d.mts} +2 -1
  202. package/dist/{layers.d-CcS42OGR.d.ts → layers.d-CH0bC4QL.d.ts} +2 -1
  203. package/dist/markdown.d.mts +5 -3
  204. package/dist/markdown.d.ts +5 -3
  205. package/dist/middleware.cjs +4 -4
  206. package/dist/middleware.d.mts +8 -5
  207. package/dist/middleware.d.ts +8 -5
  208. package/dist/middleware.mjs +6 -6
  209. package/dist/mobile.d.mts +4 -4
  210. package/dist/mobile.d.ts +4 -4
  211. package/dist/{mount.d-BP0nLYQO.d.mts → mount.d-CBqr-LfI.d.mts} +1 -1
  212. package/dist/{mount.d-CkiPky_F.d.ts → mount.d-CGzN61Kq.d.ts} +1 -1
  213. package/dist/{navigation-delegate.d-CdBP-hkZ.d.mts → navigation-delegate.d-BwCOhpj7.d.mts} +1 -1
  214. package/dist/{navigation-delegate.d-DchcGzAQ.d.ts → navigation-delegate.d-CLH2dXjy.d.ts} +1 -1
  215. package/dist/navigation.cjs +5 -5
  216. package/dist/navigation.d.mts +8 -6
  217. package/dist/navigation.d.ts +8 -6
  218. package/dist/navigation.mjs +4 -4
  219. package/dist/{nitro-55YOZWRA.mjs → nitro-NSTXT7LB.mjs} +2 -2
  220. package/dist/{nitro-EEX2J3KB.cjs → nitro-Y3LGITW3.cjs} +4 -4
  221. package/dist/node-module-bundle-LIZ2KMVW.cjs +13 -0
  222. package/dist/node-module-bundle-VR6NV6AI.mjs +13 -0
  223. package/dist/{plugin-WIU4GDD4.cjs → plugin-F2O4BFTK.cjs} +2 -2
  224. package/dist/{plugin-SAS22JL7.mjs → plugin-VEBRN7A3.mjs} +1 -1
  225. package/dist/plugin.cjs +23 -23
  226. package/dist/plugin.d.mts +7 -5
  227. package/dist/plugin.d.ts +7 -5
  228. package/dist/plugin.mjs +22 -22
  229. package/dist/{production-runtime.d-Dou_Htas.d.ts → production-runtime.d-BMyyLGBB.d.ts} +3 -57
  230. package/dist/{production-runtime.d-VwsBzIee.d.mts → production-runtime.d-DMZY3OgV.d.mts} +3 -57
  231. package/dist/query/client.cjs +6 -6
  232. package/dist/query/client.mjs +2 -2
  233. package/dist/{render-plan.d-LKymStDJ.d.mts → render-plan.d-CzGDjcT0.d.mts} +1 -1
  234. package/dist/{render-plan.d-D8UakAIk.d.ts → render-plan.d-W6LmjD6y.d.ts} +1 -1
  235. package/dist/renderer/react/server.cjs +2 -2
  236. package/dist/renderer/react/server.mjs +1 -1
  237. package/dist/renderer-client.cjs +5 -5
  238. package/dist/renderer-client.d.mts +8 -6
  239. package/dist/renderer-client.d.ts +8 -6
  240. package/dist/renderer-client.mjs +2 -2
  241. package/dist/renderer.d.mts +5 -0
  242. package/dist/renderer.d.ts +5 -0
  243. package/dist/{request.d-B928QjWy.d.ts → request.d-CTVRZiQv.d.ts} +1 -1
  244. package/dist/{request.d-KG-4d2eG.d.mts → request.d-CgNVderU.d.mts} +1 -1
  245. package/dist/request.d.mts +6 -4
  246. package/dist/request.d.ts +6 -4
  247. package/dist/{route-rendering.d-NIHQeb4m.d.mts → route-rendering.d-D0bmZVJA.d.mts} +1 -1
  248. package/dist/{route-rendering.d-DoEe_w9t.d.ts → route-rendering.d-FDSNtCMg.d.ts} +1 -1
  249. package/dist/{router.d-DYnRHQwz.d.ts → router.d-DZ3ldniI.d.ts} +1 -1
  250. package/dist/{router.d-B8PkJSGp.d.mts → router.d-GRKm_uAV.d.mts} +1 -1
  251. package/dist/{routes.d-uUBZyWoK.d.ts → routes.d-9GFFNioh.d.ts} +1 -1
  252. package/dist/{routes.d-DgZ_jgGG.d.mts → routes.d-CrEy0lJS.d.mts} +1 -1
  253. package/dist/routes.d.mts +5 -3
  254. package/dist/routes.d.ts +5 -3
  255. package/dist/{rsc-pipeline-7K5H2RPH.cjs → rsc-pipeline-J4KKBSCH.cjs} +10 -10
  256. package/dist/{rsc-pipeline-4OJ5ZQNZ.mjs → rsc-pipeline-PJZOVYSY.mjs} +9 -9
  257. package/dist/{runtime-X52Q7JFR.cjs → runtime-OLEO5NXF.cjs} +20 -20
  258. package/dist/{runtime-U7O3HZOZ.mjs → runtime-QDBSE4H6.mjs} +12 -12
  259. package/dist/{runtime.d-BxQIzwfy.d.mts → runtime.d-DqXihlxm.d.mts} +1 -1
  260. package/dist/{runtime.d-DP7mEkEF.d.ts → runtime.d-pqFQBU2N.d.ts} +1 -1
  261. package/dist/server-http.d-rAe7lAQc.d.mts +70 -0
  262. package/dist/server-http.d-rAe7lAQc.d.ts +70 -0
  263. package/dist/server-plugins.d.mts +6 -4
  264. package/dist/server-plugins.d.ts +6 -4
  265. package/dist/server.cjs +52 -50
  266. package/dist/server.d-C5FFrZAo.d.ts +57 -0
  267. package/dist/server.d-DgC8xew5.d.mts +57 -0
  268. package/dist/server.d.mts +13 -11
  269. package/dist/server.d.ts +13 -11
  270. package/dist/server.mjs +31 -29
  271. package/dist/{spa-router.d-DsFDHTsv.d.ts → spa-router.d-DhOhaQ-7.d.ts} +2 -2
  272. package/dist/{spa-router.d-BgHPVMhz.d.mts → spa-router.d-Dhvy60p4.d.mts} +2 -2
  273. package/dist/testing.d.mts +5 -3
  274. package/dist/testing.d.ts +5 -3
  275. package/dist/types.d-xCIhyjOq.d.mts +233 -0
  276. package/dist/types.d-xCIhyjOq.d.ts +233 -0
  277. package/dist/{utils.d-zxAVcf_V.d.ts → utils.d-BVCMRRau.d.ts} +1 -1
  278. package/dist/{utils.d-BKyKDBR1.d.mts → utils.d-Q8EHCpkF.d.mts} +1 -1
  279. package/dist/version.cjs +2 -2
  280. package/dist/version.mjs +1 -1
  281. package/dist/vite.cjs +23 -23
  282. package/dist/vite.d.mts +10 -8
  283. package/dist/vite.d.ts +10 -8
  284. package/dist/vite.mjs +22 -22
  285. package/dist/workflows.cjs +2 -2
  286. package/dist/workflows.d.mts +121 -1
  287. package/dist/workflows.d.ts +121 -1
  288. package/dist/workflows.mjs +1 -1
  289. package/package.json +7 -2
  290. package/dist/analyzer-KVZGVY5Q.cjs +0 -16
  291. package/dist/chunk-CLFEQGET.cjs +0 -60
  292. package/dist/chunk-MK5E44WP.mjs +0 -60
  293. package/dist/layers-DMRXRL7F.cjs +0 -18
  294. package/dist/node-module-bundle-7JHPPF6B.mjs +0 -11
  295. package/dist/node-module-bundle-YJGYBOGK.cjs +0 -11
  296. package/dist/workflows.d-CRMzQZ3k.d.mts +0 -188
  297. package/dist/workflows.d-CRMzQZ3k.d.ts +0 -188
@@ -7,6 +7,9 @@ import {
7
7
  hasFarmMobileClientEntry,
8
8
  removeFarmMobileClientManifest
9
9
  } from "./chunk-TM2E623I.mjs";
10
+ import {
11
+ loadFarmProductionVite
12
+ } from "./chunk-PSUYE5HR.mjs";
10
13
  import {
11
14
  FARM_COMPILE_CACHE_DIR,
12
15
  FARM_DESKTOP_ENV_MODULE_FILE,
@@ -17,15 +20,13 @@ import {
17
20
  createFarmBunServerEntry,
18
21
  createFarmCompileCacheLauncher,
19
22
  createFarmNodeServerEntry,
23
+ createReactProductionModePlugin,
20
24
  withProductionNodeEnv
21
- } from "./chunk-5FE5YT2N.mjs";
22
- import {
23
- loadFarmProductionVite
24
- } from "./chunk-PSUYE5HR.mjs";
25
+ } from "./chunk-ZZGQD3LL.mjs";
25
26
  import {
26
27
  collectFarmNativeServerFns,
27
28
  findFarmNativeScreenFiles
28
- } from "./chunk-HP2DQGQH.mjs";
29
+ } from "./chunk-5TOWKGV3.mjs";
29
30
  import {
30
31
  generateNativeMCPPluginSource
31
32
  } from "./chunk-KQH2COEJ.mjs";
@@ -36,9 +37,11 @@ import {
36
37
  assertFarmDocsAdapterServesNoGuardedPages,
37
38
  compileFarmDocsAdapterEdgeManifest,
38
39
  createFarmDocsAPIHandler,
40
+ farmDocsAdapterServesGuardedPages,
39
41
  hasFarmDocsRuntimeAdapter,
40
- listFarmDocsAdapterPages
41
- } from "./chunk-E6CD45JK.mjs";
42
+ listFarmDocsAdapterPages,
43
+ listFarmDocsPagePaths
44
+ } from "./chunk-PDQ6EGPK.mjs";
42
45
  import {
43
46
  FARM_DOCS_LAST_MODIFIED_MANIFEST,
44
47
  createFarmDocsHandler,
@@ -47,18 +50,22 @@ import {
47
50
  getFarmDocsMarkdownPath,
48
51
  getFarmDocsRoots,
49
52
  getFarmDocsRouteTypeEntries,
53
+ listFarmDocsBuiltInPrerenderPages,
50
54
  loadFarmDocsPage,
51
55
  resolveFarmDocsContentDir,
52
56
  toFarmDocsMarkdownPage
53
- } from "./chunk-AQDLVHNF.mjs";
57
+ } from "./chunk-5FBZJJGA.mjs";
54
58
  import {
55
59
  generateFarmDocsSearchClientRuntime,
56
60
  isFarmDocsSearchEnabled,
57
61
  resolveFarmDocsSearchClientModule
58
62
  } from "./chunk-ALEUMLJN.mjs";
63
+ import {
64
+ CDN_CACHE_CONTROL_HEADERS
65
+ } from "./chunk-JL2YW5KX.mjs";
59
66
  import {
60
67
  FARM_PRERENDER_ENV
61
- } from "./chunk-JVM3DKZE.mjs";
68
+ } from "./chunk-ZYCEEE3V.mjs";
62
69
  import {
63
70
  loadFarmDocsEngine
64
71
  } from "./chunk-VE3FWJBO.mjs";
@@ -67,17 +74,19 @@ import {
67
74
  getDeployTargetForPreset,
68
75
  hasCustomFarmRouteContext,
69
76
  resolveDeployOutputPath
70
- } from "./chunk-WDD5CTZW.mjs";
77
+ } from "./chunk-SZORL7EW.mjs";
71
78
  import {
72
79
  resolveFarmInstrumentationFile
73
- } from "./chunk-N35YPV4N.mjs";
80
+ } from "./chunk-57QAQU4F.mjs";
74
81
  import {
75
82
  resolveFarmInstrumentationRuntime
76
83
  } from "./chunk-WNDAISB7.mjs";
77
84
  import {
78
85
  DEFAULT_NOT_FOUND_STYLES,
79
86
  FARM_LAYOUT_ELEMENT_CLIENT_SOURCE,
87
+ FARM_NAVIGATION_SCRIPT_SOURCE,
80
88
  FARM_NAVIGATION_STREAM_READER_SOURCE,
89
+ FARM_REFRESH_FIELDS_SOURCE,
81
90
  FARM_SERVER_TREE_LAYOUT_CLIENT_SOURCE,
82
91
  SHARP_INSTALL_HINT,
83
92
  canBootFarmIslandsClient,
@@ -85,8 +94,10 @@ import {
85
94
  createFarmApp,
86
95
  createFarmSourceAlias,
87
96
  createFarmThemeCssPlugin,
97
+ exactIdPattern,
88
98
  farmDocsClientConfigPlugin,
89
99
  farmFontImportsPlugin,
100
+ fileNamePattern,
90
101
  generateClientCachePersistenceCode,
91
102
  generateFarmIntegrationProviderClientCode,
92
103
  generateFarmIntegrationProviderServerModules,
@@ -99,19 +110,20 @@ import {
99
110
  resolveFarmImageServerRuntime,
100
111
  resolveFarmNotFoundComponentPath,
101
112
  resolveFarmRouteRootStrategy
102
- } from "./chunk-WGHY3OL5.mjs";
113
+ } from "./chunk-IYLZZTP6.mjs";
103
114
  import {
104
115
  generateFarmClientPluginEntryCode,
116
+ hasFarmServerRuntimePlugins,
105
117
  loadTailwindVitePlugin
106
- } from "./chunk-DXZ57EPE.mjs";
118
+ } from "./chunk-YOHHL2UE.mjs";
107
119
  import {
108
120
  PluginManager
109
- } from "./chunk-KSZK34HU.mjs";
121
+ } from "./chunk-PJQ5W356.mjs";
110
122
  import {
111
123
  generateFarmTypeArtifacts,
112
124
  readRouteRenderingDirectiveFromFile,
113
125
  resolveRouteRenderingConfigFromFile
114
- } from "./chunk-6YBYX4K4.mjs";
126
+ } from "./chunk-G7NBPP7H.mjs";
115
127
  import {
116
128
  HOISTED_HEAD_ELEMENT,
117
129
  appMiddlewareMayHandlePath,
@@ -138,7 +150,7 @@ import {
138
150
  listFarmBuiltInRoutePaths,
139
151
  resolveFarmApiCatalogInput,
140
152
  resolveFarmAppManifestInput
141
- } from "./chunk-HRPTMX5C.mjs";
153
+ } from "./chunk-ZR2QB45W.mjs";
142
154
  import {
143
155
  FARM_DEFAULT_MCP_PATH,
144
156
  createFarmDefaultMCPServer,
@@ -146,7 +158,7 @@ import {
146
158
  } from "./chunk-K6SXMVXO.mjs";
147
159
  import {
148
160
  isFarmPreviewDeploymentEnvironment
149
- } from "./chunk-V5MQMQ2P.mjs";
161
+ } from "./chunk-2P7UYHZP.mjs";
150
162
  import {
151
163
  FARM_NATIVE_SERVER_FN_PLUGIN
152
164
  } from "./chunk-L4RTTTVE.mjs";
@@ -164,7 +176,7 @@ import {
164
176
  usePackageClientBoundaryCacheFile,
165
177
  usesFarmServerTree,
166
178
  withPackageClientBoundaryCache
167
- } from "./chunk-GTV2ABO7.mjs";
179
+ } from "./chunk-ULMXZYOA.mjs";
168
180
  import {
169
181
  generateFarmDocsAdapterClientRuntime,
170
182
  getFarmDocsAdapterConfigModule
@@ -174,8 +186,9 @@ import {
174
186
  toFarmDocsPublicFontAssets
175
187
  } from "./chunk-NRNAHZ57.mjs";
176
188
  import {
189
+ nitroRouteRulesBelowBasePath,
177
190
  routeRulesToNitroRouteRules
178
- } from "./chunk-724MGMIL.mjs";
191
+ } from "./chunk-R2ZHU37O.mjs";
179
192
  import {
180
193
  applyFarmCspHashesToHtml,
181
194
  createFarmCspNonce
@@ -185,7 +198,7 @@ import {
185
198
  } from "./chunk-4QENVMG7.mjs";
186
199
  import {
187
200
  getFarmAppDirectories
188
- } from "./chunk-52Y3C3HG.mjs";
201
+ } from "./chunk-E7VF3LQ5.mjs";
189
202
  import {
190
203
  REACT_RENDERER,
191
204
  getFarmRendererCapabilities,
@@ -210,7 +223,7 @@ import {
210
223
  } from "./chunk-N33DLJBC.mjs";
211
224
  import {
212
225
  isFarmMarkdownPageFile
213
- } from "./chunk-3T5TLFCQ.mjs";
226
+ } from "./chunk-HEJM46HQ.mjs";
214
227
  import {
215
228
  resolveFarmMdxComponentsModulePath,
216
229
  resolveMdxConfig
@@ -218,10 +231,13 @@ import {
218
231
  import {
219
232
  getFarmMarkdownAlternatePath
220
233
  } from "./chunk-IFR74W6S.mjs";
234
+ import {
235
+ withPlainDiagnostics
236
+ } from "./chunk-MGKWYPE3.mjs";
221
237
  import {
222
238
  applyFarmWorkflowVercelCrons,
223
239
  prepareFarmWorkflowsForNitro
224
- } from "./chunk-5TA63JD3.mjs";
240
+ } from "./chunk-MGZVDX4R.mjs";
225
241
  import {
226
242
  getFarmIntegrationPluginServerRuntime,
227
243
  getIntegrationProviders
@@ -266,14 +282,19 @@ import {
266
282
  } from "./chunk-2I6PUKWJ.mjs";
267
283
  import {
268
284
  FARM_VERSION
269
- } from "./chunk-H37MDCPR.mjs";
285
+ } from "./chunk-ANMIR6US.mjs";
270
286
  import {
271
- getFarmPresetRuntime
272
- } from "./chunk-F7JKVHU2.mjs";
287
+ normalizeFarmTrailingSlashPathname
288
+ } from "./chunk-YVPX5PI5.mjs";
289
+ import {
290
+ getFarmPresetRuntime,
291
+ resolveCloudflareProcessEnvFlags
292
+ } from "./chunk-NVOMQLI2.mjs";
273
293
  import {
274
294
  _runWithFarmCspNonce
275
295
  } from "./chunk-5OFNUETM.mjs";
276
296
  import {
297
+ applyFarmBasePath,
277
298
  normalizeFarmBasePath,
278
299
  stripFarmBasePath
279
300
  } from "./chunk-SF3JB56B.mjs";
@@ -282,7 +303,7 @@ import {
282
303
  } from "./chunk-AYP2YFVN.mjs";
283
304
 
284
305
  // src/build/index.ts
285
- import path12 from "path";
306
+ import path13 from "path";
286
307
  import { existsSync as existsSync3 } from "fs";
287
308
 
288
309
  // src/nitro/universal-build.ts
@@ -347,10 +368,10 @@ async function resolveHashedClientJsSrc(clientOutputDir) {
347
368
 
348
369
  // src/nitro/universal-build.ts
349
370
  import os from "os";
350
- import path11 from "path";
371
+ import path12 from "path";
351
372
  import { constants as fsConstants, existsSync as existsSync2, readFileSync, realpathSync as realpathSync2, statSync } from "fs";
352
373
  import { fileURLToPath } from "url";
353
- import { builtinModules, createRequire } from "module";
374
+ import { builtinModules, createRequire as createRequire2 } from "module";
354
375
  import { isDeepStrictEqual } from "util";
355
376
 
356
377
  // src/docs/compiler.ts
@@ -943,12 +964,14 @@ function createFarmVercelImmutableAssetRoute() {
943
964
  };
944
965
  }
945
966
  function buildFarmVercelRoutes(options) {
946
- const { presetRoutes, runtimeRoutes } = options;
967
+ const { presetRoutes, runtimeRoutes, middlewareRoutes = [], canonicalSlashRoutes = [] } = options;
947
968
  const filesystemIndex = presetRoutes.findIndex((route) => route.handle === "filesystem");
948
969
  const sourceRoutes = filesystemIndex >= 0 ? presetRoutes.slice(0, filesystemIndex) : [];
949
970
  const preservedSourceRoutes = sourceRoutes.filter((route) => route.continue !== true);
950
971
  return [
951
972
  ...preservedSourceRoutes,
973
+ ...middlewareRoutes,
974
+ ...canonicalSlashRoutes,
952
975
  createFarmVercelImmutableAssetRoute(),
953
976
  { handle: "filesystem" },
954
977
  ...runtimeRoutes,
@@ -958,6 +981,18 @@ function buildFarmVercelRoutes(options) {
958
981
  }
959
982
  ];
960
983
  }
984
+ function escapeRegExp2(value) {
985
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
986
+ }
987
+ function createFarmVercelCanonicalSlashRoutes(publicPaths) {
988
+ const otherSpellings = [
989
+ ...new Set(
990
+ publicPaths.filter((pathname) => pathname !== "/").map((pathname) => pathname.endsWith("/") ? pathname.replace(/\/+$/, "") : `${pathname}/`).filter((pathname) => pathname !== "")
991
+ )
992
+ ];
993
+ if (otherSpellings.length === 0) return [];
994
+ return [{ src: `^(?:${otherSpellings.map(escapeRegExp2).join("|")})$`, dest: "/__nitro" }];
995
+ }
961
996
 
962
997
  // src/nitro/ssr-public-assets.ts
963
998
  import path7 from "path";
@@ -1216,14 +1251,17 @@ function farmStripPlatformConfigPlugin(configFiles) {
1216
1251
  // Before the TypeScript transform, so its import elision also drops imports only the
1217
1252
  // removed block used (`readFileSync` for a version, say).
1218
1253
  enforce: "pre",
1219
- async transform(code, id) {
1220
- const file = id.split("?", 1)[0];
1221
- if (!files.has(path9.resolve(file)) && !files.has(realPath(file))) return null;
1222
- const { parseAst } = await import("rolldown/parseAst");
1223
- const extension = path9.extname(file).slice(1);
1224
- const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
1225
- const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
1226
- return stripped === null ? null : { code: stripped, map: null };
1254
+ transform: {
1255
+ filter: { id: fileNamePattern(configFiles) },
1256
+ async handler(code, id) {
1257
+ const file = id.split("?", 1)[0];
1258
+ if (!files.has(path9.resolve(file)) && !files.has(realPath(file))) return null;
1259
+ const { parseAst } = await import("rolldown/parseAst");
1260
+ const extension = path9.extname(file).slice(1);
1261
+ const lang = /^[cm]?tsx?$/.test(extension) ? extension.endsWith("x") ? "tsx" : "ts" : extension.endsWith("x") ? "jsx" : "js";
1262
+ const stripped = stripPlatformConfigSource(code, (source) => parseAst(source, { lang }));
1263
+ return stripped === null ? null : { code: stripped, map: null };
1264
+ }
1227
1265
  }
1228
1266
  };
1229
1267
  }
@@ -1306,6 +1344,11 @@ function readStaticMiddlewareConfig(program) {
1306
1344
  for (const property of init.properties) {
1307
1345
  if (property.type !== "Property" || property.computed) return "unknown";
1308
1346
  const key = property.key?.name ?? property.key?.value;
1347
+ if (key === "runtime") {
1348
+ const runtime = literalMatcher(unwrap(property.value));
1349
+ if (runtime === "edge" || runtime === "nodejs") config.runtime = runtime;
1350
+ continue;
1351
+ }
1309
1352
  if (key !== "matcher" && key !== "exclude") continue;
1310
1353
  const matchers = literalMatchers(unwrap(property.value));
1311
1354
  if (!matchers) return "unknown";
@@ -1328,6 +1371,164 @@ async function readMiddlewareFileConfig(filePath) {
1328
1371
  }
1329
1372
  }
1330
1373
 
1374
+ // src/nitro/vercel-edge-middleware.ts
1375
+ import { createRequire, isBuiltin } from "module";
1376
+ import path11 from "path";
1377
+ import { gzipSync } from "zlib";
1378
+ var FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION = "_farm_middleware";
1379
+ var FARM_VERCEL_EDGE_NOT_FOUND_PATH = "/__farm/not-found";
1380
+ var EDGE_NODE_MODULES = /* @__PURE__ */ new Set(["async_hooks", "events", "buffer", "assert", "util"]);
1381
+ var EDGE_FUNCTION_SIZE_WARNING_BYTES = 1024 * 1024;
1382
+ function farmTargetRunsEdgeMiddleware(preset) {
1383
+ return preset === "vercel";
1384
+ }
1385
+ function isFarmEdgeMiddlewareRoute(route) {
1386
+ return typeof route.config === "object" && route.config?.runtime === "edge";
1387
+ }
1388
+ function escapeRegExp3(value) {
1389
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1390
+ }
1391
+ function toFarmVercelEdgeGuardedUrls(pathnames, basePath) {
1392
+ return [
1393
+ ...new Set(pathnames.flatMap((pathname) => [pathname, applyFarmBasePath(pathname, basePath)]))
1394
+ ];
1395
+ }
1396
+ function createFarmVercelEdgeMiddlewareRoute(pathnames, basePath = "/") {
1397
+ const publicPaths = toFarmVercelEdgeGuardedUrls(pathnames, basePath);
1398
+ const alternatives = publicPaths.map((pathname) => {
1399
+ const trimmed = pathname.replace(/\/+$/, "");
1400
+ return trimmed ? `${escapeRegExp3(trimmed)}(?:/|/index\\.html|\\.html)?` : "/(?:index\\.html)?";
1401
+ });
1402
+ return {
1403
+ src: `^(?:${alternatives.join("|")})$`,
1404
+ middlewarePath: FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION,
1405
+ middlewareRawSrc: publicPaths,
1406
+ continue: true
1407
+ };
1408
+ }
1409
+ function generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages) {
1410
+ const imports = routes.map(
1411
+ (route, index) => `import * as farmEdgeMiddleware${index} from ${JSON.stringify(route.filePath.replace(/\\/g, "/"))};`
1412
+ );
1413
+ const modules = routes.map(
1414
+ (route, index) => ` { path: ${JSON.stringify(route.path)}, filePath: ${JSON.stringify(route.filePath)}, module: farmEdgeMiddleware${index} },`
1415
+ );
1416
+ return `import { createFarmVercelEdgeMiddleware } from "@farm.js/core/internal/vercel-edge-middleware";
1417
+ ${imports.join("\n")}
1418
+
1419
+ export default createFarmVercelEdgeMiddleware({
1420
+ modules: [
1421
+ ${modules.join("\n")}
1422
+ ],
1423
+ i18n: ${JSON.stringify(config.i18n)},
1424
+ server: ${JSON.stringify({ trustProxy: config.server?.trustProxy === true })},
1425
+ apiBasePath: ${JSON.stringify(resolveFarmAPIServerBasePath(config.api))},
1426
+ notFoundPath: ${JSON.stringify(applyFarmBasePath(FARM_VERCEL_EDGE_NOT_FOUND_PATH, config.basePath))},
1427
+ pages: ${JSON.stringify(toFarmVercelEdgeGuardedUrls(guardedPages, config.basePath))},
1428
+ });
1429
+ `;
1430
+ }
1431
+ async function resolveFarmCoreDir(root, fs4) {
1432
+ const runtimeEntry = createRequire(path11.join(root, "package.json")).resolve(
1433
+ "@farm.js/core/internal/vercel-edge-middleware"
1434
+ );
1435
+ return fs4.realpath(path11.resolve(path11.dirname(runtimeEntry), "..", ".."));
1436
+ }
1437
+ function edgeNodeModulesPlugin(coreDir, unsupported) {
1438
+ const streamStub = "\0farm-edge-node-stream";
1439
+ const corePrefix = coreDir + path11.sep;
1440
+ return {
1441
+ name: "farm-vercel-edge-node-modules",
1442
+ resolveId(source, importer) {
1443
+ if (!isBuiltin(source)) return null;
1444
+ const name = source.replace(/^node:/, "").split("/")[0];
1445
+ if (EDGE_NODE_MODULES.has(name)) return { id: `node:${name}`, external: true };
1446
+ if (name === "stream" && importer && path11.resolve(importer).startsWith(corePrefix)) {
1447
+ return streamStub;
1448
+ }
1449
+ unsupported.add(`${source} (imported by ${importer ?? "the entry"})`);
1450
+ return { id: source, external: true };
1451
+ },
1452
+ load(id) {
1453
+ if (id !== streamStub) return null;
1454
+ return `export const Readable = { toWeb() { throw new Error("[Farm.js] Node streams are not available in Vercel edge middleware."); } };`;
1455
+ }
1456
+ };
1457
+ }
1458
+ async function writeFarmVercelEdgeMiddlewareFunction(options) {
1459
+ const { root, outputDir, buildDir, config, routes, guardedPages, fs: fs4 } = options;
1460
+ const functionDir = path11.join(
1461
+ outputDir,
1462
+ "functions",
1463
+ `${FARM_VERCEL_EDGE_MIDDLEWARE_FUNCTION}.func`
1464
+ );
1465
+ const entryPath = path11.join(buildDir, "vercel-edge-middleware-entry.mjs");
1466
+ await fs4.mkdir(path11.dirname(entryPath), { recursive: true });
1467
+ await fs4.writeFile(
1468
+ entryPath,
1469
+ generateFarmVercelEdgeMiddlewareEntry(routes, config, guardedPages)
1470
+ );
1471
+ const unsupported = /* @__PURE__ */ new Set();
1472
+ const coreDir = await resolveFarmCoreDir(root, fs4);
1473
+ const { rolldown } = await import("rolldown");
1474
+ let code;
1475
+ try {
1476
+ const bundle = await rolldown({
1477
+ cwd: root,
1478
+ input: entryPath,
1479
+ platform: "browser",
1480
+ logLevel: "silent",
1481
+ plugins: [edgeNodeModulesPlugin(coreDir, unsupported)],
1482
+ resolve: {
1483
+ alias: createFarmSourceAlias(root, config.srcDir),
1484
+ conditionNames: ["edge-light", "worker", "browser", "import", "module", "default"]
1485
+ },
1486
+ transform: {
1487
+ target: "es2022",
1488
+ define: { "process.env.NODE_ENV": JSON.stringify("production") }
1489
+ }
1490
+ });
1491
+ try {
1492
+ const { output } = await bundle.generate({
1493
+ format: "esm",
1494
+ codeSplitting: false,
1495
+ minify: true
1496
+ });
1497
+ code = output[0].code;
1498
+ } finally {
1499
+ await bundle.close();
1500
+ }
1501
+ } catch (error) {
1502
+ throw withPlainDiagnostics(error);
1503
+ } finally {
1504
+ await fs4.rm(entryPath, { force: true });
1505
+ }
1506
+ if (unsupported.size > 0) {
1507
+ throw new Error(
1508
+ `[Farm.js] runtime: "edge" middleware runs in Vercel's Edge runtime, which does not provide these Node modules:
1509
+ ` + [...unsupported].map((entry) => ` - ${entry}`).join("\n") + `
1510
+ Remove them from the middleware (Edge provides ${[...EDGE_NODE_MODULES].join(", ")}), or remove runtime: "edge" so the middleware runs in the server and its pages render on request.`
1511
+ );
1512
+ }
1513
+ await fs4.rm(functionDir, { recursive: true, force: true });
1514
+ await fs4.mkdir(functionDir, { recursive: true });
1515
+ await fs4.writeFile(path11.join(functionDir, "index.js"), code);
1516
+ await fs4.writeFile(
1517
+ path11.join(functionDir, ".vc-config.json"),
1518
+ `${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}
1519
+ `
1520
+ );
1521
+ const gzippedBytes = gzipSync(code).length;
1522
+ if (gzippedBytes > EDGE_FUNCTION_SIZE_WARNING_BYTES) {
1523
+ logger.warn(
1524
+ `Vercel edge middleware is ${(gzippedBytes / 1024 / 1024).toFixed(2)} MB gzipped, over the Hobby plan's 1 MB Edge function limit (Pro allows 2 MB, Enterprise 4 MB).`
1525
+ );
1526
+ }
1527
+ logger.info(
1528
+ `\u{1F6E1}\uFE0F Vercel edge middleware: ${routes.length} middleware file(s) guard their prerendered pages before the CDN serves them`
1529
+ );
1530
+ }
1531
+
1331
1532
  // src/nitro/universal-build.ts
1332
1533
  var FARM_NATIVE_STYLESHEETS_PLACEHOLDER = "__FARM_NATIVE_STYLESHEETS__";
1333
1534
  async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
@@ -1335,7 +1536,7 @@ async function readFarmNativeStylesheets(clientOutputDir, clientCssHref) {
1335
1536
  try {
1336
1537
  return {
1337
1538
  [clientCssHref]: await fs4.readFile(
1338
- path11.join(clientOutputDir, clientCssHref.slice(1)),
1539
+ path12.join(clientOutputDir, clientCssHref.slice(1)),
1339
1540
  "utf8"
1340
1541
  )
1341
1542
  };
@@ -1350,18 +1551,18 @@ function preloadFarmNitroBuilder() {
1350
1551
  );
1351
1552
  }
1352
1553
  var _filename = typeof import.meta.url !== "undefined" ? fileURLToPath(import.meta.url) : "";
1353
- var _dirname = path11.dirname(_filename);
1554
+ var _dirname = path12.dirname(_filename);
1354
1555
  function findFarmCoreRoot(from) {
1355
- let dir = path11.dirname(from);
1356
- while (dir !== path11.dirname(dir)) {
1357
- const manifest = path11.join(dir, "package.json");
1556
+ let dir = path12.dirname(from);
1557
+ while (dir !== path12.dirname(dir)) {
1558
+ const manifest = path12.join(dir, "package.json");
1358
1559
  if (existsSync2(manifest)) {
1359
1560
  try {
1360
1561
  if (JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core") return dir;
1361
1562
  } catch {
1362
1563
  }
1363
1564
  }
1364
- dir = path11.dirname(dir);
1565
+ dir = path12.dirname(dir);
1365
1566
  }
1366
1567
  return null;
1367
1568
  }
@@ -1371,16 +1572,16 @@ function toModulePath(file) {
1371
1572
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
1372
1573
  }
1373
1574
  function findInstalledPackageDir(name, from) {
1374
- for (let dir = from; ; dir = path11.dirname(dir)) {
1375
- const candidate = path11.join(dir, "node_modules", name);
1376
- if (existsSync2(path11.join(candidate, "package.json"))) {
1575
+ for (let dir = from; ; dir = path12.dirname(dir)) {
1576
+ const candidate = path12.join(dir, "node_modules", name);
1577
+ if (existsSync2(path12.join(candidate, "package.json"))) {
1377
1578
  try {
1378
1579
  return realpathSync2(candidate);
1379
1580
  } catch {
1380
1581
  return null;
1381
1582
  }
1382
1583
  }
1383
- if (dir === path11.dirname(dir)) return null;
1584
+ if (dir === path12.dirname(dir)) return null;
1384
1585
  }
1385
1586
  }
1386
1587
  function collectFarmDependencyDirs(root) {
@@ -1391,7 +1592,7 @@ function collectFarmDependencyDirs(root) {
1391
1592
  seen.add(dir);
1392
1593
  let manifest;
1393
1594
  try {
1394
- manifest = JSON.parse(readFileSync(path11.join(dir, "package.json"), "utf8"));
1595
+ manifest = JSON.parse(readFileSync(path12.join(dir, "package.json"), "utf8"));
1395
1596
  } catch {
1396
1597
  return;
1397
1598
  }
@@ -1402,7 +1603,7 @@ function collectFarmDependencyDirs(root) {
1402
1603
  if (farmCoreRoot) visit(realpathSync2(farmCoreRoot));
1403
1604
  queue.push({ name: "@farm.js/core", from: root });
1404
1605
  try {
1405
- const manifest = JSON.parse(readFileSync(path11.join(root, "package.json"), "utf8"));
1606
+ const manifest = JSON.parse(readFileSync(path12.join(root, "package.json"), "utf8"));
1406
1607
  for (const field of ["dependencies", "devDependencies"]) {
1407
1608
  for (const name of Object.keys(manifest[field] ?? {})) {
1408
1609
  if (name.startsWith("@farm.js/")) queue.push({ name, from: root });
@@ -1469,17 +1670,17 @@ var FARM_SSR_PACKAGE_IMPORT = "#farm-ssr-entry";
1469
1670
  var FARM_SSR_OUTPUT_DIR = "farm-ssr";
1470
1671
  var FARM_CLIENT_BUILD_TARGET = ["es2020", "edge88", "firefox78", "chrome87", "safari14"];
1471
1672
  function resolveNitroRuntimeDependency(root, specifier) {
1472
- return createRequire(resolveNitroPackageEntry(root)).resolve(specifier).split(path11.sep).join("/");
1673
+ return createRequire2(resolveNitroPackageEntry(root)).resolve(specifier).split(path12.sep).join("/");
1473
1674
  }
1474
1675
  function resolveNitroInternalRuntimeAliases(root) {
1475
1676
  const nitroEntry = resolveNitroPackageEntry(root);
1476
- const runtimeDir = path11.dirname(nitroEntry);
1477
- const nitroRequire = createRequire(nitroEntry);
1677
+ const runtimeDir = path12.dirname(nitroEntry);
1678
+ const nitroRequire = createRequire2(nitroEntry);
1478
1679
  return {
1479
1680
  ...Object.fromEntries(
1480
1681
  ["app", "error/hooks", "runtime-config", "shutdown", "task"].map((moduleName) => [
1481
1682
  `#nitro/runtime/${moduleName}`,
1482
- path11.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path11.sep).join("/")
1683
+ path12.join(runtimeDir, "internal", `${moduleName}.mjs`).split(path12.sep).join("/")
1483
1684
  ])
1484
1685
  ),
1485
1686
  // Farm's generated workflow and cron wrappers live under `.farm/` and
@@ -1488,7 +1689,7 @@ function resolveNitroInternalRuntimeAliases(root) {
1488
1689
  ...Object.fromEntries(
1489
1690
  ["nitro/app", "nitro/h3", "nitro/task"].map((specifier) => [
1490
1691
  specifier,
1491
- nitroRequire.resolve(specifier).split(path11.sep).join("/")
1692
+ nitroRequire.resolve(specifier).split(path12.sep).join("/")
1492
1693
  ])
1493
1694
  )
1494
1695
  };
@@ -1499,7 +1700,7 @@ function createPrerenderRuntimeResolverPlugin(root, resolveNitroEntry = resolveN
1499
1700
  name: "farm-prerender-runtime-resolver",
1500
1701
  async resolveId(id, _importer, options) {
1501
1702
  if (options.custom?.farmPrerenderRuntimeResolve) return null;
1502
- if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path11.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
1703
+ if (id.startsWith("\0") || id.startsWith(".") || id.startsWith("#") || id.startsWith("virtual:") || path12.isAbsolute(id) || NODE_BUILTIN_MODULES.has(id)) {
1503
1704
  return null;
1504
1705
  }
1505
1706
  if (nitroEntry === void 0) {
@@ -1522,10 +1723,10 @@ function createFarmStorageModuleRegistration(config) {
1522
1723
  const modules = _collectFarmStorageModules(config.storage);
1523
1724
  if (modules.length === 0) return "";
1524
1725
  const root = config.root || process.cwd();
1525
- const projectRequire = createRequire(path11.join(root, "package.json"));
1726
+ const projectRequire = createRequire2(path12.join(root, "package.json"));
1526
1727
  let runtimeRequire = projectRequire;
1527
1728
  try {
1528
- runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
1729
+ runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
1529
1730
  } catch {
1530
1731
  }
1531
1732
  const loaders = [];
@@ -1549,10 +1750,10 @@ ${loaders.join("\n")}
1549
1750
  });` : "";
1550
1751
  }
1551
1752
  function resolveNitroPackageEntry(root) {
1552
- const projectRequire = createRequire(path11.join(root, "package.json"));
1753
+ const projectRequire = createRequire2(path12.join(root, "package.json"));
1553
1754
  let runtimeRequire = projectRequire;
1554
1755
  try {
1555
- runtimeRequire = createRequire(projectRequire.resolve("@farm.js/core"));
1756
+ runtimeRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
1556
1757
  } catch {
1557
1758
  }
1558
1759
  return runtimeRequire.resolve("nitro");
@@ -1619,7 +1820,7 @@ function createFarmReactWebServerAlias(hasEdgeBuild) {
1619
1820
  }
1620
1821
  function hasReactDomEdgeServerBuild(root) {
1621
1822
  try {
1622
- createRequire(path11.join(root, "package.json")).resolve("react-dom/server.edge");
1823
+ createRequire2(path12.join(root, "package.json")).resolve("react-dom/server.edge");
1623
1824
  return true;
1624
1825
  } catch {
1625
1826
  return false;
@@ -1648,23 +1849,11 @@ function isNitroRollupExternal(id) {
1648
1849
  return NODE_BUILTIN_MODULES.has(id) || NITRO_EXTERNAL_MODULES.has(id) || normalizedId.startsWith(".prisma/") || normalizedId.includes("/node_modules/@prisma/client/") || normalizedId.includes("/node_modules/.prisma/client/");
1649
1850
  }
1650
1851
  var FARM_METADATA_IMAGE_WASM_PREFIX = "\0farm-metadata-image-wasm:";
1651
- function createReactProductionModePlugin() {
1652
- const nodeEnvExpression = ["process", "env", "NODE_ENV"].join(".");
1653
- return {
1654
- name: "farm-react-production-mode",
1655
- transform(code, id) {
1656
- const normalizedId = id.replace(/\\/g, "/");
1657
- const isReactRuntime = normalizedId.includes("/node_modules/react/") || normalizedId.includes("/node_modules/react-dom/");
1658
- if (!isReactRuntime || !code.includes(nodeEnvExpression)) return null;
1659
- return { code: code.split(nodeEnvExpression).join('"production"'), map: null };
1660
- }
1661
- };
1662
- }
1663
1852
  var FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID = "\0farm-omitted-metadata-image-runtime";
1664
1853
  function isFarmCoreModule(file) {
1665
- let dir = path11.dirname(file.split("?", 1)[0]);
1666
- while (dir !== path11.dirname(dir)) {
1667
- const manifest = path11.join(dir, "package.json");
1854
+ let dir = path12.dirname(file.split("?", 1)[0]);
1855
+ while (dir !== path12.dirname(dir)) {
1856
+ const manifest = path12.join(dir, "package.json");
1668
1857
  if (existsSync2(manifest)) {
1669
1858
  try {
1670
1859
  return JSON.parse(readFileSync(manifest, "utf8")).name === "@farm.js/core";
@@ -1672,40 +1861,46 @@ function isFarmCoreModule(file) {
1672
1861
  return false;
1673
1862
  }
1674
1863
  }
1675
- dir = path11.dirname(dir);
1864
+ dir = path12.dirname(dir);
1676
1865
  }
1677
1866
  return false;
1678
1867
  }
1679
1868
  function createOmittedMetadataImageRuntimePlugin(externalizeOtherImports) {
1680
1869
  return {
1681
1870
  name: "farm-omitted-metadata-image-runtime",
1682
- resolveId(source, importer) {
1683
- if (source !== "@vercel/og") return null;
1684
- const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path11.basename(importer.split("?", 1)[0]));
1685
- if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
1686
- return externalizeOtherImports ? { id: source, external: true } : null;
1871
+ resolveId: {
1872
+ filter: { id: exactIdPattern(["@vercel/og"]) },
1873
+ handler(source, importer) {
1874
+ if (source !== "@vercel/og") return null;
1875
+ const fromCoreRuntime = importer !== void 0 && isFarmCoreModule(importer) && !/^og\.[cm]?[jt]sx?$/.test(path12.basename(importer.split("?", 1)[0]));
1876
+ if (fromCoreRuntime) return FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID;
1877
+ return externalizeOtherImports ? { id: source, external: true } : null;
1878
+ }
1687
1879
  },
1688
- load(id) {
1689
- if (id !== FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID) return null;
1690
- return `
1880
+ load: {
1881
+ filter: { id: exactIdPattern([FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID]) },
1882
+ handler(id) {
1883
+ if (id !== FARM_OMITTED_METADATA_IMAGE_RUNTIME_ID) return null;
1884
+ return `
1691
1885
  export class ImageResponse {
1692
1886
  constructor() {
1693
1887
  throw new Error("@vercel/og is not in this server build because the app has no generated metadata image route.");
1694
1888
  }
1695
1889
  }
1696
1890
  `;
1891
+ }
1697
1892
  }
1698
1893
  };
1699
1894
  }
1700
1895
  function readVercelOgManifest(file) {
1701
- let dir = path11.dirname(file.split("?", 1)[0]);
1702
- while (dir !== path11.dirname(dir)) {
1703
- const manifestPath = path11.join(dir, "package.json");
1896
+ let dir = path12.dirname(file.split("?", 1)[0]);
1897
+ while (dir !== path12.dirname(dir)) {
1898
+ const manifestPath = path12.join(dir, "package.json");
1704
1899
  if (existsSync2(manifestPath)) {
1705
1900
  const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
1706
1901
  return manifest.name === "@vercel/og" ? { dir, manifest } : null;
1707
1902
  }
1708
- dir = path11.dirname(dir);
1903
+ dir = path12.dirname(dir);
1709
1904
  }
1710
1905
  return null;
1711
1906
  }
@@ -1713,7 +1908,7 @@ function resolveVercelOgConditionEntry(resolvedId, condition) {
1713
1908
  const vercelOg = readVercelOgManifest(resolvedId);
1714
1909
  const entry = vercelOg?.manifest.exports?.["."]?.[condition];
1715
1910
  const file = typeof entry === "string" ? entry : entry?.default;
1716
- return vercelOg && typeof file === "string" ? path11.join(vercelOg.dir, file) : null;
1911
+ return vercelOg && typeof file === "string" ? path12.join(vercelOg.dir, file) : null;
1717
1912
  }
1718
1913
  function createEdgeMetadataImageRuntimePlugin({
1719
1914
  condition,
@@ -1731,7 +1926,7 @@ function createEdgeMetadataImageRuntimePlugin({
1731
1926
  if (wasm !== "module" || !source.endsWith(".wasm?module") || !importer?.replace(/\\/g, "/").includes("/@vercel/og/")) {
1732
1927
  return null;
1733
1928
  }
1734
- const resolvedPath = path11.resolve(path11.dirname(importer.split("?", 1)[0]), source);
1929
+ const resolvedPath = path12.resolve(path12.dirname(importer.split("?", 1)[0]), source);
1735
1930
  return { id: toPosixPath(resolvedPath), external: "absolute" };
1736
1931
  }
1737
1932
  };
@@ -1746,7 +1941,7 @@ function createVercelOgFontInlinePlugin(runtime = "Cloudflare Workers") {
1746
1941
  return null;
1747
1942
  }
1748
1943
  const inlined = code.replace(VERCEL_OG_FONT_FETCH, (_match, _quote, request) => {
1749
- const encoded = readFileSync(path11.resolve(path11.dirname(file), request)).toString("base64");
1944
+ const encoded = readFileSync(path12.resolve(path12.dirname(file), request)).toString("base64");
1750
1945
  return `Promise.resolve({ arrayBuffer: () => Uint8Array.from(atob(${JSON.stringify(encoded)}), (character) => character.charCodeAt(0)).buffer })`;
1751
1946
  });
1752
1947
  if (inlined !== code) return { code: inlined, map: null };
@@ -1765,7 +1960,7 @@ function createMetadataImageWasmPlugin() {
1765
1960
  return null;
1766
1961
  }
1767
1962
  const requestPath = source.slice(0, -"?module".length);
1768
- const resolvedPath = path11.isAbsolute(requestPath) ? requestPath : path11.resolve(path11.dirname(importer.split("?", 1)[0]), requestPath);
1963
+ const resolvedPath = path12.isAbsolute(requestPath) ? requestPath : path12.resolve(path12.dirname(importer.split("?", 1)[0]), requestPath);
1769
1964
  return `${FARM_METADATA_IMAGE_WASM_PREFIX}${resolvedPath}`;
1770
1965
  },
1771
1966
  load(id) {
@@ -1790,11 +1985,11 @@ function collectSSRExternalPackages(ssrBundle) {
1790
1985
  for (const importId of [...output.imports, ...output.dynamicImports]) {
1791
1986
  const normalizedImportId = importId.replace(/\\/g, "/");
1792
1987
  const normalizedId = normalizedImportId.replace(/^\.\//, "");
1793
- const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path11.posix.normalize(path11.posix.join(path11.posix.dirname(fileName), normalizedImportId)) : null;
1988
+ const resolvedRelativeId = normalizedImportId.startsWith("./") || normalizedImportId.startsWith("../") ? path12.posix.normalize(path12.posix.join(path12.posix.dirname(fileName), normalizedImportId)) : null;
1794
1989
  if (emittedFiles.has(normalizedId) || resolvedRelativeId !== null && emittedFiles.has(resolvedRelativeId) || NODE_BUILTIN_MODULES.has(importId) || importId.startsWith("node:")) {
1795
1990
  continue;
1796
1991
  }
1797
- if (path11.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
1992
+ if (path12.isAbsolute(importId) || /^[A-Za-z]:[\\/]/.test(importId) || importId.startsWith("#") || importId.startsWith("\0")) {
1798
1993
  externalPackages.add(importId);
1799
1994
  continue;
1800
1995
  }
@@ -1806,15 +2001,15 @@ function collectSSRExternalPackages(ssrBundle) {
1806
2001
  return externalPackages;
1807
2002
  }
1808
2003
  function createExternalSSRBundlePlugin(nitroEntryPath, ssrOutputDir, ssrEntryFile) {
1809
- const resolvedNitroEntry = path11.resolve(nitroEntryPath);
1810
- const resolvedSSREntry = path11.resolve(ssrOutputDir, ssrEntryFile);
2004
+ const resolvedNitroEntry = path12.resolve(nitroEntryPath);
2005
+ const resolvedSSREntry = path12.resolve(ssrOutputDir, ssrEntryFile);
1811
2006
  return {
1812
2007
  name: "farm-externalize-prebuilt-ssr",
1813
2008
  resolveId(source, importer) {
1814
- if (!importer || path11.resolve(importer) !== resolvedNitroEntry) {
2009
+ if (!importer || path12.resolve(importer) !== resolvedNitroEntry) {
1815
2010
  return null;
1816
2011
  }
1817
- const resolvedImport = path11.resolve(path11.dirname(importer), source);
2012
+ const resolvedImport = path12.resolve(path12.dirname(importer), source);
1818
2013
  if (resolvedImport !== resolvedSSREntry) return null;
1819
2014
  return { id: FARM_SSR_PACKAGE_IMPORT, external: true };
1820
2015
  }
@@ -1947,13 +2142,13 @@ function trimSlashes(value) {
1947
2142
  function resolveBuildDocsContentDir(docs, root, srcDir) {
1948
2143
  const configuredContentDir = docs.contentDir || docs.config.contentDir;
1949
2144
  if (typeof configuredContentDir === "string" && configuredContentDir.trim()) {
1950
- const contentDir = path11.isAbsolute(configuredContentDir) ? configuredContentDir : path11.join(root, configuredContentDir);
2145
+ const contentDir = path12.isAbsolute(configuredContentDir) ? configuredContentDir : path12.join(root, configuredContentDir);
1951
2146
  return existsSync2(contentDir) ? contentDir : null;
1952
2147
  }
1953
2148
  const entryDir = docs.config.entry || trimSlashes(docs.entry) || "docs";
1954
- const appDocsDir = path11.join(root, srcDir || "src", "app", entryDir);
2149
+ const appDocsDir = path12.join(root, srcDir || "src", "app", entryDir);
1955
2150
  if (existsSync2(appDocsDir)) return appDocsDir;
1956
- const rootDocsDir = path11.join(root, entryDir);
2151
+ const rootDocsDir = path12.join(root, entryDir);
1957
2152
  return existsSync2(rootDocsDir) ? rootDocsDir : null;
1958
2153
  }
1959
2154
  function hasProjectPostcssConfig(root) {
@@ -1970,7 +2165,7 @@ function hasProjectPostcssConfig(root) {
1970
2165
  ".postcssrc.mjs",
1971
2166
  ".postcssrc.ts"
1972
2167
  ];
1973
- const projectRequire = createRequire(path11.join(root, "package.json"));
2168
+ const projectRequire = createRequire2(path12.join(root, "package.json"));
1974
2169
  return candidates.some((file) => {
1975
2170
  try {
1976
2171
  projectRequire.resolve(`./${file}`);
@@ -1993,7 +2188,7 @@ async function findFarmConfigPath(root) {
1993
2188
  "config.mjs"
1994
2189
  ];
1995
2190
  for (const candidate of candidates) {
1996
- const resolvedPath = path11.join(root, candidate);
2191
+ const resolvedPath = path12.join(root, candidate);
1997
2192
  try {
1998
2193
  await fs4.access(resolvedPath);
1999
2194
  return resolvedPath;
@@ -2002,14 +2197,6 @@ async function findFarmConfigPath(root) {
2002
2197
  }
2003
2198
  return null;
2004
2199
  }
2005
- function hasFarmServerRuntimePlugins(config) {
2006
- return (config.plugins || []).some((plugin) => {
2007
- if (getFarmIntegrationPluginServerRuntime(plugin) === false) return false;
2008
- return Boolean(
2009
- plugin.setup || plugin.init || plugin.ready || plugin.shutdown || plugin.runtime || plugin.router || plugin.render || plugin.beforeRouteMatch || plugin.afterRouteMatch || plugin.beforeRender || plugin.afterRender || plugin.onError || plugin.transformHTML
2010
- );
2011
- });
2012
- }
2013
2200
  function hasFarmPluginRoutes(config) {
2014
2201
  return (config.plugins || []).some((plugin) => Boolean(plugin.routes));
2015
2202
  }
@@ -2038,7 +2225,7 @@ async function discoverMiddlewareRoutes(appDir) {
2038
2225
  discovered.push({
2039
2226
  path: routePath,
2040
2227
  directory,
2041
- filePath: path11.join(dir, middlewareFile.name)
2228
+ filePath: path12.join(dir, middlewareFile.name)
2042
2229
  });
2043
2230
  }
2044
2231
  for (const entry of entries) {
@@ -2046,7 +2233,7 @@ async function discoverMiddlewareRoutes(appDir) {
2046
2233
  continue;
2047
2234
  }
2048
2235
  await walk(
2049
- path11.join(dir, entry.name),
2236
+ path12.join(dir, entry.name),
2050
2237
  appendMiddlewareRoutePath(routePath, entry.name),
2051
2238
  appendMiddlewareDirectory(directory, entry.name),
2052
2239
  discovered
@@ -2122,7 +2309,7 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2122
2309
  logger.info(`\u{1F4CB} Found ${pageRoutes.length} page routes`);
2123
2310
  const fs4 = await import("fs/promises");
2124
2311
  const layoutRoutes = [];
2125
- const appDir = path11.join(root, srcDir, "app");
2312
+ const appDir = path12.join(root, srcDir, "app");
2126
2313
  async function findLayoutsForClient(dir, routePrefix = "/") {
2127
2314
  try {
2128
2315
  const entries = await fs4.readdir(dir, { withFileTypes: true });
@@ -2130,11 +2317,11 @@ async function buildUniversal(config, routeManager, apiRouteManager, serverRende
2130
2317
  if (entry.isFile() && entry.name.match(/^layout\.(tsx?|jsx?|vue|svelte)$/)) {
2131
2318
  layoutRoutes.push({
2132
2319
  pattern: routePrefix,
2133
- modulePath: path11.join(dir, entry.name)
2320
+ modulePath: path12.join(dir, entry.name)
2134
2321
  });
2135
2322
  } else if (entry.isDirectory() && !entry.name.startsWith(".") && !entry.name.startsWith("_")) {
2136
2323
  const childPrefix = routePrefix === "/" ? `/${entry.name}` : `${routePrefix}/${entry.name}`;
2137
- await findLayoutsForClient(path11.join(dir, entry.name), childPrefix);
2324
+ await findLayoutsForClient(path12.join(dir, entry.name), childPrefix);
2138
2325
  }
2139
2326
  }
2140
2327
  } catch {
@@ -2158,7 +2345,7 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2158
2345
  );
2159
2346
  }
2160
2347
  const hydrationPlanCache = /* @__PURE__ */ new Map();
2161
- const clientOutputDir = path11.join(root, distDir, "client");
2348
+ const clientOutputDir = path12.join(root, distDir, "client");
2162
2349
  const [productionViteResult] = await productionViteResultPromise;
2163
2350
  if (productionViteResult.status === "rejected") {
2164
2351
  await routeRuntimeManifestResultPromise;
@@ -2283,10 +2470,10 @@ ${islandsErrors.map((error) => ` - ${error}`).join("\n")}`
2283
2470
  lifecyclePluginManager
2284
2471
  );
2285
2472
  const runtimeManifestPath = await writeFarmRouteRuntimeManifest(
2286
- path11.join(root, distDir),
2473
+ path12.join(root, distDir),
2287
2474
  routeRuntimeManifest
2288
2475
  );
2289
- logger.info(`\u{1F4CB} Route runtime manifest: ${path11.relative(root, runtimeManifestPath)}`);
2476
+ logger.info(`\u{1F4CB} Route runtime manifest: ${path12.relative(root, runtimeManifestPath)}`);
2290
2477
  } catch (error) {
2291
2478
  if (lifecyclePluginManager) {
2292
2479
  await lifecyclePluginManager.runHookParallel("onError", {
@@ -2327,8 +2514,8 @@ async function writeSSRAssetsToClient(bundle, outputDir) {
2327
2514
  await mergeBuiltFontCss(outputDir, output.source);
2328
2515
  continue;
2329
2516
  }
2330
- const filePath = path11.join(outputDir, fileName);
2331
- await fs4.mkdir(path11.dirname(filePath), { recursive: true });
2517
+ const filePath = path12.join(outputDir, fileName);
2518
+ await fs4.mkdir(path12.dirname(filePath), { recursive: true });
2332
2519
  await fs4.writeFile(filePath, output.source);
2333
2520
  }
2334
2521
  }
@@ -2336,15 +2523,15 @@ async function copyFarmDocsFontAssetsToClient(root, outputDir) {
2336
2523
  const fs4 = await import("fs/promises");
2337
2524
  await Promise.all(
2338
2525
  resolveFarmDocsFontAssets(root).map(async ({ sourcePath, url }) => {
2339
- const targetPath = path11.join(outputDir, url.replace(/^\/+/, ""));
2340
- await fs4.mkdir(path11.dirname(targetPath), { recursive: true });
2526
+ const targetPath = path12.join(outputDir, url.replace(/^\/+/, ""));
2527
+ await fs4.mkdir(path12.dirname(targetPath), { recursive: true });
2341
2528
  await fs4.copyFile(sourcePath, targetPath);
2342
2529
  })
2343
2530
  );
2344
2531
  }
2345
2532
  async function mergeBuiltFontCss(outputDir, fontCssSource) {
2346
2533
  const fs4 = await import("fs/promises");
2347
- const fontCssPath = path11.join(outputDir, "farm-fonts.css");
2534
+ const fontCssPath = path12.join(outputDir, "farm-fonts.css");
2348
2535
  let fontCss = fontCssSource;
2349
2536
  if (fontCss === void 0) {
2350
2537
  try {
@@ -2353,7 +2540,7 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
2353
2540
  return;
2354
2541
  }
2355
2542
  }
2356
- const clientCssPath = path11.join(outputDir, "farm-client.css");
2543
+ const clientCssPath = path12.join(outputDir, "farm-client.css");
2357
2544
  let clientCss = "";
2358
2545
  try {
2359
2546
  clientCss = await fs4.readFile(clientCssPath, "utf8");
@@ -2363,6 +2550,13 @@ async function mergeBuiltFontCss(outputDir, fontCssSource) {
2363
2550
  await fs4.writeFile(fontCssPath, normalizedFontCss);
2364
2551
  await fs4.writeFile(clientCssPath, mergeFarmFontCss(clientCss, normalizedFontCss));
2365
2552
  }
2553
+ function importsFarmClientBlockedPackage(id, packageName) {
2554
+ return id === packageName || id.startsWith(`${packageName}/`);
2555
+ }
2556
+ function importsFarmApiRouteModule(id) {
2557
+ const specifier = id.replace(/\\/g, "/").split("?", 1)[0];
2558
+ return /(?:^|\/)api\/(?:.*\/)?route(?:\.[cm]?[jt]sx?)?$/.test(specifier);
2559
+ }
2366
2560
  var IncompleteClientBuildOutputError = class extends Error {
2367
2561
  constructor(detail) {
2368
2562
  super(`Farm client build produced incomplete output: ${detail}`);
@@ -2372,7 +2566,7 @@ var IncompleteClientBuildOutputError = class extends Error {
2372
2566
  async function validateClientBuildOutput(root, srcDir, outputDir) {
2373
2567
  const fs4 = await import("fs/promises");
2374
2568
  const fingerprinted = await findFingerprintedClientEntry(outputDir);
2375
- const clientEntryPath = path11.join(outputDir, fingerprinted ?? "farm-client.js");
2569
+ const clientEntryPath = path12.join(outputDir, fingerprinted ?? "farm-client.js");
2376
2570
  let clientEntrySize = 0;
2377
2571
  try {
2378
2572
  const clientEntry = await fs4.stat(clientEntryPath);
@@ -2382,8 +2576,8 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2382
2576
  if (clientEntrySize === 0) {
2383
2577
  throw new IncompleteClientBuildOutputError("farm-client.js is missing or empty");
2384
2578
  }
2385
- const clientCssPath = path11.join(outputDir, "farm-client.css");
2386
- const globalsCssPath = path11.join(root, srcDir, "app", "globals.css");
2579
+ const clientCssPath = path12.join(outputDir, "farm-client.css");
2580
+ const globalsCssPath = path12.join(root, srcDir, "app", "globals.css");
2387
2581
  let expectsCss = false;
2388
2582
  try {
2389
2583
  const globalsCss = await fs4.readFile(globalsCssPath, "utf8");
@@ -2404,7 +2598,7 @@ async function validateClientBuildOutput(root, srcDir, outputDir) {
2404
2598
  }
2405
2599
  }
2406
2600
  function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, options = {}) {
2407
- const key = `${path11.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path11.resolve(modulePath)}`;
2601
+ const key = `${path12.resolve(root)}\0${mode}\0${options.asyncOwnerIslands === true}\0${options.serverOwners === true}\0${options.serverTreeLayouts === true}\0${path12.resolve(modulePath)}`;
2408
2602
  let plan = cache.get(key);
2409
2603
  if (!plan) {
2410
2604
  plan = getClientModuleHydrationPlan(modulePath, root, mode, options);
@@ -2413,10 +2607,10 @@ function getCachedClientModuleHydrationPlan(modulePath, root, mode, cache, optio
2413
2607
  return { ...plan, isolatedBoundaries: [...plan.isolatedBoundaries] };
2414
2608
  }
2415
2609
  async function buildClient(productionVite, config, root, srcDir, outputDir, pageRoutes, layoutRoutes = [], routeSlots = [], isolatedClientBoundaryModules = /* @__PURE__ */ new Set(), hydrationPlanCache = /* @__PURE__ */ new Map(), rendererBuildLifetime, programmaticClientRoutes, mobile = false) {
2416
- if (!mobile) await removeFarmMobileClientManifest(path11.dirname(outputDir));
2610
+ if (!mobile) await removeFarmMobileClientManifest(path12.dirname(outputDir));
2417
2611
  const viteBuild = productionVite.build;
2418
2612
  const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
2419
- const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
2613
+ const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
2420
2614
  const fs4 = await import("fs/promises");
2421
2615
  const pluginManager = new PluginManager2({
2422
2616
  config,
@@ -2647,6 +2841,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2647
2841
  ) ? hydrationStrategies[0] ?? "load" : "load";
2648
2842
  const docsClientRoutes = syntheticDocsPatterns.map((pattern) => ({
2649
2843
  pattern,
2844
+ docs: true,
2650
2845
  modulePath: "",
2651
2846
  relativePath: "",
2652
2847
  pageShouldHydrate: false,
@@ -2672,10 +2867,10 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2672
2867
  `\u{1F4F1} Total hydratable routes detected: ${clientPages.length} pages, ${clientLayouts.filter((layout) => layout.shouldHydrate || layout.hasIsolatedClientBoundaries).length} layouts, and ${clientRouteSlots.length} slots`
2673
2868
  );
2674
2869
  const buildTarget = async (platform) => {
2675
- const clientEntryRoot = path11.join(root, ".farm", "tmp");
2870
+ const clientEntryRoot = path12.join(root, ".farm", "tmp");
2676
2871
  await fs4.mkdir(clientEntryRoot, { recursive: true });
2677
- const clientEntryDir = await fs4.mkdtemp(path11.join(clientEntryRoot, "client-entry-"));
2678
- const clientEntryPath = path11.join(clientEntryDir, "farm-client-entry.tsx");
2872
+ const clientEntryDir = await fs4.mkdtemp(path12.join(clientEntryRoot, "client-entry-"));
2873
+ const clientEntryPath = path12.join(clientEntryDir, "farm-client-entry.tsx");
2679
2874
  const clientHydrationCode = generateClientHydrationEntry(
2680
2875
  clientPages,
2681
2876
  clientLayouts,
@@ -2709,11 +2904,11 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2709
2904
  const clientEntry = islandsMode && platform === "web" && clientHydrationCode.includes("/*farm-router-stub*/") ? splitFarmClientRouter(clientHydrationCode) : { entry: clientHydrationCode, router: void 0 };
2710
2905
  await fs4.writeFile(clientEntryPath, clientEntry.entry);
2711
2906
  if (clientEntry.router !== void 0) {
2712
- await fs4.writeFile(path11.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
2907
+ await fs4.writeFile(path12.join(clientEntryDir, "farm-client-router.tsx"), clientEntry.router);
2713
2908
  }
2714
2909
  const clientInput = { [entryName]: clientEntryPath };
2715
2910
  if (platform === "web" && canBootFarmIslandsClient(config)) {
2716
- const clientBootPath = path11.join(clientEntryDir, "farm-client-boot.tsx");
2911
+ const clientBootPath = path12.join(clientEntryDir, "farm-client-boot.tsx");
2717
2912
  await fs4.writeFile(
2718
2913
  clientBootPath,
2719
2914
  'import { startFarmIslandsBoot } from "@farm.js/core/internal/islands-boot";\nstartFarmIslandsBoot();\n'
@@ -2730,7 +2925,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2730
2925
  if (hasScopedPostcssConfig) {
2731
2926
  logger.info("\u{1F4E6} Using project PostCSS/Tailwind configuration");
2732
2927
  } else {
2733
- const postcssConfigPath = path11.join(clientEntryDir, "postcss.config.cjs");
2928
+ const postcssConfigPath = path12.join(clientEntryDir, "postcss.config.cjs");
2734
2929
  await fs4.writeFile(postcssConfigPath, "module.exports = { plugins: [] };\n");
2735
2930
  postcssSearchPath = clientEntryDir;
2736
2931
  tailwindVitePlugin = await loadTailwindVitePlugin({
@@ -2776,7 +2971,7 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2776
2971
  // A browser cannot load a Node builtin: farmServerOnlyEntriesPlugin
2777
2972
  // resolves one to Farm's browser module for it instead.
2778
2973
  external: (id) => {
2779
- if (id === "fsevents" || id.includes("fsevents") || id.endsWith(".node")) {
2974
+ if (importsFarmClientBlockedPackage(id, "fsevents") || id.endsWith(".node")) {
2780
2975
  return true;
2781
2976
  }
2782
2977
  return false;
@@ -2786,24 +2981,24 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2786
2981
  plugins: [
2787
2982
  createFarmThemeCssPlugin(config.theme, config.basePath),
2788
2983
  createFarmPrivateClientSourcemapsPlugin({
2789
- outDir: path11.join(
2790
- path11.dirname(outputDir),
2984
+ outDir: path12.join(
2985
+ path12.dirname(outputDir),
2791
2986
  platform === "mobile" ? `${FARM_CLIENT_SOURCEMAPS_DIR}-mobile` : FARM_CLIENT_SOURCEMAPS_DIR
2792
2987
  )
2793
2988
  }),
2794
2989
  // The web client's preload manifests; the mobile client records its files instead.
2795
2990
  platform === "mobile" ? createFarmMobileClientManifestPlugin({
2796
- buildDir: path11.dirname(outputDir),
2991
+ buildDir: path12.dirname(outputDir),
2797
2992
  entryName
2798
2993
  }) : createFarmClientModulePreloadPlugin({
2799
2994
  root,
2800
- buildDir: path11.dirname(outputDir),
2995
+ buildDir: path12.dirname(outputDir),
2801
2996
  entryName: "farm-client"
2802
2997
  }),
2803
2998
  ...adapterOwnsDocsRuntime && platform === "web" ? [
2804
2999
  createFarmDocsModulePreloadPlugin({
2805
3000
  root,
2806
- buildDir: path11.dirname(outputDir),
3001
+ buildDir: path12.dirname(outputDir),
2807
3002
  importer: clientEntryPath,
2808
3003
  entryName: "farm-client",
2809
3004
  modules: [
@@ -2823,47 +3018,63 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2823
3018
  {
2824
3019
  name: "farm-client-only-imports",
2825
3020
  enforce: "pre",
2826
- resolveId(id) {
2827
- if (id === "@farm.js/core") {
2828
- return { id: "\0farm-client-exports", external: false };
2829
- }
2830
- if (id === "@farm.js/core/i18n/server") {
2831
- return { id: "\0farm-i18n-client-bridge", external: false };
2832
- }
2833
- if (id === "@farm.js/core/server" || id === "@farm.js/core/api" || id === "@farm.js/core/middleware" || id === "@farm.js/core/headers" || id === "@farm.js/core/config" || id.includes("@farm.js/core/middleware") || id.includes("@farm.js/core/query/server")) {
2834
- return { id: "\0empty-module", external: false };
2835
- }
2836
- if (id.includes("/api/") && id.includes("/route")) {
2837
- return { id: "\0empty-api-route", external: false };
2838
- }
2839
- if (id === "fsevents" || id.includes("fsevents") || id.endsWith(".node") || id === "nitro" || id === "vite" || id === "esbuild" || id === "rolldown" || id.startsWith("rolldown/") || id === "rollup" || id.startsWith("nitro/") || id.includes("node-pre-gyp") || id.includes("nf3")) {
2840
- return { id: "\0empty-module", external: false };
3021
+ resolveId: {
3022
+ // Every specifier the handler redirects, as a superset of its checks.
3023
+ filter: {
3024
+ id: /@farm\.js\/core|\/api\/|fsevents|\.node$|node-pre-gyp|nf3|^(?:nitro|vite|esbuild|rolldown|rollup)(?:\/|$)/
3025
+ },
3026
+ handler(id) {
3027
+ if (id === "@farm.js/core") {
3028
+ return { id: "\0farm-client-exports", external: false };
3029
+ }
3030
+ if (id === "@farm.js/core/i18n/server") {
3031
+ return { id: "\0farm-i18n-client-bridge", external: false };
3032
+ }
3033
+ if (id === "@farm.js/core/server" || id === "@farm.js/core/api" || id === "@farm.js/core/middleware" || id === "@farm.js/core/headers" || id === "@farm.js/core/config" || id.includes("@farm.js/core/middleware") || id.includes("@farm.js/core/query/server")) {
3034
+ return { id: "\0empty-module", external: false };
3035
+ }
3036
+ if (importsFarmApiRouteModule(id)) {
3037
+ return { id: "\0empty-api-route", external: false };
3038
+ }
3039
+ if (importsFarmClientBlockedPackage(id, "fsevents") || id.endsWith(".node") || id === "nitro" || id === "vite" || id === "esbuild" || id === "rolldown" || id.startsWith("rolldown/") || id === "rollup" || id.startsWith("nitro/") || importsFarmClientBlockedPackage(id, "node-pre-gyp") || importsFarmClientBlockedPackage(id, "@mapbox/node-pre-gyp") || importsFarmClientBlockedPackage(id, "nf3")) {
3040
+ return { id: "\0empty-module", external: false };
3041
+ }
3042
+ return null;
2841
3043
  }
2842
- return null;
2843
3044
  },
2844
- load(id) {
2845
- if (id === "\0empty-module") {
2846
- return "const emptyMiddlewareStore = new Map(); export default {}; export const getMiddlewareContext = () => emptyMiddlewareStore; export const getMiddlewareData = () => emptyMiddlewareStore; export const getMiddlewareValue = () => undefined; export const middleware = () => ({});";
2847
- }
2848
- if (id === "\0empty-api-route") {
2849
- return "export const GET = () => {}; export const HEAD = () => {}; export const QUERY = () => {}; export const POST = () => {}; export const PUT = () => {}; export const DELETE = () => {}; export const PATCH = () => {}; export const OPTIONS = () => {}; export default {};";
2850
- }
2851
- if (id === "\0farm-i18n-client-bridge") {
2852
- return 'export { createTranslator, format, getLocale, getLocaleSource, t } from "@farm.js/core/i18n/client";';
2853
- }
2854
- if (id === "\0farm-client-exports") {
2855
- return [
2856
- "// Farm.js Client Exports - Safe for browser bundling",
2857
- 'export { Link } from "@farm.js/core/client";',
2858
- 'export { useRouter } from "@farm.js/core/client";',
2859
- 'export { usePathname, useSearchParams } from "@farm.js/core/navigation";',
2860
- // A page that hydrates ships to the browser with its notFound()/redirect() calls.
2861
- 'export { getFarmRedirectError, isFarmNotFoundError, isFarmRedirectError, notFound, permanentRedirect, redirect } from "@farm.js/core/navigation";',
2862
- 'export { createAPIClient } from "@farm.js/core/client";',
2863
- 'export { localFont, remoteFont } from "@farm.js/core/font";'
2864
- ].join("\n");
3045
+ load: {
3046
+ filter: {
3047
+ id: exactIdPattern([
3048
+ "\0empty-module",
3049
+ "\0empty-api-route",
3050
+ "\0farm-i18n-client-bridge",
3051
+ "\0farm-client-exports"
3052
+ ])
3053
+ },
3054
+ handler(id) {
3055
+ if (id === "\0empty-module") {
3056
+ return "const emptyMiddlewareStore = new Map(); export default {}; export const getMiddlewareContext = () => emptyMiddlewareStore; export const getMiddlewareData = () => emptyMiddlewareStore; export const getMiddlewareValue = () => undefined; export const middleware = () => ({});";
3057
+ }
3058
+ if (id === "\0empty-api-route") {
3059
+ return "export const GET = () => {}; export const HEAD = () => {}; export const QUERY = () => {}; export const POST = () => {}; export const PUT = () => {}; export const DELETE = () => {}; export const PATCH = () => {}; export const OPTIONS = () => {}; export default {};";
3060
+ }
3061
+ if (id === "\0farm-i18n-client-bridge") {
3062
+ return 'export { createTranslator, format, getLocale, getLocaleSource, t } from "@farm.js/core/i18n/client";';
3063
+ }
3064
+ if (id === "\0farm-client-exports") {
3065
+ return [
3066
+ "// Farm.js Client Exports - Safe for browser bundling",
3067
+ 'export { Link } from "@farm.js/core/client";',
3068
+ 'export { useRouter } from "@farm.js/core/client";',
3069
+ 'export { usePathname, useSearchParams } from "@farm.js/core/navigation";',
3070
+ // A page that hydrates ships to the browser with its notFound()/redirect() calls.
3071
+ 'export { getFarmRedirectError, isFarmNotFoundError, isFarmRedirectError, notFound, permanentRedirect, redirect } from "@farm.js/core/navigation";',
3072
+ 'export { createAPIClient } from "@farm.js/core/client";',
3073
+ 'export { localFont, remoteFont } from "@farm.js/core/font";'
3074
+ ].join("\n");
3075
+ }
3076
+ return null;
2865
3077
  }
2866
- return null;
2867
3078
  }
2868
3079
  },
2869
3080
  farmPlugin(
@@ -2893,8 +3104,8 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2893
3104
  };
2894
3105
  await viteBuild(mergeFarmProductionViteConfig(clientViteConfig, config.vite));
2895
3106
  if (platform === "mobile") {
2896
- await fs4.rm(path11.join(outputDir, `${entryName}.css`), { force: true });
2897
- if (!await hasFarmMobileClientEntry(path11.dirname(outputDir), outputDir)) {
3107
+ await fs4.rm(path12.join(outputDir, `${entryName}.css`), { force: true });
3108
+ if (!await hasFarmMobileClientEntry(path12.dirname(outputDir), outputDir)) {
2898
3109
  throw new IncompleteClientBuildOutputError(
2899
3110
  `${FARM_MOBILE_CLIENT_ENTRY_NAME}.js is missing or empty`
2900
3111
  );
@@ -2915,12 +3126,12 @@ async function buildClient(productionVite, config, root, srcDir, outputDir, page
2915
3126
  }
2916
3127
  function toBakedMarkdownSourcePath(root, filePath) {
2917
3128
  if (!filePath) return "";
2918
- if (!path11.isAbsolute(filePath)) return filePath.split(path11.sep).join("/");
2919
- const relative = path11.relative(root, filePath);
2920
- if (!relative || relative.startsWith("..") || path11.isAbsolute(relative)) {
2921
- return path11.basename(filePath);
3129
+ if (!path12.isAbsolute(filePath)) return filePath.split(path12.sep).join("/");
3130
+ const relative = path12.relative(root, filePath);
3131
+ if (!relative || relative.startsWith("..") || path12.isAbsolute(relative)) {
3132
+ return path12.basename(filePath);
2922
3133
  }
2923
- return relative.split(path11.sep).join("/");
3134
+ return relative.split(path12.sep).join("/");
2924
3135
  }
2925
3136
  function generateUniversalRouterStateRuntime(streamNavigations = false) {
2926
3137
  return `
@@ -3011,6 +3222,14 @@ function hasAbsoluteNavigationHref(href) {
3011
3222
  }
3012
3223
  `.trim();
3013
3224
  }
3225
+ function generateClientPageDirectorySource() {
3226
+ return `function getFarmPageDirectory(pathname) {
3227
+ const path = getFarmRoutePathname(pathname);
3228
+ let matched = clientRouteMatcher.match(path);
3229
+ if (matched && matched.route.meta.docs) matched = clientPageRouteMatcher.match(path);
3230
+ return matched ? matched.route.meta.directory || matched.route.meta.pattern : null;
3231
+ }`;
3232
+ }
3014
3233
  function generateRuntimePathMatcherSource() {
3015
3234
  return `
3016
3235
  function normalizeRuntimePath(pathname) {
@@ -3170,30 +3389,35 @@ function encodeRuntimePathSegment(value) {
3170
3389
  }
3171
3390
 
3172
3391
  function interpolateRedirectDestination(destination, params) {
3173
- let result = destination;
3174
3392
  const catchAllParamSegments = params[farmCatchAllParamSegments] || {};
3393
+ const encodedParams = new Map();
3175
3394
  const orderedCaptures = [];
3176
3395
  for (const [key, value] of Object.entries(params)) {
3177
3396
  const segments = catchAllParamSegments[key];
3178
3397
  const encodedValue = Array.isArray(segments)
3179
3398
  ? segments.map(encodeRuntimePathSegment).join("/")
3180
3399
  : encodeRuntimePathSegment(value);
3400
+ encodedParams.set(key, encodedValue);
3181
3401
  orderedCaptures.push(encodedValue);
3182
- result = result.split("[[..." + key + "]]").join(encodedValue);
3183
- result = result.split("[..." + key + "]").join(encodedValue);
3184
- result = result.split("[" + key + "]").join(encodedValue);
3185
- result = result.split(":" + key + "*").join(encodedValue);
3186
- result = result.split(":" + key).join(encodedValue);
3187
- if (key === "wildcard") result = result.split("*").join(encodedValue);
3188
- }
3189
- // Numbered captures resolve after the named substitutions. Encoded values
3190
- // never contain "$", so this cannot rewrite an already-injected value. An
3191
- // out-of-range index resolves to "", matching the development path.
3192
- result = result.replace(/\\$(\\d+)/g, function(_whole, group) {
3193
- const captured = orderedCaptures[Number(group) - 1];
3194
- return captured === undefined ? "" : captured;
3195
- });
3196
- return result;
3402
+ }
3403
+ // One pass that reads each reference whole, as the development path does: ":id" never
3404
+ // consumes the start of ":idx", an unknown ":name" stays as written, and an injected value is
3405
+ // never read again. An out-of-range "$n" resolves to "", matching the development path.
3406
+ return destination.replace(
3407
+ /\\[\\[\\.\\.\\.(\\w+)\\]\\]|\\[\\.\\.\\.(\\w+)\\]|\\[(\\w+)\\]|:([A-Za-z0-9_]+)(\\*?)|\\$(\\d+)|\\*/g,
3408
+ function(whole, optionalCatchAll, catchAll, bracket, name, star, group) {
3409
+ if (group !== undefined) {
3410
+ const captured = orderedCaptures[Number(group) - 1];
3411
+ return captured === undefined ? "" : captured;
3412
+ }
3413
+ const wildcard = encodedParams.has("wildcard") ? encodedParams.get("wildcard") : "*";
3414
+ const key = optionalCatchAll || catchAll || bracket || name;
3415
+ if (key === undefined) return wildcard;
3416
+ if (encodedParams.has(key)) return encodedParams.get(key);
3417
+ if (name === undefined) return whole;
3418
+ return ":" + name + (star ? wildcard : "");
3419
+ },
3420
+ );
3197
3421
  }
3198
3422
  `.trim();
3199
3423
  }
@@ -3522,8 +3746,10 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
3522
3746
  const record = recover ? null : { valid: true, deploymentId, promise: null };
3523
3747
  // A navigation (not a prefetch) streams when the router supports it: the page goes in as
3524
3748
  // soon as its shell arrives, and its Suspense content follows (takeNavigationStream). A page
3525
- // whose layouts hydrate, or one rendered in this page's React root, arrives whole.
3526
- const streamShell = ${streamNavigations ? `recover && !interceptFrom && !partialHeaders["F-Render"] &&
3749
+ // whose layouts hydrate, or one rendered in this page's React root, arrives whole. So does a
3750
+ // refresh, which renders every layout again (no layout chain): like a transition, it keeps
3751
+ // the page on screen until the new one is ready, so the islands it keeps are all in it.
3752
+ const streamShell = ${streamNavigations ? `recover && layoutChain && !interceptFrom && !partialHeaders["F-Render"] &&
3527
3753
  !hasHydratableLayout(new URL(url, window.location.href).pathname)` : "false"};
3528
3754
  const request = async () => {
3529
3755
  const response = await fetchFarmNavigationDocument(url, {
@@ -3535,7 +3761,7 @@ ${streamNavigations ? ` // A streamed navigation swaps in the page's shell; its
3535
3761
  ...partialHeaders,
3536
3762
  ...(streamShell ? { "F-Stream": "flush" } : {}),
3537
3763
  }, recover, signal);
3538
- if (!response.ok) throw new Error("Failed to fetch page");
3764
+ if (!response.ok) throw new Error("Failed to fetch page: " + response.status);
3539
3765
  const store = (html) => {
3540
3766
  if (cacheResult && !signal?.aborted && generation === this.prefetchGeneration &&
3541
3767
  deploymentId === window.__FARM_DEPLOYMENT_ID__ && (!record || record.valid)) {
@@ -3950,7 +4176,7 @@ __farmConfigureApp(__farmAppSetup);` : `import React, { createRoot, hydrateRoot
3950
4176
  root,
3951
4177
  renderer.componentExtensions ?? []
3952
4178
  );
3953
- const globalsCssPath = path11.join(root, srcDir, "app", "globals.css");
4179
+ const globalsCssPath = path12.join(root, srcDir, "app", "globals.css");
3954
4180
  const serverStyleModules = [];
3955
4181
  const cssImport = [
3956
4182
  ...existsSync2(globalsCssPath) ? [globalsCssPath] : [],
@@ -4066,6 +4292,8 @@ mountFarmDocsSearch();
4066
4292
 
4067
4293
  ${generateUniversalRouterStateRuntime()}
4068
4294
 
4295
+ ${FARM_NAVIGATION_SCRIPT_SOURCE}
4296
+
4069
4297
  // SPA Router for server-rendered pages (HTML swap)
4070
4298
  const spaRouter = {
4071
4299
  ${generateUniversalRouterStateProperties()}
@@ -4236,12 +4464,7 @@ ${generateUniversalRouterStateProperties()}
4236
4464
 
4237
4465
  setTimeout(function() {
4238
4466
  Array.from(document.querySelectorAll("script")).forEach(function(script) {
4239
- const freshScript = document.createElement("script");
4240
- Array.from(script.attributes).forEach(function(attr) {
4241
- freshScript.setAttribute(attr.name, attr.value);
4242
- });
4243
- freshScript.textContent = script.textContent || "";
4244
- script.replaceWith(freshScript);
4467
+ script.replaceWith(createFarmNavigationScript(script));
4245
4468
  });
4246
4469
  }, 0);
4247
4470
 
@@ -4348,7 +4571,7 @@ document.addEventListener("click", function(e) {
4348
4571
  routeEntries.push(` {
4349
4572
  pattern: ${JSON.stringify(page.pattern)},${page.directory ? `
4350
4573
  directory: ${JSON.stringify(page.directory)},` : ""}
4351
- pageShouldHydrate: ${JSON.stringify(page.pageShouldHydrate)},
4574
+ pageShouldHydrate: ${JSON.stringify(page.pageShouldHydrate)},${page.docs ? "\n docs: true," : ""}
4352
4575
  ${page.hasIsolatedClientBoundaries ? "hasIsolatedClientBoundaries: true," : ""}
4353
4576
  islandStrategy: ${JSON.stringify(page.islandStrategy)},
4354
4577
  navigation: "html-fragment",
@@ -4449,6 +4672,12 @@ ${routeEntries.join(",\n")}
4449
4672
  const clientRouteMatcher = createFarmRouter(clientRoutes.map(function(route) {
4450
4673
  return { path: route.pattern, meta: route };
4451
4674
  }));
4675
+ ${clientPages.some((page) => page.docs) ? `const clientPageRouteMatcher = createFarmRouter(clientRoutes.filter(function(route) {
4676
+ return !route.docs;
4677
+ }).map(function(route) {
4678
+ return { path: route.pattern, meta: route };
4679
+ }));` : "const clientPageRouteMatcher = clientRouteMatcher;"}
4680
+ ${generateClientPageDirectorySource()}
4452
4681
 
4453
4682
  ${isolatedHydrationRuntime}
4454
4683
  ${routeClientGraphRuntime}
@@ -4474,10 +4703,7 @@ function getApplicableLayouts(pathname) {
4474
4703
  const urlPattern = layout.urlPattern || layout.pattern;
4475
4704
  if (urlPattern !== '/' && !isFarmRouteActive(urlPattern, normalizedPath, { exact: false })) continue;
4476
4705
  if (layout.groupScope) {
4477
- if (directory === undefined) {
4478
- const matched = matchRoute(pathname);
4479
- directory = matched ? matched.route.directory || matched.route.pattern : null;
4480
- }
4706
+ if (directory === undefined) directory = getFarmPageDirectory(pathname);
4481
4707
  if (
4482
4708
  typeof directory !== 'string' ||
4483
4709
  (directory !== layout.groupScope && !directory.startsWith(layout.groupScope + '/'))
@@ -5050,10 +5276,12 @@ async function hydrate() {
5050
5276
  }
5051
5277
  },
5052
5278
  });
5053
- ${isolatedHydrationEnabled ? `const isolatedHydration =
5279
+ ${isolatedHydrationEnabled ? `// Not cancelled with the page: a navigation disposes the islands it removes, and one in a
5280
+ // layout it keeps still waits for its trigger, as on a page of islands only.
5281
+ const isolatedHydration =
5054
5282
  !hasHydratableLayout(pathname) &&
5055
5283
  document.querySelector('f-island[src]')
5056
- ? hydrateFarmIsolatedClientBoundaries(document, hydrationController.signal)
5284
+ ? hydrateFarmIsolatedClientBoundaries(document)
5057
5285
  : Promise.resolve();
5058
5286
  await Promise.all([pageHydration, isolatedHydration]);` : "await pageHydration;"}
5059
5287
  } finally {
@@ -5099,14 +5327,11 @@ function fitsSegmentResponse(currentRoot, nextRoot) {
5099
5327
  return true;
5100
5328
  }` : ""}
5101
5329
 
5330
+ ${FARM_NAVIGATION_SCRIPT_SOURCE}
5331
+
5102
5332
  function activateNavigationScripts(root) {
5103
5333
  for (const script of Array.from(root?.querySelectorAll?.("script") || [])) {
5104
- const freshScript = document.createElement("script");
5105
- for (const attribute of Array.from(script.attributes)) {
5106
- freshScript.setAttribute(attribute.name, attribute.value);
5107
- }
5108
- freshScript.textContent = script.textContent || "";
5109
- script.replaceWith(freshScript);
5334
+ script.replaceWith(createFarmNavigationScript(script));
5110
5335
  }
5111
5336
  }
5112
5337
 
@@ -5180,8 +5405,8 @@ function removeSuspenseContent(root) {
5180
5405
  }
5181
5406
  }
5182
5407
 
5183
- // A layout's own server output, without what it wraps and without its islands, whose live DOM
5184
- // always differs from fresh HTML.
5408
+ // A layout's own server output, without what it wraps and without its islands' DOM, which live
5409
+ // always differs from fresh HTML. It keeps each island's props, so new props count as a change.
5185
5410
  function getLayoutShell(root, patterns, index) {
5186
5411
  const shell = findLayoutBoundary(root, patterns[index])?.cloneNode(true);
5187
5412
  if (!shell) return null;
@@ -5190,7 +5415,12 @@ function getLayoutShell(root, patterns, index) {
5190
5415
  : shell.querySelector("#__farm_page__");
5191
5416
  inner?.replaceChildren();
5192
5417
  removeSuspenseContent(shell);
5193
- shell.querySelectorAll("script").forEach(function(script) { script.remove(); });
5418
+ shell.querySelectorAll("script").forEach(function(script) {
5419
+ if (script.type !== "f/props") return script.remove();
5420
+ Array.from(script.attributes).forEach(function(attribute) {
5421
+ if (attribute.name !== "type") script.removeAttribute(attribute.name);
5422
+ });
5423
+ });
5194
5424
  shell.querySelectorAll("f-island").forEach(function(island) {
5195
5425
  island.replaceChildren();
5196
5426
  Array.from(island.attributes).forEach(function(attribute) {
@@ -5200,7 +5430,9 @@ function getLayoutShell(root, patterns, index) {
5200
5430
  return shell.innerHTML;
5201
5431
  }
5202
5432
 
5203
- function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5433
+ ${islandValues ? FARM_REFRESH_FIELDS_SOURCE : ""}function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5434
+ // A refresh keeps the islands still on the page: the ones in streamed Suspense content too.
5435
+ if (refresh) revealFarmStreamedContent(nextRoot);
5204
5436
  const currentPatterns = getLayoutPatterns(currentRoot);
5205
5437
  const nextPatterns = getLayoutPatterns(nextRoot);
5206
5438
  let sharedCount = 0;
@@ -5224,11 +5456,13 @@ function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5224
5456
  ? findLayoutBoundary(nextRoot, nextPatterns[sharedCount])
5225
5457
  : nextRoot.querySelector("#__farm_page__");
5226
5458
 
5227
- if (!currentTarget || !nextTarget) return false;
5459
+ if (!currentTarget || !nextTarget) return false;${islandValues ? `
5460
+ // A refresh renders the same layouts again: their fields keep what was typed, and the focus.
5461
+ const fields = refresh ? captureFarmServerFields(currentTarget) : null;` : ""}
5228
5462
  ${isolatedHydrationEnabled ? `${islandValues ? `// A refresh keeps the islands still on the page, with their state and new props.
5229
5463
  if (refresh) farmIsolatedHydrationRuntime.carryOver(currentTarget, nextTarget);
5230
5464
  ` : ""}disposeFarmIsolatedClientBoundaries(currentTarget);` : ""}
5231
- currentTarget.replaceWith(nextTarget);
5465
+ currentTarget.replaceWith(nextTarget);${islandValues ? "\n if (fields) restoreFarmServerFields(fields, nextTarget);" : ""}
5232
5466
  activateNavigationScripts(nextTarget);
5233
5467
  if (nextTreeRoot && nextTreeRoot !== nextTarget) nextTreeRoot.remove();
5234
5468
 
@@ -5236,7 +5470,17 @@ function replaceSharedLayoutBoundary(currentRoot, nextRoot, refresh = false) {
5236
5470
  const support = document.createElement("div");
5237
5471
  support.hidden = true;
5238
5472
  support.dataset.farmFragmentSupport = "true";
5239
- while (nextRoot.firstChild) support.appendChild(nextRoot.firstChild);
5473
+ while (nextRoot.firstChild) {
5474
+ const node = nextRoot.firstChild;
5475
+ // React's staged Suspense content stays in the root, where a later flush of a streamed
5476
+ // navigation reveals it; React removes it then.
5477
+ if (node.nodeType === 1 && node.matches('div[hidden][id^="S:"]')) {
5478
+ currentRoot.appendChild(node);
5479
+ activateNavigationScripts(node);
5480
+ } else {
5481
+ support.appendChild(node);
5482
+ }
5483
+ }
5240
5484
  document.body.appendChild(support);
5241
5485
  activateNavigationScripts(support);
5242
5486
  setTimeout(function() { support.remove(); }, 0);
@@ -5661,12 +5905,7 @@ ${islandValues ? ` // Islands mode: navigations name the layouts on screen, and
5661
5905
 
5662
5906
  setTimeout(function() {
5663
5907
  Array.from(document.querySelectorAll("script")).forEach(function(script) {
5664
- const freshScript = document.createElement("script");
5665
- Array.from(script.attributes).forEach(function(attr) {
5666
- freshScript.setAttribute(attr.name, attr.value);
5667
- });
5668
- freshScript.textContent = script.textContent || "";
5669
- script.replaceWith(freshScript);
5908
+ script.replaceWith(createFarmNavigationScript(script));
5670
5909
  });
5671
5910
  }, 0);
5672
5911
 
@@ -5773,7 +6012,7 @@ void hydrate();
5773
6012
  async function buildSSRInMemory(productionVite, config, root, routeManager, apiRouteManager, serverRenderer, preset, collectedPageRoutes, collectedLayoutRoutes, collectedRouteSlots, isolatedClientBoundaryModules, hydrationPlanCache, rendererBuildLifetime) {
5774
6013
  const viteBuild = productionVite.build;
5775
6014
  const { farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
5776
- const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
6015
+ const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
5777
6016
  const fs4 = await import("fs/promises");
5778
6017
  const pluginManager = new PluginManager2({
5779
6018
  config,
@@ -5789,9 +6028,9 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5789
6028
  buildLifetime: rendererBuildLifetime
5790
6029
  });
5791
6030
  if (!hasScopedPostcssConfig) {
5792
- postcssConfigDir = await fs4.mkdtemp(path11.join(os.tmpdir(), "farm-postcss-"));
6031
+ postcssConfigDir = await fs4.mkdtemp(path12.join(os.tmpdir(), "farm-postcss-"));
5793
6032
  await fs4.writeFile(
5794
- path11.join(postcssConfigDir, "postcss.config.cjs"),
6033
+ path12.join(postcssConfigDir, "postcss.config.cjs"),
5795
6034
  "module.exports = { plugins: [] };\n"
5796
6035
  );
5797
6036
  tailwindVitePlugin = await loadTailwindVitePlugin({
@@ -5893,7 +6132,13 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5893
6132
  specRoute: config.openapi.specRoute || null
5894
6133
  };
5895
6134
  }
5896
- const middlewareRoutes = await discoverMiddlewareRoutes(appDirs);
6135
+ const discoveredMiddlewareRoutes = await discoverMiddlewareRoutes(appDirs);
6136
+ const middlewareRoutes = farmTargetRunsEdgeMiddleware(preset) ? await Promise.all(
6137
+ discoveredMiddlewareRoutes.map(async (route) => ({
6138
+ ...route,
6139
+ config: await readMiddlewareFileConfig(route.filePath)
6140
+ }))
6141
+ ) : discoveredMiddlewareRoutes;
5897
6142
  const instrumentationPath = resolveFarmInstrumentationFile(root, config.srcDir || "src");
5898
6143
  const notFoundPath = resolveFarmNotFoundComponentPath(config, appDirs);
5899
6144
  if (notFoundPath) logger.info(`\u{1F4CB} Found custom 404 page: ${notFoundPath}`);
@@ -5919,7 +6164,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5919
6164
  const hasMdxComponentConfig = Boolean(config.mdx?.components);
5920
6165
  const hasMiddlewareConfig = hasFarmMiddlewareConfig(config.middleware);
5921
6166
  const hasRouteContextConfig = hasCustomFarmRouteContext(config);
5922
- const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config);
6167
+ const hasServerRuntimePlugins = hasFarmServerRuntimePlugins(config.plugins);
5923
6168
  const hasPluginRoutes = hasFarmPluginRoutes(config);
5924
6169
  const hasServerCacheConfig = hasFarmServerCacheConfig(config.cache);
5925
6170
  const configModulePath = hasServerRuntimeIntegrations || hasObservabilityHandler || hasMdxComponentConfig || hasMiddlewareConfig || hasRouteContextConfig || hasServerRuntimePlugins || hasPluginRoutes || hasServerCacheConfig || hasFarmServerStorageConfig(config.storage) || hasIntegrationProviders ? await findFarmConfigPath(root) : null;
@@ -5933,7 +6178,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5933
6178
  assertFarmDocsAdapterServesNoGuardedPages(
5934
6179
  config.docs,
5935
6180
  { root, srcDir: config.srcDir },
5936
- (pathname) => adapterGuardedPaths.has(pathname)
6181
+ (pathname) => adapterGuardedPaths.has(pathname),
6182
+ getFarmPresetRuntime(preset) === "edge" ? "edge" : "node"
5937
6183
  );
5938
6184
  }
5939
6185
  const farmDocsCspNonceMarker = createFarmCspNonce(config.security);
@@ -5962,6 +6208,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5962
6208
  if (farmDocsPrecompiledManifest && farmDocsCspNonceMarker) {
5963
6209
  farmDocsPrecompiledManifest.cspNonceMarker = farmDocsCspNonceMarker;
5964
6210
  }
6211
+ const farmDocsAnalyticsPages = await listFarmDocsAnalyticsPages(config, root, preset);
5965
6212
  const virtualEntryCode = generateVirtualEntryCode(
5966
6213
  apiRoutes,
5967
6214
  pageRoutes,
@@ -5988,7 +6235,8 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
5988
6235
  i18nCatalogs,
5989
6236
  isolatedClientBoundaryModules,
5990
6237
  hydrationPlanCache,
5991
- mobileShellLoadingRoutes
6238
+ mobileShellLoadingRoutes,
6239
+ farmDocsAnalyticsPages
5992
6240
  );
5993
6241
  const virtualEntryId = "\0virtual:farm-ssr-entry";
5994
6242
  const useExternalMetadataImageRuntime = shouldUseExternalMetadataImageRuntime(preset, true);
@@ -6138,17 +6386,23 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6138
6386
  ] : [],
6139
6387
  {
6140
6388
  name: "farm-virtual-ssr-entry",
6141
- resolveId(id) {
6142
- if (id === virtualEntryId || id === "\0virtual:farm-ssr-entry") {
6143
- return virtualEntryId;
6389
+ resolveId: {
6390
+ filter: { id: exactIdPattern([virtualEntryId, "\0virtual:farm-ssr-entry"]) },
6391
+ handler(id) {
6392
+ if (id === virtualEntryId || id === "\0virtual:farm-ssr-entry") {
6393
+ return virtualEntryId;
6394
+ }
6395
+ return null;
6144
6396
  }
6145
- return null;
6146
6397
  },
6147
- load(id) {
6148
- if (id === virtualEntryId) {
6149
- return virtualEntryCode;
6398
+ load: {
6399
+ filter: { id: exactIdPattern([virtualEntryId]) },
6400
+ handler(id) {
6401
+ if (id === virtualEntryId) {
6402
+ return virtualEntryCode;
6403
+ }
6404
+ return null;
6150
6405
  }
6151
- return null;
6152
6406
  }
6153
6407
  },
6154
6408
  {
@@ -6199,7 +6453,7 @@ async function buildSSRInMemory(productionVite, config, root, routeManager, apiR
6199
6453
  }
6200
6454
  function readFarmAppPackageIdentity(root) {
6201
6455
  try {
6202
- return JSON.parse(readFileSync(path11.join(root, "package.json"), "utf8"));
6456
+ return JSON.parse(readFileSync(path12.join(root, "package.json"), "utf8"));
6203
6457
  } catch {
6204
6458
  return {};
6205
6459
  }
@@ -6620,7 +6874,7 @@ if (typeof ReactDOMServer.configureApp !== "function") {
6620
6874
  }
6621
6875
  ReactDOMServer.configureApp(__farmAppSetup);`;
6622
6876
  }
6623
- function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache, mobileShellLoadingRoutes = []) {
6877
+ function generateVirtualEntryCode(apiRoutes, pageRoutes, layoutRoutes, routeSlots, errorRoutes, metadataImageRoutes, applicationMetadataRoutes, middlewareRoutes, redirectRoutes, configuredRewriteRoutes, configuredHeaderRoutes, openAPIReference, notFoundPath, instrumentationPath, config, farmDocsPrecompiledManifest, configModulePath, hasServerRuntimeIntegrations, hasRuntimeIntegrationConfig, hasConfiguredRuntimePlugins, hasServerRuntimePlugins, preset, i18nCatalogs, isolatedClientBoundaryModules, hydrationPlanCache, mobileShellLoadingRoutes = [], farmDocsAnalyticsPages = []) {
6624
6878
  const farmRendererDisabled = isFarmRendererDisabled(config.renderer);
6625
6879
  const farmIslandsMode = resolveFarmServerComponentsMode(config.experimental?.serverComponents) === "islands";
6626
6880
  const farmClientBoot = canBootFarmIslandsClient(config);
@@ -6690,6 +6944,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
6690
6944
  const hasGeneratedMetadataImages = metadataImageRoutes.some(
6691
6945
  (image) => image.sourceType === "module"
6692
6946
  );
6947
+ const edgeMiddlewareFilePaths = farmTargetRunsEdgeMiddleware(preset) ? middlewareRoutes.filter(isFarmEdgeMiddlewareRoute).map((route) => route.filePath) : [];
6693
6948
  const hasMiddlewareRuntime = middlewareRoutes.length > 0 || hasFarmMiddlewareConfig(config.middleware);
6694
6949
  const farmDocsFontAssets = config.docs?.enabled ? toFarmDocsPublicFontAssets(resolveFarmDocsFontAssets(config.root)) : [];
6695
6950
  const integrationProviders = getIntegrationProviders(config.integrations);
@@ -7034,6 +7289,7 @@ function renderFarmServerTreeLayout(Layout, props, outlets) {
7034
7289
  createFarmApiCatalogResponse,
7035
7290
  createFarmAppManifestResponse,
7036
7291
  farmPathGuardCoversEndpoint,
7292
+ farmPathGuardCoversPage,
7037
7293
  collectFarmLlmsTxtPages,
7038
7294
  createFarmDefaultLlmsTxt,
7039
7295
  createFarmLlmsMarkdownReader,
@@ -7144,13 +7400,15 @@ function resolveFarmMobileShellRender(request, route, routePathname) {
7144
7400
  }
7145
7401
  return loading.route.module.default;
7146
7402
  }` : ""}${farmIslandsMode ? `
7147
- import { getSharedLayoutPrefixLength, handleFarmFormActionRequest, ignoreFarmHeldValues, installFarmIslandValues, parseFarmLayoutChainHeader } from "@farm.js/core/internal/production-runtime";
7403
+ import { getFarmFormState as farmFormState, getSharedLayoutPrefixLength, handleFarmFormActionRequest, ignoreFarmHeldValues, installFarmIslandValues, parseFarmLayoutChainHeader, renderFarmFormStateScript as farmFormStateScript } from "@farm.js/core/internal/production-runtime";
7148
7404
  import { installFarmIslandsServer } from "@farm.js/core/internal/islands-server";
7149
7405
  installFarmIslandsServer();
7150
7406
  const farmFormActionsConfig = ${JSON.stringify(resolveServerActionsConfig(config.serverActions))};
7151
7407
  installFarmIslandValues();
7152
7408
  ${islandsActionKeyCode()}
7153
- ${FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME}` : ""}`;
7409
+ ${FARM_SEGMENT_NAVIGATION_SERVER_RUNTIME}` : `
7410
+ function farmFormState() { return undefined; }
7411
+ function farmFormStateScript() { return ""; }`}`;
7154
7412
  const productionSiteTelemetryImport = config.telemetry ? `import { createFarmProductionSiteReporter } from "@farm.js/core/internal/product-telemetry-runtime";` : "";
7155
7413
  const metadataImageRuntimeImport = hasGeneratedMetadataImages ? `import { createFarmMetadataImageResponse } from "@farm.js/core/internal/metadata-image-runtime";` : "";
7156
7414
  const pluginRuntimeImport = hasPluginRuntime ? `import { PluginManager } from "@farm.js/core/plugin";` : "";
@@ -7175,7 +7433,7 @@ import { fileURLToPath as farmDocsFileURLToPath } from "node:url";` : "";
7175
7433
  const markdownHandlerImport = config.md?.enabled ? `import { applyMarkdownNegotiationHeaders, createMarkdownMirrorResponse, getFarmMarkdownAlternatePath } from "@farm.js/core/markdown";` : "";
7176
7434
  const appMarkdownImport = hasMarkdownPages ? `import { FARM_MARKDOWN_ANONYMOUS_CLIENT_ADDRESS, createFarmMarkdownRouteModule, createFarmMarkdownSourceResponse, isFarmMarkdownPublicSourceResponse } from "@farm.js/core/internal/app-markdown-runtime";` : "const createFarmMarkdownSourceResponse = null;\nconst isFarmMarkdownPublicSourceResponse = null;";
7177
7435
  const markdownErrorImport = `import { FARM_MARKDOWN_CONTENT_TYPE, FARM_MARKDOWN_PAGE_CHECK_HEADER, _isFarmMarkdownPageCheck, createFarmMarkdownErrorBody, farmRequestWantsMarkdown } from "@farm.js/core/markdown";`;
7178
- const mdxComponentsPath = typeof config.mdx?.components === "string" ? path11.isAbsolute(config.mdx.components) ? config.mdx.components : path11.join(config.root, config.mdx.components) : null;
7436
+ const mdxComponentsPath = typeof config.mdx?.components === "string" ? path12.isAbsolute(config.mdx.components) ? config.mdx.components : path12.join(config.root, config.mdx.components) : null;
7179
7437
  const mdxComponentsImport = mdxComponentsPath ? `import * as FarmMdxComponentsModule from ${toVirtualEntryImportSpecifier(mdxComponentsPath)};` : "";
7180
7438
  const layerConfigPaths = (config.layers || []).map((layer) => layer.configFile).filter((configFile) => Boolean(configFile)).filter((configFile) => configFile !== configModulePath);
7181
7439
  const layerConfigImports = layerConfigPaths.map(
@@ -7678,6 +7936,19 @@ const farmDocsHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDocsP
7678
7936
  loadReactModule: async () => FarmDocsAdapterReact,
7679
7937
  // Lists the docs MCP endpoint in /.well-known/ai-catalog.json for the server's lifetime.
7680
7938
  registerMCPServer: registerFarmMCPServer,
7939
+ // A page built with this keeps its HTML string, so the preload budget and the response
7940
+ // writer use it instead of reading and re-encoding the body. Older adapters ignore it.
7941
+ createHtmlResponse: farmOwnedHtmlResponse,${farmDocsAdapterServesGuardedPages(config.docs) ? `
7942
+ // The adapter keeps pages a path guard covers off search, llms.txt, the sitemap and MCP. It
7943
+ // asks about any path its own content lists, so the guards decide here, not a page list.
7944
+ isPathGuarded: (pathname) =>
7945
+ farmPathGuardCoversPage(
7946
+ {
7947
+ config: { middleware: farmMiddlewareConfig, integrations: serverRuntimeIntegrations },
7948
+ middlewareRoutes: fileMiddlewareModules,
7949
+ },
7950
+ pathname,
7951
+ ),` : ""}
7681
7952
  })` : `createFarmDocsHandler(farmDocsResolvedConfig, {
7682
7953
  root: farmDocsRuntimeRoot,
7683
7954
  srcDir: ${JSON.stringify(config.srcDir)},
@@ -7697,7 +7968,7 @@ const farmDocsAPIHandler = ${config.docs?.enabled ? hasPrecompiledDocs ? "farmDo
7697
7968
 
7698
7969
  // API routes bundled at build time
7699
7970
  const apiRoutes = ${apiRoutes.length > 0 ? "mergePluginAPIRoutes(" : ""}[${apiRegistrations.join(",")}
7700
- ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path13, methods }) => ({ path: path13, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
7971
+ ]${apiRoutes.length > 0 ? `, configuredPlugins, ${JSON.stringify(apiRoutes.map(({ path: path14, methods }) => ({ path: path14, methods })))}, { bodySizeLimit: ${JSON.stringify(config.server.bodySizeLimit)}, dispatch: dispatchFarmPluginAPIRequest })` : ""};
7701
7972
  // A plugin calling an app endpoint (an MCP tool, say) goes through the whole
7702
7973
  // pipeline, so the endpoint's middleware and integration guards run for it.
7703
7974
  function dispatchFarmPluginAPIRequest(request) {
@@ -7839,7 +8110,7 @@ function renderFarmClientBootstrapScript(canonicalPath, selectedRouteSlots, page
7839
8110
  }
7840
8111
  return '<script id="__farm_route_slots_data__" type="application/json">' +
7841
8112
  serializedRouteSlots +
7842
- '</script>' + stampFarmCspNonce('<script>' + source + '</script>');
8113
+ '</script>' + stampFarmCspNonce('<script>' + source + '</script>') + farmFormStateScript();
7843
8114
  }
7844
8115
 
7845
8116
  // The settled defer() values the bootstrap script's props refer to, as development writes them.
@@ -7980,6 +8251,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken =
7980
8251
  typeof ReactDOMServer.renderToReadableStream === "function") {
7981
8252
  const stream = await ReactDOMServer.renderToReadableStream(element, {
7982
8253
  nonce: _resolveCurrentCspNonce(),
8254
+ formState: farmFormState(),
7983
8255
  onError(error) {
7984
8256
  // redirect()/notFound() are control flow, not render failures: the
7985
8257
  // request handler must still receive them to map the response status,
@@ -8142,6 +8414,7 @@ async function renderFarmElement(ReactDOMServer, element, routeKey, flushToken =
8142
8414
  };
8143
8415
  pipeableStream = ReactDOMServer.renderToPipeableStream(element, {
8144
8416
  nonce: _resolveCurrentCspNonce(),
8417
+ formState: farmFormState(),
8145
8418
  onShellReady() {
8146
8419
  try {
8147
8420
  pipeableStream.pipe(destination);
@@ -8257,6 +8530,12 @@ function rememberFarmSyncRender(routeKey, streamedHtml) {
8257
8530
 
8258
8531
  function renderFarmElementSync(ReactDOMServer, element, routeKey) {
8259
8532
  if (!farmReactSyncRender) return undefined;
8533
+ // renderToString takes no form state: the page a useActionState form posted to streams.
8534
+ if (farmFormState() !== undefined) return undefined;
8535
+ // renderToString takes no nonce, so the scripts React adds itself (the form replay script of a
8536
+ // form with a function action) would go out without one, and a nonce policy blocks them. A
8537
+ // response with a nonce renders with the stream, which gives them the nonce.
8538
+ if (_resolveCurrentCspNonce()) return undefined;
8260
8539
  const addsDoctype = routeKey === undefined ? undefined : farmSyncRenderRoutes.get(routeKey);
8261
8540
  if (addsDoctype === undefined) return undefined;
8262
8541
  if (typeof ReactDOMServer.renderToString !== "function") return undefined;
@@ -8670,12 +8949,8 @@ function withFarmDocsRequestCache(response, request, farmLocaleResolution, middl
8670
8949
  ) {
8671
8950
  return response;
8672
8951
  }
8673
- const headers = new Headers(response.headers);
8674
- headers.set("Cache-Control", "private, no-store");
8675
- return farmOwnedResponse(response.body, {
8676
- status: response.status,
8677
- statusText: response.statusText,
8678
- headers,
8952
+ return farmPreloadHeadersResponse(response, (headers) => {
8953
+ headers.set("Cache-Control", "private, no-store");
8679
8954
  });
8680
8955
  }
8681
8956
 
@@ -9133,13 +9408,18 @@ function matchRewriteRoute(pathname, locale) {
9133
9408
  return null;
9134
9409
  }
9135
9410
 
9411
+ // The URL the browser asked for, for a request a configured rewrite replaced.
9412
+ const farmRequestedUrls = new WeakMap();
9413
+
9136
9414
  function createRewrittenRequest(request, destination) {
9137
9415
  const sourceUrl = new URL(request.url);
9138
9416
  const destinationUrl = new URL(destination, sourceUrl);
9139
9417
  if (!destinationUrl.search && sourceUrl.search) {
9140
9418
  destinationUrl.search = sourceUrl.search;
9141
9419
  }
9142
- return new Request(destinationUrl, request);
9420
+ const rewritten = new Request(destinationUrl, request);
9421
+ farmRequestedUrls.set(rewritten, farmRequestedUrls.get(request) || request.url);
9422
+ return rewritten;
9143
9423
  }
9144
9424
 
9145
9425
  ${generateConfiguredResponseHeadersRuntimeSource()}
@@ -9147,10 +9427,17 @@ ${generateConfiguredResponseHeadersRuntimeSource()}
9147
9427
  // App middleware files bundled at build time (sorted by depth, root first)
9148
9428
  const fileMiddlewareModules = [${middlewareRegistrations.join(",")}
9149
9429
  ];
9150
-
9430
+ ${edgeMiddlewareFilePaths.length > 0 ? `
9431
+ // \`runtime: "edge"\` middleware runs as Vercel routing middleware in front of the pages the build
9432
+ // prerendered for it, so the build's own requests for those pages skip it. A page any other
9433
+ // middleware guards is never prerendered. Read once: Nitro's prerender worker sets the variable.
9434
+ const farmEdgeMiddlewareFiles = new Set(${JSON.stringify(edgeMiddlewareFilePaths)});
9435
+ const farmPrerendering =
9436
+ typeof process !== "undefined" && process.env?.${FARM_PRERENDER_ENV} === "1";
9437
+ ` : ""}
9151
9438
  const farmMiddlewareRunner = ${hasMiddlewareRuntime ? `createProductionMiddlewareRunner({
9152
9439
  config: farmMiddlewareConfig,
9153
- modules: fileMiddlewareModules,
9440
+ modules: ${edgeMiddlewareFilePaths.length > 0 ? "farmPrerendering ? fileMiddlewareModules.filter((entry) => !farmEdgeMiddlewareFiles.has(entry.filePath)) : fileMiddlewareModules" : "fileMiddlewareModules"},
9154
9441
  i18n: farmI18nConfig,
9155
9442
  server: farmServerConfig,
9156
9443
  apiBasePath: farmLocalAPIBasePath,
@@ -9415,7 +9702,8 @@ const farmBuiltInRoutePaths = new Set(${JSON.stringify(
9415
9702
  )});
9416
9703
  ${config.docs?.enabled ? `const farmDocsRouteLabelInput = {
9417
9704
  path: normalizeRuntimePath(farmDocsResolvedConfig?.entry || "/docs"),
9418
- apiPath: ${JSON.stringify(farmDocsPrecompiledManifest?.apiPath || "/api/docs")},${config.docs.roots?.length ? "\n roots: farmDocsResolvedConfig.roots.map((farmDocsRoot) => farmDocsRoot.entry)," : ""}
9705
+ apiPath: ${JSON.stringify(farmDocsPrecompiledManifest?.apiPath || "/api/docs")},${config.docs.roots?.length ? "\n roots: farmDocsResolvedConfig.roots.map((farmDocsRoot) => farmDocsRoot.entry)," : ""}${farmDocsAnalyticsPages.length ? `
9706
+ pages: new Set(${JSON.stringify(farmDocsAnalyticsPages)}),` : ""}
9419
9707
  };
9420
9708
  ` : ""}// The request's route payload, for a handler that learns what answered while it handles.
9421
9709
  const farmRouteLabelSlot = Symbol("farm.route.label.slot");
@@ -9763,6 +10051,8 @@ async function resolveFarmRequestInContext(
9763
10051
  let url = requestUrl;
9764
10052
  let pathname = url.pathname;
9765
10053
  let routePathname = getFarmRoutePathname(pathname);
10054
+ // Before middleware: a ctx.rewrite() replaces the request below.
10055
+ const farmRequestedUrl = farmRequestedUrls.get(request) || request.url;
9766
10056
 
9767
10057
  // Redirects have precedence over local routes. Configured rewrites use
9768
10058
  // after-files semantics so emitted page, API, integration, docs, image, and
@@ -9993,13 +10283,11 @@ ${hasServerRuntimeIntegrations ? `
9993
10283
  middlewareData,
9994
10284
  middlewareContext,
9995
10285
  );
9996
- const docsHeaders = new Headers(wrappedDocsResponse.headers);
9997
- docsHeaders.set("x-farm-preload-buffered", "1");
9998
- return applyProductionMiddlewareHeaders(farmOwnedResponse(wrappedDocsResponse.body, {
9999
- status: wrappedDocsResponse.status,
10000
- statusText: wrappedDocsResponse.statusText,
10001
- headers: docsHeaders,
10002
- }), middlewareHeaders);
10286
+ // In place for a page the adapter built with createHtmlResponse, so its HTML string stays.
10287
+ const bufferedDocsResponse = farmPreloadHeadersResponse(wrappedDocsResponse, (headers) => {
10288
+ headers.set("x-farm-preload-buffered", "1");
10289
+ });
10290
+ return applyProductionMiddlewareHeaders(bufferedDocsResponse, middlewareHeaders);
10003
10291
  }
10004
10292
  }
10005
10293
  ` : ""}
@@ -10263,7 +10551,7 @@ ${hasServerRuntimeIntegrations ? `
10263
10551
  if (matchedRoute && request.method === "POST") {
10264
10552
  const actionResponse = await _runWithMiddlewareData(middlewareData || {}, () =>
10265
10553
  _runWithMiddlewareContext(middlewareContext || {}, () =>
10266
- handleFarmFormActionRequest(request, farmFormActionsConfig)
10554
+ handleFarmFormActionRequest(request, farmFormActionsConfig, farmRequestedUrl)
10267
10555
  )
10268
10556
  );
10269
10557
  if (actionResponse) return applyProductionMiddlewareHeaders(actionResponse, middlewareHeaders);
@@ -11795,6 +12083,16 @@ function getEffectiveRouteRule(config, pathname) {
11795
12083
  function getManifestPageEntry(manifest, pathname) {
11796
12084
  return manifest.routes.filter((entry) => entry.kind === "page" && middlewarePatternMatches(entry.pattern, pathname)).sort((left, right) => compareRoutePatternSpecificity(left.pattern, right.pattern))[0];
11797
12085
  }
12086
+ function withFarmEdgeGuardedPrerenderHeaders(headers, edgeGuarded) {
12087
+ if (!edgeGuarded) return headers;
12088
+ const cacheHeaders = /* @__PURE__ */ new Set(["cache-control", ...CDN_CACHE_CONTROL_HEADERS]);
12089
+ return {
12090
+ ...Object.fromEntries(
12091
+ Object.entries(headers).filter(([name]) => !cacheHeaders.has(name.toLowerCase()))
12092
+ ),
12093
+ "cache-control": "private, no-store"
12094
+ };
12095
+ }
11798
12096
  function getPhysicalPrerenderBypassReason(options) {
11799
12097
  const {
11800
12098
  config,
@@ -11831,18 +12129,30 @@ function getPhysicalPrerenderBypassReason(options) {
11831
12129
  }
11832
12130
  async function getFarmDocsPrerenderPages(config, root, preset) {
11833
12131
  if (!config.docs?.enabled || !config.docs.prerender) return [];
11834
- if (!isReactRenderer(config.renderer) || !hasFarmDocsRuntimeAdapter(config.docs)) {
11835
- logger.warn(
11836
- "docs.prerender needs a docs adapter such as @farming-labs/farmjs; Farm's built-in docs renderer keeps rendering docs pages on request."
11837
- );
11838
- return [];
11839
- }
11840
12132
  if (getFarmPresetRuntime(preset) === "edge") {
11841
12133
  logger.info(
11842
12134
  `\u21AA Keeping docs pages in the edge docs snapshot: docs.prerender writes static files on Node and serverless targets, not "${preset}".`
11843
12135
  );
11844
12136
  return [];
11845
12137
  }
12138
+ if (!hasFarmDocsRuntimeAdapter(config.docs)) {
12139
+ const { pages: pages2, originDependent } = listFarmDocsBuiltInPrerenderPages(config.docs, {
12140
+ root,
12141
+ srcDir: config.srcDir
12142
+ });
12143
+ if (originDependent.length > 0) {
12144
+ logger.info(
12145
+ `\u21AA Keeping ${originDependent.length} docs page(s) rendering on request: their social image metadata is an absolute URL built from the request's origin. Set docs.socialImage.baseUrl to prerender them.`
12146
+ );
12147
+ }
12148
+ return pages2;
12149
+ }
12150
+ if (!isReactRenderer(config.renderer)) {
12151
+ logger.warn(
12152
+ `The docs adapter ${JSON.stringify(config.docs.adapter.id)} renders with React; docs.prerender keeps its pages rendering on request with the "${config.renderer.name}" renderer.`
12153
+ );
12154
+ return [];
12155
+ }
11846
12156
  const pages = await listFarmDocsAdapterPages(config.docs, { root, srcDir: config.srcDir });
11847
12157
  if (!pages) {
11848
12158
  logger.warn(
@@ -11852,6 +12162,23 @@ async function getFarmDocsPrerenderPages(config, root, preset) {
11852
12162
  }
11853
12163
  return pages;
11854
12164
  }
12165
+ async function listFarmDocsAnalyticsPages(config, root, preset) {
12166
+ if (!config.docs?.enabled || config.analytics === false || resolveFarmInstrumentationRuntime(preset) !== "nodejs") {
12167
+ return [];
12168
+ }
12169
+ try {
12170
+ return await listFarmDocsPagePaths(config.docs, {
12171
+ root,
12172
+ srcDir: config.srcDir,
12173
+ adapter: isReactRenderer(config.renderer) && hasFarmDocsRuntimeAdapter(config.docs)
12174
+ });
12175
+ } catch (error) {
12176
+ logger.warn(
12177
+ `Farm Infra analytics reports docs pages by the docs route, not each page's path: listing them failed (${error instanceof Error ? error.message : String(error)}).`
12178
+ );
12179
+ return [];
12180
+ }
12181
+ }
11855
12182
  function hasFarmNitroCacheRouteRule(routeRules) {
11856
12183
  return Object.values(routeRules || {}).some((rule) => {
11857
12184
  const swr = rule?.swr;
@@ -11870,8 +12197,8 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11870
12197
  const isVercel = preset === "vercel";
11871
12198
  const isCloudflareWorker = preset === "cloudflare-module";
11872
12199
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
11873
- const runtimeServerOutputDir = isVercel ? path11.join(outputDir, "functions", "__nitro.func") : path11.join(outputDir, "server");
11874
- const ssrOutputDir = path11.join(root, distDir, "ssr");
12200
+ const runtimeServerOutputDir = isVercel ? path12.join(outputDir, "functions", "__nitro.func") : path12.join(outputDir, "server");
12201
+ const ssrOutputDir = path12.join(root, distDir, "ssr");
11875
12202
  const imageRuntime = resolveFarmImageServerRuntime(config.images, preset);
11876
12203
  const hasGeneratedMetadataImages = Array.from(routeManager.getMetadataImages().values()).some(
11877
12204
  (image) => image.sourceType === "module"
@@ -11886,7 +12213,10 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11886
12213
  ...imageRuntime === "node" ? ["sharp"] : [],
11887
12214
  ...useExternalMetadataImageRuntime ? ["@vercel/og"] : []
11888
12215
  ]);
11889
- const isPrebuiltSSRCandidate = preset === "node-server" && [...ssrExternalPackages].every((packageName) => copiedRuntimePackages.has(packageName));
12216
+ const ssrExternalsArePackaged = [...ssrExternalPackages].every(
12217
+ (packageName) => copiedRuntimePackages.has(packageName)
12218
+ );
12219
+ const isPrebuiltSSRCandidate = preset === "node-server" && ssrExternalsArePackaged;
11890
12220
  logger.info(`\u{1F4E6} Nitro output directory: ${outputDir}`);
11891
12221
  logger.info(`\u{1F4E6} SSR entry file: ${ssrEntryFile}`);
11892
12222
  logger.info(`\u{1F4E6} Preset: ${preset}`);
@@ -11920,12 +12250,21 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11920
12250
  config: await readMiddlewareFileConfig(route.filePath)
11921
12251
  }))
11922
12252
  ) : middlewareRoutes;
12253
+ const edgeMiddlewareRoutes = farmTargetRunsEdgeMiddleware(preset) ? middlewareRoutesWithConfig.filter(isFarmEdgeMiddlewareRoute) : [];
12254
+ const serverMiddlewareRoutes = edgeMiddlewareRoutes.length > 0 ? middlewareRoutesWithConfig.filter((route) => !isFarmEdgeMiddlewareRoute(route)) : middlewareRoutesWithConfig;
12255
+ const edgeGuardedPrerenderRoutes = [];
12256
+ const addPrerenderRoute = (pathname) => {
12257
+ prerenderRoutes.push(pathname);
12258
+ if (appMiddlewareMayHandlePath(edgeMiddlewareRoutes, pathname)) {
12259
+ edgeGuardedPrerenderRoutes.push(pathname);
12260
+ }
12261
+ };
11923
12262
  for (const page of ssgPages) {
11924
12263
  if (page.revalidate !== void 0) continue;
11925
12264
  if (prerenderRoutes.includes(page.urlPath)) continue;
11926
12265
  const reason = getPhysicalPrerenderBypassReason({
11927
12266
  config,
11928
- middlewareRoutes: middlewareRoutesWithConfig,
12267
+ middlewareRoutes: serverMiddlewareRoutes,
11929
12268
  routeRuntimeManifest,
11930
12269
  redirectSources,
11931
12270
  rewriteSources,
@@ -11935,7 +12274,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11935
12274
  skippedPrerenderRoutes.push({ pathname: page.urlPath, reason });
11936
12275
  continue;
11937
12276
  }
11938
- prerenderRoutes.push(page.urlPath);
12277
+ addPrerenderRoute(page.urlPath);
11939
12278
  }
11940
12279
  const docsRouteRuntimeManifest = {
11941
12280
  ...routeRuntimeManifest,
@@ -11945,7 +12284,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11945
12284
  if (prerenderRoutes.includes(pathname)) continue;
11946
12285
  const reason = getPhysicalPrerenderBypassReason({
11947
12286
  config,
11948
- middlewareRoutes: middlewareRoutesWithConfig,
12287
+ middlewareRoutes: serverMiddlewareRoutes,
11949
12288
  routeRuntimeManifest: docsRouteRuntimeManifest,
11950
12289
  redirectSources,
11951
12290
  rewriteSources,
@@ -11955,7 +12294,7 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11955
12294
  skippedPrerenderRoutes.push({ pathname, reason });
11956
12295
  continue;
11957
12296
  }
11958
- prerenderRoutes.push(pathname);
12297
+ addPrerenderRoute(pathname);
11959
12298
  }
11960
12299
  for (const skipped of skippedPrerenderRoutes) {
11961
12300
  logger.info(`\u21AA Keeping SSG route ${skipped.pathname} server-handled (${skipped.reason})`);
@@ -11981,15 +12320,15 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
11981
12320
  resolveHashedClientCssHref(clientOutputDir),
11982
12321
  resolveHashedClientJsSrc(clientOutputDir),
11983
12322
  resolveClientBootSrc(clientOutputDir),
11984
- readFarmDocsModulePreloads(path11.join(root, distDir)),
11985
- readFarmClientModulePreloads(path11.join(root, distDir))
12323
+ readFarmDocsModulePreloads(path12.join(root, distDir)),
12324
+ readFarmClientModulePreloads(path12.join(root, distDir))
11986
12325
  ]);
11987
12326
  let nativeStylesheets;
11988
12327
  const encodedDocsModulePreloads = encodeFarmDocsModulePreloads(docsModulePreloads);
11989
12328
  const encodedClientModulePreloads = encodeFarmClientModulePreloads(clientModulePreloads);
11990
12329
  const encodedMobileShellClient = shouldBuildFarmMobileClient(config) ? encodeFarmMobileShellClient(
11991
12330
  await finalizeFarmMobileClient({
11992
- buildDir: path11.join(root, distDir),
12331
+ buildDir: path12.join(root, distDir),
11993
12332
  clientOutputDir,
11994
12333
  webEntry: clientJsSrc,
11995
12334
  webBoot: clientBootSrc,
@@ -12028,12 +12367,12 @@ async function buildNitroUniversal(config, routeManager, apiRouteManager, server
12028
12367
  await fs4.mkdir(ssrOutputDir, { recursive: true });
12029
12368
  await Promise.all(
12030
12369
  Object.entries(ssrBundle).map(async ([fileName, output]) => {
12031
- const filePath = path11.join(ssrOutputDir, fileName);
12032
- await fs4.mkdir(path11.dirname(filePath), { recursive: true });
12370
+ const filePath = path12.join(ssrOutputDir, fileName);
12371
+ await fs4.mkdir(path12.dirname(filePath), { recursive: true });
12033
12372
  await fs4.writeFile(filePath, output.type === "chunk" ? output.code : output.source);
12034
12373
  })
12035
12374
  );
12036
- const nitroEntryPath = path11.join(ssrOutputDir, "nitro-entry.mjs");
12375
+ const nitroEntryPath = path12.join(ssrOutputDir, "nitro-entry.mjs");
12037
12376
  const nodeAdapterModule = preset === "node-server" ? resolveNitroRuntimeDependency(root, "srvx/node") : null;
12038
12377
  const hasNitroCacheRouteRules = hasFarmNitroCacheRouteRule(config.routeRules);
12039
12378
  const nitroEntryCode = `
@@ -12161,12 +12500,19 @@ function resolveTrustedLocalOrigin(event, request) {
12161
12500
  : requestURL.hostname
12162
12501
  const isLoopback = (value) =>
12163
12502
  value === 'localhost' || value === '::1' || /^127(?:[.][0-9]{1,3}){3}$/.test(value)
12164
- return requestURL.protocol === protocol &&
12503
+ if (
12504
+ requestURL.protocol === protocol &&
12165
12505
  requestPort === port &&
12166
12506
  isLoopback(address) &&
12167
12507
  isLoopback(normalizedRequestHostname)
12168
- ? requestURL.origin
12169
- : undefined
12508
+ ) {
12509
+ return requestURL.origin
12510
+ }
12511
+ // Any other Host is the client's to choose, so it must not decide where a local image is
12512
+ // fetched from: the optimizer reads local sources from this server's own socket address, as the
12513
+ // development server does. A TLS socket's certificate names the public host, not this address,
12514
+ // so there the request origin still stands in.
12515
+ return socket.encrypted ? undefined : origin
12170
12516
  }
12171
12517
 
12172
12518
  // Export the event handler for Nitro
@@ -12241,20 +12587,20 @@ function toFarmNodeResponse(request, response) {
12241
12587
  );
12242
12588
  }
12243
12589
  await fs4.writeFile(
12244
- path11.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
12590
+ path12.join(ssrOutputDir, FARM_DESKTOP_ENV_MODULE_FILE),
12245
12591
  FARM_DESKTOP_ENV_MODULE_SOURCE
12246
12592
  );
12247
12593
  }
12248
- const farmNodeServerEntryPath = preset === "node-server" ? path11.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
12594
+ const farmNodeServerEntryPath = preset === "node-server" ? path12.join(ssrOutputDir, "farm-node-server-entry.mjs") : null;
12249
12595
  if (farmNodeServerEntryPath && nodeAdapterModule) {
12250
12596
  await fs4.writeFile(
12251
- path11.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
12597
+ path12.join(ssrOutputDir, FARM_NODE_ENV_MODULE_FILE),
12252
12598
  FARM_NODE_ENV_MODULE_SOURCE
12253
12599
  );
12254
12600
  await fs4.writeFile(
12255
12601
  farmNodeServerEntryPath,
12256
12602
  createFarmNodeServerEntry({
12257
- nitroEntryFile: path11.basename(nitroEntryPath),
12603
+ nitroEntryFile: path12.basename(nitroEntryPath),
12258
12604
  nodeAdapterModule,
12259
12605
  server: config.server,
12260
12606
  websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/node"),
@@ -12262,12 +12608,12 @@ function toFarmNodeResponse(request, response) {
12262
12608
  })
12263
12609
  );
12264
12610
  }
12265
- const farmBunServerEntryPath = preset === "bun" ? path11.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
12611
+ const farmBunServerEntryPath = preset === "bun" ? path12.join(ssrOutputDir, "farm-bun-server-entry.mjs") : null;
12266
12612
  if (farmBunServerEntryPath) {
12267
12613
  await fs4.writeFile(
12268
12614
  farmBunServerEntryPath,
12269
12615
  createFarmBunServerEntry({
12270
- nitroEntryFile: path11.basename(nitroEntryPath),
12616
+ nitroEntryFile: path12.basename(nitroEntryPath),
12271
12617
  bunAdapterModule: resolveNitroRuntimeDependency(root, "srvx/bun"),
12272
12618
  server: config.server,
12273
12619
  websocketAdapterModule: resolveNitroRuntimeDependency(root, "crossws/adapters/bun"),
@@ -12275,7 +12621,7 @@ function toFarmNodeResponse(request, response) {
12275
12621
  })
12276
12622
  );
12277
12623
  }
12278
- const farmNetlifyEntryPath = preset === "netlify" ? path11.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
12624
+ const farmNetlifyEntryPath = preset === "netlify" ? path12.join(ssrOutputDir, "farm-netlify-entry.mjs") : null;
12279
12625
  if (farmNetlifyEntryPath) {
12280
12626
  await fs4.writeFile(
12281
12627
  farmNetlifyEntryPath,
@@ -12284,7 +12630,7 @@ function toFarmNodeResponse(request, response) {
12284
12630
  })
12285
12631
  );
12286
12632
  }
12287
- const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path11.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
12633
+ const farmCloudflareEnvPath = preset === "cloudflare-pages" ? path12.join(ssrOutputDir, "farm-cloudflare-env.mjs") : null;
12288
12634
  if (farmCloudflareEnvPath) {
12289
12635
  await fs4.writeFile(
12290
12636
  farmCloudflareEnvPath,
@@ -12300,19 +12646,30 @@ function toFarmNodeResponse(request, response) {
12300
12646
  ssrOutputDir,
12301
12647
  ssrEntryFile
12302
12648
  );
12303
- const configuredNitroRouteRules = shouldBuildFarmMobileClient(config) ? varyFarmNitroCacheRulesByShell(routeRulesToNitroRouteRules(config.routeRules)) : routeRulesToNitroRouteRules(config.routeRules);
12649
+ const configuredNitroRouteRules = nitroRouteRulesBelowBasePath(
12650
+ shouldBuildFarmMobileClient(config) ? varyFarmNitroCacheRulesByShell(routeRulesToNitroRouteRules(config.routeRules)) : routeRulesToNitroRouteRules(config.routeRules),
12651
+ config.basePath,
12652
+ resolveFarmAPIServerBasePath(config.api)
12653
+ );
12654
+ const toPrerenderPublicPath = (route) => normalizeFarmTrailingSlashPathname(
12655
+ applyFarmBasePath(route, config.basePath),
12656
+ config.trailingSlash === true
12657
+ );
12304
12658
  const prerenderNitroRouteRules = Object.fromEntries(
12305
12659
  prerenderRoutes.map((route) => {
12306
12660
  const configuredRule = configuredNitroRouteRules[route] || {};
12307
12661
  return [
12308
- route,
12662
+ toPrerenderPublicPath(route),
12309
12663
  {
12310
12664
  ...configuredRule,
12311
12665
  prerender: true,
12312
- headers: {
12313
- ...getPrerenderRouteHeaders(route, configuredHeaderRoutes),
12314
- ...configuredRule.headers
12315
- }
12666
+ headers: withFarmEdgeGuardedPrerenderHeaders(
12667
+ {
12668
+ ...getPrerenderRouteHeaders(route, configuredHeaderRoutes),
12669
+ ...configuredRule.headers
12670
+ },
12671
+ edgeGuardedPrerenderRoutes.includes(route)
12672
+ )
12316
12673
  }
12317
12674
  ];
12318
12675
  })
@@ -12331,7 +12688,7 @@ function toFarmNodeResponse(request, response) {
12331
12688
  // `src` directory), as Nitro handlers outside Farm's aliases.
12332
12689
  serverDir: false,
12333
12690
  serverEntry: false,
12334
- buildDir: path11.join(root, distDir, ".nitro"),
12691
+ buildDir: path12.join(root, distDir, ".nitro"),
12335
12692
  alias: resolveNitroInternalRuntimeAliases(root),
12336
12693
  compatibilityDate: "2024-12-01",
12337
12694
  output: resolveFarmNitroOutputConfig(preset, outputDir),
@@ -12359,7 +12716,7 @@ function toFarmNodeResponse(request, response) {
12359
12716
  // answered independently, as by the production server, so keeping several
12360
12717
  // in flight overlaps the worker's rendering with this thread's per-route work.
12361
12718
  concurrency: Math.min(os.availableParallelism(), 8),
12362
- routes: prerenderRoutes
12719
+ routes: prerenderRoutes.map(toPrerenderPublicPath)
12363
12720
  }
12364
12721
  } : {},
12365
12722
  experimental: {
@@ -12423,7 +12780,7 @@ function toFarmNodeResponse(request, response) {
12423
12780
  if (pluginManager) {
12424
12781
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
12425
12782
  }
12426
- const expectedServerDir = path11.join(outputDir, "server");
12783
+ const expectedServerDir = path12.join(outputDir, "server");
12427
12784
  const customRollupKeys = Object.keys(nitroConfig.rollupConfig || {}).filter(
12428
12785
  (key) => key !== "external" && key !== "plugins"
12429
12786
  );
@@ -12436,11 +12793,13 @@ function toFarmNodeResponse(request, response) {
12436
12793
  snapshotSSRRebundleOptions(nitroConfig)
12437
12794
  );
12438
12795
  const requestedBuilder = nitroConfig.builder ?? process.env.NITRO_BUILDER;
12439
- const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && path11.resolve(nitroConfig.output?.serverDir || "") === path11.resolve(expectedServerDir) && Boolean(
12796
+ const nitroBuildIsFarms = (requestedBuilder === void 0 || requestedBuilder === "rollup" || requestedBuilder === "rolldown") && nitroConfig.sourcemap === false && !hasCustomOxcOptions && !hasLateBuildMutationConfig && !hasUnsupportedSSRRebundleOverrides && nitroConfig.rollupConfig?.external === nitroRollupExternal && !hasRollupPlugins(nitroConfig.rollupConfig?.plugins) && customRollupKeys.length === 0 && Boolean(
12440
12797
  nitroConfig.handlers?.some(
12441
- (handler) => path11.resolve(handler?.handler || "") === nitroEntryPath
12798
+ (handler) => path12.resolve(handler?.handler || "") === nitroEntryPath
12442
12799
  )
12443
12800
  );
12801
+ const canReusePrebuiltSSR = isPrebuiltSSRCandidate && nitroConfig.preset === "node-server" && nitroBuildIsFarms && path12.resolve(nitroConfig.output?.serverDir || "") === path12.resolve(expectedServerDir);
12802
+ const prerenderReusesPrebuiltSSR = prerenderRoutes.length > 0 && ssrExternalsArePackaged && nitroBuildIsFarms;
12444
12803
  const selectRolldownBuilder = canReusePrebuiltSSR && requestedBuilder === void 0 && await canUseRolldownBuilder();
12445
12804
  if (selectRolldownBuilder) nitroConfig.builder = "rolldown";
12446
12805
  const useRolldownBuilder = canReusePrebuiltSSR && (nitroConfig.builder ?? process.env.NITRO_BUILDER) === "rolldown";
@@ -12535,7 +12894,24 @@ function toFarmNodeResponse(request, response) {
12535
12894
  });
12536
12895
  await nitroBuilder.prepare(nitroInstance);
12537
12896
  await nitroBuilder.copyPublicAssets(nitroInstance);
12538
- if (prerenderRoutes.length > 0 && canReusePrebuiltSSR) {
12897
+ if (prerenderReusesPrebuiltSSR && !canReusePrebuiltSSR) {
12898
+ nitroInstance.hooks.hook("prerender:config", (prerendererConfig) => {
12899
+ const configuredPlugins = prerendererConfig.rollupConfig?.plugins;
12900
+ const plugins = Array.isArray(configuredPlugins) ? configuredPlugins : configuredPlugins ? [configuredPlugins] : [];
12901
+ prerendererConfig.rollupConfig = {
12902
+ ...prerendererConfig.rollupConfig,
12903
+ plugins: [...plugins.filter((plugin) => plugin !== ssrRollupPlugin), prebuiltSSRPlugin]
12904
+ };
12905
+ prerendererConfig.output = {
12906
+ ...prerendererConfig.output,
12907
+ serverDir: path12.join(
12908
+ prerendererConfig.buildDir ?? path12.join(root, distDir, ".nitro"),
12909
+ "prerender"
12910
+ )
12911
+ };
12912
+ });
12913
+ }
12914
+ if (prerenderReusesPrebuiltSSR) {
12539
12915
  nitroInstance.hooks.hook("prerender:init", (prerenderer) => {
12540
12916
  if (useRolldownBuilder) {
12541
12917
  prerenderer.hooks.hook("rollup:before", (_nitro, rollupConfig) => {
@@ -12545,10 +12921,10 @@ function toFarmNodeResponse(request, response) {
12545
12921
  });
12546
12922
  }
12547
12923
  prerenderer.hooks.hook("compiled", async () => {
12548
- const prerenderServerDir = path11.join(outputDir, "server");
12924
+ const prerenderServerDir = prerenderer.options.output.serverDir;
12549
12925
  await copyPrebuiltSSRBundle(
12550
12926
  ssrBundle,
12551
- path11.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
12927
+ path12.join(prerenderServerDir, FARM_SSR_OUTPUT_DIR),
12552
12928
  null,
12553
12929
  fs4
12554
12930
  );
@@ -12624,7 +13000,7 @@ function toFarmNodeResponse(request, response) {
12624
13000
  const copyResults = await Promise.allSettled([
12625
13001
  prebuiltSSRFilesResult.value ? writeSSRBundleFiles(
12626
13002
  prebuiltSSRFilesResult.value,
12627
- path11.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
13003
+ path12.join(outputDir, "server", FARM_SSR_OUTPUT_DIR),
12628
13004
  fs4
12629
13005
  ) : Promise.resolve(),
12630
13006
  runtimeCopyPromise
@@ -12634,14 +13010,14 @@ function toFarmNodeResponse(request, response) {
12634
13010
  );
12635
13011
  if (failedCopy) throw failedCopy.reason;
12636
13012
  if (canReusePrebuiltSSR) {
12637
- await registerPrebuiltSSRPackageImport(path11.join(outputDir, "server"), ssrEntryFile, fs4);
13013
+ await registerPrebuiltSSRPackageImport(path12.join(outputDir, "server"), ssrEntryFile, fs4);
12638
13014
  logger.info("\u26A1 Reused Farm's prebuilt SSR bundle for the Node output");
12639
13015
  }
12640
13016
  if (useRolldownBuilder) {
12641
13017
  logger.info("\u26A1 Built the Node adapter with Rolldown");
12642
13018
  }
12643
13019
  if (preset === "node-server" && !desktopServerEntry) {
12644
- await installFarmCompileCacheLauncher(path11.join(outputDir, "server"), fs4);
13020
+ await installFarmCompileCacheLauncher(path12.join(outputDir, "server"), fs4);
12645
13021
  }
12646
13022
  if (preset.startsWith("cloudflare")) {
12647
13023
  await populateCloudflareProcessEnv(nitroInstance.options.output.serverDir, fs4);
@@ -12662,7 +13038,13 @@ function toFarmNodeResponse(request, response) {
12662
13038
  config,
12663
13039
  farmWorkflows,
12664
13040
  routeRuntimeManifest,
12665
- farmCron.provider === "host" ? farmCron.jobs : []
13041
+ farmCron.provider === "host" ? farmCron.jobs : [],
13042
+ {
13043
+ buildDir: path12.join(root, distDir),
13044
+ middlewareRoutes: edgeMiddlewareRoutes,
13045
+ guardedPages: edgeGuardedPrerenderRoutes
13046
+ },
13047
+ prerenderRoutes.map(toPrerenderPublicPath)
12666
13048
  );
12667
13049
  }
12668
13050
  logger.success(`\u2705 Nitro build completed with preset: ${preset}`);
@@ -12672,29 +13054,16 @@ function resolveFarmNitroOutputConfig(preset, outputDir) {
12672
13054
  return {
12673
13055
  dir: outputDir,
12674
13056
  ...preset === "node-server" ? {
12675
- serverDir: path11.join(outputDir, "server"),
12676
- publicDir: path11.join(outputDir, "public")
13057
+ serverDir: path12.join(outputDir, "server"),
13058
+ publicDir: path12.join(outputDir, "public")
12677
13059
  } : isVercel ? {
12678
- serverDir: path11.join(outputDir, "functions", "__nitro.func"),
12679
- publicDir: path11.join(outputDir, "static")
13060
+ serverDir: path12.join(outputDir, "functions", "__nitro.func"),
13061
+ publicDir: path12.join(outputDir, "static")
12680
13062
  } : {}
12681
13063
  };
12682
13064
  }
12683
- var CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG = "nodejs_compat_populate_process_env";
12684
- var CLOUDFLARE_DO_NOT_POPULATE_PROCESS_ENV_FLAG = "nodejs_compat_do_not_populate_process_env";
12685
- var CLOUDFLARE_POPULATE_PROCESS_ENV_DATE = "2025-04-01";
12686
- function resolveCloudflareProcessEnvFlags(wrangler) {
12687
- const date = wrangler.compatibility_date;
12688
- const flags = wrangler.compatibility_flags;
12689
- if (typeof date !== "string" || date >= CLOUDFLARE_POPULATE_PROCESS_ENV_DATE) return void 0;
12690
- if (!Array.isArray(flags) || !flags.includes("nodejs_compat")) return void 0;
12691
- if (flags.includes(CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG) || flags.includes(CLOUDFLARE_DO_NOT_POPULATE_PROCESS_ENV_FLAG)) {
12692
- return void 0;
12693
- }
12694
- return [...flags, CLOUDFLARE_POPULATE_PROCESS_ENV_FLAG];
12695
- }
12696
13065
  async function populateCloudflareProcessEnv(serverDir, fs4) {
12697
- const wranglerPath = path11.join(serverDir, "wrangler.json");
13066
+ const wranglerPath = path12.join(serverDir, "wrangler.json");
12698
13067
  let source;
12699
13068
  try {
12700
13069
  source = await fs4.readFile(wranglerPath, "utf8");
@@ -12722,8 +13091,8 @@ async function writeSSRBundleFiles(files, targetDir, fs4) {
12722
13091
  await fs4.rm(targetDir, { recursive: true, force: true });
12723
13092
  await Promise.all(
12724
13093
  files.map(async ({ fileName, contents }) => {
12725
- const targetPath = path11.join(targetDir, fileName);
12726
- await fs4.mkdir(path11.dirname(targetPath), { recursive: true });
13094
+ const targetPath = path12.join(targetDir, fileName);
13095
+ await fs4.mkdir(path12.dirname(targetPath), { recursive: true });
12727
13096
  await fs4.writeFile(targetPath, contents);
12728
13097
  })
12729
13098
  );
@@ -12732,8 +13101,8 @@ async function copyPrebuiltSSRBundle(ssrBundle, targetDir, minifyOptions, fs4) {
12732
13101
  await writeSSRBundleFiles(await prepareSSRBundleFiles(ssrBundle, minifyOptions), targetDir, fs4);
12733
13102
  }
12734
13103
  async function installFarmCompileCacheLauncher(serverDir, fs4) {
12735
- const entryPath = path11.join(serverDir, "index.mjs");
12736
- const serverPath = path11.join(serverDir, FARM_SERVER_MODULE_FILE);
13104
+ const entryPath = path12.join(serverDir, "index.mjs");
13105
+ const serverPath = path12.join(serverDir, FARM_SERVER_MODULE_FILE);
12737
13106
  const entry = await fs4.readFile(entryPath, "utf8").catch((error) => {
12738
13107
  if (error.code === "ENOENT") return null;
12739
13108
  throw error;
@@ -12742,11 +13111,11 @@ async function installFarmCompileCacheLauncher(serverDir, fs4) {
12742
13111
  if (entry.includes(`./${FARM_SERVER_MODULE_FILE}`)) return false;
12743
13112
  await fs4.rename(entryPath, serverPath);
12744
13113
  await fs4.writeFile(entryPath, createFarmCompileCacheLauncher(FARM_SERVER_MODULE_FILE));
12745
- await fs4.rm(path11.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
13114
+ await fs4.rm(path12.join(serverDir, FARM_COMPILE_CACHE_DIR), { recursive: true, force: true });
12746
13115
  return true;
12747
13116
  }
12748
13117
  async function registerPrebuiltSSRPackageImport(serverDir, ssrEntryFile, fs4) {
12749
- const packagePath = path11.join(serverDir, "package.json");
13118
+ const packagePath = path12.join(serverDir, "package.json");
12750
13119
  const packageJSON = await fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
12751
13120
  if (error.code === "ENOENT") return { type: "module" };
12752
13121
  throw error;
@@ -12774,19 +13143,19 @@ async function moveVercelOutputPath(src, dest, fs4) {
12774
13143
  await fs4.cp(src, dest, { recursive: true, force: true });
12775
13144
  await fs4.rm(src, { recursive: true, force: true });
12776
13145
  }
12777
- async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs) {
12778
- const serverDir = path11.join(outputDir, "server");
12779
- const functionsDir = path11.join(outputDir, "functions");
12780
- const nitroFuncDir = path11.join(functionsDir, "__nitro.func");
12781
- const staticDir = path11.join(outputDir, "static");
12782
- const publicDir = path11.join(outputDir, "public");
13146
+ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflows, routeRuntimeManifest, cronJobs, edgeMiddleware, prerenderedPages) {
13147
+ const serverDir = path12.join(outputDir, "server");
13148
+ const functionsDir = path12.join(outputDir, "functions");
13149
+ const nitroFuncDir = path12.join(functionsDir, "__nitro.func");
13150
+ const staticDir = path12.join(outputDir, "static");
13151
+ const publicDir = path12.join(outputDir, "public");
12783
13152
  await fs4.mkdir(nitroFuncDir, { recursive: true });
12784
13153
  const serverContents = await fs4.readdir(serverDir).catch((error) => {
12785
13154
  if (error.code === "ENOENT") return [];
12786
13155
  throw error;
12787
13156
  });
12788
13157
  for (const file of serverContents) {
12789
- await moveVercelOutputPath(path11.join(serverDir, file), path11.join(nitroFuncDir, file), fs4);
13158
+ await moveVercelOutputPath(path12.join(serverDir, file), path12.join(nitroFuncDir, file), fs4);
12790
13159
  }
12791
13160
  if (serverContents.length > 0) await fs4.rm(serverDir, { recursive: true, force: true });
12792
13161
  try {
@@ -12796,7 +13165,7 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
12796
13165
  }
12797
13166
  await copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4);
12798
13167
  await copyPrismaClientForVercel(root, nitroFuncDir, fs4);
12799
- const configPath = path11.join(outputDir, "config.json");
13168
+ const configPath = path12.join(outputDir, "config.json");
12800
13169
  const configContent = await fs4.readFile(configPath, "utf-8");
12801
13170
  const vercelConfig = JSON.parse(configContent);
12802
13171
  const runtimeRoutes = await createFarmVercelRouteRuntimeFunctions(
@@ -12805,9 +13174,25 @@ async function postProcessVercelOutput(root, outputDir, fs4, config, farmWorkflo
12805
13174
  fs4,
12806
13175
  config.basePath
12807
13176
  );
13177
+ const edgeMiddlewareRoutes = edgeMiddleware.middlewareRoutes.filter(
13178
+ (route) => edgeMiddleware.guardedPages.some((pathname) => appMiddlewareMayHandlePath([route], pathname))
13179
+ );
13180
+ if (edgeMiddlewareRoutes.length > 0) {
13181
+ await writeFarmVercelEdgeMiddlewareFunction({
13182
+ root,
13183
+ outputDir,
13184
+ buildDir: edgeMiddleware.buildDir,
13185
+ config,
13186
+ routes: edgeMiddlewareRoutes,
13187
+ guardedPages: edgeMiddleware.guardedPages,
13188
+ fs: fs4
13189
+ });
13190
+ }
12808
13191
  vercelConfig.routes = buildFarmVercelRoutes({
12809
13192
  presetRoutes: Array.isArray(vercelConfig.routes) ? vercelConfig.routes : [],
12810
- runtimeRoutes
13193
+ runtimeRoutes,
13194
+ middlewareRoutes: edgeMiddlewareRoutes.length > 0 ? [createFarmVercelEdgeMiddlewareRoute(edgeMiddleware.guardedPages, config.basePath)] : [],
13195
+ canonicalSlashRoutes: createFarmVercelCanonicalSlashRoutes(prerenderedPages)
12811
13196
  });
12812
13197
  const vercelConfigWithWorkflowCrons = applyFarmWorkflowVercelCrons(
12813
13198
  vercelConfig,
@@ -12824,7 +13209,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
12824
13209
  mainRoot,
12825
13210
  root,
12826
13211
  config.srcDir,
12827
- path11.join(nitroFuncDir, "farm-docs-content"),
13212
+ path12.join(nitroFuncDir, "farm-docs-content"),
12828
13213
  fs4
12829
13214
  );
12830
13215
  for (const [index, docsRoot] of extraRoots.entries()) {
@@ -12832,7 +13217,7 @@ async function copyFarmDocsContentForVercel(config, root, nitroFuncDir, fs4) {
12832
13217
  docsRoot,
12833
13218
  root,
12834
13219
  config.srcDir,
12835
- path11.join(nitroFuncDir, "farm-docs-roots", String(index)),
13220
+ path12.join(nitroFuncDir, "farm-docs-roots", String(index)),
12836
13221
  fs4
12837
13222
  );
12838
13223
  }
@@ -12850,17 +13235,17 @@ async function copyFarmDocsRootContent(docs, root, srcDir, bundledContentDir, fs
12850
13235
  );
12851
13236
  }
12852
13237
  await fs4.rm(bundledContentDir, { recursive: true, force: true });
12853
- await fs4.mkdir(path11.dirname(bundledContentDir), { recursive: true });
13238
+ await fs4.mkdir(path12.dirname(bundledContentDir), { recursive: true });
12854
13239
  await fs4.cp(docsContentDir, bundledContentDir, {
12855
13240
  recursive: true,
12856
13241
  force: true
12857
13242
  });
12858
13243
  await fs4.writeFile(
12859
- path11.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
13244
+ path12.join(bundledContentDir, FARM_DOCS_LAST_MODIFIED_MANIFEST),
12860
13245
  `${JSON.stringify(lastModifiedManifest, null, 2)}
12861
13246
  `
12862
13247
  );
12863
- logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path11.relative(root, docsContentDir)}`);
13248
+ logger.info(`\u{1F4DA} Bundled docs content for Vercel: ${path12.relative(root, docsContentDir)}`);
12864
13249
  }
12865
13250
  function resolveServerFunctionPlatform(preset) {
12866
13251
  return preset === "vercel" || preset === "netlify" ? { os: "linux", cpu: "x64", libc: "glibc" } : null;
@@ -12877,20 +13262,20 @@ function platformFieldAllows(field, value) {
12877
13262
  }
12878
13263
  async function stageSharpRuntime(config, root, distDir, fs4, preset) {
12879
13264
  const functionPlatform = resolveServerFunctionPlatform(preset);
12880
- const projectRequire = createRequire(path11.join(root, "package.json"));
13265
+ const projectRequire = createRequire2(path12.join(root, "package.json"));
12881
13266
  let sharpRequire = projectRequire;
12882
13267
  if (!resolvePackageJson(projectRequire, "sharp")) {
12883
13268
  try {
12884
- sharpRequire = createRequire(projectRequire.resolve("@farm.js/core"));
13269
+ sharpRequire = createRequire2(projectRequire.resolve("@farm.js/core"));
12885
13270
  } catch {
12886
13271
  }
12887
13272
  }
12888
13273
  const copiedPackages = /* @__PURE__ */ new Map();
12889
13274
  const packageCopies = /* @__PURE__ */ new Map();
12890
- const stageRoot = path11.join(root, distDir, "tmp");
13275
+ const stageRoot = path12.join(root, distDir, "tmp");
12891
13276
  await fs4.mkdir(stageRoot, { recursive: true });
12892
- const stageDir = await fs4.mkdtemp(path11.join(stageRoot, "sharp-runtime-"));
12893
- const targetNodeModules = path11.join(stageDir, "node_modules");
13277
+ const stageDir = await fs4.mkdtemp(path12.join(stageRoot, "sharp-runtime-"));
13278
+ const targetNodeModules = path12.join(stageDir, "node_modules");
12894
13279
  function copyPackage(packageName, parentRequire) {
12895
13280
  const activeCopy = packageCopies.get(packageName);
12896
13281
  if (activeCopy) return activeCopy;
@@ -12903,11 +13288,11 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
12903
13288
  if (!packageJsonPath) return;
12904
13289
  const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
12905
13290
  if (functionPlatform && !packageSupportsPlatform(packageJson, functionPlatform)) return;
12906
- const packageDir = path11.dirname(packageJsonPath);
12907
- const targetDir = path11.join(targetNodeModules, ...packageName.split("/"));
13291
+ const packageDir = path12.dirname(packageJsonPath);
13292
+ const targetDir = path12.join(targetNodeModules, ...packageName.split("/"));
12908
13293
  copiedPackages.set(packageName, String(packageJson.version || "*"));
12909
- await fs4.mkdir(path11.dirname(targetDir), { recursive: true });
12910
- const packageRequire = createRequire(packageJsonPath);
13294
+ await fs4.mkdir(path12.dirname(targetDir), { recursive: true });
13295
+ const packageRequire = createRequire2(packageJsonPath);
12911
13296
  const dependencies = {
12912
13297
  ...packageJson.dependencies,
12913
13298
  ...packageJson.optionalDependencies
@@ -12941,8 +13326,8 @@ async function stageSharpRuntime(config, root, distDir, fs4, preset) {
12941
13326
  };
12942
13327
  }
12943
13328
  async function installStagedSharpRuntime(staged, nitroFuncDir, fs4) {
12944
- const stagedNodeModules = path11.join(staged.stageDir, "node_modules");
12945
- const targetNodeModules = path11.join(nitroFuncDir, "node_modules");
13329
+ const stagedNodeModules = path12.join(staged.stageDir, "node_modules");
13330
+ const targetNodeModules = path12.join(nitroFuncDir, "node_modules");
12946
13331
  try {
12947
13332
  await mergeStagedDirectory(stagedNodeModules, targetNodeModules, fs4);
12948
13333
  const functionPackage = await readNitroOutputPackage(nitroFuncDir, fs4);
@@ -12970,8 +13355,8 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
12970
13355
  const entries = await fs4.readdir(sourceDir, { withFileTypes: true });
12971
13356
  await settleAllOrThrow(
12972
13357
  entries.map(async (entry) => {
12973
- const sourcePath = path11.join(sourceDir, entry.name);
12974
- const targetPath = path11.join(targetDir, entry.name);
13358
+ const sourcePath = path12.join(sourceDir, entry.name);
13359
+ const targetPath = path12.join(targetDir, entry.name);
12975
13360
  try {
12976
13361
  await fs4.rename(sourcePath, targetPath);
12977
13362
  return;
@@ -12998,17 +13383,17 @@ async function mergeStagedDirectory(sourceDir, targetDir, fs4) {
12998
13383
  function assertMetadataImageRuntimeInstalled(root, metadataImageRoutes) {
12999
13384
  const generated = metadataImageRoutes.find((image) => image.sourceType === "module");
13000
13385
  if (!generated || resolveMetadataImageRuntimePackageJson(root)) return;
13001
- const file = generated.modulePath ? toPosixPath(path11.relative(root, generated.modulePath)) : "";
13386
+ const file = generated.modulePath ? toPosixPath(path12.relative(root, generated.modulePath)) : "";
13002
13387
  throw new Error(
13003
13388
  `${file || "A generated metadata image"} renders with @vercel/og, which is not installed. ${VERCEL_OG_INSTALL_HINT}`
13004
13389
  );
13005
13390
  }
13006
13391
  function resolveMetadataImageRuntimePackageJson(root) {
13007
- const projectRequire = createRequire(path11.join(root, "package.json"));
13392
+ const projectRequire = createRequire2(path12.join(root, "package.json"));
13008
13393
  const packageJsonPath = resolvePackageJson(projectRequire, "@vercel/og");
13009
13394
  if (packageJsonPath) return packageJsonPath;
13010
13395
  try {
13011
- return resolvePackageJson(createRequire(projectRequire.resolve("@farm.js/core")), "@vercel/og");
13396
+ return resolvePackageJson(createRequire2(projectRequire.resolve("@farm.js/core")), "@vercel/og");
13012
13397
  } catch {
13013
13398
  return null;
13014
13399
  }
@@ -13017,9 +13402,9 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
13017
13402
  const packageJsonPath = resolveMetadataImageRuntimePackageJson(root);
13018
13403
  if (!packageJsonPath) return;
13019
13404
  const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf8"));
13020
- const packageDir = path11.dirname(packageJsonPath);
13021
- const targetDir = path11.join(nitroFuncDir, "node_modules", "@vercel", "og");
13022
- await fs4.mkdir(path11.dirname(targetDir), { recursive: true });
13405
+ const packageDir = path12.dirname(packageJsonPath);
13406
+ const targetDir = path12.join(nitroFuncDir, "node_modules", "@vercel", "og");
13407
+ await fs4.mkdir(path12.dirname(targetDir), { recursive: true });
13023
13408
  await fs4.cp(packageDir, targetDir, {
13024
13409
  recursive: true,
13025
13410
  force: true,
@@ -13035,7 +13420,7 @@ async function copyMetadataImageRuntime(root, nitroFuncDir, fs4) {
13035
13420
  logger.info("\u{1F5BC}\uFE0F Bundled generated metadata image runtime");
13036
13421
  }
13037
13422
  async function readNitroOutputPackage(outputDir, fs4) {
13038
- const packagePath = path11.join(outputDir, "package.json");
13423
+ const packagePath = path12.join(outputDir, "package.json");
13039
13424
  return fs4.readFile(packagePath, "utf8").then((contents) => JSON.parse(contents)).catch((error) => {
13040
13425
  if (error.code === "ENOENT") return {};
13041
13426
  throw error;
@@ -13044,7 +13429,7 @@ async function readNitroOutputPackage(outputDir, fs4) {
13044
13429
  async function writeNitroOutputPackage(outputDir, packageJson, fs4) {
13045
13430
  await fs4.mkdir(outputDir, { recursive: true });
13046
13431
  await fs4.writeFile(
13047
- path11.join(outputDir, "package.json"),
13432
+ path12.join(outputDir, "package.json"),
13048
13433
  `${JSON.stringify(packageJson, null, 2)}
13049
13434
  `
13050
13435
  );
@@ -13060,9 +13445,9 @@ function resolvePackageJson(parentRequire, packageName) {
13060
13445
  }
13061
13446
  }
13062
13447
  try {
13063
- let directory = path11.dirname(metadataModule ?? parentRequire.resolve(packageName));
13064
- while (directory !== path11.dirname(directory)) {
13065
- const candidate = path11.join(directory, "package.json");
13448
+ let directory = path12.dirname(metadataModule ?? parentRequire.resolve(packageName));
13449
+ while (directory !== path12.dirname(directory)) {
13450
+ const candidate = path12.join(directory, "package.json");
13066
13451
  if (existsSync2(candidate)) {
13067
13452
  try {
13068
13453
  const manifest = JSON.parse(readFileSync(candidate, "utf8"));
@@ -13070,31 +13455,40 @@ function resolvePackageJson(parentRequire, packageName) {
13070
13455
  } catch {
13071
13456
  }
13072
13457
  }
13073
- if (path11.basename(directory) === "node_modules") break;
13074
- directory = path11.dirname(directory);
13458
+ if (path12.basename(directory) === "node_modules") break;
13459
+ directory = path12.dirname(directory);
13075
13460
  }
13076
13461
  } catch {
13077
13462
  }
13078
13463
  return null;
13079
13464
  }
13080
- async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13081
- const projectRequire = createRequire(path11.join(root, "package.json"));
13082
- let prismaClientDir;
13083
- try {
13084
- prismaClientDir = path11.dirname(projectRequire.resolve("@prisma/client/default.js"));
13085
- } catch {
13086
- return;
13465
+ async function resolveProjectInstalledPackageDir(root, packageName, fs4) {
13466
+ let directory = path12.resolve(root);
13467
+ while (true) {
13468
+ const candidate = path12.join(directory, "node_modules", ...packageName.split("/"));
13469
+ try {
13470
+ const packageDir = await fs4.realpath(candidate);
13471
+ if ((await fs4.stat(path12.join(packageDir, "package.json"))).isFile()) return packageDir;
13472
+ } catch {
13473
+ }
13474
+ const parent = path12.dirname(directory);
13475
+ if (parent === directory) return null;
13476
+ directory = parent;
13087
13477
  }
13088
- const generatedClientDir = path11.join(prismaClientDir, "..", "..", ".prisma", "client");
13478
+ }
13479
+ async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13480
+ const prismaClientDir = await resolveProjectInstalledPackageDir(root, "@prisma/client", fs4);
13481
+ if (!prismaClientDir) return;
13482
+ const generatedClientDir = path12.join(prismaClientDir, "..", "..", ".prisma", "client");
13089
13483
  try {
13090
13484
  await fs4.access(generatedClientDir);
13091
13485
  } catch {
13092
13486
  return;
13093
13487
  }
13094
- const targetNodeModules = path11.join(nitroFuncDir, "node_modules");
13095
- const targetPrismaScopeDir = path11.join(targetNodeModules, "@prisma");
13096
- const targetGeneratedDir = path11.join(targetNodeModules, ".prisma", "client");
13097
- const targetClientDir = path11.join(targetPrismaScopeDir, "client");
13488
+ const targetNodeModules = path12.join(nitroFuncDir, "node_modules");
13489
+ const targetPrismaScopeDir = path12.join(targetNodeModules, "@prisma");
13490
+ const targetGeneratedDir = path12.join(targetNodeModules, ".prisma", "client");
13491
+ const targetClientDir = path12.join(targetPrismaScopeDir, "client");
13098
13492
  await fs4.mkdir(targetPrismaScopeDir, { recursive: true });
13099
13493
  await fs4.cp(prismaClientDir, targetClientDir, {
13100
13494
  recursive: true,
@@ -13104,7 +13498,7 @@ async function copyPrismaClientForVercel(root, nitroFuncDir, fs4) {
13104
13498
  recursive: true,
13105
13499
  force: true
13106
13500
  });
13107
- const clientPackagePath = path11.join(prismaClientDir, "package.json");
13501
+ const clientPackagePath = path12.join(prismaClientDir, "package.json");
13108
13502
  const [functionPackage, clientPackageContent] = await Promise.all([
13109
13503
  readNitroOutputPackage(nitroFuncDir, fs4),
13110
13504
  fs4.readFile(clientPackagePath, "utf-8")
@@ -13290,9 +13684,9 @@ async function buildWithProductionNodeEnv(inputConfig, options) {
13290
13684
  } else {
13291
13685
  const { build: legacyViteBuild } = await import("vite");
13292
13686
  logger.info("\u{1F4E6} Building client bundle...");
13293
- await buildClient2(legacyViteBuild, config, root, srcDir, path12.join(root, distDir, "client"));
13687
+ await buildClient2(legacyViteBuild, config, root, srcDir, path13.join(root, distDir, "client"));
13294
13688
  logger.info("\u{1F4E6} Building SSR bundle...");
13295
- await buildSSR(legacyViteBuild, config, root, srcDir, path12.join(root, distDir, "server"));
13689
+ await buildSSR(legacyViteBuild, config, root, srcDir, path13.join(root, distDir, "server"));
13296
13690
  logger.info(`\u{1F680} Building server with Nitro (preset: ${preset})...`);
13297
13691
  await buildNitro(
13298
13692
  config,
@@ -13369,8 +13763,10 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13369
13763
  }),
13370
13764
  farmEnvironmentFunctionsPlugin(),
13371
13765
  // Route modules load here at build time (rendering config, prerendering): `server-only`
13372
- // resolves as it does in the server build.
13373
- farmServerOnlyEntriesPlugin()
13766
+ // resolves as it does in the server build. Module-entry packages load pre-bundled, as in
13767
+ // `farm dev`: unbundled, lucide-react alone is ~1,750 modules through the module runner,
13768
+ // which a docs build waited on after its bundles.
13769
+ farmServerOnlyEntriesPlugin({ prebundleServerPackages: true })
13374
13770
  ],
13375
13771
  server: {
13376
13772
  middlewareMode: true,
@@ -13390,6 +13786,12 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13390
13786
  return createViteServer({
13391
13787
  ...viteConfig,
13392
13788
  root,
13789
+ // Vite keys its pre-bundled dependencies on the config, mode included, so this server and
13790
+ // `farm dev` sharing one cache would each rebuild it after the other ran.
13791
+ cacheDir: path13.join(
13792
+ path13.resolve(root, viteConfig.cacheDir ?? path13.join("node_modules", ".vite")),
13793
+ "farm-build"
13794
+ ),
13393
13795
  configFile: false,
13394
13796
  appType: "custom",
13395
13797
  mode: "production",
@@ -13421,7 +13823,7 @@ async function createProjectModuleServer(createViteServer, config, root, buildLi
13421
13823
  }
13422
13824
  async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
13423
13825
  const { farmI18nClientBridgePlugin, farmPlugin, farmServerOnlyEntriesPlugin } = await import("./vite.mjs");
13424
- const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
13826
+ const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
13425
13827
  const pluginManager = new PluginManager2({
13426
13828
  config,
13427
13829
  isDev: false,
@@ -13448,7 +13850,7 @@ async function buildClient2(viteBuild, config, root, srcDir, outputDir) {
13448
13850
  }
13449
13851
  async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
13450
13852
  const { farmI18nClientBridgePlugin, farmPlugin } = await import("./vite.mjs");
13451
- const { PluginManager: PluginManager2 } = await import("./plugin-SAS22JL7.mjs");
13853
+ const { PluginManager: PluginManager2 } = await import("./plugin-VEBRN7A3.mjs");
13452
13854
  const pluginManager = new PluginManager2({
13453
13855
  config,
13454
13856
  isDev: false,
@@ -13480,16 +13882,16 @@ async function buildSSR(viteBuild, config, root, srcDir, outputDir) {
13480
13882
  });
13481
13883
  }
13482
13884
  function resolveLegacyPageEntry(config, root, srcDir) {
13483
- const appDir = path12.join(root, srcDir, "app");
13885
+ const appDir = path13.join(root, srcDir, "app");
13484
13886
  for (const extension of getFarmRendererComponentExtensions(config.renderer)) {
13485
- const candidate = path12.join(appDir, `page${extension}`);
13887
+ const candidate = path13.join(appDir, `page${extension}`);
13486
13888
  if (existsSync3(candidate)) return candidate;
13487
13889
  }
13488
- return path12.join(appDir, "page.tsx");
13890
+ return path13.join(appDir, "page.tsx");
13489
13891
  }
13490
13892
  async function buildNitro(config, routeManager, apiRouteManager, serverRenderer, preset, root, distDir, pluginManager) {
13491
13893
  const [{ createNitroConfig }, { createNitro, build: nitroBuild }] = await Promise.all([
13492
- import("./nitro-55YOZWRA.mjs"),
13894
+ import("./nitro-NSTXT7LB.mjs"),
13493
13895
  import("nitro/builder")
13494
13896
  ]);
13495
13897
  let nitroConfig = await createNitroConfig(
@@ -13503,18 +13905,18 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13503
13905
  nitroConfig = await pluginManager.runHookSerial("beforeNitroBuild", nitroConfig);
13504
13906
  }
13505
13907
  const outputDir = resolveDeployOutputPath(root, config.deploy.outputDir);
13506
- const serverOutputDir = path12.join(outputDir, "server");
13507
- const publicOutputDir = path12.join(outputDir, "public");
13908
+ const serverOutputDir = path13.join(outputDir, "server");
13909
+ const publicOutputDir = path13.join(outputDir, "public");
13508
13910
  const { mkdir, cp } = await import("fs/promises");
13509
13911
  await mkdir(serverOutputDir, { recursive: true });
13510
13912
  await mkdir(publicOutputDir, { recursive: true });
13511
- const clientDir = path12.join(root, distDir, "client");
13913
+ const clientDir = path13.join(root, distDir, "client");
13512
13914
  try {
13513
13915
  await mkdir(publicOutputDir, { recursive: true });
13514
13916
  await cp(clientDir, publicOutputDir, { recursive: true });
13515
13917
  logger.info("\u{1F4E6} Copied client assets to public directory");
13516
- const manifestPath = path12.join(publicOutputDir, "farm-client-manifest.json");
13517
- const assetsDir = path12.join(publicOutputDir, "assets");
13918
+ const manifestPath = path13.join(publicOutputDir, "farm-client-manifest.json");
13919
+ const assetsDir = path13.join(publicOutputDir, "assets");
13518
13920
  const manifestExists = await import("fs/promises").then(
13519
13921
  (fs4) => fs4.access(manifestPath).then(() => true).catch(() => false)
13520
13922
  );
@@ -13530,8 +13932,8 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13530
13932
  logger.error(`\u274C Failed to copy client assets: ${error}`);
13531
13933
  throw error;
13532
13934
  }
13533
- const serverDir = path12.join(root, distDir, "server");
13534
- const nitroServerDir = path12.join(root, distDir, ".nitro", "server", "farm");
13935
+ const serverDir = path13.join(root, distDir, "server");
13936
+ const nitroServerDir = path13.join(root, distDir, ".nitro", "server", "farm");
13535
13937
  try {
13536
13938
  await mkdir(nitroServerDir, { recursive: true });
13537
13939
  await cp(serverDir, nitroServerDir, { recursive: true });
@@ -13540,7 +13942,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13540
13942
  logger.warn(`Could not copy SSR bundles: ${error}`);
13541
13943
  }
13542
13944
  const nitro = await createNitro(nitroConfig);
13543
- const registryPath = path12.join(root, distDir, ".nitro", "server", "farm-registry.ts");
13945
+ const registryPath = path13.join(root, distDir, ".nitro", "server", "farm-registry.ts");
13544
13946
  try {
13545
13947
  const { farmRegistry } = await import(
13546
13948
  /* @vite-ignore */
@@ -13557,7 +13959,7 @@ async function buildNitro(config, routeManager, apiRouteManager, serverRenderer,
13557
13959
  }
13558
13960
  farmRegistry.routePaths = routePaths;
13559
13961
  try {
13560
- const clientManifestPath = path12.join(root, distDir, "client", "farm-client-manifest.json");
13962
+ const clientManifestPath = path13.join(root, distDir, "client", "farm-client-manifest.json");
13561
13963
  const { readFile } = await import("fs/promises");
13562
13964
  const manifestContent = await readFile(clientManifestPath, "utf-8");
13563
13965
  farmRegistry.clientManifest = JSON.parse(manifestContent);